How to Prevent a WordPress Plugin from Updating

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.
Table of Contents

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

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.

Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Sponsored Ad

If you purchase through a link on our site, we may earn a commission.

All suggestions are anonymous.

More from our blog...

6 Responses

  1. 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.

Post a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Stay updated with WP Mayor's newsletter showcase every week

Stay on top of every new WordPress innovation and latest launches. Receive all our fresh product reviews and expert guides directly in your inbox.

Hosting Survey 2024

Are you happy with your hosting provider or are you over-paying for too little? Have your say below!

"*" indicates required fields

What's the main reason you picked this host?*
How happy are you with your host?*

OPTIONAL: If you'd like to receive the results of this survey, please enter your details below.