From 0b83bffd457a47469e5f6c69ed1033c08e9f90da Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 25 Oct 2019 12:51:03 +0000 Subject: [PATCH] Date/Time: Correct the logic in `WP_Posts_List_Table::column_date()` and `WP_Media_List_Table::column_date()` to check for a valid post timestamp. Props Rarst. Reviewed by azaozz, SergeyBiryukov. See #48384. Built from https://develop.svn.wordpress.org/trunk@46578 git-svn-id: http://core.svn.wordpress.org/trunk@46375 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../includes/class-wp-media-list-table.php | 19 ++++++---------- .../includes/class-wp-posts-list-table.php | 22 ++++++++++++++----- wp-includes/version.php | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/wp-admin/includes/class-wp-media-list-table.php b/wp-admin/includes/class-wp-media-list-table.php index e00e28eb57..b76c92072d 100644 --- a/wp-admin/includes/class-wp-media-list-table.php +++ b/wp-admin/includes/class-wp-media-list-table.php @@ -452,19 +452,14 @@ class WP_Media_List_Table extends WP_List_Table { if ( '0000-00-00 00:00:00' === $post->post_date ) { $h_time = __( 'Unpublished' ); } else { - $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post, false ); - $t_diff = time() - $time; - if ( ( abs( $t_diff ) ) < DAY_IN_SECONDS ) { - if ( $t_diff < 0 ) { - /* translators: %s: Human-readable time difference. */ - $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); - } else { - /* translators: %s: Human-readable time difference. */ - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); - } + $time = get_post_timestamp( $post ); + $time_diff = time() - $time; + + if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { + /* translators: %s: Human-readable time difference. */ + $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + $h_time = get_the_time( __( 'Y/m/d' ), $post ); } } diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index 71c77d877a..cb7b6c21af 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -1066,17 +1066,15 @@ class WP_Posts_List_Table extends WP_List_Table { $h_time = $t_time; $time_diff = 0; } else { - $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); - $m_time = $post->post_date; - $time = get_post_time( 'G', true, $post ); - + $t_time = get_the_time( __( 'Y/m/d g:i:s a' ), $post ); + $time = get_post_timestamp( $post ); $time_diff = time() - $time; - if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { + if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { /* translators: %s: Human-readable time difference. */ $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); } else { - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); + $h_time = get_the_time( __( 'Y/m/d' ), $post ); } } @@ -1584,6 +1582,18 @@ class WP_Posts_List_Table extends WP_List_Table { $users_opt['show_option_none'] = __( '— No Change —' ); } + /** + * Filters the arguments used to generate the Quick Edit authors drop-down. + * + * @since 5.3.0 + * + * @see wp_dropdown_users() + * + * @param array $users_opt An array of arguments for wp_dropdown_users function. + * @param bool $bulk A boolean to know if it's a bulk action or not. + */ + $users_opt = apply_filters( 'quick_edit_authors_query_args', $users_opt, $bulk ); + $authors = wp_dropdown_users( $users_opt ); if ( $authors ) : $authors_dropdown = '