From 33c1c7600147f09d32ac150ee706b7978bce5cd8 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Sat, 13 Jun 2015 14:15:25 +0000 Subject: [PATCH] Nav menu: Introduce a `has_nav_menu` filter in `has_nav_menu()` to filter whether a nav menu is assigned to a specified location. props westonruter. fixes #32630. Built from https://develop.svn.wordpress.org/trunk@32746 git-svn-id: http://core.svn.wordpress.org/trunk@32717 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu.php | 18 ++++++++++++++---- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index 88922ccdd1..26d2e8ca38 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -146,13 +146,23 @@ function get_nav_menu_locations() { * @return bool Whether location has a menu. */ function has_nav_menu( $location ) { + $has_nav_menu = false; + $registered_nav_menus = get_registered_nav_menus(); - if ( ! isset( $registered_nav_menus[ $location ] ) ) { - return false; + if ( isset( $registered_nav_menus[ $location ] ) ) { + $locations = get_nav_menu_locations(); + $has_nav_menu = ! empty( $locations[ $location ] ); } - $locations = get_nav_menu_locations(); - return ( ! empty( $locations[ $location ] ) ); + /** + * Filter whether a nav menu is assigned to the specified location. + * + * @since 4.3.0 + * + * @param bool $has_nav_menu Whether there is a menu assigned to a location. + * @param string $location Menu location. + */ + return apply_filters( 'has_nav_menu', $has_nav_menu, $location ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 1b3ff035f9..c9739ad1a3 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.3-alpha-32745'; +$wp_version = '4.3-alpha-32746'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.