The real job of above functions aren’t to get locations but to get locations and the menu they have inside. Something like array($location1 => $menu_id1,);
. So these functions don’t list empty locations. If you want to get all filled and empty locations you might want to add the following to your function.php file:
//// here is how you register your menu locations
function register_my_menus()
{
register_nav_menus(
array(
'high-menu' => __('top menu'),
'main-menu' => __('main menu'),
'sec-menu' => __('sec menu'),
'thrd-menu' => __('thrd menu'),
)
);
}
add_action('init', 'register_my_menus');
//// This is our new function to get all menu locations
function get_all_menus_locations(){
//// sadly we have to init them like this. I couldn't find any other way yet
$all_location = array(
'high-menu',
'main-menu',
'sec-menu' ,
'thrd-menu',
);
//// this is the original function which gets only filled locations
$locations = get_nav_menu_locations();
//// this is our new variable. we will fill it by all locations
$registered_nav_menus= [];
foreach($all_locations as $location){
if(isset($locations[$location])){
//// if the location had a menu inside...
$registered_nav_menus[$location] = $locations[$location];
}
else {
////if location was empty, set a new value for it.
$registered_nav_menus[$location] = '';
}
}
return $registered_nav_menus;
}
This isn’t the solution I was looking for, but It’s what I did. for now I work with it, If you have anything better, please share it.