Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
buddypress body classes
function bp_get_the_body_class( $wp_classes, $custom_classes = false ) {
$bp_classes = array();
/** Pages *************************************************************/
if ( is_front_page() )
$bp_classes[] = 'home-page';
if ( bp_is_directory() )
$bp_classes[] = 'directory';
if ( bp_is_single_item() )
$bp_classes[] = 'single-item';
/** Components ********************************************************/
if ( !bp_is_blog_page() ) :
if ( bp_is_user_profile() )
$bp_classes[] = 'xprofile';
if ( bp_is_activity_component() )
$bp_classes[] = 'activity';
if ( bp_is_blogs_component() )
$bp_classes[] = 'blogs';
if ( bp_is_messages_component() )
$bp_classes[] = 'messages';
if ( bp_is_friends_component() )
$bp_classes[] = 'friends';
if ( bp_is_groups_component() )
$bp_classes[] = 'groups';
if ( bp_is_settings_component() )
$bp_classes[] = 'settings';
endif;
/** User **************************************************************/
if ( bp_is_user() )
$bp_classes[] = 'bp-user';
if ( !bp_is_directory() ) :
if ( bp_is_user_blogs() )
$bp_classes[] = 'my-blogs';
if ( bp_is_user_groups() )
$bp_classes[] = 'my-groups';
if ( bp_is_user_activity() )
$bp_classes[] = 'my-activity';
endif;
if ( bp_is_my_profile() )
$bp_classes[] = 'my-account';
if ( bp_is_user_profile() )
$bp_classes[] = 'my-profile';
if ( bp_is_user_friends() )
$bp_classes[] = 'my-friends';
if ( bp_is_user_messages() )
$bp_classes[] = 'my-messages';
if ( bp_is_user_recent_commments() )
$bp_classes[] = 'recent-comments';
if ( bp_is_user_recent_posts() )
$bp_classes[] = 'recent-posts';
if ( bp_is_user_change_avatar() )
$bp_classes[] = 'change-avatar';
if ( bp_is_user_profile_edit() )
$bp_classes[] = 'profile-edit';
if ( bp_is_user_friends_activity() )
$bp_classes[] = 'friends-activity';
if ( bp_is_user_groups_activity() )
$bp_classes[] = 'groups-activity';
if ( is_user_logged_in() )
$bp_classes[] = 'logged-in';
/** Messages **********************************************************/
if ( bp_is_messages_inbox() )
$bp_classes[] = 'inbox';
if ( bp_is_messages_sentbox() )
$bp_classes[] = 'sentbox';
if ( bp_is_messages_compose_screen() )
$bp_classes[] = 'compose';
if ( bp_is_notices() )
$bp_classes[] = 'notices';
if ( bp_is_user_friend_requests() )
$bp_classes[] = 'friend-requests';
if ( bp_is_create_blog() )
$bp_classes[] = 'create-blog';
/** Groups ************************************************************/
if ( bp_is_group_leave() )
$bp_classes[] = 'leave-group';
if ( bp_is_group_invites() )
$bp_classes[] = 'group-invites';
if ( bp_is_group_members() )
$bp_classes[] = 'group-members';
if ( bp_is_group_forum_topic() )
$bp_classes[] = 'group-forum-topic';
if ( bp_is_group_forum_topic_edit() )
$bp_classes[] = 'group-forum-topic-edit';
if ( bp_is_group_forum() )
$bp_classes[] = 'group-forum';
if ( bp_is_group_admin_page() ) {
$bp_classes[] = 'group-admin';
$bp_classes[] = bp_get_group_current_admin_tab();
}
if ( bp_is_group_create() ) {
$bp_classes[] = 'group-create';
$bp_classes[] = bp_get_groups_current_create_step();
}
if ( bp_is_group_home() )
$bp_classes[] = 'group-home';
if ( bp_is_single_activity() )
$bp_classes[] = 'activity-permalink';
/** Registration ******************************************************/
if ( bp_is_register_page() )
$bp_classes[] = 'registration';
if ( bp_is_activation_page() )
$bp_classes[] = 'activation';
/** Current Component & Action ****************************************/
if ( !bp_is_blog_page() ) {
$bp_classes[] = bp_current_component();
$bp_classes[] = bp_current_action();
}
/** Clean up***********************************************************/
// We don't want WordPress blog classes to appear on non-blog pages.
if ( !bp_is_blog_page() ) {
// Observe WP custom background body class
if ( in_array( 'custom-background', (array) $wp_classes ) )
$bp_classes[] = 'custom-background';
// Preserve any custom classes already set
if ( !empty( $custom_classes ) ) {
$wp_classes = (array) $custom_classes;
} else {
$wp_classes = array();
}
}
// Merge WP classes with BP classes
$classes = array_merge( (array) $bp_classes, (array) $wp_classes );
// Remove any duplicates
$classes = array_unique( $classes );
return apply_filters( 'bp_get_the_body_class', $classes, $bp_classes, $wp_classes, $custom_classes );
}
add_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.