Make WordPress Core


Ignore:
Timestamp:
09/25/2012 05:26:19 AM (13 years ago)
Author:
nacin
Message:

Introduce constants to allow for easier expression of time periods in seconds. Adds MINUTE_IN_SECONDS, HOUR_IN_SECONDS, DAY_IN_SECONDS, WEEK_IN_SECONDS, YEAR_IN_SECONDS. props nbachiyski, SergeyBiryukov. fixes #20987.

File:
1 edited

Legend:

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

    r21874 r21996  
    156156    switch ( current_filter() ) {
    157157        case 'load-update-core.php' :
    158             $timeout = 60; // 1 min
     158            $timeout = MINUTE_IN_SECONDS;
    159159            break;
    160160        case 'load-plugins.php' :
    161161        case 'load-update.php' :
    162             $timeout = 3600; // 1 hour
     162            $timeout = HOUR_IN_SECONDS;
    163163            break;
    164164        default :
    165             $timeout = 43200; // 12 hours
     165            $timeout = 12 * HOUR_IN_SECONDS;
    166166    }
    167167
     
    265265    switch ( current_filter() ) {
    266266        case 'load-update-core.php' :
    267             $timeout = 60; // 1 min
     267            $timeout = MINUTE_IN_SECONDS;
    268268            break;
    269269        case 'load-themes.php' :
    270270        case 'load-update.php' :
    271             $timeout = 3600; // 1 hour
     271            $timeout = HOUR_IN_SECONDS;
    272272            break;
    273273        default :
    274             $timeout = 43200; // 12 hours
     274            $timeout = 12 * HOUR_IN_SECONDS;
    275275    }
    276276
     
    372372
    373373    if ( isset( $current->last_checked ) &&
    374         43200 > ( time() - $current->last_checked ) &&
     374        12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) &&
    375375        isset( $current->version_checked ) &&
    376376        $current->version_checked == $wp_version )
     
    391391function _maybe_update_plugins() {
    392392    $current = get_site_transient( 'update_plugins' );
    393     if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
     393    if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) )
    394394        return;
    395395    wp_update_plugins();
     
    407407function _maybe_update_themes( ) {
    408408    $current = get_site_transient( 'update_themes' );
    409     if ( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
     409    if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time( ) - $current->last_checked ) )
    410410        return;
    411411
Note: See TracChangeset for help on using the changeset viewer.