[wp-hackers] Stumped by WordPress' Admin Menus

Peter Westwood peter.westwood at ftwr.co.uk
Tue Jan 11 19:17:15 UTC 2011

On 11 Jan 2011, at 11:32, Mike Schinkel wrote:

> On Jan 11, 2011, at 5:16 AM, Sergey Biryukov wrote:
>> On Tue, Jan 11, 2011 at 1:32 AM, Mike Schinkel
>> <mikeschinkel at newclarity.net> wrote:
>>> Although there are other issues I've had with the admin menu system (described here[1]) the problem I am having today is that the menu_page seems to inherit the first URL from the submenu_page and no matter what I try I can't get them decoupled. To illustrate the point I've created a very simple example:
>>> add_action('admin_menu','my_admin_menu');
>>> function my_admin_menu() {
>>>      global $submenu;
>>>      unset($submenu['edit.php'][5]);    // Remove 'Posts'
>>>      unset($submenu['edit.php'][10]);   // Remove 'Add New'
>>>      $submenu['edit.php'][15][0] = 'Post Categories';
>>>      unset($submenu['edit.php'][16]);   // Remove 'Post Tags'
>>> }
>> Since $submenu_as_parent lacks a filter which could help here, the
>> only other option I can think of is to leave the "Posts" item in the
>> array and then hide it via CSS. Still not very elegant.
> Agreed, not very elegant.  But thanks for looking at it to see if you could come up with something for me.

You should look at remove_menu_page and remove_submenu_page (introduced in 3.1)

You can always port them back for your plugin and wrap in function_exists

Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5

More information about the wp-hackers mailing list