An In-depth Look at WordPress Automated Updates

May 31, 2022
wordpress automatic updates
  1. Database tables, backup files, and back-ups
  2. Disable plugins
  3. Update
  4. Allow plugins one at a time.
  5. Go to the website

It can be an exhausting job for one website, and could be an annoying and complex job for those who have to upgrade up to ten, five or even many more sites.

In order to improve the installation security and to make administration of the website more simple, WordPress 3.7 introduced automatic updates. By default, this cool feature is only available on minor updates (i.e. security and maintenance releases) and translations files however it's also possible to alter any kind of updates. This is why, in this blog post we'll discuss how to automate the upgrade process whenever a new version of WordPress themes, core or plugin is launched. So, let's get into WordPress automated updates!

WordPress automatic updates
WordPress automatic updates

Automatic Updates Index

WordPress Automatic Updates

There are four different types of updates and WordPress automatic updates:

  1.    Core Updates  
  2.    Plugin updates  
  3.    Theme changes  
  4.    Translation files updates  

Core updates are divided into three sub-types of a sub-typology:

  1. Development Core (only made available to developers on installation for development)
  2. Small core updates (maintenance and security) is disabled by default on stable versions
  3.    Big core update  

WordPress can be automated to manage the process of updating for any of these typologies offering the two wp-config.php constants and numerous API filters.

The Control of Background Updates through wp-config.php

WordPress has a number of wp-config.php constants that enable us to manage auto-updates. Setting AUTOMATIC_UPDATER_DISABLED to true will disable any kind of automatic upgrade:

define( 'AUTOMATIC_UPDATER_DISABLED', true );

WP_AUTO_UPDATE_CORE allows us to manage core updates (minor, major and development releases). This constant can be defined in the following way:

# Disables all core updates:
 define( 'WP_AUTO_UPDATE_CORE', false );
 
 # Enables all core updates, including minor and major:
 define( 'WP_AUTO_UPDATE_CORE', true );
 
 # Enables minor updates:
 define( 'WP_AUTO_UPDATE_CORE', 'minor' );
 

For development environments, WP_AUTO_UPDATE_CORE is set to true. In stable installations it defaults to minor.

For the sake of completeness, I should mention an additional constant that can be defined to disable auto-updates. But setting it to true will disable any modifications to files, not even the installation of themes or plugins, as well as manual updates.

define( 'DISALLOW_FILE_MODS', true );

It is better to define the Disallow_FILE_EDITS constant. This would disable the file editor, while preserving the installation and update functionalities.

Controlling Background Updates via API Filters

Configuration constants provide a general method to disable or enable auto-updates. But WordPress provides a number of options to give users more control over each kind of updates.

Note: Filters should be integrated into plugins as well as "must make use of plugins" are a good option for background updates. mu-plugins reside in a specific folder within /wp-content and are automatically enabled by WordPress. The plugins are not visible on the WordPress Plugins Screen, so they could not be accidentally disabled or removed by the WordPress admins. For more information of the plugins, check out the Codex document.

First, returning true through the automatic_updater_disabled filter has the same effect as defining the AUTOMATIC_UPDATER_DISABLED constant to true in wp-config.php:

add_filter( 'automatic_updater_disabled', '__return_true' );

We can control any updates by using the auto_update_$type filters that enable or disable updates depending on the $type value ('core', 'plugin', 'theme' or "translation").

So, we can automate all core updates when we return true via the auto_update_core filter:

add_filter( 'auto_update_core', '__return_true' );

In the next example, we're enabling automatic updates to themes, plugins as well as translations:

add_filter( 'auto_update_theme', '__return_true' );
 add_filter( 'auto_update_plugin', '__return_true' );
 add_filter( 'auto_update_translation', '__return_true' );

In the examples above we've only activated automatic updates. However, these filters allow us to have the ability to control updates. In this example, we'll automate auto-updates on two specific plugins:

function cb_auto_update_plugins ( $update, $item ) 
 $plugins = array ( 'hello', 'akismet' );
 if ( in_array( $item->slug, $plugins ) ) 
 // update plugin
 return true; 
  else 
 // use default settings
 return $update; 
 
 
 add_filter( 'auto_update_plugin', 'cb_auto_update_plugins', 10, 2 );
 

Callback functions keep two arguments:

Want to know what we did to increase our traffic over 1000 percent?

Join 20,000+ others who get our weekly newsletter with insider WordPress tricks!

  1. $update A boolean that decides whether or not;
  2. $item This is the update-offer object.

This function tests if the object to be updated is in $plugins array. If it is, it returns true or false accordingly.

Last, we can make difference between development, minor and major updates, through making either true or false through these filtering:

add_filter( 'allow_dev_auto_core_updates', '__return_false' );
 add_filter( 'allow_minor_auto_core_updates', '__return_true' );
 add_filter( 'allow_major_auto_core_updates', '__return_true' );
 

We know that occasionally the update may be unsuccessful. In the worst case, your website could go out of service after an update fails. We can, however, ask WordPress to notify us with an email upon any upgrade (or attempt to do so).

Result, Notification and Debugging emails

Based on the outcome of the update process, WordPress is able to send an email to the administrator address:

  • a result email will be sent after an automatic update to the core
  • A notification email will be sent out when WordPress could not run an automatic update;
  • an email to debug can be sent to developers in version of WordPress.

When an auto-update fails or fails, WordPress sends a result or notification email with one of the following topics:

  • Your site has changed up to WordPress XXX (case success)

The auto_core_update_send_email filter controls result and notification emails. These emails can be disabled through returning false as follows:

apply_filters( 'auto_core_update_send_email', '__return_false' );

Particularly if you plan to extend automatic updates to the major theme and/or core and plugin versions, you may prefer to leave result and notification emails enabled, or customize your emails based on the outcome or the update's typology. For example, WordPress doesn't email the result email in the event of a successful update:

function cb_auto_core_update_send_email ( $send, $type, $core_update, $result ) 
 if ( !empty( $type ) && $type == 'success' ) 
 // don't send email
 return false; 
 
 // use default settings
 return $send; 
 
 }
 add_filter( 'auto_core_update_send_email', 'cb_auto_core_update_send_email', 10, 4 );
 

Callback functions keep these arguments in mind:

  • The $send can be described as a boolean that will determine if it is ok to send an email result email or a notification;
  • $type is a string that specifies the email type to be sent (success failure, critical);
  • The $core_update is the update offer object;
  • The $result is the output of the update to the core (can be a WP_Error).

Administrators are not notified when an update request was received from WordPress.org has a specific setting and the installed cannot upgrade. The notification email will only be sent out every update. The send_core_update_notification_email filter allows some discretion in wether and when to send this kind of notifications. Use the filter in this manner:

apply_filters( 'send_core_update_notification_email', '__return_true' );

Finally, the automatic_updates_send_debug_email filter controls debugging emails, which provide useful log information concerning the performed updates. The default is that these emails are sent to WordPress development versions. False will block WordPress from sending debug emails and returning true will enable this feature even for stable versions:

apply_filters( 'automatic_updates_send_debug_email', '__return_true' );

What is the best time and reason to disable WordPress's Automatic Updates

The auto-updating process is a great feature to many users as they can save a lot of time and energy.
 Even if it seems as if that auto-updates are secure it is important to consider if it's always a good option to allow each one of them.

Sometimes, we may encounter difficulties with themes or plugins which can cause interruptions to some functions or completely break the website. If your site relies upon a large number of plugins, it might be safer to perform manual update, at the very least for plugins. One-by-one updates allow us to quickly detect issues that automation would make hard to find.

Additionally, if you're a developer, you need to be aware of the names you choose for your themes and plugins even if you're not planning to release them. While running updates WordPress searches the Plugin Directory for the latest editions of plugins. It replaces your plugins when a plugin that has identical name is discovered. If you are thinking to enable background updates for themes and plugins, be sure to set distinct names for your scripts.

Yes, there's lots of useful information for developers. However, how does a non-developer user manage automatic updates?

The Control WordPress Automatic Updates with WordPress Plugins

If you're not a developer, you can control WordPress automatic updates with the plugin.

Easy Updates Manager - manage WordPress automatic updates
Easy Updates Manager
WP Rollback
WP Rollback

Finally, if you need to test the compatibility of auto-updates for your WordPress setup, Background Update Tester will give you the info that you require.

Automated Updates of Premium Plugins and Themes

As an author of premium WordPress themes or plugins, it's your duty to integrate an automatic updates feature into your plugins or themes in order to provide the smooth update experience customers have come to expect when using WordPress.org products. It's now a market standard (for an excellent reason). You can host the high-end products you want and build an updated mechanism or use platforms such as Freemius, Kernl and WP Updates with a secure repository and automatic updates via a subscription in-built.

Summary

WordPress automated updates are a great feature that could make a huge difference in time and energy, as well as let us keep our website regularly updated. Would you be able to enable every kind of update? Tell us via the comment section below.

Reduce time, money and maximize site performance with:

  • Help is available immediately from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise integration.
  • The global reach of the audience is enhanced by 34 data centers worldwide.
  • Optimization using the integrated Application for Performance Monitoring.