Created
December 17, 2022 01:02
-
-
Save SitesByYogi/fd993f819d8eb45b612c8e1ee6d30eb9 to your computer and use it in GitHub Desktop.
Adds a custom link to the WordPress Toolbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action('admin_bar_menu', 'add_toolbar_items', 100); | |
function add_toolbar_items($admin_bar){ | |
$admin_bar->add_menu( array( | |
'id' => 'my-item', | |
'title' => 'My Item', | |
'href' => '#', | |
'meta' => array( | |
'title' => __('My Item'), | |
), | |
)); | |
$admin_bar->add_menu( array( | |
'id' => 'my-sub-item', | |
'parent' => 'my-item', | |
'title' => 'My Sub Menu Item', | |
'href' => '#', | |
'meta' => array( | |
'title' => __('My Sub Menu Item'), | |
'target' => '_blank', | |
'class' => 'my_menu_item_class' | |
), | |
)); | |
$admin_bar->add_menu( array( | |
'id' => 'my-second-sub-item', | |
'parent' => 'my-item', | |
'title' => 'My Second Sub Menu Item', | |
'href' => '#', | |
'meta' => array( | |
'title' => __('My Second Sub Menu Item'), | |
'target' => '_blank', | |
'class' => 'my_menu_item_class' | |
), | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment