[wp-trac] [WordPress Trac] #24035: in WP 3.5.1, filter wp_nav_menu_items is never called on empty menus
WordPress Trac
noreply at wordpress.org
Wed Apr 10 18:03:24 UTC 2013
#24035: in WP 3.5.1, filter wp_nav_menu_items is never called on empty menus
-----------------------------+--------------------------
Reporter: mykle | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Menus
Version: | Severity: major
Keywords: |
-----------------------------+--------------------------
We upgraded from 3.4 to 3.5.1 and our main navigation menu vanished.
Our theme uses the "wp_nav_menu_items" filter to add menu items to an
empty menu, depending on login context & other things.
I have verified that in 3.5.1, this filter is never called on empty menus.
wp_nav_menu() called with the proper args to select our menu just returns
null. we are specifying theme_location in the call.
A workaround/hack is to add a bogus menu item to the DB, via the admin
interface, and then delete that bogus menu item in our filter.
I imagine this crept in with the new 3.5 behavior of not emitting HTML for
an empty menu.
The bug is in wp-includes/nav-menu-template.php . The comment at line 174
claims we will fallback on empty menus only if no theme_location is
specified, and we do test that on line 177, but on line 181 we test again
and fallback on empty menus without checking theme_location.
This line (181) :
{{{ if ( !$menu || is_wp_error( $menu ) || empty( $menu_items ) ) }}}
... should be this line:
{{{ if ( !$menu || is_wp_error( $menu )) }}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/24035>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list