Adding nav_menu to admin_bar (toolbar)

This feature can be practically indispensable because, in addition to convenience, it also adds functionality.

By using the following code, we register the navigation menu wp_nav_menu and add items from this menu to the toolbar.

/**
 * toolbar nav menu - навигационное меню в тулбаре
 * v0.3
 */
add_action( 'after_setup_theme', function() {
	register_nav_menu( 'toolbar', 'Toolbar' );
} );

add_action( 'admin_bar_menu', 'kama_add_toolbar_menu', 999 );
function kama_add_toolbar_menu( $toolbar ) {
	$locations = get_nav_menu_locations();

	if( ! isset( $locations['toolbar'] ) ){
		return;
	}

	$items = wp_get_nav_menu_items( $locations['toolbar'] );

	if( ! $items ){
		return;
	}

	foreach( $items as $item ){
		$args = [
			'parent' => $item->menu_item_parent ? 'id_' . $item->menu_item_parent : false,
			'id'     => 'id_' . $item->ID,
			'title'  => $item->title,
			'href'   => $item->url,
			'meta'   => [
				'class'  => implode( ' ', $item->classes ),
				'title'  => esc_attr( $item->description ),
				'target' => $item->target,
			],
		];

		$toolbar->add_node( $args );
	}
}

How it works.

You add the code to functions.php. Then go to the admin panel: Appearance > Menus and create a menu, add any links to it, and attach the menu to the "Toolbar" area. You can use multiple levels, then the top level will be the main in the toolbar, and the additional ones will become a dropdown list.