Make WordPress Core

Opened 18 years ago

Closed 18 years ago

#2610 closed defect (bug) (fixed)

New menu permissions code messes up plugins using globals

Reported by: ryanscheuermann's profile ryanscheuermann Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: menu, submenu
Focuses: Cc:

Description

In menu.php, the loops that recreate the menus based on permissions are called before the action "admin_menu" is called.

So any menus or submenus added by plugins aren't removed with the loops. Also, this causes problems when any plugins directly modify the global arrays $menu or $submenu using the original parent as a key.

Proposed fix: just moved the call to

do_action('admin_menu', '');

above the permission loops.

Also, submenus are not sorted by calling

ksort($menu); // make it all pretty

for my own sanity, please change to:

ksort($menu); // make it all pretty
foreach($submenu as $key => $menu_item) 
{
ksort($menu_item);
$submenu[$key] = $menu_item;
}

And I know that plugins are supposed to use the add_submenu_page, but that function contains no method of indicating the sort number for the menus. What's the point of using ksort if plugins can't add menu items where they want?

Thanks!

Change History (2)

#1 @ryanscheuermann
18 years ago

  • Summary changed from New menu privelege code messes up plugins using globals to New menu permissions code messes up plugins using globals

#2 @ryanscheuermann
18 years ago

  • Resolution set to fixed
  • Status changed from new to closed

changeset [3756] - fixed this issue (just doing some ticket cleanup)

Note: See TracTickets for help on using tickets.