Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update yahnis-elsts/plugin-update-checker from 4.13 to 5.1 #1124

Merged
merged 3 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ indent_size = 4
[*.{json,yml,md}]
indent_style = space
indent_size = 2

[{*.txt,wp-config-sample.php}]
end_of_line = crlf
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
/.gitattributes export-ignore
/.gitignore export-ignore
/.wordpress-version-checker.json export-ignore

# Text files should have LF line endings.
* text eol=lf

# Binary files should not be modified.
*.mo binary
*.png binary
*.jpg binary
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"require": {
"php": ">=7.4",
"yahnis-elsts/plugin-update-checker": "4.13",
"yahnis-elsts/plugin-update-checker": "5.1",
"ext-json": "*"
},
"autoload": {
Expand Down
20 changes: 10 additions & 10 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions includes/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

namespace Distributor;

use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

/**
* PSR-4 autoloading
*/
Expand Down Expand Up @@ -130,7 +132,7 @@ function() {
}
);

if ( class_exists( '\\Puc_v4_Factory' ) ) {
if ( class_exists( '\\YahnisElsts\PluginUpdateChecker\v5\PucFactory' ) ) {
/**
* Enable updates if we have a valid license
*/
Expand All @@ -144,7 +146,7 @@ function() {

if ( $valid_license ) {
// @codingStandardsIgnoreStart
$updateChecker = \Puc_v4_Factory::buildUpdateChecker(
$updateChecker = PucFactory::buildUpdateChecker(
'https://github.com/10up/distributor/',
DT_PLUGIN_FULL_FILE,
'distributor'
Expand Down Expand Up @@ -174,7 +176,9 @@ function( $transient ) use ( $updateChecker ) {
$update = $updateChecker->getUpdateState()->getUpdate();
// Adding the plugin info to the `no_update` property is required
// for the enable/disable auto-updates links to correctly appear in UI.
$transient->no_update[ $update->filename ] = $update;
if ( $update ) {
$transient->no_update[ $update->filename ] = $update;
}
}

return $transient;
Expand Down
1 change: 1 addition & 0 deletions vendor/yahnis-elsts/plugin-update-checker/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build export-ignore

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5;

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

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

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

namespace YahnisElsts\PluginUpdateChecker\v5p1;

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

class Autoloader {
const DEFAULT_NS_PREFIX = 'YahnisElsts\\PluginUpdateChecker\\';

private $prefix;
private $rootDir;
private $libraryDir;

private $staticMap;

public function __construct() {
$this->rootDir = dirname(__FILE__) . '/';

$namespaceWithSlash = __NAMESPACE__ . '\\';
$this->prefix = $namespaceWithSlash;

$this->libraryDir = $this->rootDir . '../..';
if ( !self::isPhar() ) {
$this->libraryDir = realpath($this->libraryDir);
}
$this->libraryDir = $this->libraryDir . '/';

//Usually, dependencies like Parsedown are in the global namespace,
//but if someone adds a custom namespace to the entire library, they
//will be in the same namespace as this class.
$isCustomNamespace = (
substr($namespaceWithSlash, 0, strlen(self::DEFAULT_NS_PREFIX)) !== self::DEFAULT_NS_PREFIX
);
$libraryPrefix = $isCustomNamespace ? $namespaceWithSlash : '';

$this->staticMap = array(
$libraryPrefix . 'PucReadmeParser' => 'vendor/PucReadmeParser.php',
$libraryPrefix . 'Parsedown' => 'vendor/Parsedown.php',
);

//Add the generic, major-version-only factory class to the static map.
$versionSeparatorPos = strrpos(__NAMESPACE__, '\\v');
if ( $versionSeparatorPos !== false ) {
$versionSegment = substr(__NAMESPACE__, $versionSeparatorPos + 1);
$pointPos = strpos($versionSegment, 'p');
if ( ($pointPos !== false) && ($pointPos > 1) ) {
$majorVersionSegment = substr($versionSegment, 0, $pointPos);
$majorVersionNs = __NAMESPACE__ . '\\' . $majorVersionSegment;
$this->staticMap[$majorVersionNs . '\\PucFactory'] =
'Puc/' . $majorVersionSegment . '/Factory.php';
}
}

spl_autoload_register(array($this, 'autoload'));
}

/**
* Determine if this file is running as part of a Phar archive.
*
* @return bool
*/
private static function isPhar() {
//Check if the current file path starts with "phar://".
static $pharProtocol = 'phar://';
return (substr(__FILE__, 0, strlen($pharProtocol)) === $pharProtocol);
}

public function autoload($className) {
if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
include($this->libraryDir . $this->staticMap[$className]);
return;
}

if ( strpos($className, $this->prefix) === 0 ) {
$path = substr($className, strlen($this->prefix));
$path = str_replace(array('_', '\\'), '/', $path);
$path = $this->rootDir . $path . '.php';

if ( file_exists($path) ) {
include $path;
}
}
}
}

endif;
Loading