From 5b3b2aaee16a81e7a742139eace7d8bf52abfc9f Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Tue, 1 Jun 2010 16:40:14 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@15091 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/nav-menu.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index aecb7f24f7..ae79cfd1af 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -113,6 +113,18 @@ function get_nav_menu_locations() { return get_theme_mod( 'nav_menu_locations' ); } +/** + * Whether a registered nav menu location has a menu assigned to it. + * + * @since 3.0.0 + * @param string $location Menu location identifier. + * @return bool Whether location has a menu. + */ +function has_nav_menu( $location ) { + $locations = get_nav_menu_locations(); + return ( ! empty( $locations[ $location ] ) ); +} + /** * Determine whether the given ID is a nav menu item. *