[wp-trac] [WordPress Trac] #52035: The `add_submenu_page()` position is ignored.

WordPress Trac noreply at wordpress.org
Sat Jul 6 02:19:30 UTC 2024


#52035: The `add_submenu_page()` position is ignored.
-------------------------------------+------------------------------
 Reporter:  Howdy_McGee              |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Administration           |     Version:
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:  administration
-------------------------------------+------------------------------

Comment (by rajinsharwar):

 @leogermani I have added a case for the one you mentioned in
 https://core.trac.wordpress.org/ticket/52035#comment:5.

 Now if the menus have larger $position passed, then it adds float values
 to arrange accordingly. Like for below:

 {{{#!php
 add_submenu_page( 'my_top_level_slug', 'My Custom Submenu Page - 1', 'My
 Custom Submenu Page - 1',
                 'manage_options', 'my-secondary-slug', '', 200 );
 add_submenu_page( 'my_top_level_slug', 'My Custom Submenu Page - 2', 'My
 Custom Submenu Page - 2',
         'manage_options', 'my-secondary-slug', '', 200 );
 }}}

 The output will be:

 {{{
     [0] => Array
         (
             [0] => My Custom Page
             [1] => manage_options
             [2] => my_top_level_slug
             [3] => My Custom Page
         )

     [200] => Array
         (
             [0] => My Custom Submenu Page - 1
             [1] => manage_options
             [2] => my-secondary-slug
             [3] => My Custom Submenu Page - 1
         )

     [200.1] => Array
         (
             [0] => My Custom Submenu Page - 2
             [1] => manage_options
             [2] => my-secondary-slug
             [3] => My Custom Submenu Page - 2
         )
 }}}

 Let me know if we should add a unit test for this case.

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


More information about the wp-trac mailing list