From 28f29c940cc22754aff85a99645e3c0a51c097e8 Mon Sep 17 00:00:00 2001 From: Yahnis Elsts Date: Fri, 7 Feb 2020 13:07:19 +0200 Subject: [PATCH] Bump version number to 4.9 --- Puc/v4/Factory.php | 2 +- Puc/{v4p8 => v4p9}/Autoloader.php | 4 +- Puc/{v4p8 => v4p9}/DebugBar/Extension.php | 16 +++---- Puc/{v4p8 => v4p9}/DebugBar/Panel.php | 6 +-- .../DebugBar/PluginExtension.php | 8 ++-- Puc/{v4p8 => v4p9}/DebugBar/PluginPanel.php | 6 +-- Puc/{v4p8 => v4p9}/DebugBar/ThemePanel.php | 6 +-- Puc/{v4p8 => v4p9}/Factory.php | 8 ++-- Puc/{v4p8 => v4p9}/InstalledPackage.php | 6 +-- Puc/{v4p8 => v4p9}/Metadata.php | 4 +- Puc/{v4p8 => v4p9}/OAuthSignature.php | 4 +- Puc/{v4p8 => v4p9}/Plugin/Info.php | 4 +- Puc/{v4p8 => v4p9}/Plugin/Package.php | 10 ++--- Puc/{v4p8 => v4p9}/Plugin/Ui.php | 6 +-- Puc/{v4p8 => v4p9}/Plugin/Update.php | 16 +++---- Puc/{v4p8 => v4p9}/Plugin/UpdateChecker.php | 34 +++++++------- Puc/{v4p8 => v4p9}/Scheduler.php | 14 +++--- Puc/{v4p8 => v4p9}/StateStore.php | 18 ++++---- Puc/{v4p8 => v4p9}/Theme/Package.php | 4 +- Puc/{v4p8 => v4p9}/Theme/Update.php | 8 ++-- Puc/{v4p8 => v4p9}/Theme/UpdateChecker.php | 20 ++++----- Puc/{v4p8 => v4p9}/Update.php | 4 +- Puc/{v4p8 => v4p9}/UpdateChecker.php | 44 +++++++++---------- Puc/{v4p8 => v4p9}/UpgraderStatus.php | 4 +- Puc/{v4p8 => v4p9}/Utils.php | 4 +- Puc/{v4p8 => v4p9}/Vcs/Api.php | 14 +++--- Puc/{v4p8 => v4p9}/Vcs/BaseChecker.php | 6 +-- Puc/{v4p8 => v4p9}/Vcs/BitBucketApi.php | 24 +++++----- Puc/{v4p8 => v4p9}/Vcs/GitHubApi.php | 18 ++++---- Puc/{v4p8 => v4p9}/Vcs/GitLabApi.php | 16 +++---- .../Vcs/PluginUpdateChecker.php | 16 +++---- Puc/{v4p8 => v4p9}/Vcs/Reference.php | 4 +- Puc/{v4p8 => v4p9}/Vcs/ThemeUpdateChecker.php | 18 ++++---- README.md | 8 ++-- composer.json | 2 +- load-v4p8.php | 28 ------------ load-v4p9.php | 28 ++++++++++++ plugin-update-checker.php | 6 +-- 38 files changed, 224 insertions(+), 224 deletions(-) rename Puc/{v4p8 => v4p9}/Autoloader.php (93%) rename Puc/{v4p8 => v4p9}/DebugBar/Extension.php (91%) rename Puc/{v4p8 => v4p9}/DebugBar/Panel.php (96%) rename Puc/{v4p8 => v4p9}/DebugBar/PluginExtension.php (75%) rename Puc/{v4p8 => v4p9}/DebugBar/PluginPanel.php (82%) rename Puc/{v4p8 => v4p9}/DebugBar/ThemePanel.php (68%) rename Puc/{v4p8 => v4p9}/Factory.php (97%) rename Puc/{v4p8 => v4p9}/InstalledPackage.php (95%) rename Puc/{v4p8 => v4p9}/Metadata.php (97%) rename Puc/{v4p8 => v4p9}/OAuthSignature.php (96%) rename Puc/{v4p8 => v4p9}/Plugin/Info.php (97%) rename Puc/{v4p8 => v4p9}/Plugin/Package.php (94%) rename Puc/{v4p8 => v4p9}/Plugin/Ui.php (98%) rename Puc/{v4p8 => v4p9}/Plugin/Update.php (87%) rename Puc/{v4p8 => v4p9}/Plugin/UpdateChecker.php (93%) rename Puc/{v4p8 => v4p9}/Scheduler.php (95%) rename Puc/{v4p8 => v4p9}/StateStore.php (89%) rename Puc/{v4p8 => v4p9}/Theme/Package.php (93%) rename Puc/{v4p8 => v4p9}/Theme/Update.php (89%) rename Puc/{v4p8 => v4p9}/Theme/UpdateChecker.php (87%) rename Puc/{v4p8 => v4p9}/Update.php (84%) rename Puc/{v4p8 => v4p9}/UpdateChecker.php (96%) rename Puc/{v4p8 => v4p9}/UpgraderStatus.php (98%) rename Puc/{v4p8 => v4p9}/Utils.php (96%) rename Puc/{v4p8 => v4p9}/Vcs/Api.php (96%) rename Puc/{v4p8 => v4p9}/Vcs/BaseChecker.php (75%) rename Puc/{v4p8 => v4p9}/Vcs/BitBucketApi.php (92%) rename Puc/{v4p8 => v4p9}/Vcs/GitHubApi.php (96%) rename Puc/{v4p8 => v4p9}/Vcs/GitLabApi.php (95%) rename Puc/{v4p8 => v4p9}/Vcs/PluginUpdateChecker.php (93%) rename Puc/{v4p8 => v4p9}/Vcs/Reference.php (92%) rename Puc/{v4p8 => v4p9}/Vcs/ThemeUpdateChecker.php (85%) delete mode 100644 load-v4p8.php create mode 100644 load-v4p9.php diff --git a/Puc/v4/Factory.php b/Puc/v4/Factory.php index 71f2de43..3723e008 100644 --- a/Puc/v4/Factory.php +++ b/Puc/v4/Factory.php @@ -1,6 +1,6 @@ updateChecker = $updateChecker; @@ -150,11 +150,11 @@ private function getLibraryUrl($filePath) { $absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/')); //Where is the library located inside the WordPress directory structure? - $absolutePath = Puc_v4p8_Factory::normalizePath($absolutePath); + $absolutePath = Puc_v4p9_Factory::normalizePath($absolutePath); - $pluginDir = Puc_v4p8_Factory::normalizePath(WP_PLUGIN_DIR); - $muPluginDir = Puc_v4p8_Factory::normalizePath(WPMU_PLUGIN_DIR); - $themeDir = Puc_v4p8_Factory::normalizePath(get_theme_root()); + $pluginDir = Puc_v4p9_Factory::normalizePath(WP_PLUGIN_DIR); + $muPluginDir = Puc_v4p9_Factory::normalizePath(WPMU_PLUGIN_DIR); + $themeDir = Puc_v4p9_Factory::normalizePath(get_theme_root()); if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) { //It's part of a plugin. diff --git a/Puc/v4p8/DebugBar/Panel.php b/Puc/v4p9/DebugBar/Panel.php similarity index 96% rename from Puc/v4p8/DebugBar/Panel.php rename to Puc/v4p9/DebugBar/Panel.php index 4082bd41..dd0e259b 100644 --- a/Puc/v4p8/DebugBar/Panel.php +++ b/Puc/v4p9/DebugBar/Panel.php @@ -1,9 +1,9 @@ '; diff --git a/Puc/v4p8/DebugBar/PluginExtension.php b/Puc/v4p9/DebugBar/PluginExtension.php similarity index 75% rename from Puc/v4p8/DebugBar/PluginExtension.php rename to Puc/v4p9/DebugBar/PluginExtension.php index 2c125f64..ca3de424 100644 --- a/Puc/v4p8/DebugBar/PluginExtension.php +++ b/Puc/v4p9/DebugBar/PluginExtension.php @@ -1,12 +1,12 @@ pluginAbsolutePath); //If realpath() fails, just normalize the syntax instead. if (($muPluginDir === false) || ($pluginPath === false)) { - $muPluginDir = Puc_v4p8_Factory::normalizePath(WPMU_PLUGIN_DIR); - $pluginPath = Puc_v4p8_Factory::normalizePath($this->pluginAbsolutePath); + $muPluginDir = Puc_v4p9_Factory::normalizePath(WPMU_PLUGIN_DIR); + $pluginPath = Puc_v4p9_Factory::normalizePath($this->pluginAbsolutePath); } $cachedResult = (strpos($pluginPath, $muPluginDir) === 0); diff --git a/Puc/v4p8/Plugin/Ui.php b/Puc/v4p9/Plugin/Ui.php similarity index 98% rename from Puc/v4p8/Plugin/Ui.php rename to Puc/v4p9/Plugin/Ui.php index b4748e0e..390bcdf7 100644 --- a/Puc/v4p8/Plugin/Ui.php +++ b/Puc/v4p9/Plugin/Ui.php @@ -1,14 +1,14 @@ updateChecker = $updateChecker; diff --git a/Puc/v4p8/Plugin/Update.php b/Puc/v4p9/Plugin/Update.php similarity index 87% rename from Puc/v4p8/Plugin/Update.php rename to Puc/v4p9/Plugin/Update.php index a4459b3b..43456174 100644 --- a/Puc/v4p8/Plugin/Update.php +++ b/Puc/v4p9/Plugin/Update.php @@ -1,5 +1,5 @@ pluginFile, array($this, 'removeHooks')); - $this->extraUi = new Puc_v4p8_Plugin_Ui($this); + $this->extraUi = new Puc_v4p9_Plugin_Ui($this); } /** * Create an instance of the scheduler. * * @param int $checkPeriod - * @return Puc_v4p8_Scheduler + * @return Puc_v4p9_Scheduler */ protected function createScheduler($checkPeriod) { - $scheduler = new Puc_v4p8_Scheduler($this, $checkPeriod, array('load-plugins.php')); + $scheduler = new Puc_v4p9_Scheduler($this, $checkPeriod, array('load-plugins.php')); register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron')); return $scheduler; } @@ -124,13 +124,13 @@ public function removeHooks() { * @uses wp_remote_get() * * @param array $queryArgs Additional query arguments to append to the request. Optional. - * @return Puc_v4p8_Plugin_Info + * @return Puc_v4p9_Plugin_Info */ public function requestInfo($queryArgs = array()) { - list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p8_Plugin_Info', 'request_info', $queryArgs); + list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p9_Plugin_Info', 'request_info', $queryArgs); if ( $pluginInfo !== null ) { - /** @var Puc_v4p8_Plugin_Info $pluginInfo */ + /** @var Puc_v4p9_Plugin_Info $pluginInfo */ $pluginInfo->filename = $this->pluginFile; $pluginInfo->slug = $this->slug; } @@ -144,7 +144,7 @@ public function requestInfo($queryArgs = array()) { * * @uses PluginUpdateChecker::requestInfo() * - * @return Puc_v4p8_Update|null An instance of Plugin_Update, or NULL when no updates are available. + * @return Puc_v4p9_Update|null An instance of Plugin_Update, or NULL when no updates are available. */ public function requestUpdate() { //For the sake of simplicity, this function just calls requestInfo() @@ -153,7 +153,7 @@ public function requestUpdate() { if ( $pluginInfo === null ){ return null; } - $update = Puc_v4p8_Plugin_Update::fromPluginInfo($pluginInfo); + $update = Puc_v4p9_Plugin_Update::fromPluginInfo($pluginInfo); $update = $this->filterUpdateResult($update); @@ -265,12 +265,12 @@ public function isBeingUpgraded($upgrader = null) { * Uses cached update data. To retrieve update information straight from * the metadata URL, call requestUpdate() instead. * - * @return Puc_v4p8_Plugin_Update|null + * @return Puc_v4p9_Plugin_Update|null */ public function getUpdate() { $update = parent::getUpdate(); if ( isset($update) ) { - /** @var Puc_v4p8_Plugin_Update $update */ + /** @var Puc_v4p9_Plugin_Update $update */ $update->filename = $this->pluginFile; } return $update; @@ -375,20 +375,20 @@ public function addResultFilter($callback) { } protected function createDebugBarExtension() { - return new Puc_v4p8_DebugBar_PluginExtension($this); + return new Puc_v4p9_DebugBar_PluginExtension($this); } /** * Create a package instance that represents this plugin or theme. * - * @return Puc_v4p8_InstalledPackage + * @return Puc_v4p9_InstalledPackage */ protected function createInstalledPackage() { - return new Puc_v4p8_Plugin_Package($this->pluginAbsolutePath, $this); + return new Puc_v4p9_Plugin_Package($this->pluginAbsolutePath, $this); } /** - * @return Puc_v4p8_Plugin_Package + * @return Puc_v4p9_Plugin_Package */ public function getInstalledPackage() { return $this->package; diff --git a/Puc/v4p8/Scheduler.php b/Puc/v4p9/Scheduler.php similarity index 95% rename from Puc/v4p8/Scheduler.php rename to Puc/v4p9/Scheduler.php index 1b89cf26..ce814636 100644 --- a/Puc/v4p8/Scheduler.php +++ b/Puc/v4p9/Scheduler.php @@ -1,11 +1,11 @@ updateChecker, 'Puc_v4p8_Theme_UpdateChecker') ) { + if ( is_a($this->updateChecker, 'Puc_v4p9_Theme_UpdateChecker') ) { if ( 'theme' !== $upgradeInfo['type'] || !isset($upgradeInfo['themes']) ) { return; } @@ -120,7 +120,7 @@ public function upgraderProcessComplete( } } - if ( is_a($this->updateChecker, 'Puc_v4p8_Plugin_UpdateChecker') ) { + if ( is_a($this->updateChecker, 'Puc_v4p9_Plugin_UpdateChecker') ) { if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) { return; } diff --git a/Puc/v4p8/StateStore.php b/Puc/v4p9/StateStore.php similarity index 89% rename from Puc/v4p8/StateStore.php rename to Puc/v4p9/StateStore.php index aa2d38b6..ff140638 100644 --- a/Puc/v4p8/StateStore.php +++ b/Puc/v4p9/StateStore.php @@ -1,8 +1,8 @@ lazyLoad(); @@ -73,10 +73,10 @@ public function getUpdate() { } /** - * @param Puc_v4p8_Update|null $update + * @param Puc_v4p9_Update|null $update * @return $this */ - public function setUpdate(Puc_v4p8_Update $update = null) { + public function setUpdate(Puc_v4p9_Update $update = null) { $this->lazyLoad(); $this->update = $update; return $this; @@ -138,7 +138,7 @@ public function save() { $updateClass = get_class($this->update); $state->updateClass = $updateClass; $prefix = $this->getLibPrefix(); - if ( Puc_v4p8_Utils::startsWith($updateClass, $prefix) ) { + if ( Puc_v4p9_Utils::startsWith($updateClass, $prefix) ) { $state->updateBaseClass = substr($updateClass, strlen($prefix)); } } @@ -169,8 +169,8 @@ protected function load() { return; } - $this->lastCheck = intval(Puc_v4p8_Utils::get($state, 'lastCheck', 0)); - $this->checkedVersion = Puc_v4p8_Utils::get($state, 'checkedVersion', ''); + $this->lastCheck = intval(Puc_v4p9_Utils::get($state, 'lastCheck', 0)); + $this->checkedVersion = Puc_v4p9_Utils::get($state, 'checkedVersion', ''); $this->update = null; if ( isset($state->update) ) { diff --git a/Puc/v4p8/Theme/Package.php b/Puc/v4p9/Theme/Package.php similarity index 93% rename from Puc/v4p8/Theme/Package.php rename to Puc/v4p9/Theme/Package.php index bc0062e2..4766c5cb 100644 --- a/Puc/v4p8/Theme/Package.php +++ b/Puc/v4p9/Theme/Package.php @@ -1,7 +1,7 @@ requestMetadata('Puc_v4p8_Theme_Update', 'request_update'); + list($themeUpdate, $result) = $this->requestMetadata('Puc_v4p9_Theme_Update', 'request_update'); if ( $themeUpdate !== null ) { - /** @var Puc_v4p8_Theme_Update $themeUpdate */ + /** @var Puc_v4p9_Theme_Update $themeUpdate */ $themeUpdate->slug = $this->slug; } @@ -61,10 +61,10 @@ public function userCanInstallUpdates() { * Create an instance of the scheduler. * * @param int $checkPeriod - * @return Puc_v4p8_Scheduler + * @return Puc_v4p9_Scheduler */ protected function createScheduler($checkPeriod) { - return new Puc_v4p8_Scheduler($this, $checkPeriod, array('load-themes.php')); + return new Puc_v4p9_Scheduler($this, $checkPeriod, array('load-themes.php')); } /** @@ -78,7 +78,7 @@ public function isBeingUpgraded($upgrader = null) { } protected function createDebugBarExtension() { - return new Puc_v4p8_DebugBar_Extension($this, 'Puc_v4p8_DebugBar_ThemePanel'); + return new Puc_v4p9_DebugBar_Extension($this, 'Puc_v4p9_DebugBar_ThemePanel'); } /** @@ -132,10 +132,10 @@ public function addResultFilter($callback) { /** * Create a package instance that represents this plugin or theme. * - * @return Puc_v4p8_InstalledPackage + * @return Puc_v4p9_InstalledPackage */ protected function createInstalledPackage() { - return new Puc_v4p8_Theme_Package($this->stylesheet, $this); + return new Puc_v4p9_Theme_Package($this->stylesheet, $this); } } diff --git a/Puc/v4p8/Update.php b/Puc/v4p9/Update.php similarity index 84% rename from Puc/v4p8/Update.php rename to Puc/v4p9/Update.php index eb43359f..3db3d605 100644 --- a/Puc/v4p8/Update.php +++ b/Puc/v4p9/Update.php @@ -1,5 +1,5 @@ package = $this->createInstalledPackage(); $this->scheduler = $this->createScheduler($checkPeriod); - $this->upgraderStatus = new Puc_v4p8_UpgraderStatus(); - $this->updateState = new Puc_v4p8_StateStore($this->optionName); + $this->upgraderStatus = new Puc_v4p9_UpgraderStatus(); + $this->updateState = new Puc_v4p9_StateStore($this->optionName); if ( did_action('init') ) { $this->loadTextDomain(); @@ -201,12 +201,12 @@ public function allowMetadataHost($allow, $host) { /** * Create a package instance that represents this plugin or theme. * - * @return Puc_v4p8_InstalledPackage + * @return Puc_v4p9_InstalledPackage */ abstract protected function createInstalledPackage(); /** - * @return Puc_v4p8_InstalledPackage + * @return Puc_v4p9_InstalledPackage */ public function getInstalledPackage() { return $this->package; @@ -219,14 +219,14 @@ public function getInstalledPackage() { * and substitute their own scheduler. * * @param int $checkPeriod - * @return Puc_v4p8_Scheduler + * @return Puc_v4p9_Scheduler */ abstract protected function createScheduler($checkPeriod); /** * Check for updates. The results are stored in the DB option specified in $optionName. * - * @return Puc_v4p8_Update|null + * @return Puc_v4p9_Update|null */ public function checkForUpdates() { $installedVersion = $this->getInstalledVersion(); @@ -260,7 +260,7 @@ public function checkForUpdates() { /** * Load the update checker state from the DB. * - * @return Puc_v4p8_StateStore + * @return Puc_v4p9_StateStore */ public function getUpdateState() { return $this->updateState->lazyLoad(); @@ -285,7 +285,7 @@ public function resetUpdateState() { * Uses cached update data. To retrieve update information straight from * the metadata URL, call requestUpdate() instead. * - * @return Puc_v4p8_Update|null + * @return Puc_v4p9_Update|null */ public function getUpdate() { $update = $this->updateState->getUpdate(); @@ -306,16 +306,16 @@ public function getUpdate() { * * Subclasses should run the update through filterUpdateResult before returning it. * - * @return Puc_v4p8_Update An instance of Update, or NULL when no updates are available. + * @return Puc_v4p9_Update An instance of Update, or NULL when no updates are available. */ abstract public function requestUpdate(); /** * Filter the result of a requestUpdate() call. * - * @param Puc_v4p8_Update|null $update + * @param Puc_v4p9_Update|null $update * @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any. - * @return Puc_v4p8_Update + * @return Puc_v4p9_Update */ protected function filterUpdateResult($update, $httpResult = null) { //Let plugins/themes modify the update. @@ -338,9 +338,9 @@ protected function filterUpdateResult($update, $httpResult = null) { * "Compatibility: Unknown". * The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to". * - * @param Puc_v4p8_Metadata|null $update + * @param Puc_v4p9_Metadata|null $update */ - protected function fixSupportedWordpressVersion(Puc_v4p8_Metadata $update = null) { + protected function fixSupportedWordpressVersion(Puc_v4p9_Metadata $update = null) { if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) { return; } @@ -570,7 +570,7 @@ protected function shouldShowUpdates() { * @param string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method. * @param string $filterRoot * @param array $queryArgs Additional query arguments. - * @return array [Puc_v4p8_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get(). + * @return array [Puc_v4p9_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get(). */ protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()) { //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()). @@ -909,13 +909,13 @@ public function maybeInitDebugBar() { } protected function createDebugBarExtension() { - return new Puc_v4p8_DebugBar_Extension($this); + return new Puc_v4p9_DebugBar_Extension($this); } /** * Display additional configuration details in the Debug Bar panel. * - * @param Puc_v4p8_DebugBar_Panel $panel + * @param Puc_v4p9_DebugBar_Panel $panel */ public function onDisplayConfiguration($panel) { //Do nothing. Subclasses can use this to add additional info to the panel. diff --git a/Puc/v4p8/UpgraderStatus.php b/Puc/v4p9/UpgraderStatus.php similarity index 98% rename from Puc/v4p8/UpgraderStatus.php rename to Puc/v4p9/UpgraderStatus.php index f1eeef5a..2918fa1c 100644 --- a/Puc/v4p8/UpgraderStatus.php +++ b/Puc/v4p9/UpgraderStatus.php @@ -1,5 +1,5 @@ $branch->name, 'updated' => $branch->target->date, 'downloadUrl' => $this->getDownloadUrl($branch->name), @@ -70,7 +70,7 @@ public function getBranch($branchName) { * Get a specific tag. * * @param string $tagName - * @return Puc_v4p8_Vcs_Reference|null + * @return Puc_v4p9_Vcs_Reference|null */ public function getTag($tagName) { $tag = $this->api('/refs/tags/' . $tagName); @@ -78,7 +78,7 @@ public function getTag($tagName) { return null; } - return new Puc_v4p8_Vcs_Reference(array( + return new Puc_v4p9_Vcs_Reference(array( 'name' => $tag->name, 'version' => ltrim($tag->name, 'v'), 'updated' => $tag->target->date, @@ -89,7 +89,7 @@ public function getTag($tagName) { /** * Get the tag that looks like the highest version number. * - * @return Puc_v4p8_Vcs_Reference|null + * @return Puc_v4p9_Vcs_Reference|null */ public function getLatestTag() { $tags = $this->api('/refs/tags?sort=-target.date'); @@ -103,7 +103,7 @@ public function getLatestTag() { //Return the first result. if ( !empty($versionTags) ) { $tag = $versionTags[0]; - return new Puc_v4p8_Vcs_Reference(array( + return new Puc_v4p9_Vcs_Reference(array( 'name' => $tag->name, 'version' => ltrim($tag->name, 'v'), 'updated' => $tag->target->date, @@ -117,7 +117,7 @@ public function getLatestTag() { * Get the tag/ref specified by the "Stable tag" header in the readme.txt of a given branch. * * @param string $branch - * @return null|Puc_v4p8_Vcs_Reference + * @return null|Puc_v4p9_Vcs_Reference */ protected function getStableTag($branch) { $remoteReadme = $this->getRemoteReadme($branch); @@ -187,7 +187,7 @@ public function getLatestCommitTime($ref) { */ public function api($url, $version = '2.0') { $url = ltrim($url, '/'); - $isSrcResource = Puc_v4p8_Utils::startsWith($url, 'src/'); + $isSrcResource = Puc_v4p9_Utils::startsWith($url, 'src/'); $url = implode('/', array( 'https://api.bitbucket.org', @@ -242,7 +242,7 @@ public function setAuthentication($credentials) { parent::setAuthentication($credentials); if ( !empty($credentials) && !empty($credentials['consumer_key']) ) { - $this->oauth = new Puc_v4p8_OAuthSignature( + $this->oauth = new Puc_v4p9_OAuthSignature( $credentials['consumer_key'], $credentials['consumer_secret'] ); diff --git a/Puc/v4p8/Vcs/GitHubApi.php b/Puc/v4p9/Vcs/GitHubApi.php similarity index 96% rename from Puc/v4p8/Vcs/GitHubApi.php rename to Puc/v4p9/Vcs/GitHubApi.php index 6bfc16a6..0187a666 100644 --- a/Puc/v4p8/Vcs/GitHubApi.php +++ b/Puc/v4p9/Vcs/GitHubApi.php @@ -1,8 +1,8 @@ api('/repos/:user/:repo/releases/latest'); @@ -65,7 +65,7 @@ public function getLatestRelease() { return null; } - $reference = new Puc_v4p8_Vcs_Reference(array( + $reference = new Puc_v4p9_Vcs_Reference(array( 'name' => $release->tag_name, 'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3". 'downloadUrl' => $release->zipball_url, @@ -109,7 +109,7 @@ public function getLatestRelease() { /** * Get the tag that looks like the highest version number. * - * @return Puc_v4p8_Vcs_Reference|null + * @return Puc_v4p9_Vcs_Reference|null */ public function getLatestTag() { $tags = $this->api('/repos/:user/:repo/tags'); @@ -124,7 +124,7 @@ public function getLatestTag() { } $tag = $versionTags[0]; - return new Puc_v4p8_Vcs_Reference(array( + return new Puc_v4p9_Vcs_Reference(array( 'name' => $tag->name, 'version' => ltrim($tag->name, 'v'), 'downloadUrl' => $tag->zipball_url, @@ -136,7 +136,7 @@ public function getLatestTag() { * Get a branch by name. * * @param string $branchName - * @return null|Puc_v4p8_Vcs_Reference + * @return null|Puc_v4p9_Vcs_Reference */ public function getBranch($branchName) { $branch = $this->api('/repos/:user/:repo/branches/' . $branchName); @@ -144,7 +144,7 @@ public function getBranch($branchName) { return null; } - $reference = new Puc_v4p8_Vcs_Reference(array( + $reference = new Puc_v4p9_Vcs_Reference(array( 'name' => $branch->name, 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name), 'apiResponse' => $branch, @@ -314,7 +314,7 @@ public function setAuthentication($credentials) { * Figure out which reference (i.e tag or branch) contains the latest version. * * @param string $configBranch Start looking in this branch. - * @return null|Puc_v4p8_Vcs_Reference + * @return null|Puc_v4p9_Vcs_Reference */ public function chooseReference($configBranch) { $updateSource = null; diff --git a/Puc/v4p8/Vcs/GitLabApi.php b/Puc/v4p9/Vcs/GitLabApi.php similarity index 95% rename from Puc/v4p8/Vcs/GitLabApi.php rename to Puc/v4p9/Vcs/GitLabApi.php index 86fac42a..30bbd13c 100644 --- a/Puc/v4p8/Vcs/GitLabApi.php +++ b/Puc/v4p9/Vcs/GitLabApi.php @@ -1,8 +1,8 @@ getLatestTag(); @@ -100,7 +100,7 @@ public function getLatestRelease() { /** * Get the tag that looks like the highest version number. * - * @return Puc_v4p8_Vcs_Reference|null + * @return Puc_v4p9_Vcs_Reference|null */ public function getLatestTag() { $tags = $this->api('/:id/repository/tags'); @@ -114,7 +114,7 @@ public function getLatestTag() { } $tag = $versionTags[0]; - return new Puc_v4p8_Vcs_Reference(array( + return new Puc_v4p9_Vcs_Reference(array( 'name' => $tag->name, 'version' => ltrim($tag->name, 'v'), 'downloadUrl' => $this->buildArchiveDownloadUrl($tag->name), @@ -126,7 +126,7 @@ public function getLatestTag() { * Get a branch by name. * * @param string $branchName - * @return null|Puc_v4p8_Vcs_Reference + * @return null|Puc_v4p9_Vcs_Reference */ public function getBranch($branchName) { $branch = $this->api('/:id/repository/branches/' . $branchName); @@ -134,7 +134,7 @@ public function getBranch($branchName) { return null; } - $reference = new Puc_v4p8_Vcs_Reference(array( + $reference = new Puc_v4p9_Vcs_Reference(array( 'name' => $branch->name, 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name), 'apiResponse' => $branch, @@ -283,7 +283,7 @@ public function getTag($tagName) { * Figure out which reference (i.e tag or branch) contains the latest version. * * @param string $configBranch Start looking in this branch. - * @return null|Puc_v4p8_Vcs_Reference + * @return null|Puc_v4p9_Vcs_Reference */ public function chooseReference($configBranch) { $updateSource = null; diff --git a/Puc/v4p8/Vcs/PluginUpdateChecker.php b/Puc/v4p9/Vcs/PluginUpdateChecker.php similarity index 93% rename from Puc/v4p8/Vcs/PluginUpdateChecker.php rename to Puc/v4p9/Vcs/PluginUpdateChecker.php index 85dfbb85..fab268fd 100644 --- a/Puc/v4p8/Vcs/PluginUpdateChecker.php +++ b/Puc/v4p9/Vcs/PluginUpdateChecker.php @@ -1,21 +1,21 @@ api; $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath()); - $info = new Puc_v4p8_Plugin_Info(); + $info = new Puc_v4p9_Plugin_Info(); $info->filename = $this->pluginFile; $info->slug = $this->slug; @@ -124,7 +124,7 @@ protected function readmeTxtExistsLocally() { * Copy plugin metadata from a file header to a Plugin Info object. * * @param array $fileHeader - * @param Puc_v4p8_Plugin_Info $pluginInfo + * @param Puc_v4p9_Plugin_Info $pluginInfo */ protected function setInfoFromHeader($fileHeader, $pluginInfo) { $headerToPropertyMap = array( @@ -155,7 +155,7 @@ protected function setInfoFromHeader($fileHeader, $pluginInfo) { * Copy plugin metadata from the remote readme.txt file. * * @param string $ref GitHub tag or branch where to look for the readme. - * @param Puc_v4p8_Plugin_Info $pluginInfo + * @param Puc_v4p9_Plugin_Info $pluginInfo */ protected function setInfoFromRemoteReadme($ref, $pluginInfo) { $readme = $this->api->getRemoteReadme($ref); diff --git a/Puc/v4p8/Vcs/Reference.php b/Puc/v4p9/Vcs/Reference.php similarity index 92% rename from Puc/v4p8/Vcs/Reference.php rename to Puc/v4p9/Vcs/Reference.php index 99feb986..b9b30c19 100644 --- a/Puc/v4p8/Vcs/Reference.php +++ b/Puc/v4p9/Vcs/Reference.php @@ -1,5 +1,5 @@ api; $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath()); - $update = new Puc_v4p8_Theme_Update(); + $update = new Puc_v4p9_Theme_Update(); $update->slug = $this->slug; //Figure out which reference (tag or branch) we'll use to get the latest version of the theme. @@ -60,13 +60,13 @@ public function requestUpdate() { //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->package->getFileHeader($api->getRemoteFile('style.css', $ref)); - $update->version = Puc_v4p8_Utils::findNotEmpty(array( + $update->version = Puc_v4p9_Utils::findNotEmpty(array( $remoteHeader['Version'], - Puc_v4p8_Utils::get($updateSource, 'version'), + Puc_v4p9_Utils::get($updateSource, 'version'), )); //The details URL defaults to the Theme URI header or the repository URL. - $update->details_url = Puc_v4p8_Utils::findNotEmpty(array( + $update->details_url = Puc_v4p9_Utils::findNotEmpty(array( $remoteHeader['ThemeURI'], $this->package->getHeaderValue('ThemeURI'), $this->metadataUrl, diff --git a/README.md b/README.md index e6942e22..d2f8280e 100644 --- a/README.md +++ b/README.md @@ -244,8 +244,8 @@ BitBucket doesn't have an equivalent to GitHub's releases, so the process is sli Alternatively, if you're using a self-hosted GitLab instance, initialize the update checker like this: ```php - $myUpdateChecker = new Puc_v4p8_Vcs_PluginUpdateChecker( - new Puc_v4p8_Vcs_GitLabApi('https://myserver.com/user-name/repo-name/'), + $myUpdateChecker = new Puc_v4p9_Vcs_PluginUpdateChecker( + new Puc_v4p9_Vcs_GitLabApi('https://myserver.com/user-name/repo-name/'), __FILE__, 'unique-plugin-or-theme-slug' ); @@ -253,8 +253,8 @@ BitBucket doesn't have an equivalent to GitHub's releases, so the process is sli ``` If you're using a self-hosted GitLab instance and [subgroups or nested groups](https://docs.gitlab.com/ce/user/group/subgroups/index.html), you have to tell the update checker which parts of the URL are subgroups: ```php - $myUpdateChecker = new Puc_v4p8_Vcs_PluginUpdateChecker( - new Puc_v4p8_Vcs_GitLabApi('https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', null, 'subgroup-level1/subgroup-level2/subgroup-level3'), + $myUpdateChecker = new Puc_v4p9_Vcs_PluginUpdateChecker( + new Puc_v4p9_Vcs_GitLabApi('https://myserver.com/group-name/subgroup-level1/subgroup-level2/subgroup-level3/repo-name/', null, 'subgroup-level1/subgroup-level2/subgroup-level3'), __FILE__, 'unique-plugin-or-theme-slug' ); diff --git a/composer.json b/composer.json index fc821863..4379eeb1 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,6 @@ "ext-json": "*" }, "autoload": { - "files": ["load-v4p8.php"] + "files": ["load-v4p9.php"] } } diff --git a/load-v4p8.php b/load-v4p8.php deleted file mode 100644 index 175614f0..00000000 --- a/load-v4p8.php +++ /dev/null @@ -1,28 +0,0 @@ - 'Puc_v4p8_Plugin_UpdateChecker', - 'Theme_UpdateChecker' => 'Puc_v4p8_Theme_UpdateChecker', - - 'Vcs_PluginUpdateChecker' => 'Puc_v4p8_Vcs_PluginUpdateChecker', - 'Vcs_ThemeUpdateChecker' => 'Puc_v4p8_Vcs_ThemeUpdateChecker', - - 'GitHubApi' => 'Puc_v4p8_Vcs_GitHubApi', - 'BitBucketApi' => 'Puc_v4p8_Vcs_BitBucketApi', - 'GitLabApi' => 'Puc_v4p8_Vcs_GitLabApi', - ) - as $pucGeneralClass => $pucVersionedClass -) { - Puc_v4_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.8'); - //Also add it to the minor-version factory in case the major-version factory - //was already defined by another, older version of the update checker. - Puc_v4p8_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.8'); -} - diff --git a/load-v4p9.php b/load-v4p9.php new file mode 100644 index 00000000..f5634b5f --- /dev/null +++ b/load-v4p9.php @@ -0,0 +1,28 @@ + 'Puc_v4p9_Plugin_UpdateChecker', + 'Theme_UpdateChecker' => 'Puc_v4p9_Theme_UpdateChecker', + + 'Vcs_PluginUpdateChecker' => 'Puc_v4p9_Vcs_PluginUpdateChecker', + 'Vcs_ThemeUpdateChecker' => 'Puc_v4p9_Vcs_ThemeUpdateChecker', + + 'GitHubApi' => 'Puc_v4p9_Vcs_GitHubApi', + 'BitBucketApi' => 'Puc_v4p9_Vcs_BitBucketApi', + 'GitLabApi' => 'Puc_v4p9_Vcs_GitLabApi', + ) + as $pucGeneralClass => $pucVersionedClass +) { + Puc_v4_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.9'); + //Also add it to the minor-version factory in case the major-version factory + //was already defined by another, older version of the update checker. + Puc_v4p9_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.9'); +} + diff --git a/plugin-update-checker.php b/plugin-update-checker.php index 624a01be..2abd4ec7 100644 --- a/plugin-update-checker.php +++ b/plugin-update-checker.php @@ -1,10 +1,10 @@