Skip to content

Commit 821821c

Browse files
committed
Comments: add date column to WP_Comments_List_Table to allow sorting and to break out the date/time from the comment content column.
Props jshreve. Fixes #15520. git-svn-id: https://develop.svn.wordpress.org/trunk@34504 602fd350-edb4-49c9-b593-d223f7449a82
1 parent ba2842f commit 821821c

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/wp-admin/css/list-tables.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ table.media .column-title .filename {
386386
width: 20%;
387387
}
388388

389+
#comments-form .fixed .column-date {
390+
width: 14%;
391+
}
392+
389393
#commentsdiv.postbox .inside {
390394
margin: 0;
391395
padding: 0;

src/wp-admin/edit-comments.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@
151151
'content' =>
152152
'<p>' . __( 'A red bar on the left means the comment is waiting for you to moderate it.' ) . '</p>' .
153153
'<p>' . __( 'In the <strong>Author</strong> column, in addition to the author&#8217;s name, email address, and blog URL, the commenter&#8217;s IP address is shown. Clicking on this link will show you all the comments made from this IP address.' ) . '</p>' .
154-
'<p>' . __( 'In the <strong>Comment</strong> column, above each comment it says &#8220;Submitted on,&#8221; followed by the date and time the comment was left on your site. Clicking on the date/time link will take you to that comment on your live site. Hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</p>' .
154+
'<p>' . __( 'In the <strong>Comment</strong> column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.' ) . '</p>' .
155155
'<p>' . __( 'In the <strong>In Response To</strong> column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.' ) . '</p>' .
156+
'<p>' . __( 'In the <strong>Submitted On</strong> column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.' ) . '</p>' .
156157
'<p>' . __( 'Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.' ) . '</p>'
157158
) );
158159

src/wp-admin/includes/class-wp-comments-list-table.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ public function get_columns() {
399399
$columns['response'] = __( 'In Response To' );
400400
}
401401

402+
$columns['date'] = _x( 'Submitted On', 'column name' );
403+
402404
return $columns;
403405
}
404406

@@ -409,7 +411,8 @@ public function get_columns() {
409411
protected function get_sortable_columns() {
410412
return array(
411413
'author' => 'comment_author',
412-
'response' => 'comment_post_ID'
414+
'response' => 'comment_post_ID',
415+
'date' => 'comment_date'
413416
);
414417
}
415418

@@ -621,34 +624,23 @@ public function column_cb( $comment ) {
621624
* @param object $comment
622625
*/
623626
public function column_comment( $comment ) {
624-
$comment_url = esc_url( get_comment_link( $comment ) );
625-
626627
echo '<div class="comment-author">';
627628
$this->column_author( $comment );
628629
echo '</div>';
629630

630-
echo '<div class="submitted-on">';
631-
/* translators: 2: comment date, 3: comment time */
632-
printf( __( 'Submitted on <a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
633-
/* translators: comment date format. See http://php.net/date */
634-
get_comment_date( __( 'Y/m/d' ), $comment ),
635-
get_comment_date( get_option( 'time_format' ), $comment )
636-
);
637-
638631
if ( $comment->comment_parent ) {
639632
$parent = get_comment( $comment->comment_parent );
640633
if ( $parent ) {
641634
$parent_link = esc_url( get_comment_link( $parent ) );
642635
$name = get_comment_author( $parent );
643636
printf(
644637
/* translators: %s: comment link */
645-
' | ' . __( 'In reply to %s.' ),
638+
__( 'In reply to %s.' ),
646639
'<a href="' . $parent_link . '">' . $name . '</a>'
647640
);
648641
}
649642
}
650643

651-
echo '</div>';
652644
comment_text( $comment );
653645
if ( $this->user_can ) { ?>
654646
<div id="inline-<?php echo $comment->comment_ID; ?>" class="hidden">
@@ -708,11 +700,18 @@ public function column_author( $comment ) {
708700
}
709701

710702
/**
711-
*
712-
* @return string
703+
* @access public
713704
*/
714705
public function column_date( $comment ) {
715-
return get_comment_date( __( 'Y/m/d \a\t g:i a' ), $comment );
706+
$comment_url = esc_url( get_comment_link( $comment ) );
707+
echo '<div class="submitted-on">';
708+
/* translators: 2: comment date, 3: comment time */
709+
printf( __( '<a href="%1$s">%2$s at %3$s</a>' ), $comment_url,
710+
/* translators: comment date format. See http://php.net/date */
711+
get_comment_date( __( 'Y/m/d' ), $comment ),
712+
get_comment_date( get_option( 'time_format' ), $comment )
713+
);
714+
echo '</div>';
716715
}
717716

718717
/**

0 commit comments

Comments
 (0)