WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#52035 new defect (bug)

The `add_submenu_page()` position is ignored.

Reported by: Howdy_McGee Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Administration Keywords: has-patch
Focuses: administration Cc:

Description

Hello,

I'm not sure that the add_submenu_page() position argument is being applied properly. See the below example:

<?php
add_action( 'admin_menu', function() {
        
        add_submenu_page(
                'edit.php',
                'Foo',
                'Foo',
                'list_users',
                'foo',
                function() {
                        echo 'Hello Foo';
                },
                200,
        );
        
        add_submenu_page(
                'edit.php',
                'Bar',
                'Bar',
                'list_users',
                'bar',
                function() {
                        echo 'Hello Bar';
                },
                100,
        );
        
} );

I would expect "Bar" to appear before "Foo" since it has a lower position number. What ends up happening is whichever add_submenu_page() was called first, gets position priority.

Change History (3)

#1 @SergeyBiryukov
3 months ago

  • Component changed from Menus to Administration

Thanks for the report!

Moving to the Administration component, as Menus is specifically for the Menus screen and nav menu functions.

This ticket was mentioned in PR #816 on WordPress/wordpress-develop by mukeshpanchal27.


3 months ago

  • Keywords has-patch added

#3 @mukesh27
3 months ago

Hi there!

Above attached PR #816 fixes the menu position issue.

Note: See TracTickets for help on using tickets.