Skip to content

Instantly share code, notes, and snippets.

@nfsarmento
Created December 30, 2019 17:00
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 nfsarmento/8a0f26d49bb561ab4663131de6e76b12 to your computer and use it in GitHub Desktop.
Save nfsarmento/8a0f26d49bb561ab4663131de6e76b12 to your computer and use it in GitHub Desktop.
Removing Items From the Admin Bar
/**
*
* Removing Items From the Admin Bar
*
*/
if ( ! function_exists( 'nwljds_remove_from_admin_bar' ) ) :
function nwljds_remove_from_admin_bar($wp_admin_bar) {
/*
* Placing items in here will only remove them from admin bar
* when viewing the fronte end of the site
*/
global $wp_admin_bar;
if ( ! is_admin() ) {
// Example of removing item generated by plugin. Full ID is #wp-admin-bar-si_menu
$wp_admin_bar->remove_node('si_menu');
$wp_admin_bar->remove_node('updates');
$wp_admin_bar->remove_node('comments');
$wp_admin_bar->remove_node('new-content');
$wp_admin_bar->remove_node('tribe-events');
$wp_admin_bar->remove_node('fb-edit');
$wp_admin_bar->remove_node('avada');
}
/*
* Items placed outside the if statement will remove it from both the frontend
* and backend of the site
*/
$wp_admin_bar->remove_node('wp-logo');
}
add_action('wp_before_admin_bar_render', 'nwljds_remove_from_admin_bar', 9999);
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment