Changeset 13092 for trunk/src/bp-friends/bp-friends-template.php
- Timestamp:
- 08/24/2021 04:16:17 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-template.php
r12670 r13092 15 15 * 16 16 * @since 1.5.0 17 *18 17 */ 19 18 function bp_friends_slug() { … … 43 42 * 44 43 * @since 1.5.0 45 *46 44 */ 47 45 function bp_friends_root_slug() { … … 246 244 * Return value is a string of the form "x friends". 247 245 * 246 * @global object $members_template 247 * 248 248 * @since 1.2.0 249 249 * … … 296 296 global $friends_template; 297 297 298 if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) 298 if ( empty( $user_id ) && isset( $friends_template->friendship->friend ) ) { 299 299 $user_id = $friends_template->friendship->friend->id; 300 elseif ( empty( $user_id ) && !isset( $friends_template->friendship->friend ) )300 } elseif ( empty( $user_id ) && ! isset( $friends_template->friendship->friend ) ) { 301 301 $user_id = bp_displayed_user_id(); 302 } 302 303 303 304 /** … … 320 321 * @param int $user_id ID of the potential friend. Default: the value of 321 322 * {@link bp_get_potential_friend_id()}. 322 * @return string 'is_friend', 'not_friends', or 'pending'.323 * @return bool|string 'is_friend', 'not_friends', or 'pending'. 323 324 */ 324 325 function bp_is_friend( $user_id = 0 ) { 325 326 326 if ( ! is_user_logged_in() )327 if ( ! is_user_logged_in() ) { 327 328 return false; 328 329 if ( empty( $user_id ) ) 329 } 330 331 if ( empty( $user_id ) ) { 330 332 $user_id = bp_get_potential_friend_id( $user_id ); 331 332 if ( bp_loggedin_user_id() == $user_id ) 333 } 334 335 if ( bp_loggedin_user_id() === $user_id ) { 333 336 return false; 337 } 334 338 335 339 /** … … 338 342 * @since 1.2.10 339 343 * 340 * @param string $value String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'. 344 * @param string $value String status of friendship. Possible values are 'is_friend', 'not_friends', 'pending'. 345 * @param int $user_id ID of the potential friend. 341 346 */ 342 347 return apply_filters( 'bp_is_friend', friends_check_friendship_status( bp_loggedin_user_id(), $user_id ), $user_id ); … … 364 369 * applies. Default: value of {@link bp_get_potential_friend_id()}. 365 370 * @param bool $friend_status Not currently used. 366 * @return false|string HTML for the Add Friend button.371 * @return bool|string HTML for the Add Friend button. False if already friends. 367 372 */ 368 373 function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) { 369 374 370 if ( empty( $potential_friend_id ) ) 375 if ( empty( $potential_friend_id ) ) { 371 376 $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id ); 377 } 372 378 373 379 $is_friend = bp_is_friend( $potential_friend_id ); 374 380 375 if ( empty( $is_friend ) ) 381 if ( empty( $is_friend ) ) { 376 382 return false; 383 } 377 384 378 385 switch ( $is_friend ) { 379 case 'pending' 386 case 'pending': 380 387 $button = array( 381 388 'id' => 'pending', … … 389 396 'link_id' => 'friend-' . $potential_friend_id, 390 397 'link_rel' => 'remove', 391 'link_class' => 'friendship-button pending_friend requested' 398 'link_class' => 'friendship-button pending_friend requested', 392 399 ); 393 400 break; 394 401 395 case 'awaiting_response' 402 case 'awaiting_response': 396 403 $button = array( 397 404 'id' => 'awaiting_response', … … 405 412 'link_id' => 'friend-' . $potential_friend_id, 406 413 'link_rel' => 'remove', 407 'link_class' => 'friendship-button awaiting_response_friend requested' 414 'link_class' => 'friendship-button awaiting_response_friend requested', 408 415 ); 409 416 break; 410 417 411 case 'is_friend' 418 case 'is_friend': 412 419 $button = array( 413 420 'id' => 'is_friend', … … 421 428 'link_id' => 'friend-' . $potential_friend_id, 422 429 'link_rel' => 'remove', 423 'link_class' => 'friendship-button is_friend remove' 430 'link_class' => 'friendship-button is_friend remove', 424 431 ); 425 432 break; … … 437 444 'link_id' => 'friend-' . $potential_friend_id, 438 445 'link_rel' => 'add', 439 'link_class' => 'friendship-button not_friends add' 446 'link_class' => 'friendship-button not_friends add', 440 447 ); 441 448 break; … … 459 466 * @param int $user_id Optional. Default: the displayed user's ID, or the 460 467 * logged-in user's ID. 461 * @return false|string A comma-separated list of friend IDs if any are found,468 * @return bool|string A comma-separated list of friend IDs if any are found, 462 469 * otherwise false. 463 470 */ 464 471 function bp_get_friend_ids( $user_id = 0 ) { 465 472 466 if ( empty( $user_id ) ) 473 if ( empty( $user_id ) ) { 467 474 $user_id = ( bp_displayed_user_id() ) ? bp_displayed_user_id() : bp_loggedin_user_id(); 475 } 468 476 469 477 $friend_ids = friends_get_friend_user_ids( $user_id ); 470 478 471 if ( empty( $friend_ids ) ) 479 if ( empty( $friend_ids ) ) { 472 480 return false; 481 } 473 482 474 483 return implode( ',', friends_get_friend_user_ids( $user_id ) ); … … 488 497 */ 489 498 function bp_get_friendship_requests( $user_id = 0 ) { 490 if ( ! $user_id ) {499 if ( ! $user_id ) { 491 500 $user_id = bp_displayed_user_id(); 492 501 } 493 502 494 if ( ! $user_id ) {503 if ( ! $user_id ) { 495 504 return 0; 496 505 } … … 498 507 $requests = friends_get_friendship_request_user_ids( $user_id ); 499 508 500 if ( ! empty( $requests ) ) {509 if ( ! empty( $requests ) ) { 501 510 $requests = implode( ',', (array) $requests ); 502 511 } else { … … 529 538 * @since 1.2.0 530 539 * 540 * @global object $members_template 541 * 531 542 * @return int ID of the friendship. 532 543 */ … … 562 573 * @since 1.0.0 563 574 * 575 * @global object $members_template 576 * 564 577 * @return string accept-friendship URL. 565 578 */ … … 597 610 * @since 1.0.0 598 611 * 612 * @global object $members_template 613 * 599 614 * @return string reject-friendship URL. 600 615 */ … … 656 671 * @since 1.2.0 657 672 * 658 * @see bp_friend_get_total_requests_count() for description of arguments. 659 * 660 * @param int $user_id See {@link bp_friend_get_total_requests_count(). 673 * @param int $user_id ID of the user whose requests are being counted. 674 * Default: ID of the logged-in user. 661 675 */ 662 676 function bp_friend_total_requests_count( $user_id = 0 ) { … … 673 687 */ 674 688 function bp_friend_get_total_requests_count( $user_id = 0 ) { 675 if ( empty( $user_id ) ) 689 if ( empty( $user_id ) ) { 676 690 $user_id = bp_loggedin_user_id(); 691 } 677 692 678 693 /**
Note: See TracChangeset
for help on using the changeset viewer.