/** * Retrieve the latest update (if any) from the configured API endpoint. * * @uses Tribe__PUE__Checker::request_info() * * @return Tribe__PUE__Utility An instance of Tribe__PUE__Utility, or NULL when no updates are available. */ public 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 = esc_url_raw(add_query_arg($download_query, $pluginInfo->download_url)); } // Add plugin dirname/file (this will be expected by WordPress when it builds the plugin list table) $pluginInfo->plugin = $this->get_plugin_file(); return Tribe__PUE__Utility::from_plugin_info($pluginInfo); }
/** * Retrieve the latest update (if any) from the configured API endpoint. * * @uses Tribe__PUE__Checker::request_info() * * @return Tribe__PUE__Utility An instance of Tribe__PUE__Utility, or NULL when no updates are available. */ public function request_update() { // For the sake of simplicity, this function just calls request_info() // and transforms the result accordingly. $args = array('pu_checking_for_updates' => 1); if (!empty($_POST['key'])) { $args['pu_install_key'] = $_POST['key']; } elseif (!empty($_POST[$this->pue_install_key])) { $args['pu_install_key'] = $_POST[$this->pue_install_key]; } $this->plugin_info = $plugin_info = $this->license_key_status($args); if (null === $plugin_info) { 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($plugin_info->api_invalid)) { $plugin_info = Tribe__PUE__Utility::from_plugin_info($plugin_info); $plugin_info->license_error = $this->get_api_message($plugin_info); return $plugin_info; } if (isset($plugin_info->new_install_key)) { $this->update_option($this->pue_install_key, $plugin_info->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)) { $plugin_info->download_url = esc_url_raw(add_query_arg($download_query, $plugin_info->download_url)); } // Add plugin dirname/file (this will be expected by WordPress when it builds the plugin list table) $plugin_info->plugin = $this->get_plugin_file(); return Tribe__PUE__Utility::from_plugin_info($plugin_info); }