Opened 6 years ago
Closed 5 years ago
#45298 closed defect (bug) (fixed)
Menu Quick Search: Allow searching for empty taxonomy terms
Reported by: | birgire | Owned by: | johnbillion |
---|---|---|---|
Milestone: | 5.5 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Menus | Keywords: | has-screenshots has-patch has-unit-tests early |
Focuses: | administration | Cc: |
Description
In the Menu admin page /wp-admin/nav-menus.php
we can view empty taxonomy terms, but we can't search for empty ones.
This was reported here: https://wordpress.stackexchange.com/questions/302406/how-to-show-empity-category-in-admin-menus-search
I had a look and found the same behavior in the Customizer.
This seems like a bug.
Screenshots:
See screenshots below for categories (same applies for other taxonomies).
Fixes:
The default of get_terms()
is to hide empty taxonomy terms.
To fix this here, we need to add:
'hide_empty' => false,
to the input of get_terms()
in _wp_ajax_menu_quick_search()
:
https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-admin/includes/nav-menu.php#L109
and to the input of get_terms()
in WP_Customize_Nav_Menus::search_available_items_query
:
Attachments (9)
Change History (21)
#1
@
6 years ago
- Owner set to audrasjb
- Status changed from new to reviewing
Hi, thanks for the ticket,
I agree, we should list empty categories. Here is a first patch (simply adds empty terms to the search tools).
But, I'm wondering about adding post count as well…
Cheers,
Jb
@
6 years ago
Add empty categories to Menu quick search tool in both Menu screen and Customizer screen.
#3
@
6 years ago
- Keywords has-unit-tests added
Thank you for the patch @audrasjb
45298-2.diff adds unit tests for both cases (i.e. for the Admin Menu page and the Customizer).
It also adjusts the test in WP_Customize_Nav_Menus::search_available_items_query
that assumed that the Uncategorized category would not show up in the quick search results.
#5
@
5 years ago
- Keywords needs-refresh added
- Milestone changed from Future Release to 5.4
- Status changed from reviewing to accepted
#6
@
5 years ago
- Milestone changed from 5.4 to 5.5
Hi,
With 5.4 Beta 3 approaching and the Beta period reserved for bugs introduced during the cycle, this is being moved to 5.5.
#7
@
5 years ago
- Keywords early added; 2nd-opinion needs-refresh removed
Patch refreshed against trunk :-)
Category setup for the screenshots