/** * Check for Updates at the defined API endpoint and modify the update array. * * This function dives into the update api just when WordPress creates its update array, * then adds a custom API call and injects the custom plugin data retrieved from the API. * It is reassembled from parts of the native WordPress plugin update code. * See wp-includes/update.php line 121 for the original wp_update_plugins() function. * * @author Vova Feldman (@svovaf) * @since 1.0.4 * * @uses FS_Api * * @param stdClass $transient_data Update array build by WordPress. * * @return array Modified update array with custom plugin data. */ function pre_set_site_transient_update_plugins_filter($transient_data) { $this->_logger->entrance(); if (empty($transient_data) || defined('WP_FS__UNINSTALL_MODE')) { return $transient_data; } if (!isset($this->_update_details)) { // Get plugin's newest update. $new_version = $this->_fs->get_update(false, false); $this->_update_details = false; if (is_object($new_version)) { $this->_logger->log('Found newer plugin version ' . $new_version->version); $plugin_details = new stdClass(); $plugin_details->slug = $this->_fs->get_slug(); $plugin_details->new_version = $new_version->version; $plugin_details->url = WP_FS__ADDRESS; $plugin_details->package = $new_version->url; $plugin_details->plugin = $this->_fs->get_plugin_basename(); /** * Cache plugin details locally since set_site_transient( 'update_plugins' ) * called multiple times and the non wp.org plugins are filtered after the * call to .org. * * @since 1.1.8.1 */ $this->_update_details = $plugin_details; } } if (is_object($this->_update_details)) { // Add plugin to transient data. $transient_data->response[$this->_fs->get_plugin_basename()] = $this->_update_details; } return $transient_data; }
/** * Check for Updates at the defined API endpoint and modify the update array. * * This function dives into the update api just when WordPress creates its update array, * then adds a custom API call and injects the custom plugin data retrieved from the API. * It is reassembled from parts of the native WordPress plugin update code. * See wp-includes/update.php line 121 for the original wp_update_plugins() function. * * @author Vova Feldman (@svovaf) * @since 1.0.4 * * @uses FS_Api * * @param stdClass $transient_data Update array build by WordPress. * * @return array Modified update array with custom plugin data. */ function pre_set_site_transient_update_plugins_filter($transient_data) { $this->_logger->entrance(); if (empty($transient_data) || defined('WP_FS__UNINSTALL_MODE')) { return $transient_data; } // Get plugin's newest update. $new_version = $this->_fs->get_update(); if (is_object($new_version)) { $this->_logger->log('Found newer plugin version ' . $new_version->version); $plugin_details = new stdClass(); $plugin_details->slug = $this->_fs->get_slug(); $plugin_details->new_version = $new_version->version; $plugin_details->url = WP_FS__ADDRESS; $plugin_details->package = $new_version->url; $plugin_details->plugin = $this->_fs->get_plugin_basename(); // Add plugin to transient data. $transient_data->response[$this->_fs->get_plugin_basename()] = $plugin_details; } return $transient_data; }