telephone: (920) 215-1842
facsimile: (866) 456-2115

Remove Update Checks for a WordPress Plugin

WordCamp Chicago 2010While I was attending WordPress WordCamp 2010 in Chicago I met Pete Mall. He gave a great presentation titled “Beginner’s Plugin Development”. I contacted him regarding more information on how to remove the update notification you receive when a developer updates their plugin. Many of us tweak the design or internal workings of a plugin and we don’t want it updated by mistake in the future.

This may be helpful if you are running a custom version of a plugin from the repository and you don’t want to accidentally update the plugin and lose the customizations, or if you are running a private plugin and don’t want WordPress to check for updates from the plugin repository. WordPress doesn’t know if your plugin is in the WordPress plugins repository and it will request the update check on all installed plugins.

WordPress checks for updates using wp_update_plugins() in wp-includes/update.php but there are NO hooks in this function which could be used to exclude your plugin from the update check. However, you can hook into http_request_args and remove your plugin from the query arguments passed in the http request. You can add the following code to your plugin to prevent WordPress from checking for updates for your plugin:

add_filter() takes in four parameters and you can read more about it in the codex here.

add_filter( 'http_request_args', 'dm_prevent_update_check', 10, 2 );
function dm_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;
}

Remember you need to add the code above to only the specific plugins you don’t wish to udpate.

If you are already receiving a notice stating that your plugin needs to be updated. A value called “_transient_update_plugins” in the WordPress database is the reason. To do this insert the following command into your wp-includes/update.php file at the top. Refresh your plugin list page and remove the snippet after the database is updated.

	get_site_transient( 'update_plugins' ); // unset the plugin
	set_site_transient( 'update_plugins', '' ); // reset plugin database information

 

While using this solution I realized I can only use it on one plug-in per WordPress installation without writing additional code. I thought a WordPress plugin sure would be nice. Here is a current plug-in by a group of guys. Several of them I have meet. WP Manage Plugins It has a weird interface issue on the admin side. For support please visit the Support Forum.

 

I hope this saves you time!

  • http://developersmind.com/ Pete Mall

    It should beset_site_transient( 'update_plugins', '' ) to clear the cache or you can unserialize and iterate through it and unset it for your plugin.

    • http://www.gegere.com Jason Gegere

      Thanks for the tip I have the post updated.

  • http://wpwebshop.com Rene

    This hack doesn’t seem to work in WordPress 3.0.1, after copy/pasting it (exactly!) into a plugin file it generates this error :

    Fatal error: Cannot redeclare dm_prevent_update_check() (previously declared in mydomain.com/wp-content/plugins/category-shortcode-w-generator/category_shortcode.php:264) in mydomain.com/wp-content/plugins/rotating-posts/rotating-posts.php on line 36

    • http://www.gegere.com Jason Gegere

      The issue with using this code in a plugin is you can only use it once otherwise you will have redeclaration issues.

      A plugin that I have been using now is WP-Manage-Plugins. There seems to be a small interface issue when using WordPress 3.0-3.1 but a browser refresh makes plugins usable again, just an admin glitch. I will add a new post when I have more information regarding a solid solution.

  • http://typeofundefined.com Matthias

    Another more easy and pretty reliable way to prevent a customized plugin from updating is to set its version number to something a lot higher than its current version number.

    The solution presented here or Pete’s solution didn’t work reliably for me (or didn’t work at all).

  • MOst_53

    Thanx for your post! It really help me! :)

  • http://www.wordimpressed.com/ Devin Walker

    Awesome post! Thanks for this bit of code.

  • http://www.geckodesigns.com Gabriel Silverman

    Thanks, I’ve been trying to figure out how to disable WordPress plugins that have modified from being eligible for version updates. This is what I was looking for!

  • promaty

    Meh, I just indicate version of my plugin 999, good enough for me :)