diff --git a/src/wp-admin/comment.php b/src/wp-admin/comment.php index f5d4b3320f..ef2d1d628e 100644 --- a/src/wp-admin/comment.php +++ b/src/wp-admin/comment.php @@ -36,6 +36,16 @@ if ( isset( $_GET['dt'] ) ) { } } +// Prevent actions on a comment associated with a trashed post. +$comment_id = absint( $_GET['c'] ); +$comment = get_comment( $comment_id ); + +if ( 'trash' === get_post_status( $comment->comment_post_ID ) ) { + wp_die( + __( 'You can’t edit this comment because the associated post is in the Trash. Please restore the post first, then try again.' ) + ); +} + switch ( $action ) { case 'editcomment': @@ -60,9 +70,6 @@ switch ( $action ) { wp_enqueue_script( 'comment' ); require_once ABSPATH . 'wp-admin/admin-header.php'; - $comment_id = absint( $_GET['c'] ); - - $comment = get_comment( $comment_id ); if ( ! $comment ) { comment_footer_die( __( 'Invalid comment ID.' ) . sprintf( ' ' . __( 'Go back' ) . '.', 'javascript:history.go(-1)' ) ); } @@ -87,9 +94,6 @@ switch ( $action ) { case 'spam': $title = __( 'Moderate Comment' ); - $comment_id = absint( $_GET['c'] ); - - $comment = get_comment( $comment_id ); if ( ! $comment ) { wp_redirect( admin_url( 'edit-comments.php?error=1' ) ); die(); diff --git a/src/wp-admin/css/list-tables.css b/src/wp-admin/css/list-tables.css index 277bef152e..bb64d40489 100644 --- a/src/wp-admin/css/list-tables.css +++ b/src/wp-admin/css/list-tables.css @@ -75,17 +75,17 @@ border-right: 5px solid transparent; } -.column-response .post-com-count-approved:hover .comment-count-approved, -.column-response .post-com-count-approved:focus .comment-count-approved, -.column-comments .post-com-count-approved:hover .comment-count-approved, -.column-comments .post-com-count-approved:focus .comment-count-approved { +.column-response a.post-com-count-approved:hover .comment-count-approved, +.column-response a.post-com-count-approved:focus .comment-count-approved, +.column-comments a.post-com-count-approved:hover .comment-count-approved, +.column-comments a.post-com-count-approved:focus .comment-count-approved { background: #0073aa; } -.column-response .post-com-count-approved:hover:after, -.column-response .post-com-count-approved:focus:after, -.column-comments .post-com-count-approved:hover:after, -.column-comments .post-com-count-approved:focus:after { +.column-response a.post-com-count-approved:hover:after, +.column-response a.post-com-count-approved:focus:after, +.column-comments a.post-com-count-approved:hover:after, +.column-comments a.post-com-count-approved:focus:after { border-top-color: #0073aa; } diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php index 11cde8edcb..7f9ab03c5b 100644 --- a/src/wp-admin/includes/class-wp-list-table.php +++ b/src/wp-admin/includes/class-wp-list-table.php @@ -682,14 +682,21 @@ class WP_List_Table { $pending_comments_number ); - // No comments at all. if ( ! $approved_comments && ! $pending_comments ) { + // No comments at all. printf( '%s', __( 'No comments' ) ); - // Approved comments have different display depending on some conditions. + } elseif ( $approved_comments && 'trash' === get_post_status( $post_id ) ) { + // Don't link the comment bubble for a trashed post. + printf( + '%s', + $approved_comments_number, + $pending_comments ? $approved_phrase : $approved_only_phrase + ); } elseif ( $approved_comments ) { + // Link the comment bubble to approved comments. printf( '%s', esc_url( @@ -705,6 +712,7 @@ class WP_List_Table { $pending_comments ? $approved_phrase : $approved_only_phrase ); } else { + // Don't link the comment bubble when there are no approved comments. printf( '%s', $approved_comments_number,