Last active
August 29, 2015 13:56
-
-
Save niraj-shah/9052629 to your computer and use it in GitHub Desktop.
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 | |
// remove WordPress items from toolbar | |
function preload_my_toolbar() { | |
global $wp_admin_bar; | |
// remove WordPress logo | |
$wp_admin_bar->remove_node('wp-logo'); | |
// remove search button | |
$wp_admin_bar->remove_node('search'); | |
} | |
// add custom items to toolbar | |
function my_toolbar() { | |
global $wp_admin_bar; | |
// add a single link | |
$wp_admin_bar->add_node( array( | |
'id' => 'my-link-one', | |
'title' => 'Item 1', | |
'href' => site_url() | |
) ); | |
// add a item to the right of the menu using parent: top-secondary | |
$wp_admin_bar->add_node( array( | |
'id' => 'my-search', | |
'title' => 'Search', | |
'href' => '#', | |
'parent' => 'top-secondary' | |
) ); | |
// add a sub-item | |
$wp_admin_bar->add_node( array( | |
'id' => 'my-google-search', | |
'title' => 'Google', | |
'parent' => 'my-search', | |
'href' => 'http://www.google.com', | |
'meta' =>array( 'target' => '_blank' ) | |
) ); | |
// add another sub-item | |
$wp_admin_bar->add_node( array( | |
'id' => 'my-bing-search', | |
'title' => 'Bing', | |
'parent' => 'my-search', | |
'href' => 'http://www.bing.com', | |
'meta' =>array( 'target' => '_blank' ) | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment