Skip to:
Content
Pages
Categories
Search
Top
Bottom

Missing argument 2 for bp_get_the_body_class


  • peterverkooijen
    Participant

    @peterverkooijen

    Installed v1.1.1. I get this error message in all pages (related to body tag in header.php):

    Missing argument 2 for bp_get_the_body_class() in /serverpath/wp-content/plugins/buddypress/bp-core/bp-core-templatetags.php on line 1593

    function bp_get_the_body_class( $wp_classes, $custom_classes ) {
    global $bp;

    if ( bp_is_blog_page() && is_front_page() && $bp->current_component != BP_HOME_BLOG_SLUG )
    $bp_classes[] = 'home-page';

    if ( bp_is_blog_page() || bp_is_register_page() || bp_is_activation_page() )
    $bp_classes[] = 'blog-page';

    if ( !bp_is_blog_page() && !bp_is_register_page() && !bp_is_activation_page() )
    $bp_classes[] = 'internal-page';

    if ( bp_is_directory() )
    $bp_classes[] = 'directory';

    if ( bp_is_user_profile() && !bp_is_blog_page() )
    $bp_classes[] = 'profile';

    if ( bp_is_activity_component() && !bp_is_blog_page() )
    $bp_classes[] = 'activity';

    if ( bp_is_blogs_component() && !bp_is_blog_page() )
    $bp_classes[] = 'blogs';

    if ( bp_is_wire_component() && !bp_is_blog_page() )
    $bp_classes[] = 'wire';

    if ( bp_is_messages_component() && !bp_is_blog_page() )
    $bp_classes[] = 'messages';

    if ( bp_is_friends_component() && !bp_is_blog_page() )
    $bp_classes[] = 'friends';

    if ( bp_is_groups_component() && !bp_is_blog_page() )
    $bp_classes[] = 'groups';

    if ( bp_is_settings_component() && !bp_is_blog_page() )
    $bp_classes[] = 'settings';

    if ( bp_is_single_item() )
    $bp_classes[] = 'single-item';

    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_friend_requests() )
    $bp_classes[] = 'friend-requests';

    if ( bp_is_user_friends() )
    $bp_classes[] = 'my-friends';

    if ( bp_is_create_blog() )
    $bp_classes[] = 'create-blog';

    if ( bp_is_user_recent_commments() )
    $bp_classes[] = 'recent-comments';

    if ( bp_is_user_recent_posts() )
    $bp_classes[] = 'recent-posts';

    if ( bp_is_user_blogs() && !bp_is_directory() )
    $bp_classes[] = 'my-blogs';

    if ( bp_is_user_groups() && !bp_is_directory() )
    $bp_classes[] = 'my-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() )
    $bp_classes[] = 'group-forum';

    if ( bp_is_group_wire() )
    $bp_classes[] = 'group-wire';

    if ( bp_is_group_admin_page() )
    $bp_classes[] = 'group-admin';

    if ( bp_is_group_create() )
    $bp_classes[] = 'group-create';

    if ( bp_is_group_home() )
    $bp_classes[] = 'group-home';

    if ( bp_is_profile_wire() )
    $bp_classes[] = 'profile-wire';

    if ( bp_is_change_avatar() )
    $bp_classes[] = 'change-avatar';

    if ( bp_is_profile_edit() )
    $bp_classes[] = 'profile-edit';

    if ( bp_is_user_friends_activity() )
    $bp_classes[] = 'friends-activity';

    if ( bp_is_user_activity() )
    $bp_classes[] = 'my-activity';

    if ( bp_is_register_page() )
    $bp_classes[] = 'registration';

    if ( bp_is_activation_page() )
    $bp_classes[] = 'activation';

    if ( is_user_logged_in() )
    $bp_classes[] = 'logged-in';

    /* Add the current_component, current_action into the bp classes */
    if ( !bp_is_blog_page() ) {
    if ( !empty( $bp->current_component ) )
    $bp_classes[] = $bp->current_component;

    if ( !empty( $bp->current_action ) )
    $bp_classes[] = $bp->current_action;
    }

    /* We don't want WordPress blog classes to appear on non-blog pages. */
    if ( !bp_is_blog_page() || is_home() ) {
    /* 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 )

Viewing 6 replies - 1 through 6 (of 6 total)

  • Paul Wong-Gibbs
    Keymaster

    @djpaul

    Are you using a custom theme and have called bp_the_body_class() directly? A quick look at the code reveals that will cause missing argument errors but if this is on the default theme the error is a bit deeper and we’ll need to dig further.


    German Laullon
    Participant

    @laullon

    I’ve made this changes:

    1593c1593

    < function bp_get_the_body_class( $wp_classes, $custom_classes ) {

    > function bp_get_the_body_class( $wp_classes, $custom_classes=”” ) {

    1732c1732

    < $wp_classes = (array) $custom_classes;

    > $wp_classes += (array) $custom_classes;

    1734c1734

    < $wp_classes = array();

    > $wp_classes += array();

    And now works….

    ( < org > new )


    peterverkooijen
    Participant

    @peterverkooijen

    @DJPaul, my site has lots of messy customization, but I saw the same error when I put back the original template. Not 100% sure. Please check if you get the chance.

    I’ll try German Laullon’s edits.


    Joss Winn
    Participant

    @josswinn

    Hi, I’ve upgraded to 1.1.1 and am getting lots of these warnings, too. A custom theme from dev.wpmu.org

    I’ll post over there to see if they claim responsibility!


    r-a-y
    Keymaster

    @r-a-y

    Just encountered this issue, this is most likely because everyone in this thread is using the deprecated /bp-themes/ format.

    I tried German’s fix but that duplicated some CSS classes.

    Since I was already using some form of filter to add CSS classes to the body, I removed the bp_get_the_body_class() filter.

    If you want to do the same, put this somewhere in your theme’s functions.php:

    remove_filter( 'body_class', 'bp_get_the_body_class', 10, 2 );


    peterverkooijen
    Participant

    @peterverkooijen

    Thanks for those clues r-a-y, but I have no idea what you’re saying here.

    I had to go through a lot of headaches to get the body class tags to work the first time around. I’m now about to start on upgrading to 1.1.3 (or hopefully 1.2).

    Can anyone explain in plain English how to get the right body tags? Which piece of code in which file generates them? Why does it break with some themes?

    I have my own custom theme. German’s changes are too much of a hack. I’m trying to make a clean new start.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Missing argument 2 for bp_get_the_body_class’ is closed to new replies.
Skip to toolbar