Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 11:44:14 AM (4 years ago)
Author:
imath
Message:

Introduce a function to only get the "Join/Leave Group" button args

bp_groups_get_group_join_button_args() eases the process of getting these arguments and removes the need for BP Nouveau's workaround.
Deprecate the bp_nouveau_groups_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/groups/template-tags.php

    r13193 r13302  
    997997                // Membership button on groups loop or single group's header
    998998                } else {
    999                         /*
    1000                          * This filter workaround is waiting for a core adaptation
    1001                          * so that we can directly get the groups button arguments
    1002                          * instead of the button.
    1003                          *
    1004                          * See https://buddypress.trac.wordpress.org/ticket/7126
    1005                          */
    1006                         add_filter( 'bp_get_group_join_button', 'bp_nouveau_groups_catch_button_args', 100, 1 );
    1007 
    1008                         bp_get_group_join_button( $group );
    1009 
    1010                         remove_filter( 'bp_get_group_join_button', 'bp_nouveau_groups_catch_button_args', 100, 1 );
    1011 
    1012                         if ( isset( bp_nouveau()->groups->button_args ) && bp_nouveau()->groups->button_args ) {
    1013                                 $button_args = bp_nouveau()->groups->button_args;
    1014 
    1015                                 // If we pass through parent classes merge those into the existing ones
    1016                                 if ( $parent_class ) {
    1017                                         $parent_class .= ' ' . $button_args['wrapper_class'];
    1018                                 }
    1019 
    1020                                 // The join or leave group header button should default to 'button'
    1021                                 // Reverse the earler button var to set default as 'button' not 'a'
    1022                                 if ( empty( $args['button_element'] ) ) {
    1023                                         $button_element = 'button';
    1024                                 }
    1025 
    1026                                 $buttons['group_membership'] = array(
    1027                                         'id'                => 'group_membership',
    1028                                         'position'          => 5,
    1029                                         'component'         => $button_args['component'],
    1030                                         'must_be_logged_in' => $button_args['must_be_logged_in'],
    1031                                         'block_self'        => $button_args['block_self'],
    1032                                         'parent_element'    => $parent_element,
    1033                                         'button_element'    => $button_element,
    1034                                         'link_text'         => $button_args['link_text'],
    1035                                         'parent_attr'       => array(
    1036                                                         'id'    => $button_args['wrapper_id'],
    1037                                                         'class' => $parent_class,
    1038                                         ),
    1039                                         'button_attr'       => array(
    1040                                                 'id'    => ! empty( $button_args['link_id'] ) ? $button_args['link_id'] : '',
    1041                                                 'class' => $button_args['link_class'] . ' button',
    1042                                                 'rel'   => ! empty( $button_args['link_rel'] ) ? $button_args['link_rel'] : '',
    1043                                                 'title' => '',
    1044                                         ),
    1045                                 );
     999                        $button_args = bp_groups_get_group_join_button_args( $group );
     1000
     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                        );
    10461033
    10471034                        // If button element set add nonce 'href' link to data-attr attr.
    … …  
    10511038                        // Else this is an anchor so use an 'href' attr.
    10521039                                $buttons['group_membership']['button_attr']['href'] = $button_args['link_href'];
    1053                         }
    1054 
    1055                                 unset( bp_nouveau()->groups->button_args );
    10561040                        }
    10571041                }
Note: See TracChangeset for help on using the changeset viewer.