diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php index f130d2f3e1..b618f96e9b 100644 --- a/src/wp-includes/nav-menu.php +++ b/src/wp-includes/nav-menu.php @@ -92,6 +92,13 @@ function register_nav_menus( $locations = array() ) { add_theme_support( 'menus' ); + foreach ( $locations as $key => $value ) { + if ( is_int( $key ) ) { + _doing_it_wrong( __FUNCTION__, __( 'Nav menu locations must be strings.' ), '5.3' ); + break; + } + } + $_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations ); } diff --git a/tests/phpunit/tests/menu/nav-menu.php b/tests/phpunit/tests/menu/nav-menu.php index 2627f9f21a..4577f5e9a9 100644 --- a/tests/phpunit/tests/menu/nav-menu.php +++ b/tests/phpunit/tests/menu/nav-menu.php @@ -182,6 +182,8 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { /** * Technically possible to register menu locations numerically. * + * @expectedIncorrectUsage register_nav_menus + * * @covers ::wp_map_nav_menu_locations() */ function test_numerical_locations() { @@ -205,6 +207,8 @@ class Tests_Nav_Menu_Theme_Change extends WP_UnitTestCase { /** * Technically possible old nav menu locations were registered numerically. * + * @expectedIncorrectUsage register_nav_menus + * * @covers wp_map_nav_menu_locations() */ public function test_numerical_old_locations() {