Opened 9 hours ago
Last modified 9 hours ago
#66260 new enhancement
Comments: Hide zero-count status filters on the Comments list table
| Reported by: | abditsori | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Comments | Version: | |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
The Posts list table (WP_Posts_List_Table::get_views()) hides any status
filter link — other than "All" — whose post count is zero:
if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) {
continue;
}
WP_Comments_List_Table::get_views() has no equivalent check. As a result,
"Pending", "Approved", "Spam", "Trash", and "Mine" are always rendered as
filter links above the Comments list table, even when their count is (0).
On a typical site with few or no pending/spam/trashed comments, this clutters
the screen with filter links that lead to an empty list, rather than only
showing filters that are actually useful.
Steps to reproduce:
- Go to a site where every comment is approved (no pending, spam, or trashed comments).
- Go to Comments in wp-admin.
- Observe the filter row above the list: "All | Mine | Pending (0) | Approved (12) | Spam (0) | Trash (0)".
Expected behavior: filters with a zero count, other than "All", should not
be shown — consistent with how the Posts list table already behaves for
post statuses.
Change History (1)
This ticket was mentioned in PR #14056 on WordPress/wordpress-develop by @abditsori.
9 hours ago
#1
- Keywords has-patch has-unit-tests added
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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 check, so "Pending", "Approved", "Spam", "Trash", and "Mine" were always rendered as filter links even when their count is(0), cluttering the screen with filters that return no results.Changes
class-wp-comments-list-table.php, skip adding a comment status link (other thanall) when its count is empty, mirroring the Posts list table's logic.test_get_views_should_return_views_by_defaultfromwpCommentsListTable.php, since it explicitly asserted the old behavior (all statuses shown at(0)), which this change intentionally reverses. No replacement test is included in this PR.Test plan
php -lon both changed files.Tests_Admin_wpCommentsListTable— 9 tests, 24 assertions, all passing.🤖 Generated with Claude Code