Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#26900 closed defect (bug) (fixed)

unregister_nav_menu() should remove_theme_support()

Reported by: kovshenin's profile kovshenin Owned by: nacin's profile nacin
Milestone: 3.9 Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch
Focuses: Cc:

Description

I thought about this when reading through #26276. When a child theme (or a plugin) unregisters all menu items, current_theme_supports still returns true for menus, which can cause certain weirdness with the UI:

  • If widgets are not supported, the Menus menu is still visible
  • The "your theme has no menus but you can use a widget" text is not displayed on the Menus screen
  • The "Theme locations" label is visible on the Menus screen but the list is empty

Since register_nav_menu() adds theme support, I think unregister_nav_menu() should remove it.

Attachments (1)

26900.diff (1.7 KB) - added by kovshenin 11 years ago.

Download all attachments as: .zip

Change History (8)

@kovshenin
11 years ago

#1 @kovshenin
11 years ago

  • Keywords has-patch added

26900.diff removes theme support during unregister_nav_menu() + unit tests.

#2 follow-up: @mordauk
11 years ago

Shouldn't users still be able to create custom menus and add them via widgets even if the theme does not explicitly support menus?

#3 in reply to: ↑ 2 ; follow-up: @kovshenin
11 years ago

Replying to mordauk: Sure. If widgets are supported by the theme, the menus UI will be shown regardless of navigation menu support.

#4 in reply to: ↑ 3 @mordauk
11 years ago

Replying to kovshenin:

Replying to mordauk: Sure. If widgets are supported by the theme, the menus UI will be shown regardless of navigation menu support.

Ah, didn't realize that. I just assumed the menus UI got disabled when the theme didn't support it.

#5 @nacin
11 years ago

  • Milestone changed from Awaiting Review to 3.9

#6 @nacin
11 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 27220:

Remove theme support for 'menus' in unregister_nav_menu() when there are no more menus.

props kovshenin.
fixes #26900.

#7 @nacin
10 years ago

In 29894:

Fix theme support unit test added in [27220].

The test assumed that the active theme either had no menu locations, or a subset of 'primary' and 'secondary'. see #26900.

Note: See TracTickets for help on using tickets.