From 6ddf02b1889daa274123e5a7a782c0e4daa1bfd7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 9 Dec 2019 21:03:02 +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. 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 --- 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 6a33e04115..e1a6fa9d40 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -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. diff --git a/wp-includes/version.php b/wp-includes/version.php index 7f39061f21..6ec3ae97e2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.