Files
wp-plugin-starter-template-…/includes/github-updater/load.php
T
marcus 51ccabc24e
CI / Lint (PHP 7.4) (push) Canceled after 0s
CI / Release build, preflight and Plugin Check (push) Canceled after 0s
CI / Smoke test (WordPress 6.2, PHP 7.4) (push) Canceled after 0s
CI / Smoke test (WordPress latest, PHP 8.3) (push) Canceled after 0s
fix: GitHub updater requests never follow redirects, whatever other plugins set
HTTP Requests Manager (blocking modes) sets every request's redirection to 1 on http_request_args. The updater's no-redirect requests then followed GitHub's redirect: signed_address() lost the Location, so private updates failed (and the token went to the download host), and fetch_web()'s HEAD on releases/latest got 200 instead of a redirect. remote_no_redirect() holds redirection at 0 for that one URL at PHP_INT_MAX. Updater copy 1.0.1 (the GH#261 change had not raised it).
2026-10-03 16:44:42 +01:00

51 lines
1.9 KiB
PHP

<?php
/**
* Shared GitHub updater: registers this copy.
*
* Every plugin made from the starter carries a copy of includes/github-updater/.
* Each copy registers its version here when its plugin loads; on
* plugins_loaded only the newest copy loads, once, and serves every installed
* plugin with a `GitHub Plugin URI` header. So one update check covers all of
* them, however many carry a copy.
*
* The WordPress.org build leaves this folder out (.distignore-wporg): plugins
* hosted there may not install or update code from anywhere else.
*
* The starter holds the master copy. Change it there, raise the version
* below with every change, then copy it to each plugin (scripts/sync-core.sh).
* Plugins change what it does only through its filters, never by calling the
* class: another plugin's newer or older copy may be the one that runs.
*
* @package WPStarter
*/
if (!defined('ABSPATH')) {
exit;
}
if (!isset($GLOBALS['wpallstars_github_updater']) || !is_array($GLOBALS['wpallstars_github_updater'])) {
$GLOBALS['wpallstars_github_updater'] = array();
}
// Version of this copy => its class file.
$GLOBALS['wpallstars_github_updater']['1.0.1'] = __DIR__ . '/class-wpallstars-github-updater.php';
if (!function_exists('wpallstars_github_updater_load')) {
/**
* Load the newest registered copy of the updater (plugins_loaded).
*/
function wpallstars_github_updater_load() {
if (class_exists('WPAllStars_GitHub_Updater', false) || empty($GLOBALS['wpallstars_github_updater'])) {
return;
}
$copies = (array) $GLOBALS['wpallstars_github_updater'];
uksort($copies, 'version_compare');
$file = (string) end($copies);
if (is_readable($file)) {
require_once $file;
WPAllStars_GitHub_Updater::load();
}
}
// Every plugin's main file has run by then, so every copy is registered.
add_action('plugins_loaded', 'wpallstars_github_updater_load', 1);
}