Last active
August 29, 2015 14:26
-
-
Save marcbacon/11f15fd2ee8c2d942011 to your computer and use it in GitHub Desktop.
Code to edit the admin bar/toolbar in WordPress
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
// Remove links from the admin bar/toolbar | |
function remove_admin_bar_links() { | |
global $wp_admin_bar; | |
$wp_admin_bar->remove_menu('wp-logo'); | |
$wp_admin_bar->remove_menu('updates'); | |
$wp_admin_bar->remove_menu('search'); | |
$wp_admin_bar->remove_menu('comments'); | |
// Remove site name and new only if user is not administrator | |
if ( !current_user_can( 'manage_options' ) ) $wp_admin_bar->remove_menu('site-name'); | |
if ( !current_user_can( 'manage_options' ) ) $wp_admin_bar->remove_menu('new-content'); | |
// Jetpack links | |
$wp_admin_bar->remove_menu('notes'); | |
$wp_admin_bar->remove_menu('stats'); | |
} | |
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' ); | |
/* | |
Here are more options to add into remove_menu(): | |
wp-logo: WordPress logo | |
my-account: Links to your account. The ID depends upon if you have avatar enabled or not. | |
site-name: Site name with other dashboard items | |
my-sites : My Sites menu, if you have more than one site | |
get-shortlink : Shortlink to a page/post | |
edit : Post/Page/Category/Tag edit link | |
new-content : Add New menu | |
comments : Comments link | |
updates : Updates link | |
search: Search box | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment