Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/22/2022 09:32:13 AM (4 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-messages/bp-messages-template.php

    r13295 r13300  
    15051505 * @since 3.0.0 Added `$args` parameter.
    15061506 *
    1507  * @param array|string $args See {@link bp_get_send_message_button()}.
     1507 * @see bp_get_send_message_button_args() for description of parameters.
     1508 *
     1509 * @param array|string $args See {@link bp_get_send_message_button_args()}.
    15081510 */
    15091511function bp_send_message_button( $args = '' ) {
    15101512        echo bp_get_send_message_button( $args );
    15111513}
    1512         /**
    1513          * Generate the 'Private Message' button for member profile headers.
    1514          *
    1515          * @since 1.2.0
    1516          * @since 3.0.0 Added `$args` parameter.
     1514
     1515        /**
     1516         * Get the arguments for the private message button.
     1517         *
     1518         * @since 11.0.0
    15171519         *
    15181520         * @param array|string $args {
    1519          *     All arguments are optional. See {@link BP_Button} for complete
    1520          *     descriptions.
    1521          *     @type string $id                Default: 'private_message'.
    1522          *     @type string $component         Default: 'messages'.
    1523          *     @type bool   $must_be_logged_in Default: true.
    1524          *     @type bool   $block_self        Default: true.
    1525          *     @type string $wrapper_id        Default: 'send-private-message'.
    1526          *     @type string $link_href         Default: the private message link for
    1527          *                                     the current member in the loop.
    1528          *     @type string $link_text         Default: 'Private Message'.
    1529          *     @type string $link_class        Default: 'send-message'.
     1521         *    All arguments are optional. See {@link BP_Button} for complete
     1522         *    descriptions.
     1523         *    @type string $id                Default: 'private_message'.
     1524         *    @type string $component         Default: 'messages'.
     1525         *    @type bool   $must_be_logged_in Default: true.
     1526         *    @type bool   $block_self        Default: true.
     1527         *    @type string $wrapper_id        Default: 'send-private-message'.
     1528         *    @type string $link_href         Default: the private message link for
     1529         *                                    the current member in the loop.
     1530         *    @type string $link_title        Default: 'Send a private message to this member.'.
     1531         *    @type string $link_text         Default: 'Private Message'.
     1532         *    @type string $link_class        Default: 'send-message'.
    15301533         * }
    1531          * @return string
    1532          */
    1533         function bp_get_send_message_button( $args = '' ) {
    1534 
    1535                 $r = bp_parse_args(
     1534         * @return array The arguments for the public message button.
     1535         */
     1536        function bp_get_send_message_button_args( $args = '' ) {
     1537                $button_args = bp_parse_args(
    15361538                        $args,
    15371539                        array(
    … …  
    15431545                                'link_href'         => bp_get_send_private_message_link(),
    15441546                                'link_text'         => __( 'Private Message', 'buddypress' ),
     1547                                'link_title'        => __( 'Send a private message to this member.', 'buddypress' ),
    15451548                                'link_class'        => 'send-message',
    15461549                        )
    15471550                );
    15481551
    1549                 // Note: 'bp_get_send_message_button' is a legacy filter. Use
    1550                 // 'bp_get_send_message_button_args' instead. See #4536.
    1551                 return apply_filters( 'bp_get_send_message_button',
    1552 
    1553                         /**
    1554                          * Filters the "Private Message" button for member profile headers.
    1555                          *
    1556                          * @since 1.8.0
    1557                          *
    1558                          * @param array $value See {@link BP_Button}.
    1559                          */
    1560                         bp_get_button( apply_filters( 'bp_get_send_message_button_args', $r ) )
     1552                /**
     1553                 * Filters the "Private Message" button for member profile headers.
     1554                 *
     1555                 * @since 1.8.0
     1556                 *
     1557                 * @param array $button_args See {@link BP_Button}.
     1558                 */
     1559                return apply_filters( 'bp_get_send_message_button_args', $button_args );
     1560        }
     1561
     1562        /**
     1563         * Generate the 'Private Message' button for member profile headers.
     1564         *
     1565         * @since 1.2.0
     1566         * @since 3.0.0 Added `$args` parameter.
     1567         * @since 11.0.0 uses `bp_get_send_message_button_args()`.
     1568         *
     1569         * @see bp_get_send_message_button_args() for description of parameters.
     1570         *
     1571         * @param array|string $args See {@link bp_get_send_message_button_args()}.
     1572         * @return string
     1573         */
     1574        function bp_get_send_message_button( $args = '' ) {
     1575                $button_args = bp_get_send_message_button_args( $args );
     1576
     1577                if ( ! array_filter( $button_args ) ) {
     1578                        return '';
     1579                }
     1580
     1581                /** This filter is documented in wp-includes/deprecated.php */
     1582                $button = apply_filters_deprecated(
     1583                        'bp_get_send_message_button',
     1584                        array( bp_get_button( $button_args ) ),
     1585                        '1.8.0',
     1586                        'bp_get_send_message_button_args'
    15611587                );
     1588
     1589                return $button;
    15621590        }
    15631591
Note: See TracChangeset for help on using the changeset viewer.