10 tips for wordpress admin bar

Shortlink:

Remove the WordPress Logo from the WordPress Admin Bar

/*
* Remove the WordPress Logo from the WordPress Admin Bar
*/
function remove_wp_logo() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
}
add_action( 'wp_before_admin_bar_render', 'remove_wp_logo' );

Remove the Howdy menu from the WordPress Admin Bar

/*
* Remove the Howdy menu from the WordPress Admin Bar
*/
function remove_my_account() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('my-account');
}
add_action( 'wp_before_admin_bar_render', 'remove_my_account' );

Remove the Comment Bubble from the WordPress Admin Bar

/*
* Remove the Comment Bubble from the WordPress Admin Bar
*/
function remove_comment_bubble() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('comments');
}
add_action( 'wp_before_admin_bar_render', 'remove_comment_bubble' );

Disable the My Sites menu in the Admin Bar

/*
* Disable the My Sites menu in the Admin Bar
*/
function remove_my_sites() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('my-sites');
}
add_action( 'wp_before_admin_bar_render', 'remove_my_sites' );

Disable the current Site Name menu in the Admin Bar

This is the menu shows the current site, with a dropdown to visit the Website.

/*
* Disable the current Site Name menu in the Admin Bar
*/
function remove_this_site() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('site-name');
}
add_action( 'wp_before_admin_bar_render', 'remove_this_site' );

Disable the Add New Content menu

/*
* Disable the Add New Content menu
*/
function disable_new_content() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('new-content');
}
add_action( 'wp_before_admin_bar_render', 'disable_new_content' );

Disable the Search Icon and Input within the Admin Bar

Located to the far right within the toolbar, on the Website itself.

/*
* Disable the Search Icon and Input within the Admin Bar
*/
function disable_bar_search() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('search');
}
add_action( 'wp_before_admin_bar_render', 'disable_bar_search' );

Disable the Update Menus

/*
* Disable the Update Menus
*/
function disable_bar_updates() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('updates');
}
add_action( 'wp_before_admin_bar_render', 'disable_bar_updates' );

Add a simple menu and link that opens in a new window

Add a quick menu and link to the admin bar.

/*
* Add a simple menu & link that opens in a new window
* Change the Menu 'title' name and 'href' link.
*/
function custom_adminbar_menu( $meta = TRUE ) {
global $wp_admin_bar;
if ( !is_user_logged_in() ) { return; }
if ( !is_super_admin() || !is_admin_bar_showing() ) { return; }
$wp_admin_bar->add_menu( array(
'id' => 'custom_menu',
'title' => __( 'Menu Name' ),
'href' => 'http://google.com/',
'meta' => array( target => '_blank' ) )
);
}
add_action( 'admin_bar_menu', 'custom_adminbar_menu', 15 );

/* The add_action # is the menu position:
10 = Before the WP Logo
15 = Between the logo and My Sites
25 = After the My Sites menu
100 = End of menu
*/

Add a Menu to the Theme Editor for Multisite and Standalone WordPress

/*
* Add a Menu to the Theme Editor for Multisite and Standalone WordPress
*/
function add_theme_menu() {
global $wp_admin_bar;
if ( !is_user_logged_in() ) { return; }
if ( !is_super_admin() || !is_admin_bar_showing() ) { return; }
if ( function_exists('is_multisite') && is_multisite() ) {
$wp_admin_bar->add_menu( array(
'id' => 'theme-editor',
'title' => __('Edit Theme'),
'href' => network_admin_url( 'theme-editor.php' ) )
);
}

else{
$wp_admin_bar->add_menu( array(
'id' => 'theme-editor',
'title' => __('Edit Theme'),
'href' => admin_url( 'theme-editor.php' ) )
);
}
}
add_action( 'admin_bar_menu', 'add_theme_menu', 100 );

Theme Editor for Multisite, Standalone WordPress, Add a simple menu, opens in a new window. Disable the Update Menus, Disable the Search Icon, Input within the Admin Bar, Disable the Add New Content menu, Disable the current Site Name, Disable the My Sites menu, Remove the Comment Bubble, Remove the Howdy menu, Remove the WordPress Logo

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!