183 | | $activity_id = 0; |
184 | | $parent_id = 0; |
185 | | |
186 | | extract( $params ); |
187 | | |
188 | | $original_activity = new BP_Activity_Activity( $activity_id ); |
189 | | |
190 | | if ( $original_activity->user_id != $commenter_id && 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { |
191 | | $poster_name = bp_core_get_user_displayname( $commenter_id ); |
192 | | $thread_link = bp_activity_get_permalink( $activity_id ); |
193 | | $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; |
194 | | $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/'; |
195 | | |
196 | | $poster_name = stripslashes( $poster_name ); |
197 | | $content = bp_activity_filter_kses( stripslashes($content) ); |
198 | | |
199 | | // Set up and send the message |
200 | | $ud = bp_core_get_core_userdata( $original_activity->user_id ); |
201 | | $to = $ud->user_email; |
202 | | $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ) ) ); |
203 | | $message = sprintf( __( |
| 183 | $reply = (object) wp_parse_args( $params, array( |
| 184 | 'activity_id' => 0, |
| 185 | 'parent_id' => 0, |
| 186 | ) ); |
| 187 | |
| 188 | $original_activity = new BP_Activity_Activity( $reply->activity_id ); |
| 189 | |
| 190 | if ( $original_activity->user_id != $commenter_id ) { |
| 191 | // Send an email if the user has not disabled it |
| 192 | if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { |
| 193 | $poster_name = bp_core_get_user_displayname( $commenter_id ); |
| 194 | $thread_link = bp_activity_get_permalink( $reply->activity_id ); |
| 195 | $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'; |
| 196 | $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . $settings_slug . '/notifications/'; |
| 197 | |
| 198 | $poster_name = stripslashes( $poster_name ); |
| 199 | $content = bp_activity_filter_kses( stripslashes( $reply->content ) ); |
| 200 | |
| 201 | // Set up and send the message |
| 202 | $ud = bp_core_get_core_userdata( $original_activity->user_id ); |
| 203 | $to = $ud->user_email; |
| 204 | $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your updates', 'buddypress' ), $poster_name ) ) ); |
| 205 | $message = sprintf( __( |
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 | | */ |
235 | | $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name ); |
| 220 | /** |
| 221 | * Filters the user email that the new comment notification will be sent to. |
| 222 | * |
| 223 | * @since BuddyPress (1.2.0) |
| 224 | * |
| 225 | * @param string $to User email the notification is being sent to. |
| 226 | */ |
| 227 | $to = apply_filters( 'bp_activity_new_comment_notification_to', $to ); |
| 228 | |
| 229 | /** |
| 230 | * Filters the new comment notification subject that will be sent to user. |
| 231 | * |
| 232 | * @since BuddyPress (1.2.0) |
| 233 | * |
| 234 | * @param string $subject Email notification subject text. |
| 235 | * @param string $poster_name Name of the person who made the comment. |
| 236 | */ |
| 237 | $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject, $poster_name ); |
| 238 | |
| 239 | /** |
| 240 | * Filters the new comment notification message that will be sent to user. |
| 241 | * |
| 242 | * @since BuddyPress (1.2.0) |
| 243 | * |
| 244 | * @param string $message Email notification message text. |
| 245 | * @param string $poster_name Name of the person who made the comment. |
| 246 | * @param string $content Content of the comment. |
| 247 | * @param string $thread_link URL permalink for the activity thread. |
| 248 | * @param string $settings_link URL permalink for the user's notification settings area. |
| 249 | */ |
| 250 | $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link ); |
| 251 | |
| 252 | wp_mail( $to, $subject, $message ); |
| 253 | |
| 254 | /** |
| 255 | * Fires after the sending of a reply to an update email notification. |
| 256 | * |
| 257 | * @since BuddyPress (1.5.0) |
| 258 | * |
| 259 | * @param int $user_id ID of the original activity item author. |
| 260 | * @param string $subject Email notification subject text. |
| 261 | * @param string $message Email notification message text. |
| 262 | * @param int $comment_id ID for the newly received comment. |
| 263 | * @param int $commenter_id ID of the user who made the comment. |
| 264 | * @param array $params Arguments used with the original activity comment. |
| 265 | */ |
| 266 | do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params ); |
| 267 | } |
248 | | $message = apply_filters( 'bp_activity_new_comment_notification_message', $message, $poster_name, $content, $thread_link, $settings_link ); |
249 | | |
250 | | wp_mail( $to, $subject, $message ); |
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 | | */ |
264 | | do_action( 'bp_activity_sent_reply_to_update_email', $original_activity->user_id, $subject, $message, $comment_id, $commenter_id, $params ); |
| 279 | do_action( 'bp_activity_sent_reply_to_update_notification', $original_activity, $comment_id, $commenter_id, $reply ); |
301 | | // Only show the disable notifications line if the settings component is enabled |
302 | | if ( bp_is_active( 'settings' ) ) { |
303 | | $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); |
304 | | } |
305 | | |
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 | | */ |
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 | | */ |
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 | | */ |
336 | | $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link ); |
| 318 | // Only show the disable notifications line if the settings component is enabled |
| 319 | if ( bp_is_active( 'settings' ) ) { |
| 320 | $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); |
| 321 | } |
338 | | wp_mail( $to, $subject, $message ); |
| 323 | /** |
| 324 | * Filters the user email that the new comment reply notification will be sent to. |
| 325 | * |
| 326 | * @since BuddyPress (1.2.0) |
| 327 | * |
| 328 | * @param string $to User email the notification is being sent to. |
| 329 | */ |
| 330 | $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to ); |
| 331 | |
| 332 | /** |
| 333 | * Filters the new comment reply notification subject that will be sent to user. |
| 334 | * |
| 335 | * @since BuddyPress (1.2.0) |
| 336 | * |
| 337 | * @param string $subject Email notification subject text. |
| 338 | * @param string $poster_name Name of the person who made the comment reply. |
| 339 | */ |
| 340 | $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject, $poster_name ); |
| 341 | |
| 342 | /** |
| 343 | * Filters the new comment reply notification message that will be sent to user. |
| 344 | * |
| 345 | * @since BuddyPress (1.2.0) |
| 346 | * |
| 347 | * @param string $message Email notification message text. |
| 348 | * @param string $poster_name Name of the person who made the comment reply. |
| 349 | * @param string $content Content of the comment reply. |
| 350 | * @param string $settings_link URL permalink for the user's notification settings area. |
| 351 | * @param string $thread_link URL permalink for the activity thread. |
| 352 | */ |
| 353 | $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message, $poster_name, $content, $settings_link, $thread_link ); |
| 354 | |
| 355 | wp_mail( $to, $subject, $message ); |
| 356 | |
| 357 | /** |
| 358 | * Fires after the sending of a reply to a reply email notification. |
| 359 | * |
| 360 | * @since BuddyPress (1.5.0) |
| 361 | * |
| 362 | * @param int $user_id ID of the parent activity item author. |
| 363 | * @param string $subject Email notification subject text. |
| 364 | * @param string $message Email notification message text. |
| 365 | * @param int $comment_id ID for the newly received comment. |
| 366 | * @param int $commenter_id ID of the user who made the comment. |
| 367 | * @param array $params Arguments used with the original activity comment. |
| 368 | */ |
| 369 | do_action( 'bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params ); |
| 370 | } |
| 438 | |
| 439 | if ( 'string' == $format ) { |
| 440 | /** |
| 441 | * Filters the @mention notification for the string format. |
| 442 | * |
| 443 | * This is a variable filter that is dependent on how many items |
| 444 | * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification |
| 445 | * or bp_activity_multiple_at_mentions_notification. |
| 446 | * |
| 447 | * @since BuddyPress (1.5.0) |
| 448 | * |
| 449 | * @param string $string HTML anchor tag for the mention. |
| 450 | * @param string $at_mention_link The permalink for the mention. |
| 451 | * @param int $total_items How many items being notified about. |
| 452 | * @param int $activity_id ID of the activity item being formatted. |
| 453 | * @param int $poster_user_id ID of the user posting the mention. |
| 454 | */ |
| 455 | $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 ); |
| 456 | } else { |
| 457 | |
| 458 | /** |
| 459 | * Filters the @mention notification for any non-string format. |
| 460 | * |
| 461 | * This is a variable filter that is dependent on how many items need notified about. |
| 462 | * The two possible hooks are bp_activity_single_at_mentions_notification |
| 463 | * or bp_activity_multiple_at_mentions_notification. |
| 464 | * |
| 465 | * @since BuddyPress (1.5.0) |
| 466 | * |
| 467 | * @param array $array Array holding the content and permalink for the mention notification. |
| 468 | * @param string $at_mention_link The permalink for the mention. |
| 469 | * @param int $total_items How many items being notified about. |
| 470 | * @param int $activity_id ID of the activity item being formatted. |
| 471 | * @param int $poster_user_id ID of the user posting the mention. |
| 472 | */ |
| 473 | $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array( |
| 474 | 'text' => $text, |
| 475 | 'link' => $at_mention_link |
| 476 | ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); |
| 477 | } |
411 | | /** |
412 | | * Filters the @mention notification for the string format. |
413 | | * |
414 | | * This is a variable filter that is dependent on how many items |
415 | | * need notified about. The two possible hooks are bp_activity_single_at_mentions_notification |
416 | | * or bp_activity_multiple_at_mentions_notification. |
417 | | * |
418 | | * @since BuddyPress (1.5.0) |
419 | | * |
420 | | * @param string $string HTML anchor tag for the mention. |
421 | | * @param string $at_mention_link The permalink for the mention. |
422 | | * @param int $total_items How many items being notified about. |
423 | | * @param int $activity_id ID of the activity item being formatted. |
424 | | * @param int $poster_user_id ID of the user posting the mention. |
425 | | */ |
426 | | $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 ); |
427 | | } else { |
| 487 | if ( (int) $total_items > 1 ) { |
| 488 | $reply_link = add_query_arg( 'type', $action, $reply_link ); |
| 489 | $text = sprintf( __( 'You have %1$d new replies', 'buddypress' ), (int) $total_items ); |
| 490 | $amount = 'multiple'; |
| 491 | } else { |
| 492 | $reply_link = bp_activity_get_permalink( $activity_id ); |
| 493 | $user_fullname = bp_core_get_user_displayname( $commenter_id ); |
| 494 | $text = sprintf( __( '%1$s commented one your updates', 'buddypress' ), $user_fullname ); |
| 495 | } |
429 | | /** |
430 | | * Filters the @mention notification for any non-string format. |
431 | | * |
432 | | * This is a variable filter that is dependent on how many items need notified about. |
433 | | * The two possible hooks are bp_activity_single_at_mentions_notification |
434 | | * or bp_activity_multiple_at_mentions_notification. |
435 | | * |
436 | | * @since BuddyPress (1.5.0) |
437 | | * |
438 | | * @param array $array Array holding the content and permalink for the mention notification. |
439 | | * @param string $at_mention_link The permalink for the mention. |
440 | | * @param int $total_items How many items being notified about. |
441 | | * @param int $activity_id ID of the activity item being formatted. |
442 | | * @param int $poster_user_id ID of the user posting the mention. |
443 | | */ |
444 | | $return = apply_filters( 'bp_activity_' . $amount . '_at_mentions_notification', array( |
445 | | 'text' => $text, |
446 | | 'link' => $at_mention_link |
447 | | ), $at_mention_link, (int) $total_items, $activity_id, $poster_user_id ); |
| 497 | if ( 'string' == $format ) { |
| 498 | /** |
| 499 | * Filters the update_reply notification for the string format. |
| 500 | * |
| 501 | * This is a variable filter that is dependent on how many items |
| 502 | * need notified about. The two possible hooks are bp_activity_single_update_reply_notification |
| 503 | * or bp_activity_multiple_update_reply_notification. |
| 504 | * |
| 505 | * @since BuddyPress (?) |
| 506 | * |
| 507 | * @param string $string HTML anchor tag for the update_reply. |
| 508 | * @param string $reply_link The permalink for the activity notification. |
| 509 | * @param int $total_items How many items being notified about. |
| 510 | * @param int $activity_id ID of the activity item being formatted. |
| 511 | * @param int $commenter_id ID of the user posting the reply. |
| 512 | */ |
| 513 | $return = apply_filters( 'bp_activity_' . $amount . '_update_reply_notification', '<a href="' . esc_url( $reply_link ) . '" title="' . esc_attr( $reply_title ) . '">' . esc_html( $text ) . '</a>', $reply_link, (int) $total_items, $activity_id, $commenter_id ); |
| 514 | } else { |
| 515 | |
| 516 | /** |
| 517 | * Filters the update_reply notification for any non-string format. |
| 518 | * |
| 519 | * This is a variable filter that is dependent on how many items need notified about. |
| 520 | * The two possible hooks are bp_activity_single_update_reply_notification |
| 521 | * or bp_activity_multiple_update_reply_notification. |
| 522 | * |
| 523 | * @since BuddyPress (?) |
| 524 | * |
| 525 | * @param array $array Array holding the content and permalink for the update_reply notification. |
| 526 | * @param string $reply_link The permalink for the mention. |
| 527 | * @param int $total_items How many items being notified about. |
| 528 | * @param int $activity_id ID of the activity item being formatted. |
| 529 | * @param int $commenter_id ID of the user posting the reply. |
| 530 | */ |
| 531 | $return = apply_filters( 'bp_activity_' . $amount . '_update_reply_notification', array( |
| 532 | 'text' => $text, |
| 533 | 'link' => $reply_link |
| 534 | ), $reply_link, (int) $total_items, $activity_id, $commenter_id ); |
| 535 | } |
| 536 | break; |
| 537 | |
| 538 | case 'comment_reply': |
| 539 | $activity_id = $item_id; |
| 540 | $commenter_id = $secondary_item_id; |
| 541 | $reply_link = bp_get_notifications_permalink(); |
| 542 | $reply_title = __( 'New Activity comment reply', 'buddypress' ); |
| 543 | $amount = 'single'; |
| 544 | |
| 545 | if ( (int) $total_items > 1 ) { |
| 546 | $reply_link = add_query_arg( 'type', $action, $reply_link ); |
| 547 | $text = sprintf( __( 'You have %1$d new comment replies', 'buddypress' ), (int) $total_items ); |
| 548 | $amount = 'multiple'; |
| 549 | } else { |
| 550 | $reply_link = bp_activity_get_permalink( $activity_id ); |
| 551 | $user_fullname = bp_core_get_user_displayname( $commenter_id ); |
| 552 | $text = sprintf( __( '%1$s replied to one your activity comments', 'buddypress' ), $user_fullname ); |
| 553 | } |
| 554 | |
| 555 | if ( 'string' == $format ) { |
| 556 | /** |
| 557 | * Filters the comment_reply notification for the string format. |
| 558 | * |
| 559 | * This is a variable filter that is dependent on how many items |
| 560 | * need notified about. The two possible hooks are bp_activity_single_update_reply_notification |
| 561 | * or bp_activity_multiple_comment_reply_notification. |
| 562 | * |
| 563 | * @since BuddyPress (?) |
| 564 | * |
| 565 | * @param string $string HTML anchor tag for the comment_reply. |
| 566 | * @param string $reply_link The permalink for the activity notification. |
| 567 | * @param int $total_items How many items being notified about. |
| 568 | * @param int $activity_id ID of the activity item being formatted. |
| 569 | * @param int $commenter_id ID of the user posting the reply. |
| 570 | */ |
| 571 | $return = apply_filters( 'bp_activity_' . $amount . '_comment_reply_notification', '<a href="' . esc_url( $reply_link ) . '" title="' . esc_attr( $reply_title ) . '">' . esc_html( $text ) . '</a>', $reply_link, (int) $total_items, $activity_id, $commenter_id ); |
| 572 | } else { |
| 573 | |
| 574 | /** |
| 575 | * Filters the comment_reply notification for any non-string format. |
| 576 | * |
| 577 | * This is a variable filter that is dependent on how many items need notified about. |
| 578 | * The two possible hooks are bp_activity_single_comment_reply_notification |
| 579 | * or bp_activity_multiple_comment_reply_notification. |
| 580 | * |
| 581 | * @since BuddyPress (?) |
| 582 | * |
| 583 | * @param array $array Array holding the content and permalink for the comment_reply notification. |
| 584 | * @param string $reply_link The permalink for the activity notification. |
| 585 | * @param int $total_items How many items being notified about. |
| 586 | * @param int $activity_id ID of the activity item being formatted. |
| 587 | * @param int $commenter_id ID of the user posting the reply. |
| 588 | */ |
| 589 | $return = apply_filters( 'bp_activity_' . $amount . '_comment_reply_notification', array( |
| 590 | 'text' => $text, |
| 591 | 'link' => $reply_link |
| 592 | ), $reply_link, (int) $total_items, $activity_id, $commenter_id ); |
| 593 | } |
| 594 | break; |
| 644 | * Notify a member one of their activity received a reply. |
| 645 | * |
| 646 | * Hooked to the 'bp_activity_sent_reply_to_update_notification' action |
| 647 | * |
| 648 | * @since BuddyPress (?) |
| 649 | * |
| 650 | * @param BP_Activity_Activity $activity the original activity. |
| 651 | * @param int $comment_id ID for the newly received comment. |
| 652 | * @param int $commenter_id ID of the user who made the comment. |
| 653 | * @param object $reply Arguments used with the original activity comment. |
| 654 | */ |
| 655 | function bp_activity_update_reply_add_notification( $activity, $comment_id, $commenter_id ) { |
| 656 | if ( bp_is_active( 'notifications' ) ) { |
| 657 | bp_notifications_add_notification( array( |
| 658 | 'user_id' => $activity->user_id, |
| 659 | 'item_id' => $activity->id, |
| 660 | 'secondary_item_id' => $commenter_id, |
| 661 | 'component_name' => buddypress()->activity->id, |
| 662 | 'component_action' => 'update_reply', |
| 663 | 'date_notified' => bp_core_current_time(), |
| 664 | 'is_new' => 1, |
| 665 | ) ); |
| 666 | } |
| 667 | } |
| 668 | add_action( 'bp_activity_sent_reply_to_update_notification', 'bp_activity_update_reply_add_notification', 10, 3 ); |
| 669 | |
| 670 | /** |
| 671 | * Notify a member one of their activity comment received a reply. |
| 672 | * |
| 673 | * Hooked to the 'bp_activity_sent_reply_to_update_notification' action |
| 674 | * |
| 675 | * @since BuddyPress (?) |
| 676 | * |
| 677 | * @param BP_Activity_Activity $activity_comment the parent activity. |
| 678 | * @param int $comment_id ID for the newly received comment. |
| 679 | * @param int $commenter_id ID of the user who made the comment. |
| 680 | * @param object $reply Arguments used with the original activity comment. |
| 681 | */ |
| 682 | function bp_activity_comment_reply_add_notification( $activity_comment, $comment_id, $commenter_id ) { |
| 683 | if ( bp_is_active( 'notifications' ) ) { |
| 684 | bp_notifications_add_notification( array( |
| 685 | 'user_id' => $activity_comment->user_id, |
| 686 | 'item_id' => $activity_comment->item_id, |
| 687 | 'secondary_item_id' => $commenter_id, |
| 688 | 'component_name' => buddypress()->activity->id, |
| 689 | 'component_action' => 'comment_reply', |
| 690 | 'date_notified' => bp_core_current_time(), |
| 691 | 'is_new' => 1, |
| 692 | ) ); |
| 693 | } |
| 694 | } |
| 695 | add_action( 'bp_activity_sent_reply_to_reply_notification', 'bp_activity_comment_reply_add_notification', 10, 3 ); |
| 696 | |
| 697 | /** |