Disable WordPress auto-update core and Notifications

This is the era of blogging, e-commerce, and various kind of web platforms. So WordPress is the backbone of these kinds of websites now. 

We are here to stop the update WordPress automatically. However, you have to always update WordPress to the latest version.

First, we should know about the types of WordPress background updates.

  1. Core updates
  2. Plugin updates
  3. Theme updates
  4. Translation file updates

WordPress further categorized core update into three types.

  1. Core development( For development installations )
  2. Minor core updates( For maintenance and security releases )
  3. Major core updates

Are you getting worried about the auto-updates of WordPress?

Do you really want to stop automatic background WordPress updates?

Okay Okay, I got it, you are very much hungry to do. So let’s get dirty our hands in the WordPress Code…

There are various ways to achieve that.

a) By defining constants in wp-config.php file.

define( 'AUTOMATIC_UPDATER_DISABLED', TRUE ); 

With the help of this constant, by setting the value to TRUE. We are going to completely disable all kinds of updates.

All types of updates? Yes, however, WordPress provides a couple of ways to handle enabling or disabling selected updates.

// Disabled all core updates
define( 'WP_AUTO_UPDATE_CORE', false );

// Enabled all core updates, both minor and major updates
define( 'WP_AUTO_UPDATE_CORE', true );

// Enabled only minor updates but disabled development, and major updates
define( 'WP_AUTO_UPDATE_CORE', 'minor' );

Have to keep in mind.
For development sites, the default value of WP_AUTO_UPDATE_CORE is true. For other sites, the default value of WP_AUTO_UPDATE_CORE is minor.

b) By applying WordPress filter from its rich library.

There are a couple of filters available to control updates in various instances. The best place to use filters in the plugin or theme files.

// This will work the same as AUTOMATIC_UPDATER_DISABLED constant.
add_filter( 'automatic_updater_disabled', '__return_true' );

We can also enable or disable three types of core updates by applying different filters.

// To enable all core-type updates only,
add_filter( 'auto_update_core', '__return_true' );

// To enable for all plugins automatic updates only,
add_filter( 'auto_update_plugin', '__return_true' );

// To enable all theme automatic  updates only,
add_filter( 'auto_update_theme', '__return_true' );

// To disable all theme automatic updates only,
add_filter( 'auto_update_theme', '__return_false' );

Here is the example of the plugin update filter.

function cfd_update_specific_plugin( $update, $item ) {
    if ( $item->slug ==  'plugin_slug' ) {
// Always update plugins in this array
return true;
    } else {
// Else, return detault values
return $update;
    }
}
add_filter( 'auto_update_plugin', 'cfd_update_specific_plugin ', 10, 2 );

Want to stop Notifications too?

Copy to below code and paste it to your functions.php file. This will stop showing WordPress update notifications. 

function remove_core_updates(){
   global $wp_version;
   return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
//hide updates for WordPress itself
add_filter('pre_site_transient_update_core','remove_core_updates');

//hide updates for all plugins
add_filter('pre_site_transient_update_plugins','remove_core_updates'); 

//hide updates for all themes
add_filter('pre_site_transient_update_themes','remove_core_updates');

Leave a Reply

Your email address will not be published.