How to selectively or totally enable & disable ‘WordPress Automatic Background Updates’ while modifying code in WordPress root wp-config.php file & Your theme’s functions.php file

Introduction to WordPress’s New Functionality Automatic Background Updates:

 
Automatic background updates were introduced in WordPress 3.7 in to promote greater security and to streamline the process of updating WordPress. By default, only minor releases – such as for maintenance and security purposes – and translation file updates are enabled.

 
Default behaviour in WordPress 3.7 is automatic update of core for minor versions i.e. from 3.7.0 to 3.7.1

 
No configuration options are available in WordPress’s Graphical User Interface (GUI). To change the behaviour, you’ll need to modify your wp-config.php file in your WordPress root installation or add some filters in your theme’s functions.php file.

 
In WordPress, there are four types of automatic background updates:

 

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

 
Core Updates

 
Core updates are subdivided into three types:

 

  1. Core development updates, known as the “bleeding edge”
  2. Minor core updates, such as maintenance and security releases e.g 3.7.1
  3. Major core release updates e.g. 3.7

 
But If you want to selectively enable or disable them here is how you will do it,

 

Enable or Disable them Via wp-config.php

 
Enable Automatic Update for core – development, major, and minor versions

 

// Update core - development, major, and minor versions
define( 'WP_AUTO_UPDATE_CORE', true );

 
Enable Automatic Update for core for minor versions only

 
Note: This is enabled by default so use it only when necessary & with caution

 

// Update core - minor versions
define( 'WP_AUTO_UPDATE_CORE', 'minor' );

 
Disable All Core Updates

 

// Core update disabled
define( 'WP_AUTO_UPDATE_CORE', false );

 

Enable or Disable them Via your theme’s functions.php file

 
Enable Automatic Development (Nightly) Core Updates only

 

// Enable development (nightly) updates
add_filter( 'allow_dev_auto_core_updates', '__return_true' );

 
Disable Automatic Minor Updates

 

// Disable minor updates
add_filter( 'allow_minor_auto_core_updates', '__return_false' );

 
Enable Automatic Major Updates

 

// Enable major updates
add_filter( 'allow_major_auto_core_updates', '__return_true' );

 
Enable Automatic Updates even if a VCS folder (.git, .hg, .svn) was found in the WordPress directory

 

// Enable automatic updates even if a VCS folder (.git, .hg, .svn) was found in the WordPress directory
function always_return_false_for_vcs( $checkout, $context ) {
   return false;
}
add_filter( 'automatic_updates_is_vcs_checkout', 'always_return_false_for_vcs', 10, 2 );

 
Plugin & Theme Updates

 
Automatic plugin and theme updates are disabled by default.

 
Here is how to enable Automatic Theme or Plugin updates via Theme’s functions.php file

 
Enable Automatic Plugin Updates

 

// Enable automatic updates for plugins
add_filter( 'auto_update_plugin', '__return_true' );

 
Enable Automatic Theme Updates

 

// Enable automatic updates for themes
add_filter( 'auto_update_theme', '__return_true' );

 
Translation Updates

 
Automatic translation file updates are already enabled by default.

 
Disable Automatic Translation file updates via Theme’s functions.php file

 

// Disable translation file updates
add_filter( 'auto_update_translation', '__return_false' );

 
Disabling Automatic Updates

 
The core developers made a conscious decision to enable automatic updates for minor releases and translation files out of the box. Going forward, this will be one of the best ways to guarantee your site stays up to date and secure and, as such, disabling these updates is strongly discouraged.

 
Disable Core Updates Only

 

// Disable all core-type updates only
add_filter( 'auto_update_core', '__return_false' );

 
Disable All Automatic Updates

 
Through wp-config.php file

 

// Disable All Automatic Updates
define( 'AUTOMATIC_UPDATER_DISABLED', true );

 
Through fuctions.php filter in Themes’s folder

 

// Disable All Automatic Updates
add_filter( 'automatic_updater_disabled', '__return_true' );

 
Disable Automatic Update Result Emails

 
The WordPress Automatic updater sends a result email on success, failure, or critical error. Here is how to disable it via filter:

 

// Disable Automatic Update Result Emails
add_filter( 'auto_core_update_send_email', '__return_false' );

 

Important Note About Automatic Background Updates for WordPress MultiSite:

 
When deploying filters on WordPress Multisite Blog Network, You should put your preferred filters in main domain’s theme functions.php file but additionally you can paste it in subdomain’s theme functions.php file also.

 

My Recommendations!

 
Your Question: What basic WordPress Automatic Background Updates you should activate for your Installation?

 
My Answer: Automatic core minor updates are done by default so you should only enable automatic updates for Themes, Plugins & Major Core Updates.

 
Benefit: You will never have to press ‘Update’ button again in your WordPress installation.

 
Solution: Copy following code in your active theme’s functions.php file

 

// Enable major updates
add_filter( 'allow_major_auto_core_updates', '__return_true' );

// Enable automatic updates for plugins
add_filter( 'auto_update_plugin', '__return_true' );

// Enable automatic updates for themes
add_filter( 'auto_update_theme', '__return_true' );

 

Note: WordPress will check for available updates every 12 hours

 
Hope this information helps you to manage & control your WordPress Website’s Installation’s Automatic Updating Process easily & securely.

 
Thanks & Regards
Mandar Apte

Leave a Reply

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