WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 2 months 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:

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 20 months ago.
empty-category-not-searchable-in-customizer.jpg (63.0 KB) - added by birgire 20 months ago.
category-setup.jpg (64.7 KB) - added by birgire 20 months ago.
Category setup for the screenshots
menu-items-taxonomies-settings-fixed.png (36.6 KB) - added by audrasjb 18 months ago.
Here is the settings used to reproduce the issue
menu-items-taxonomies-menuscreen-fixed.png (20.8 KB) - added by audrasjb 18 months ago.
Fixed in menu screen
menu-items-taxonomies-customizer-fixed.png (12.8 KB) - added by audrasjb 18 months ago.
Fixed in customizer screen
45298.diff (936 bytes) - added by audrasjb 18 months 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 17 months ago.
45298.3.diff (4.4 KB) - added by audrasjb 3 months ago.
Menus: Allow searching for empty taxonomy terms.

Download all attachments as: .zip

Change History (21)

@birgire
20 months ago

Category setup for the screenshots

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

Here is the settings used to reproduce the issue

@audrasjb
18 months ago

Fixed in menu screen

@audrasjb
18 months ago

Fixed in customizer screen

@audrasjb
18 months ago

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

#2 @audrasjb
18 months ago

  • Keywords has-patch 2nd-opinion added

#3 @birgire
17 months 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
17 months ago

#4 @audrasjb
17 months ago

  • Milestone changed from Awaiting Review to Future Release

#5 @audrasjb
6 months ago

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

#6 @audrasjb
5 months 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
3 months ago

Menus: Allow searching for empty taxonomy terms.

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


3 months ago

#9 @johnbillion
3 months ago

  • Owner changed from audrasjb to johnbillion

#10 @johnbillion
3 months ago

  • Status changed from accepted to assigned

#11 @johnbillion
3 months ago

  • Status changed from assigned to reviewing

#12 @johnbillion
2 months 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.