Location slug => description. */ public static function registered(): array { return array_map('strval', (array) get_registered_nav_menus()); } /** @return array Location slug => menu ID. */ public static function assigned(): array { $locations = get_nav_menu_locations(); return is_array($locations) ? array_map('intval', $locations) : []; } /** @return list */ public static function of(int $menuId): array { return array_map('strval', array_keys(array_filter( self::assigned(), static fn (int $id): bool => $id === $menuId ))); } public static function assign(string $location, int $menuId): void { $locations = self::assigned(); if ($menuId > 0) { $locations[$location] = $menuId; } else { unset($locations[$location]); } set_theme_mod('nav_menu_locations', $locations); } }