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 c4d323cf892b0..29343f78a0f6d 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -99,7 +99,11 @@ public function prepare_items() { $comment_status = 'all'; } - $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; + $comment_type = ''; + + if ( ! empty( $_REQUEST['comment_type'] ) && 'note' !== $_REQUEST['comment_type'] ) { + $comment_type = $_REQUEST['comment_type']; + } $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index 230bd3d2c30e5..ed1d3a83bfb38 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -213,4 +213,35 @@ public function test_get_views_should_return_views_by_default() { ); $this->assertSame( $expected, $this->table->get_views() ); } + + /** + * Verify that the comments table never shows the note comment_type. + * + * @ticket 64198 + */ + public function test_comments_list_table_does_not_show_note_comment_type() { + $post_id = self::factory()->post->create(); + $note_id = self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_content' => 'This is a note.', + 'comment_type' => 'note', + 'comment_approved' => '1', + ) + ); + $comment_id = self::factory()->comment->create( + array( + 'comment_post_ID' => $post_id, + 'comment_content' => 'This is a regular comment.', + 'comment_type' => '', + 'comment_approved' => '1', + ) + ); + // Request the note comment type. + $_REQUEST['comment_type'] = 'note'; + $this->table->prepare_items(); + $items = $this->table->items; + $this->assertCount( 1, $items ); + $this->assertEquals( $comment_id, $items[0]->comment_ID ); + } }