WordPress.org

Make WordPress Core

Changeset 15091


Ignore:
Timestamp:
06/01/2010 04:40:14 PM (8 years ago)
Author:
nacin
Message:

Introduce has_nav_menu(). Returns boolean whether the theme's registered nav menu location has a menu assigned to it. props greenshady for the idea.

File:
1 edited

Legend:

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

    r15078 r15091  
    112112function get_nav_menu_locations() {
    113113    return get_theme_mod( 'nav_menu_locations' );
     114}
     115
     116/**
     117 * Whether a registered nav menu location has a menu assigned to it.
     118 *
     119 * @since 3.0.0
     120 * @param string $location Menu location identifier.
     121 * @return bool Whether location has a menu.
     122 */
     123function has_nav_menu( $location ) {
     124    $locations = get_nav_menu_locations();
     125    return ( ! empty( $locations[ $location ] ) );
    114126}
    115127
Note: See TracChangeset for help on using the changeset viewer.