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
This commit is contained in:
Sergey Biryukov 2019-10-25 12:51:03 +00:00
parent 8410526528
commit 0b83bffd45
3 changed files with 24 additions and 19 deletions

View File

@ -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 );
}
}

View File

@ -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'] = __( '&mdash; No Change &mdash;' );
}
/**
* 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 = '<label class="inline-edit-author">';

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.3-RC2-46577';
$wp_version = '5.3-RC2-46578';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.