Yesterday I shared how to remove items from the WordPress Admin Toolbar. This can be very useful but for someone who spends a lot of time logged into their website like myself, this tip can be even more useful. Here is the code.
[php]
add_action( ‘admin_bar_menu’, ‘my_toolbar_links_to_stuff’, 999 );
function my_toolbar_links_to_stuff( $wp_admin_bar ) {
if( current_user_can( ‘administrator’ ) ) :
$args = array(
‘id’ => ‘my_twitter’,
‘title’ => ‘Twitter’,
‘href’ => ‘http://twitter.com/#!/jameslaws’,
‘parent’ => ‘site-name’
);
$wp_admin_bar->add_node( $args );
endif;
}
[/php]
In the code above I’ve wrapped the call to add_node in an if statement so that it will only show for administrators. You could leave this out if you wanted it to show for everyone logged in. the code is pretty easy to follow and you could do as many of these as you need. Give your new menu item an ID, a title that will represent the link, the address you want the link to go to, and a parent ID if you want to show up under an already established menu item. If you set parent to false it will become the main menu item. You can visit my post about removing items from your admin toolbar for how to determine the menu items ID.
You are a busy person. How might you leverage this newly discovered power. Link to your social sites, Google Analytics, or your favorite web resources. You might even add links to pages within your admin that aren’t readily available from the front-end of your site.
How are using this on your sites? I would love to hear from you.
Leave a Reply