Skip to content

Commit

Permalink
plugin updateer update
Browse files Browse the repository at this point in the history
  • Loading branch information
liedekef committed May 22, 2023
1 parent f05cb22 commit 7c417bc
Show file tree
Hide file tree
Showing 47 changed files with 629 additions and 333 deletions.
1 change: 1 addition & 0 deletions plugin-update-checker/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build export-ignore
2 changes: 1 addition & 1 deletion plugin-update-checker/Puc/v5/PucFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

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

endif;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

use YahnisElsts\PluginUpdateChecker\v5p0\UpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p1\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
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\DebugBar;
namespace YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

use LogicException;
use stdClass;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p0\PucFactory;
use YahnisElsts\PluginUpdateChecker\v5p1\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p1\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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Plugin;

use YahnisElsts\PluginUpdateChecker\v5p0\Metadata;
use YahnisElsts\PluginUpdateChecker\v5p1\Metadata;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Plugin;

if ( !class_exists('Ui', false) ):
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Plugin;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
namespace YahnisElsts\PluginUpdateChecker\v5p1\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\v5p1\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p1\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p1\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

use YahnisElsts\PluginUpdateChecker\v5p0\Plugin;
use YahnisElsts\PluginUpdateChecker\v5p0\Theme;
use YahnisElsts\PluginUpdateChecker\v5p0\Vcs;
use YahnisElsts\PluginUpdateChecker\v5p1\Plugin;
use YahnisElsts\PluginUpdateChecker\v5p1\Theme;
use YahnisElsts\PluginUpdateChecker\v5p1\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.1)
*
* @param string $path Path to normalize.
* @return string Normalized path.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Theme;

use YahnisElsts\PluginUpdateChecker\v5p0\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p1\InstalledPackage;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Theme;

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p0\Theme;
namespace YahnisElsts\PluginUpdateChecker\v5p1\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\v5p1\UpdateChecker as BaseUpdateChecker;
use YahnisElsts\PluginUpdateChecker\v5p1\InstalledPackage;
use YahnisElsts\PluginUpdateChecker\v5p1\Scheduler;
use YahnisElsts\PluginUpdateChecker\v5p1\DebugBar;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

use stdClass;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0;
namespace YahnisElsts\PluginUpdateChecker\v5p1;

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Vcs;

namespace YahnisElsts\PluginUpdateChecker\v5p1\Vcs;

use Parsedown;
use PucReadmeParser;
Expand All @@ -12,6 +13,31 @@ abstract class Api {
const STRATEGY_STABLE_TAG = 'stable_tag';
const STRATEGY_BRANCH = 'branch';

/**
* Consider all releases regardless of their version number or prerelease/upcoming
* release status.
*/
const RELEASE_FILTER_ALL = 3;

/**
* Exclude releases that have the "prerelease" or "upcoming release" flag.
*
* This does *not* look for prerelease keywords like "beta" in the version number.
* It only uses the data provided by the API. For example, on GitHub, you can
* manually mark a release as a prerelease.
*/
const RELEASE_FILTER_SKIP_PRERELEASE = 1;

/**
* If there are no release assets or none of them match the configured filter,
* fall back to the automatically generated source code archive.
*/
const PREFER_RELEASE_ASSETS = 1;
/**
* Skip releases that don't have any matching release assets.
*/
const REQUIRE_RELEASE_ASSETS = 2;

protected $tagNameProperty = 'name';
protected $slug = '';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace YahnisElsts\PluginUpdateChecker\v5p0\Vcs;
namespace YahnisElsts\PluginUpdateChecker\v5p1\Vcs;

if ( !interface_exists(BaseChecker::class, false) ):

Expand Down
Loading

0 comments on commit 7c417bc

Please sign in to comment.