﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
19380,There is no way to specify placement of a new menu item in the Admin Bar,willshouse,,"I recently opened ticket #19371 and scribu has added a fantastic and simple solution to be able to modify existing menu items. The only problem, however, is that it is impossible to control placement of a new menu item.

For example, if I wanted to add a class on the ""wp-logo"" menu item, I would use the method specified in #19371 to remove it, modify it, and add it back.

{{{

add_action( 'admin_bar_menu', function( $admin_bar ) {
	$node = $admin_bar->remove_menu( 'wp-logo' );

	$node['meta']['class'] = 'foo';

	$admin_bar->add_menu( $node );
}, 99 );

}}}


The only problem is that it would put the menu item at the far right of the other menu items. I could then remove and re-add all the other menu items. However I don't think there is a way to get a list of all the top level menu items from within the admin bar class, so you would have to know the ID of each one from a print_r debug of the object and hard code the items in. This would break if a plugin added a menu item that wasn't in the hard coded list.

My thoughts would be either add a parameter to the add_menu() function such as priority, which could be boolean and cause the item to be added with array_unshift() instead of the current method, or a parameter that would be be for the id to ""add before menu item x"" , or just a method that would return a list of ids of the root menu items.

ps: I don't really need to add a CSS class to the wp-logo menu item, but this is the far-left-most item and I thought it would make the best example.",defect (bug),new,normal,Future Release,Toolbar,3.3,minor,,,
