Menus: Avoid a PHP warning in `add_submenu_page()` when the same value is passed for both `$parent_slug` and `$menu_slug` parameters.

Props welcher, ispreview, ayeshrajans, NextScripts, adamsilverstein, garrett-eclipse, 123host.
Fixes #48599.
Built from https://develop.svn.wordpress.org/trunk@46868


git-svn-id: http://core.svn.wordpress.org/trunk@46668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-12-09 21:03:02 +00:00
parent a209908501
commit 6ddf02b188
2 changed files with 4 additions and 3 deletions

View File

@ -1390,8 +1390,9 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability,
$submenu[ $parent_slug ][] = $new_sub_menu;
} else {
// If position is equal or higher than the number of items in the array, append the submenu.
if ( $position >= count( $submenu[ $parent_slug ] ) ) {
// Append the submenu if the parent item is not present in the submenu,
// or if position is equal or higher than the number of items in the array.
if ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) ) {
$submenu[ $parent_slug ][] = $new_sub_menu;
} else {
// Test for a negative position.

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-46866';
$wp_version = '5.4-alpha-46868';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.