From d85d6f58ef5e011135e6e304f79b2527c17c2935 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Wed, 28 Jun 2023 12:20:52 -0400 Subject: [PATCH 1/4] no need to double escape --- classes/class-table-of-contents.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-table-of-contents.php b/classes/class-table-of-contents.php index a449607..2a51f1e 100644 --- a/classes/class-table-of-contents.php +++ b/classes/class-table-of-contents.php @@ -149,7 +149,7 @@ function get_toc() { } // Bail if not enough h2s. - if ( count( $this->data['matches'] ) < absint( $this->args['headings'] ) ) { + if ( count( $this->data['matches'] ) < $this->args['headings'] ) { return $cache[ $this->post_id ]; } From 29a03b4b6eff2a54e2450d1539d27161afc4d205 Mon Sep 17 00:00:00 2001 From: JiveDig Date: Wed, 28 Jun 2023 15:35:25 -0400 Subject: [PATCH 2/4] update updater --- vendor/composer/autoload_files.php | 2 +- vendor/composer/autoload_static.php | 2 +- vendor/composer/installed.json | 16 +- vendor/composer/installed.php | 10 +- .../plugin-update-checker/.gitattributes | 1 + .../Puc/v5/PucFactory.php | 2 +- .../Puc/{v5p0 => v5p1}/Autoloader.php | 2 +- .../Puc/{v5p0 => v5p1}/DebugBar/Extension.php | 6 +- .../Puc/{v5p0 => v5p1}/DebugBar/Panel.php | 13 +- .../DebugBar/PluginExtension.php | 4 +- .../{v5p0 => v5p1}/DebugBar/PluginPanel.php | 4 +- .../{v5p0 => v5p1}/DebugBar/ThemePanel.php | 4 +- .../Puc/{v5p0 => v5p1}/InstalledPackage.php | 2 +- .../Puc/{v5p0 => v5p1}/Metadata.php | 2 +- .../Puc/{v5p0 => v5p1}/OAuthSignature.php | 2 +- .../Puc/{v5p0 => v5p1}/Plugin/Package.php | 8 +- .../Puc/{v5p0 => v5p1}/Plugin/PluginInfo.php | 4 +- .../Puc/{v5p0 => v5p1}/Plugin/Ui.php | 2 +- .../Puc/{v5p0 => v5p1}/Plugin/Update.php | 4 +- .../{v5p0 => v5p1}/Plugin/UpdateChecker.php | 10 +- .../Puc/{v5p0 => v5p1}/PucFactory.php | 10 +- .../Puc/{v5p0 => v5p1}/Scheduler.php | 4 +- .../Puc/{v5p0 => v5p1}/StateStore.php | 7 +- .../Puc/{v5p0 => v5p1}/Theme/Package.php | 4 +- .../Puc/{v5p0 => v5p1}/Theme/Update.php | 4 +- .../{v5p0 => v5p1}/Theme/UpdateChecker.php | 10 +- .../Puc/{v5p0 => v5p1}/Update.php | 2 +- .../Puc/{v5p0 => v5p1}/UpdateChecker.php | 6 +- .../Puc/{v5p0 => v5p1}/UpgraderStatus.php | 4 +- .../Puc/{v5p0 => v5p1}/Utils.php | 2 +- .../Puc/{v5p0 => v5p1}/Vcs/Api.php | 28 ++- .../Puc/{v5p0 => v5p1}/Vcs/BaseChecker.php | 2 +- .../Puc/{v5p0 => v5p1}/Vcs/BitBucketApi.php | 8 +- .../Puc/{v5p0 => v5p1}/Vcs/GitHubApi.php | 182 ++++++++++-------- .../Puc/{v5p0 => v5p1}/Vcs/GitLabApi.php | 154 ++++++++------- .../Vcs/PluginUpdateChecker.php | 4 +- .../Puc/{v5p0 => v5p1}/Vcs/Reference.php | 2 +- .../Puc/v5p1/Vcs/ReleaseAssetSupport.php | 83 ++++++++ .../Puc/v5p1/Vcs/ReleaseFilteringFeature.php | 108 +++++++++++ .../{v5p0 => v5p1}/Vcs/ThemeUpdateChecker.php | 6 +- .../{v5p0 => v5p1}/Vcs/VcsCheckerMethods.php | 2 +- .../plugin-update-checker/README.md | 91 ++++----- .../plugin-update-checker/composer.json | 2 +- .../examples/plugin.json | 102 +++++----- .../plugin-update-checker/examples/theme.json | 8 +- .../plugin-update-checker/js/debug-bar.js | 2 + .../languages/plugin-update-checker.pot | 12 +- .../{load-v5p0.php => load-v5p1.php} | 12 +- .../plugin-update-checker/phpcs.xml | 21 ++ .../plugin-update-checker.php | 4 +- .../vendor/PucReadmeParser.php | 6 +- 51 files changed, 644 insertions(+), 348 deletions(-) create mode 100644 vendor/yahnis-elsts/plugin-update-checker/.gitattributes rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Autoloader.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/DebugBar/Extension.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/DebugBar/Panel.php (92%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/DebugBar/PluginExtension.php (90%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/DebugBar/PluginPanel.php (87%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/DebugBar/ThemePanel.php (79%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/InstalledPackage.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Metadata.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/OAuthSignature.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Plugin/Package.php (95%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Plugin/PluginInfo.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Plugin/Ui.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Plugin/Update.php (96%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Plugin/UpdateChecker.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/PucFactory.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Scheduler.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/StateStore.php (95%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Theme/Package.php (93%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Theme/Update.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Theme/UpdateChecker.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Update.php (93%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/UpdateChecker.php (99%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/UpgraderStatus.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Utils.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/Api.php (91%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/BaseChecker.php (90%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/BitBucketApi.php (97%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/GitHubApi.php (72%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/GitLabApi.php (76%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/PluginUpdateChecker.php (98%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/Reference.php (95%) create mode 100644 vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ReleaseAssetSupport.php create mode 100644 vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ReleaseFilteringFeature.php rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/ThemeUpdateChecker.php (94%) rename vendor/yahnis-elsts/plugin-update-checker/Puc/{v5p0 => v5p1}/Vcs/VcsCheckerMethods.php (95%) rename vendor/yahnis-elsts/plugin-update-checker/{load-v5p0.php => load-v5p1.php} (80%) create mode 100644 vendor/yahnis-elsts/plugin-update-checker/phpcs.xml diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index b9076c9..a9b255d 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -6,5 +6,5 @@ $baseDir = dirname($vendorDir); return array( - '5ff2501974ebd86c0be698ddfca6451e' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p0.php', + '9b77ddcfb14408a32f5aaf74e0a11694' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p1.php', ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index de8cd9b..7e44255 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,7 +7,7 @@ class ComposerStaticInit1782162e12bcf11213202aa27e2616cd { public static $files = array ( - '5ff2501974ebd86c0be698ddfca6451e' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p0.php', + '9b77ddcfb14408a32f5aaf74e0a11694' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p1.php', ); public static $classMap = array ( diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index e22a8e4..48d679d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -2,29 +2,29 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.0", - "version_normalized": "5.0.0.0", + "version": "v5.1", + "version_normalized": "5.1.0.0", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "81be284da76f12c8751b477b2a0fa44364d26f84" + "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/81be284da76f12c8751b477b2a0fa44364d26f84", - "reference": "81be284da76f12c8751b477b2a0fa44364d26f84", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/48b03e93c9c2587f9276dce00ce2b6d94c1190d2", + "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2", "shasum": "" }, "require": { "ext-json": "*", "php": ">=5.6.20" }, - "time": "2022-10-28T17:46:32+00:00", + "time": "2023-05-20T11:55:43+00:00", "type": "library", "installation-source": "dist", "autoload": { "files": [ - "load-v5p0.php" + "load-v5p1.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.0" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.1" }, "install-path": "../yahnis-elsts/plugin-update-checker" } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index efb5b63..d43598d 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' => 'f4e7890d7d94bd0593a31b7604d7dc8e38b8a3e6', + 'reference' => 'd85d6f58ef5e011135e6e304f79b2527c17c2935', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -13,16 +13,16 @@ '__root__' => array( 'pretty_version' => 'dev-develop', 'version' => 'dev-develop', - 'reference' => 'f4e7890d7d94bd0593a31b7604d7dc8e38b8a3e6', + 'reference' => 'd85d6f58ef5e011135e6e304f79b2527c17c2935', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), 'yahnis-elsts/plugin-update-checker' => array( - 'pretty_version' => 'v5.0', - 'version' => '5.0.0.0', - 'reference' => '81be284da76f12c8751b477b2a0fa44364d26f84', + 'pretty_version' => 'v5.1', + 'version' => '5.1.0.0', + 'reference' => '48b03e93c9c2587f9276dce00ce2b6d94c1190d2', 'type' => 'library', 'install_path' => __DIR__ . '/../yahnis-elsts/plugin-update-checker', 'aliases' => array(), diff --git a/vendor/yahnis-elsts/plugin-update-checker/.gitattributes b/vendor/yahnis-elsts/plugin-update-checker/.gitattributes new file mode 100644 index 0000000..ba74e78 --- /dev/null +++ b/vendor/yahnis-elsts/plugin-update-checker/.gitattributes @@ -0,0 +1 @@ +/build export-ignore 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 9ea49a5..3cda059 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\v5p0\PucFactory { + class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p1\PucFactory { } endif; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Autoloader.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Autoloader.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php index dfd1ee6..ecdede9 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Autoloader.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Autoloader.php @@ -1,6 +1,6 @@ ' . htmlentities(print_r($value, true)) . ''; } else if ($value === null) { $value = 'null'; } - printf('%1$s %2$s', $name, $value); + printf( + '%1$s %2$s', + esc_html($name), + //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped above. + $value + ); } } diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/DebugBar/PluginExtension.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/DebugBar/PluginExtension.php similarity index 90% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/DebugBar/PluginExtension.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/DebugBar/PluginExtension.php index feaf2ff..21fbe0b 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/DebugBar/PluginExtension.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/DebugBar/PluginExtension.php @@ -1,8 +1,8 @@ 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 diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Plugin/PluginInfo.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Plugin/PluginInfo.php similarity index 97% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Plugin/PluginInfo.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Plugin/PluginInfo.php index 45700f9..db8e51e 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Plugin/PluginInfo.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Plugin/PluginInfo.php @@ -1,7 +1,7 @@ checkPeriod . 'hours'; + //phpcs:ignore WordPress.WP.CronInterval.ChangeDetected -- WPCS fails to parse the callback. add_filter('cron_schedules', array($this, '_addCustomSchedule')); } @@ -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) { diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/StateStore.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/StateStore.php similarity index 95% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/StateStore.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/StateStore.php index ec26969..b6f6cc1 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/StateStore.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/StateStore.php @@ -1,5 +1,5 @@ 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); } } } diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Theme/Package.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Theme/Package.php similarity index 93% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Theme/Package.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Theme/Package.php index d677614..030046b 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Theme/Package.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Theme/Package.php @@ -1,7 +1,7 @@ 10, //seconds + 'timeout' => wp_doing_cron() ? 10 : 3, 'headers' => array( 'Accept' => 'application/json', ), diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/UpgraderStatus.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/UpgraderStatus.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/UpgraderStatus.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/UpgraderStatus.php index f95100d..2dc6736 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/UpgraderStatus.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/UpgraderStatus.php @@ -1,5 +1,5 @@ oauth->sign($url,'GET'); } - $options = array('timeout' => 10); + $options = array('timeout' => wp_doing_cron() ? 10 : 3); if ( !empty($this->httpFilterName) ) { $options = apply_filters($this->httpFilterName, $options); } diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitHubApi.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitHubApi.php similarity index 72% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitHubApi.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitHubApi.php index 8682c8b..364584b 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitHubApi.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitHubApi.php @@ -1,11 +1,15 @@ api('/repos/:user/:repo/releases/latest'); - if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) { - return null; + //The "latest release" endpoint returns one release and always skips pre-releases, + //so we can only use it if that's compatible with the current filter settings. + if ( + $this->shouldSkipPreReleases() + && ( + ($this->releaseFilterMaxReleases === 1) || !$this->hasCustomReleaseFilter() + ) + ) { + //Just get the latest release. + $release = $this->api('/repos/:user/:repo/releases/latest'); + if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) { + return null; + } + $foundReleases = array($release); + } else { + //Get a list of the most recent releases. + $foundReleases = $this->api( + '/repos/:user/:repo/releases', + array('per_page' => $this->releaseFilterMaxReleases) + ); + if ( is_wp_error($foundReleases) || !is_array($foundReleases) ) { + return null; + } } - $reference = new Reference(array( - 'name' => $release->tag_name, - 'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3". - 'downloadUrl' => $release->zipball_url, - 'updated' => $release->created_at, - 'apiResponse' => $release, - )); + foreach ($foundReleases as $release) { + //Always skip drafts. + if ( isset($release->draft) && !empty($release->draft) ) { + continue; + } - if ( isset($release->assets[0]) ) { - $reference->downloadCount = $release->assets[0]->download_count; - } + //Skip pre-releases unless specifically included. + if ( + $this->shouldSkipPreReleases() + && isset($release->prerelease) + && !empty($release->prerelease) + ) { + continue; + } + + $versionNumber = ltrim($release->tag_name, 'v'); //Remove the "v" prefix from "v1.2.3". + + //Custom release filtering. + if ( !$this->matchesCustomReleaseFilter($versionNumber, $release) ) { + continue; + } + + $reference = new Reference(array( + 'name' => $release->tag_name, + 'version' => $versionNumber, + 'downloadUrl' => $release->zipball_url, + 'updated' => $release->created_at, + 'apiResponse' => $release, + )); + + if ( isset($release->assets[0]) ) { + $reference->downloadCount = $release->assets[0]->download_count; + } - if ( $this->releaseAssetsEnabled && isset($release->assets, $release->assets[0]) ) { - //Use the first release asset that matches the specified regular expression. - $matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter')); - if ( !empty($matchingAssets) ) { - if ( $this->isAuthenticationEnabled() ) { - /** - * Keep in mind that we'll need to add an "Accept" header to download this asset. - * - * @see setUpdateDownloadHeaders() - */ - $reference->downloadUrl = $matchingAssets[0]->url; + if ( $this->releaseAssetsEnabled ) { + //Use the first release asset that matches the specified regular expression. + if ( isset($release->assets, $release->assets[0]) ) { + $matchingAssets = array_values(array_filter($release->assets, array($this, 'matchesAssetFilter'))); } else { - //It seems that browser_download_url only works for public repositories. - //Using an access_token doesn't help. Maybe OAuth would work? - $reference->downloadUrl = $matchingAssets[0]->browser_download_url; + $matchingAssets = array(); } - $reference->downloadCount = $matchingAssets[0]->download_count; + if ( !empty($matchingAssets) ) { + if ( $this->isAuthenticationEnabled() ) { + /** + * Keep in mind that we'll need to add an "Accept" header to download this asset. + * + * @see setUpdateDownloadHeaders() + */ + $reference->downloadUrl = $matchingAssets[0]->url; + } else { + //It seems that browser_download_url only works for public repositories. + //Using an access_token doesn't help. Maybe OAuth would work? + $reference->downloadUrl = $matchingAssets[0]->browser_download_url; + } + + $reference->downloadCount = $matchingAssets[0]->download_count; + } else if ( $this->releaseAssetPreference === Api::REQUIRE_RELEASE_ASSETS ) { + //None of the assets match the filter, and we're not allowed + //to fall back to the auto-generated source ZIP. + return null; + } } - } - if ( !empty($release->body) ) { - $reference->changelog = Parsedown::instance()->text($release->body); + if ( !empty($release->body) ) { + $reference->changelog = Parsedown::instance()->text($release->body); + } + + return $reference; } - return $reference; + return null; } /** @@ -205,7 +248,7 @@ protected function api($url, $queryParams = array()) { $baseUrl = $url; $url = $this->buildApiUrl($url, $queryParams); - $options = array('timeout' => 10); + $options = array('timeout' => wp_doing_cron() ? 10 : 3); if ( $this->isAuthenticationEnabled() ) { $options['headers'] = array('Authorization' => $this->getAuthorizationHeader()); } @@ -315,7 +358,7 @@ public function setAuthentication($credentials) { protected function getUpdateDetectionStrategies($configBranch) { $strategies = array(); - if ( $configBranch === 'master' ) { + if ( $configBranch === 'master' || $configBranch === 'main') { //Use the latest release. $strategies[self::STRATEGY_LATEST_RELEASE] = array($this, 'getLatestRelease'); //Failing that, use the tag with the highest version number. @@ -323,7 +366,7 @@ protected function getUpdateDetectionStrategies($configBranch) { } //Alternatively, just use the branch itself. - $strategies[self::STRATEGY_BRANCH] = function() use ($configBranch) { + $strategies[self::STRATEGY_BRANCH] = function () use ($configBranch) { return $this->getBranch($configBranch); }; @@ -331,43 +374,29 @@ protected function getUpdateDetectionStrategies($configBranch) { } /** - * Enable updating via release assets. - * - * If the latest release contains no usable assets, the update checker - * will fall back to using the automatically generated ZIP archive. - * - * Private repositories will only work with WordPress 3.7 or later. + * Get the unchanging part of a release asset URL. Used to identify download attempts. * - * @param string|null $fileNameRegex Optional. Use only those assets where the file name matches this regex. + * @return string */ - public function enableReleaseAssets($fileNameRegex = null) { - $this->releaseAssetsEnabled = true; - $this->assetFilterRegex = $fileNameRegex; - $this->assetApiBaseUrl = sprintf( + protected function getAssetApiBaseUrl() { + return sprintf( '//api.github.com/repos/%1$s/%2$s/releases/assets/', $this->userName, $this->repositoryName ); } - /** - * Does this asset match the file name regex? - * - * @param \stdClass $releaseAsset - * @return bool - */ - protected function matchesAssetFilter($releaseAsset) { - if ( $this->assetFilterRegex === null ) { - //The default is to accept all assets. - return true; + protected function getFilterableAssetName($releaseAsset) { + if ( isset($releaseAsset->name) ) { + return $releaseAsset->name; } - return isset($releaseAsset->name) && preg_match($this->assetFilterRegex, $releaseAsset->name); + return null; } /** - * @internal * @param bool $result * @return bool + * @internal */ public function addHttpRequestFilter($result) { if ( !$this->downloadFilterAdded && $this->isAuthenticationEnabled() ) { @@ -383,6 +412,7 @@ public function addHttpRequestFilter($result) { * Set the HTTP headers that are necessary to download updates from private repositories. * * See GitHub docs: + * * @link https://developer.github.com/v3/repos/releases/#get-a-single-release-asset * @link https://developer.github.com/v3/auth/#basic-authentication * @@ -393,7 +423,7 @@ public function addHttpRequestFilter($result) { */ public function setUpdateDownloadHeaders($requestArgs, $url = '') { //Is WordPress trying to download one of our release assets? - if ( $this->releaseAssetsEnabled && (strpos($url, $this->assetApiBaseUrl) !== false) ) { + if ( $this->releaseAssetsEnabled && (strpos($url, $this->getAssetApiBaseUrl()) !== false) ) { $requestArgs['headers']['Accept'] = 'application/octet-stream'; } //Use Basic authentication, but only if the download is from our repository. @@ -409,9 +439,9 @@ public function setUpdateDownloadHeaders($requestArgs, $url = '') { * the authorization header to other hosts. We don't want that because it breaks * AWS downloads and can leak authorization information. * - * @internal * @param string $location * @param array $headers + * @internal */ public function removeAuthHeaderFromRedirects(&$location, &$headers) { $repoApiBaseUrl = $this->buildApiUrl('/repos/:user/:repo/', array()); diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitLabApi.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitLabApi.php similarity index 76% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitLabApi.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitLabApi.php index b43b4ce..663c2e7 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/GitLabApi.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/GitLabApi.php @@ -1,9 +1,13 @@ api('/:id/releases'); + $releases = $this->api('/:id/releases', array('per_page' => $this->releaseFilterMaxReleases)); if ( is_wp_error($releases) || empty($releases) || !is_array($releases) ) { return null; } foreach ($releases as $release) { - if ( true !== $release->upcoming_release ) { - break 1; //Break the loop on the first release we find that isn't an upcoming release + if ( + //Skip invalid/unsupported releases. + !is_object($release) + || !isset($release->tag_name) + //Skip upcoming releases. + || ( + !empty($release->upcoming_release) + && $this->shouldSkipPreReleases() + ) + ) { + continue; } - } - if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) { - return null; - } - $reference = new Reference(array( - 'name' => $release->tag_name, - 'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3". - 'downloadUrl' => '', - 'updated' => $release->released_at, - 'apiResponse' => $release, - )); - $download_url = false; - - if ( $this->releasePackageEnabled && isset($release->assets, $release->assets->links) ) { - /** - * Use the first asset LINK that is a zip format file generated by a Gitlab Release Pipeline - * - * @link https://gist.github.com/timwiel/9dfd3526c768efad4973254085e065ce - */ - foreach ($release->assets->links as $link) { - //TODO: Check the "format" property instead of the URL suffix. - if ( 'zip' === substr($link->url, -3) ) { - $download_url = $link->url; - break 1; - } + $versionNumber = ltrim($release->tag_name, 'v'); //Remove the "v" prefix from "v1.2.3". + + //Apply custom filters. + if ( !$this->matchesCustomReleaseFilter($versionNumber, $release) ) { + continue; } - if ( empty( $download_url ) ) { + + $downloadUrl = $this->findReleaseDownloadUrl($release); + if ( empty($downloadUrl) ) { + //The latest release doesn't have valid download URL. return null; } - if ( ! empty( $this->accessToken ) ) { - $download_url = add_query_arg('private_token', $this->accessToken, $download_url); + + if ( !empty($this->accessToken) ) { + $downloadUrl = add_query_arg('private_token', $this->accessToken, $downloadUrl); } - $reference->downloadUrl = $download_url; - return $reference; - - } elseif ( isset($release->assets) ) { - /** - * Use the first asset SOURCE file that is a zip format from a Gitlab Release which should be a zip file - */ - foreach ($release->assets->sources as $source) { - if ( 'zip' === $source->format ) { - $download_url = $source->url; - break 1; + + return new Reference(array( + 'name' => $release->tag_name, + 'version' => $versionNumber, + 'downloadUrl' => $downloadUrl, + 'updated' => $release->released_at, + 'apiResponse' => $release, + )); + } + + return null; + } + + /** + * @param object $release + * @return string|null + */ + protected function findReleaseDownloadUrl($release) { + if ( $this->releaseAssetsEnabled ) { + if ( isset($release->assets, $release->assets->links) ) { + //Use the first asset link where the URL matches the filter. + foreach ($release->assets->links as $link) { + if ( $this->matchesAssetFilter($link) ) { + return $link->url; + } } } - if ( empty( $download_url ) ) { + + if ( $this->releaseAssetPreference === Api::REQUIRE_RELEASE_ASSETS ) { + //Falling back to source archives is not allowed, so give up. return null; } - if ( ! empty( $this->accessToken ) ) { - $download_url = add_query_arg('private_token', $this->accessToken, $download_url); - } - $reference->downloadUrl = $download_url; - return $reference; + } + //Use the first source code archive that's in ZIP format. + foreach ($release->assets->sources as $source) { + if ( isset($source->format) && ($source->format === 'zip') ) { + return $source->url; + } } - //If we get this far without a return then obviosuly noi release download urls were found return null; - } + } /** * Get the tag that looks like the highest version number. @@ -251,7 +260,7 @@ protected function api($url, $queryParams = array()) { $baseUrl = $url; $url = $this->buildApiUrl($url, $queryParams); - $options = array('timeout' => 10); + $options = array('timeout' => wp_doing_cron() ? 10 : 3); if ( !empty($this->httpFilterName) ) { $options = apply_filters($this->httpFilterName, $options); } @@ -365,7 +374,7 @@ protected function getUpdateDetectionStrategies($configBranch) { $strategies[self::STRATEGY_LATEST_TAG] = array($this, 'getLatestTag'); } - $strategies[self::STRATEGY_BRANCH] = function() use ($configBranch) { + $strategies[self::STRATEGY_BRANCH] = function () use ($configBranch) { return $this->getBranch($configBranch); }; @@ -377,16 +386,29 @@ public function setAuthentication($credentials) { $this->accessToken = is_string($credentials) ? $credentials : null; } - public function enableReleaseAssets() { - $this->releaseAssetsEnabled = true; - $this->releasePackageEnabled = false; - } - + /** + * Use release assets that link to GitLab generic packages (e.g. .zip files) + * instead of automatically generated source archives. + * + * This is included for backwards compatibility with older versions of PUC. + * + * @return void + * @deprecated Use enableReleaseAssets() instead. + * @noinspection PhpUnused -- Public API + */ public function enableReleasePackages() { - $this->releaseAssetsEnabled = false; - $this->releasePackageEnabled = true; + $this->enableReleaseAssets( + /** @lang RegExp */ '/\.zip($|[?&#])/i', + Api::REQUIRE_RELEASE_ASSETS + ); } + protected function getFilterableAssetName($releaseAsset) { + if ( isset($releaseAsset->url) ) { + return $releaseAsset->url; + } + return null; + } } endif; diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/PluginUpdateChecker.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/PluginUpdateChecker.php similarity index 98% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/PluginUpdateChecker.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/PluginUpdateChecker.php index aa1dfae..082a847 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/PluginUpdateChecker.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/PluginUpdateChecker.php @@ -1,8 +1,8 @@ releaseAssetsEnabled = true; + $this->assetFilterRegex = $nameRegex; + $this->releaseAssetPreference = $preference; + } + + /** + * Disable release assets. + * + * @return void + * @noinspection PhpUnused -- Public API + */ + public function disableReleaseAssets() { + $this->releaseAssetsEnabled = false; + $this->assetFilterRegex = null; + } + + /** + * Does the specified asset match the name regex? + * + * @param mixed $releaseAsset Data type and structure depend on the host/API. + * @return bool + */ + protected function matchesAssetFilter($releaseAsset) { + if ( $this->assetFilterRegex === null ) { + //The default is to accept all assets. + return true; + } + + $name = $this->getFilterableAssetName($releaseAsset); + if ( !is_string($name) ) { + return false; + } + return (bool)preg_match($this->assetFilterRegex, $releaseAsset->name); + } + + /** + * Get the part of asset data that will be checked against the filter regex. + * + * @param mixed $releaseAsset + * @return string|null + */ + abstract protected function getFilterableAssetName($releaseAsset); + } + +endif; \ No newline at end of file diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ReleaseFilteringFeature.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ReleaseFilteringFeature.php new file mode 100644 index 0000000..12ef54e --- /dev/null +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ReleaseFilteringFeature.php @@ -0,0 +1,108 @@ + 100 ) { + throw new \InvalidArgumentException(sprintf( + 'The max number of releases is too high (%d). It must be 100 or less.', + $maxReleases + )); + } else if ( $maxReleases < 1 ) { + throw new \InvalidArgumentException(sprintf( + 'The max number of releases is too low (%d). It must be at least 1.', + $maxReleases + )); + } + + $this->releaseFilterCallback = $callback; + $this->releaseFilterByType = $releaseTypes; + $this->releaseFilterMaxReleases = $maxReleases; + return $this; + } + + /** + * Filter releases by their version number. + * + * @param string $regex A regular expression. The release version number must match this regex. + * @param int $releaseTypes + * @param int $maxReleasesToExamine + * @return $this + * @noinspection PhpUnused -- Public API + */ + public function setReleaseVersionFilter( + $regex, + $releaseTypes = Api::RELEASE_FILTER_SKIP_PRERELEASE, + $maxReleasesToExamine = 20 + ) { + return $this->setReleaseFilter( + function ($versionNumber) use ($regex) { + return (preg_match($regex, $versionNumber) === 1); + }, + $releaseTypes, + $maxReleasesToExamine + ); + } + + /** + * @param string $versionNumber The detected release version number. + * @param object $releaseObject Varies depending on the host/API. + * @return bool + */ + protected function matchesCustomReleaseFilter($versionNumber, $releaseObject) { + if ( !is_callable($this->releaseFilterCallback) ) { + return true; //No custom filter. + } + return call_user_func($this->releaseFilterCallback, $versionNumber, $releaseObject); + } + + /** + * @return bool + */ + protected function shouldSkipPreReleases() { + //Maybe this could be a bitfield in the future, if we need to support + //more release types. + return ($this->releaseFilterByType !== Api::RELEASE_FILTER_ALL); + } + + /** + * @return bool + */ + protected function hasCustomReleaseFilter() { + return isset($this->releaseFilterCallback) && is_callable($this->releaseFilterCallback); + } + } + +endif; \ No newline at end of file diff --git a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/ThemeUpdateChecker.php b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ThemeUpdateChecker.php similarity index 94% rename from vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/ThemeUpdateChecker.php rename to vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ThemeUpdateChecker.php index b8624c6..c871ce9 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p0/Vcs/ThemeUpdateChecker.php +++ b/vendor/yahnis-elsts/plugin-update-checker/Puc/v5p1/Vcs/ThemeUpdateChecker.php @@ -1,9 +1,9 @@ setBranch('stable-branch-name'); - ``` - - Caveats: - - If you set the branch to `main` (the default) or `master` (the historical default), the update checker will look for recent releases and tags first. It'll only use the `main` or `master` branch if it doesn't find anything else suitable. - -2. **GitLab Releases using Generic Packages**: - - Use a Gitlab CI/CD Pipeline to automatically generate your update on release using a Generic Package. The benefit of using Generic Package assets over the Source Code assets is that the code can already be built and production ready. - - Add the following code: - ```php - //Add the following code to your main plugin file or `functions.php` file to check for a new update from releases using generic packages - $myUpdateChecker->getVcsApi()->enableReleasePackages(); - ``` - - PUC will periodically check the release version (i.e. the tag name of the release) and will display a notification if the release is a greater version than the installed version. - - The release tag name should loosely follow [SemVer](https://semver.org/) but these are all valid release names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5` However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead. - - For more information about *Gitlab Release Generic Packages* refer to the following links: + +A GitLab repository can be checked for updates in 3 different ways. + +- **GitLab releases** + + Create a new release using the "Releases" feature on GitLab. The tag name should match the version number. You can add a `v` prefix to the tag, like `v1.2.3`. Releases that are marked as ["Upcoming Release"](https://docs.gitlab.com/ee/user/project/releases/index.html#upcoming-releases) will be automatically ignored. + + If you want to use custom release assets, call the `enableReleaseAssets()` method after creating the update checker instance: + ```php + $myUpdateChecker->getVcsApi()->enableReleaseAssets(); + ``` + + By default, PUC will use the first available asset link, regardless of type. You can pass a regular expression to `enableReleaseAssets()` to make it pick the first link where the URL matches the regex. For example: + ```php + $myUpdateChecker->getVcsApi()->enableReleaseAssets('/\.zip($|[?&#])/i'); + ``` + + **Tip:** You can use a Gitlab CI/CD Pipeline to automatically generate your update on release using a Generic Package. For more information about generic packages, refer to the following links: - [Gitlab CI/CD Release Documentation](https://docs.gitlab.com/ee/user/project/releases/#create-release-from-gitlab-ci) - [Gitlab Release Assets as Generic Package Documentation](https://gitlab.com/gitlab-org/release-cli/-/tree/master/docs/examples/release-assets-as-generic-package/) - [Example .gitlab-ci.yml file using Release Generic Packages for generating a update package from the Sensei-LMS wordpress plugin](https://gist.github.com/timwiel/9dfd3526c768efad4973254085e065ce) +- **Tags** -3. **GitLab Releases using Source Code Assets**: - - Create a new release using the "Releases" feature on Gitlab. - - Add the following code: - ```php - //Add the following code to your main plugin file or `functions.php` file to check for a new update from releases using release assets - $myUpdateChecker->getVcsApi()->enableReleaseAssets(); - ``` - - PUC will periodically check the release version (based on release tag name) and display a notification if the release version is greater than the installed version. - - The release name should loosely follow [SemVer](https://semver.org/) but these are all valid release names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5` However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead. + To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. The update checker will look at recent tags and use the one that looks like the highest version number. + + PUC doesn't require strict adherence to [SemVer](https://semver.org/). However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead. +- **Stable branch** -4. **Tags** (this is the default option): - - To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. - - Optionally, add the following code: - ```php - //Add the following code to your main plugin file or `functions.php` file to check for updates from the default branch - $myUpdateChecker->setBranch('master'); //or 'main' - ``` - - PUC doesn't require strict adherence to [SemVer](https://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead. + Point the update checker at any stable, production-ready branch: + ```php + $myUpdateChecker->setBranch('stable-branch-name'); + ``` + PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: Even if you set the branch to `main` (the default) or `master` (the historical default), the update checker will still look for recent releases and tags first. Migrating from 4.x ------------------ @@ -358,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\v5p0\PucFactory` | -| `Puc_v4p13_Plugin_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p0\Plugin\UpdateChecker` | -| `Puc_v4p13_Theme_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p0\Theme\UpdateChecker` | -| `Puc_v4p13_Vcs_PluginUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p0\Vcs\PluginUpdateChecker` | -| `Puc_v4p13_Vcs_ThemeUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p0\Vcs\ThemeUpdateChecker` | -| `Puc_v4p13_Vcs_GitHubApi` | `YahnisElsts\PluginUpdateChecker\v5p0\Vcs\GitHubApi` | -| `Puc_v4p13_Vcs_GitLabApi` | `YahnisElsts\PluginUpdateChecker\v5p0\Vcs\GitLabApi` | -| `Puc_v4p13_Vcs_BitBucketApi` | `YahnisElsts\PluginUpdateChecker\v5p0\Vcs\BitBucketApi` | +| `Puc_v4p13_Factory` | `YahnisElsts\PluginUpdateChecker\v5p1\PucFactory` | +| `Puc_v4p13_Plugin_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p1\Plugin\UpdateChecker` | +| `Puc_v4p13_Theme_UpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p1\Theme\UpdateChecker` | +| `Puc_v4p13_Vcs_PluginUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p1\Vcs\PluginUpdateChecker` | +| `Puc_v4p13_Vcs_ThemeUpdateChecker` | `YahnisElsts\PluginUpdateChecker\v5p1\Vcs\ThemeUpdateChecker` | +| `Puc_v4p13_Vcs_GitHubApi` | `YahnisElsts\PluginUpdateChecker\v5p1\Vcs\GitHubApi` | +| `Puc_v4p13_Vcs_GitLabApi` | `YahnisElsts\PluginUpdateChecker\v5p1\Vcs\GitLabApi` | +| `Puc_v4p13_Vcs_BitBucketApi` | `YahnisElsts\PluginUpdateChecker\v5p1\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 0589f01..1a71ce8 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-v5p0.php"] + "files": ["load-v5p1.php"] } } diff --git a/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json b/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json index fea211a..946b730 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json +++ b/vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json @@ -1,52 +1,52 @@ -{ - "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 +{ + "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 index df6c8c7..0e08072 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/examples/theme.json +++ b/vendor/yahnis-elsts/plugin-update-checker/examples/theme.json @@ -1,5 +1,5 @@ -{ - "version": "2.0", - "details_url": "http://example.com/version-2.0-details.html", - "download_url": "http://example.com/example-theme-2.0.zip" +{ + "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/js/debug-bar.js b/vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js index 9cb65a0..80f53f1 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js +++ b/vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js @@ -14,6 +14,8 @@ jQuery(function($) { _wpnonce: panel.data('nonce') }, function(data) { + //The response contains HTML that should already be escaped in server-side code. + //phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html responseBox.html(data); }, 'html' 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 ec7bc19..edc8de4 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 @@ -17,33 +17,33 @@ msgstr "" "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" "X-Poedit-SearchPath-0: .\n" -#: Puc/v5p0/Plugin/Ui.php:128 +#: Puc/v5p1/Plugin/Ui.php:128 msgid "Check for updates" msgstr "" -#: Puc/v5p0/Plugin/Ui.php:214 +#: Puc/v5p1/Plugin/Ui.php:214 #, php-format msgctxt "the plugin title" msgid "The %s plugin is up to date." msgstr "" -#: Puc/v5p0/Plugin/Ui.php:216 +#: Puc/v5p1/Plugin/Ui.php:216 #, php-format msgctxt "the plugin title" msgid "A new version of the %s plugin is available." msgstr "" -#: Puc/v5p0/Plugin/Ui.php:218 +#: Puc/v5p1/Plugin/Ui.php:218 #, php-format msgctxt "the plugin title" msgid "Could not determine if updates are available for %s." msgstr "" -#: Puc/v5p0/Plugin/Ui.php:224 +#: Puc/v5p1/Plugin/Ui.php:224 #, php-format msgid "Unknown update checker status \"%s\"" msgstr "" -#: Puc/v5p0/Vcs/PluginUpdateChecker.php:100 +#: Puc/v5p1/Vcs/PluginUpdateChecker.php:100 msgid "There is no changelog available." msgstr "" diff --git a/vendor/yahnis-elsts/plugin-update-checker/load-v5p0.php b/vendor/yahnis-elsts/plugin-update-checker/load-v5p1.php similarity index 80% rename from vendor/yahnis-elsts/plugin-update-checker/load-v5p0.php rename to vendor/yahnis-elsts/plugin-update-checker/load-v5p1.php index 7998cbf..83cebcb 100644 --- a/vendor/yahnis-elsts/plugin-update-checker/load-v5p0.php +++ b/vendor/yahnis-elsts/plugin-update-checker/load-v5p1.php @@ -1,14 +1,14 @@ $pucVersionedClass ) { - MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.0'); + MajorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.1'); //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.0'); + MinorFactory::addVersion($pucGeneralClass, $pucVersionedClass, '5.1'); } diff --git a/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml b/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml new file mode 100644 index 0000000..e8260b9 --- /dev/null +++ b/vendor/yahnis-elsts/plugin-update-checker/phpcs.xml @@ -0,0 +1,21 @@ + + + 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 1d892f3..ebf10bc 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 @@ Date: Wed, 28 Jun 2023 15:36:15 -0400 Subject: [PATCH 3/4] fix block/shortcode not respecting min headings --- CHANGES.md | 4 ++++ classes/class-table-of-contents.php | 4 ++-- composer.lock | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 1b16b04..d227a84 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ # Changelog +## 1.5.2 (6/28/23) +* Changed: Update the updater. +* Fixed: TOC block and shortcode not respecting the minimum headings count. + ## 1.5.1 (5/5/23) * Fixed: Missing content on some post types when a TOC is not present. diff --git a/classes/class-table-of-contents.php b/classes/class-table-of-contents.php index 2a51f1e..2891c76 100644 --- a/classes/class-table-of-contents.php +++ b/classes/class-table-of-contents.php @@ -323,8 +323,8 @@ function get_data() { } } - // If we have at least 3 h2 headings. - if ( count( $data['matches'] ) > 2 ) { + // If we have the minimum h2 headings. + if ( count( $data['matches'] ) >= $this->args['headings'] ) { // Store TOC in new content. $data['content'] = $dom->saveHTML(); } diff --git a/composer.lock b/composer.lock index aa556e4..08d5783 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "yahnis-elsts/plugin-update-checker", - "version": "v5.0", + "version": "v5.1", "source": { "type": "git", "url": "https://github.com/YahnisElsts/plugin-update-checker.git", - "reference": "81be284da76f12c8751b477b2a0fa44364d26f84" + "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/81be284da76f12c8751b477b2a0fa44364d26f84", - "reference": "81be284da76f12c8751b477b2a0fa44364d26f84", + "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/48b03e93c9c2587f9276dce00ce2b6d94c1190d2", + "reference": "48b03e93c9c2587f9276dce00ce2b6d94c1190d2", "shasum": "" }, "require": { @@ -27,7 +27,7 @@ "type": "library", "autoload": { "files": [ - "load-v5p0.php" + "load-v5p1.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.0" + "source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.1" }, - "time": "2022-10-28T17:46:32+00:00" + "time": "2023-05-20T11:55:43+00:00" } ], "packages-dev": [], From 23831f80d3e6905ef934b024393a122b0441e45b Mon Sep 17 00:00:00 2001 From: JiveDig Date: Wed, 28 Jun 2023 15:36:21 -0400 Subject: [PATCH 4/4] vbump 1.5.2 --- mai-table-of-contents.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mai-table-of-contents.php b/mai-table-of-contents.php index 807339c..7d83bd6 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.5.1 + * Version: 1.5.2 * * 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.5.1' ); + define( 'MAI_TABLE_OF_CONTENTS_VERSION', '1.5.2' ); } // Plugin Folder Path.