Changeset 13301
- Timestamp:
- 07/22/2022 10:50:40 AM (2 years ago)
- Location:
- trunk/src
- Files:
-
- 1 added
- 3 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 -
trunk/src/bp-templates/bp-nouveau/includes/members/functions.php
r13136 r13301 159 159 160 160 /** 161 * Catch the arguments for buttons162 *163 * @since 3.0.0164 *165 * @param array $buttons The arguments of the button that BuddyPress is about to create.166 *167 * @return array An empty array to stop the button creation process.168 */169 function bp_nouveau_members_catch_button_args( $button = array() ) {170 /*171 * Globalize the arguments so that we can use it172 * in bp_nouveau_get_member_header_buttons().173 */174 bp_nouveau()->members->button_args = $button;175 176 // return an empty array to stop the button creation process177 return array();178 }179 180 /**181 161 * Catch the content hooked to the do_action hooks in single member header 182 162 * and in the members loop. -
trunk/src/bp-templates/bp-nouveau/includes/members/template-tags.php
r13300 r13301 320 320 // It's any other members screen 321 321 } else { 322 /* 323 * This filter workaround is waiting for a core adaptation 324 * so that we can directly get the friends button arguments 325 * instead of the button. 326 * 327 * See https://buddypress.trac.wordpress.org/ticket/7126 328 */ 329 add_filter( 'bp_get_add_friend_button', 'bp_nouveau_members_catch_button_args', 100, 1 ); 330 331 bp_get_add_friend_button( $user_id ); 332 333 remove_filter( 'bp_get_add_friend_button', 'bp_nouveau_members_catch_button_args', 100, 1 ); 334 335 if ( isset( bp_nouveau()->members->button_args ) && bp_nouveau()->members->button_args ) { 336 $button_args = bp_nouveau()->members->button_args; 337 322 $button_args = bp_get_add_friend_button_args( $user_id ); 323 324 if ( $button_args ) { 338 325 $buttons['member_friendship'] = array( 339 326 'id' => 'member_friendship', … … 344 331 'parent_element' => $parent_element, 345 332 'link_text' => $button_args['link_text'], 333 'link_title' => $button_args['link_title'], 346 334 'parent_attr' => array( 347 335 'id' => $button_args['wrapper_id'], … … 364 352 $buttons['member_friendship']['button_attr']['href'] = $button_args['link_href']; 365 353 } 366 367 unset( bp_nouveau()->members->button_args );368 354 } 369 355 }
Note: See TracChangeset
for help on using the changeset viewer.