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.

git-svn-id: http://core.svn.wordpress.org/trunk@21996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2012-09-25 05:26:19 +00:00
parent 0ada88ef52
commit 557d9313a7
29 changed files with 97 additions and 90 deletions

View File

@ -30,7 +30,7 @@ function wp_credits() {
if ( ! is_array( $results ) )
return false;
set_site_transient( 'wordpress_credits_' . $locale, $results, 86400 ); // One day
set_site_transient( 'wordpress_credits_' . $locale, $results, DAY_IN_SECONDS );
}
return $results;

View File

@ -335,7 +335,7 @@ class WP_Comments_List_Table extends WP_List_Table {
$the_comment_status = wp_get_comment_status( $comment->comment_ID );
$ptime = date( 'G', strtotime( $comment->comment_date ) );
if ( ( abs( time() - $ptime ) ) < 86400 )
if ( ( abs( time() - $ptime ) ) < DAY_IN_SECONDS )
$ptime = sprintf( __( '%s ago' ), human_time_diff( $ptime ) );
else
$ptime = mysql2date( __( 'Y/m/d \a\t g:i A' ), $comment->comment_date );

View File

@ -282,7 +282,7 @@ foreach ( $columns as $column_name => $column_display_name ) {
} else {
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post, false );
if ( ( abs( $t_diff = time() - $time ) ) < 86400 ) {
if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
if ( $t_diff < 0 )
$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
else

View File

@ -70,14 +70,13 @@ class WP_Plugins_List_Table extends WP_List_Table {
}
}
set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), 86400 );
set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS );
if ( ! $screen->is_network ) {
$recently_activated = get_option( 'recently_activated', array() );
$one_week = 7*24*60*60;
foreach ( $recently_activated as $key => $time )
if ( $time + $one_week < time() )
if ( $time + WEEK_IN_SECONDS < time() )
unset( $recently_activated[$key] );
update_option( 'recently_activated', $recently_activated );
}

View File

@ -580,7 +580,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < 24*60*60 )
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
else
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );

View File

@ -916,7 +916,7 @@ function wp_dashboard_plugins_output() {
if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) {
$plugin_slugs = array_keys( get_plugins() );
set_transient( 'plugin_slugs', $plugin_slugs, 86400 );
set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS );
}
foreach ( array( 'popular' => __('Most Popular'), 'new' => __('Newest Plugins') ) as $feed => $label ) {
@ -1024,7 +1024,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar
array_unshift( $args, $widget_id );
ob_start();
call_user_func_array( $callback, $args );
set_transient( $cache_key, ob_get_flush(), 43200); // Default lifetime in cache of 12 hours (same as the feeds)
set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds)
}
return true;
@ -1215,7 +1215,7 @@ function wp_check_browser_version() {
if ( ! is_array( $response ) )
return false;
set_site_transient( 'browser_' . $key, $response, 604800 ); // cache for 1 week
set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS );
}
return $response;

View File

@ -89,7 +89,7 @@ function wp_import_handle_upload() {
$id = wp_insert_attachment( $object, $file );
// schedule a cleanup for one day from now in case of failed import or missing wp_import_cleanup() call
wp_schedule_single_event( time() + 86400, 'importer_scheduled_cleanup', array( $id ) );
wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) );
return array( 'file' => $file, 'id' => $id );
}

View File

@ -1150,7 +1150,7 @@ function wp_nav_menu_manage_columns() {
*/
function _wp_delete_orphaned_draft_menu_items() {
global $wpdb;
$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
// delete orphaned draft menu items
$menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) );

View File

@ -74,7 +74,7 @@ function install_popular_tags( $args = array() ) {
if ( is_wp_error($tags) )
return $tags;
set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800
set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
return $tags;
}

View File

@ -511,11 +511,11 @@ function upgrade_110() {
$time_difference = $all_options->time_difference;
$server_time = time()+date('Z');
$weblogger_time = $server_time + $time_difference*3600;
$weblogger_time = $server_time + $time_difference * HOUR_IN_SECONDS;
$gmt_time = time();
$diff_gmt_server = ($gmt_time - $server_time) / 3600;
$diff_weblogger_server = ($weblogger_time - $server_time) / 3600;
$diff_gmt_server = ($gmt_time - $server_time) / HOUR_IN_SECONDS;
$diff_weblogger_server = ($weblogger_time - $server_time) / HOUR_IN_SECONDS;
$diff_gmt_weblogger = $diff_gmt_server - $diff_weblogger_server;
$gmt_offset = -$diff_gmt_weblogger;

View File

@ -125,7 +125,7 @@ require(ABSPATH . WPINC . '/version.php');
$compress = ( isset($_GET['c']) && $_GET['c'] );
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
$expires_offset = 31536000;
$expires_offset = YEAR_IN_SECONDS;
$out = '';
$wp_scripts = new WP_Scripts();

View File

@ -104,7 +104,7 @@ if ( empty($load) )
$compress = ( isset($_GET['c']) && $_GET['c'] );
$force_gzip = ( $compress && 'gzip' == $_GET['c'] );
$rtl = ( isset($_GET['dir']) && 'rtl' == $_GET['dir'] );
$expires_offset = 31536000;
$expires_offset = YEAR_IN_SECONDS;
$out = '';
$wp_styles = new WP_Styles();

View File

@ -78,7 +78,7 @@ function _walk_bookmarks($bookmarks, $args = '' ) {
if ( $show_updated )
if ( '00' != substr($bookmark->link_updated_f, 0, 2) ) {
$title .= ' (';
$title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * 3600)));
$title .= sprintf(__('Last updated: %s'), date(get_option('links_updated_date_format'), $bookmark->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)));
$title .= ')';
}

View File

@ -808,7 +808,7 @@ class WP_Http_Fsockopen {
if ( ! function_exists( 'fsockopen' ) )
return false;
if ( false !== ($option = get_option( 'disable_fsockopen' )) && time()-$option < 43200 ) // 12 hours
if ( false !== ( $option = get_option( 'disable_fsockopen' ) ) && time() - $option < 12 * HOUR_IN_SECONDS )
return false;
$is_ssl = isset( $args['ssl'] ) && $args['ssl'];

View File

@ -699,7 +699,7 @@ function check_comment_flood_db( $ip, $email, $date ) {
global $wpdb;
if ( current_user_can( 'manage_options' ) )
return; // don't throttle admins
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );
$hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
if ( $lasttime = $wpdb->get_var( $wpdb->prepare( "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( `comment_author_IP` = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1", $hour_ago, $ip, $email ) ) ) {
$time_lastcomment = mysql2date('U', $lasttime, false);
$time_newcomment = mysql2date('U', $date, false);
@ -1981,7 +1981,7 @@ function _close_comments_for_old_posts( $posts, $query ) {
if ( ! $days_old )
return $posts;
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
$posts[0]->comment_status = 'closed';
$posts[0]->ping_status = 'closed';
}
@ -2016,7 +2016,7 @@ function _close_comments_for_old_post( $open, $post_id ) {
if ( ! in_array( $post->post_type, $post_types ) )
return $open;
if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
return false;
return $open;

View File

@ -22,7 +22,7 @@
function wp_schedule_single_event( $timestamp, $hook, $args = array()) {
// don't schedule a duplicate if there's already an identical event due in the next 10 minutes
$next = wp_next_scheduled($hook, $args);
if ( $next && $next <= $timestamp + 600 )
if ( $next && $next <= $timestamp + 10 * MINUTE_IN_SECONDS )
return;
$crons = _get_cron_array();
@ -206,7 +206,7 @@ function spawn_cron( $gmt_time = 0 ) {
*/
$lock = get_transient('doing_cron');
if ( $lock > $gmt_time + 10*60 )
if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS )
$lock = 0;
// don't run if another process is currently running it or more than once every 60 sec.
@ -318,9 +318,9 @@ function wp_cron() {
*/
function wp_get_schedules() {
$schedules = array(
'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ),
'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
'hourly' => array( 'interval' => HOUR_IN_SECONDS, 'display' => __( 'Once Hourly' ) ),
'twicedaily' => array( 'interval' => 12 * HOUR_IN_SECONDS, 'display' => __( 'Twice Daily' ) ),
'daily' => array( 'interval' => DAY_IN_SECONDS, 'display' => __( 'Once Daily' ) ),
);
return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
}

View File

@ -72,6 +72,14 @@ function wp_initial_constants( ) {
if ( !defined('SHORTINIT') )
define('SHORTINIT', false);
// Constants for expressing human-interval intervals
// in their respective number of seconds.
define( 'MINUTE_IN_SECONDS', 60 );
define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
}
/**

View File

@ -984,7 +984,7 @@ function get_links($category = -1, $before = '', $after = '<br />', $between = '
if ( $show_updated )
if (substr($row->link_updated_f, 0, 2) != '00')
$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')';
$title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS)) . ')';
if ( '' != $title )
$title = ' title="' . $title . '"';

View File

@ -538,7 +538,7 @@ function fetch_feed($url) {
}
$feed->set_feed_url($url);
$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));
$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
$feed->init();
$feed->handle_content_type();

View File

@ -1898,13 +1898,13 @@ function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
$datetime = new DateTime( $string );
$datetime->setTimezone( new DateTimeZone('UTC') );
$offset = $datetime->getOffset();
$datetime->modify( '+' . $offset / 3600 . ' hours');
$datetime->modify( '+' . $offset / HOUR_IN_SECONDS . ' hours');
$string_gmt = gmdate($format, $datetime->format('U'));
date_default_timezone_set('UTC');
} else {
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * HOUR_IN_SECONDS);
}
return $string_gmt;
}
@ -1924,7 +1924,7 @@ function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
$string_localtime = gmdate($format, $string_time + get_option('gmt_offset') * HOUR_IN_SECONDS);
return $string_localtime;
}
@ -1944,7 +1944,7 @@ function iso8601_timezone_to_offset($timezone) {
$sign = (substr($timezone, 0, 1) == '+') ? 1 : -1;
$hours = intval(substr($timezone, 1, 2));
$minutes = intval(substr($timezone, 3, 4)) / 60;
$offset = $sign * 3600 * ($hours + $minutes);
$offset = $sign * HOUR_IN_SECONDS * ($hours + $minutes);
}
return $offset;
}
@ -1968,7 +1968,7 @@ function iso8601_to_datetime($date_string, $timezone = 'user') {
if (!empty($date_bits[7])) { // we have a timezone, so let's compute an offset
$offset = iso8601_timezone_to_offset($date_bits[7]);
} else { // we don't have a timezone, so we assume user local timezone (not server's!)
$offset = 3600 * get_option('gmt_offset');
$offset = HOUR_IN_SECONDS * get_option('gmt_offset');
}
$timestamp = gmmktime($date_bits[4], $date_bits[5], $date_bits[6], $date_bits[2], $date_bits[3], $date_bits[1]);
@ -2093,28 +2093,28 @@ function sanitize_email( $email ) {
* @return string Human readable time difference.
*/
function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
if ( empty( $to ) )
$to = time();
$diff = (int) abs($to - $from);
if ($diff <= 3600) {
$mins = round($diff / 60);
if ($mins <= 1) {
$diff = (int) abs( $to - $from );
if ( $diff <= HOUR_IN_SECONDS ) {
$mins = round( $diff / MINUTE_IN_SECONDS );
if ( $mins <= 1 ) {
$mins = 1;
}
/* translators: min=minute */
$since = sprintf(_n('%s min', '%s mins', $mins), $mins);
} else if (($diff <= 86400) && ($diff > 3600)) {
$hours = round($diff / 3600);
if ($hours <= 1) {
$since = sprintf( _n( '%s min', '%s mins', $mins ), $mins );
} elseif ( ( $diff <= DAY_IN_SECONDS ) && ( $diff > HOUR_IN_SECONDS ) ) {
$hours = round( $diff / HOUR_IN_SECONDS );
if ( $hours <= 1 ) {
$hours = 1;
}
$since = sprintf(_n('%s hour', '%s hours', $hours), $hours);
} elseif ($diff >= 86400) {
$days = round($diff / 86400);
if ($days <= 1) {
$since = sprintf( _n( '%s hour', '%s hours', $hours ), $hours );
} elseif ( $diff >= DAY_IN_SECONDS ) {
$days = round( $diff / DAY_IN_SECONDS );
if ( $days <= 1 ) {
$days = 1;
}
$since = sprintf(_n('%s day', '%s days', $days), $days);
$since = sprintf( _n( '%s day', '%s days', $days ), $days );
}
return $since;
}

View File

@ -59,10 +59,10 @@ function mysql2date( $format, $date, $translate = true ) {
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
case 'mysql':
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * 3600 ) ) );
return ( $gmt ) ? gmdate( 'Y-m-d H:i:s' ) : gmdate( 'Y-m-d H:i:s', ( time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) ) );
break;
case 'timestamp':
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * 3600 );
return ( $gmt ) ? time() : time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS );
break;
}
}
@ -214,8 +214,8 @@ function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
if ( $weekday < $start_of_week )
$weekday += 7;
$start = $day - 86400 * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
$end = $start + 604799; // $start + 7 days - 1 second
$start = $day - DAY_IN_SECONDS * ( $weekday - $start_of_week ); // The most recent week start day on or before $day
$end = $start + 7 * DAY_IN_SECONDS - 1; // $start + 7 days - 1 second
return compact( 'start', 'end' );
}
@ -934,7 +934,7 @@ function nocache_headers() {
* @since 2.1.0
*/
function cache_javascript_headers() {
$expiresOffset = 864000; // 10 days
$expiresOffset = 10 * DAY_IN_SECONDS;
header( "Content-Type: text/javascript; charset=" . get_bloginfo( 'charset' ) );
header( "Vary: Accept-Encoding" ); // Handle proxies
header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT" );
@ -3117,7 +3117,7 @@ function wp_timezone_override_offset() {
if ( false === $timezone_object || false === $datetime_object ) {
return false;
}
return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 );
return round( timezone_offset_get( $timezone_object, $datetime_object ) / HOUR_IN_SECONDS, 2 );
}
/**
@ -3317,7 +3317,7 @@ function _cleanup_header_comment($str) {
function wp_scheduled_delete() {
global $wpdb;
$delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
$delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
$posts_to_delete = $wpdb->get_results($wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < '%d'", $delete_timestamp), ARRAY_A);

View File

@ -19,7 +19,7 @@ function get_file($path) {
return @file_get_contents($path);
}
$expires_offset = 31536000;
$expires_offset = YEAR_IN_SECONDS;
header('Content-Type: application/x-javascript; charset=UTF-8');
header('Vary: Accept-Encoding'); // Handle proxies

View File

@ -1408,7 +1408,7 @@ function get_dirsize( $directory ) {
$dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
set_transient( 'dirsize_cache', $dirsize, 3600 );
set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
return $dirsize[ $directory ][ 'size' ];
}

View File

@ -560,8 +560,8 @@ function wp_user_settings() {
}
}
setcookie( 'wp-settings-' . $user->ID, $settings, time() + 31536000, SITECOOKIEPATH );
setcookie( 'wp-settings-time-' . $user->ID, time(), time() + 31536000, SITECOOKIEPATH );
setcookie( 'wp-settings-' . $user->ID, $settings, time() + YEAR_IN_SECONDS, SITECOOKIEPATH );
setcookie( 'wp-settings-time-' . $user->ID, time(), time() + YEAR_IN_SECONDS, SITECOOKIEPATH );
$_COOKIE['wp-settings-' . $user->ID] = $settings;
}
@ -724,7 +724,7 @@ function delete_all_user_settings() {
return;
update_user_option( $user->ID, 'user-settings', '', false );
setcookie('wp-settings-' . $user->ID, ' ', time() - 31536000, SITECOOKIEPATH);
setcookie('wp-settings-' . $user->ID, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH);
}
/**

View File

@ -529,7 +529,7 @@ function wp_validate_auth_cookie($cookie = '', $scheme = '') {
// Allow a grace period for POST and AJAX requests
if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
$expired += 3600;
$expired += HOUR_IN_SECONDS;
// Quick check to see if an honest cookie has expired
if ( $expired < time() ) {
@ -694,24 +694,24 @@ if ( !function_exists('wp_clear_auth_cookie') ) :
function wp_clear_auth_cookie() {
do_action('clear_auth_cookie');
setcookie(AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
setcookie(LOGGED_IN_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN );
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN );
setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
// Old cookies
setcookie(AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
// Even older cookies
setcookie(USER_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, ' ', time() - 31536000, COOKIEPATH, COOKIE_DOMAIN);
setcookie(USER_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, ' ', time() - 31536000, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN );
setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN );
}
endif;
@ -1229,7 +1229,7 @@ if ( !function_exists('wp_nonce_tick') ) :
* @return int
*/
function wp_nonce_tick() {
$nonce_life = apply_filters('nonce_life', 86400);
$nonce_life = apply_filters( 'nonce_life', DAY_IN_SECONDS );
return ceil(time() / ( $nonce_life / 2 ));
}

View File

@ -1399,7 +1399,7 @@ function get_terms($taxonomies, $args = '') {
}
if ( empty($terms) ) {
wp_cache_add( $cache_key, array(), 'terms', 86400 ); // one day
wp_cache_add( $cache_key, array(), 'terms', DAY_IN_SECONDS );
$terms = apply_filters('get_terms', array(), $taxonomies, $args);
return $terms;
}
@ -1450,7 +1450,7 @@ function get_terms($taxonomies, $args = '') {
$terms = array_slice($terms, $offset, $number);
}
wp_cache_add( $cache_key, $terms, 'terms', 86400 ); // one day
wp_cache_add( $cache_key, $terms, 'terms', DAY_IN_SECONDS );
$terms = apply_filters('get_terms', $terms, $taxonomies, $args);
return $terms;

View File

@ -155,14 +155,14 @@ function wp_update_plugins() {
// Check for update on a different schedule, depending on the page.
switch ( current_filter() ) {
case 'load-update-core.php' :
$timeout = 60; // 1 min
$timeout = MINUTE_IN_SECONDS;
break;
case 'load-plugins.php' :
case 'load-update.php' :
$timeout = 3600; // 1 hour
$timeout = HOUR_IN_SECONDS;
break;
default :
$timeout = 43200; // 12 hours
$timeout = 12 * HOUR_IN_SECONDS;
}
$time_not_changed = isset( $current->last_checked ) && $timeout > ( time() - $current->last_checked );
@ -264,14 +264,14 @@ function wp_update_themes() {
// Check for update on a different schedule, depending on the page.
switch ( current_filter() ) {
case 'load-update-core.php' :
$timeout = 60; // 1 min
$timeout = MINUTE_IN_SECONDS;
break;
case 'load-themes.php' :
case 'load-update.php' :
$timeout = 3600; // 1 hour
$timeout = HOUR_IN_SECONDS;
break;
default :
$timeout = 43200; // 12 hours
$timeout = 12 * HOUR_IN_SECONDS;
}
$time_not_changed = isset( $last_update->last_checked ) && $timeout > ( time( ) - $last_update->last_checked );
@ -371,7 +371,7 @@ function _maybe_update_core() {
$current = get_site_transient( 'update_core' );
if ( isset( $current->last_checked ) &&
43200 > ( time() - $current->last_checked ) &&
12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) &&
isset( $current->version_checked ) &&
$current->version_checked == $wp_version )
return;
@ -390,7 +390,7 @@ function _maybe_update_core() {
*/
function _maybe_update_plugins() {
$current = get_site_transient( 'update_plugins' );
if ( isset( $current->last_checked ) && 43200 > ( time() - $current->last_checked ) )
if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time() - $current->last_checked ) )
return;
wp_update_plugins();
}
@ -406,7 +406,7 @@ function _maybe_update_plugins() {
*/
function _maybe_update_themes( ) {
$current = get_site_transient( 'update_themes' );
if ( isset( $current->last_checked ) && 43200 > ( time( ) - $current->last_checked ) )
if ( isset( $current->last_checked ) && 12 * HOUR_IN_SECONDS > ( time( ) - $current->last_checked ) )
return;
wp_update_themes();

View File

@ -390,7 +390,7 @@ case 'postpass' :
}
// 10 days
setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 864000, COOKIEPATH );
setcookie( 'wp-postpass_' . COOKIEHASH, $wp_hasher->HashPassword( stripslashes( $_POST['post_password'] ) ), time() + 10 * DAY_IN_SECONDS, COOKIEPATH );
wp_safe_redirect( wp_get_referer() );
exit();

View File

@ -30,7 +30,7 @@ if ( $last_checked )
set_transient('mailserver_last_checked', true, WP_MAIL_INTERVAL);
$time_difference = get_option('gmt_offset') * 3600;
$time_difference = get_option('gmt_offset') * HOUR_IN_SECONDS;
$phone_delim = '::';