Disable Update Check and Notification for Specific Plugin

[ad_1]

Sometimes when you login to the admin section of your WordPress website, you may see a number in a red bubble next to the Plugins-item in the menu. This indicates that some of your plugins have updates available and are ready to install from WordPress plugin respiratory.

It is strongly advised to keep your plugins up to date since plugin updates usually come with new additional features and more importantly with many security fixes.

But there are times when you don’t want to receive updates for a specific plugin because you may have modified plugin core files and updating plugin will simply wash away your customizations

The situation become direr when you setup a WordPress website for your client and he accidentally updates all plugins resulting in broken website or at least broken functionality in some part of the website.

To avoid such scenarios and fixing your WordPress website later on, you may want to disable update check as well as update notification for a specific plugin for a website.

Previously we have posted code snippet for disabling updates for all plugins in WordPress. If you are looking for a solution to disable update check for all plugins then you must head over there and use provided code snippet.

To disable the updates for specific plugin(s), we will use same method but restrict http request for plugins that we do not want to update. So here is the function you can paste in your functions.php file of your theme.

// Disable Update Check and Notification for Specific Plugin
function wcs_disable_plugin_update_check( $r, $url ) {
    if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
        return $r;

    // array of the plugins
    $blocked_plugins = array(
        'akismet/akismet.php',
        'contact-form-7/wp-contact-form-7.php',
    );

    if ( 0 === (int) count( $blocked_plugins ) )
        return $r;

    $installed_plugins = unserialize( $r['body']['plugins'] );
    foreach( $blocked_plugins as $p ) {
        unset( $installed_plugins->plugins[ $p ] );
        unset( $installed_plugins->active[ array_key_exists( $p, $installed_plugins ) ] );
    }
    $r['body']['plugins'] = serialize( $installed_plugins );

    return $r;
}
add_filter( 'http_request_args', 'wcs_disable_plugin_update_check', 5, 2 );

In this example, we have disabled updates check for Akismet and Contact Form 7 plugins. Of course you must modify this code snippet and add path of the plugins that you do not want to receive updates as well as notifications.

[ad_2]

Leave a Reply

Random Post Selection ::

Recent Posts

Unlock Unlimited Downloads