Ticket #5942: bp-friends-notifications-5942.diff
| File bp-friends-notifications-5942.diff, 6.9 KB (added by , 11 years ago) |
|---|
-
src/bp-friends/bp-friends-notifications.php
56 56 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 57 57 } 58 58 59 // Send the message 59 /** 60 * Filters the email address for who is getting the friend request. 61 * 62 * @since BuddyPress (1.2.0) 63 * 64 * @param string $to Email address for who is getting the friend request. 65 */ 60 66 $to = apply_filters( 'friends_notification_new_request_to', $to ); 67 68 /** 69 * Filters the subject for the friend request email. 70 * 71 * @since BuddyPress (1.2.0) 72 * 73 * @param string $subject Subject line to be used in friend request email. 74 * @param string $initiator_name Name of the person requesting friendship. 75 */ 61 76 $subject = apply_filters( 'friends_notification_new_request_subject', $subject, $initiator_name ); 77 78 /** 79 * Filters the message for the friend request email. 80 * 81 * @since BuddyPress (1.2.0) 82 * 83 * @param string $message Message to be used in friend request email. 84 * @param string $initiator_name Name of the person requesting friendship. 85 * @param string $initiator_link Profile link of person requesting friendship. 86 * @param string $all_requests_link User's friends request management link. 87 * @param string $settings_link Email recipient's settings management link. 88 */ 62 89 $message = apply_filters( 'friends_notification_new_request_message', $message, $initiator_name, $initiator_link, $all_requests_link, $settings_link ); 63 90 64 91 wp_mail( $to, $subject, $message ); 65 92 93 /** 94 * Fires after the new friend request email is sent. 95 * 96 * @since BuddyPress (1.5.0) 97 * 98 * @param int $friend_id ID of the request recipient. 99 * @param string $subject Text for the friend request subject field. 100 * @param string $message Text for the friend request message field. 101 * @param int $friendship_id ID of the friendship object. 102 * @param int $initiator_id ID of the friendship requester. 103 */ 66 104 do_action( 'bp_friends_sent_request_email', $friend_id, $subject, $message, $friendship_id, $initiator_id ); 67 105 } 68 106 add_action( 'friends_friendship_requested', 'friends_notification_new_request', 10, 3 ); … … 105 143 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 106 144 } 107 145 108 // Send the message 146 /** 147 * Filters the email address for whose friend request got accepted. 148 * 149 * @since BuddyPress (1.2.0) 150 * 151 * @param string $to Email address for whose friend request got accepted. 152 */ 109 153 $to = apply_filters( 'friends_notification_accepted_request_to', $to ); 154 155 /** 156 * Filters the subject for the friend request accepted email. 157 * 158 * @since BuddyPress (1.2.0) 159 * 160 * @param string $subject Subject line to be used in friend 161 * request accepted email. 162 * @param string $friend_name Name of the person who accepted 163 * the friendship request. 164 */ 110 165 $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject, $friend_name ); 166 167 /** 168 * Filters the message for the friend request accepted email. 169 * 170 * @since BuddyPress (1.2.0) 171 * 172 * @param string $message Message to be used in friend request email. 173 * @param string $friend_name Name of the person who accepted 174 * the friendship request. 175 * @param string $friend_link Profile link of person who accepted 176 * the friendship request. 177 * @param string $settings_link Email recipient's settings management link. 178 */ 111 179 $message = apply_filters( 'friends_notification_accepted_request_message', $message, $friend_name, $friend_link, $settings_link ); 112 180 113 181 wp_mail( $to, $subject, $message ); 114 182 183 /** 184 * Fires after the friend request accepted email is sent. 185 * 186 * @since BuddyPress (1.5.0) 187 * 188 * @param int $initiator_id ID of the friendship requester. 189 * @param string $subject Text for the friend request subject field. 190 * @param string $message Text for the friend request message field. 191 * @param int $friendship_id ID of the friendship object. 192 * @param int $friend_id ID of the request recipient. 193 */ 115 194 do_action( 'bp_friends_sent_accepted_email', $initiator_id, $subject, $message, $friendship_id, $friend_id ); 116 195 } 117 196 add_action( 'friends_friendship_accepted', 'friends_notification_accepted_request', 10, 3 ); … … 136 215 case 'friendship_accepted': 137 216 $link = trailingslashit( bp_loggedin_user_domain() . bp_get_friends_slug() . '/my-friends' ); 138 217 139 // $action and $amount are used to generate dynamic filter names.140 218 $action = 'accepted'; 141 219 142 220 // Set up the string and the filter … … 169 247 170 248 // Return either an HTML link or an array, depending on the requested format 171 249 if ( 'string' == $format ) { 250 251 /** 252 * Filters the format of friendship notifications based on type and amount 253 * of notifications pending. 254 * 255 * This is a variable filter that has four possible versions. 256 * The four possible versions are: 257 * bp_friends_single_friendship_accepted_notification 258 * bp_friends_multiple_friendship_accepted_notification 259 * bp_friends_single_friendship_request_notification 260 * bp_friends_multiple_friendship_request_notification 261 * 262 * @since BuddyPress (1.0.0) 263 * 264 * @param string|array $value Depending on format, an HTML link to new 265 * requests profile tab or array with link and text. 266 * @param int $total_items The total number of messaging-related 267 * notifications waiting for the user. 268 * @param int $item_id The primary item ID. 269 */ 172 270 $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', '<a href="' . esc_url( $link ) . '">' . esc_html( $text ) . '</a>', (int) $total_items, $item_id ); 173 271 } else { 272 /** This filter is documented in bp-friends/bp-friends-notifications.php */ 174 273 $return = apply_filters( 'bp_friends_' . $amount . '_friendship_' . $action . '_notification', array( 175 274 'link' => $link, 176 275 'text' => $text … … 177 276 ), (int) $total_items, $item_id ); 178 277 } 179 278 279 /** 280 * Fires at the end of the bp-friends notification format callback. 281 * 282 * @since BuddyPress (1.0.0) 283 * 284 * @param string $action The kind of notification being rendered. 285 * @param int $item_id The primary item ID. 286 * @param int $secondary_item_id The secondary item ID. 287 * @param int $total_items The total number of messaging-related notifications 288 * waiting for the user. 289 * @param array|string $return Notification text string or array of link and text. 290 */ 180 291 do_action( 'friends_format_notifications', $action, $item_id, $secondary_item_id, $total_items, $return ); 181 292 182 293 return $return;