I’ve had a couple of cases where I downloaded a plugin, then needed to make some modifications and disable updating to make sure those changes are not overwritten when the next version came out. Ever wondered how plugin updates can be disabled? Here’s how to do it.
Add the following code to your plugin’s core PHP file:
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; }
If you enjoyed this post, make sure to subscribe to WP Mayor’s RSS feed.
6 Responses
Nice solution π
Another, less attractive way, is to simply increase the version number in the header of the main plugin file to something unthinkably high – like 100. That way WordPress will always think you’re using the latest version, even if you’re not.
That didn’t always work for me for some reason.
Thanks. Big help.
Great contribution Jean, thanks.
Otherwise look for “Plugin Protector” in the repository: is a little known gem
I’m kind of fond of this route. π