Skip to content

Instantly share code, notes, and snippets.

@niraj-shah
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niraj-shah/9052629 to your computer and use it in GitHub Desktop.
Save niraj-shah/9052629 to your computer and use it in GitHub Desktop.
<?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