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
This commit is contained in:
Dominik Schilling 2015-06-13 14:15:25 +00:00
parent fe31ed1e5f
commit 33c1c76001
2 changed files with 15 additions and 5 deletions

View File

@ -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 );
}
/**

View File

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