WordPress.org

Make WordPress Core

Changeset 46570


Ignore:
Timestamp:
10/22/2019 05:50:45 PM (11 months ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r46410 r46570  
    13741374
    13751375    $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
    1376     if ( null === $position ) {
     1376    if ( ! is_int( $position ) ) {
     1377        if ( null !== $position ) {
     1378            _doing_it_wrong(
     1379                __FUNCTION__,
     1380                sprintf(
     1381                    /* translators: %s: add_submenu_page() */
     1382                    __( 'The seventh parameter passed to %s should be an integer representing menu position.' ),
     1383                    '<code>add_submenu_page()</code>'
     1384                ),
     1385                '5.3.0'
     1386            );
     1387        }
     1388
    13771389        $submenu[ $parent_slug ][] = $new_sub_menu;
    13781390    } else {
Note: See TracChangeset for help on using the changeset viewer.