Changeset 10706
- Timestamp:
- 04/14/2016 08:36:39 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-messages/bp-messages-notifications.php
r10513 r10706 104 104 function messages_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { 105 105 $total_items = (int) $total_items; 106 $text = ''; 106 107 $link = trailingslashit( bp_loggedin_user_domain() . bp_get_messages_slug() . '/inbox' ); 107 108 $title = __( 'Inbox', 'buddypress' ); … … 112 113 $amount = 'multiple'; 113 114 $text = sprintf( __( 'You have %d new messages', 'buddypress' ), $total_items ); 115 114 116 } else { 115 $amount = 'single';116 117 117 // Get message thread ID. 118 118 $message = new BP_Messages_Message( $item_id ); … … 128 128 } 129 129 } 130 } 131 132 if ( 'string' === $format ) { 133 if ( ! empty( $link ) ) { 134 $retval = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $text ) . '</a>'; 130 131 if ( 'string' === $format ) { 132 if ( ! empty( $link ) ) { 133 $return = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $title ) . '">' . esc_html( $text ) . '</a>'; 134 } else { 135 $return = esc_html( $text ); 136 } 137 138 /** 139 * Filters the new message notification text before the notification is created. 140 * 141 * This is a dynamic filter. Possible filter names are: 142 * - 'bp_messages_multiple_new_message_notification'. 143 * - 'bp_messages_single_new_message_notification'. 144 * 145 * @param string $return Notification text. 146 * @param int $total_items Number of messages referred to by the notification. 147 * @param string $text The raw notification test (ie, not wrapped in a link). 148 * @param int $item_id ID of the associated item. 149 * @param int $secondary_item_id ID of the secondary associated item. 150 */ 151 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 135 152 } else { 136 $retval = esc_html( $text ); 153 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 154 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', array( 155 'text' => $text, 156 'link' => $link 157 ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 158 } 159 160 // Custom notification action for the Messages component 161 } else { 162 if ( 'string' === $format ) { 163 $return = $text; 164 } else { 165 $return = array( 166 'text' => $text, 167 'link' => $link 168 ); 137 169 } 138 170 139 171 /** 140 * Filters the new message notification text before the notification is created. 172 * Backcompat for plugins that used to filter bp_messages_single_new_message_notification 173 * for their custom actions. These plugins should now use 'bp_messages_' . $action . '_notification' 174 */ 175 if ( has_filter( 'bp_messages_single_new_message_notification' ) ) { 176 if ( 'string' === $format ) { 177 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 178 $return = apply_filters( 'bp_messages_single_new_message_notification', $return, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 179 180 // Notice that there are seven parameters instead of six? Ugh... 181 } else { 182 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 183 $return = apply_filters( 'bp_messages_single_new_message_notification', $return, $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 184 } 185 } 186 187 /** 188 * Filters the custom action notification before the notification is created. 141 189 * 142 * This is a dynamic filter. Possible filter names are: 143 * - 'bp_messages_multiple_new_message_notification'. 144 * - 'bp_messages_single_new_message_notification'. 190 * This is a dynamic filter based on the message notification action. 145 191 * 146 * @ param string $retval Notification text.147 * @param int $total_items Number of messages referred to by the notification.148 * @param string $text The raw notification test (ie, not wrapped in a link).192 * @since 2.6.0 193 * 194 * @param array $value An associative array containing the text and the link of the notification 149 195 * @param int $item_id ID of the associated item. 150 196 * @param int $secondary_item_id ID of the secondary associated item. 197 * @param int $total_items Number of messages referred to by the notification. 198 * @param string $format Return value format. 'string' for BuddyBar-compatible 199 * notifications; 'array' for WP Toolbar. Default: 'string'. 151 200 */ 152 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', $retval, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 153 } else { 154 /** This filter is documented in bp-messages/bp-messages-notifications.php */ 155 $return = apply_filters( 'bp_messages_' . $amount . '_new_message_notification', array( 156 'text' => $text, 157 'link' => $link 158 ), $link, (int) $total_items, $text, $link, $item_id, $secondary_item_id ); 201 $return = apply_filters( "bp_messages_{$action}_notification", $return, $item_id, $secondary_item_id, $total_items, $format ); 159 202 } 160 203
Note: See TracChangeset
for help on using the changeset viewer.