Wordpress Basic Tricks

How to Disable Plugin Updates in WordPress

Some of our readers asked us how to disable plugin updates in WordPress? Earlier there was an option in WordPress itself to disable Plugin updates. But now, it was removed by WordPress due to some reasons and there is no need to worry, we can provide you some PHP codes to do that. Remember that blocking a plugin from updating is not a good idea, as updates provides fixes for bugs and gives stability to the plugin and most importantly plugin updates gives compatibility with latest versions of WordPress Core and PHP. By not updating plugins, you are intentionally compromising security and stability of your WordPress site.

If you still insist to disable plugin updates on your site, then we are here to help you with that.

There are some Plugins which can disable Plugin Updates, but installing too many plugins may slow your site and also sometimes it increases the size of the Site. So here we are providing PHP codes to do that.

Add the following codes to your functions.php file in your theme editor, remember to replace plugin-folder/plugin.php to your plugin name which updates should be disabled.

/**
 * this code prevents updates to specific plugin
 * code by https://siteshastra.com/
 * Place this code in your theme functions.php
 */function disable_plugin_updates( $value ) {

  if ( isset($value) && is_object($value) ) {
    if ( isset( $value->response['plugin-folder/plugin.php'] ) ) {
      unset( $value->response['plugin-folder/plugin.php'] );
    }
  }
  return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );



/**
 * This is an example code to disable updates for Akismet Anti-Spam plugin
 * code by https://siteshastra.com/
 * Place this code in your theme functions.php
 */
function disable_plugin_updates( $value ) {

 if ( isset($value) && is_object($value) ) {
   if ( isset( $value->response[‘akismet/akismet.php’] ) ) {
       unset( $value->response[‘akismet/akismet.php’] );
    }
  }
  return $value;
}
add_filter( ‘site_transient_update_plugins’, ‘disable_plugin_updates’ );

Now you have the code to block plugins from updating for a single plugin, but what if we need to disable updating plugins in bulk? Here is the code to do that in simple way.

/**
 * this code prevents updates to plugins in batch mode
 * code by https://siteshastra.com/
 * Place this code in your theme functions.php
 */ function disable_plugin_updates( $value ) {

    $pluginsToDisable = [
        'plugin-folder/plugin.php',
        'plugin-folder2/plugin2.php'
    ];

    if ( isset($value) && is_object($value) ) {
        foreach ($pluginsToDisable as $plugin) {
            if ( isset( $value->response[$plugin] ) ) {
                unset( $value->response[$plugin] );
            }
        }
    }
    return $value;
}
add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' );

With above code you can block all the plugins you need from updating in a single go.

If you like this article, Please like us on Facebook, Twitter and Instagram and share your thoughts by commenting below. for more code snippets go to Code Snippets

Follow us on Telegram for regular updates.

Vinod Katrela

Share
Published by
Vinod Katrela

Recent Posts

Move Reviews tab before the description on WooCommerce product pages

Here, We explain how to move ‘Reviews’ tab to first position among ‘description’ and ‘additional…

4 years ago