[wp-trac] [WordPress Trac] #12718: Better structure for admin menu (was: Better structure for admin $menu)
WordPress Trac
wp-trac at lists.automattic.com
Sat Jul 21 12:48:14 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 |
------------------------------------+-----------------------
Description changed by scribu:
Old description:
> Currently, the global $menu variable is one big linear array:
>
> {{{
> $menu = array(
> [2] => array('Dashboard', ...
> [4] => array('', 'read', 'separator1', ...),
> [5] => array('Posts', ...)
> ...
> )
> }}}
>
> To allow plugins to add a menu item at the end of a group, we use a bunch
> of additional global variables that remember the last element in each
> group.
>
> It's very low level.
>
> Things would be a lot easier if groups were built in:
>
> {{{
> $menu = array(
> 'dashboard' => array(
> [5] => array('Dashboard', ...
> ),
>
> 'object' => array(
> [5] => array('Posts', ...)
> [10] => array('Media', ...)
> ...
> ),
>
> 'utility' => array(
> [5] => array('Posts', ...)
> [10] => array('Media', ...)
> ...
> ),
> )
> }}}
>
> With this structure, separators could be inserted automatically in the
> right places. Also, you wouldn't have to worry about adding 'menu-top-
> first' and 'menu-top-last' classes.
New description:
Currently, the global $menu variable is one big linear array:
{{{
$menu = array(
[2] => array('Dashboard', ...
[4] => array('', 'read', 'separator1', ...),
[5] => array('Posts', ...)
...
)
}}}
To allow plugins to add a menu item at the end of a group, we use a bunch
of additional global variables that remember the last element in each
group.
Also, we use arbitrary numeric indexes to specify the order of the items,
instead of being able to position items relative to one another.
It's all very low level. Things would be a lot easier if we had an actual
API for manipulating the menu items.
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/12718#comment:52>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list