当前位置: 首页>>代码示例>>PHP>>正文


PHP BP_Friends_Friendship::total_friend_count方法代码示例

本文整理汇总了PHP中BP_Friends_Friendship::total_friend_count方法的典型用法代码示例。如果您正苦于以下问题:PHP BP_Friends_Friendship::total_friend_count方法的具体用法?PHP BP_Friends_Friendship::total_friend_count怎么用?PHP BP_Friends_Friendship::total_friend_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BP_Friends_Friendship的用法示例。


在下文中一共展示了BP_Friends_Friendship::total_friend_count方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: bp_friends_random_friends

function bp_friends_random_friends() {
	global $bp;

	if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . $bp->displayed_user->id, 'bp' ) ) {
		$friend_ids = BP_Friends_Friendship::get_random_friends( $bp->displayed_user->id );
		wp_cache_set( 'friends_friend_ids_' . $bp->displayed_user->id, $friend_ids, 'bp' );
	}
?>
	<div class="info-group">
		<h4><?php bp_word_or_name( __( "My Friends", 'buddypress' ), __( "%s's Friends", 'buddypress' ) ) ?>  (<?php echo BP_Friends_Friendship::total_friend_count( $bp->displayed_user->id ) ?>) <span><a href="<?php echo $bp->displayed_user->domain . $bp->friends->slug ?>"><?php _e('See All', 'buddypress') ?> &rarr;</a></span></h4>

		<?php if ( $friend_ids ) { ?>
			<ul class="horiz-gallery">
			<?php for ( $i = 0; $i < count( $friend_ids ); $i++ ) { ?>
				<li>
					<a href="<?php echo bp_core_get_user_domain( $friend_ids[$i] ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $friend_ids[$i], 'type' => 'thumb' ) ) ?></a>
					<h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5>
				</li>
			<?php } ?>
			</ul>
		<?php } else { ?>
			<div id="message" class="info">
				<p><?php bp_word_or_name( __( "You haven't added any friend connections yet.", 'buddypress' ), __( "%s hasn't created any friend connections yet.", 'buddypress' ) ) ?></p>
			</div>
		<?php } ?>
		<div class="clear"></div>
	</div>
<?php
}
开发者ID:n-sane,项目名称:zaroka,代码行数:29,代码来源:bp-friends-templatetags.php

示例2: populate_extras

 function populate_extras()
 {
     global $bp;
     if (function_exists('friends_install')) {
         $this->total_friends = BP_Friends_Friendship::total_friend_count($this->id);
         if ($this->total_friends) {
             if (1 == $this->total_friends) {
                 $this->total_friends .= ' ' . __('friend', 'buddypress');
             } else {
                 $this->total_friends .= ' ' . __('friends', 'buddypress');
             }
             $this->total_friends = '<a href="' . $this->user_url . $bp->friends->slug . '" title="' . sprintf(__("%s's friend list", 'buddypress'), $this->fullname) . '">' . $this->total_friends . '</a>';
         }
     }
     if (function_exists('bp_blogs_install')) {
         if ($this->total_blogs) {
             if (1 == $this->total_blogs) {
                 $this->total_blogs .= ' ' . __('blog', 'buddypress');
             } else {
                 $this->total_blogs .= ' ' . __('blogs', 'buddypress');
             }
             $this->total_blogs = '<a href="' . $this->user_url . $bp->blogs->slug . '" title="' . sprintf(__("%s's blog list", 'buddypress'), $this->fullname) . '">' . $this->total_blogs . '</a>';
         }
     }
     if (function_exists('groups_install')) {
         $this->total_groups = BP_Groups_Member::total_group_count($this->id);
         if ($this->total_groups) {
             if (1 == $this->total_groups) {
                 $this->total_groups .= ' ' . __('group', 'buddypress');
             } else {
                 $this->total_groups .= ' ' . __('groups', 'buddypress');
             }
             $this->total_groups = '<a href="' . $this->user_url . $bp->groups->slug . '" title="' . sprintf(__("%s's group list", 'buddypress'), $this->fullname) . '">' . $this->total_groups . '</a>';
         }
     }
 }
开发者ID:alvaropereyra,项目名称:shrekcms,代码行数:36,代码来源:bp-core-classes.php

示例3: bp_friends_random_friends

/**
 * Output a block of random friends.
 *
 * No longer used in BuddyPress.
 *
 * @todo Deprecate
 */
function bp_friends_random_friends()
{
    if (!($friend_ids = wp_cache_get('friends_friend_ids_' . bp_displayed_user_id(), 'bp'))) {
        $friend_ids = BP_Friends_Friendship::get_random_friends(bp_displayed_user_id());
        wp_cache_set('friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp');
    }
    ?>

	<div class="info-group">
		<h4><?php 
    bp_word_or_name(__("My Friends", 'buddypress'), __("%s's Friends", 'buddypress'));
    ?>
  (<?php 
    echo BP_Friends_Friendship::total_friend_count(bp_displayed_user_id());
    ?>
) <span><a href="<?php 
    echo trailingslashit(bp_displayed_user_domain() . bp_get_friends_slug());
    ?>
"><?php 
    _e('See All', 'buddypress');
    ?>
</a></span></h4>

		<?php 
    if ($friend_ids) {
        ?>

			<ul class="horiz-gallery">

			<?php 
        for ($i = 0, $count = count($friend_ids); $i < $count; ++$i) {
            ?>

				<li>
					<a href="<?php 
            echo bp_core_get_user_domain($friend_ids[$i]);
            ?>
"><?php 
            echo bp_core_fetch_avatar(array('item_id' => $friend_ids[$i], 'type' => 'thumb'));
            ?>
</a>
					<h5><?php 
            echo bp_core_get_userlink($friend_ids[$i]);
            ?>
</h5>
				</li>

			<?php 
        }
        ?>

			</ul>

		<?php 
    } else {
        ?>

			<div id="message" class="info">
				<p><?php 
        bp_word_or_name(__("You haven't added any friend connections yet.", 'buddypress'), __("%s hasn't created any friend connections yet.", 'buddypress'));
        ?>
</p>
			</div>

		<?php 
    }
    ?>

		<div class="clear"></div>
	</div>

<?php 
}
开发者ID:mawilliamson,项目名称:wordpress,代码行数:80,代码来源:bp-friends-template.php

示例4: the_invite

 function the_invite()
 {
     global $group_id;
     $this->in_the_loop = true;
     $user_id = $this->next_invite();
     $this->invite = new stdClass();
     $this->invite->user = $this->invite_data[$user_id];
     // This method previously populated the user object with
     // BP_Core_User. We manually configure BP_Core_User data for
     // backward compatibility.
     if (bp_is_active('xprofile')) {
         $this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
     }
     $this->invite->user->avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_mini = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Avatar of %s', 'buddypress'), $this->invite->user->fullname), 'width' => 30, 'height' => 30));
     $this->invite->user->email = $this->invite->user->user_email;
     $this->invite->user->user_url = bp_core_get_user_domain($user_id, $this->invite->user->user_nicename, $this->invite->user->user_login);
     $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
     $this->invite->user->last_active = bp_core_get_last_activity($this->invite->user->last_activity, __('active %s', 'buddypress'));
     if (bp_is_active('groups')) {
         $total_groups = BP_Groups_Member::total_group_count($user_id);
         $this->invite->user->total_groups = sprintf(_n('%d group', '%d groups', $total_groups, 'buddypress'), $total_groups);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     $this->invite->user->total_blogs = null;
     $this->invite->group_id = $group_id;
     // Globaled in bp_group_has_invites()
     if (0 == $this->current_invite) {
         // loop has just started
         do_action('loop_start');
     }
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:38,代码来源:bp-groups-template.php

示例5: bp_admin_repair_friend_count

/**
 * Recalculate friend counts for each user.
 *
 * @since BuddyPress (2.0.0)
 *
 * @return array
 */
function bp_admin_repair_friend_count()
{
    global $wpdb;
    if (!bp_is_active('friends')) {
        return;
    }
    $statement = __('Counting the number of friends for each user&hellip; %s', 'buddypress');
    $result = __('Failed!', 'buddypress');
    $sql_delete = "DELETE FROM {$wpdb->usermeta} WHERE meta_key IN ( 'total_friend_count' );";
    if (is_wp_error($wpdb->query($sql_delete))) {
        return array(1, sprintf($statement, $result));
    }
    $bp = buddypress();
    // Walk through all users on the site
    $total_users = $wpdb->get_row("SELECT count(ID) as c FROM {$wpdb->users}")->c;
    $updated = array();
    if ($total_users > 0) {
        $per_query = 500;
        $offset = 0;
        while ($offset < $total_users) {
            // Only bother updating counts for users who actually have friendships
            $friendships = $wpdb->get_results($wpdb->prepare("SELECT initiator_user_id, friend_user_id FROM {$bp->friends->table_name} WHERE is_confirmed = 1 AND ( ( initiator_user_id > %d AND initiator_user_id <= %d ) OR ( friend_user_id > %d AND friend_user_id <= %d ) )", $offset, $offset + $per_query, $offset, $offset + $per_query));
            // The previous query will turn up duplicates, so we
            // filter them here
            foreach ($friendships as $friendship) {
                if (!isset($updated[$friendship->initiator_user_id])) {
                    BP_Friends_Friendship::total_friend_count($friendship->initiator_user_id);
                    $updated[$friendship->initiator_user_id] = 1;
                }
                if (!isset($updated[$friendship->friend_user_id])) {
                    BP_Friends_Friendship::total_friend_count($friendship->friend_user_id);
                    $updated[$friendship->friend_user_id] = 1;
                }
            }
            $offset += $per_query;
        }
    } else {
        return array(2, sprintf($statement, $result));
    }
    return array(0, sprintf($statement, __('Complete!', 'buddypress')));
}
开发者ID:un1coin,项目名称:ovn-space,代码行数:48,代码来源:bp-core-admin-tools.php

示例6: delete_all_for_user

 function delete_all_for_user($user_id)
 {
     global $nxtdb, $bp;
     // Get friends of $user_id
     $friend_ids = BP_Friends_Friendship::get_friend_user_ids($user_id);
     // Delete all friendships related to $user_id
     $nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id));
     // Delete friend request notifications for members who have a notification from this user.
     $nxtdb->query($nxtdb->prepare("DELETE FROM {$bp->core->table_name_notifications} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id));
     // Loop through friend_ids and update their counts
     foreach ((array) $friend_ids as $friend_id) {
         BP_Friends_Friendship::total_friend_count($friend_id);
     }
 }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:14,代码来源:bp-friends-classes.php

示例7: friends_get_friend_count_for_user

/**
 * Get a total friend count for a given user.
 *
 * @param int $user_id Optional. ID of the user whose friendships you are
 *        counting. Default: displayed user (if any), otherwise logged-in user.
 * @return int Friend count for the user.
 */
function friends_get_friend_count_for_user($user_id)
{
    return BP_Friends_Friendship::total_friend_count($user_id);
}
开发者ID:eresyyl,项目名称:mk,代码行数:11,代码来源:bp-friends-functions.php

示例8: populate_extras

 /**
  * Populates extra fields such as group and friendship counts.
  */
 public function populate_extras()
 {
     if (bp_is_active('friends')) {
         $this->total_friends = BP_Friends_Friendship::total_friend_count($this->id);
     }
     if (bp_is_active('groups')) {
         $this->total_groups = BP_Groups_Member::total_group_count($this->id);
         $this->total_groups = sprintf(_n('%d group', '%d groups', $this->total_groups, 'buddypress'), $this->total_groups);
     }
 }
开发者ID:kosir,项目名称:thatcamp-org,代码行数:13,代码来源:class-bp-core-user.php

示例9: delete_all_for_user

 /**
  * Delete all friendships and friend notifications related to a user.
  *
  * @param int $user_id ID of the user being expunged.
  */
 public static function delete_all_for_user($user_id)
 {
     global $wpdb;
     $bp = buddypress();
     // Get friends of $user_id
     $friend_ids = BP_Friends_Friendship::get_friend_user_ids($user_id);
     // Delete all friendships related to $user_id
     $wpdb->query($wpdb->prepare("DELETE FROM {$bp->friends->table_name} WHERE friend_user_id = %d OR initiator_user_id = %d", $user_id, $user_id));
     // Delete friend request notifications for members who have a
     // notification from this user.
     if (bp_is_active('notifications')) {
         $wpdb->query($wpdb->prepare("DELETE FROM {$bp->notifications->table_name} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id));
     }
     // Loop through friend_ids and update their counts
     foreach ((array) $friend_ids as $friend_id) {
         BP_Friends_Friendship::total_friend_count($friend_id);
     }
 }
开发者ID:AceMedia,项目名称:BuddyPress,代码行数:23,代码来源:class-bp-friends-friendship.php

示例10: delete_all_for_user

 /**
  * Delete all friendships and friend notifications related to a user.
  *
  * @since 1.0.0
  *
  * @param int $user_id ID of the user being expunged.
  */
 public static function delete_all_for_user($user_id)
 {
     global $wpdb;
     $bp = buddypress();
     // Get all friendships, of any status, for the user.
     $friendships = self::get_friendships($user_id);
     $friend_ids = array();
     $friendship_ids = array();
     foreach ($friendships as $friendship) {
         $friendship_ids[] = $friendship->id;
         if ($friendship->is_confirmed) {
             $friend_ids[] = $friendship->friend_user_id == $user_id ? $friendship->initiator_user_id : $friendship->friend_user_id;
         }
     }
     // Delete the friendships from the database.
     if ($friendship_ids) {
         $friendship_ids_sql = implode(',', wp_parse_id_list($friendship_ids));
         $wpdb->query("DELETE FROM {$bp->friends->table_name} WHERE id IN ({$friendship_ids_sql})");
     }
     // Delete friend request notifications for members who have a
     // notification from this user.
     if (bp_is_active('notifications')) {
         $wpdb->query($wpdb->prepare("DELETE FROM {$bp->notifications->table_name} WHERE component_name = 'friends' AND ( component_action = 'friendship_request' OR component_action = 'friendship_accepted' ) AND item_id = %d", $user_id));
     }
     // Clean up the friendships cache.
     foreach ($friendship_ids as $friendship_id) {
         wp_cache_delete($friendship_id, 'bp_friends_friendships');
     }
     // Loop through friend_ids to scrub user caches and update total count metas.
     foreach ((array) $friend_ids as $friend_id) {
         // Delete cached friendships.
         wp_cache_delete($friend_id, 'bp_friends_friendships_for_user');
         BP_Friends_Friendship::total_friend_count($friend_id);
     }
     // Delete cached friendships.
     wp_cache_delete($user_id, 'bp_friends_friendships_for_user');
 }
开发者ID:buddypress,项目名称:BuddyPress-build,代码行数:44,代码来源:class-bp-friends-friendship.php

示例11: populate_extras

	function populate_extras() {
		global $bp;

		if ( function_exists('friends_install') )
			$this->total_friends = BP_Friends_Friendship::total_friend_count( $this->id );

		if ( function_exists('groups_install') ) {
			$this->total_groups = BP_Groups_Member::total_group_count( $this->id );

			if ( $this->total_groups ) {
				if ( 1 == $this->total_groups )
					$this->total_groups .= ' ' . __( 'group', 'buddypress' );
				else
					$this->total_groups .= ' ' . __( 'groups', 'buddypress' );
			}
		}
	}
开发者ID:n-sane,项目名称:zaroka,代码行数:17,代码来源:bp-core-classes.php

示例12: the_invite

 /**
  * Sets up the invite to show.
  *
  * @since 1.1.0
  */
 public function the_invite()
 {
     global $group_id;
     $this->in_the_loop = true;
     $user_id = $this->next_invite();
     $this->invite = new stdClass();
     $this->invite->user = $this->invite_data[$user_id];
     // This method previously populated the user object with
     // BP_Core_User. We manually configure BP_Core_User data for
     // backward compatibility.
     if (bp_is_active('xprofile')) {
         $this->invite->user->profile_data = BP_XProfile_ProfileData::get_all_for_user($user_id);
     }
     $this->invite->user->avatar = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'full', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_thumb = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname)));
     $this->invite->user->avatar_mini = bp_core_fetch_avatar(array('item_id' => $user_id, 'type' => 'thumb', 'alt' => sprintf(__('Profile photo of %s', 'buddypress'), $this->invite->user->fullname), 'width' => 30, 'height' => 30));
     $this->invite->user->email = $this->invite->user->user_email;
     $this->invite->user->user_url = bp_core_get_user_domain($user_id, $this->invite->user->user_nicename, $this->invite->user->user_login);
     $this->invite->user->user_link = "<a href='{$this->invite->user->user_url}' title='{$this->invite->user->fullname}'>{$this->invite->user->fullname}</a>";
     $this->invite->user->last_active = bp_core_get_last_activity($this->invite->user->last_activity, __('active %s', 'buddypress'));
     if (bp_is_active('groups')) {
         $total_groups = BP_Groups_Member::total_group_count($user_id);
         $this->invite->user->total_groups = sprintf(_n('%d group', '%d groups', $total_groups, 'buddypress'), $total_groups);
     }
     if (bp_is_active('friends')) {
         $this->invite->user->total_friends = BP_Friends_Friendship::total_friend_count($user_id);
     }
     $this->invite->user->total_blogs = null;
     // Global'ed in bp_group_has_invites()
     $this->invite->group_id = $group_id;
     // loop has just started
     if (0 == $this->current_invite) {
         /**
          * Fires if the current invite item is the first in the loop.
          *
          * @since 1.1.0
          * @since 2.3.0 `$this` parameter added.
          * @since 2.7.0 Action renamed from `loop_start`.
          *
          * @param BP_Groups_Invite_Template $this Instance of the current Invites template.
          */
         do_action('group_invitation_loop_start', $this);
     }
 }
开发者ID:CompositeUK,项目名称:clone.BuddyPress,代码行数:49,代码来源:class-bp-groups-invite-template.php


注:本文中的BP_Friends_Friendship::total_friend_count方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。