1

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?

1
  • 1
    what did you change in the plugin? You're meant too modify plugin behaviour using hooks and filters
    – Tom J Nowell
    Oct 25, 2021 at 21:12

5 Answers 5

6
 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' );
2
  • Where to put this? In functions.php?
    – WendiT
    Feb 8, 2022 at 9:10
  • Yes that's One option Feb 9, 2022 at 10:54
3

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.

1
  • 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.
    – Yvan
    Dec 12, 2022 at 17:03
1

Follow these steps to disable updates for a specific plugin:

  1. Go to the plugin main file containing plugin name and other details
  2. Change the version to 1.0 and save it.
  3. Rename the plugin folder name to any name you want.
1
  • 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. Mar 5 at 11:42
0

just go and give version name like

9999999999999999999999 enter image description here

2
  • It's considered bad practise to just post code without an explanation as to the what & why, of what your solution does, etc. 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. Mar 5 at 11:41
0

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.