/** * Create a new instance of TribePluginUpdateUtility from its JSON-encoded representation. * * @param string $json * @return TribePluginUpdateUtility */ public static function from_json($json) { //Since update-related information is simply a subset of the full plugin info, //we can parse the update JSON as if it was a plugin info string, then copy over //the parts that we care about. $pluginInfo = Tribe_PU_PluginInfo::from_json($json); if ($pluginInfo != null) { return TribePluginUpdateUtility::from_plugin_info($pluginInfo); } else { return null; } }
/** * Retrieve the latest update (if any) from the configured API endpoint. * * @uses TribePluginUpdateEngineChecker::request_info() * * @return TribePluginUpdateUtility An instance of TribePluginUpdateUtility, or NULL when no updates are available. */ function request_update() { //For the sake of simplicity, this function just calls request_info() //and transforms the result accordingly. $pluginInfo = $this->request_info(array('pu_checking_for_updates' => '1')); if ($pluginInfo == null) { return null; } //admin display for if the update check reveals that there is a new version but the API key isn't valid. if (isset($pluginInfo->api_invalid)) { //we have json_error returned let's display a message $this->json_error = $pluginInfo; add_action('admin_notices', array(&$this, 'display_json_error')); return null; } if (isset($pluginInfo->new_install_key)) { $this->update_option($this->pue_install_key, $pluginInfo->new_install_key); } //need to correct the download url so it contains the custom user data (i.e. api and any other paramaters) $download_query = $this->get_download_query(); if (!empty($download_query)) { $pluginInfo->download_url = add_query_arg($download_query, $pluginInfo->download_url); } return TribePluginUpdateUtility::from_plugin_info($pluginInfo); }