Disable WordPress Plugin Update Notification

“There is a new version of XYZ plugin available”. This message is so familiar to WordPress admin. But sometimes, we need to turn it off. For example, I just customized a plugin, and don’t want my customization code being overwritten by anyone who doesn’t know this plugin has to be remain untouched.

wordpress-plugin-update-notification

There are actually more than one solution to do so. Let me show you how.

Solution 1 – Change Version Number

Not much of hacking, simply change the version number of the plugin to a super large number such as 999.9 can stop the update notification. Because 999 should remain the latest version for a very long time.

But when I run into “disable WordPress plugin update notification” request from client, I realized that I need a serious solution other than fooling around with a fake version number. A quick Google search reveals another two options.

Solution 2 – http_request_args hook

// Disable plugin update check
function my_prevent_update_check($r, $url) {
    if (0 === strpos($url,'http://api.wordpress.org/plugins/update-check/')){
        $my_plugin = plugin_basename(__FILE__);
        $plugins = unserialize($r['body']['plugins']);
        unset($plugins->plugins[$my_plugin]);
        unset($plugins->active[array_search($my_plugin, $plugins->active )]);
        $r['body']['plugins'] = serialize($plugins);
    }
    return $r;
}

add_filter('http_request_args', 'my_prevent_update_check', 10, 2);

This code snippet hooks into http_request_args and remove the plugin from the query arguments passed in the http request. Therefore, this code snippet must be inserted into the very plugin we want to disable the update check.

In case there are more than one plugin we want to disable update check, we need to insert this snippet into each plugin. And make sure we use a different function name in different plugin. (i.e. my_prevent_update_check_nnn instead of my_prevent_update_check)

Solution 3 – site_transient_update_plugins hook

// Disable plugin update check
function my_disable_filter_plugin_updates($value) {
	unset($value->response['plugin/plugin.php']);
	return $value;
}

add_filter('site_transient_update_plugins', 'my_disable_filter_plugin_updates');

This solution is simpler yet more powerful. To use it, we can drop this into either function.php, or our own plugin (my favorite). Just remember to replace the ‘plugin/plugin.php’ in line 3 with the actual plugin path and main php file anme. For example: using

akismet/akismet.php

will stop WordPress from checking update for plugin Akismet.

To disable update check on more plugins, simply declare each plugin using the same unset() function. For example: following code will stop update check on Akismet & Events Manager.

// Disable plugin update check
function my_disable_filter_plugin_updates($value) {
	unset($value->response['akismet/akismet.php']);
	unset($value->response['events-manager/events-manager.php']);
	return $value;
}

add_filter('site_transient_update_plugins', 'my_disable_filter_plugin_updates');