[wp-trac] [WordPress Trac] #48702: [function] => add_submenu_page

WordPress Trac noreply at wordpress.org
Mon Nov 18 20:50:03 UTC 2019


#48702: [function] => add_submenu_page
----------------------------+------------------------------
 Reporter:  j3gaming        |       Owner:  (none)
     Type:  defect (bug)    |      Status:  reopened
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  Administration  |     Version:  5.3
 Severity:  normal          |  Resolution:
 Keywords:                  |     Focuses:
----------------------------+------------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:4 j3gaming]:
 > This is my line of code:
 > add_submenu_page('activeadmin', "Users", "Users", 'administrator',
 'Users', 'ActiveAdminUsers');
 >
 > Notice 6 parameters right?

 Right, but you have 8 parameters here, per comment:2:
 > add_submenu_page('Reporting', 'Labour Hours', 'Labour Hours',
 'reporting_dashboard', 'LabourHours', 'ShowLabourHours' , $iconPin, 2);

 It's the `$iconPin` that triggers a `_doing_it_wrong()` error message.

 > I'm assuming the 7th parameter (position) is being passed as null.
 > That causes this:
 > The seventh parameter passed to add_submenu_page() should be an integer
 representing menu position
 >
 > null != int

 The default value of `null` does not trigger the error message, as it
 specifically [source:tags/5.3/src/wp-
 admin/includes/plugin.php?marks=1377-1387#L1374 checks for null]:
 {{{
 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.' ),
                                 '<code>add_submenu_page()</code>'
                         ),
                         '5.3.0'
                 );
         }

         $submenu[ $parent_slug ][] = $new_sub_menu;
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/48702#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list