Skip to content

Instantly share code, notes, and snippets.

@jphorn
Created February 23, 2012 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jphorn/1892987 to your computer and use it in GitHub Desktop.
Save jphorn/1892987 to your computer and use it in GitHub Desktop.
Add menu to WordPress Admin Bar for Editor role (and higher) (WordPress Toolbar)
/*
* Paste in functions.php and adapt as needed
* Author: Jean-Paul Horn, iCulture.nl (@JeanPaulH)
* Special thanks to Joeke-Remkus de Vries (@defries)
*/
function iculture_admin_bar_menu() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'id' => 'favorites',
'title' => __( 'Favorite'),
'href' => '#' ) );
$wp_admin_bar->add_menu( array(
'parent' => 'favorites',
'title' => __( 'My Title 1'),
'href' => 'http://www.example.com' ) );
$wp_admin_bar->add_menu( array(
'parent' => 'favorites',
'title' => __( 'My Title 2'),
'href' => 'http://www.example.com' ) );
$wp_admin_bar->add_menu( array(
'parent' => 'favorites',
'title' => __( 'My Title 3'),
'href' => 'http://www.example.com' ) );
}
//Feel free to adapt this to your desired user role/capability
if ( current_user_can('publish_posts') ) :
add_action('admin_bar_menu', 'iculture_admin_bar_menu', 99);
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment