Make WordPress Core

Changeset 47879


Ignore:
Timestamp:
06/01/2020 07:13:54 PM (4 years ago)
Author:
whyisjake
Message:

Administration: Unify the date structure in list view and excerpt view.

Both views now show a full date string. Something like Published 2020/05/27 at 10:25 pm.

Fixes: #35391.
Props: afercia, ocean90, TimothyBlynJacobs, audrasjb, SergeyBiryukov, joedolson.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/list-tables.css

    r47835 r47879  
    296296
    297297.fixed .column-posts,
    298 .fixed .column-date,
    299298.fixed .column-parent,
    300299.fixed .column-links,
     
    302301.fixed .column-format {
    303302    width: 10%;
     303}
     304
     305.fixed .column-date {
     306    width: 14%;
    304307}
    305308
     
    389392#comments-form .fixed .column-author {
    390393    width: 20%;
    391 }
    392 
    393 #comments-form .fixed .column-date {
    394     width: 14%;
    395394}
    396395
     
    16351634        margin-top: 0;
    16361635    }
    1637 
    1638     .fixed .column-date {
    1639         width: 14%;
    1640     }
    16411636}
    16421637
  • trunk/src/wp-admin/includes/class-wp-posts-list-table.php

    r47808 r47879  
    10661066        if ( '0000-00-00 00:00:00' === $post->post_date ) {
    10671067            $t_time    = __( 'Unpublished' );
    1068             $h_time    = $t_time;
    10691068            $time_diff = 0;
    10701069        } else {
    1071             $t_time    = get_the_time( __( 'Y/m/d g:i:s a' ), $post );
     1070            $t_time = sprintf(
     1071                /* translators: 1: Post date, 2: Post time. */
     1072                __( '%1$s at %2$s' ),
     1073                /* translators: Post date format. See https://www.php.net/date */
     1074                get_the_time( __( 'Y/m/d' ), $post ),
     1075                /* translators: Post time format. See https://www.php.net/date */
     1076                get_the_time( __( 'g:i a' ), $post )
     1077            );
     1078
    10721079            $time      = get_post_timestamp( $post );
    10731080            $time_diff = time() - $time;
    1074 
    1075             if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
    1076                 /* translators: %s: Human-readable time difference. */
    1077                 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
    1078             } else {
    1079                 $h_time = get_the_time( __( 'Y/m/d' ), $post );
    1080             }
    10811081        }
    10821082
     
    11091109        }
    11101110
    1111         if ( 'excerpt' === $mode ) {
    1112             /**
    1113              * Filters the published time of the post.
    1114              *
    1115              * If `$mode` equals 'excerpt', the published time and date are both displayed.
    1116              * If `$mode` equals 'list' (default), the publish date is displayed, with the
    1117              * time and date together available as an abbreviation definition.
    1118              *
    1119              * @since 2.5.1
    1120              *
    1121              * @param string  $t_time      The published time.
    1122              * @param WP_Post $post        Post object.
    1123              * @param string  $column_name The column name.
    1124              * @param string  $mode        The list display mode ('excerpt' or 'list').
    1125              */
    1126             echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
    1127         } else {
    1128 
    1129             /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
    1130             echo '<span title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</span>';
    1131         }
     1111        /**
     1112         * Filters the published time of the post.
     1113         *
     1114         * @since 2.5.1
     1115         * @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes.
     1116         *              The published time and date are both displayed now,
     1117         *              which is equivalent to the previous 'excerpt' mode.
     1118         *
     1119         * @param string  $t_time      The published time.
     1120         * @param WP_Post $post        Post object.
     1121         * @param string  $column_name The column name.
     1122         * @param string  $mode        The list display mode ('excerpt' or 'list').
     1123         */
     1124        echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
    11321125    }
    11331126
Note: See TracChangeset for help on using the changeset viewer.