api = $api; $this->api->setHttpFilterName($this->getUniqueName('request_update_options')); parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName); } public function requestUpdate() { $api = $this->api; $update = new Puc_v4p1_Theme_Update(); $update->slug = $this->slug; //Figure out which reference (tag or branch) we'll use to get the latest version of the theme. $updateSource = $api->chooseReference($this->branch); if ( $updateSource ) { $ref = $updateSource->name; $update->download_url = $updateSource->downloadUrl; } else { $ref = $this->branch; } //Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags. $remoteHeader = $this->getFileHeader($api->getRemoteFile('style.css', $ref)); $update->version = Puc_v4p1_Utils::findNotEmpty(array( $remoteHeader['Version'], Puc_v4p1_Utils::get($updateSource, 'version'), )); //The details URL defaults to the Theme URI header or the repository URL. $update->details_url = Puc_v4p1_Utils::findNotEmpty(array( $remoteHeader['ThemeURI'], $this->theme->get('ThemeURI'), $this->metadataUrl, )); if ( empty($update->version) ) { //It looks like we didn't find a valid update after all. $update = null; } $update = $this->filterUpdateResult($update); return $update; } //FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods. public function setBranch($branch) { $this->branch = $branch; return $this; } public function setAuthentication($credentials) { $this->api->setAuthentication($credentials); return $this; } public function getUpdate() { $update = parent::getUpdate(); if ( isset($update) && !empty($update->download_url) ) { $update->download_url = $this->api->signDownloadUrl($update->download_url); } return $update; } public function onDisplayConfiguration($panel) { parent::onDisplayConfiguration($panel); $panel->row('Branch', $this->branch); $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No'); $panel->row('API client', get_class($this->api)); } } endif;