Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 09:00:42 AM (4 years ago)
Author:
imath
Message:

Introduce a function to only get the Public Message button arguments

BP Nouveau is doing a complex workaround to only get these arguments without generating the BP_Button HTML output. bp_activity_get_public_message_button_args() eases the process of getting these arguments and removes the need for such a workaround.

Props hnla

See #7126
See #8722

File:
1 edited

Legend:

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

    r13276 r13299  
    373373                if ( 'profile' === $type ) {
    374374                        if ( bp_is_active( 'activity' ) && bp_activity_do_mentions() ) {
     375                                $button_args = bp_activity_get_public_message_button_args();
     376
    375377                                /*
    376                                  * This filter workaround is waiting for a core adaptation
    377                                  * so that we can directly get the public message button arguments
    378                                  * instead of the button.
    379                                  *
    380                                  * See https://buddypress.trac.wordpress.org/ticket/7126
     378                                 * This button should remain as an anchor link.
     379                                 * Hardcode the use of anchor elements if button arg passed in for other elements.
    381380                                 */
    382                                 add_filter( 'bp_get_send_public_message_button', 'bp_nouveau_members_catch_button_args', 100, 1 );
    383 
    384                                 bp_get_send_public_message_button();
    385 
    386                                 remove_filter( 'bp_get_send_public_message_button', 'bp_nouveau_members_catch_button_args', 100, 1 );
    387 
    388                                 if ( isset( bp_nouveau()->members->button_args ) && bp_nouveau()->members->button_args ) {
    389                                         $button_args = bp_nouveau()->members->button_args;
    390 
    391                                         /*
    392                                          * This button should remain as an anchor link.
    393                                          * Hardcode the use of anchor elements if button arg passed in for other elements.
    394                                          */
    395                                         $buttons['public_message'] = array(
    396                                                 'id'                => $button_args['id'],
    397                                                 'position'          => 15,
    398                                                 'component'         => $button_args['component'],
    399                                                 'must_be_logged_in' => $button_args['must_be_logged_in'],
    400                                                 'block_self'        => $button_args['block_self'],
    401                                                 'parent_element'    => $parent_element,
    402                                                 'button_element'    => 'a',
    403                                                 'link_text'         => $button_args['link_text'],
    404                                                 'parent_attr'       => array(
    405                                                         'id'    => $button_args['wrapper_id'],
    406                                                         'class' => $parent_class,
    407                                                 ),
    408                                                 'button_attr'       => array(
    409                                                         'href'             => $button_args['link_href'],
    410                                                         'id'               => '',
    411                                                         'class'            => $button_args['link_class'],
    412                                                 ),
    413                                         );
    414                                         unset( bp_nouveau()->members->button_args );
    415                                 }
     381                                $buttons['public_message'] = array(
     382                                        'id'                => $button_args['id'],
     383                                        'position'          => 15,
     384                                        'component'         => $button_args['component'],
     385                                        'must_be_logged_in' => $button_args['must_be_logged_in'],
     386                                        'block_self'        => $button_args['block_self'],
     387                                        'parent_element'    => $parent_element,
     388                                        'button_element'    => 'a',
     389                                        'link_text'         => $button_args['link_text'],
     390                                        'link_title'        => $button_args['link_title'],
     391                                        'parent_attr'       => array(
     392                                                'id'    => $button_args['wrapper_id'],
     393                                                'class' => $parent_class,
     394                                        ),
     395                                        'button_attr'       => array(
     396                                                'href'             => $button_args['link_href'],
     397                                                'id'               => '',
     398                                                'class'            => $button_args['link_class'],
     399                                        ),
     400                                );
    416401                        }
    417402
Note: See TracChangeset for help on using the changeset viewer.