public function pre_set_site_transient_update_plugins($data) { // // Only run after other plugins are checked. // if (empty($data->checked)) { return $data; } Themeco_Update_Api::refresh(); $update_cache = Themeco_Update_Api::get_update_cache(); if (!isset($update_cache['plugins']) || empty($update_cache['plugins'])) { return $data; } include_once ABSPATH . '/wp-admin/includes/plugin.php'; $installed_plugins = get_plugins(); foreach ((array) $installed_plugins as $plugin_file => $local) { // Only check plugins in the Themeco update cache if (!isset($update_cache['plugins'][$plugin_file])) { continue; } $remote = $update_cache['plugins'][$plugin_file]; // Version check if (version_compare($remote['new_version'], $local['Version'], '<=')) { continue; } if (!$remote['package']) { $remote['upgrade_notice'] = X_Update_API::get_validation_html_plugin_updates(); } $data->response[$plugin_file] = (object) $remote; } return $data; }
public function pre_set_site_transient_update_plugins($data) { // // Only run after other plugins are checked. // if (empty($data->checked)) { return $data; } // // Create Batch of plugins to update. // $plugins = $this->get_plugin_meta(); $batch = array(); foreach ($plugins as $slug => $plugin) { $batch[] = $plugin->product_slug; } if (!empty($batch)) { // // Request update information from the remote API. // $request = X_Update_API::get_products($batch); $remote_plugins = isset($request['products']) ? $request['products'] : array(); // // Set update info for each plugin. // foreach ($plugins as $slug => $plugin) { // // Continue if there was a response from the server for this plugin. // if (isset($remote_plugins[$plugin->product_slug])) { $remote = $remote_plugins[$plugin->product_slug]; } else { continue; } $update = array('upgrade_notice' => $remote['download_url'] == null ? X_Update_API::get_validation_html_plugin_updates() : '', 'plugin' => $slug, 'slug' => dirname($slug), 'new_version' => $remote['latest_version'], 'url' => 'http://theme.co/changelog/?iframe=true', 'package' => $remote['download_url']); $remote_is_newer = 1 === version_compare($remote['latest_version'], $plugin->local_version); if ($remote_is_newer) { $data->response[$slug] = (object) $update; } } } // Clear addon list cache delete_site_option('x_addon_list_cache'); return $data; }