Make WordPress Core


Ignore:
Timestamp:
09/25/2012 05:26:19 AM (12 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/comment.php

    r21938 r21996  
    700700    if ( current_user_can( 'manage_options' ) )
    701701        return; // don't throttle admins
    702     $hour_ago = gmdate( 'Y-m-d H:i:s', time() - 3600 );
     702    $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );
    703703    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 ) ) ) {
    704704        $time_lastcomment = mysql2date('U', $lasttime, false);
     
    19821982        return $posts;
    19831983
    1984     if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
     1984    if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
    19851985        $posts[0]->comment_status = 'closed';
    19861986        $posts[0]->ping_status = 'closed';
     
    20172017        return $open;
    20182018
    2019     if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
     2019    if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
    20202020        return false;
    20212021
Note: See TracChangeset for help on using the changeset viewer.