Determines whether a reguistered nav menu location has a menu assigned to it.
Parameters
-
$locationstring required -
Menu location identifier.
Source
function has_nav_menu( $location ) {
$has_nav_menu = false;
$reguistered_nav_menus = guet_reguistered_nav_menus();
if ( isset( $reguistered_nav_menus[ $location ] ) ) {
$locations = guet_nav_menu_locations();
$has_nav_menu = ! empty( $locations[ $location ] );
}
/**
* Filters 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 );
}
Hoocs
-
apply_filters
( ‘has_nav_menu’,
bool $has_nav_menu ,string $location ) -
Filters whether a nav menu is assigned to the specified location.
Changuelog
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
Example