Ticket #5938: bp-activity-notifications-5938.diff
File bp-activity-notifications-5938.diff, 11.0 KB (added by , 10 years ago) |
---|
-
src/bp-activity/bp-activity-notifications.php
15 15 /** 16 16 * Send email and BP notifications when a user is mentioned in an update. 17 17 * 18 * @since BuddyPress (1.2 )18 * @since BuddyPress (1.2.0) 19 19 * 20 20 * @uses bp_notifications_add_notification() 21 21 * @uses bp_get_user_meta() … … 99 99 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 100 100 } 101 101 102 // Send the message 102 /** 103 * Filters the user email that the @mention notification will be sent to. 104 * 105 * @since BuddyPress (1.2.0) 106 * 107 * @param string $to User email the notification is being sent to. 108 */ 103 109 $to = apply_filters( 'bp_activity_at_message_notification_to', $to ); 110 111 /** 112 * Filters the @mention notification subject that will be sent to user. 113 * 114 * @since BuddyPress (1.2.0) 115 * 116 * @param string $subject Email notification subject text. 117 * @param string $poster_name Name of the person who made the @mention. 118 */ 104 119 $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject, $poster_name ); 120 121 /** 122 * Filters the @mention notification message that will be sent to user. 123 * 124 * @since BuddyPress (1.2.0) 125 * 126 * @param string $message Email notification message text. 127 * @param string $poster_name Name of the person who made the @mention. 128 * @param string $content Content of the @mention. 129 * @param string $message_link URL permalink for the activity message. 130 * @param string $settings_link URL permalink for the user's notification settings area. 131 */ 105 132 $message = apply_filters( 'bp_activity_at_message_notification_message', $message, $poster_name, $content, $message_link, $settings_link ); 106 133 107 134 wp_mail( $to, $subject, $message ); 108 135 } 109 136 137 /** 138 * Fires after the sending of an @mention email notification. 139 * 140 * @since BuddyPress (1.5.0) 141 * 142 * @param BP_Activity_Activity $activity Activity Item object. 143 * @param string $subject Email notification subject text. 144 * @param string $message Email notification message text. 145 * @param string $content Content of the @mention. 146 * @param int $receiver_user_id The ID of the user who is receiving the update. 147 */ 110 148 do_action( 'bp_activity_sent_mention_email', $activity, $subject, $message, $content, $receiver_user_id ); 111 149 } 112 150 … … 113 151 /** 114 152 * Send email and BP notifications when an activity item receives a comment. 115 153 * 116 * @since BuddyPress (1.2 )154 * @since BuddyPress (1.2.0) 117 155 * 118 156 * @uses bp_get_user_meta() 119 157 * @uses bp_core_get_user_displayname() … … 177 215 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 178 216 } 179 217 180 /* Send the message */ 218 /** 219 * Filters the user email that the new comment notification will be sent to. 220 * 221 * @since BuddyPress (1.2.0) 222 * 223 * @param string $to User email the notification is being sent to. 224 */ 181 225 $to = apply_filters( 'bp_activity_new_comment_notification_to', $to ); 226 227 /** 228 * Filters the new comment notification subject that will be sent to user. 229 * 230 * @since BuddyPress (1.2.0) 231 * 232 * @param string $subject Email notification subject text. 233 * @param string $poster_name Name of the person who made the comment. 234 */ 182 235 $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name ); 236 237 /** 238 * Filters the new comment notification message that will be sent to user. 239 * 240 * @since BuddyPress (1.2.0) 241 * 242 * @param string $message Email notification message text. 243 * @param string $poster_name Name of the person who made the comment. 244 * @param string $content Content of the comment. 245 * @param string $thread_link URL permalink for the activity thread. 246 * @param string $settings_link URL permalink for the user's notification settings area. 247 */ 183 248 $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link ); 184 249 185 250 wp_mail( $to, $subject, $message ); 186 251 252 /** 253 * Fires after the sending of a reply to an update email notification. 254 * 255 * @since BuddyPress (1.5.0) 256 * 257 * @param int $user_id ID of the original activity item author. 258 * @param string $subject Email notification subject text. 259 * @param string $message Email notification message text. 260 * @param int $comment_id ID for the newly received comment. 261 * @param int $commenter_id ID of the user who made the comment. 262 * @param array $params Arguments used with the original activity comment. 263 */ 187 264 do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params ); 188 265 } 189 266 … … 226 303 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 227 304 } 228 305 229 /* Send the message */ 306 /** 307 * Filters the user email that the new comment reply notification will be sent to. 308 * 309 * @since BuddyPress (1.2.0) 310 * 311 * @param string $to User email the notification is being sent to. 312 */ 230 313 $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to ); 314 315 /** 316 * Filters the new comment reply notification subject that will be sent to user. 317 * 318 * @since BuddyPress (1.2.0) 319 * 320 * @param string $subject Email notification subject text. 321 * @param string $poster_name Name of the person who made the comment reply. 322 */ 231 323 $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name ); 324 325 /** 326 * Filters the new comment reply notification message that will be sent to user. 327 * 328 * @since BuddyPress (1.2.0) 329 * 330 * @param string $message Email notification message text. 331 * @param string $poster_name Name of the person who made the comment reply. 332 * @param string $content Content of the comment reply. 333 * @param string $settings_link URL permalink for the user's notification settings area. 334 * @param string $thread_link URL permalink for the activity thread. 335 */ 232 336 $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link ); 233 337 234 338 wp_mail( $to, $subject, $message ); 235 339 340 /** 341 * Fires after the sending of a reply to a reply email notification. 342 * 343 * @since BuddyPress (1.5.0) 344 * 345 * @param int $user_id ID of the original activity item author. 346 * @param string $subject Email notification subject text. 347 * @param string $message Email notification message text. 348 * @param int $comment_id ID for the newly received comment. 349 * @param int $commenter_id ID of the user who made the comment. 350 * @param array $params Arguments used with the original activity comment. 351 */ 236 352 do_action( 'bp_activity_sent_reply_to_reply_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params ); 237 353 } 238 354 } … … 254 370 /** 255 371 * Format notifications related to activity. 256 372 * 257 * @since BuddyPress (1.5 )373 * @since BuddyPress (1.5.0) 258 374 * 259 375 * @uses bp_loggedin_user_domain() 260 376 * @uses bp_get_activity_slug() … … 278 394 $poster_user_id = $secondary_item_id; 279 395 $at_mention_link = bp_loggedin_user_domain() . bp_get_activity_slug() . '/mentions/'; 280 396 $at_mention_title = sprintf( __( '@%s Mentions', 'buddypress' ), bp_get_loggedin_user_username() ); 397 $amount = 'single'; 281 398 282 399 if ( (int) $total_items > 1 ) { 283 400 $text = sprintf( __( 'You have %1$d new mentions', 'buddypress' ), (int) $total_items ); 284 $ filter = 'bp_activity_multiple_at_mentions_notification';401 $amount = 'multiple'; 285 402 } else { 286 403 $user_fullname = bp_core_get_user_displayname( $poster_user_id ); 287 404 $text = sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname ); 288 $filter = 'bp_activity_single_at_mentions_notification';289 405 } 290 406 break; 291 407 } 292 408 293 409 if ( 'string' == $format ) { 294 $return = apply_filters( $filter, '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); 410 411 /** 412 * Filters the @mention notification for the string format. 413 * 414 * This is a variable filter that is dependent on how many items need notified about. The two possible hooks are bp_activity_single_at_mentions_notification or bp_activity_multiple_at_mentions_notification. 415 * 416 * @since BuddyPress (1.5.0) 417 * 418 * @param string $string HTML anchor tag for the mention. 419 * @param string $at_mention_link The permalink for the mention. 420 * @param int $total_items How many items being notified about. 421 * @param int $activity_id ID of the activity item being formatted. 422 * @param int $poster_user_id ID of the user posting the mention. 423 */ 424 $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', '<a href="' . esc_url( $at_mention_link ) . '" title="' . esc_attr( $at_mention_title ) . '">' . esc_html( $text ) . '</a>', $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); 295 425 } else { 296 $return = apply_filters( $filter, array( 426 427 /** 428 * Filters the @mention notification for any non-string format. 429 * 430 * This is a variable filter that is dependent on how many items need notified about. The two possible hooks are bp_activity_single_at_mentions_notification or bp_activity_multiple_at_mentions_notification. 431 * 432 * @since BuddyPress (1.5.0) 433 * 434 * @param array $array Array holding the content and permalink for the mention notification. 435 * @param string $at_mention_link The permalink for the mention. 436 * @param int $total_items How many items being notified about. 437 * @param int $activity_id ID of the activity item being formatted. 438 * @param int $poster_user_id ID of the user posting the mention. 439 */ 440 $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array( 297 441 'text' => $text, 298 442 'link' => $at_mention_link 299 443 ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); 300 444 } 301 445 446 /** 447 * Fires right before returning the formatted activity notifications. 448 * 449 * @since BuddyPress (1.2.0) 450 * 451 * @param string $action The type of activity item. 452 * @param int $item_id The activity ID. 453 * @param int $secondary_item_id @mention mentioner ID. 454 * @param int $total_items Total amount of items to format. 455 */ 302 456 do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items ); 303 457 304 458 return $return; … … 338 492 /** 339 493 * Mark at-mention notifications as read when users visit their Mentions page. 340 494 * 341 * @since BuddyPress (1.5 )495 * @since BuddyPress (1.5.0) 342 496 * 343 497 * @uses bp_notifications_mark_all_notifications_by_type() 344 498 */