Skip to:

Re: Adding menu items to the admin bar


I’ve had to do a fairly extensive rewrite on the function for a number of reasons:

1/ There was a significant degree of malfomed ul child nesting which prevents drop down aspects working correctly primarily I’ve removed the opening and closing UL elements as they are not required and cause issues.

2/ Not sure how the wp_list_pages was intended to work but with the parameter ‘title_li’ declared as empty you correctly remove the wrapping elements but would need to add UL elements manually wrapping the function call for the dropdown to function correctly.

3/ Added back in the wp_nav_menu function calls but wrapped them in a check to see if WP 3.0 is running i.e are the new menu available if not hide altogether.

Also added a reverse check to remove the wp_list_pages function if using the new menus as there is little point in both and the new menu system serves better.

4/ Changed region and menu top link names to ‘pages’ but this area is a fundamental issue as it cant be known what the user sets as menu names, ideally one shouldn’t hard code values but retrieve them from the admin menu area, but this proves far too hard to work out (asked a question on WP support but haven’t had a reply and I don’t expect one – sadly there is little codex documentation of any depth on the new menus.)

This issue applies to the wp_list_pages as well as you can’t really pass any values for ‘include’ and ‘exclude’ as these values can’t be known so you ought to remove those values you have hardcoded (I have left them in).

If I can get some guidance on how to fetch values from the menu backend view such as menu names then it will be possible to make the menus far more effective but have spent quite a while trawling through the core WP files for nav-menu and it’s not obvious and too time consuming.

I have copied the revised code to this pastebin page, give it a check over, but don’t assume I have things all correct, run it as plugin copy 2

Skip to toolbar