WordPress.org

Make WordPress Core

Ticket #20987: 20987.patch

File 20987.patch, 6.6 KB (added by SergeyBiryukov, 6 years ago)
  • wp-admin/includes/class-wp-plugins-list-table.php

     
    7474                if ( ! $screen->is_network ) {
    7575                        $recently_activated = get_option( 'recently_activated', array() );
    7676
    77                         $one_week = 7*24*60*60;
    7877                        foreach ( $recently_activated as $key => $time )
    79                                 if ( $time + $one_week < time() )
     78                                if ( $time + WEEK_IN_SECONDS < time() )
    8079                                        unset( $recently_activated[$key] );
    8180                        update_option( 'recently_activated', $recently_activated );
    8281                }
  • wp-admin/includes/class-wp-posts-list-table.php

     
    573573
    574574                                        $time_diff = time() - $time;
    575575
    576                                         if ( $time_diff > 0 && $time_diff < 24*60*60 )
     576                                        if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS )
    577577                                                $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
    578578                                        else
    579579                                                $h_time = mysql2date( __( 'Y/m/d' ), $m_time );
  • wp-admin/includes/nav-menu.php

     
    11501150 */
    11511151function _wp_delete_orphaned_draft_menu_items() {
    11521152        global $wpdb;
    1153         $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     1153        $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
    11541154
    11551155        // delete orphaned draft menu items
    11561156        $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 ) );
  • wp-admin/includes/plugin-install.php

     
    7474        if ( is_wp_error($tags) )
    7575                return $tags;
    7676
    77         set_site_transient('poptags_' . $key, $tags, 10800); // 3 * 60 * 60 = 10800
     77        set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS );
    7878
    7979        return $tags;
    8080}
  • wp-includes/comment.php

     
    19761976        if ( ! $days_old )
    19771977                return $posts;
    19781978
    1979         if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) ) {
     1979        if ( time() - strtotime( $posts[0]->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) ) {
    19801980                $posts[0]->comment_status = 'closed';
    19811981                $posts[0]->ping_status = 'closed';
    19821982        }
     
    20112011        if ( ! in_array( $post->post_type, $post_types ) )
    20122012                return $open;
    20132013
    2014         if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * 24 * 60 * 60 ) )
     2014        if ( time() - strtotime( $post->post_date_gmt ) > ( $days_old * DAY_IN_SECONDS ) )
    20152015                return false;
    20162016
    20172017        return $open;
  • wp-includes/cron.php

     
    206206        */
    207207        $lock = get_transient('doing_cron');
    208208
    209         if ( $lock > $local_time + 10*60 )
     209        if ( $lock > $local_time + 10 * MINUTE_IN_SECONDS )
    210210                $lock = 0;
    211211
    212212        // don't run if another process is currently running it or more than once every 60 sec.
     
    313313 */
    314314function wp_get_schedules() {
    315315        $schedules = array(
    316                 'hourly' => array( 'interval' => 3600, 'display' => __('Once Hourly') ),
    317                 'twicedaily' => array( 'interval' => 43200, 'display' => __('Twice Daily') ),
    318                 'daily' => array( 'interval' => 86400, 'display' => __('Once Daily') ),
     316                'hourly' => array( 'interval' => HOUR_IN_SECONDS, 'display' => __('Once Hourly') ),
     317                'twicedaily' => array( 'interval' => DAY_IN_SECONDS / 2, 'display' => __('Twice Daily') ),
     318                'daily' => array( 'interval' => DAY_IN_SECONDS, 'display' => __('Once Daily') ),
    319319        );
    320320        return array_merge( apply_filters( 'cron_schedules', array() ), $schedules );
    321321}
  • wp-includes/default-constants.php

     
    299299                define( 'WP_DEFAULT_THEME', 'twentyeleven' );
    300300
    301301}
     302
     303/**
     304 * Defines time related WordPress constants
     305 *
     306 * @since 3.5.0
     307 */
     308function wp_time_constants( ) {
     309        /**
     310         * Constants for expressing human-interval intervals in their
     311         * respective number of seconds
     312         */
     313        define( 'MINUTE_IN_SECONDS', 60 );
     314        define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
     315        define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
     316        define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
     317        define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
     318        define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
     319
     320        /**
     321         * Constants for expressing human-interval intervals in their
     322         * respective number of minutes
     323         */
     324        define( 'HOUR_IN_MINUTES', 60 );
     325        define( 'DAY_IN_MINUTES', 24 * HOUR_IN_MINUTES );
     326        define( 'WEEK_IN_MINUTES', 7 * DAY_IN_MINUTES );
     327        define( 'MONTH_IN_MINUTES', 30 * DAY_IN_MINUTES );
     328        define( 'YEAR_IN_MINUTES', 365 * DAY_IN_MINUTES );
     329}
  • wp-includes/functions.php

     
    32203220function wp_scheduled_delete() {
    32213221        global $wpdb;
    32223222
    3223         $delete_timestamp = time() - (60*60*24*EMPTY_TRASH_DAYS);
     3223        $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
    32243224
    32253225        $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);
    32263226
  • wp-settings.php

     
    2323require( ABSPATH . WPINC . '/version.php' );
    2424
    2525// Set initial default constants including WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT, WP_DEBUG, WP_CONTENT_DIR and WP_CACHE.
    26 wp_initial_constants( );
     26wp_initial_constants();
     27// Define time related constants.
     28wp_time_constants();
    2729
    2830// Check for the required PHP version and for the MySQL extension or a database drop-in.
    2931wp_check_php_mysql_versions();