From 2e3574cb5969e4621c5aa522c13db439b39a40af Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Tue, 4 Nov 2025 09:04:16 -0700 Subject: [PATCH 1/6] Never show notes on the comments page --- src/wp-admin/edit-comments.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index 8a004b52265ef..614b2cd8fe5f9 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -16,6 +16,11 @@ ); } +// Never show notes on the comments page. +if ( 'note' === $_REQUEST['comment_type'] ) { + unset( $_REQUEST['comment_type'] ); +} + $wp_list_table = _get_list_table( 'WP_Comments_List_Table' ); $pagenum = $wp_list_table->get_pagenum(); From eb019e40a7f487e109f8f558f58655935312d9ff Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Tue, 4 Nov 2025 09:29:00 -0700 Subject: [PATCH 2/6] Move note exclusion logic to comments list table class --- src/wp-admin/edit-comments.php | 5 ----- src/wp-admin/includes/class-wp-comments-list-table.php | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/wp-admin/edit-comments.php b/src/wp-admin/edit-comments.php index 614b2cd8fe5f9..8a004b52265ef 100644 --- a/src/wp-admin/edit-comments.php +++ b/src/wp-admin/edit-comments.php @@ -16,11 +16,6 @@ ); } -// Never show notes on the comments page. -if ( 'note' === $_REQUEST['comment_type'] ) { - unset( $_REQUEST['comment_type'] ); -} - $wp_list_table = _get_list_table( 'WP_Comments_List_Table' ); $pagenum = $wp_list_table->get_pagenum(); 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..ad796dd3c8bd8 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -100,6 +100,7 @@ public function prepare_items() { } $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; + $comment_type = 'note' === $comment_type ? '' : $comment_type; $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; From d2b23a72f1f0fad6e7143659209d64c9160b2759 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Tue, 4 Nov 2025 11:26:11 -0700 Subject: [PATCH 3/6] Update class-wp-comments-list-table.php Co-authored-by: Jonathan Desrosiers <359867+desrosj@users.noreply.github.com> --- src/wp-admin/includes/class-wp-comments-list-table.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 ad796dd3c8bd8..81d50a16aaa8a 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -99,8 +99,11 @@ public function prepare_items() { $comment_status = 'all'; } - $comment_type = ! empty( $_REQUEST['comment_type'] ) ? $_REQUEST['comment_type'] : ''; - $comment_type = 'note' === $comment_type ? '' : $comment_type; + $comment_type = ''; + + if ( ! empty( $_REQUEST['comment_type'] ) && 'note' !== $_REQUEST['comment_type'] ) { + $comment_type = $_REQUEST['comment_type']; + } $search = ( isset( $_REQUEST['s'] ) ) ? $_REQUEST['s'] : ''; From 868ef262a56a8b7b0ebc6cc2b533446b2bd52199 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 10:45:11 -0700 Subject: [PATCH 4/6] whitespace --- src/wp-admin/includes/class-wp-comments-list-table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 81d50a16aaa8a..29343f78a0f6d 100644 --- a/src/wp-admin/includes/class-wp-comments-list-table.php +++ b/src/wp-admin/includes/class-wp-comments-list-table.php @@ -100,7 +100,7 @@ public function prepare_items() { } $comment_type = ''; - + if ( ! empty( $_REQUEST['comment_type'] ) && 'note' !== $_REQUEST['comment_type'] ) { $comment_type = $_REQUEST['comment_type']; } From 631bd560759a0120c1987aea479229a8cfa60063 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 11:00:01 -0700 Subject: [PATCH 5/6] Add a test to verify that the comments table never shows the note comment_type. --- .../tests/admin/wpCommentsListTable.php | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index 230bd3d2c30e5..0f0e1e600487b 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 ); + } +} \ No newline at end of file From 66e21b31124422c13c8140b546a35b852a330fce Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 11:02:01 -0700 Subject: [PATCH 6/6] phpcbf --- .../tests/admin/wpCommentsListTable.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/phpunit/tests/admin/wpCommentsListTable.php b/tests/phpunit/tests/admin/wpCommentsListTable.php index 0f0e1e600487b..ed1d3a83bfb38 100644 --- a/tests/phpunit/tests/admin/wpCommentsListTable.php +++ b/tests/phpunit/tests/admin/wpCommentsListTable.php @@ -220,21 +220,21 @@ public function test_get_views_should_return_views_by_default() { * @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( + $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_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', + 'comment_post_ID' => $post_id, + 'comment_content' => 'This is a regular comment.', + 'comment_type' => '', + 'comment_approved' => '1', ) ); // Request the note comment type. @@ -244,4 +244,4 @@ public function test_comments_list_table_does_not_show_note_comment_type() { $this->assertCount( 1, $items ); $this->assertEquals( $comment_id, $items[0]->comment_ID ); } -} \ No newline at end of file +}