Skip to content

Commit

Permalink
plugin-update-checker 5.2 バージョンアップ
Browse files Browse the repository at this point in the history
  • Loading branch information
xs-khosomi committed Oct 3, 2023
1 parent bf4006b commit aa9fde5
Show file tree
Hide file tree
Showing 46 changed files with 621 additions and 324 deletions.
1 change: 1 addition & 0 deletions lib/plugin-update-checker/.gitattributes
@@ -0,0 +1 @@
/build export-ignore
2 changes: 1 addition & 1 deletion lib/plugin-update-checker/Puc/v5/PucFactory.php
Expand Up @@ -4,7 +4,7 @@

if ( !class_exists(PucFactory::class, false) ):

class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p0\PucFactory {
class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p2\PucFactory {
}

endif;
@@ -1,6 +1,6 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(Autoloader::class, false) ):

Expand Down
@@ -1,8 +1,8 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\PucFactory;
use YahnisElsts\PluginUpdateChecker\v5p0\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\PucFactory;
use YahnisElsts\PluginUpdateChecker\v5p2\UpdateChecker;

if ( !class_exists(Extension::class, false) ):

Expand Down
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\UpdateChecker;

if ( !class_exists(Panel::class, false) && class_exists('Debug_Bar_Panel', false) ):

Expand Down Expand Up @@ -160,11 +160,18 @@ private function formatTimestamp($unixTime) {

public function row($name, $value) {
if ( is_object($value) || is_array($value) ) {
//This is specifically for debugging, so print_r() is fine.
//phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
$value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>';
} else if ($value === null) {
$value = '<code>null</code>';
}
printf('<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value);
printf(
'<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>',
esc_html($name),
//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above.
$value
);
}
}

Expand Down
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\Plugin\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\Plugin\UpdateChecker;

if ( !class_exists(PluginExtension::class, false) ):

Expand Down
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\Plugin\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\Plugin\UpdateChecker;

if ( !class_exists(PluginPanel::class, false) ):

Expand Down
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\Theme\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\Theme\UpdateChecker;

if ( !class_exists(ThemePanel::class, false) ):

Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(InstalledPackage::class, false) ):

Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

use LogicException;
use stdClass;
Expand All @@ -15,6 +15,12 @@
* @access public
*/
abstract class Metadata {
/**
* Additional dynamic properties, usually copied from the API response.
*
* @var array<string,mixed>
*/
protected $extraProperties = array();

/**
* Create an instance of this class from a JSON document.
Expand Down Expand Up @@ -135,6 +141,22 @@ protected function getFieldNames() {
protected function getPrefixedFilter($tag) {
return 'puc_' . $tag;
}

public function __set($name, $value) {
$this->extraProperties[$name] = $value;
}

public function __get($name) {
return isset($this->extraProperties[$name]) ? $this->extraProperties[$name] : null;
}

public function __isset($name) {
return isset($this->extraProperties[$name]);
}

public function __unset($name) {
unset($this->extraProperties[$name]);
}
}

endif;
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(OAuthSignature::class, false) ):

Expand Down
@@ -1,8 +1,8 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p0\PucFactory;
use YahnisElsts\PluginUpdateChecker\v5p2\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p2\PucFactory;

if ( !class_exists(Package::class, false) ):

Expand Down Expand Up @@ -51,7 +51,7 @@ public function getInstalledVersion() {
//This can happen if the filename points to something that is not a plugin.
$this->updateChecker->triggerError(
sprintf(
"Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
"Cannot read the Version header for '%s'. The filename is incorrect or is not a plugin.",
$this->updateChecker->pluginFile
),
E_USER_WARNING
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\Metadata;
use YahnisElsts\PluginUpdateChecker\v5p2\Metadata;

if ( !class_exists(PluginInfo::class, false) ):

Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Plugin;

if ( !class_exists('Ui', false) ):
/**
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\Update as BaseUpdate;
use YahnisElsts\PluginUpdateChecker\v5p2\Update as BaseUpdate;

if ( !class_exists(Update::class, false) ):

Expand Down
@@ -1,10 +1,10 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p0\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p0\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
use YahnisElsts\PluginUpdateChecker\v5p2\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p2\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

if ( !class_exists(UpdateChecker::class, false) ):

Expand Down
@@ -1,10 +1,10 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

use YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
use YahnisElsts\PluginUpdateChecker\v5p0\Theme;
use YahnisElsts\PluginUpdateChecker\v5p0\Vcs;
use YahnisElsts\PluginUpdateChecker\v5p2\Plugin;
use YahnisElsts\PluginUpdateChecker\v5p2\Theme;
use YahnisElsts\PluginUpdateChecker\v5p2\Vcs;

if ( !class_exists(PucFactory::class, false) ):

Expand Down Expand Up @@ -147,7 +147,7 @@ public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $
*
* Normalize a filesystem path. Introduced in WP 3.9.
* Copying here allows use of the class on earlier versions.
* This version adapted from WP 4.8.2 (unchanged since 4.5.0)
* This version adapted from WP 4.8.2 (unchanged since 4.5.2)
*
* @param string $path Path to normalize.
* @return string Normalized path.
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(Scheduler::class, false) ):

Expand Down Expand Up @@ -49,6 +49,7 @@ public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('
} else {
//Use a custom cron schedule.
$scheduleName = 'every' . $this->checkPeriod . 'hours';
//phpcs:ignore WordPress.WP.CronInterval.ChangeDetected -- WPCS fails to parse the callback.
add_filter('cron_schedules', array($this, '_addCustomSchedule'));
}

Expand Down Expand Up @@ -79,6 +80,7 @@ public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('
//Like WordPress itself, we check more often on certain pages.
/** @see wp_update_plugins */
add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
//phpcs:ignore Squiz.PHP.CommentedOutCode.Found -- Not actually code, just file names.
//"load-update.php" and "load-plugins.php" or "load-themes.php".
$this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks);
foreach($this->hourlyCheckHooks as $hook) {
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(StateStore::class, false) ):

Expand Down Expand Up @@ -185,8 +185,9 @@ protected function load() {
$updateClass = $state->updateClass;
}

if ( ($updateClass !== null) && class_exists($updateClass) ) {
$this->update = call_user_func(array($updateClass, 'fromObject'), $state->update);
$factory = array($updateClass, 'fromObject');
if ( ($updateClass !== null) && is_callable($factory) ) {
$this->update = call_user_func($factory, $state->update);
}
}
}
Expand Down
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Theme;

use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p2\InstalledPackage;

if ( !class_exists(Package::class, false) ):

Expand Down
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Theme;

use YahnisElsts\PluginUpdateChecker\v5p0\Update as BaseUpdate;
use YahnisElsts\PluginUpdateChecker\v5p2\Update as BaseUpdate;

if ( !class_exists(Update::class, false) ):

Expand Down
@@ -1,11 +1,11 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p2\Theme;

use YahnisElsts\PluginUpdateChecker\v5p0\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p0\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
use YahnisElsts\PluginUpdateChecker\v5p2\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p2\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p2\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p2\DebugBar;

if ( !class_exists(UpdateChecker::class, false) ):

Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

use stdClass;

Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

use stdClass;
use WP_Error;
Expand All @@ -9,7 +9,7 @@
abstract class UpdateChecker {
protected $filterSuffix = '';
protected $updateTransient = '';
protected $translationType = ''; //"plugin" or "theme".
protected $translationType = ''; //This can be "plugin" or "theme".

/**
* Set to TRUE to enable error reporting. Errors are raised using trigger_error()
Expand Down Expand Up @@ -660,7 +660,7 @@ protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()

//Various options for the wp_remote_get() call. Plugins can filter these, too.
$options = array(
'timeout' => 10, //seconds
'timeout' => wp_doing_cron() ? 10 : 3,
'headers' => array(
'Accept' => 'application/json',
),
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(UpgraderStatus::class, false) ):

Expand All @@ -11,7 +11,7 @@
* This class uses a few workarounds and heuristics to get the file name.
*/
class UpgraderStatus {
private $currentType = null; //"plugin" or "theme".
private $currentType = null; //This must be either "plugin" or "theme".
private $currentId = null; //Plugin basename or theme directory name.

public function __construct() {
Expand Down
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(Utils::class, false) ):

Expand Down

0 comments on commit aa9fde5

Please sign in to comment.