WordPress Black Friday & Cyber Monday Deals 2021
Days
Hours
Minutes
Seconds

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.

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
Jean Galea
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.

Consider sharing this post so others can find it:

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on telegram
Share on whatsapp
Share on pocket
Share on email

Join thousands of people receiving real-world, genuine evaluations of WordPress products and services just like this one every week.

Our Sponsors
Solid Affiliate
Contents

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.

Leave a Reply

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

The Beginner’s Handbook
From an introduction on how WordPress works to our recommendations on products and services.
👋 Hey there! We're Gaby and Mark
Every week we share tutorials and genuine reviews of WordPress products and services in our newsletter.
Thousands of people read it!
We’d love for you to join.
We’d love for you to join. Here’s what you’ll be getting:

A single weekly email directly to your inbox.