Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/03/2014 03:27:09 PM (12 years ago)
Author:
boonebgorges
Message:

Assemble message notification filters dynamically.

This allows us to centralize the documentation.

Props tw2113.
See #5970.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-messages/bp-messages-notifications.php

    r8947 r9208  
    129129        if ( 'new_message' === $action ) {
    130130                if ( $total_items > 1 ) {
     131                        $amount = 'multiple';
    131132                        $text   = sprintf( __( 'You have %d new messages', 'buddypress' ), $total_items );
    132                         $filter = 'bp_messages_multiple_new_message_notification';
    133133                } else {
     134                        $amount = 'single';
     135
    134136                        // get message thread ID
    135137                        $message   = new BP_Messages_Message( $item_id );
     
    144146                                $text = sprintf( _n( 'You have %s new private message', 'You have %s new private messages', $total_items, 'buddypress' ), bp_core_number_format( $total_items ) );
    145147                        }
    146                         $filter = 'bp_messages_single_new_message_notification';
    147148                }
    148149        }
     
    154155                        $retval = esc_html( $text );
    155156                }
    156                 $return = apply_filters( $filter, $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
     157
     158                /**
     159                 * Filters the new message notification text before the notification is created.
     160                 *
     161                 * This is a dynamic filter. Possible filter names are:
     162                 *   - 'bp_messages_multiple_new_message_notification'
     163                 *   - 'bp_messages_single_new_message_notification'
     164                 *
     165                 * @param string $retval            Notification text.
     166                 * @param int    $total_items       Number of messages referred to by the notification.
     167                 * @param string $text              The raw notification test (ie, not wrappen in a link).
     168                 * @param int    $item_id           ID of the associated item.
     169                 * @param int    $secondary_item_id ID of the secondary associated item.
     170                 */
     171                $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id );
    157172        } else {
    158                 $return = apply_filters( $filter, array(
     173                /** This filter is documented in bp-messages/bp-messages-notifications.php */
     174                $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', array(
    159175                        'text' => $text,
    160176                        'link' => $link
Note: See TracChangeset for help on using the changeset viewer.