[wp-trac] [WordPress Trac] #54021: Auto-update (plugin/theme) needs option to restrict to point or patch release
WordPress Trac
noreply at wordpress.org
Fri Aug 27 13:13:03 UTC 2021
#54021: Auto-update (plugin/theme) needs option to restrict to point or patch
release
-----------------------------+---------------------------------
Reporter: jqz | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upgrade/Install | Version:
Severity: normal | Resolution:
Keywords: close | Focuses: ui, administration
-----------------------------+---------------------------------
Comment (by chesio):
This can be quite easy implemented with
[https://developer.wordpress.org/reference/hooks/auto_update_type/
auto_update_plugin] filter (I use something similar on my websites):
{{{#!php
<?php
add_filter('auto_update_plugin', function ($update, $plugin) {
if (!$update) {
// Auto updates for this plugin are (already) disabled.
return $update;
}
if (!$plugin->current_version || !$plugin->new_version) {
// Sanity check: if current or new version number is not
available, do not update.
return false;
}
$current_version_parts = explode('.', $plugin->current_version);
$new_version_parts = explode('.', $plugin->new_version);
// Only update if major version does not change.
return $current_version_parts [0] === $new_version_parts[0];
}, 10, 2);
}}}
Anyway, I also think it's plugins' territory.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54021#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list