Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/03/2023 08:34:14 PM (14 months ago)
Author:
imath
Message:

Prevent a Members single view header action button filters wrong use

Some custom code/plugins might wrongly use something else than an array
(eg: false) to disable one of the action buttons shown inside the single
Members view header. Changes made during the 11.0.0 release revealed this
potential issue.

See #7126
Closes https://github.com/buddypress/buddypress/pull/59
Fixes #8800 (branch 11.0)

File:
1 edited

Legend:

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

    r13301 r13410  
    322322                $button_args = bp_get_add_friend_button_args( $user_id );
    323323
    324                 if ( $button_args ) {
     324                if ( array_filter( $button_args ) ) {
    325325                    $buttons['member_friendship'] = array(
    326326                        'id'                => 'member_friendship',
     
    361361                $button_args = bp_activity_get_public_message_button_args();
    362362
    363                 /*
    364                  * This button should remain as an anchor link.
    365                  * Hardcode the use of anchor elements if button arg passed in for other elements.
    366                  */
    367                 $buttons['public_message'] = array(
    368                     'id'                => $button_args['id'],
    369                     'position'          => 15,
    370                     'component'         => $button_args['component'],
    371                     'must_be_logged_in' => $button_args['must_be_logged_in'],
    372                     'block_self'        => $button_args['block_self'],
    373                     'parent_element'    => $parent_element,
    374                     'button_element'    => 'a',
    375                     'link_text'         => $button_args['link_text'],
    376                     'link_title'        => $button_args['link_title'],
    377                     'parent_attr'       => array(
    378                         'id'    => $button_args['wrapper_id'],
    379                         'class' => $parent_class,
    380                     ),
    381                     'button_attr'       => array(
    382                         'href'             => $button_args['link_href'],
    383                         'id'               => '',
    384                         'class'            => $button_args['link_class'],
    385                     ),
    386                 );
     363                if ( array_filter( $button_args ) ) {
     364                    /*
     365                    * This button should remain as an anchor link.
     366                    * Hardcode the use of anchor elements if button arg passed in for other elements.
     367                    */
     368                    $buttons['public_message'] = array(
     369                        'id'                => $button_args['id'],
     370                        'position'          => 15,
     371                        'component'         => $button_args['component'],
     372                        'must_be_logged_in' => $button_args['must_be_logged_in'],
     373                        'block_self'        => $button_args['block_self'],
     374                        'parent_element'    => $parent_element,
     375                        'button_element'    => 'a',
     376                        'link_text'         => $button_args['link_text'],
     377                        'link_title'        => $button_args['link_title'],
     378                        'parent_attr'       => array(
     379                            'id'    => $button_args['wrapper_id'],
     380                            'class' => $parent_class,
     381                        ),
     382                        'button_attr'       => array(
     383                            'href'             => $button_args['link_href'],
     384                            'id'               => '',
     385                            'class'            => $button_args['link_class'],
     386                        ),
     387                    );
     388                }
    387389            }
    388390
     
    390392                $button_args = bp_get_send_message_button_args();
    391393
    392                 /*
    393                  * This button should remain as an anchor link.
    394                  * Hardcode the use of anchor elements if button arg passed in for other elements.
    395                  */
    396                 $buttons['private_message'] = array(
    397                     'id'                => $button_args['id'],
    398                     'position'          => 25,
    399                     'component'         => $button_args['component'],
    400                     'must_be_logged_in' => $button_args['must_be_logged_in'],
    401                     'block_self'        => $button_args['block_self'],
    402                     'parent_element'    => $parent_element,
    403                     'button_element'    => 'a',
    404                     'link_text'         => $button_args['link_text'],
    405                     'link_title'        => $button_args['link_title'],
    406                     'parent_attr'       => array(
    407                         'id'    => $button_args['wrapper_id'],
    408                         'class' => $parent_class,
    409                     ),
    410                     'button_attr'       => array(
    411                         'href'  => bp_get_send_private_message_link(),
    412                         'id'    => false,
    413                         'class' => $button_args['link_class'],
    414                         'rel'   => '',
    415                         'title' => '',
    416                     ),
    417                 );
     394                if ( array_filter( $button_args ) ) {
     395                    /*
     396                    * This button should remain as an anchor link.
     397                    * Hardcode the use of anchor elements if button arg passed in for other elements.
     398                    */
     399                    $buttons['private_message'] = array(
     400                        'id'                => $button_args['id'],
     401                        'position'          => 25,
     402                        'component'         => $button_args['component'],
     403                        'must_be_logged_in' => $button_args['must_be_logged_in'],
     404                        'block_self'        => $button_args['block_self'],
     405                        'parent_element'    => $parent_element,
     406                        'button_element'    => 'a',
     407                        'link_text'         => $button_args['link_text'],
     408                        'link_title'        => $button_args['link_title'],
     409                        'parent_attr'       => array(
     410                            'id'    => $button_args['wrapper_id'],
     411                            'class' => $parent_class,
     412                        ),
     413                        'button_attr'       => array(
     414                            'href'  => bp_get_send_private_message_link(),
     415                            'id'    => false,
     416                            'class' => $button_args['link_class'],
     417                            'rel'   => '',
     418                            'title' => '',
     419                        ),
     420                    );
     421                }
    418422            }
    419423        }
Note: See TracChangeset for help on using the changeset viewer.