Make WordPress Core

Changeset 53264


Ignore:
Timestamp:
04/26/2022 02:57:22 AM (4 years ago)
Author:
peterwilsoncc
Message:

Administration: Trigger a notice for incorrect add_menu_page() parameter.

Trigger a notice (via _doing_it_wrong()) for developers incorrectly setting the position when calling add_menu_page().

Modify a similar message in add_submenu_page() to combine near identical strings and match the error description to the conditions in which it is called.

Follow up to [52569], [53104].

Fixes #40927.

File:
1 edited

Legend:

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

    r53215 r53264  
    13261326        $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url );
    13271327
     1328        if ( null !== $position && ! is_numeric( $position ) ) {
     1329                _doing_it_wrong(
     1330                        __FUNCTION__,
     1331                        sprintf(
     1332                                /* translators: %s: add_menu_page() */
     1333                                __( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
     1334                                '<code>add_menu_page()</code>'
     1335                        ),
     1336                        '6.0.0'
     1337                );
     1338                $position = null;
     1339        }
     1340
    13281341        if ( null === $position || ! is_numeric( $position ) ) {
    13291342                $menu[] = $new_menu;
     
    14221435                        sprintf(
    14231436                                /* translators: %s: add_submenu_page() */
    1424                                 __( 'The seventh parameter passed to %s should be an integer representing menu position.' ),
     1437                                __( 'The seventh parameter passed to %s should be numeric representing menu position.' ),
    14251438                                '<code>add_submenu_page()</code>'
    14261439                        ),
Note: See TracChangeset for help on using the changeset viewer.