WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2013 04:01:06 AM (6 years ago)
Author:
nacin
Message:

Remove the old wp_auto_updates_maybe_update cron event. Schedule the new wp_maybe_auto_update event at 7 a.m. and 7 p.m. in the site's timezone.

see #27704.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/update.php

    r25823 r25825  
    567567        wp_schedule_event(time(), 'twicedaily', 'wp_update_themes');
    568568
    569     if ( !wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) )
    570         wp_schedule_event( time(), 'twicedaily', 'wp_maybe_auto_update' );
     569    if ( ! wp_next_scheduled( 'wp_maybe_auto_update' ) && ! defined( 'WP_INSTALLING' ) ) {
     570        // Schedule auto updates for 7 a.m. and 7 p.m. in the timezone of the site.
     571        $next = strtotime( 'today 7am' );
     572        $now = time();
     573        // Find the next instance of 7 a.m. or 7 p.m., but skip it if it is within 3 hours from now.
     574        while ( ( $now + 3 * HOUR_IN_SECONDS ) > $next ) {
     575            $next += 12 * HOUR_IN_SECONDS;
     576        }
     577        $next = $next - get_option( 'gmt_offset' ) * HOUR_IN_SECONDS;
     578        wp_schedule_event( $next, 'twicedaily', 'wp_maybe_auto_update' );
     579    }
    571580}
    572581
Note: See TracChangeset for help on using the changeset viewer.