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

Introduction to WordPress’s New Functionality Automatic Background Updates:
WordPress 3.7 introduced automatic background updates to promote greater security and streamline the update process. By default, only minor releases are enabled for maintenance and security purposes, as well as translation file updates. The default behaviour in WordPress 3.7 is the automatic core update for minor versions, i.e., from 3.7.0 to 3.7.1. WordPress’s Graphical User Interface (GUI) does not offer configuration options. To change the behaviour, modify the wp-config.php file in your WordPress root installation or add filters to 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 turn them on or off selectively, here is how you will do it,

Turn them on or off via wp-config.php

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

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

Enable Automatic Update for the 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 );

Turn them on or off 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 plugins and theme updates are turned off by default.

Here is how to enable Automatic Theme or Plugin updates via the 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 the theme’s functions.php file

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

Disabling Automatic Updates
The core developers consciously decided to enable automatic updates for minor releases and translation files out of the box. From now on, this will be one of the best ways to guarantee your site stays up-to-date and secure, and turning off 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 the 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 turn it off 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 the main domain’s theme functions.php file. Additionally, you can paste them into the subdomain’s theme functions.php file.

My Recommendations!
Your Question: What basic WordPress Automatic Background Updates should you activate for your installation?My Answer: Automatic core minor updates are done by default, so you should only enable automatic updates for Themes, Plugins, and major Core Updates.
Benefit: You will never have to press the ‘Update’ button again in your WordPress installation.
Solution: Copy the 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
I hope this information helps you manage and control your WordPress Website’s Installation’s Automatic Updating Process easily and securely.

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply