WordPress.org

Make WordPress Core

Ticket #13378: 13378.diff

File 13378.diff, 1.7 KB (added by ryan, 8 years ago)

Beginning of register_nav_menus()

  • wp-includes/nav-menu-template.php

     
    192192function wp_nav_menu( $args = array() ) {
    193193        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
    194194        'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
    195         'depth' => 0, 'walker' => '', 'context' => 'frontend' );
     195        'depth' => 0, 'walker' => '', 'context' => 'frontend', 'slot' => '' );
    196196
    197197        $args = wp_parse_args( $args, $defaults );
    198198        $args = apply_filters( 'wp_nav_menu_args', $args );
     
    201201        // Get the nav menu
    202202        $menu = wp_get_nav_menu_object( $args->menu );
    203203
     204        if ( ! $menu && $slot ) {
     205                $slots = get_option('nav_menu_slots');
     206                if ( isset($slots) && isset($slots[$slot]) )
     207                        $menu = wp_get_nav_menu_object( $slots['slot'] );
     208        }
     209
    204210        // If we couldn't find a menu based off the menu argument
    205211        // get the first menu that has items.
    206212        if ( ! $menu ) {
  • wp-includes/nav-menu.php

     
    6262}
    6363
    6464/**
     65 * Register nav menus for a theme.
     66 *
     67 * @since 3.0.0
     68 *
     69 * @param array Associative array of menu slot identifiers and descriptions.
     70 */
     71function register_nav_menus( $menus = array() ) {
     72        global $_wp_registered_nav_menus;
     73
     74        add_theme_support( 'nav-menus' );
     75
     76        $_wp_registered_nav_menus = $menus;
     77}
     78
     79/**
    6580 * Determine whether the given ID is a nav menu item.
    6681 *
    6782 * @since 3.0.0