Skip to:
Content

BuddyPress.org

Changeset 13310


Ignore:
Timestamp:
08/08/2022 09:46:33 PM (4 years ago)
Author:
imath
Message:

Be sure the join/leave group button args exist before trying to use it

This is a follow up to [13302]. When the group creator is displaying the corresponding group's pages, the "join/leave group" header's button is not generated. In [13302], we were wrongly trying to access the arguments of this button although they do not exist. In this particular case, we just need to only perform BP Nouveau's button reset when this button is generated: that is to say when someone else than the creator is viewing a group's page.

See #8722

File:
1 edited

Legend:

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

    r13302 r13310  
    999999                        $button_args = bp_groups_get_group_join_button_args( $group );
    10001000
    1001                         // If we pass through parent classes merge those into the existing ones
    1002                         if ( $parent_class ) {
    1003                                 $parent_class .= ' ' . $button_args['wrapper_class'];
    1004                         }
    1005 
    1006                         // The join or leave group header button should default to 'button'
    1007                         // Reverse the earler button var to set default as 'button' not 'a'
    1008                         if ( empty( $args['button_element'] ) ) {
    1009                                 $button_element = 'button';
    1010                         }
    1011 
    1012                         $buttons['group_membership'] = array(
    1013                                 'id'                => 'group_membership',
    1014                                 'position'          => 5,
    1015                                 'component'         => $button_args['component'],
    1016                                 'must_be_logged_in' => $button_args['must_be_logged_in'],
    1017                                 'block_self'        => $button_args['block_self'],
    1018                                 'parent_element'    => $parent_element,
    1019                                 'button_element'    => $button_element,
    1020                                 'link_text'         => $button_args['link_text'],
    1021                                 'link_title'        => $button_args['link_title'],
    1022                                 'parent_attr'       => array(
    1023                                                 'id'    => $button_args['wrapper_id'],
    1024                                                 'class' => $parent_class,
    1025                                 ),
    1026                                 'button_attr'       => array(
    1027                                         'id'    => ! empty( $button_args['link_id'] ) ? $button_args['link_id'] : '',
    1028                                         'class' => $button_args['link_class'] . ' button',
    1029                                         'rel'   => ! empty( $button_args['link_rel'] ) ? $button_args['link_rel'] : '',
    1030                                         'title' => '',
    1031                                 ),
    1032                         );
    1033 
    1034                         // If button element set add nonce 'href' link to data-attr attr.
    1035                         if ( 'button' === $button_element ) {
    1036                                 $buttons['group_membership']['button_attr']['data-bp-nonce'] = $button_args['link_href'];
    1037                         } else {
    1038                         // Else this is an anchor so use an 'href' attr.
    1039                                 $buttons['group_membership']['button_attr']['href'] = $button_args['link_href'];
     1001                        if ( $button_args ) {
     1002                                // If we pass through parent classes merge those into the existing ones.
     1003                                if ( $parent_class ) {
     1004                                        $parent_class .= ' ' . $button_args['wrapper_class'];
     1005                                }
     1006
     1007                                // The join or leave group header button should default to 'button'.
     1008                                // Reverse the earlier button var to set default as 'button' not 'a'.
     1009                                if ( empty( $args['button_element'] ) ) {
     1010                                        $button_element = 'button';
     1011                                }
     1012
     1013                                $buttons['group_membership'] = array(
     1014                                        'id'                => 'group_membership',
     1015                                        'position'          => 5,
     1016                                        'component'         => $button_args['component'],
     1017                                        'must_be_logged_in' => $button_args['must_be_logged_in'],
     1018                                        'block_self'        => $button_args['block_self'],
     1019                                        'parent_element'    => $parent_element,
     1020                                        'button_element'    => $button_element,
     1021                                        'link_text'         => $button_args['link_text'],
     1022                                        'link_title'        => $button_args['link_title'],
     1023                                        'parent_attr'       => array(
     1024                                                        'id'    => $button_args['wrapper_id'],
     1025                                                        'class' => $parent_class,
     1026                                        ),
     1027                                        'button_attr'       => array(
     1028                                                'id'    => ! empty( $button_args['link_id'] ) ? $button_args['link_id'] : '',
     1029                                                'class' => $button_args['link_class'] . ' button',
     1030                                                'rel'   => ! empty( $button_args['link_rel'] ) ? $button_args['link_rel'] : '',
     1031                                                'title' => '',
     1032                                        ),
     1033                                );
     1034
     1035                                // If button element set add nonce 'href' link to data-attr attr.
     1036                                if ( 'button' === $button_element ) {
     1037                                        $buttons['group_membership']['button_attr']['data-bp-nonce'] = $button_args['link_href'];
     1038                                } else {
     1039                                        // Else this is an anchor so use an 'href' attr.
     1040                                        $buttons['group_membership']['button_attr']['href'] = $button_args['link_href'];
     1041                                }
    10401042                        }
    10411043                }
Note: See TracChangeset for help on using the changeset viewer.