Ticket #6932: 6932.10.diff
File 6932.10.diff, 27.4 KB (added by , 8 years ago) |
---|
-
src/bp-activity/bp-activity-notifications.php
diff --git a/src/bp-activity/bp-activity-notifications.php b/src/bp-activity/bp-activity-notifications.php index 7803f76..ec750d1 100644
a b function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) 54 54 $group_name = bp_get_current_group_name(); 55 55 } 56 56 57 $unsubscribe_args = array( 58 'user_id' => $receiver_user_id, 59 'notification_type' => $email_type, 60 ); 61 57 62 $args = array( 58 63 'tokens' => array( 59 64 'activity' => $activity, … … function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) 62 67 'mentioned.url' => $message_link, 63 68 'poster.name' => $poster_name, 64 69 'receiver-user.id' => $receiver_user_id, 70 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 65 71 ), 66 72 ); 67 73 … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 113 119 114 120 // Send an email if the user hasn't opted-out. 115 121 if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { 122 123 $unsubscribe_args = array( 124 'user_id' => $original_activity->user_id, 125 'notification_type' => 'activity-comment', 126 ); 127 116 128 $args = array( 117 129 'tokens' => array( 118 130 'comment.id' => $comment_id, … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 121 133 'original_activity.user_id' => $original_activity->user_id, 122 134 'poster.name' => $poster_name, 123 135 'thread.url' => esc_url( $thread_link ), 136 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 124 137 ), 125 138 ); 126 139 … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 155 168 156 169 // Send an email if the user hasn't opted-out. 157 170 if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) { 171 172 $unsubscribe_args = array( 173 'user_id' => $parent_comment->user_id, 174 'notification_type' => 'activity-comment-author', 175 ); 176 158 177 $args = array( 159 178 'tokens' => array( 160 179 'comment.id' => $comment_id, … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 163 182 'parent-comment-user.id' => $parent_comment->user_id, 164 183 'poster.name' => $poster_name, 165 184 'thread.url' => esc_url( $thread_link ), 185 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 166 186 ), 167 187 ); 168 188 … … function bp_activity_new_comment_notification( $comment_id = 0, $commenter_id = 178 198 * @param int $comment_id ID for the newly received comment. 179 199 * @param int $commenter_id ID of the user who made the comment. 180 200 * @param array $params Arguments used with the original activity comment. 181 201 */ 182 202 do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $params ); 183 203 } 184 204 } -
src/bp-core/admin/bp-core-admin-schema.php
diff --git a/src/bp-core/admin/bp-core-admin-schema.php b/src/bp-core/admin/bp-core-admin-schema.php index 1867e78..6f9043a 100644
a b function bp_core_install_emails() { 500 500 ); 501 501 502 502 $emails = bp_email_get_schema(); 503 $descriptions = bp_email_get_type_schema( );503 $descriptions = bp_email_get_type_schema( 'description' ); 504 504 505 505 // Add these emails to the database. 506 506 foreach ( $emails as $id => $email ) { -
src/bp-core/bp-core-actions.php
diff --git a/src/bp-core/bp-core-actions.php b/src/bp-core/bp-core-actions.php index b4478a1..9968913 100644
a b if ( is_admin() ) { 110 110 111 111 // Activation redirect. 112 112 add_action( 'bp_activation', 'bp_add_activation_redirect' ); 113 114 // Email unsubscribe. 115 add_action( 'bp_get_request_unsubscribe', 'bp_email_unsubscribe_handler' ); -
src/bp-core/bp-core-filters.php
diff --git a/src/bp-core/bp-core-filters.php b/src/bp-core/bp-core-filters.php index 934131a..2e6f916 100644
a b function bp_email_set_default_tokens( $tokens, $property_name, $transform, $emai 1030 1030 $tokens['recipient.email'] = ''; 1031 1031 $tokens['recipient.name'] = ''; 1032 1032 $tokens['recipient.username'] = ''; 1033 $tokens['unsubscribe'] = site_url( 'wp-login.php' );1034 1033 1035 1034 1036 1035 // Who is the email going to? … … function bp_email_set_default_tokens( $tokens, $property_name, $transform, $emai 1047 1046 } 1048 1047 1049 1048 if ( $user_obj ) { 1050 // Unsubscribe link.1051 $tokens['unsubscribe'] = esc_url( sprintf(1052 '%s%s/notifications/',1053 bp_core_get_user_domain( $user_obj->ID ),1054 function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'1055 ) );1056 1049 $tokens['recipient.username'] = $user_obj->user_login; 1057 } 1050 if ( bp_is_active( 'settings' ) && empty( $tokens['unsubscribe'] ) ) { 1051 $tokens['unsubscribe'] = esc_url( sprintf( 1052 '%s%s/notifications/', 1053 bp_core_get_user_domain( $user_obj->ID ), 1054 bp_get_settings_slug() 1055 ) ); 1056 } 1057 } 1058 1058 } 1059 1059 1060 // Set default unsubscribe link if not passed. 1061 if ( empty( $tokens['unsubscribe'] ) ) { 1062 $tokens['unsubscribe'] = site_url( 'wp-login.php' ); 1063 } 1064 1060 1065 // Email preheader. 1061 1066 $post = $email->get_post_object(); 1062 1067 if ( $post ) { -
src/bp-core/bp-core-functions.php
diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php index 6acfb73..643fc68 100644
a b function bp_email_get_schema() { 3369 3369 * Get a list of emails for populating email type taxonomy terms. 3370 3370 * 3371 3371 * @since 2.5.1 3372 * @since 2.7.0 $field argument added. 3373 * 3374 * @param string $field Optional; defaults to "description" for backwards compatibility. Other values: "all". 3375 * @return array { 3376 * The array of email types and their schema. 3377 * 3378 * @type string $description The description of the action which causes this to trigger. 3379 * @type array $unsubscribe { 3380 * Replacing this with false indicates that a user cannot unsubscribe from this type. 3381 * 3382 * @type string $meta_key The meta_key used to toggle the email setting for this notification. 3383 * @type string $message The message shown when the user has successfully unsubscribed. 3384 * } 3385 */ 3386 function bp_email_get_type_schema( $field = 'description' ) { 3387 $activity_comment = array( 3388 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ), 3389 'unsubscribe' => array( 3390 'meta_key' => 'notification_activity_new_reply', 3391 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), 3392 ), 3393 ); 3394 3395 $activity_comment_author = array( 3396 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ), 3397 'unsubscribe' => array( 3398 'meta_key' => 'notification_activity_new_reply', 3399 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), 3400 ), 3401 ); 3402 3403 $activity_at_message = array( 3404 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ), 3405 'unsubscribe' => array( 3406 'meta_key' => 'notification_activity_new_mention', 3407 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), 3408 ), 3409 ); 3410 3411 $groups_at_message = array( 3412 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ), 3413 'unsubscribe' => array( 3414 'meta_key' => 'notification_activity_new_mention', 3415 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), 3416 ), 3417 ); 3418 3419 $core_user_registration = array( 3420 'description' => __( 'Recipient has registered for an account.', 'buddypress' ), 3421 'unsubscribe' => false, 3422 ); 3423 3424 $core_user_registration_with_blog = array( 3425 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ), 3426 'unsubscribe' => false, 3427 ); 3428 3429 $friends_request = array( 3430 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ), 3431 'unsubscribe' => array( 3432 'meta_key' => 'notification_friends_friendship_request', 3433 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ), 3434 ), 3435 ); 3436 3437 $friends_request_accepted = array( 3438 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ), 3439 'unsubscribe' => array( 3440 'meta_key' => 'notification_friends_friendship_accepted', 3441 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ), 3442 ), 3443 ); 3444 3445 $groups_details_updated = array( 3446 'description' => __( "A group's details were updated.", 'buddypress' ), 3447 'unsubscribe' => array( 3448 'meta_key' => 'notification_groups_group_updated', 3449 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ), 3450 ), 3451 ); 3452 3453 $groups_details_updated = array( 3454 'description' => __( "A group's details were updated.", 'buddypress' ), 3455 'unsubscribe' => array( 3456 'meta_key' => 'notification_groups_group_updated', 3457 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ), 3458 ), 3459 ); 3460 3461 $groups_invitation = array( 3462 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ), 3463 'unsubscribe' => array( 3464 'meta_key' => 'notification_groups_invite', 3465 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ), 3466 ), 3467 ); 3468 3469 $groups_member_promoted = array( 3470 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3471 'unsubscribe' => array( 3472 'meta_key' => 'notification_groups_admin_promotion', 3473 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ), 3474 ), 3475 ); 3476 3477 $groups_member_promoted = array( 3478 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3479 'unsubscribe' => array( 3480 'meta_key' => 'notification_groups_admin_promotion', 3481 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ), 3482 ), 3483 ); 3484 3485 $groups_membership_request = array( 3486 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ), 3487 'unsubscribe' => array( 3488 'meta_key' => 'notification_groups_membership_request', 3489 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ), 3490 ), 3491 ); 3492 3493 $messages_unread = array( 3494 'description' => __( 'Recipient has received a private message.', 'buddypress' ), 3495 'unsubscribe' => array( 3496 'meta_key' => 'notification_messages_new_message', 3497 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ), 3498 ), 3499 ); 3500 3501 $settings_verify_email_change = array( 3502 'description' => __( 'Recipient has changed their email address.', 'buddypress' ), 3503 'unsubscribe' => false, 3504 ); 3505 3506 $groups_membership_request_accepted = array( 3507 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ), 3508 'unsubscribe' => array( 3509 'meta_key' => 'notification_membership_request_completed', 3510 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), 3511 ), 3512 ); 3513 3514 $groups_membership_request_rejected = array( 3515 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), 3516 'unsubscribe' => array( 3517 'meta_key' => 'notification_membership_request_completed', 3518 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), 3519 ), 3520 ); 3521 3522 $types = array( 3523 'activity-comment' => $activity_comment, 3524 'activity-comment-author' => $activity_comment_author, 3525 'activity-at-message' => $activity_at_message, 3526 'groups-at-message' => $groups_at_message, 3527 'core-user-registration' => $core_user_registration, 3528 'core-user-registration-with-blog' => $core_user_registration_with_blog, 3529 'friends-request' => $friends_request, 3530 'friends-request-accepted' => $friends_request_accepted, 3531 'groups-details-updated' => $groups_details_updated, 3532 'groups-invitation' => $groups_invitation, 3533 'groups-member-promoted' => $groups_member_promoted, 3534 'groups-membership-request' => $groups_membership_request, 3535 'messages-unread' => $messages_unread, 3536 'settings-verify-email-change' => $settings_verify_email_change, 3537 'groups-membership-request-accepted' => $groups_membership_request_accepted, 3538 'groups-membership-request-rejected' => $groups_membership_request_rejected, 3539 ); 3540 3541 if ( $field !== 'all' ) { 3542 return wp_list_pluck( $types, $field ); 3543 } else { 3544 return $types; 3545 } 3546 } 3547 3548 /** 3549 * Handles unsubscribing user from notification emails. 3372 3550 * 3373 * @ return array3551 * @since 2.7.0 3374 3552 */ 3375 function bp_email_get_type_schema() { 3376 return array( 3377 'activity-comment' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ), 3378 'activity-comment-author' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ), 3379 'activity-at-message' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ), 3380 'groups-at-message' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ), 3381 'core-user-registration' => __( 'Recipient has registered for an account.', 'buddypress' ), 3382 'core-user-registration-with-blog' => __( 'Recipient has registered for an account and site.', 'buddypress' ), 3383 'friends-request' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ), 3384 'friends-request-accepted' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ), 3385 'groups-details-updated' => __( "A group's details were updated.", 'buddypress' ), 3386 'groups-invitation' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ), 3387 'groups-member-promoted' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3388 'groups-membership-request' => __( 'A member has requested permission to join a group.', 'buddypress' ), 3389 'messages-unread' => __( 'Recipient has received a private message.', 'buddypress' ), 3390 'settings-verify-email-change' => __( 'Recipient has changed their email address.', 'buddypress' ), 3391 'groups-membership-request-accepted' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ), 3392 'groups-membership-request-rejected' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), 3553 function bp_email_unsubscribe_handler() { 3554 $emails = bp_email_get_type_schema(); 3555 $raw_email_type = ! empty( $_GET['nt'] ) ? sanitize_text_field( $_GET['nt'] ) : ''; 3556 $raw_nonce = ! empty( $_GET['nn'] ) ? sanitize_text_field( $_GET['nn'] ) : ''; 3557 $raw_user_id = ! empty( $_GET['uid'] ) ? absint( $_GET['uid'] ) : 0; 3558 $settings_slug = bp_is_active( 'settings' ) ? bp_get_settings_slug() : 'settings'; 3559 $check_nonce = hash_hmac( 'sha1', "{$raw_email_type}:{$raw_user_id}", bp_email_get_salt() ); 3560 3561 // Check required values. 3562 if ( ! $raw_user_id || ! $raw_email_type || ! $raw_nonce || ! array_key_exists( $raw_email_type, $emails ) ) { 3563 $redirect_to = site_url( 'wp-login.php' ); 3564 $result_msg = __( 'Something has gone wrong.', 'buddypress' ); 3565 $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' ); 3566 3567 // Check valid hash. 3568 } elseif ( ! hash_equals( $check_nonce, $raw_nonce ) ) { 3569 $redirect_to = site_url( 'wp-login.php' ); 3570 $result_msg = __( 'Something has gone wrong.', 'buddypress' ); 3571 $unsub_msg = __( 'Please log in and go to your settings to unsubscribe from notification emails.', 'buddypress' ); 3572 3573 // Don't let authenticated users unsubscribe other users' email notifications. 3574 } elseif ( is_user_logged_in() && get_current_user_id() !== $raw_user_id ) { 3575 $result_msg = __( 'Something has gone wrong.', 'buddypress' ); 3576 $unsub_msg = __( 'Please go to your settings to unsubscribe from notification emails.', 'buddypress' ); 3577 $redirect_to = sprintf( 3578 '%s%s/notifications/', 3579 bp_core_get_user_domain( get_current_user_id() ), 3580 $settings_slug 3581 ); 3582 3583 } else { 3584 $redirect_to = sprintf( 3585 '%s%s/notifications/', 3586 bp_core_get_user_domain( $raw_user_id ), 3587 $settings_slug 3588 ); 3589 3590 // Unsubscribe. 3591 $meta_key = $emails[ $raw_email_type ]['unsubscribe']['meta_key']; 3592 bp_update_user_meta( $raw_user_id, $meta_key, 'no' ); 3593 3594 $result_msg = $emails[ $raw_email_type ]['unsubscribe']['message']; 3595 $unsub_msg = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' ); 3596 } 3597 3598 $message = sprintf( 3599 '%1$s <a href="%2$s">%3$s</a>', 3600 $result_msg, 3601 esc_url( $redirect_to ), 3602 esc_html( $unsub_msg ) 3603 ); 3604 3605 bp_core_add_message( $message ); 3606 bp_core_redirect( bp_core_get_user_domain( $raw_user_id ) ); 3607 3608 exit; 3609 } 3610 3611 /** 3612 * Creates unsubscribe link for notification emails. 3613 * 3614 * @since 2.7.0 3615 * 3616 * @param string $redirect_to The URL to which the unsubscribe query string is appended. 3617 * @param array $args { 3618 * Used to build unsubscribe query string. 3619 * 3620 * @type string $notification_type Which notification type is being sent. 3621 * @type string $user_id The ID of the user to whom the notification is sent. 3622 * @type string $redirect_to Optional. The url to which the user will be redirected. Default is the activity directory. 3623 * } 3624 * @return string The unsubscribe link. 3625 */ 3626 function bp_email_get_unsubscribe_link( $args ) { 3627 $emails = bp_email_get_type_schema(); 3628 3629 if ( empty( $args['notification_type'] ) || ! array_key_exists( $args['notification_type'], $emails ) ) { 3630 return site_url( 'wp-login.php' ); 3631 } 3632 3633 $email_type = $args['notification_type']; 3634 $redirect_to = ! empty( $args['redirect_to'] ) ? $args['redirect_to'] : bp_get_activity_directory_permalink(); 3635 $user_id = (int) $args['user_id']; 3636 3637 // Bail out if the activity type is not un-unsubscribable. 3638 if ( empty( $emails[ $email_type ]['unsubscribe'] ) ) { 3639 return ''; 3640 } 3641 3642 $link = add_query_arg( 3643 array( 3644 'action' => 'unsubscribe', 3645 'nn' => hash_hmac( 'sha1', "{$email_type}:{$user_id}", bp_email_get_salt() ), 3646 ), 3647 $redirect_to 3393 3648 ); 3649 3650 /** 3651 * Filters the unsubscribe link. 3652 * 3653 * @since 2.7.0 3654 */ 3655 return apply_filters( 'bp_email_get_link', $link, $redirect_to, $args ); 3656 } 3657 3658 /** 3659 * Get a persistent salt for email unsubscribe links. 3660 * 3661 * @since 2.7.0 3662 * 3663 * @return string 3664 */ 3665 function bp_email_get_salt() { 3666 $salt = bp_get_option( 'bp-emails-unsubscribe-salt', null ); 3667 3668 if ( is_null( $salt ) ) { 3669 $salt = base64_encode( wp_generate_password( 12, true, true ) ); 3670 bp_add_option( 'bp-emails-unsubscribe-salt', $salt ); 3671 } 3672 3673 return $salt; 3394 3674 } -
src/bp-friends/bp-friends-notifications.php
diff --git a/src/bp-friends/bp-friends-notifications.php b/src/bp-friends/bp-friends-notifications.php index c7a851e..d1ae381 100644
a b function friends_notification_new_request( $friendship_id, $initiator_id, $frien 32 32 return; 33 33 } 34 34 35 $unsubscribe_args = array( 36 'user_id' => $friend_id, 37 'notification_type' => 'friends-request', 38 ); 39 35 40 $args = array( 36 41 'tokens' => array( 37 42 'friend-requests.url' => esc_url( bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/' ), … … function friends_notification_new_request( $friendship_id, $initiator_id, $frien 40 45 'initiator.id' => $initiator_id, 41 46 'initiator.url' => esc_url( bp_core_get_user_domain( $initiator_id ) ), 42 47 'initiator.name' => bp_core_get_user_displayname( $initiator_id ), 48 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 43 49 ), 44 50 ); 45 51 bp_send_email( 'friends-request', $friend_id, $args ); … … function friends_notification_accepted_request( $friendship_id, $initiator_id, $ 63 69 return; 64 70 } 65 71 72 $unsubscribe_args = array( 73 'user_id' => $initiator_id, 74 'notification_type' => 'friends-request-accepted', 75 ); 76 66 77 $args = array( 67 78 'tokens' => array( 68 79 'friend.id' => $friend_id, … … function friends_notification_accepted_request( $friendship_id, $initiator_id, $ 70 81 'friend.name' => bp_core_get_user_displayname( $friend_id ), 71 82 'friendship.id' => $friendship_id, 72 83 'initiator.id' => $initiator_id, 84 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 73 85 ), 74 86 ); 75 87 bp_send_email( 'friends-request-accepted', $initiator_id, $args ); -
src/bp-groups/bp-groups-notifications.php
diff --git a/src/bp-groups/bp-groups-notifications.php b/src/bp-groups/bp-groups-notifications.php index 3ee37a2..6b6492c 100644
a b function groups_notification_group_updated( $group_id = 0, $old_group = null ) { 68 68 continue; 69 69 } 70 70 71 $unsubscribe_args = array( 72 'user_id' => $user_id, 73 'notification_type' => 'groups-details-updated', 74 ); 75 71 76 $args = array( 72 77 'tokens' => array( 73 78 'changed_text' => $changed_text, … … function groups_notification_group_updated( $group_id = 0, $old_group = null ) { 75 80 'group.id' => $group_id, 76 81 'group.url' => esc_url( bp_get_group_permalink( $group ) ), 77 82 'group.name' => $group->name, 83 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 78 84 ), 79 85 ); 80 86 bp_send_email( 'groups-details-updated', (int) $user_id, $args ); … … function groups_notification_new_membership_request( $requesting_user_id = 0, $a 115 121 'item_id' => $group_id, 116 122 'secondary_item_id' => $requesting_user_id, 117 123 'component_name' => buddypress()->groups->id, 118 'component_action' => 'new_membership_request' 124 'component_action' => 'new_membership_request', 119 125 ) ); 120 126 } 121 127 … … function groups_notification_new_membership_request( $requesting_user_id = 0, $a 124 130 return; 125 131 } 126 132 133 $unsubscribe_args = array( 134 'user_id' => $admin_id, 135 'notification_type' => 'groups-membership-request', 136 ); 137 127 138 $group = groups_get_group( array( 'group_id' => $group_id ) ); 128 139 $args = array( 129 140 'tokens' => array( … … function groups_notification_new_membership_request( $requesting_user_id = 0, $a 136 147 'profile.url' => esc_url( bp_core_get_user_domain( $requesting_user_id ) ), 137 148 'requesting-user.id' => $requesting_user_id, 138 149 'requesting-user.name' => bp_core_get_user_displayname( $requesting_user_id ), 150 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 139 151 ), 140 152 ); 141 153 bp_send_email( 'groups-membership-request', (int) $admin_id, $args ); … … function groups_notification_membership_request_completed( $requesting_user_id = 184 196 ); 185 197 186 198 if ( ! empty( $accepted ) ) { 199 200 $unsubscribe_args = array( 201 'user_id' => $requesting_user_id, 202 'notification_type' => 'groups-membership-request-accepted', 203 ); 204 205 $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 206 187 207 bp_send_email( 'groups-membership-request-accepted', (int) $requesting_user_id, $args ); 208 188 209 } else { 210 211 $unsubscribe_args = array( 212 'user_id' => $requesting_user_id, 213 'notification_type' => 'groups-membership-request-rejected', 214 ); 215 216 $args['tokens']['unsubscribe'] = esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 217 189 218 bp_send_email( 'groups-membership-request-rejected', (int) $requesting_user_id, $args ); 190 219 } 191 220 } … … function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) { 226 255 return; 227 256 } 228 257 258 $unsubscribe_args = array( 259 'user_id' => $user_id, 260 'notification_type' => 'groups-member-promoted', 261 ); 262 229 263 $group = groups_get_group( array( 'group_id' => $group_id ) ); 230 264 $args = array( 231 265 'tokens' => array( … … function groups_notification_promoted_member( $user_id = 0, $group_id = 0 ) { 235 269 'group.name' => $group->name, 236 270 'promoted_to' => $promoted_to, 237 271 'user.id' => $user_id, 272 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 238 273 ), 239 274 ); 240 275 bp_send_email( 'groups-member-promoted', (int) $user_id, $args ); … … function groups_notification_group_invites( &$group, &$member, $inviter_user_id 277 312 } 278 313 279 314 $invited_link = bp_core_get_user_domain( $invited_user_id ) . bp_get_groups_slug(); 315 316 $unsubscribe_args = array( 317 'user_id' => $invited_user_id, 318 'notification_type' => 'groups-invitation', 319 ); 320 280 321 $args = array( 281 322 'tokens' => array( 282 323 'group' => $group, … … function groups_notification_group_invites( &$group, &$member, $inviter_user_id 286 327 'inviter.url' => bp_core_get_user_domain( $inviter_user_id ), 287 328 'inviter.id' => $inviter_user_id, 288 329 'invites.url' => esc_url( $invited_link . '/invites/' ), 330 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 289 331 ), 290 332 ); 291 333 bp_send_email( 'groups-invitation', (int) $invited_user_id, $args ); -
src/bp-messages/bp-messages-notifications.php
diff --git a/src/bp-messages/bp-messages-notifications.php b/src/bp-messages/bp-messages-notifications.php index 0a0bca1..cb16804 100644
a b function messages_notification_new_message( $raw_args = array() ) { 58 58 continue; 59 59 } 60 60 61 $unsubscribe_args = array( 62 'user_id' => $recipient->user_id, 63 'notification_type' => 'messages-unread', 64 ); 65 61 66 $args = array( 62 67 'tokens' => array( 63 68 'usermessage' => wp_strip_all_tags( stripslashes( $message ) ), 64 69 'message.url' => esc_url( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' ), 65 70 'sender.name' => $sender_name, 66 71 'usersubject' => sanitize_text_field( stripslashes( $subject ) ), 72 'unsubscribe' => esc_url( bp_email_get_unsubscribe_link( $unsubscribe_args ) ), 67 73 ), 68 74 ); 69 75 bp_send_email( 'messages-unread', $ud, $args ); -
tests/phpunit/testcases/admin/functions.php
diff --git a/tests/phpunit/testcases/admin/functions.php b/tests/phpunit/testcases/admin/functions.php index cc6ea19..cfa7015 100644
a b class BP_Tests_Admin_Functions extends BP_UnitTestCase { 252 252 'hide_empty' => false, 253 253 ) ); 254 254 255 $correct_descriptions = bp_email_get_type_schema( );255 $correct_descriptions = bp_email_get_type_schema( 'description' ); 256 256 foreach ( $d_terms as $d_term ) { 257 257 $correct_description = $correct_descriptions[ $d_term->slug ]; 258 258 $this->assertSame( $correct_description, $d_term->description );