Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 10:50:40 AM (2 years ago)
Author:
imath
Message:

Introduce a function to only get the Friendship button arguments

bp_get_add_friend_button_args() eases the process of getting these arguments and removes the need for BP Nouveau's workaround.
Deprecate the bp_nouveau_members_catch_button_args() as no more needed.

Props hnla

See #7126
See #8722

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/members/template-tags.php

    r13300 r13301  
    320320            // It's any other members screen
    321321            } 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 ) {
    338325                    $buttons['member_friendship'] = array(
    339326                        'id'                => 'member_friendship',
     
    344331                        'parent_element'    => $parent_element,
    345332                        'link_text'         => $button_args['link_text'],
     333                        'link_title'        => $button_args['link_title'],
    346334                        'parent_attr'       => array(
    347335                            'id'    => $button_args['wrapper_id'],
     
    364352                        $buttons['member_friendship']['button_attr']['href'] = $button_args['link_href'];
    365353                    }
    366 
    367                     unset( bp_nouveau()->members->button_args );
    368354                }
    369355            }
Note: See TracChangeset for help on using the changeset viewer.