本文整理汇总了PHP中friends_get_total_friend_count函数的典型用法代码示例。如果您正苦于以下问题:PHP friends_get_total_friend_count函数的具体用法?PHP friends_get_total_friend_count怎么用?PHP friends_get_total_friend_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了friends_get_total_friend_count函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup_nav
/**
* Setup BuddyBar navigation
*
* @global obj $bp
*/
function setup_nav()
{
global $bp;
// Add 'Friends' to the main navigation
$main_nav = array('name' => sprintf(__('Friends <span>%d</span>', 'buddypress'), friends_get_total_friend_count()), 'slug' => $this->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id);
$friends_link = trailingslashit($bp->loggedin_user->domain . bp_get_friends_slug());
// Add the subnav items to the friends nav item
$sub_nav[] = array('name' => __('Friendships', 'buddypress'), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends');
$sub_nav[] = array('name' => __('Requests', 'buddypress'), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_is_my_profile());
parent::setup_nav($main_nav, $sub_nav);
}
示例2: setup_nav
/**
* Setup BuddyBar navigation
*
* @global BuddyPress $bp The one true BuddyPress instance
*/
public function setup_nav($main_nav = array(), $sub_nav = array())
{
global $bp;
$sub_nav = array();
// Add 'Friends' to the main navigation
$main_nav = array('name' => sprintf(__('Friends <span>%d</span>', 'buddypress'), friends_get_total_friend_count()), 'slug' => $this->slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $bp->friends->id);
// Determine user to use
if (bp_displayed_user_domain()) {
$user_domain = bp_displayed_user_domain();
} elseif (bp_loggedin_user_domain()) {
$user_domain = bp_loggedin_user_domain();
} else {
return;
}
$friends_link = trailingslashit($user_domain . bp_get_friends_slug());
// Add the subnav items to the friends nav item
$sub_nav[] = array('name' => __('Friendships', 'buddypress'), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends');
$sub_nav[] = array('name' => __('Requests', 'buddypress'), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => bp_get_friends_slug(), 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => bp_core_can_edit_settings());
parent::setup_nav($main_nav, $sub_nav);
}
示例3: bp_friends_get_profile_stats
/**
* Return the number of friends in user's profile.
*
* @since 2.0.0
*
* @param array|string $args before|after|user_id.
* @return string HTML for stats output.
*/
function bp_friends_get_profile_stats($args = '')
{
// Parse the args.
$r = bp_parse_args($args, array('before' => '<li class="bp-friends-profile-stats">', 'after' => '</li>', 'user_id' => bp_displayed_user_id(), 'friends' => 0, 'output' => ''), 'friends_get_profile_stats');
// Allow completely overloaded output.
if (empty($r['output'])) {
// Only proceed if a user ID was passed.
if (!empty($r['user_id'])) {
// Get the user's friends.
if (empty($r['friends'])) {
$r['friends'] = absint(friends_get_total_friend_count($r['user_id']));
}
// If friends exist, show some formatted output.
$r['output'] = $r['before'] . sprintf(_n('%s friend', '%s friends', $r['friends'], 'buddypress'), '<strong>' . $r['friends'] . '</strong>') . $r['after'];
}
}
/**
* Filters the number of friends in user's profile.
*
* @since 2.0.0
*
* @param string $value Formatted string displaying total friends count.
* @param array $r Array of arguments for string formatting and output.
*/
return apply_filters('bp_friends_get_profile_stats', $r['output'], $r);
}
示例4: friends_check_user_has_friends
/**
* Check whether a given user has any friends.
*
* @param int $user_id ID of the user whose friends are being checked.
* @return bool True if the user has friends, otherwise false.
*/
function friends_check_user_has_friends($user_id)
{
$friend_count = friends_get_total_friend_count($user_id);
if (empty($friend_count)) {
return false;
}
if (!(int) $friend_count) {
return false;
}
return true;
}
示例5: bp_get_total_friend_count
function bp_get_total_friend_count($user_id = 0)
{
return apply_filters('bp_get_total_friend_count', friends_get_total_friend_count($user_id));
}
示例6: bp_friends_prime_mentions_results
/**
* Used by the Activity component's @mentions to print a JSON list of the current user's friends.
*
* This is intended to speed up @mentions lookups for a majority of use cases.
*
* @since 2.1.0
*
* @see bp_activity_mentions_script()
*/
function bp_friends_prime_mentions_results()
{
if (!bp_activity_maybe_load_mentions_scripts()) {
return;
}
// Bail out if the site has a ton of users.
if (is_multisite() && wp_is_large_network('users')) {
return;
}
if (friends_get_total_friend_count(get_current_user_id()) > 150) {
return;
}
$friends_query = array('count_total' => '', 'populate_extras' => false, 'type' => 'alphabetical', 'user_id' => get_current_user_id());
$friends_query = new BP_User_Query($friends_query);
$results = array();
foreach ($friends_query->results as $user) {
$result = new stdClass();
$result->ID = $user->user_nicename;
$result->image = bp_core_fetch_avatar(array('html' => false, 'item_id' => $user->ID));
if (!empty($user->display_name) && !bp_disable_profile_sync()) {
$result->name = $user->display_name;
} else {
$result->name = bp_core_get_user_displayname($user->ID);
}
$results[] = $result;
}
wp_localize_script('bp-mentions', 'BP_Suggestions', array('friends' => $results));
}
示例7: setup_nav
/**
* Set up component navigation.
*
* @since 1.5.0
*
* @see BP_Component::setup_nav() for a description of arguments.
*
* @param array $main_nav Optional. See BP_Component::setup_nav() for
* description.
* @param array $sub_nav Optional. See BP_Component::setup_nav() for
* description.
*/
public function setup_nav($main_nav = array(), $sub_nav = array())
{
// Determine user to use.
if (bp_displayed_user_domain()) {
$user_domain = bp_displayed_user_domain();
} elseif (bp_loggedin_user_domain()) {
$user_domain = bp_loggedin_user_domain();
} else {
return;
}
$access = bp_core_can_edit_settings();
$slug = bp_get_friends_slug();
$friends_link = trailingslashit($user_domain . $slug);
// Add 'Friends' to the main navigation.
$count = friends_get_total_friend_count();
$class = 0 === $count ? 'no-count' : 'count';
$main_nav = array('name' => sprintf(__('Friends <span class="%s">%s</span>', 'buddypress'), esc_attr($class), bp_core_number_format($count)), 'slug' => $slug, 'position' => 60, 'screen_function' => 'friends_screen_my_friends', 'default_subnav_slug' => 'my-friends', 'item_css_id' => $this->id);
// Add the subnav items to the friends nav item.
$sub_nav[] = array('name' => _x('Friendships', 'Friends screen sub nav', 'buddypress'), 'slug' => 'my-friends', 'parent_url' => $friends_link, 'parent_slug' => $slug, 'screen_function' => 'friends_screen_my_friends', 'position' => 10, 'item_css_id' => 'friends-my-friends');
$sub_nav[] = array('name' => _x('Requests', 'Friends screen sub nav', 'buddypress'), 'slug' => 'requests', 'parent_url' => $friends_link, 'parent_slug' => $slug, 'screen_function' => 'friends_screen_requests', 'position' => 20, 'user_has_access' => $access);
parent::setup_nav($main_nav, $sub_nav);
}
示例8: bp_friends_get_profile_stats
/**
* Return the number of friends in user's profile.
*
* @since BuddyPress (2.0.0)
*
* @param array $args before|after|user_id
* @return string HTML for stats output.
*/
function bp_friends_get_profile_stats($args = '')
{
// Parse the args
$r = bp_parse_args($args, array('before' => '<li class="bp-friends-profile-stats">', 'after' => '</li>', 'user_id' => bp_displayed_user_id(), 'friends' => 0, 'output' => ''), 'friends_get_profile_stats');
// Allow completely overloaded output
if (empty($r['output'])) {
// Only proceed if a user ID was passed
if (!empty($r['user_id'])) {
// Get the user's friends
if (empty($r['friends'])) {
$r['friends'] = absint(friends_get_total_friend_count($r['user_id']));
}
// If friends exist, show some formatted output
$r['output'] = $r['before'] . sprintf(_n('%s friend', '%s friends', $r['friends'], 'buddypress'), '<strong>' . $r['friends'] . '</strong>') . $r['after'];
}
}
// Filter and return
return apply_filters('bp_friends_get_profile_stats', $r['output'], $r);
}
示例9: kleo_bp_get_total_friend_count_member_type
function kleo_bp_get_total_friend_count_member_type()
{
$user_id = get_current_user_id();
$count = friends_get_total_friend_count($user_id);
$member_type = bp_get_current_member_type();
if (bp_is_directory() && $member_type) {
global $bp, $wpdb;
$friends = $wpdb->get_results("SELECT count(1) as count FROM {$bp->friends->table_name} bpf\n LEFT JOIN {$wpdb->term_relationships} tr ON (bpf.initiator_user_id = tr.object_id || bpf.friend_user_id = tr.object_id )\n LEFT JOIN {$wpdb->terms} t ON t.term_id = tr.term_taxonomy_id\n WHERE t.slug = '" . $member_type . "' AND (bpf.initiator_user_id = {$user_id} || bpf.friend_user_id = {$user_id} ) AND tr.object_id != {$user_id} AND bpf.is_confirmed = 1", ARRAY_A);
$count = 0;
if (isset($friends['0']['count']) && is_numeric($friends['0']['count'])) {
$count = $friends['0']['count'];
}
}
return $count;
}
示例10: widget
/**
* Displays the widget
*
* @package BP_Show_Friends_Widget
* @since 2.0
*
* @uses bp_is_user() to check we're on a user's profile
* @uses bp_displayed_user_id() to get displayed user id
* @uses bp_loggedin_user_id() to get loggedin user id
* @uses bp_core_get_user_domain() to build the user domain
* @uses bp_get_friends_slug() to get the friends component slug
* @uses bp_core_get_user_displayname() to get the display name of the user
* @uses is_user_logged_in() to check the visitor is logged in
* @uses friends_get_total_friend_count() to get the total friends for the user
* @uses BP_Show_Friends_Widget->list_friends() to output the user's friends
*/
public function widget($args = array(), $instance = array())
{
$user_id = false;
$user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id();
if (empty($user_id)) {
return;
}
extract($args);
$instance['per_page'] = !empty($instance['per_page']) ? $instance['per_page'] : 5;
$instance['size'] = !empty($instance['size']) ? $instance['size'] : 50;
$user_all_friends_url = trailingslashit(bp_core_get_user_domain($user_id) . bp_get_friends_slug());
$user_name = bp_core_get_user_displayname($user_id);
?>
<?php
if (bp_is_user() || is_user_logged_in()) {
echo $before_widget;
echo $before_title;
if (bp_is_my_profile()) {
printf(__('My Friends - <a href="%1$s">All (%2$s)</a>', 'bp-show-friends'), $user_all_friends_url, friends_get_total_friend_count($user_id));
} else {
printf(__('%1$s's Friends - <a href="%2$s">All (%3$s)</a>', 'bp-show-friends'), $user_name, $user_all_friends_url, friends_get_total_friend_count($user_id));
}
echo $after_title;
?>
<div class="item-options bpsf-list-options">
<a href="#" class="bp-show-friends-action current" data-type="active" data-number="<?php
echo intval($this->number);
?>
"><?php
_e('Recently Actives', 'bp-show-friends');
?>
</a> |
<a href="#" class="bp-show-friends-action" data-type="online" data-number="<?php
echo intval($this->number);
?>
"><?php
_e('Online Friends', 'bp-show-friends');
?>
</a>
</div>
<?php
$this->list_friends($instance['per_page'], $instance['size']);
echo $after_widget;
?>
<?php
}
}
示例11: bp_member_last_active
<div class="item-meta">
<div class="activity">
<?php
bp_member_last_active();
?>
</div>
<?php
if ($showing == "friends") {
?>
<span class="count"><?php
echo friends_get_total_friend_count(bp_get_member_user_id());
?>
</span>
<?php
if (friends_get_total_friend_count(bp_get_member_user_id()) > 1) {
?>
<span><?php
_e("Friends", "boss");
?>
</span>
<?php
} else {
?>
<span><?php
_e("Friend", "boss");
?>
</span>
<?php
}
?>
示例12: _e
</p>
<p><?php
_e("Followers", "boss");
?>
</p>
</span>
<?php
}
?>
<?php
if ($showing == "friends") {
?>
<span>
<p><?php
echo (int) friends_get_total_friend_count();
?>
</p>
<p><?php
_e("Friends", "boss");
?>
</p>
</span>
<?php
}
?>
</div>
<div id="item-buttons" class="profile">
示例13: bmf_get_total_mutual_friend_count
/**
* Return mutual friends counts for the current member in the loop.
*
* @since 1.5
*
*
* @param array $classes Array of custom classes
*
* @return string Row class of the member
*/
function bmf_get_total_mutual_friend_count()
{
global $members_template;
if (!is_user_logged_in()) {
return;
}
$mutual_friends_count = bmf_mutual_friend_total_count($members_template->member->ID);
if (get_current_user_id() == $members_template->member->ID) {
return;
}
$mutual_friends_link = '';
$show_mutual_friends_count = apply_filters('bmf_show_mutual_friend_count', true);
if ($show_mutual_friends_count && 0 < absint($mutual_friends_count)) {
$mutual_friends_link = '<a href="" data-action="bmf_mutual_friends_dialog" data-effect="mfp-zoom-in" data-user-id="' . $members_template->member->ID . '"
class="mutual-friends">
' . sprintf(_n('%s mutual friend', '%s mutual friends', $mutual_friends_count, 'bmf'), $mutual_friends_count) . '
</a>';
} else {
$friends_count = friends_get_total_friend_count($members_template->member->ID);
$show_friends_count = apply_filters('bmf_show_friend_count', true);
if (0 < $friends_count && $show_friends_count) {
$mutual_friends_link = '<a href="" data-action="bmf_friends_dialog" data-effect="mfp-zoom-in" data-user-id="' . $members_template->member->ID . '"
class="mutual-friends">
' . sprintf(_n('%s friend', '%s friends', $friends_count, 'bmf'), $friends_count) . '
</a>';
}
}
return apply_filters('bmf_get_total_mutual_friend_count', $mutual_friends_link);
}