4

I have the following snippet above That's all, stop editing! via wp-config.php file:

/* Enable automatic updates for WordPress ) */
define( 'WP_AUTO_UPDATE_CORE', true );

I also have the following via my functions.php file:

/**
 * Enable automatic updates for plugins and themes
 */
add_filter( 'auto_update_plugin', '__return_true' );
add_filter( 'auto_update_theme', '__return_true' );

Approximately, how frequently does WordPress check for these updates and how quickly are they automatically applied?

The websites I manage seem to vary. From the 50+ sites that I look after, half have applied plugin updates today, whilst the other half haven't applied updates. They are all running the same code and similar setups (themes / plugins). I don't want to jump the gun manually updating these plugins if I can establish that update times vary.

1
  • 1
    As long as i know, each time wp-cron is ran, it will also check for updates too. Updating will not take long if your server has a fast port, mine never take more than a few seconds.
    – Johansson
    Apr 1, 2017 at 1:52

1 Answer 1

2

WordPress will check twice a day ( 12 hours ). This time can drift because WordPress doesn't use traditional server cronjobs but cheap cronjobs which rely on user actions to trigger them such as viewing a page. So it could be 13 hours for when the updates are trigger but it still won't run automatically, someone has to "trip the switch" so to speak by visiting your website.

It's not the most reliable way but it does the job well enough. Here's one of 3 similar functions:

/**
 * Determines whether core should be updated.
 * wp-includes/updates.php
 * Line 632 
 *
 * @since 2.8.0
 *
 * @global string $wp_version
 */
function _maybe_update_core() {
    // include an unmodified $wp_version
    include( ABSPATH . WPINC . '/version.php' );
    $current = get_site_transient( 'update_core' );
    if ( isset( $current->last_checked, $current->version_checked ) &&
            12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) &&
            $current->version_checked == $wp_version ) {
            return;
    }
    wp_version_check();
}
2
  • Superb answer. Do you know if there's a way to "trip the switch" automatically every 12 hours with a function?
    – Sam
    May 3, 2017 at 21:36
  • 1
    @Sam You would need to set up an actual server cronjob to call the PHP function wp_maybe_auto_update(). In the other direction you can also modify when plugins update to only try to update in a certain timeframe window.
    – Howdy_McGee
    May 3, 2017 at 21:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.