/** * @param StdClass|null $updates * @param PluginUpdate $updateToAdd * @return StdClass */ private function addUpdateToList($updates, $updateToAdd) { if (!is_object($updates)) { $updates = new StdClass(); $updates->response = array(); } $wpUpdate = $updateToAdd->toWpFormat(); $pluginFile = $this->pluginFile; if ($this->isMuPlugin()) { //WP does not support automatic update installation for mu-plugins, but we can still display a notice. $wpUpdate->package = null; $pluginFile = $this->muPluginFile; } $updates->response[$pluginFile] = $wpUpdate; return $updates; }
/** * Load the update checker state from the DB. * * @return StdClass|null */ public function getUpdateState() { $state = get_site_option($this->option_db_name, null); if (empty($state) || !is_array($state)) { $state = null; } if (!empty($state) && isset($state['update_info']) && is_object($state['update_info'])) { $state['update_info'] = PluginUpdate::fromObject($state['update_info']); } return $state; }
/** * Create a new instance of PluginUpdate from its JSON-encoded representation. * * @param string $json * @param bool $triggerErrors * @return PluginUpdate|null */ public static function fromJson($json, $triggerErrors = false) { //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 = PluginInfo::fromJson($json, $triggerErrors); if ($pluginInfo != null) { return PluginUpdate::fromPluginInfo($pluginInfo); } else { return null; } }
/** * Retrieve the latest update (if any) from the configured API endpoint. * * @uses PluginUpdateChecker::requestInfo() * * @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available. */ function requestUpdate() { //For the sake of simplicity, this function just calls requestInfo() //and transforms the result accordingly. $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1')); if ($pluginInfo == null) { return null; } return PluginUpdate::fromPluginInfo($pluginInfo); }