From 7bbce99655e3a12b58b89a25f9b30eb76f7e5a44 Mon Sep 17 00:00:00 2001 From: desrosj Date: Fri, 13 Sep 2019 17:58:55 +0000 Subject: [PATCH] Menus: Nav menu locations should not be integers. When nav menu location slugs are integers, some hard to debug results can occur. `register_nav_menus()` utilizes `array_merge()` which renumbers numeric indexes, starting from 0. Because of this, numeric menu locations will almost always be changed. This change introduces a `_doing_it_wrong()` notice to inform developers that nav menu locations should always be strings. Props audrasjb, desrosj, welcher. Fixes #45361. Built from https://develop.svn.wordpress.org/trunk@46102 git-svn-id: http://core.svn.wordpress.org/trunk@45914 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu.php | 7 +++++++ wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index f130d2f3e1..b618f96e9b 100644 --- a/wp-includes/nav-menu.php +++ b/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/wp-includes/version.php b/wp-includes/version.php index a9c177a11b..77e280aec6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46101'; +$wp_version = '5.3-alpha-46102'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.