Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 09:32:13 AM (3 years ago)
Author:
imath
Message:

Introduce a function to only get the Private Message button arguments

bp_get_send_message_button_args() eases the process of getting these arguments and removes the need for BP Nouveau's 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

    r13299 r13300  
    402402
    403403            if ( bp_is_active( 'messages' ) ) {
    404                 /**
    405                  * This filter workaround is waiting for a core adaptation
    406                  * so that we can directly get the private messages button arguments
    407                  * instead of the button.
    408                  * @see https://buddypress.trac.wordpress.org/ticket/7126
     404                $button_args = bp_get_send_message_button_args();
     405
     406                /*
     407                 * This button should remain as an anchor link.
     408                 * Hardcode the use of anchor elements if button arg passed in for other elements.
    409409                 */
    410                 add_filter( 'bp_get_send_message_button_args', 'bp_nouveau_members_catch_button_args', 100, 1 );
    411 
    412                 bp_get_send_message_button();
    413 
    414                 remove_filter( 'bp_get_send_message_button_args', 'bp_nouveau_members_catch_button_args', 100, 1 );
    415 
    416                 if ( isset( bp_nouveau()->members->button_args ) && bp_nouveau()->members->button_args ) {
    417                     $button_args = bp_nouveau()->members->button_args;
    418 
    419                     /*
    420                      * This button should remain as an anchor link.
    421                      * Hardcode the use of anchor elements if button arg passed in for other elements.
    422                      */
    423                     $buttons['private_message'] = array(
    424                         'id'                => $button_args['id'],
    425                         'position'          => 25,
    426                         'component'         => $button_args['component'],
    427                         'must_be_logged_in' => $button_args['must_be_logged_in'],
    428                         'block_self'        => $button_args['block_self'],
    429                         'parent_element'    => $parent_element,
    430                         'button_element'    => 'a',
    431                         'link_text'         => $button_args['link_text'],
    432                         'parent_attr'       => array(
    433                             'id'    => $button_args['wrapper_id'],
    434                             'class' => $parent_class,
    435                         ),
    436                         'button_attr'       => array(
    437                             'href'  => bp_get_send_private_message_link(),
    438                             'id'    => false,
    439                             'class' => $button_args['link_class'],
    440                             'rel'   => '',
    441                             'title' => '',
    442                         ),
    443                     );
    444 
    445                     unset( bp_nouveau()->members->button_args );
    446                 }
     410                $buttons['private_message'] = array(
     411                    'id'                => $button_args['id'],
     412                    'position'          => 25,
     413                    'component'         => $button_args['component'],
     414                    'must_be_logged_in' => $button_args['must_be_logged_in'],
     415                    'block_self'        => $button_args['block_self'],
     416                    'parent_element'    => $parent_element,
     417                    'button_element'    => 'a',
     418                    'link_text'         => $button_args['link_text'],
     419                    'link_title'        => $button_args['link_title'],
     420                    'parent_attr'       => array(
     421                        'id'    => $button_args['wrapper_id'],
     422                        'class' => $parent_class,
     423                    ),
     424                    'button_attr'       => array(
     425                        'href'  => bp_get_send_private_message_link(),
     426                        'id'    => false,
     427                        'class' => $button_args['link_class'],
     428                        'rel'   => '',
     429                        'title' => '',
     430                    ),
     431                );
    447432            }
    448433        }
Note: See TracChangeset for help on using the changeset viewer.