Make WordPress Core

Opened 17 months ago

Last modified 8 months ago

#39776 assigned enhancement

add priority argument to add_submenu_page() function

Reported by: alexvorn2 Owned by: welcher
Milestone: 5.0 Priority: normal
Severity: normal Version: 4.7.2
Component: Menus Keywords: has-patch dev-feedback
Focuses: administration Cc:


Add option to add new sub-menu pages with specific order - adding priority number, so if we will have a bigger priority the menu will have higher position in sidebar admin menus.

Attachments (1)

39776.diff (13.5 KB) - added by welcher 13 months ago.
Initial Patch

Download all attachments as: .zip

Change History (7)

13 months ago

Initial Patch

#1 @welcher
13 months ago

  • Keywords has-patch dev-feedback added

Attached is an initial approach based on what is done in add_menu_page. The position numbers are not sequential, but rather multiples of 5. Adding a submenu item with a priority of 5 ( or lower ) will place it at the top of the list, 10 will be the second, 15 the third and so on.

This is due to how the menus are generated and output in includes/menu.php: https://core.trac.wordpress.org/browser/tags/4.7/src/wp-admin/includes/menu.php

The Appearance menu does deviate from this numbering system slightly which may cause some confusion when adding items to it.

I'd love a second opinion on this approach.

#3 @alexvorn2
11 months ago

So can we move this to 4.9 Milestone?

#4 @welcher
8 months ago

  • Milestone changed from Awaiting Review to 5.0

I think its too late for 4.9 but lets aim for 5.0

#5 @welcher
8 months ago

The ability to set the position is done with the attached patch.

However, I don't really like how the numbering seems arbitrary. 1 is the top but 5 is the second slot and then 10 is the third unless you are in the Appearance menu in which case 6 is the third.

I think we need a way to abstract that away so it's consistent and numbered in a sane fashion.

#6 @welcher
8 months ago

  • Owner set to welcher
  • Status changed from new to assigned
Note: See TracTickets for help on using tickets.