I'd like to make sure that the customizations I made to a plugin doesn't get overwritten by a future update, so I'd like to somehow disable updates for that particular plug (and only that plugin). Am I able to just change the name of the plugin and that will work, or is there something I can do (beside backups) to make sure it isn't accidentally updated with some other plugins?
5 Answers
function AS_disable_plugin_updates( $value ) {
//create an array of plugins you want to exclude from updates ( string composed by folder/main_file.php)
$pluginsNotUpdatable = [
'plugin1/plugin.php',
'plugin2/plugin2.php'
];
if ( isset($value) && is_object($value) ) {
foreach ($pluginsNotUpdatable as $plugin) {
if ( isset( $value->response[$plugin] ) ) {
unset( $value->response[$plugin] );
}
}
}
return $value;
}
add_filter( 'site_transient_update_plugins', 'AS_disable_plugin_updates' );
Updates for plugins often include bug fixes and security patches, so ideally you wouldn't want to not update them for both functionality and security reasons.
If you want to customize the functionality of a plugin, I'd recommend creating your own plugin that extends the other plugin's functionality instead of editing the other plugin's files directly. This will ensure that you can still update the plugin without your changes being overwritten.
If you're still intent on ensuring that the plugin doesn't get updated, make sure that "Automatic Updates" is disabled for that plugin on the plugins page in wp-admin. With automatic updates turned off, the only way the plugin would update is if you manually choose to do so.
-
One big reason is that some plugins go from working great to total bullshit (for example «Insert headers and footers», which doesn't work anymore with 2.x release). So blocking major updates (1.x to 2.x) makes sense sometimes. Other plugins ask for registration to their websites... even if you already have a license key. Extending the plugin is a good idea, but the easiest way is to copy it (see Ahmed's answer). And update or not, you must run a security check. As some plugins don't fix their issues.– YvanCommented Dec 12, 2022 at 17:03
Follow these steps to disable updates for a specific plugin:
- Go to the plugin main file containing plugin name and other details
- Change the version to 1.0 and save it.
- Rename the plugin folder name to any name you want.
-
Doing this isn't a great idea as it prevents WP from identifying and then informing users that a newer version is available. This in turn means that WP owners/admins could be running old code for a very long time which opens the site upto to various issues. Commented Mar 5 at 11:42
-
It's considered bad practise to just post code without an explanation as to the what & why, of what your solution does, etc. Commented Mar 5 at 11:39
-
Also, doing this isn't a great idea as it prevents WP from identifying and then informing users that a newer version is available. This in turn means that WP owners/admins could be running old code for a very long time which opens the site upto to various issues. Commented Mar 5 at 11:41
Wordpress sometimes still shows a plugin as "Auto-Updates enabled" even after adding above code from Andrea Somovigo. Following code disables Auto-Updates for any specific plugin AND alters the visibility in the plugins list to show "Auto-Updates DISABLED" in red color.
add_filter('site_transient_update_plugins', 'custom_disable_plugin_updates_and_display', 10, 1);
function custom_disable_plugin_updates_and_display($value) {
$pluginsToDisableUpdates = [
'plugin-folder/plugin-file.php',
'another-plugin-folder/another-plugin-file.php'
];
if (isset($value) && is_object($value)) {
foreach ($pluginsToDisableUpdates as $plugin) {
if (isset($value->response[$plugin])) {
unset($value->response[$plugin]);
}
}
}
add_filter('plugin_auto_update_setting_html', function ($html, $plugin_file) use ($pluginsToDisableUpdates) {
if (in_array($plugin_file, $pluginsToDisableUpdates, true)) {
$html = '<span style="color:red;">Auto-Updates DISABLED</span>';
}
return $html;
}, 10, 2);
return $value;
}