From 34876111290fcd78642b8853eb17c4a51bfb62c8 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 9 Dec 2019 21:06:03 +0000 Subject: [PATCH] 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. Merges [46868] to the 5.3 branch. Fixes #48599. Built from https://develop.svn.wordpress.org/branches/5.3@46869 git-svn-id: http://core.svn.wordpress.org/branches/5.3@46669 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 5 +++-- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 32a37f106a..92743086f4 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1388,8 +1388,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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 0459d663c2..84b3629bae 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3.1-alpha-46867'; +$wp_version = '5.3.1-alpha-46869'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.