WordPress.org

Make WordPress Core

Changeset 21868


Ignore:
Timestamp:
09/16/2012 05:07:56 PM (8 years ago)
Author:
nacin
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu-template.php

    r21664 r21868  
    167167        $menu_items = wp_get_nav_menu_items( $menu->term_id );
    168168
    169     // If no menu was found or if the menu has no items and no location was requested, call the fallback_cb if it exists
     169    /*
     170     * If no menu was found:
     171     *  - Fallback (if one was specified), or bail.
     172     *
     173     * If no menu items were found:
     174     *  - Fallback, but only if no theme location was specified.
     175     *  - Otherwise, bail.
     176     */
    170177    if ( ( !$menu || is_wp_error($menu) || ( isset($menu_items) && empty($menu_items) && !$args->theme_location ) )
    171178        && $args->fallback_cb && is_callable( $args->fallback_cb ) )
    172179            return call_user_func( $args->fallback_cb, (array) $args );
    173180
    174     // If no fallback function was specified and the menu doesn't exists, bail.
    175     if ( !$menu || is_wp_error($menu) )
     181    if ( !$menu || is_wp_error( $menu ) || empty( $menu_items ) )
    176182        return false;
    177183
Note: See TracChangeset for help on using the changeset viewer.