Show the Enable auto-updates toggle for the self-updater
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / No Debug Code (pull_request) Successful in 3s
CI / Coding Standards (pull_request) Successful in 3m7s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / PHPStan (pull_request) Successful in 2m50s
CI / Build Plugin Zip (pull_request) Skipped
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 47s
CI / No Debug Code (pull_request) Successful in 3s
CI / Coding Standards (pull_request) Successful in 3m7s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m38s
CI / PHPStan (pull_request) Successful in 2m50s
CI / Build Plugin Zip (pull_request) Skipped
WordPress only renders the "Enable auto-updates" toggle for a plugin that appears in the update_plugins transient's response or no_update list, which is what sets core's update-supported flag. UpdateChecker only populated the response side (when a newer release existed), so between releases the plugin was absent from the transient and the toggle never showed. provideUpdate() now returns a no_update payload (installed version, empty package) whenever no newer release is offered — including when the release lookup fails — so the plugin stays in the transient and the toggle appears. The response path (one-click and unattended updates) is unchanged. Bumps to 1.1.1 so the fix ships to installed sites via the self-updater. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
@@ -75,9 +75,18 @@ class UpdateChecker {
|
||||
}
|
||||
|
||||
/**
|
||||
* `update_plugins_{hostname}` filter callback. Returns the incoming
|
||||
* value untouched unless a newer release with a zip asset exists, in
|
||||
* which case it returns the update array core expects.
|
||||
* `update_plugins_{hostname}` filter callback.
|
||||
*
|
||||
* For a newer release with a zip asset, returns the update array core
|
||||
* files under the transient's `response` list (the update offer).
|
||||
* Otherwise — the plugin is current, or the release lookup failed — it
|
||||
* returns a payload with the installed version and no package, which core
|
||||
* files under `no_update`. That `no_update` entry is what sets core's
|
||||
* `update-supported` flag and makes the "Enable auto-updates" toggle
|
||||
* appear on the Plugins screen; without it, an off-directory plugin is
|
||||
* absent from the transient between releases and the toggle never shows.
|
||||
*
|
||||
* The incoming value is only passed through untouched for other plugins.
|
||||
*/
|
||||
public function provideUpdate( mixed $update, mixed $plugin_data, mixed $plugin_file ): mixed {
|
||||
if ( plugin_basename( USC_PLUGIN_FILE ) !== $plugin_file ) {
|
||||
@@ -86,19 +95,24 @@ class UpdateChecker {
|
||||
|
||||
$release = $this->latestRelease();
|
||||
|
||||
if ( '' === $release['version'] || '' === $release['package'] ) {
|
||||
return $update;
|
||||
}
|
||||
|
||||
if ( version_compare( $release['version'], USC_VERSION, '<=' ) ) {
|
||||
return $update;
|
||||
if ( '' !== $release['version'] && '' !== $release['package']
|
||||
&& version_compare( $release['version'], USC_VERSION, '>' ) ) {
|
||||
return [
|
||||
'slug' => 'unsupervised-schedular',
|
||||
'version' => $release['version'],
|
||||
'url' => self::REPO_URL,
|
||||
'package' => $release['package'],
|
||||
];
|
||||
}
|
||||
|
||||
// No newer release: answer with a `no_update` payload so core keeps
|
||||
// the plugin in the update transient and shows the auto-update toggle.
|
||||
// The empty package leaves core nothing to auto-install, as intended.
|
||||
return [
|
||||
'slug' => 'unsupervised-schedular',
|
||||
'version' => $release['version'],
|
||||
'version' => USC_VERSION,
|
||||
'url' => self::REPO_URL,
|
||||
'package' => $release['package'],
|
||||
'package' => '',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user