WordPress.org

Make WordPress Core

Opened 5 years ago

Last modified 6 weeks ago

#12718 reopened enhancement

Better structure for admin $menu — at Initial Version

Reported by: scribu Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Plugins Keywords: has-patch dev-feedback
Focuses: administration Cc:

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.

Change History (0)

Note: See TracTickets for help on using tickets.