Changeset 13301 for trunk/src/bp-friends/bp-friends-template.php
- Timestamp:
- 07/22/2022 10:50:40 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-friends/bp-friends-template.php
r13108 r13301 361 361 echo bp_get_add_friend_button( $potential_friend_id, $friend_status ); 362 362 } 363 /** 364 * Create the Add Friend button.365 * 366 * @since 1.1.0367 * 368 * @param int $potential_friend_id ID of the user to whom the button369 * applies. Default: value of {@link bp_get_potential_friend_id()}.370 * @ param bool $friend_status Not currently used.371 * @return bool|string HTML for the Add Friend button. False if already friends.372 */373 function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {363 364 /** 365 * Build friend button arguments. 366 * 367 * @since 11.0.0 368 * 369 * @param int $potential_friend_id The user ID of the potential friend. 370 * @return array The friend button arguments. 371 */ 372 function bp_get_add_friend_button_args( $potential_friend_id = 0 ) { 373 $button_args = array(); 374 374 375 375 if ( empty( $potential_friend_id ) ) { … … 377 377 } 378 378 379 $ is_friend= bp_is_friend( $potential_friend_id );380 381 if ( empty( $ is_friend) ) {382 return false;383 } 384 385 switch ( $ is_friend) {379 $friendship_status = bp_is_friend( $potential_friend_id ); 380 381 if ( empty( $friendship_status ) ) { 382 return $button_args; 383 } 384 385 switch ( $friendship_status ) { 386 386 case 'pending': 387 $button = array(387 $button_args = array( 388 388 'id' => 'pending', 389 389 'component' => 'friends', … … 394 394 'link_href' => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $potential_friend_id . '/', 'friends_withdraw_friendship' ), 395 395 'link_text' => __( 'Cancel Friendship Request', 'buddypress' ), 396 'link_title' => __( 'Cancel Friendship Requested', 'buddypress' ), 396 397 'link_id' => 'friend-' . $potential_friend_id, 397 398 'link_rel' => 'remove', … … 401 402 402 403 case 'awaiting_response': 403 $button = array(404 $button_args = array( 404 405 'id' => 'awaiting_response', 405 406 'component' => 'friends', … … 410 411 'link_href' => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/', 411 412 'link_text' => __( 'Friendship Requested', 'buddypress' ), 413 'link_title' => __( 'Friendship Requested', 'buddypress' ), 412 414 'link_id' => 'friend-' . $potential_friend_id, 413 415 'link_rel' => 'remove', … … 417 419 418 420 case 'is_friend': 419 $button = array(421 $button_args = array( 420 422 'id' => 'is_friend', 421 423 'component' => 'friends', … … 426 428 'link_href' => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ), 427 429 'link_text' => __( 'Cancel Friendship', 'buddypress' ), 430 'link_title' => __( 'Cancel Friendship', 'buddypress' ), 428 431 'link_id' => 'friend-' . $potential_friend_id, 429 432 'link_rel' => 'remove', … … 433 436 434 437 default: 435 $button = array(438 $button_args = array( 436 439 'id' => 'not_friends', 437 440 'component' => 'friends', … … 442 445 'link_href' => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ), 443 446 'link_text' => __( 'Add Friend', 'buddypress' ), 447 'link_title' => __( 'Add Friend', 'buddypress' ), 444 448 'link_id' => 'friend-' . $potential_friend_id, 445 449 'link_rel' => 'add', … … 454 458 * @since 1.1.0 455 459 * 456 * @param string $button HTML markup for add friend button. 457 */ 458 return bp_get_button( apply_filters( 'bp_get_add_friend_button', $button ) ); 460 * @param string $button_args Button arguments for add friend button. 461 */ 462 return apply_filters( 'bp_get_add_friend_button', $button_args ); 463 } 464 465 /** 466 * Create the Add Friend button. 467 * 468 * @since 1.1.0 469 * @since 11.0.0 uses `bp_get_add_friend_button_args()`. 470 * 471 * @param int $potential_friend_id ID of the user to whom the button 472 * applies. Default: value of {@link bp_get_potential_friend_id()}. 473 * @param bool $friend_status Not currently used. 474 * @return bool|string HTML for the Add Friend button. False if already friends. 475 */ 476 function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) { 477 $button_args = bp_get_add_friend_button_args( $potential_friend_id ); 478 479 if ( ! array_filter( $button_args ) ) { 480 return false; 481 } 482 483 return bp_get_button( $button_args ); 459 484 } 460 485
Note: See TracChangeset
for help on using the changeset viewer.