@Mods: Remove bp_core_admin_bar_css on Backend
-
Hey,
some time ago i was looking for the best solution to alter the admin-bar.css in BP.
I figured out the following solution which removes the original admin-bar.css and replaces it on a per blog basis with a my-admin-bar.css.
The my-admin-bar.css is only loaded when the user is logged in (i set the option to hide the buddybar from user who are not logged in).
function check_admin_bar() {
global $bp, $wpdb, $current_blog, $doing_admin_bar;
$doing_admin_bar = true;
//remove core admin bar CSS at all times!
remove_action('wp_head', 'bp_core_admin_bar_css', 1);
remove_action('admin_head', 'bp_core_admin_bar_css', 1);
if ( (int) get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
return false;
//add custom CSS only if admin bar is true
if($doing_admin_bar)
add_action('wp_head', 'my_admin_bar_css', 1);
add_action('admin_head', 'my_admin_bar_css', 1);
}
add_action('plugins_loaded','check_admin_bar',99);However i’m not able to remove the original admin_bar.css in the backend! It still loads the original admin_bar.css along with my_admin_bar.css.
Any ideas if i missed some hook or some other suggestions?
-
You need to remove the bp admin css with plugins_loaded as well.
Try this:
function remove_adminbar_css(){
remove_action('wp_head', 'bp_core_admin_bar_css', 1);
}
add_action('plugins_loaded','remove_adminbar_css');Hey r-a-y
thanks again for your help, but that doesn’t work neither.
I tried it with remove_action(‘wp_head‘, ‘bp_core_admin_bar_css’, 1);
and also with remove_action(‘admin_head‘, ‘bp_core_admin_bar_css’, 1);
I had a look at bp-core-cssjs.php and on line 108 i found the following function
/**
* bp_core_add_admin_css()
*
* Add the CSS needed for all components in the admin area.
*
* @package BuddyPress Core
* @uses get_option() Selects a site setting from the DB.
*/
function bp_core_add_admin_css() {
if ( defined( 'BP_DISABLE_ADMIN_BAR') )
return false;
wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', BP_PLUGIN_URL . '/bp-core/css/admin-bar.css' ) );
}
add_action( 'admin_menu', 'bp_core_add_admin_css' );It seems to be the key to remove the admin-bar.css on the backend of WPMU. However i tried it with the following code, but it still doesn’t work.
function remove_adminbar_css(){
remove_action('admin_menu', 'bp_core_add_admin_css', 1);
}
add_action('plugins_loaded','remove_adminbar_css');Sorry!
I misread your post!
Try this:
function remove_adminbar_css(){
remove_action('admin_menu', 'bp_core_add_admin_css');
}
add_action('init','remove_adminbar_css');Put the code in “/wp-content/plugins/bp-custom.php”
Try that.
Thanks a million! add_action(‘init‘,’remove_adminbar_css’); is what i was missing!
- The topic ‘@Mods: Remove bp_core_admin_bar_css on Backend’ is closed to new replies.