Skip to content

Comments: Hide zero-count status filters on the Comments list table - #14056

Open
AbdiTolesa wants to merge 6 commits into
WordPress:trunkfrom
AbdiTolesa:fix/hide-zero-count-comment-status-filters
Open

AbdiTolesa wants to merge 6 commits into
WordPress:trunkfrom
AbdiTolesa:fix/hide-zero-count-comment-status-filters

Conversation

@AbdiTolesa

@AbdiTolesa AbdiTolesa commented Oct 6, 2026 •

Copy link
Copy Markdown

Trac ticket: https://core.trac.wordpress.org/ticket/66260

Summary

WP_Posts_List_Table::get_views() hides any status filter link (other than "All") whose post count is zero. WP_Comments_List_Table::get_views() had no equivalent, so "Pending", "Approved", "Spam", "Trash", and "Mine" were always rendered even at (0).

Per review feedback, applying the Posts list table's logic as-is doesn't fit the Comments screen, which is primarily a moderation queue rather than a plain content list:

  • Hiding "Pending (0)" removes a reassuring "inbox zero" signal and could read as moderation being broken.
  • Hiding "Approved (0)" removes the default working view.
  • Hiding whichever status is currently selected (e.g. landing on ?comment_status=moderated from a stale notification, or ?comment_status=spam right after "Empty Spam") leaves the page with no visible "current" tab at all — no indication of what's being filtered.

Changes

  • In class-wp-comments-list-table.php: "Mine", "Spam", and "Trash" are hidden when their count is zero (unless currently active). "All", "Pending", and "Approved" always stay visible regardless of count. The currently active $comment_status is never hidden, even at zero count.
  • Removed test_get_views_should_return_views_by_default (added for #42066), which asserted the old all-statuses-always-shown behavior this change intentionally revises.
  • Updated/added tests in wpCommentsListTable.php:
    • test_get_views_should_hide_empty_status_links: with zero comments, "All", "Pending", and "Approved" are present; "Mine", "Spam", "Trash" are not.
    • test_get_views_should_show_status_link_with_nonzero_count: with one approved comment, "Approved" and "Pending" are shown; "Spam"/"Trash" stay hidden.
    • test_get_views_should_not_hide_the_currently_active_status: with comment_status=spam and zero spam comments, "Spam" is still present and marked current.

Test plan

  • php -l on both changed files.
  • Ran Tests_Admin_wpCommentsListTable — 12 tests, 36 assertions, all passing.
  • Verified the active-view test fails without the $status !== $comment_status exception and passes with it.

🤖 Generated with Claude Code

WP_Posts_List_Table::get_views() hides any status filter link (other
than "All") whose post count is zero. WP_Comments_List_Table::get_views()
had no equivalent check, so "Pending", "Approved", "Spam", "Trash", and
"Mine" were always shown even with a count of (0), cluttering the
screen with filters that return no results.

Apply the same logic: skip adding a status link when its count is
empty, except for "All" which always stays visible.

This reverses the behavior asserted by test_get_views_should_return_views_by_default
(added for #42066), which is removed since it codified the opposite,
now-undesired behavior. No replacement test is added in this change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props abditsori.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

AbdiTolesa and others added 5 commits October 6, 2026 22:32
Covers WP_Comments_List_Table::get_views() hiding "Pending", "Approved",
"Spam", and "Trash" links when their count is zero, while keeping "All"
visible, and showing a status link again once its count becomes nonzero.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…ive view

Addresses review feedback on the zero-count filtering added in the
previous commit. Comments is a moderation queue, not a plain list like
Posts, so:

- "Pending" and "Approved" now always stay visible regardless of count.
  A "(0)" on Pending is reassuring confirmation of an empty queue, not
  clutter, and hiding it could read as moderation being broken.
- The currently active $comment_status is never hidden, even at zero
  count, so an admin who lands on e.g. ?comment_status=moderated (from
  a stale notification) or ?comment_status=spam (after "Empty Spam")
  always has a visible, "current" tab showing what they're filtered to.

"Mine", "Spam", and "Trash" are still hidden when empty and not the
active view.

Updated the existing get_views() tests for the new rules and added a
regression test for the active-view exception.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
… hiding

WP_Post_Comments_List_Table extends WP_Comments_List_Table and inherits
its get_views(), so it was asserting the same superseded
all-statuses-always-shown behavior (also added for #42066) that was
already updated in wpCommentsListTable.php. Missed in the earlier
commit since it lives in a separate test file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant