Creates menu in WordPress admin bar.
// ADD TOOLBAR MENU ITEMS //
function add_scree_toolbar($admin_bar){
$menuName = 'You Menu Name';
$screeMenu = wp_get_nav_menu_items($menuName);
$admin_bar->add_menu(array(
'id' => 'parent-item',
'title' => 'Menu',
'href' => '#',
'meta' => array(
'title' => __('Menu')
)
));
foreach ($screeMenu as $menuItem) {
$menuArgs = array(
'id' => $menuItem->ID,
'title' => $menuItem->title,
'href' => $menuItem->url,
'parent' => 'ai-item',
'meta' => array(
'title' => __($menuItem->title)
)
);
$admin_bar->add_menu($menuArgs);
}
}
add_action('admin_bar_menu', 'add_scree_toolbar', 100);