diff --git a/src/bp-friends/bp-firends-template.php b/src/bp-friends/bp-firends-template.php
index e101f17..f333506 100644
|
a
|
b
|
function bp_friends_root_slug() { |
| 77 | 77 | */ |
| 78 | 78 | function bp_friends_random_friends() { |
| 79 | 79 | |
| 80 | | if ( !$friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) { |
| | 80 | if ( ! $friend_ids = wp_cache_get( 'friends_friend_ids_' . bp_displayed_user_id(), 'bp' ) ) { |
| 81 | 81 | $friend_ids = BP_Friends_Friendship::get_random_friends( bp_displayed_user_id() ); |
| 82 | 82 | wp_cache_set( 'friends_friend_ids_' . bp_displayed_user_id(), $friend_ids, 'bp' ); |
| 83 | 83 | } ?> |
| 84 | 84 | |
| 85 | 85 | <div class="info-group"> |
| 86 | | <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> |
| | 86 | <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> |
| 87 | 87 | |
| 88 | 88 | <?php if ( $friend_ids ) { ?> |
| 89 | 89 | |
| … |
… |
function bp_friends_random_friends() { |
| 92 | 92 | <?php for ( $i = 0, $count = count( $friend_ids ); $i < $count; ++$i ) { ?> |
| 93 | 93 | |
| 94 | 94 | <li> |
| 95 | | <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> |
| 96 | | <h5><?php echo bp_core_get_userlink($friend_ids[$i]) ?></h5> |
| | 95 | <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> |
| | 96 | <h5><?php echo bp_core_get_userlink( $friend_ids[$i] ); ?></h5> |
| 97 | 97 | </li> |
| 98 | 98 | |
| 99 | 99 | <?php } ?> |
| … |
… |
function bp_friends_random_friends() { |
| 103 | 103 | <?php } else { ?> |
| 104 | 104 | |
| 105 | 105 | <div id="message" class="info"> |
| 106 | | <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> |
| | 106 | <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> |
| 107 | 107 | </div> |
| 108 | 108 | |
| 109 | 109 | <?php } ?> |
| … |
… |
function bp_friends_random_friends() { |
| 125 | 125 | */ |
| 126 | 126 | function bp_friends_random_members( $total_members = 5 ) { |
| 127 | 127 | |
| 128 | | if ( !$user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) { |
| | 128 | if ( ! $user_ids = wp_cache_get( 'friends_random_users', 'bp' ) ) { |
| 129 | 129 | $user_ids = BP_Core_User::get_users( 'random', $total_members ); |
| 130 | 130 | wp_cache_set( 'friends_random_users', $user_ids, 'bp' ); |
| 131 | 131 | } |
| … |
… |
function bp_friends_random_members( $total_members = 5 ) { |
| 139 | 139 | <?php for ( $i = 0, $count = count( $user_ids['users'] ); $i < $count; ++$i ) { ?> |
| 140 | 140 | |
| 141 | 141 | <li> |
| 142 | | <a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->id ) ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->id, 'type' => 'thumb' ) ) ?></a> |
| 143 | | <h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->id ) ?></h5> |
| | 142 | <a href="<?php echo bp_core_get_user_domain( $user_ids['users'][$i]->id ); ?>"><?php echo bp_core_fetch_avatar( array( 'item_id' => $user_ids['users'][$i]->id, 'type' => 'thumb' ) ); ?></a> |
| | 143 | <h5><?php echo bp_core_get_userlink( $user_ids['users'][$i]->id ); ?></h5> |
| 144 | 144 | |
| 145 | 145 | <?php if ( bp_is_active( 'xprofile' ) ) { ?> |
| 146 | 146 | |
| 147 | 147 | <?php $random_data = xprofile_get_random_profile_data( $user_ids['users'][$i]->id, true ); ?> |
| 148 | 148 | |
| 149 | 149 | <div class="profile-data"> |
| 150 | | <p class="field-name"><?php echo $random_data[0]->name ?></p> |
| | 150 | <p class="field-name"><?php echo $random_data[0]->name; ?></p> |
| 151 | 151 | |
| 152 | | <?php echo $random_data[0]->value ?> |
| | 152 | <?php echo $random_data[0]->value; ?> |
| 153 | 153 | |
| 154 | 154 | </div> |
| 155 | 155 | |
| … |
… |
function bp_friends_random_members( $total_members = 5 ) { |
| 159 | 159 | |
| 160 | 160 | <?php if ( bp_is_active( 'friends' ) ) { ?> |
| 161 | 161 | |
| 162 | | <?php bp_add_friend_button( $user_ids['users'][$i]->id ) ?> |
| | 162 | <?php bp_add_friend_button( $user_ids['users'][$i]->id ); ?> |
| 163 | 163 | |
| 164 | 164 | <?php } ?> |
| 165 | 165 | |
| … |
… |
function bp_friends_random_members( $total_members = 5 ) { |
| 173 | 173 | <?php } else { ?> |
| 174 | 174 | |
| 175 | 175 | <div id="message" class="info"> |
| 176 | | <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ) ?></p> |
| | 176 | <p><?php _e( "There aren't enough site members to show a random sample just yet.", 'buddypress' ); ?></p> |
| 177 | 177 | </div> |
| 178 | 178 | |
| 179 | 179 | <?php } ?> |
| … |
… |
function bp_friend_search_form() { |
| 192 | 192 | $action = bp_displayed_user_domain() . bp_get_friends_slug() . '/my-friends/search/'; |
| 193 | 193 | $label = __( 'Filter Friends', 'buddypress' ); ?> |
| 194 | 194 | |
| 195 | | <form action="<?php echo $action ?>" id="friend-search-form" method="post"> |
| | 195 | <form action="<?php echo $action; ?>" id="friend-search-form" method="post"> |
| 196 | 196 | |
| 197 | 197 | <label for="friend-search-box" id="friend-search-label"><?php echo $label ?></label> |
| 198 | 198 | <input type="search" name="friend-search-box" id="friend-search-box" value="<?php echo $value ?>"<?php echo $disabled ?> /> |
| 199 | 199 | |
| 200 | | <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ) ?> |
| | 200 | <?php wp_nonce_field( 'friends_search', '_wpnonce_friend_search' ); ?> |
| 201 | 201 | |
| 202 | | <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( bp_displayed_user_id() ) ?>" /> |
| | 202 | <input type="hidden" name="initiator" id="initiator" value="<?php echo esc_attr( bp_displayed_user_id() ); ?>" /> |
| 203 | 203 | |
| 204 | 204 | </form> |
| 205 | 205 | |
| … |
… |
function bp_get_friend_ids( $user_id = 0 ) { |
| 476 | 476 | * @return array|int An array of user IDs if found, or a 0 if none are found. |
| 477 | 477 | */ |
| 478 | 478 | function bp_get_friendship_requests( $user_id = 0 ) { |
| 479 | | if ( !$user_id ) { |
| | 479 | if ( ! $user_id ) { |
| 480 | 480 | $user_id = bp_displayed_user_id(); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | | if ( !$user_id ) { |
| | 483 | if ( ! $user_id ) { |
| 484 | 484 | return 0; |
| 485 | 485 | } |
| 486 | 486 | |
| 487 | 487 | $requests = friends_get_friendship_request_user_ids( $user_id ); |
| 488 | 488 | |
| 489 | | if ( !empty( $requests ) ) { |
| | 489 | if ( ! empty( $requests ) ) { |
| 490 | 490 | $requests = implode( ',', (array) $requests ); |
| 491 | 491 | } else { |
| 492 | 492 | $requests = 0; |
| … |
… |
function bp_get_friendship_requests( $user_id = 0 ) { |
| 496 | 496 | * Filters the total pending friendship requests for a user. |
| 497 | 497 | * |
| 498 | 498 | * @since 1.2.0 |
| | 499 | * @since 2.6.0 Added the `$user_id` parameter. |
| 499 | 500 | * |
| 500 | | * @param array|int An array of user IDs if found, or a 0 if none are found. |
| | 501 | * @param array|int $requests An array of user IDs if found, or a 0 if none are found. |
| | 502 | * @param int $user_id ID of the queried user. |
| 501 | 503 | */ |
| 502 | | return apply_filters( 'bp_get_friendship_requests', $requests ); |
| | 504 | return apply_filters( 'bp_get_friendship_requests', $requests, $user_id ); |
| 503 | 505 | } |
| 504 | 506 | |
| 505 | 507 | /** |
| … |
… |
function bp_friend_friendship_id() { |
| 520 | 522 | function bp_get_friend_friendship_id() { |
| 521 | 523 | global $members_template; |
| 522 | 524 | |
| 523 | | if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| | 525 | if ( ! $friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| 524 | 526 | $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); |
| 525 | 527 | wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); |
| 526 | 528 | } |
| … |
… |
function bp_friend_accept_request_link() { |
| 553 | 555 | function bp_get_friend_accept_request_link() { |
| 554 | 556 | global $members_template; |
| 555 | 557 | |
| 556 | | if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| | 558 | if ( ! $friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| 557 | 559 | $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); |
| 558 | 560 | wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); |
| 559 | 561 | } |
| … |
… |
function bp_friend_accept_request_link() { |
| 562 | 564 | * Filters the URL for accepting the current friendship request in the loop. |
| 563 | 565 | * |
| 564 | 566 | * @since 1.0.0 |
| | 567 | * @since 2.6.0 Added the `$friendship_id` parameter. |
| 565 | 568 | * |
| 566 | | * @param string $value Accept-friendship URL. |
| | 569 | * @param string $value Accept-friendship URL. |
| | 570 | * @param int $friendship_id ID of the friendship. |
| 567 | 571 | */ |
| 568 | | return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ) ); |
| | 572 | return apply_filters( 'bp_get_friend_accept_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/accept/' . $friendship_id, 'friends_accept_friendship' ), $friendship_id ); |
| 569 | 573 | } |
| 570 | 574 | |
| 571 | 575 | /** |
| … |
… |
function bp_friend_reject_request_link() { |
| 586 | 590 | function bp_get_friend_reject_request_link() { |
| 587 | 591 | global $members_template; |
| 588 | 592 | |
| 589 | | if ( !$friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| | 593 | if ( ! $friendship_id = wp_cache_get( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id() ) ) { |
| 590 | 594 | $friendship_id = friends_get_friendship_id( $members_template->member->id, bp_loggedin_user_id() ); |
| 591 | 595 | wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); |
| 592 | 596 | } |
| … |
… |
function bp_friend_reject_request_link() { |
| 595 | 599 | * Filters the URL for rejecting the current friendship request in the loop. |
| 596 | 600 | * |
| 597 | 601 | * @since 1.0.0 |
| | 602 | * @since 2.6.0 Added the `$friendship_id` parameter. |
| 598 | 603 | * |
| 599 | | * @param string $value Reject-friendship URL. |
| | 604 | * @param string $value Reject-friendship URL. |
| | 605 | * @param int $friendship_id ID of the friendship. |
| 600 | 606 | */ |
| 601 | | return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ) ); |
| | 607 | return apply_filters( 'bp_get_friend_reject_request_link', wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/reject/' . $friendship_id, 'friends_reject_friendship' ), $friendship_id ); |
| 602 | 608 | } |
| 603 | 609 | |
| 604 | 610 | /** |
| … |
… |
function bp_total_friend_count( $user_id = 0 ) { |
| 625 | 631 | * Filters the total friend count for a given user. |
| 626 | 632 | * |
| 627 | 633 | * @since 1.2.0 |
| | 634 | * @since 2.6.0 Added the `$user_id` parameter. |
| 628 | 635 | * |
| 629 | | * @param int $value Total friend count. |
| | 636 | * @param int $value Total friend count. |
| | 637 | * @param int $user_id ID of the queried user. |
| 630 | 638 | */ |
| 631 | | return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) ); |
| | 639 | return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ), $user_id ); |
| 632 | 640 | } |
| 633 | 641 | add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' ); |
| 634 | 642 | |
| … |
… |
function bp_friend_total_requests_count( $user_id = 0 ) { |
| 661 | 669 | * Filters the total friendship request count for a given user. |
| 662 | 670 | * |
| 663 | 671 | * @since 1.2.0 |
| | 672 | * @since 2.6.0 Added the `$user_id` parameter. |
| 664 | 673 | * |
| 665 | | * @param int $value Friendship request count. |
| | 674 | * @param int $value Friendship request count. |
| | 675 | * @param int $user_id ID of the queried user. |
| 666 | 676 | */ |
| 667 | | return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) ); |
| | 677 | return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ), $user_id ); |
| 668 | 678 | } |
| 669 | 679 | |
| 670 | 680 | /** Stats **********************************************************************/ |