Created
January 17, 2012 04:18
-
-
Save AndorChen/1624625 to your computer and use it in GitHub Desktop.
Add Links to WordPress 3.3 New Toolbar
This file contains hidden or 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
<?php | |
/** | |
* Add Links to WP3.3+ New Toolbar | |
* | |
*/ | |
add_action('admin_bar_menu', 'add_toolbar_items', 100); | |
function add_toolbar_items($admin_bar) { | |
// Top level menu | |
$admin_bar->add_menu( array( | |
'id' => 'my-item', | |
'title' => 'My Item', | |
'href' => '#', | |
'meta' => array( | |
'title' => __('My Item'), | |
), | |
)); | |
// Add sub menu to 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' | |
), | |
)); | |
// Another sub menu to my-item | |
$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