Prevent a WordPress plugin from searching for updates

By Faruque Ahamed Mollick

It can be found many times for developers that they modify a WordPress plugin to use it for their need. But here is the problem with those modified WordPress plugins available on wordpress.org. These plugins always search for updates and if new update available then it will show you the update available notice.

Suppose you have built a WordPress site for someone or for a client. If this update notification shown to him/her and if he/she update the plugin then all the changes you made inside the plugin will be disappear. So you need to stop searching for updates for that WordPress plugin to protect from losing modification that you made in that plugin.

Once I faced a problem with the custom meta box plugin CMB2. this is a framework and I built an audio directory plugin using this framework type plugin. One day I got the update notification for this plugin. I knew that it will erase all the modification that I did to built that plugin if I update it. So I did not update this plugin. I used the below code to stop searching my plugin for any updates. Here is the code:

// Disable update
function filter_plugin_updates( $value ) {
    unset( $value->response['PATH_TO_PLUGIN_MAIN_FILE'] ); //Replace the path with main PHP file of your plugin.
    return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );

Here “PATH_TO_PLUGIN_MAIN_FILE” is the path of main PHP file of the plugin. For my CMB2 plugin it was cmb2/init.php. You have to replace it with yours plugin’s main PHP file. The main PHP file of any plugins is the one which contain plugin name, author etc on the top.

How to use this code to prevent stop the WordPress plugin from searching for updates?

You can use this code in your theme’s functions.php file or in a separate plugin’s file. But the best suggestion is to use it inside that plugin’s main PHP file which you want to be stop from searching for updates. It will works nicely and perfectly just like you want.

Leave a Reply

Your email address will not be published. Required fields are marked *