/**
 * Output the ID of the current blog in the loop.
 *
 * @since BuddyPress (1.7.0)
 */
function bp_blog_id()
{
    echo bp_get_blog_id();
}
Example #2
-1
 /**
  * Static method to generate a follow blogs button.
  */
 public static function get_button($args = '')
 {
     global $blogs_template;
     $r = wp_parse_args($args, array('leader_id' => !empty($blogs_template->in_the_loop) ? bp_get_blog_id() : get_current_blog_id(), 'follower_id' => bp_loggedin_user_id(), 'link_text' => '', 'link_title' => '', 'wrapper_class' => '', 'link_class' => '', 'wrapper' => 'div'));
     if (!$r['leader_id'] || !$r['follower_id']) {
         return false;
     }
     // if we're checking during a blog loop, then follow status is already
     // queried via bulk_inject_follow_blog_status()
     if (!empty($blogs_template->in_the_loop) && $r['follower_id'] == bp_loggedin_user_id() && $r['leader_id'] == bp_get_blog_id()) {
         $is_following = $blogs_template->blog->is_following;
         // else we manually query the follow status
     } else {
         $is_following = bp_follow_is_following(array('leader_id' => $r['leader_id'], 'follower_id' => $r['follower_id'], 'follow_type' => 'blogs'));
     }
     // setup some variables
     if ($is_following) {
         $id = 'following';
         $action = 'unfollow';
         $link_text = _x('Unfollow', 'Button', 'bp-follow');
         if (empty($blogs_template->in_the_loop)) {
             $link_text = _x('Unfollow Site', 'Button', 'bp-follow');
         }
         if (empty($r['link_text'])) {
             $r['link_text'] = $link_text;
         }
     } else {
         $id = 'not-following';
         $action = 'follow';
         $link_text = _x('Follow', 'Button', 'bp-follow');
         if (empty($blogs_template->in_the_loop)) {
             $link_text = _x('Follow Site', 'Button', 'bp-follow');
         }
         if (empty($r['link_text'])) {
             $r['link_text'] = $link_text;
         }
     }
     $wrapper_class = 'follow-button ' . $id;
     if (!empty($r['wrapper_class'])) {
         $wrapper_class .= ' ' . esc_attr($r['wrapper_class']);
     }
     $link_class = $action;
     if (!empty($r['link_class'])) {
         $link_class .= ' ' . esc_attr($r['link_class']);
     }
     // setup the button arguments
     $button = array('id' => $id, 'component' => 'follow', 'must_be_logged_in' => true, 'block_self' => false, 'wrapper_class' => $wrapper_class, 'wrapper_id' => 'follow-button-' . (int) $r['leader_id'], 'link_href' => wp_nonce_url(add_query_arg('blog_id', $r['leader_id'], home_url('/')), "bp_follow_blog_{$action}", "bpfb-{$action}"), 'link_text' => esc_attr($r['link_text']), 'link_title' => esc_attr($r['link_title']), 'link_id' => $action . '-' . (int) $r['leader_id'], 'link_class' => $link_class, 'wrapper' => !empty($r['wrapper']) ? esc_attr($r['wrapper']) : false);
     // Filter and return the HTML button
     return bp_get_button(apply_filters('bp_follow_blogs_get_follow_button', $button, $r, $is_following));
 }