Disable Plugin Update Notification.


Why We Need To Disable Plugin Update?

Most Of Important plugins like Dokan , WooCommerce need many customization according to client requirements.
Many of requirements can be done using hooks/ Filter and by copying template to theme’s folder. But Many of js or Class Function need to be change in plugin files only. which can remove when plugin is updated. And we need to do changes again and again , which is too annoying.

It’s annoying to constantly ignore the Updates(2) notice in the header! or We have Edited the plugin and don’t want to lose our edits on an update.
we can simply use ‘site_transient_update_plugins’ filter for that.

For example if you don’t want WordPress to show update notifications for WooCommerce. than use


		function remove_update_notifications( $value ) {
    unset( $value->response['woocommerce/woocommerce.php'] );
    return $value;
}

add_filter('site_transient_update_plugins','remove_update_notifications');

The answer will throw a PHP warning. Warning: Attempt to modify property of non-object.

To avoid the warnings we have to use if clause to check and to make sure it’s an object before unsetting the response for that plugin.


		function remove_update_notifications($value) {
    if ( isset( $value ) && is_object( $value ) ) {
        unset( $value->response[ plugin_basename(__FILE__) ] );
    }
    return $value;
}

add_filter('site_transient_update_plugins','remove_update_notifications');

Since you’ve edited the code in plugin and don’t want to lose your edits on an update. You’ve already edited the plugin and thus don’t mind editing it more.So, put this in the actual plugin file.

But if you wish you can put it in theme’s functions file , benefit of this method is you can remove multiple plugins from updates by adding another unset line for that plugin. (code for functions.php)


		function remove_update_notifications( $value ) {
    if ( isset( $value ) && is_object( $value ) ) {
        unset( $value->response[ 'akismet/akismet.php' ] );
        unset( $value->response[ 'woocommerce/woocommerce.php' ] );
    }
    return $value;
}

add_filter('site_transient_update_plugins','remove_update_notifications');

Enjoy

, , ,

Leave a Reply

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