Repository navigation
Comments: Hide zero-count status filters on the Comments list table - #14056
AbdiTolesa wants to merge 6 commits into
Conversation
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>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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>
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:
?comment_status=moderatedfrom a stale notification, or?comment_status=spamright after "Empty Spam") leaves the page with no visible "current" tab at all — no indication of what's being filtered.Changes
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_statusis never hidden, even at zero count.test_get_views_should_return_views_by_default(added for #42066), which asserted the old all-statuses-always-shown behavior this change intentionally revises.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: withcomment_status=spamand zero spam comments, "Spam" is still present and markedcurrent.Test plan
php -lon both changed files.Tests_Admin_wpCommentsListTable— 12 tests, 36 assertions, all passing.$status !== $comment_statusexception and passes with it.🤖 Generated with Claude Code