Make WordPress Core


Ignore:
Timestamp:
07/10/2013 05:14:43 AM (11 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

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

    r23565 r24634  
    180180    /*
    181181     * If no menu was found:
    182      *  - Fallback (if one was specified), or bail.
     182     *  - Fall back (if one was specified), or bail.
    183183     *
    184184     * If no menu items were found:
    185      *  - Fallback, but only if no theme location was specified.
     185     *  - Fall back, but only if no theme location was specified.
    186186     *  - Otherwise, bail.
    187187     */
     
    190190            return call_user_func( $args->fallback_cb, (array) $args );
    191191
    192     if ( !$menu || is_wp_error( $menu ) || empty( $menu_items ) )
     192    if ( ! $menu || is_wp_error( $menu ) )
    193193        return false;
    194194
     
    239239    $items = apply_filters( 'wp_nav_menu_items', $items, $args );
    240240    $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
     241
     242    // Don't print any markup if there are no items at this point.
     243    if ( empty( $items ) )
     244        return false;
    241245
    242246    $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );
Note: See TracChangeset for help on using the changeset viewer.