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.php

    r14614 r14620  
    6767 * @since 3.0.0
    6868 *
    69  * @param array Associative array of menu slot identifiers and descriptions.
    70  */
    71 function register_nav_menus( $menus = array() ) {
     69 * @param array $locations Associative array of menu location identifiers (like a slug) and descriptive text.
     70 */
     71function register_nav_menus( $locations = array() ) {
    7272    global $_wp_registered_nav_menus;
    7373
    7474    add_theme_support( 'nav-menus' );
    7575
    76     $_wp_registered_nav_menus = $menus;
     76    $_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations );
     77}
     78
     79/**
     80 * Register nav menu for a theme.
     81 *
     82 * @since 3.0.0
     83 *
     84 * @param string $location Menu location identifier, like a slug.
     85 * @param string $description Menu location descriptive text.
     86 */
     87function register_nav_menu( $location, $description ) {
     88    register_nav_menus( array( $location => $description ) );
    7789}
    7890
    7991function get_registered_nav_menus() {
    80     global $_wp_registered_nav_menus;
    81 
    82     return $_wp_registered_nav_menus;
    83 }
    84 
    85 function get_nav_menu_slots() {
    86     return get_theme_mod('nav_menu_slots');
     92    return $GLOBALS['_wp_registered_nav_menus'];
     93}
     94
     95function get_nav_menu_locations() {
     96    return get_theme_mod('nav_menu_locations');
    8797}
    8898
Note: See TracChangeset for help on using the changeset viewer.