in WP 3.5.1, filter wp_nav_menu_items is never called on empty menus
|Reported by:||mykle||Owned by:|
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 ))
Change History (15)
- Keywords needs-patch added; close dev-feedback removed
- Milestone changed from Awaiting Review to 3.5.3