Make WordPress Core

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's profile birgire Owned by: johnbillion's profile 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:

https://core.trac.wordpress.org/browser/tags/4.9.8/src/wp-includes/class-wp-customize-nav-menus.php#L352

Attachments (9)

quick-menu-searching-for-empty-categories.jpg (73.1 KB) - added by birgire 6 years ago.
empty-category-not-searchable-in-customizer.jpg (63.0 KB) - added by birgire 6 years ago.
category-setup.jpg (64.7 KB) - added by birgire 6 years ago.
Category setup for the screenshots
menu-items-taxonomies-settings-fixed.png (36.6 KB) - added by audrasjb 6 years ago.
Here is the settings used to reproduce the issue
menu-items-taxonomies-menuscreen-fixed.png (20.8 KB) - added by audrasjb 6 years ago.
Fixed in menu screen
menu-items-taxonomies-customizer-fixed.png (12.8 KB) - added by audrasjb 6 years ago.
Fixed in customizer screen
45298.diff (936 bytes) - added by audrasjb 6 years ago.
Add empty categories to Menu quick search tool in both Menu screen and Customizer screen.
45298-2.diff (4.3 KB) - added by birgire 6 years ago.
45298.3.diff (4.4 KB) - added by audrasjb 5 years ago.
Menus: Allow searching for empty taxonomy terms.

Download all attachments as: .zip

Change History (21)

@birgire
6 years ago

Category setup for the screenshots

#1 @audrasjb
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

@audrasjb
6 years ago

Here is the settings used to reproduce the issue

@audrasjb
6 years ago

Fixed in menu screen

@audrasjb
6 years ago

Fixed in customizer screen

@audrasjb
6 years ago

Add empty categories to Menu quick search tool in both Menu screen and Customizer screen.

#2 @audrasjb
6 years ago

  • Keywords has-patch 2nd-opinion added

#3 @birgire
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.

@birgire
6 years ago

#4 @audrasjb
6 years ago

  • Milestone changed from Awaiting Review to Future Release

#5 @audrasjb
5 years ago

  • Keywords needs-refresh added
  • Milestone changed from Future Release to 5.4
  • Status changed from reviewing to accepted

#6 @audrasjb
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.

@audrasjb
5 years ago

Menus: Allow searching for empty taxonomy terms.

#7 @audrasjb
5 years ago

  • Keywords early added; 2nd-opinion needs-refresh removed

Patch refreshed against trunk :-)

This ticket was mentioned in Slack in #core by david.baumwald. View the logs.


5 years ago

#9 @johnbillion
5 years ago

  • Owner changed from audrasjb to johnbillion

#10 @johnbillion
5 years ago

  • Status changed from accepted to assigned

#11 @johnbillion
5 years ago

  • Status changed from assigned to reviewing

#12 @johnbillion
5 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 47747:

Menus: Allow empty taxonomy terms to be surfaced when searching for items.

This brings the behaviour inline with that of browsing terms or using the All Items tab, which correctly shows empty terms.

Props birgire, audrasjb

Fixes #45298

Note: See TracTickets for help on using tickets.