From 29efd5d9420f5e7f93d65935e8f4a8fe5c34dda1 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Thu, 8 Jan 2026 12:45:01 +0100 Subject: [PATCH 1/3] Comments: always exclude comments on ap_post from queries Fixes #2700 Follow-up to #2662 and #2667 Until now, we were only excluding the ap_post post type from comment queries happening within wp-admin. This is problematic because the admin bar menu item makes a wp_count_comments() call from anywhere on the site where the admin bar is displayed. That includes all frontend pages. Since we do return early in the cases where we want those comments to appear, we should be able to always exclude them in other situations. --- .../fix-comment-count-ap-post-comments-admin-bar | 4 ++++ includes/class-comment.php | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 .github/changelog/fix-comment-count-ap-post-comments-admin-bar diff --git a/.github/changelog/fix-comment-count-ap-post-comments-admin-bar b/.github/changelog/fix-comment-count-ap-post-comments-admin-bar new file mode 100644 index 000000000..c8dec9738 --- /dev/null +++ b/.github/changelog/fix-comment-count-ap-post-comments-admin-bar @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Admin bar: do not count interactions on posts from folks you follow in the comment bbubble of the admin bar. diff --git a/includes/class-comment.php b/includes/class-comment.php index 47d7df3a8..96ad4f47f 100644 --- a/includes/class-comment.php +++ b/includes/class-comment.php @@ -702,11 +702,12 @@ public static function comment_query( $query ) { return; } - // Do only exclude interactions of `ap_post` post type. - if ( \is_admin() ) { - $query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::hide_for() ); - return; - } + /* + * Exclude interactions of `ap_post` post type. + * We do not want to display them on the comment management screen + * or in the admin bar. + */ + $query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::hide_for() ); // Do not exclude likes and reposts on non-singular pages. if ( ! \is_singular() ) { From 9fb3c4f54a3fa1d087615d4ae51ec92f4269514c Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Thu, 8 Jan 2026 13:06:39 +0100 Subject: [PATCH 2/3] Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/changelog/fix-comment-count-ap-post-comments-admin-bar | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/changelog/fix-comment-count-ap-post-comments-admin-bar b/.github/changelog/fix-comment-count-ap-post-comments-admin-bar index c8dec9738..6ecf2b771 100644 --- a/.github/changelog/fix-comment-count-ap-post-comments-admin-bar +++ b/.github/changelog/fix-comment-count-ap-post-comments-admin-bar @@ -1,4 +1,4 @@ Significance: patch Type: fixed -Admin bar: do not count interactions on posts from folks you follow in the comment bbubble of the admin bar. +Admin bar: do not count interactions on posts from folks you follow in the comment bubble of the admin bar. From 5f509901c1db45ae71d20b9ba29e3a7ae5714837 Mon Sep 17 00:00:00 2001 From: Jeremy Herve Date: Thu, 8 Jan 2026 13:32:43 +0100 Subject: [PATCH 3/3] Update includes/class-comment.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- includes/class-comment.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-comment.php b/includes/class-comment.php index 96ad4f47f..38390a0a2 100644 --- a/includes/class-comment.php +++ b/includes/class-comment.php @@ -703,9 +703,9 @@ public static function comment_query( $query ) { } /* - * Exclude interactions of `ap_post` post type. - * We do not want to display them on the comment management screen - * or in the admin bar. + * Exclude interactions of `ap_post` post type from all comment queries + * (except ActivityPub and REST requests), so they are not shown in + * standard comment listings (including admin screens and frontend). */ $query->query_vars['post_type'] = array_diff( \get_post_types_by_support( 'comments' ), self::hide_for() );