Ticket #5942: bp-friends-template-5942.diff
| File bp-friends-template-5942.diff, 6.0 KB (added by , 11 years ago) |
|---|
-
src/bp-friends/bp-friends-template.php
26 26 * @since BuddyPress (1.5.0) 27 27 */ 28 28 function bp_get_friends_slug() { 29 30 /** 31 * Filters the friends component slug. 32 * 33 * @since BuddyPress (1.5.0) 34 * 35 * @param string $value Friends component slug. 36 */ 29 37 return apply_filters( 'bp_get_friends_slug', buddypress()->friends->slug ); 30 38 } 31 39 … … 45 53 * @since BuddyPress (1.5.0) 46 54 */ 47 55 function bp_get_friends_root_slug() { 56 57 /** 58 * Filters the friends component root slug. 59 * 60 * @since BuddyPress (1.5.0) 61 * 62 * @param string $value Friends component root slug. 63 */ 48 64 return apply_filters( 'bp_get_friends_root_slug', buddypress()->friends->root_slug ); 49 65 } 50 66 … … 212 228 function bp_get_member_total_friend_count() { 213 229 global $members_template; 214 230 215 if ( 1 == (int) $members_template->member->total_friend_count ) 231 if ( 1 == (int) $members_template->member->total_friend_count ) { 232 233 /** 234 * Filters text used to denote total friend count. 235 * 236 * @since BuddyPress (1.2.0) 237 * 238 * @param string $value String of the form "x friends". 239 * @param int $value Total friend count for current member in the loop. 240 */ 216 241 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friend', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 217 else 242 } else { 243 244 /** This filter is documented in bp-friends/bp-friends-template.php */ 218 245 return apply_filters( 'bp_get_member_total_friend_count', sprintf( __( '%d friends', 'buddypress' ), (int) $members_template->member->total_friend_count ) ); 246 } 219 247 } 220 248 221 249 /** … … 245 273 else if ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) ) 246 274 $user_id = bp_displayed_user_id(); 247 275 276 /** 277 * Filters the ID of current user in the friend request loop. 278 * 279 * @since BuddyPress (1.2.10) 280 * 281 * @param int $user_id ID of current user in the friend request loop. 282 */ 248 283 return apply_filters( 'bp_get_potential_friend_id', (int) $user_id ); 249 284 } 250 285 … … 268 303 if ( bp_loggedin_user_id() == $user_id ) 269 304 return false; 270 305 306 /** 307 * Filters the status of friendship between logged in user and given user. 308 * 309 * @since BuddyPress (1.2.10) 310 * 311 * @param string $value String status of friendship. Possible values are 312 * 'is_friend', 'not_friends', 'pending'. 313 */ 271 314 return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id ); 272 315 } 273 316 … … 370 413 break; 371 414 } 372 415 373 // Filter and return the HTML button 416 /** 417 * Filters the HTML for the add friend button. 418 * 419 * @since BuddyPress (1.1.0) 420 * 421 * @param string $button HTML markup for add friend button. 422 */ 374 423 return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) ); 375 424 } 376 425 … … 422 471 $requests = 0; 423 472 } 424 473 474 /** 475 * Filters the total pending friendship requests for a user. 476 * 477 * @since BuddyPress (1.2.0) 478 * 479 * @param array|int An array of user IDs if found, or a 0 if none are found. 480 */ 425 481 return apply_filters( 'bp_get_friendship_requests', $requests ); 426 482 } 427 483 … … 444 500 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 445 501 } 446 502 503 /** 504 * Filters the ID of the friendship between the logged in user and the current user in the loop. 505 * 506 * @since BuddyPress (1.2.0) 507 * 508 * @param int $friendship_id ID of the friendship. 509 */ 447 510 return apply_filters( 'bp_get_friend_friendship_id', $friendship_id ); 448 511 } 449 512 … … 466 529 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 467 530 } 468 531 532 /** 533 * Filters the URL for accepting the current friendship request in the loop. 534 * 535 * @since BuddyPress (1.0.0) 536 * 537 * @param string $value Accept-friendship URL. 538 */ 469 539 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' ) ); 470 540 } 471 541 … … 488 558 wp_cache_set( 'friendship_id_' . $members_template->member->id . '_' . bp_loggedin_user_id(), $friendship_id, 'bp' ); 489 559 } 490 560 561 /** 562 * Filters the URL for rejecting the current friendship request in the loop. 563 * 564 * @since BuddyPress (1.0.0) 565 * 566 * @param string $value Reject-friendship URL. 567 */ 491 568 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' ) ); 492 569 } 493 570 … … 506 583 * @return int Total friend count. 507 584 */ 508 585 function bp_get_total_friend_count( $user_id = 0 ) { 586 587 /** 588 * Filters the total friend count for a given user. 589 * 590 * @since BuddyPress (1.2.0) 591 * 592 * @param int $value Total friend count. 593 */ 509 594 return apply_filters( 'bp_get_total_friend_count', friends_get_total_friend_count( $user_id ) ); 510 595 } 511 596 add_filter( 'bp_get_total_friend_count', 'bp_core_number_format' ); … … 531 616 if ( empty( $user_id ) ) 532 617 $user_id = bp_loggedin_user_id(); 533 618 619 /** 620 * Filters the total friendship request count for a given user. 621 * 622 * @since BuddyPress (1.2.0) 623 * 624 * @param int $value Friendship request count. 625 */ 534 626 return apply_filters( 'bp_friend_get_total_requests_count', count( BP_Friends_Friendship::get_friend_user_ids( $user_id, true ) ) ); 535 627 } 536 628 … … 584 676 } 585 677 } 586 678 587 // Filter and return 679 /** 680 * Filters the number of friends in user's profile. 681 * 682 * @since BuddyPress (2.0.0) 683 * 684 * @param string $value Formatted string displaying total friends count. 685 * @param array $r Array of arguments for string formatting and output. 686 */ 588 687 return apply_filters( 'bp_friends_get_profile_stats', $r['output'], $r ); 589 688 }