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
This commit is contained in:
parent
55378bd295
commit
7bbce99655
|
@ -92,6 +92,13 @@ function register_nav_menus( $locations = array() ) {
|
||||||
|
|
||||||
add_theme_support( 'menus' );
|
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 );
|
$_wp_registered_nav_menus = array_merge( (array) $_wp_registered_nav_menus, $locations );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue