From 0609e042662f9c4f865db60c462e06966a5c1a3f Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Oct 2019 17:52:04 +0000 Subject: [PATCH] Administration: Relax the default value check for the `$position` argument added to `add_submenu_page()` and related functions in [46197]. Due to a confusion with `add_menu_page()`, which takes the `$icon_url` parameter, while `add_submenu_page()` does not, some plugins were passing in a string instead of integer as `$position`, causing backward compatibility issues. A `_doing_it_wrong()` message is now added to alert developers of the wrong parameter type. Props david.binda, desrosj, 123host, dennis_f, MattyRob. Reviewed by desrosj. Fixes #48249. Built from https://develop.svn.wordpress.org/trunk@46570 git-svn-id: http://core.svn.wordpress.org/trunk@46367 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/plugin.php | 14 +++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wp-admin/includes/plugin.php b/wp-admin/includes/plugin.php index 43f60a187b..32a37f106a 100644 --- a/wp-admin/includes/plugin.php +++ b/wp-admin/includes/plugin.php @@ -1373,7 +1373,19 @@ function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, } $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title ); - if ( null === $position ) { + if ( ! is_int( $position ) ) { + if ( null !== $position ) { + _doing_it_wrong( + __FUNCTION__, + sprintf( + /* translators: %s: add_submenu_page() */ + __( 'The seventh parameter passed to %s should be an integer representing menu position.' ), + 'add_submenu_page()' + ), + '5.3.0' + ); + } + $submenu[ $parent_slug ][] = $new_sub_menu; } else { // If position is equal or higher than the number of items in the array, append the submenu. diff --git a/wp-includes/version.php b/wp-includes/version.php index de8bcab22e..051815178a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-RC1-46569'; +$wp_version = '5.3-RC1-46570'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.