From 7ee1e127154ee1ffc0af7a246fc67519ec53e617 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 22 Oct 2019 17:50:45 +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. git-svn-id: https://develop.svn.wordpress.org/trunk@46570 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/plugin.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 43f60a187b..32a37f106a 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/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.