[wp-trac] [WordPress Trac] #12718: Better structure for admin $menu
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 20 13:47:08 UTC 2012
#12718: Better structure for admin $menu
------------------------------------+-----------------------
Reporter: scribu | Owner:
Type: enhancement | Status: reopened
Priority: normal | Milestone: 3.5
Component: Plugins | Version:
Severity: normal | Resolution:
Keywords: has-patch dev-feedback |
------------------------------------+-----------------------
Changes (by scribu):
* cc: duck_ (added)
* keywords: => has-patch dev-feedback
* milestone: Awaiting Review => 3.5
Comment:
I think the patch is stable enough to warrant a first round of reviews.
You can get a feel for the current API by looking through the changes in
wp-admin/menu.php as well as in wp-admin/includes/plugin.php
All the existing menu-related functions, such as add_menu_page(),
remove_submenu_page() etc. work.
The meaning of the 'menu_position' arg has been changed. Previously, it
was an arbitrary numeric index, which could overwrite other menu items -
see #16946
Now, you pass to it a menu id. For example, here's how you would register
a CPT that you want to show up above the Pages menu:
{{{
register_post_type( 'my-cpt', array(
...
'menu_position' => 'pages'
) );
}}}
I also thought of deprecating 'menu_position' outright and replacing it
with 'menu_before'.
Also, the reason it inserts menus before a given menu id and not after is
because it's more intuitive when you have multiple post types:
{{{
register_post_type( 'cpt-1', array(
...
'menu_position' => 'pages'
) );
register_post_type( 'cpt-2', array(
...
'menu_position' => 'pages'
) );
}}}
The resulting order will be CPT 1, CPT 2, Pages. This is also consistent
with the behavior of the revamped $menu_position parameter of
add_menu_page().
Some unanswered questions:
1. Currently submenu items don't have ids (they default to the slugs).
Should they?
2. There was an old 'custom_menu_order' filter, again numeric index based.
Should we introduce a replacement? My impression is that with the improved
API, it's not really needed anymore.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12718#comment:49>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list