Skip to:
Content

BuddyPress.org

Ticket #6057: 6057.01.patch

File 6057.01.patch, 30.1 KB (added by imath, 5 years ago)
  • src/bp-activity/bp-activity-notifications.php

    diff --git src/bp-activity/bp-activity-notifications.php src/bp-activity/bp-activity-notifications.php
    index a5ce0ed..e4fee0f 100644
    To view and respond to the message, log in and visit: %3$s 
    180180function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 0, $params = array() ) {
    181181
    182182        // Set some default parameters
    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( __(
    204206'%1$s replied to one of your updates:
    205207
    206208"%2$s"
    To view your original update and all comments, log in and visit: %3$s 
    210212---------------------
    211213', 'buddypress' ), $poster_name, $content, $thread_link );
    212214
    213                 // Only show the disable notifications line if the settings component is enabled
    214                 if ( bp_is_active( 'settings' ) ) {
    215                         $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
    216                 }
    217 
    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                  */
    225                 $to = apply_filters( 'bp_activity_new_comment_notification_to', $to );
     215                        // Only show the disable notifications line if the settings component is enabled
     216                        if ( bp_is_active( 'settings' ) ) {
     217                                $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link );
     218                        }
    226219
    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                }
    236268
    237269                /**
    238                  * Filters the new comment notification message that will be sent to user.
     270                 * Triggers the update_reply notification.
    239271                 *
    240                  * @since BuddyPress (1.2.0)
     272                 * @since BuddyPress (?)
    241273                 *
    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.
     274                 * @param BP_Activity_Activity $original_activity the original activity.
     275                 * @param int                  $comment_id ID for the newly received comment.
     276                 * @param int                  $commenter_id ID of the user who made the comment.
     277                 * @param object               $reply Arguments used with the original activity comment.
    247278                 */
    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 );
    265280        }
    266281
    267282        /***
    268283         * If this is a reply to another comment, send an email notification to the
    269284         * author of the immediate parent comment.
    270285         */
    271         if ( empty( $parent_id ) || ( $activity_id == $parent_id ) ) {
     286        if ( empty( $reply->parent_id ) || ( $reply->activity_id == $reply->parent_id ) ) {
    272287                return false;
    273288        }
    274289
    275         $parent_comment = new BP_Activity_Activity( $parent_id );
     290        $parent_comment = new BP_Activity_Activity( $reply->parent_id );
    276291
    277         if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id && 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
    278                 $poster_name   = bp_core_get_user_displayname( $commenter_id );
    279                 $thread_link   = bp_activity_get_permalink( $activity_id );
    280                 $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
    281                 $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
     292        if ( $parent_comment->user_id != $commenter_id && $original_activity->user_id != $parent_comment->user_id ) {
     293                // Send an email if the user has not disabled it
     294                if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) {
     295                        $poster_name   = bp_core_get_user_displayname( $commenter_id );
     296                        $thread_link   = bp_activity_get_permalink( $reply->activity_id );
     297                        $settings_slug = function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings';
     298                        $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . $settings_slug . '/notifications/';
    282299
    283                 // Set up and send the message
    284                 $ud       = bp_core_get_core_userdata( $parent_comment->user_id );
    285                 $to       = $ud->user_email;
    286                 $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ) ) );
     300                        // Set up and send the message
     301                        $ud       = bp_core_get_core_userdata( $parent_comment->user_id );
     302                        $to       = $ud->user_email;
     303                        $subject = bp_get_email_subject( array( 'text' => sprintf( __( '%s replied to one of your comments', 'buddypress' ), $poster_name ) ) );
    287304
    288                 $poster_name = stripslashes( $poster_name );
    289                 $content = bp_activity_filter_kses( stripslashes( $content ) );
     305                        $poster_name = stripslashes( $poster_name );
     306                        $content = bp_activity_filter_kses( stripslashes( $reply->content ) );
    290307
    291308$message = sprintf( __(
    292309'%1$s replied to one of your comments:
    To view the original activity, your comment and all replies, log in and visit: % 
    298315---------------------
    299316', 'buddypress' ), $poster_name, $content, $thread_link );
    300317
    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                        }
    337322
    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                }
    339371
    340372                /**
    341                  * Fires after the sending of a reply to a reply email notification.
     373                 * Triggers the comment_reply notification.
    342374                 *
    343                  * @since BuddyPress (1.5.0)
     375                 * @since BuddyPress (?)
    344376                 *
    345                  * @param int    $user_id ID of the parent 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.
     377                 * @param BP_Activity_Activity $parent_comment the parent activity.
     378                 * @param int                  $comment_id ID for the newly received comment.
     379                 * @param int                  $commenter_id ID of the user who made the comment.
     380                 * @param object               $reply Arguments used with the original activity comment.
    351381                 */
    352                 do_action( 'bp_activity_sent_reply_to_reply_email', $parent_comment->user_id, $subject, $message, $comment_id, $commenter_id, $params );
     382                do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $reply );
    353383        }
    354384}
    355385
    add_action( 'bp_activity_comment_posted', 'bp_activity_new_comment_notification_ 
    387417 * @return string $return Formatted @mention notification.
    388418 */
    389419function bp_activity_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) {
     420        // Initilialize the returned value
     421        $return = false;
    390422
    391423        switch ( $action ) {
    392424                case 'new_at_mention':
    function bp_activity_format_notifications( $action, $item_id, $secondary_item_id 
    403435                                $user_fullname = bp_core_get_user_displayname( $poster_user_id );
    404436                                $text =  sprintf( __( '%1$s mentioned you', 'buddypress' ), $user_fullname );
    405437                        }
     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                        }
    406478                break;
    407         }
    408479
    409         if ( 'string' == $format ) {
     480                case 'update_reply':
     481                        $activity_id  = $item_id;
     482                        $commenter_id = $secondary_item_id;
     483                        $reply_link   = bp_get_notifications_permalink();
     484                        $reply_title  = __( 'New Activity reply', 'buddypress' );
     485                        $amount       = 'single';
    410486
    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                        }
    428496
    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;
    448595        }
    449596
    450597        /**
    function bp_activity_format_notifications( $action, $item_id, $secondary_item_id 
    454601         *
    455602         * @param string $action The type of activity item.
    456603         * @param int    $item_id The activity ID.
    457          * @param int    $secondary_item_id @mention mentioner ID.
     604         * @param int    $secondary_item_id the user ID who inited the interaction.
    458605         * @param int    $total_items Total amount of items to format.
    459606         */
    460607        do_action( 'activity_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
    function bp_activity_at_mention_add_notification( $activity, $subject, $message, 
    494641add_action( 'bp_activity_sent_mention_email', 'bp_activity_at_mention_add_notification', 10, 5 );
    495642
    496643/**
     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 */
     655function 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}
     668add_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 */
     682function 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}
     695add_action( 'bp_activity_sent_reply_to_reply_notification', 'bp_activity_comment_reply_add_notification', 10, 3 );
     696
     697/**
    497698 * Mark at-mention notifications as read when users visit their Mentions page.
    498699 *
    499700 * @since BuddyPress (1.5.0)
    function bp_activity_remove_screen_notifications_single_activity_permalink( $act 
    531732        // Mark as read any notifications for the current user related to this
    532733        // activity item
    533734        bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'new_at_mention' );
     735        bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'update_reply' );
     736        bp_notifications_mark_notifications_by_item_id( bp_loggedin_user_id(), $activity->id, buddypress()->activity->id, 'comment_reply' );
    534737}
    535738add_action( 'bp_activity_screen_single_activity_permalink', 'bp_activity_remove_screen_notifications_single_activity_permalink' );
    536739
    537740/**
     741 * Mark activity notification as read when user visits their notifications unread screen.
     742 *
     743 * @since BuddyPress (?)
     744 */
     745function bp_activity_remove_multiple_notifications() {
     746        if ( ! bp_is_active( 'notifications' ) || ! isset( $_GET['type'] ) ) {
     747                return;
     748        }
     749
     750        if ( ! bp_is_my_profile() ) {
     751                return;
     752        }
     753
     754        bp_notifications_mark_notifications_by_type( bp_loggedin_user_id(), buddypress()->activity->id, sanitize_key( $_GET['type'] ) );
     755}
     756add_action( 'notifications_loop_end', 'bp_activity_remove_multiple_notifications' );
     757
     758/**
    538759 * Delete at-mention notifications when the corresponding activity item is deleted.
    539760 *
    540761 * @since BuddyPress (2.0.0)