Bump version number to 3.2

This commit is contained in:
Yahnis Elsts 2016-12-08 12:22:54 +02:00
parent 93c9d661d5
commit 38dabff869
4 changed files with 56 additions and 56 deletions

View File

@ -1,12 +1,12 @@
<?php
if ( !class_exists('PluginUpdateCheckerPanel_3_1', false) && class_exists('Debug_Bar_Panel', false) ) {
if ( !class_exists('PluginUpdateCheckerPanel_3_2', false) && class_exists('Debug_Bar_Panel', false) ) {
/**
* A Debug Bar panel for the plugin update checker.
*/
class PluginUpdateCheckerPanel_3_1 extends Debug_Bar_Panel {
/** @var PluginUpdateChecker_3_1 */
class PluginUpdateCheckerPanel_3_2 extends Debug_Bar_Panel {
/** @var PluginUpdateChecker_3_2 */
private $updateChecker;
private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';

View File

@ -1,8 +1,8 @@
<?php
if ( !class_exists('PucDebugBarPlugin_3_1', false) ) {
if ( !class_exists('PucDebugBarPlugin_3_2', false) ) {
class PucDebugBarPlugin_3_1 {
/** @var PluginUpdateChecker_3_1 */
class PucDebugBarPlugin_3_2 {
/** @var PluginUpdateChecker_3_2 */
private $updateChecker;
public function __construct($updateChecker) {
@ -23,8 +23,8 @@ class PucDebugBarPlugin_3_1 {
*/
public function addDebugBarPanel($panels) {
require_once dirname(__FILE__) . '/debug-bar-panel.php';
if ( current_user_can('update_plugins') && class_exists('PluginUpdateCheckerPanel_3_1', false) ) {
$panels[] = new PluginUpdateCheckerPanel_3_1($this->updateChecker);
if ( current_user_can('update_plugins') && class_exists('PluginUpdateCheckerPanel_3_2', false) ) {
$panels[] = new PluginUpdateCheckerPanel_3_2($this->updateChecker);
}
return $panels;
}

View File

@ -1,8 +1,8 @@
<?php
if ( !class_exists('PucGitHubChecker_3_1', false) ):
if ( !class_exists('PucGitHubChecker_3_2', false) ):
class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 {
class PucGitHubChecker_3_2 extends PluginUpdateChecker_3_2 {
/**
* @var string GitHub username.
*/
@ -54,10 +54,10 @@ class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 {
* Retrieve details about the latest plugin version from GitHub.
*
* @param array $unusedQueryArgs Unused.
* @return PluginInfo_3_1
* @return PluginInfo_3_2
*/
public function requestInfo($unusedQueryArgs = array()) {
$info = new PluginInfo_3_1();
$info = new PluginInfo_3_2();
$info->filename = $this->pluginFile;
$info->slug = $this->slug;
@ -359,7 +359,7 @@ class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 {
* Copy plugin metadata from a file header to a PluginInfo object.
*
* @param array $fileHeader
* @param PluginInfo_3_1 $pluginInfo
* @param PluginInfo_3_2 $pluginInfo
*/
protected function setInfoFromHeader($fileHeader, $pluginInfo) {
$headerToPropertyMap = array(
@ -390,7 +390,7 @@ class PucGitHubChecker_3_1 extends PluginUpdateChecker_3_1 {
* Copy plugin metadata from the remote readme.txt file.
*
* @param string $ref GitHub tag or branch where to look for the readme.
* @param PluginInfo_3_1 $pluginInfo
* @param PluginInfo_3_2 $pluginInfo
*/
protected function setInfoFromRemoteReadme($ref, $pluginInfo) {
$readmeTxt = $this->getRemoteFile('readme.txt', $ref);

View File

@ -1,23 +1,23 @@
<?php
/**
* Plugin Update Checker Library 3.1
* Plugin Update Checker Library 3.2
* http://w-shadow.com/
*
* Copyright 2016 Janis Elsts
* Released under the MIT license. See license.txt for details.
*/
if ( !class_exists('PluginUpdateChecker_3_1', false) ):
if ( !class_exists('PluginUpdateChecker_3_2', false) ):
/**
* A custom plugin update checker.
*
* @author Janis Elsts
* @copyright 2016
* @version 3.0
* @version 3.2
* @access public
*/
class PluginUpdateChecker_3_1 {
class PluginUpdateChecker_3_2 {
public $metadataUrl = ''; //The URL of the plugin's metadata file.
public $pluginAbsolutePath = ''; //Full path of the main plugin file.
public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
@ -85,7 +85,7 @@ class PluginUpdateChecker_3_1 {
}
$this->scheduler = $this->createScheduler($checkPeriod);
$this->upgraderStatus = new PucUpgraderStatus_3_1();
$this->upgraderStatus = new PucUpgraderStatus_3_2();
$this->installHooks();
}
@ -97,10 +97,10 @@ class PluginUpdateChecker_3_1 {
* and substitute their own scheduler.
*
* @param int $checkPeriod
* @return PucScheduler_3_1
* @return PucScheduler_3_2
*/
protected function createScheduler($checkPeriod) {
return new PucScheduler_3_1($this, $checkPeriod);
return new PucScheduler_3_2($this, $checkPeriod);
}
/**
@ -178,7 +178,7 @@ class PluginUpdateChecker_3_1 {
* @uses wp_remote_get()
*
* @param array $queryArgs Additional query arguments to append to the request. Optional.
* @return PluginInfo_3_1
* @return PluginInfo_3_2
*/
public function requestInfo($queryArgs = array()){
//Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
@ -210,7 +210,7 @@ class PluginUpdateChecker_3_1 {
$status = $this->validateApiResponse($result);
$pluginInfo = null;
if ( !is_wp_error($status) ){
$pluginInfo = PluginInfo_3_1::fromJson($result['body']);
$pluginInfo = PluginInfo_3_2::fromJson($result['body']);
if ( $pluginInfo !== null ) {
$pluginInfo->filename = $this->pluginFile;
$pluginInfo->slug = $this->slug;
@ -261,7 +261,7 @@ class PluginUpdateChecker_3_1 {
*
* @uses PluginUpdateChecker::requestInfo()
*
* @return PluginUpdate_3_1 An instance of PluginUpdate, or NULL when no updates are available.
* @return PluginUpdate_3_2 An instance of PluginUpdate, or NULL when no updates are available.
*/
public function requestUpdate(){
//For the sake of simplicity, this function just calls requestInfo()
@ -270,7 +270,7 @@ class PluginUpdateChecker_3_1 {
if ( $pluginInfo == null ){
return null;
}
$update = PluginUpdate_3_1::fromPluginInfo($pluginInfo);
$update = PluginUpdate_3_2::fromPluginInfo($pluginInfo);
//Keep only those translation updates that apply to this site.
$update->translations = $this->filterApplicableTranslations($update->translations);
@ -369,7 +369,7 @@ class PluginUpdateChecker_3_1 {
* Check for plugin updates.
* The results are stored in the DB option specified in $optionName.
*
* @return PluginUpdate_3_1|null
* @return PluginUpdate_3_2|null
*/
public function checkForUpdates(){
$installedVersion = $this->getInstalledVersion();
@ -412,7 +412,7 @@ class PluginUpdateChecker_3_1 {
}
if ( isset($state, $state->update) && is_object($state->update) ) {
$state->update = PluginUpdate_3_1::fromObject($state->update);
$state->update = PluginUpdate_3_2::fromObject($state->update);
}
return $state;
}
@ -426,7 +426,7 @@ class PluginUpdateChecker_3_1 {
*/
private function setUpdateState($state) {
if ( isset($state->update) && is_object($state->update) && method_exists($state->update, 'toStdClass') ) {
$update = $state->update; /** @var PluginUpdate_3_1 $update */
$update = $state->update; /** @var PluginUpdate_3_2 $update */
$state->update = $update->toStdClass();
}
update_site_option($this->optionName, $state);
@ -500,7 +500,7 @@ class PluginUpdateChecker_3_1 {
/**
* @param StdClass|null $updates
* @param PluginUpdate_3_1 $updateToAdd
* @param PluginUpdate_3_2 $updateToAdd
* @return StdClass
*/
private function addUpdateToList($updates, $updateToAdd) {
@ -699,7 +699,7 @@ class PluginUpdateChecker_3_1 {
* Uses cached update data. To retrieve update information straight from
* the metadata URL, call requestUpdate() instead.
*
* @return PluginUpdate_3_1|null
* @return PluginUpdate_3_2|null
*/
public function getUpdate() {
$state = $this->getUpdateState(); /** @var StdClass $state */
@ -954,7 +954,7 @@ class PluginUpdateChecker_3_1 {
if ( class_exists('Debug_Bar', false) && file_exists($debugBarPlugin) ) {
/** @noinspection PhpIncludeInspection */
require_once $debugBarPlugin;
$this->debugBarPlugin = new PucDebugBarPlugin_3_1($this);
$this->debugBarPlugin = new PucDebugBarPlugin_3_2($this);
}
}
@ -973,17 +973,17 @@ class PluginUpdateChecker_3_1 {
endif;
if ( !class_exists('PluginInfo_3_1', false) ):
if ( !class_exists('PluginInfo_3_2', false) ):
/**
* A container class for holding and transforming various plugin metadata.
*
* @author Janis Elsts
* @copyright 2016
* @version 3.0
* @version 3.2
* @access public
*/
class PluginInfo_3_1 {
class PluginInfo_3_2 {
//Most fields map directly to the contents of the plugin's info.json file.
//See the relevant docs for a description of their meaning.
public $name;
@ -1017,7 +1017,7 @@ class PluginInfo_3_1 {
* returned by an external update API.
*
* @param string $json Valid JSON string representing plugin info.
* @return PluginInfo_3_1|null New instance of PluginInfo, or NULL on error.
* @return PluginInfo_3_2|null New instance of PluginInfo, or NULL on error.
*/
public static function fromJson($json){
/** @var StdClass $apiResponse */
@ -1115,17 +1115,17 @@ class PluginInfo_3_1 {
endif;
if ( !class_exists('PluginUpdate_3_1', false) ):
if ( !class_exists('PluginUpdate_3_2', false) ):
/**
* A simple container class for holding information about an available update.
*
* @author Janis Elsts
* @copyright 2016
* @version 3.0
* @version 3.2
* @access public
*/
class PluginUpdate_3_1 {
class PluginUpdate_3_2 {
public $id = 0;
public $slug;
public $version;
@ -1146,13 +1146,13 @@ class PluginUpdate_3_1 {
* Create a new instance of PluginUpdate from its JSON-encoded representation.
*
* @param string $json
* @return PluginUpdate_3_1|null
* @return PluginUpdate_3_2|null
*/
public static function fromJson($json){
//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_3_1::fromJson($json);
$pluginInfo = PluginInfo_3_2::fromJson($json);
if ( $pluginInfo != null ) {
return self::fromPluginInfo($pluginInfo);
} else {
@ -1164,8 +1164,8 @@ class PluginUpdate_3_1 {
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
* Basically, this just copies a subset of fields from one object to another.
*
* @param PluginInfo_3_1 $info
* @return PluginUpdate_3_1
* @param PluginInfo_3_2 $info
* @return PluginUpdate_3_2
*/
public static function fromPluginInfo($info){
return self::fromObject($info);
@ -1175,8 +1175,8 @@ class PluginUpdate_3_1 {
* Create a new instance of PluginUpdate by copying the necessary fields from
* another object.
*
* @param StdClass|PluginInfo_3_1|PluginUpdate_3_1 $object The source object.
* @return PluginUpdate_3_1 The new copy.
* @param StdClass|PluginInfo_3_2|PluginUpdate_3_2 $object The source object.
* @return PluginUpdate_3_2 The new copy.
*/
public static function fromObject($object) {
$update = new self();
@ -1241,21 +1241,21 @@ class PluginUpdate_3_1 {
endif;
if ( !class_exists('PucScheduler_3_1', false) ):
if ( !class_exists('PucScheduler_3_2', false) ):
/**
* The scheduler decides when and how often to check for updates.
* It calls @see PluginUpdateChecker::checkForUpdates() to perform the actual checks.
*
* @version 3.0
* @version 3.2
*/
class PucScheduler_3_1 {
class PucScheduler_3_2 {
public $checkPeriod = 12; //How often to check for updates (in hours).
public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
public $throttledCheckPeriod = 72;
/**
* @var PluginUpdateChecker_3_1
* @var PluginUpdateChecker_3_2
*/
protected $updateChecker;
@ -1264,7 +1264,7 @@ class PucScheduler_3_1 {
/**
* Scheduler constructor.
*
* @param PluginUpdateChecker_3_1 $updateChecker
* @param PluginUpdateChecker_3_2 $updateChecker
* @param int $checkPeriod How often to check for updates (in hours).
*/
public function __construct($updateChecker, $checkPeriod) {
@ -1420,7 +1420,7 @@ class PucScheduler_3_1 {
endif;
if ( !class_exists('PucUpgraderStatus_3_1', false) ):
if ( !class_exists('PucUpgraderStatus_3_2', false) ):
/**
* A utility class that helps figure out which plugin WordPress is upgrading.
@ -1429,7 +1429,7 @@ if ( !class_exists('PucUpgraderStatus_3_1', false) ):
* Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT).
* This class uses a few workarounds and heuristics to get the file name.
*/
class PucUpgraderStatus_3_1 {
class PucUpgraderStatus_3_2 {
private $upgradedPluginFile = null; //The plugin that is currently being upgraded by WordPress.
public function __construct() {
@ -1594,7 +1594,7 @@ class PucFactory {
* @param int $checkPeriod
* @param string $optionName
* @param string $muPluginFile
* @return PluginUpdateChecker_3_1
* @return PluginUpdateChecker_3_2
*/
public static function buildUpdateChecker($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
$class = self::getLatestClassVersion('PluginUpdateChecker');
@ -1657,7 +1657,7 @@ endif;
require_once(dirname(__FILE__) . '/github-checker.php');
//Register classes defined in this file with the factory.
PucFactory::addVersion('PluginUpdateChecker', 'PluginUpdateChecker_3_1', '3.1');
PucFactory::addVersion('PluginUpdate', 'PluginUpdate_3_1', '3.1');
PucFactory::addVersion('PluginInfo', 'PluginInfo_3_1', '3.1');
PucFactory::addVersion('PucGitHubChecker', 'PucGitHubChecker_3_1', '3.1');
PucFactory::addVersion('PluginUpdateChecker', 'PluginUpdateChecker_3_2', '3.2');
PucFactory::addVersion('PluginUpdate', 'PluginUpdate_3_2', '3.2');
PucFactory::addVersion('PluginInfo', 'PluginInfo_3_2', '3.2');
PucFactory::addVersion('PucGitHubChecker', 'PucGitHubChecker_3_2', '3.2');