Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save remkus/1892993 to your computer and use it in GitHub Desktop.
Save remkus/1892993 to your computer and use it in GitHub Desktop.
Add menu to WordPress Admin Bar for Editor role (and higher) (WordPress Toolbar)
<?php
/**
* Adding a menu to your WordPress Toolbar
*
* @author: Jean-Paul Horn, iCulture.nl (@JeanPaulH)
* @param $wp_admin_bar used to add an extra dropdown menu
*
* Thanks to 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