WP_REST_Menus_Controller::get_menu_locations
Returns the names of the locations assigned to the menu.
Method of the class: WP_REST_Menus_Controller{}
No Hooks.
Returns
String[]. The locations assigned to the menu.
Usage
// protected - for code of main (parent) or child class $result = $this->get_menu_locations( $menu_id );
- $menu_id(int) (required)
- The menu id.
Changelog
| Since 5.9.0 | Introduced. |
WP_REST_Menus_Controller::get_menu_locations() WP REST Menus Controller::get menu locations code WP 7.0
protected function get_menu_locations( $menu_id ) {
$locations = get_nav_menu_locations();
$menu_locations = array();
foreach ( $locations as $location => $assigned_menu_id ) {
if ( $menu_id === $assigned_menu_id ) {
$menu_locations[] = $location;
}
}
return $menu_locations;
}