Make WordPress Core


Ignore:
Timestamp:
05/14/2010 06:20:30 AM (14 years ago)
Author:
nacin
Message:

First pass on 'Theme Locations' for navigation menus. Themes need to specify a location when calling wp_nav_menu and register locations in functions.php. Users then map menus to locations in the nav menu admin. Subject to review. see #13378.

File:
1 edited

Legend:

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

    r14611 r14620  
    194194    $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
    195195    'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
    196     'depth' => 0, 'walker' => '', 'context' => 'frontend', 'theme_menu' => '' );
     196    'depth' => 0, 'walker' => '', 'context' => 'frontend', 'theme_location' => '' );
    197197
    198198    $args = wp_parse_args( $args, $defaults );
     
    200200    $args = (object) $args;
    201201
    202     // Get the nav menu
     202    // Get the nav menu based on the requested menu
    203203    $menu = wp_get_nav_menu_object( $args->menu );
    204204
    205     if ( ! $menu && $slot ) {
    206         $slots = get_nav_menu_slots();
    207         if ( isset($slots) && isset($slots['theme_menu']) )
    208             $menu = wp_get_nav_menu_object( $slots['theme_menu'] );
    209     }
    210 
    211     // If we couldn't find a menu based off the menu argument
    212     // get the first menu that has items.
     205    // Get the nav menu based on the theme_location
     206    if ( ! $menu && $args->theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $args->theme_location ] ) )
     207        $menu = wp_get_nav_menu_object( $locations[ $args->theme_location ] );
     208
     209    // get the first menu that has items if we still can't find a menu
    213210    if ( ! $menu ) {
    214211        $menus = wp_get_nav_menus();
Note: See TracChangeset for help on using the changeset viewer.