Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding comment counts to BuddyBar

  • I’ve been trying to make a custom buddybar tweak (following these epic directions: http://codex.buddypress.org/how-to-guides/modifying-the-buddypress-admin-bar/ ) to show any pending comments I may have per blog.

    The problem I ran into is having the foreach blog loop call the site ID:

    if ( is_array( $blogs ) && (int)$blogs ) {
    $counter = 0;
    foreach ( (array)$blogs as $blog ) {
    $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
    $site_url = esc_attr( $blog->siteurl );
    $site_id = esc_attr( $blog->id );
    $site_id = 'wp_' .$site_id. '_comments';
    
    $numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $site_id WHERE comment_approved = '0'");
    if (0 < $numcomms) $numcomms = number_format($numcomms);
    
    echo '
    ';
    echo '' . esc_html( $blog->name ) . '';
    
    echo '
    
        ';
        echo '
        ' . __( 'Dashboard', 'buddypress' ) . '
    
        ';
        echo '
        ' . __( 'New Post', 'buddypress' ) . '
    
        ';
        echo '
        ' . __( 'Manage Posts', 'buddypress' ) . '
    
        ';
        echo '
        ' . __( 'Manage Comments', 'buddypress' ) . ' (' . $site_id . ')';
        echo '
    
        '; 
    
    echo '';
    echo '';
    $counter++;
    }
    }

    The numbers it spits back are wrong. So I think $site_id = esc_attr( $blog->id ); isn’t right but I’m not sure where I went off the path on that one.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Adding comment counts to BuddyBar’ is closed to new replies.