diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php index 681cdd0885d7..d62020039d3b 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -95,6 +95,7 @@ public function prepare_items() { } $comment_status = isset( $_REQUEST['comment_status'] ) ? $_REQUEST['comment_status'] : 'all'; + if ( ! in_array( $comment_status, array( 'all', 'mine', 'moderated', 'approved', 'spam', 'trash' ), true ) ) { $comment_status = 'all'; } @@ -162,6 +163,7 @@ public function prepare_items() { $args = apply_filters( 'comments_list_table_query_args', $args ); $_comments = get_comments( $args ); + if ( is_array( $_comments ) ) { update_comment_cache( $_comments ); @@ -198,6 +200,7 @@ public function prepare_items() { */ public function get_per_page( $comment_status = 'all' ) { $comments_per_page = $this->get_items_per_page( 'edit_comments_per_page' ); + /** * Filters the number of comments listed per page in the comments list table. * @@ -284,6 +287,7 @@ protected function get_views() { } $link = admin_url( 'edit-comments.php' ); + if ( ! empty( $comment_type ) && 'all' !== $comment_type ) { $link = add_query_arg( 'comment_type', $comment_type, $link ); } @@ -312,15 +316,19 @@ protected function get_views() { if ( ! isset( $num_comments->$status ) ) { $num_comments->$status = 10; } + $link = add_query_arg( 'comment_status', $status, $link ); + if ( $post_id ) { $link = add_query_arg( 'p', absint( $post_id ), $link ); } + /* // I toyed with this, but decided against it. Leaving it in here in case anyone thinks it is a good idea. ~ Mark if ( !empty( $_REQUEST['s'] ) ) $link = add_query_arg( 's', esc_attr( wp_unslash( $_REQUEST['s'] ) ), $link ); */ + $status_links[ $status ] = "" . sprintf( translate_nooped_plural( $label, $num_comments->$status ), sprintf( @@ -352,12 +360,15 @@ protected function get_bulk_actions() { global $comment_status; $actions = array(); + if ( in_array( $comment_status, array( 'all', 'approved' ), true ) ) { $actions['unapprove'] = __( 'Unapprove' ); } + if ( in_array( $comment_status, array( 'all', 'moderated' ), true ) ) { $actions['approve'] = __( 'Approve' ); } + if ( in_array( $comment_status, array( 'all', 'moderated', 'approved', 'trash' ), true ) ) { $actions['spam'] = _x( 'Mark as spam', 'comment' ); } @@ -414,7 +425,7 @@ protected function extra_tablenav( $which ) { } if ( ( 'spam' === $comment_status || 'trash' === $comment_status ) && $has_items - && current_user_can( 'moderate_comments' ) + && current_user_can( 'moderate_comments' ) ) { wp_nonce_field( 'bulk-destroy', '_destroy_nonce' ); $title = ( 'spam' === $comment_status ) ? esc_attr__( 'Empty Spam' ) : esc_attr__( 'Empty Trash' ); @@ -519,7 +530,8 @@ protected function comment_type_dropdown( $comment_type ) { ); } } - echo ''; + + echo ''; } } @@ -558,6 +570,7 @@ public function display() { if ( ! isset( $has_items ) ) { $has_items = $this->has_items(); + if ( $has_items ) { $this->display_tablenav( 'top' ); } @@ -614,14 +627,17 @@ public function single_row( $item ) { $comment = $item; $the_comment_class = wp_get_comment_status( $comment ); + if ( ! $the_comment_class ) { $the_comment_class = ''; } + $the_comment_class = implode( ' ', get_comment_class( $the_comment_class, $comment, $comment->comment_post_ID ) ); if ( $comment->comment_post_ID > 0 ) { $post = get_post( $comment->comment_post_ID ); } + $this->user_can = current_user_can( 'edit_comment', $comment->comment_ID ); echo ""; @@ -873,6 +889,7 @@ public function column_comment( $comment ) { if ( $comment->comment_parent ) { $parent = get_comment( $comment->comment_parent ); + if ( $parent ) { $parent_link = esc_url( get_comment_link( $parent ) ); $name = get_comment_author( $parent ); @@ -912,6 +929,7 @@ public function column_author( $comment ) { $author_url = get_comment_author_url( $comment ); $author_url_display = untrailingslashit( preg_replace( '|^http(s)?://(www\.)?|i', '', $author_url ) ); + if ( strlen( $author_url_display ) > 50 ) { $author_url_display = wp_html_excerpt( $author_url_display, 49, '…' ); } @@ -919,6 +937,7 @@ public function column_author( $comment ) { echo ''; comment_author( $comment ); echo '
'; + if ( ! empty( $author_url_display ) ) { printf( '
%s
', esc_url( $author_url ), esc_html( $author_url_display ) ); } @@ -934,6 +953,7 @@ public function column_author( $comment ) { } $author_ip = get_comment_author_IP( $comment ); + if ( $author_ip ) { $author_ip_url = add_query_arg( array( @@ -942,9 +962,11 @@ public function column_author( $comment ) { ), admin_url( 'edit-comments.php' ) ); + if ( 'spam' === $comment_status ) { $author_ip_url = add_query_arg( 'comment_status', 'spam', $author_ip_url ); } + printf( '%2$s', esc_url( $author_ip_url ), esc_html( $author_ip ) ); } } @@ -964,6 +986,7 @@ public function column_date( $comment ) { ); echo '
'; + if ( 'approved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_post_ID ) ) { printf( '%s', @@ -973,6 +996,7 @@ public function column_date( $comment ) { } else { echo $submitted; } + echo '
'; } @@ -1002,18 +1026,23 @@ public function column_response( $comment ) { } echo ''; }