Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#21576 closed enhancement (fixed)

wp_nav_menu: Don't return markup, when no menu item is set

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

Description

Having assigned an empty menu to a location can be assumed to be the user's way of "disabling" the menu.

When there are no items, there shouldn't be a menu, hence there shouldn't be any extra menu markup.
Rendering markup nonetheless could lead to issues when menu wrappers are styled (as they are in Twenty Twelve) and left empty.

Currently out put is:

<div class="menu-menu-container"><ul id="menu-menu" class="menu"></ul></div>

Related: #21562

Attachments (1)

21576.patch (686 bytes) - added by obenland 11 years ago.

Download all attachments as: .zip

Change History (7)

@obenland
11 years ago

#1 @SergeyBiryukov
11 years ago

  • Milestone changed from Awaiting Review to 3.5

#2 @nacin
11 years ago

I can get behind this.

#4 @nacin
11 years ago

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

In [21868]:

If a nav menu has no menu items, print nothing (instead of empty container markup). props obenland. fixes #21576.

#6 @nacin
10 years ago

In 24634:

If a nav menu has no items, wait until after the wp_nav_menu_items filter before deciding whether to print nothing.

see [21868] for original commit. see #21576.
see #24035 for trunk.

Note: See TracTickets for help on using tickets.