diff --git a/CHANGES.md b/CHANGES.md index 8243233..32d67f5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 1.6.4 (12/5/24) +* Changed: Updated the updater. +* Changed: [Performance] Only run ACF filters in back end. + ## 1.6.3 (1/19/24) * Fixed: Encoded special characters were displaying on the front end in some configurations. diff --git a/blocks/table-of-contents/block.php b/blocks/table-of-contents/block.php index 29c58e4..90abff0 100644 --- a/blocks/table-of-contents/block.php +++ b/blocks/table-of-contents/block.php @@ -112,7 +112,6 @@ function mai_register_toc_field_group() { 'label' => __( 'Label', 'mai-table-of-contents' ), 'name' => 'maitoc_label', 'type' => 'text', - 'required' => 1, 'conditional_logic' => [ [ [ diff --git a/classes/class-settings.php b/classes/class-settings.php index 8408b88..3f06737 100644 --- a/classes/class-settings.php +++ b/classes/class-settings.php @@ -40,6 +40,10 @@ function hooks() { * @return array */ function get_post_types( $field ) { + if ( ! is_admin() ) { + return $field; + } + // Reset choices. $field['choices'] = []; diff --git a/composer.lock b/composer.lock index 6bb25b3..aabf8e2 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.3", + "version": "v5.5", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "0b6bd7cd3286688ab680201aa6a7d8572c51ae1f" + "reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/0b6bd7cd3286688ab680201aa6a7d8572c51ae1f", - "reference": "0b6bd7cd3286688ab680201aa6a7d8572c51ae1f", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/845d65da93bcff31649ede00d9d73b1beadbb7f0", + "reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ "type": "library", "autoload": { "files": [ - "load-v5p3.php" + "load-v5p5.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -52,9 +52,9 @@ ], "support": { "issues": "https://github.com/YahnisElsts/plugin-update-checker/issues", - "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.3" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.5" }, - "time": "2023-11-09T08:34:00+00:00" + "time": "2024-10-16T14:25:00+00:00" } ], "packages-dev": [], diff --git a/mai-table-of-contents.php b/mai-table-of-contents.php index 8358abf..22d9ec3 100644 --- a/mai-table-of-contents.php +++ b/mai-table-of-contents.php @@ -4,7 +4,7 @@ * Plugin Name: Mai Table of Contents * Plugin URI: https://bizbudding.com/mai-design-pack/ * Description: Automatically create a table of contents from headings in your posts. - * Version: 1.6.3 + * Version: 1.6.4 * * Author: BizBudding * Author URI: https://bizbudding.com @@ -92,7 +92,7 @@ public function __wakeup() { private function setup_constants() { // Plugin version. if ( ! defined( 'MAI_TABLE_OF_CONTENTS_VERSION' ) ) { - define( 'MAI_TABLE_OF_CONTENTS_VERSION', '1.6.3' ); + define( 'MAI_TABLE_OF_CONTENTS_VERSION', '1.6.4' ); } // Plugin Folder Path. diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 605388e..c1789fb 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -6,5 +6,5 @@ $baseDir = dirname($vendorDir); return array( - '45a16669595eb3c0a9e2994e57fc3188' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p3.php', + '256558b1ddf2fa4366ea7d7602798dd1' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p5.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 534f652..1c66a9f 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInit1782162e12bcf11213202aa27e2616cd { public static $files = array ( - '45a16669595eb3c0a9e2994e57fc3188' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p3.php', + '256558b1ddf2fa4366ea7d7602798dd1' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p5.php', ); public static $classMap = array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index fc2280d..3284a75 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,29 +2,29 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.3", - "version_normalized": "5.3.0.0", + "version": "v5.5", + "version_normalized": "5.5.0.0", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "0b6bd7cd3286688ab680201aa6a7d8572c51ae1f" + "reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/0b6bd7cd3286688ab680201aa6a7d8572c51ae1f", - "reference": "0b6bd7cd3286688ab680201aa6a7d8572c51ae1f", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/845d65da93bcff31649ede00d9d73b1beadbb7f0", + "reference": "845d65da93bcff31649ede00d9d73b1beadbb7f0", "shasum": "" }, "require": { "ext-json": "*", "php": ">=5.6.20" }, - "time": "2023-11-09T08:34:00+00:00", + "time": "2024-10-16T14:25:00+00:00", "type": "library", "installation-source": "dist", "autoload": { "files": [ - "load-v5p3.php" + "load-v5p5.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -49,7 +49,7 @@ ], "support": { "issues": "https://github.com/YahnisElsts/plugin-update-checker/issues", - "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.3" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.5" }, "install-path": "../yahnis-elsts/plugin-update-checker" } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 3c055f2..1a38344 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => '__root__', 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '050b3614b33ca9be5c8522661c678034f79c5a53', + 'reference' => 'dc4e24a7f535ca7bb83b9c5d62e8bc7d56e16958', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,16 +13,16 @@ '__root__' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => '050b3614b33ca9be5c8522661c678034f79c5a53', + 'reference' => 'dc4e24a7f535ca7bb83b9c5d62e8bc7d56e16958', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'yahnis-elsts/plugin-update-checker' => array( - 'pretty_version' => 'v5.3', - 'version' => '5.3.0.0', - 'reference' => '0b6bd7cd3286688ab680201aa6a7d8572c51ae1f', + 'pretty_version' => 'v5.5', + 'version' => '5.5.0.0', + 'reference' => '845d65da93bcff31649ede00d9d73b1beadbb7f0', 'type' => 'library', 'install_path' => __DIR__ . '/../yahnis-elsts/plugin-update-checker', 'aliases' => array(), diff --git a/vendor/yahnis-elsts/plugin-update-checker/.editorconfig b/vendor/yahnis-elsts/plugin-update-checker/.editorconfig deleted file mode 100644 index 1b51cad..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/.editorconfig +++ /dev/null @@ -1,15 +0,0 @@ -[*] -charset=utf-8 -end_of_line=lf -insert_final_newline=false -indent_style=tab -tab_width=4 - -[{phpunit.xml.dist,*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}] -indent_style=space -indent_size=4 - -[*.svg] -indent_style=space -indent_size=4 - diff --git a/vendor/yahnis-elsts/plugin-update-checker/.gitattributes b/vendor/yahnis-elsts/plugin-update-checker/.gitattributes deleted file mode 100644 index ba74e78..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -/build export-ignore diff --git a/vendor/yahnis-elsts/plugin-update-checker/.gitignore b/vendor/yahnis-elsts/plugin-update-checker/.gitignore deleted file mode 100644 index 7126070..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/.gitignore +++ /dev/null @@ -1,40 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# The entire IDEA/PhpStorm directory -.idea/ - -# CMake -cmake-build-*/ - -# Mongo Explorer plugin -.idea/**/mongoSettings.xml - -# File-based project format -*.iws - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -# Editor-based Rest Client -.idea/httpRequests - -# Android studio 3.1+ serialized cache file -.idea/caches/build_file_checksums.ser diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php index a2ec2d2..a8ebf7e 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php @@ -4,7 +4,7 @@ if ( !class_exists(PucFactory::class, false) ): - class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p3\PucFactory { + class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p5\PucFactory { } endif; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Autoloader.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Autoloader.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Autoloader.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Autoloader.php index 5074ab2..b937260 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Autoloader.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Autoloader.php @@ -1,6 +1,6 @@ Status'; echo ''; $state = $this->updateChecker->getUpdateState(); - $checkNowButton = ''; + $checkButtonId = $this->updateChecker->getUniqueName('check-now-button'); if ( function_exists('get_submit_button') ) { $checkNowButton = get_submit_button( 'Check Now', 'secondary', 'puc-check-now-button', false, - array('id' => $this->updateChecker->getUniqueName('check-now-button')) + array('id' => $checkButtonId) + ); + } else { + //get_submit_button() is not available in the frontend. Make a button directly. + //It won't look the same without admin styles, but it should still work. + $checkNowButton = sprintf( + '', + esc_attr($checkButtonId), + esc_attr('Check Now') ); } diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/PluginExtension.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/PluginExtension.php similarity index 90% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/PluginExtension.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/PluginExtension.php index b5546c7..50972ec 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/PluginExtension.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/PluginExtension.php @@ -1,8 +1,8 @@ updateChecker->getUniqueName('request-info-button'); if ( function_exists('get_submit_button') ) { $requestInfoButton = get_submit_button( 'Request Info', 'secondary', 'puc-request-info-button', false, - array('id' => $this->updateChecker->getUniqueName('request-info-button')) + array('id' => $buttonId) + ); + } else { + $requestInfoButton = sprintf( + '', + esc_attr($buttonId), + esc_attr('Request Info') ); } return $requestInfoButton; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/ThemePanel.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/ThemePanel.php similarity index 79% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/ThemePanel.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/ThemePanel.php index 3183ead..e9c99ff 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/DebugBar/ThemePanel.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/DebugBar/ThemePanel.php @@ -1,8 +1,8 @@ removeHooks(); + $this->updateChecker->removeHooks(); + } + } + /** * Runs upon the WP action upgrader_process_complete. * @@ -108,16 +125,6 @@ public function upgraderProcessComplete( /** @noinspection PhpUnusedParameterInspection */ $upgrader, $upgradeInfo ) { - //Cancel all further actions if the current version of PUC has been deleted or overwritten - //by a different version during the upgrade. If we try to do anything more in that situation, - //we could trigger a fatal error by trying to autoload a deleted class. - clearstatcache(); - if ( !file_exists(__FILE__) ) { - $this->removeHooks(); - $this->updateChecker->removeHooks(); - return; - } - //Sanity check and limitation to relevant types. if ( !is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action']) @@ -180,6 +187,21 @@ public function maybeCheckForUpdates() { $state = $this->updateChecker->getUpdateState(); $shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod()); + if ( $shouldCheck ) { + //Sanity check: Do not proceed if one of the critical classes is missing. + //That can happen - theoretically and extremely rarely - if maybeCheckForUpdates() + //is called before the old version of our plugin has been fully deleted, or + //called from an independent AJAX request during deletion. + if ( !( + class_exists(Utils::class) + && class_exists(Metadata::class) + && class_exists(Plugin\Update::class) + && class_exists(Theme\Update::class) + ) ) { + return; + } + } + //Let plugin authors substitute their own algorithm. $shouldCheck = apply_filters( $this->updateChecker->getUniqueName('check_now'), diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/StateStore.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/StateStore.php similarity index 93% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/StateStore.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/StateStore.php index f182787..b3dac76 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/StateStore.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/StateStore.php @@ -1,5 +1,5 @@ optionName, null); - if ( !is_object($state) ) { + if ( + !is_object($state) + //Sanity check: If the Utils class is missing, the plugin is probably in the process + //of being deleted (e.g. the old version gets deleted during an update). + || !class_exists(Utils::class) + ) { $this->lastCheck = 0; $this->checkedVersion = ''; $this->update = null; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Theme/Package.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Theme/Package.php similarity index 93% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Theme/Package.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Theme/Package.php index 8a83f66..7180229 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/Theme/Package.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/Theme/Package.php @@ -1,7 +1,7 @@ debugMode = (bool)(constant('WP_DEBUG')); $this->metadataUrl = $metadataUrl; @@ -91,6 +105,10 @@ public function __construct($metadataUrl, $directoryName, $slug = null, $checkPe } } + if ( empty($this->translationType) ) { + $this->translationType = $this->componentType; + } + $this->package = $this->createInstalledPackage(); $this->scheduler = $this->createScheduler($checkPeriod); $this->upgraderStatus = new UpgraderStatus(); @@ -103,6 +121,10 @@ public function __construct($metadataUrl, $directoryName, $slug = null, $checkPe } $this->installHooks(); + + if ( ($this->wpCliCheckTrigger === null) && defined('WP_CLI') ) { + $this->wpCliCheckTrigger = new WpCliCheckTrigger($this->componentType, $this->scheduler); + } } /** @@ -149,6 +171,10 @@ protected function installHooks() { //Allow HTTP requests to the metadata URL even if it's on a local host. add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2); + //Potentially exclude information about this entity from core update check requests to api.wordpress.org. + //phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.http_request_args -- Doesn't modify timeouts. + add_filter('http_request_args', array($this, 'excludeEntityFromWordPressAPI'), 10, 2); + //DebugBar integration. if ( did_action('plugins_loaded') ) { $this->maybeInitDebugBar(); @@ -170,6 +196,7 @@ public function removeHooks() { remove_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10); remove_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10); + remove_filter('http_request_args', array($this, 'excludeEntityFromWordPressAPI')); remove_action('plugins_loaded', array($this, 'maybeInitDebugBar')); remove_action('init', array($this, 'loadTextDomain')); @@ -244,6 +271,76 @@ public function getInstalledPackage() { */ abstract protected function createScheduler($checkPeriod); + /** + * Remove information about this plugin or theme from the requests that WordPress core sends + * to api.wordpress.org when checking for updates. + * + * @param array $args + * @param string $url + * @return array + */ + public function excludeEntityFromWordPressAPI($args, $url) { + //Is this an api.wordpress.org update check request? + $parsedUrl = wp_parse_url($url); + if ( !isset($parsedUrl['host']) || (strtolower($parsedUrl['host']) !== 'api.wordpress.org') ) { + return $args; + } + + $typePluralised = $this->componentType . 's'; + $expectedPathPrefix = '/' . $typePluralised . '/update-check/1.'; //e.g. "/plugins/update-check/1.1/" + if ( !isset($parsedUrl['path']) || !Utils::startsWith($parsedUrl['path'], $expectedPathPrefix) ) { + return $args; + } + + //Plugins and themes can disable this feature by using the filter below. + if ( !apply_filters( + $this->getUniqueName('remove_from_default_update_checks'), + true, $this, $args, $url + ) ) { + return $args; + } + + if ( empty($args['body'][$typePluralised]) ) { + return $args; + } + + $reportingItems = json_decode($args['body'][$typePluralised], true); + if ( $reportingItems === null ) { + return $args; + } + + //The list of installed items uses different key formats for plugins and themes. + //Luckily, we can reuse the getUpdateListKey() method here. + $updateListKey = $this->getUpdateListKey(); + if ( isset($reportingItems[$typePluralised][$updateListKey]) ) { + unset($reportingItems[$typePluralised][$updateListKey]); + } + + if ( !empty($reportingItems['active']) ) { + if ( is_array($reportingItems['active']) ) { + foreach ($reportingItems['active'] as $index => $relativePath) { + if ( $relativePath === $updateListKey ) { + unset($reportingItems['active'][$index]); + } + } + //Re-index the array. + $reportingItems['active'] = array_values($reportingItems['active']); + } else if ( $reportingItems['active'] === $updateListKey ) { + //For themes, the "active" field is a string that contains the theme's directory name. + //Pretend that the default theme is active so that we don't reveal the actual theme. + if ( defined('WP_DEFAULT_THEME') ) { + $reportingItems['active'] = WP_DEFAULT_THEME; + } + + //Unfortunately, it doesn't seem to be documented if we can safely remove the "active" + //key. So when we don't know the default theme, we'll just leave it as is. + } + } + + $args['body'][$typePluralised] = wp_json_encode($reportingItems); + return $args; + } + /** * Check for updates. The results are stored in the DB option specified in $optionName. * @@ -676,7 +773,7 @@ protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array() $result = wp_remote_get($url, $options); $result = apply_filters($this->getUniqueName('request_metadata_http_result'), $result, $url, $options); - + //Try to parse the response $status = $this->validateApiResponse($result); $metadata = null; @@ -902,25 +999,62 @@ public function fixDirectoryName($source, $remoteSource, $upgrader) { return $source; } + //Fix the remote source structure if necessary. + //The update archive should contain a single directory that contains the rest of plugin/theme files. + //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource). + //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files + //after update. + if ( $this->isBadDirectoryStructure($remoteSource) ) { + //Create a new directory using the plugin slug. + $newDirectory = trailingslashit($remoteSource) . $this->slug . '/'; + + if ( !$wp_filesystem->is_dir($newDirectory) ) { + $wp_filesystem->mkdir($newDirectory); + + //Move all files to the newly created directory. + $sourceFiles = $wp_filesystem->dirlist($remoteSource); + if ( is_array($sourceFiles) ) { + $sourceFiles = array_keys($sourceFiles); + $allMoved = true; + foreach ($sourceFiles as $filename) { + //Skip our newly created folder. + if ( $filename === $this->slug ) { + continue; + } + + $previousSource = trailingslashit($remoteSource) . $filename; + $newSource = trailingslashit($newDirectory) . $filename; + + if ( !$wp_filesystem->move($previousSource, $newSource, true) ) { + $allMoved = false; + break; + } + } + + if ( $allMoved ) { + //Rename source. + $source = $newDirectory; + } else { + //Delete our newly created folder including all files in it. + $wp_filesystem->rmdir($newDirectory, true); + + //And return a relevant error. + return new WP_Error( + 'puc-incorrect-directory-structure', + sprintf( + 'The directory structure of the update was incorrect. All files should be inside ' . + 'a directory named %s, not at the root of the ZIP archive. Plugin Update Checker tried to fix the directory structure, but failed.', + htmlentities($this->slug) + ) + ); + } + } + } + } + //Rename the source to match the existing directory. $correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/'; if ( $source !== $correctedSource ) { - //The update archive should contain a single directory that contains the rest of plugin/theme files. - //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource). - //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files - //after update. - if ( $this->isBadDirectoryStructure($remoteSource) ) { - return new WP_Error( - 'puc-incorrect-directory-structure', - sprintf( - 'The directory structure of the update is incorrect. All files should be inside ' . - 'a directory named %s, not at the root of the ZIP archive.', - htmlentities($this->slug) - ) - ); - } - - /** @var \WP_Upgrader_Skin $upgrader ->skin */ $upgrader->skin->feedback(sprintf( 'Renaming %s to %s…', '' . basename($source) . '', diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/UpgraderStatus.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/UpgraderStatus.php similarity index 99% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/UpgraderStatus.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/UpgraderStatus.php index 81b1f4c..f06db1c 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p3/UpgraderStatus.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p5/UpgraderStatus.php @@ -1,5 +1,5 @@ componentType = $componentType; + $this->scheduler = $scheduler; + + if ( !defined('WP_CLI') || !class_exists(WP_CLI::class, false) ) { + return; //Nothing to do if WP-CLI is not available. + } + + /* + * We can't hook directly into wp_update_plugins(), but we can hook into the WP-CLI + * commands that call it. We'll use the "before_invoke:xyz" hook to trigger update checks. + */ + foreach ($this->getRelevantCommands() as $command) { + WP_CLI::add_hook('before_invoke:' . $command, [$this, 'triggerUpdateCheckOnce']); + } + } + + private function getRelevantCommands() { + $result = []; + foreach (['status', 'list', 'update'] as $subcommand) { + $result[] = $this->componentType . ' ' . $subcommand; + } + return $result; + } + + /** + * Trigger a potential update check once. + * + * @param mixed $input + * @return mixed The input value, unchanged. + * @internal This method is public so that it can be used as a WP-CLI hook callback. + * It should not be called directly. + * + */ + public function triggerUpdateCheckOnce($input = null) { + if ( $this->wasCheckTriggered ) { + return $input; + } + + $this->wasCheckTriggered = true; + $this->scheduler->maybeCheckForUpdates(); + + return $input; + } +} \ No newline at end of file diff --git a/vendor/yahnis-elsts/plugin-update-checker/README.md b/vendor/yahnis-elsts/plugin-update-checker/README.md index 1af16f0..843ed82 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/README.md +++ b/vendor/yahnis-elsts/plugin-update-checker/README.md @@ -29,7 +29,7 @@ From the users' perspective, it works just like with plugins and themes hosted o Getting Started --------------- -*Note:* In each of the below examples, part of the instructions are to create an instance of the update checker class. It's recommended to do this either during the `plugins_loaded` action or outside of any hooks. If you do it only during an `admin_*` action, then updates will not be visible to a wide variety of WordPress maanagement tools; they will only be visible to logged-in users on dashboard pages. +*Note:* In each of the below examples, part of the instructions is to create an instance of the update checker class. It's recommended to do this either during the `plugins_loaded` action or outside of any hooks. If you do it only during an `admin_*` action, then updates will not be visible to a wide variety of WordPress management tools; they will only be visible to logged-in users on dashboard pages. ### Self-hosted Plugins and Themes @@ -252,8 +252,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 - use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\PluginUpdateChecker; - use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitLabApi; + use YahnisElsts\PluginUpdateChecker\v5p5\Vcs\PluginUpdateChecker; + use YahnisElsts\PluginUpdateChecker\v5p5\Vcs\GitLabApi; $myUpdateChecker = new PluginUpdateChecker( new GitLabApi('https://myserver.com/user-name/repo-name/'), @@ -264,8 +264,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 - use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\PluginUpdateChecker; - use YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitLabApi; + use YahnisElsts\PluginUpdateChecker\v5p5\Vcs\PluginUpdateChecker; + use YahnisElsts\PluginUpdateChecker\v5p5\Vcs\GitLabApi; $myUpdateChecker = new PluginUpdateChecker( new GitLabApi( @@ -347,14 +347,14 @@ Other classes have also been renamed, usually by simply removing the `Puc_vXpY_` | Old class name | New class name | |-------------------------------------|----------------------------------------------------------------| | `Puc_v4_Factory` | `YahnisElsts\PluginUpdateChecker\v5\PucFactory` | -| `Puc_v4p13_Factory` | `YahnisElsts\PluginUpdateChecker\v5p3\PucFactory` | -| `Puc_v4p13_Plugin_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p3\Plugin\UpdateChecker` | -| `Puc_v4p13_Theme_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p3\Theme\UpdateChecker` | -| `Puc_v4p13_Vcs_PluginUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p3\Vcs\PluginUpdateChecker` | -| `Puc_v4p13_Vcs_ThemeUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p3\Vcs\ThemeUpdateChecker` | -| `Puc_v4p13_Vcs_GitHubApi` | `YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitHubApi` | -| `Puc_v4p13_Vcs_GitLabApi` | `YahnisElsts\PluginUpdateChecker\v5p3\Vcs\GitLabApi` | -| `Puc_v4p13_Vcs_BitBucketApi` | `YahnisElsts\PluginUpdateChecker\v5p3\Vcs\BitBucketApi` | +| `Puc_v4p13_Factory` | `YahnisElsts\PluginUpdateChecker\v5p5\PucFactory` | +| `Puc_v4p13_Plugin_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p5\Plugin\UpdateChecker` | +| `Puc_v4p13_Theme_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p5\Theme\UpdateChecker` | +| `Puc_v4p13_Vcs_PluginUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p5\Vcs\PluginUpdateChecker` | +| `Puc_v4p13_Vcs_ThemeUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p5\Vcs\ThemeUpdateChecker` | +| `Puc_v4p13_Vcs_GitHubApi` | `YahnisElsts\PluginUpdateChecker\v5p5\Vcs\GitHubApi` | +| `Puc_v4p13_Vcs_GitLabApi` | `YahnisElsts\PluginUpdateChecker\v5p5\Vcs\GitLabApi` | +| `Puc_v4p13_Vcs_BitBucketApi` | `YahnisElsts\PluginUpdateChecker\v5p5\Vcs\BitBucketApi` | License Management ------------------ diff --git a/vendor/yahnis-elsts/plugin-update-checker/composer.json b/vendor/yahnis-elsts/plugin-update-checker/composer.json index 27b65b0..5cb6861 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/composer.json +++ b/vendor/yahnis-elsts/plugin-update-checker/composer.json @@ -18,6 +18,6 @@ "ext-json": "*" }, "autoload": { - "files": ["load-v5p3.php"] + "files": ["load-v5p5.php"] } } diff --git a/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json b/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json deleted file mode 100644 index 946b730..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "name": "My Example Plugin", - "version": "2.0", - "download_url": "http://example.com/updates/example-plugin.zip", - - "homepage": "http://example.com/", - "requires": "4.5", - "tested": "4.8", - "last_updated": "2017-01-01 16:17:00", - "upgrade_notice": "Here's why you should upgrade...", - - "author": "Janis Elsts", - "author_homepage": "http://example.com/", - - "sections": { - "description": "(Required) Plugin description. Basic HTML can be used in all sections.", - "installation": "(Recommended) Installation instructions.", - "changelog": "(Recommended) Changelog.

This section will be displayed by default when the user clicks 'View version x.y.z details'.

", - "custom_section": "This is a custom section labeled 'Custom Section'." - }, - - "icons" : { - "1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png", - "2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png" - }, - - "banners": { - "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png", - "high": "http://w-shadow.com/files/external-update-example/assets/banner-1544x500.png" - }, - - "translations": [ - { - "language": "fr_FR", - "version": "4.0", - "updated": "2016-04-22 23:22:42", - "package": "http://example.com/updates/translations/french-language-pack.zip" - }, - { - "language": "de_DE", - "version": "5.0", - "updated": "2016-04-22 23:22:42", - "package": "http://example.com/updates/translations/german-language-pack.zip" - } - ], - - "rating": 90, - "num_ratings": 123, - - "downloaded": 1234, - "active_installs": 12345 -} \ No newline at end of file diff --git a/vendor/yahnis-elsts/plugin-update-checker/examples/theme.json b/vendor/yahnis-elsts/plugin-update-checker/examples/theme.json deleted file mode 100644 index 0e08072..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/examples/theme.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "version": "2.0", - "details_url": "http://example.com/version-2.0-details.html", - "download_url": "http://example.com/example-theme-2.0.zip" -} \ No newline at end of file diff --git a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.mo b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.mo new file mode 100644 index 0000000..08306de Binary files /dev/null and b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.mo differ diff --git a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.po b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.po new file mode 100644 index 0000000..6b1ba21 --- /dev/null +++ b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-el.po @@ -0,0 +1,52 @@ +msgid "" +msgstr "" +"Project-Id-Version: plugin-update-checker\n" +"POT-Creation-Date: 2022-07-29 15:34+0300\n" +"PO-Revision-Date: 2024-05-09 22:22+0000\n" +"Last-Translator: theogk\n" +"Language-Team: Ελληνικά\n" +"Language: el\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Loco https://localise.biz/\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" +"X-Poedit-SearchPath-0: .\n" +"Report-Msgid-Bugs-To: \n" +"X-Loco-Version: 2.6.9; wp-6.5.3" + +#: Puc/v5p4/Plugin/Ui.php:128 +msgid "Check for updates" +msgstr "Έλεγχος για ενημερώσεις" + +#: Puc/v5p4/Plugin/Ui.php:214 +#, php-format +msgctxt "the plugin title" +msgid "The %s plugin is up to date." +msgstr "Το πρόσθετο %s είναι ενημερωμένο." + +#: Puc/v5p4/Plugin/Ui.php:216 +#, php-format +msgctxt "the plugin title" +msgid "A new version of the %s plugin is available." +msgstr "Μία νέα έκδοση είναι διαθέσιμη για το πρόσθετο %s." + +#: Puc/v5p4/Plugin/Ui.php:218 +#, php-format +msgctxt "the plugin title" +msgid "Could not determine if updates are available for %s." +msgstr "" +"Δεν ήταν εφικτό να εκτελεστεί ο έλεγχος για νέες ενημερώσεις για το πρόσθετο " +"%s." + +#: Puc/v5p4/Plugin/Ui.php:224 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Άγνωστο πρόβλημα του ενημερωτή προσθέτων \"%s\"" + +#: Puc/v5p4/Vcs/PluginUpdateChecker.php:100 +msgid "There is no changelog available." +msgstr "Δεν υπάρχει διαθέσιμο αρχείο αλλαγών." diff --git a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo index 86d1144..5236777 100644 Binary files a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo and b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.mo differ diff --git a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.po b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.po index d4f7056..b9e0eb6 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.po +++ b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-zh_CN.po @@ -1,57 +1,57 @@ msgid "" msgstr "" "Project-Id-Version: plugin-update-checker\n" -"POT-Creation-Date: 2022-01-29 12:09+0800\n" -"PO-Revision-Date: 2022-01-29 12:10+0800\n" +"POT-Creation-Date: 2024-05-18 00:08+0800\n" +"PO-Revision-Date: 2024-05-18 00:08+0800\n" "Last-Translator: Seaton Jiang \n" "Language-Team: \n" "Language: zh_CN\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.4.3\n" -"X-Poedit-Basepath: ..\n" "Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Poedit 3.4.4\n" +"X-Poedit-Basepath: ..\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" "X-Poedit-SearchPath-0: .\n" -#: Puc/v4p11/Plugin/Ui.php:54 +#: Puc/v5p4/Plugin/Ui.php:56 msgid "View details" msgstr "查看详情" -#: Puc/v4p11/Plugin/Ui.php:77 +#: Puc/v5p4/Plugin/Ui.php:79 #, php-format msgid "More information about %s" msgstr "%s 的更多信息" -#: Puc/v4p11/Plugin/Ui.php:128 +#: Puc/v5p4/Plugin/Ui.php:130 msgid "Check for updates" msgstr "检查更新" -#: Puc/v4p11/Plugin/Ui.php:214 +#: Puc/v5p4/Plugin/Ui.php:217 #, php-format msgctxt "the plugin title" msgid "The %s plugin is up to date." msgstr "%s 目前是最新版本。" -#: Puc/v4p11/Plugin/Ui.php:216 +#: Puc/v5p4/Plugin/Ui.php:219 #, php-format msgctxt "the plugin title" msgid "A new version of the %s plugin is available." msgstr "%s 当前有可用的更新。" -#: Puc/v4p11/Plugin/Ui.php:218 +#: Puc/v5p4/Plugin/Ui.php:221 #, php-format msgctxt "the plugin title" msgid "Could not determine if updates are available for %s." msgstr "%s 无法确定是否有可用的更新。" -#: Puc/v4p11/Plugin/Ui.php:224 +#: Puc/v5p4/Plugin/Ui.php:227 #, php-format msgid "Unknown update checker status \"%s\"" msgstr "未知的更新检查状态:%s" -#: Puc/v4p11/Vcs/PluginUpdateChecker.php:100 +#: Puc/v5p4/Vcs/PluginUpdateChecker.php:113 msgid "There is no changelog available." msgstr "没有可用的更新日志。" diff --git a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot index 4985307..a3f9aca 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot +++ b/vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: plugin-update-checker\n" -"POT-Creation-Date: 2022-07-29 15:34+0300\n" +"POT-Creation-Date: 2024-10-16 17:23+0300\n" "PO-Revision-Date: 2016-01-10 20:59+0100\n" "Last-Translator: \n" "Language-Team: \n" @@ -11,39 +11,39 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 3.1.1\n" +"X-Generator: Poedit 3.5\n" "X-Poedit-Basepath: ..\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" "X-Poedit-SearchPath-0: .\n" -#: Puc/v5p3/Plugin/Ui.php:128 +#: Puc/v5p5/Plugin/Ui.php:130 msgid "Check for updates" msgstr "" -#: Puc/v5p3/Plugin/Ui.php:214 +#: Puc/v5p5/Plugin/Ui.php:217 #, php-format msgctxt "the plugin title" msgid "The %s plugin is up to date." msgstr "" -#: Puc/v5p3/Plugin/Ui.php:216 +#: Puc/v5p5/Plugin/Ui.php:219 #, php-format msgctxt "the plugin title" msgid "A new version of the %s plugin is available." msgstr "" -#: Puc/v5p3/Plugin/Ui.php:218 +#: Puc/v5p5/Plugin/Ui.php:221 #, php-format msgctxt "the plugin title" msgid "Could not determine if updates are available for %s." msgstr "" -#: Puc/v5p3/Plugin/Ui.php:224 +#: Puc/v5p5/Plugin/Ui.php:227 #, php-format msgid "Unknown update checker status \"%s\"" msgstr "" -#: Puc/v5p3/Vcs/PluginUpdateChecker.php:100 +#: Puc/v5p5/Vcs/PluginUpdateChecker.php:113 msgid "There is no changelog available." msgstr "" diff --git a/vendor/yahnis-elsts/plugin-update-checker/load-v5p3.php b/vendor/yahnis-elsts/plugin-update-checker/load-v5p5.php similarity index 80% rename from vendor/yahnis-elsts/plugin-update-checker/load-v5p3.php rename to vendor/yahnis-elsts/plugin-update-checker/load-v5p5.php index 1de3d58..1ce30a1 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/load-v5p3.php +++ b/vendor/yahnis-elsts/plugin-update-checker/load-v5p5.php @@ -1,14 +1,14 @@ $pucVersionedClass ) { - MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.3'); + MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.5'); //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. - MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.3'); + MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.5'); } diff --git a/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml b/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml deleted file mode 100644 index e8260b9..0000000 --- a/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - PHPCS settings for Plugin Update Checker - - - - - - - - ./ - - - - - - - - - ^vendor/* - diff --git a/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php b/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php index 7a9268c..0c070a8 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php +++ b/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php @@ -1,10 +1,10 @@