Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 12:54:40 PM (4 years ago)
Author:
imath
Message:

Introduce a function to only get the "Visit blog" button args

bp_get_blogs_visit_blog_button_args() eases the process of getting these arguments and removes the need for BP Nouveau's workaround.
Deprecate the bp_nouveau_blogs_catch_button_args() as no more needed.

Props hnla

Fixes #7126
See #8722

File:
1 edited

Legend:

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

    r12567 r13303  
    200200                }
    201201
    202                 /*
    203                  * This filter workaround is waiting for a core adaptation
    204                  * so that we can directly get the groups button arguments
    205                  * instead of the button.
    206                  *
    207                  * See https://buddypress.trac.wordpress.org/ticket/7126
    208                  */
    209                 add_filter( 'bp_get_blogs_visit_blog_button', 'bp_nouveau_blogs_catch_button_args', 100, 1 );
    210 
    211                 bp_get_blogs_visit_blog_button();
    212 
    213                 remove_filter( 'bp_get_blogs_visit_blog_button', 'bp_nouveau_blogs_catch_button_args', 100, 1 );
    214 
    215                 if ( isset( bp_nouveau()->blogs->button_args ) && bp_nouveau()->blogs->button_args ) {
    216                         $button_args = bp_nouveau()->blogs->button_args ;
    217 
    218                         // If we pass through parent classes add them to $button array
    219                         $parent_class = '';
    220                         if ( ! empty( $args['parent_attr']['class'] ) ) {
    221                                 $parent_class = $args['parent_attr']['class'];
    222                         }
    223 
    224                         // Set defaults if not set.
    225                         $button_args = array_merge( array(
    226                                 'wrapper_id' => '',
    227                                 'link_id'    => '',
    228                                 'link_rel'   => ''
    229                         ), $button_args );
    230 
    231                         $buttons['visit_blog'] = array(
    232                                 'id'                => 'visit_blog',
    233                                 'position'          => 5,
    234                                 'component'         => $button_args['component'],
    235                                 'must_be_logged_in' => $button_args['must_be_logged_in'],
    236                                 'block_self'        => $button_args['block_self'],
    237                                 'parent_element'    => $parent_element,
    238                                 'button_element'    => $button_element,
    239                                 'link_text'         => $button_args['link_text'],
    240                                 'parent_attr'       => array(
    241                                         'id'              => $button_args['wrapper_id'],
    242                                         'class'           => $parent_class,
    243                                 ),
    244                                 'button_attr'       => array(
    245                                         'href'             => $button_args['link_href'],
    246                                         'id'               => $button_args['link_id'],
    247                                         'class'            => $button_args['link_class'] . ' button',
    248                                         'rel'              => $button_args['link_rel'],
    249                                         'title'            => '',
    250                                 ),
    251                         );
    252 
    253                         unset( bp_nouveau()->blogs->button_args );
    254                 }
     202                $button_args = bp_get_blogs_visit_blog_button_args();
     203
     204                // If we pass through parent classes add them to $button array
     205                $parent_class = '';
     206                if ( ! empty( $args['parent_attr']['class'] ) ) {
     207                        $parent_class = $args['parent_attr']['class'];
     208                }
     209
     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                );
    255239
    256240                /**
Note: See TracChangeset for help on using the changeset viewer.