Skip to:
Content

BuddyPress.org

Ticket #5734: 5734.friend_button.patch

File 5734.friend_button.patch, 2.8 KB (added by r-a-y, 11 years ago)
  • src/bp-friends/bp-friends-template.php

     
    291291         * @return string HTML for the Add Friend button.
    292292         */
    293293        function bp_get_add_friend_button( $potential_friend_id = 0, $friend_status = false ) {
     294                global $members_template;
    294295
    295                 if ( empty( $potential_friend_id ) )
     296                if ( empty( $potential_friend_id ) ) {
    296297                        $potential_friend_id = bp_get_potential_friend_id( $potential_friend_id );
     298                }
    297299
    298300                $is_friend = bp_is_friend( $potential_friend_id );
    299301
    300                 if ( empty( $is_friend ) )
     302                if ( empty( $is_friend ) ) {
    301303                        return false;
     304                }
     305
     306                $block_self = ! empty( $members_template->in_the_loop ) ? false : true;
    302307
    303308                switch ( $is_friend ) {
    304309                        case 'pending' :
     
    306311                                        'id'                => 'pending',
    307312                                        'component'         => 'friends',
    308313                                        'must_be_logged_in' => true,
    309                                         'block_self'        => true,
     314                                        'block_self'        => $block_self,
    310315                                        'wrapper_class'     => 'friendship-button pending_friend',
    311316                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    312317                                        'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/cancel/' . $potential_friend_id . '/', 'friends_withdraw_friendship' ),
     
    323328                                        'id'                => 'awaiting_response',
    324329                                        'component'         => 'friends',
    325330                                        'must_be_logged_in' => true,
    326                                         'block_self'        => true,
     331                                        'block_self'        => $block_self,
    327332                                        'wrapper_class'     => 'friendship-button awaiting_response_friend',
    328333                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    329334                                        'link_href'         => bp_loggedin_user_domain() . bp_get_friends_slug() . '/requests/',
     
    340345                                        'id'                => 'is_friend',
    341346                                        'component'         => 'friends',
    342347                                        'must_be_logged_in' => true,
    343                                         'block_self'        => false,
     348                                        'block_self'        => $block_self,
    344349                                        'wrapper_class'     => 'friendship-button is_friend',
    345350                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    346351                                        'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/remove-friend/' . $potential_friend_id . '/', 'friends_remove_friend' ),
     
    357362                                        'id'                => 'not_friends',
    358363                                        'component'         => 'friends',
    359364                                        'must_be_logged_in' => true,
    360                                         'block_self'        => true,
     365                                        'block_self'        => $block_self,
    361366                                        'wrapper_class'     => 'friendship-button not_friends',
    362367                                        'wrapper_id'        => 'friendship-button-' . $potential_friend_id,
    363368                                        'link_href'         => wp_nonce_url( bp_loggedin_user_domain() . bp_get_friends_slug() . '/add-friend/' . $potential_friend_id . '/', 'friends_add_friend' ),