Skip to:
Content

BuddyPress.org

Changeset 13409


Ignore:
Timestamp:
02/03/2023 08:19:48 PM (4 years 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
See #8800 (Trunk)

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r13395 r13409  
    35593559                 * @param array $button_args Array of arguments for the public message button HTML.
    35603560                 */
    3561                 return apply_filters( 'bp_get_send_public_message_button', $button_args );
     3561                return (array) apply_filters( 'bp_get_send_public_message_button', $button_args );
    35623562        }
    35633563
  • trunk/src/bp-blogs/bp-blogs-template.php

    r13405 r13409  
    15951595                 * @param array $button_args Array of arguments to be used for the button to visit a blog.
    15961596                 */
    1597                 return apply_filters( 'bp_get_blogs_visit_blog_button', $button_args );
     1597                return (array) apply_filters( 'bp_get_blogs_visit_blog_button', $button_args );
    15981598        }
    15991599
  • trunk/src/bp-friends/bp-friends-template.php

    r13395 r13409  
    458458                 * @since 1.1.0
    459459                 *
    460                  * @param string $button_args Button arguments for add friend button.
    461                  */
    462                 return apply_filters( 'bp_get_add_friend_button', $button_args );
     460                 * @param array $button_args Button arguments for add friend button.
     461                 */
     462                return (array) apply_filters( 'bp_get_add_friend_button', $button_args );
    463463        }
    464464
  • trunk/src/bp-groups/bp-groups-template.php

    r13395 r13409  
    37003700                 * @param object $group       BuddyPress group object
    37013701                 */
    3702                 return apply_filters( 'bp_get_group_join_button', $button_args, $group );
     3702                return (array) apply_filters( 'bp_get_group_join_button', $button_args, $group );
    37033703        }
    37043704        /**
  • trunk/src/bp-messages/bp-messages-template.php

    r13395 r13409  
    15571557                 * @param array $button_args See {@link BP_Button}.
    15581558                 */
    1559                 return apply_filters( 'bp_get_send_message_button_args', $button_args );
     1559                return (array) apply_filters( 'bp_get_send_message_button_args', $button_args );
    15601560        }
    15611561
  • trunk/src/bp-templates/bp-nouveau/includes/blogs/template-tags.php

    r13303 r13409  
    200200                }
    201201
    202                 $button_args = bp_get_blogs_visit_blog_button_args();
    203 
    204202                // If we pass through parent classes add them to $button array
    205203                $parent_class = '';
     
    208206                }
    209207
    210                 // Set defaults if not set.
    211                 $button_args = array_merge( array(
    212                         'wrapper_id' => '',
    213                         'link_id'    => '',
    214                         'link_rel'   => ''
    215                 ), $button_args );
    216 
    217                 $buttons['visit_blog'] = array(
    218                         'id'                => 'visit_blog',
    219                         'position'          => 5,
    220                         'component'         => $button_args['component'],
    221                         'must_be_logged_in' => $button_args['must_be_logged_in'],
    222                         'block_self'        => $button_args['block_self'],
    223                         'parent_element'    => $parent_element,
    224                         'button_element'    => $button_element,
    225                         'link_text'         => $button_args['link_text'],
    226                         'link_title'        => $button_args['link_title'],
    227                         'parent_attr'       => array(
    228                                 'id'              => $button_args['wrapper_id'],
    229                                 'class'           => $parent_class,
    230                         ),
    231                         'button_attr'       => array(
    232                                 'href'             => $button_args['link_href'],
    233                                 'id'               => $button_args['link_id'],
    234                                 'class'            => $button_args['link_class'] . ' button',
    235                                 'rel'              => $button_args['link_rel'],
    236                                 'title'            => '',
    237                         ),
    238                 );
     208                $button_args = bp_get_blogs_visit_blog_button_args();
     209                if ( array_filter( $button_args ) ) {
     210                        // Set defaults if not set.
     211                        $button_args = array_merge( array(
     212                                'wrapper_id' => '',
     213                                'link_id'    => '',
     214                                'link_rel'   => ''
     215                        ), $button_args );
     216
     217                        $buttons['visit_blog'] = array(
     218                                'id'                => 'visit_blog',
     219                                'position'          => 5,
     220                                'component'         => $button_args['component'],
     221                                'must_be_logged_in' => $button_args['must_be_logged_in'],
     222                                'block_self'        => $button_args['block_self'],
     223                                'parent_element'    => $parent_element,
     224                                'button_element'    => $button_element,
     225                                'link_text'         => $button_args['link_text'],
     226                                'link_title'        => $button_args['link_title'],
     227                                'parent_attr'       => array(
     228                                        'id'              => $button_args['wrapper_id'],
     229                                        'class'           => $parent_class,
     230                                ),
     231                                'button_attr'       => array(
     232                                        'href'             => $button_args['link_href'],
     233                                        'id'               => $button_args['link_id'],
     234                                        'class'            => $button_args['link_class'] . ' button',
     235                                        'rel'              => $button_args['link_rel'],
     236                                        'title'            => '',
     237                                ),
     238                        );
     239                }
    239240
    240241                /**
  • trunk/src/bp-templates/bp-nouveau/includes/members/template-tags.php

    r13301 r13409  
    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.