/** * @group bp_follow_total_follow_counts */ public function test_bp_follow_total_follow_counts_cache() { $u1 = $this->factory->user->create(); $u2 = $this->factory->user->create(); // create a follow relationship bp_follow_start_following(array('leader_id' => $u1, 'follower_id' => $u2)); // unfollow bp_follow_stop_following(array('leader_id' => $u1, 'follower_id' => $u2)); // make sure cache is invalidated $this->assertEmpty(wp_cache_get($u1, 'bp_follow_user_followers_count')); $this->assertEmpty(wp_cache_get($u2, 'bp_follow_user_following_count')); // get counts and assert $u1_counts = bp_follow_total_follow_counts(array('user_id' => $u1)); $this->assertSame(0, $u1_counts['followers']); $u2_counts = bp_follow_total_follow_counts(array('user_id' => $u2)); $this->assertSame(0, $u2_counts['following']); }
/** * Add a "Following (X)" tab to the sites directory. * * This is so the logged-in user can filter the site directory to only * sites that the current user is following. */ function add_blog_directory_tab() { if (!is_user_logged_in()) { return; } $counts = bp_follow_total_follow_counts(array('user_id' => bp_loggedin_user_id(), 'follow_type' => 'blogs')); if (empty($counts['following'])) { return false; } ?> <li id="blogs-following"><a href="<?php echo esc_url(bp_loggedin_user_domain() . bp_get_blogs_slug() . '/' . constant('BP_FOLLOW_BLOGS_USER_FOLLOWING_SLUG') . '/'); ?> "><?php printf(__('Following <span>%d</span>', 'bp-follow'), (int) $counts['following']); ?> </a></li><?php }
/** * Modifies 'no activity found' text to be more specific to follow scope. * * @since 1.2.1 * * @author r-a-y * @see bp_follow_has_activities() * @param string $translated_text The translated text. * @param string $untranslated_text The unmodified text. * @return string */ function bp_follow_no_activity_text($translated_text, $untranslated_text) { if ($untranslated_text == 'Sorry, there was no activity found. Please try a different filter.') { if (!bp_is_user() || bp_is_my_profile()) { $follow_counts = bp_follow_total_follow_counts(array('user_id' => bp_loggedin_user_id())); if ($follow_counts['following']) { return __("You are following some users, but they haven't posted yet.", 'bp-follow'); } else { return __("You are not following anyone yet.", 'bp-follow'); } } else { $follow_counts = bp_follow_total_follow_counts(array('user_id' => bp_displayed_user_id())); if (!empty($follow_counts['following'])) { return __("This user is following some users, but they haven't posted yet.", 'bp-follow'); } else { return __("This user isn't following anyone yet.", 'bp-follow'); } } } return $translated_text; }
<span><?php _e("Friend", "boss"); ?> </span> <?php } ?> <?php } ?> <?php if ($showing == "follows") { ?> <span class="count"><?php $followers = bp_follow_total_follow_counts(array("user_id" => bp_get_member_user_id())); echo $followers["followers"]; ?> </span><span><?php _e("Followers", "boss"); ?> </span> <?php } ?> </div> <div class="item-desc"> <p> <?php if (bp_get_member_latest_update()) {
/** * Setup profile / BuddyBar navigation */ public function setup_nav($main_nav = array(), $sub_nav = array()) { global $bp; // Need to change the user ID, so if we're not on a member page, $counts variable is still calculated $user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id(); $counts = bp_follow_total_follow_counts(array('user_id' => $user_id)); // BuddyBar compatibility $domain = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain(); /** FOLLOWERS NAV ************************************************/ bp_core_new_nav_item(array('name' => sprintf(__('Following <span>%d</span>', 'bp-follow'), $counts['following']), 'slug' => $bp->follow->following->slug, 'position' => $this->params['adminbar_myaccount_order'], 'screen_function' => 'bp_follow_screen_following', 'default_subnav_slug' => 'following', 'item_css_id' => 'members-following')); /** FOLLOWING NAV ************************************************/ bp_core_new_nav_item(array('name' => sprintf(__('Followers <span>%d</span>', 'bp-follow'), $counts['followers']), 'slug' => $bp->follow->followers->slug, 'position' => apply_filters('bp_follow_followers_nav_position', 62), 'screen_function' => 'bp_follow_screen_followers', 'default_subnav_slug' => 'followers', 'item_css_id' => 'members-followers')); /** ACTIVITY SUBNAV **********************************************/ // Add activity sub nav item if (bp_is_active('activity') && apply_filters('bp_follow_show_activity_subnav', true)) { bp_core_new_subnav_item(array('name' => _x('Following', 'Activity subnav tab', 'bp-follow'), 'slug' => constant('BP_FOLLOWING_SLUG'), 'parent_url' => trailingslashit($domain . bp_get_activity_slug()), 'parent_slug' => bp_get_activity_slug(), 'screen_function' => 'bp_follow_screen_activity_following', 'position' => 21, 'item_css_id' => 'activity-following')); } // BuddyBar compatibility add_action('bp_adminbar_menus', array($this, 'group_buddybar_items'), 3); do_action('bp_follow_setup_nav'); }
<?php do_action('bp_before_member_header_meta'); ?> </div><!-- #item-header-content --> </div> <div class="table-cell"> <?php $showing = null; //if bp-followers activated then show it. if (function_exists("bp_follow_add_follow_button")) { $showing = "follows"; $followers = bp_follow_total_follow_counts(array("user_id" => bp_displayed_user_id())); } elseif (function_exists("bp_add_friend_button")) { $showing = "friends"; } ?> <div id="item-statistics"> <div class="numbers"> <?php if ($GLOBALS['badgeos']) { ?> <span> <p><?php $points = badgeos_get_users_points(bp_displayed_user_id()); echo number_format($points);