Ticket #6932: 6932.5.diff
File 6932.5.diff, 30.6 KB (added by , 8 years ago) |
---|
-
src/bp-activity/bp-activity-notifications.php
40 40 * @param int $receiver_user_id The ID of the user who is receiving the update. 41 41 */ 42 42 function bp_activity_at_message_notification( $activity_id, $receiver_user_id ) { 43 43 44 $notifications = BP_Core_Notification::get_all_for_user( $receiver_user_id, 'all' ); 44 45 45 46 // Don't leave multiple notifications for the same activity item. … … 73 74 $group_name = bp_get_current_group_name(); 74 75 } 75 76 77 $unsubscribe_args = array( 78 'user_id' => (int) $receiver_user_id, 79 'notification_type' => $email_type, 80 ); 81 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 82 76 83 $args = array( 77 84 'tokens' => array( 78 85 'activity' => $activity, … … 81 88 'mentioned.url' => $message_link, 82 89 'poster.name' => $poster_name, 83 90 'receiver-user.id' => $receiver_user_id, 91 'unsubscribe' => $unsubscribe_link, 84 92 ), 85 93 ); 86 94 … … 152 160 153 161 // Send an email if the user hasn't opted-out. 154 162 if ( 'no' != bp_get_user_meta( $original_activity->user_id, 'notification_activity_new_reply', true ) ) { 163 164 $unsubscribe_args = array( 165 'user_id' => (int) $original_activity->user_id, 166 'notification_type' => 'activity-comment', 167 ); 168 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 169 155 170 $args = array( 156 171 'tokens' => array( 157 172 'comment.id' => $comment_id, … … 160 175 'original_activity.user_id' => $original_activity->user_id, 161 176 'poster.name' => $poster_name, 162 177 'thread.url' => esc_url( $thread_link ), 178 'unsubscribe' => $unsubscribe_link, 163 179 ), 164 180 ); 165 181 … … 194 210 195 211 // Send an email if the user hasn't opted-out. 196 212 if ( 'no' != bp_get_user_meta( $parent_comment->user_id, 'notification_activity_new_reply', true ) ) { 213 214 $unsubscribe_args = array( 215 'user_id' => (int) $parent_comment->user_id, 216 'notification_type' => 'activity-comment-author', 217 ); 218 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 219 197 220 $args = array( 198 221 'tokens' => array( 199 222 'comment.id' => $comment_id, … … 202 225 'parent-comment-user.id' => $parent_comment->user_id, 203 226 'poster.name' => $poster_name, 204 227 'thread.url' => esc_url( $thread_link ), 228 'unsubscribe' => $unsubscribe_link, 205 229 ), 206 230 ); 207 231 … … 217 241 * @param int $comment_id ID for the newly received comment. 218 242 * @param int $commenter_id ID of the user who made the comment. 219 243 * @param array $params Arguments used with the original activity comment. 220 244 */ 221 245 do_action( 'bp_activity_sent_reply_to_reply_notification', $parent_comment, $comment_id, $commenter_id, $params ); 222 246 } 223 247 } -
src/bp-core/admin/bp-core-admin-schema.php
539 539 ); 540 540 541 541 $emails = bp_email_get_schema(); 542 $descriptions = bp_email_ get_type_schema();542 $descriptions = bp_email_type_schema(); 543 543 544 544 // Add these emails to the database. 545 545 foreach ( $emails as $id => $email ) { … … 552 552 foreach ( $tt_ids as $tt_id ) { 553 553 $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() ); 554 554 wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array( 555 'description' => $descriptions[ $id ] ,555 'description' => $descriptions[ $id ]['description'], 556 556 ) ); 557 557 } 558 558 } -
src/bp-core/bp-core-actions.php
109 109 110 110 // Activation redirect. 111 111 add_action( 'bp_activation', 'bp_add_activation_redirect' ); 112 113 // Email unsubscribe. 114 add_action( 'bp_get_request_unsubscribe', 'bp_emails_unsubscribe_handler' ); 115 -
src/bp-core/bp-core-filters.php
1012 1012 * @return array 1013 1013 */ 1014 1014 function bp_email_set_default_tokens( $tokens, $property_name, $transform, $email ) { 1015 1015 1016 $tokens['site.admin-email'] = bp_get_option( 'admin_email' ); 1016 1017 $tokens['site.url'] = home_url(); 1017 1018 … … 1024 1025 $tokens['recipient.email'] = ''; 1025 1026 $tokens['recipient.name'] = ''; 1026 1027 $tokens['recipient.username'] = ''; 1027 $tokens['unsubscribe'] = site_url( 'wp-login.php' );1028 1028 1029 1029 1030 1030 // Who is the email going to? … … 1041 1041 } 1042 1042 1043 1043 if ( $user_obj ) { 1044 // Unsubscribe link.1045 $tokens['unsubscribe'] = esc_url( sprintf(1046 '%s%s/notifications/',1047 bp_core_get_user_domain( $user_obj->ID ),1048 function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings'1049 ) );1050 1044 $tokens['recipient.username'] = $user_obj->user_login; 1051 } 1045 if ( bp_is_active( 'settings' ) && empty( $tokens['unsubscribe'] ) ) { 1046 $tokens['unsubscribe'] = esc_url( sprintf( 1047 '%s%s/notifications/', 1048 bp_core_get_user_domain( $user_obj->ID ), 1049 bp_get_settings_slug() 1050 ) ); 1051 } 1052 } 1052 1053 } 1053 1054 1055 // Set default unsubscribe link if not passed. 1056 if ( empty( $tokens['unsubscribe'] ) ) { 1057 $tokens['unsubscribe'] = site_url( 'wp-login.php' ); 1058 } 1059 1054 1060 // Email preheader. 1055 1061 $post = $email->get_post_object(); 1056 1062 if ( $post ) { -
src/bp-core/bp-core-functions.php
2983 2983 * on the email delivery class you are using. 2984 2984 */ 2985 2985 function bp_send_email( $email_type, $to, $args = array() ) { 2986 2986 2987 static $is_default_wpmail = null; 2987 2988 static $wp_html_emails = null; 2988 2989 … … 3006 3007 'tokens' => array(), 3007 3008 ), 'send_email' ); 3008 3009 3009 3010 3010 /* 3011 3011 * Build the email. 3012 3012 */ … … 3039 3039 3040 3040 if ( $must_use_wpmail ) { 3041 3041 $to = $email->get( 'to' ); 3042 3043 3042 return wp_mail( 3044 3043 array_shift( $to )->get_address(), 3045 3044 $email->get( 'subject', 'replace-tokens' ), … … 3047 3046 ); 3048 3047 } 3049 3048 3050 3051 3049 /* 3052 3050 * Send the email. 3053 3051 */ … … 3074 3072 } 3075 3073 3076 3074 $delivery = new $delivery_class(); 3075 3077 3076 $status = $delivery->bp_email( $email ); 3078 3077 3079 3078 if ( is_wp_error( $status ) ) { … … 3351 3350 } 3352 3351 3353 3352 /** 3354 * Get a list of emails for populating email type taxonomy terms.3353 * Gets an array of the email types descriptions. 3355 3354 * 3355 * Deprecated. 3356 * 3356 3357 * @since 2.5.1 3358 * @deprecated 2.6 Use bp_email_types_get_schema() 3359 * @see bp_email_types_get_schema() 3357 3360 * 3358 * @return array 3361 * @return array Array of the email type descriptions. 3359 3362 */ 3360 3363 function bp_email_get_type_schema() { 3361 return array( 3362 'activity-comment' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ), 3363 'activity-comment-author' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ), 3364 'activity-at-message' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ), 3365 'groups-at-message' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ), 3366 'core-user-registration' => __( 'Recipient has registered for an account.', 'buddypress' ), 3367 'core-user-registration-with-blog' => __( 'Recipient has registered for an account and site.', 'buddypress' ), 3368 'friends-request' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ), 3369 'friends-request-accepted' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ), 3370 'groups-details-updated' => __( "A group's details were updated.", 'buddypress' ), 3371 'groups-invitation' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ), 3372 'groups-member-promoted' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3373 'groups-membership-request' => __( 'A member has requested permission to join a group.', 'buddypress' ), 3374 'messages-unread' => __( 'Recipient has received a private message.', 'buddypress' ), 3375 'settings-verify-email-change' => __( 'Recipient has changed their email address.', 'buddypress' ), 3376 'groups-membership-request-accepted' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ), 3377 'groups-membership-request-rejected' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), 3364 $type_schema_description = wp_list_pluck( bp_email_type_schema(), 'description' ); 3365 return $type_schema_description; 3366 } 3367 3368 /** 3369 * Get a list of emails for populating email type taxonomy terms. 3370 * 3371 * @since 3372 * 3373 * @return array Array of the email type schema. 3374 */ 3375 function bp_email_types_get_schema() { 3376 3377 $activity_comment = array( 3378 'description' => __( 'A member has replied to an activity update that the recipient posted.', 'buddypress' ), 3379 'unsubscribe' => array( 3380 'meta_key' => 'notification_activity_new_reply', 3381 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), 3382 ), 3378 3383 ); 3384 3385 $activity_comment_author = array( 3386 'description' => __( 'A member has replied to a comment on an activity update that the recipient posted.', 'buddypress' ), 3387 'unsubscribe' => array( 3388 'meta_key' => 'notification_activity_new_reply', 3389 'message' => __( 'You will no longer receive emails when someone replies to an update or comment you posted.', 'buddypress' ), 3390 ), 3391 ); 3392 3393 $activity_at_message = array( 3394 'description' => __( 'Recipient was mentioned in an activity update.', 'buddypress' ), 3395 'unsubscribe' => array( 3396 'meta_key' => 'notification_activity_new_mention', 3397 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), 3398 ), 3399 ); 3400 3401 $groups_at_message = array( 3402 'description' => __( 'Recipient was mentioned in a group activity update.', 'buddypress' ), 3403 'unsubscribe' => array( 3404 'meta_key' => 'notification_activity_new_mention', 3405 'message' => __( 'You will no longer receive emails when someone mentions you in an update.', 'buddypress' ), 3406 ), 3407 ); 3408 3409 $core_user_registration = array( 3410 'description' => __( 'Recipient has registered for an account.', 'buddypress' ), 3411 'unsubscribe' => false, 3412 ); 3413 3414 $core_user_registration_with_blog = array( 3415 'description' => __( 'Recipient has registered for an account and site.', 'buddypress' ), 3416 'unsubscribe' => false, 3417 ); 3418 3419 $friends_request = array( 3420 'description' => __( 'A member has sent a friend request to the recipient.', 'buddypress' ), 3421 'unsubscribe' => array( 3422 'meta_key' => 'notification_friends_friendship_request', 3423 'message' => __( 'You will no longer receive emails when someone sends you a friend request.', 'buddypress' ), 3424 ), 3425 ); 3426 3427 $friends_request_accepted = array( 3428 'description' => __( 'Recipient has had a friend request accepted by a member.', 'buddypress' ), 3429 'unsubscribe' => array( 3430 'meta_key' => 'notification_friends_friendship_accepted', 3431 'message' => __( 'You will no longer receive emails when someone accepts your friendship request.', 'buddypress' ), 3432 ), 3433 ); 3434 3435 $groups_details_updated = array( 3436 'description' => __( "A group's details were updated.", 'buddypress' ), 3437 'unsubscribe' => array( 3438 'meta_key' => 'notification_groups_group_updated', 3439 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ), 3440 ), 3441 ); 3442 3443 $groups_details_updated = array( 3444 'description' => __( "A group's details were updated.", 'buddypress' ), 3445 'unsubscribe' => array( 3446 'meta_key' => 'notification_groups_group_updated', 3447 'message' => __( 'You will no longer receive emails when one of your groups is updated.', 'buddypress' ), 3448 ), 3449 ); 3450 3451 $groups_invitation = array( 3452 'description' => __( 'A member has sent a group invitation to the recipient.', 'buddypress' ), 3453 'unsubscribe' => array( 3454 'meta_key' => 'notification_groups_invite', 3455 'message' => __( 'You will no longer receive emails when you are invited to join a group.', 'buddypress' ), 3456 ), 3457 ); 3458 3459 $groups_member_promoted = array( 3460 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3461 'unsubscribe' => array( 3462 'meta_key' => 'notification_groups_admin_promotion', 3463 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ), 3464 ), 3465 ); 3466 3467 $groups_member_promoted = array( 3468 'description' => __( "Recipient's status within a group has changed.", 'buddypress' ), 3469 'unsubscribe' => array( 3470 'meta_key' => 'notification_groups_admin_promotion', 3471 'message' => __( 'You will no longer receive emails when you have been promoted in a group.', 'buddypress' ), 3472 ), 3473 ); 3474 3475 $groups_membership_request = array( 3476 'description' => __( 'A member has requested permission to join a group.', 'buddypress' ), 3477 'unsubscribe' => array( 3478 'meta_key' => 'notification_groups_membership_request', 3479 'message' => __( 'You will no longer receive emails when someone requests to be a member of your group.', 'buddypress' ), 3480 ), 3481 ); 3482 3483 $messages_unread = array( 3484 'description' => __( 'Recipient has received a private message.', 'buddypress' ), 3485 'unsubscribe' => array( 3486 'meta_key' => 'notification_messages_new_message', 3487 'message' => __( 'You will no longer receive emails when someone sends you a message.', 'buddypress' ), 3488 ), 3489 ); 3490 3491 $settings_verify_email_change = array( 3492 'description' => __( 'Recipient has changed their email address.', 'buddypress' ), 3493 'unsubscribe' => false, 3494 ); 3495 3496 $groups_membership_request_accepted = array( 3497 'description' => __( 'Recipient had requested to join a group, which was accepted.', 'buddypress' ), 3498 'unsubscribe' => array( 3499 'meta_key' => 'notification_membership_request_completed', 3500 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), 3501 ), 3502 ); 3503 3504 $groups_membership_request_rejected = array( 3505 'description' => __( 'Recipient had requested to join a group, which was rejected.', 'buddypress' ), 3506 'unsubscribe' => array( 3507 'meta_key' => 'notification_membership_request_completed', 3508 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), 3509 ), 3510 ); 3511 3512 $email_type_schema_array = array( 3513 'activity-comment' => $activity_comment, 3514 'activity-comment-author' => $activity_comment_author, 3515 'activity-at-message' => $activity_at_message, 3516 'groups-at-message' => $groups_at_message, 3517 'core-user-registration' => $core_user_registration, 3518 'core-user-registration-with-blog' => $core_user_registration_with_blog, 3519 'friends-request' => $friends_request, 3520 'friends-request-accepted' => $friends_request_accepted, 3521 'groups-details-updated' => $groups_details_updated, 3522 'groups-invitation' => $groups_invitation, 3523 'groups-member-promoted' => $groups_member_promoted, 3524 'groups-membership-request' => $groups_membership_request, 3525 'messages-unread' => $messages_unread, 3526 'settings-verify-email-change' => $settings_verify_email_change, 3527 'groups-membership-request-accepted' => $groups_membership_request_accepted, 3528 'groups-membership-request-rejected' => $groups_membership_request_rejected, 3529 ); 3530 3531 /** 3532 * Email types schema. 3533 * 3534 * @since 3535 * 3536 * @param array $email_type_schema_array { 3537 * The array of email types and their schema. 3538 * 3539 * @type string $description The description of the action which causes this to trigger. 3540 * @type array $email_type_schema_array['unsubscribe'] { 3541 * The unsubscribe array. 3542 * Setting the value to false indicates that a user cannot unsubscribe from this type. 3543 * 3544 * @type string $email_type_schema_array['unsubscribe']['meta_key'] The meta_key used to toggle the email setting for this notification. 3545 * @type string $email_type_schema_array['unsubscribe']['message'] The message shown when the user has successfully unsubscribed. 3546 * } 3547 * } 3548 */ 3549 return apply_filters( 'bp_email_types_get_schema', $email_type_schema_array ); 3379 3550 } 3551 3552 /** 3553 * Handles unsubscribe action to unsubscribe user from notification emails. 3554 * 3555 * @since 3556 * 3557 */ 3558 function bp_emails_unsubscribe_handler() { 3559 3560 $request = $_GET; 3561 $admin_email = get_bloginfo( 'admin_email' ); 3562 $bp_email_schema = bp_email_types_get_schema(); 3563 3564 $user_id = ( isset( $request['uid'] ) && ! empty( $request['uid'] ) ) ? (int) $request['uid'] : ''; 3565 $notification_type = ( isset( $request['nt'] ) && ! empty( $request['nt'] ) ) ? esc_attr( $request['nt'] ) : ''; 3566 $to_check = ( isset( $request['nn'] ) && ! empty( $request['nn'] ) ) ? $request['nn'] : ''; 3567 3568 $check_args = array( 3569 'uid' => $user_id, 3570 'nt' => $notification_type, 3571 ); 3572 3573 $check = bp_hash_array( $check_args ); 3574 3575 $current_user = is_user_logged_in() ? wp_get_current_user() : false; 3576 3577 if ( empty( $user_id ) || empty( $notification_type ) || empty( $to_check ) || ! array_key_exists( $notification_type, $bp_email_schema ) ) { 3578 3579 $settings_link = site_url( 'wp-login.php' ); 3580 $result_message = __( 'Sorry, something has gone wrong.', 'buddypress' ); 3581 $how_to_unsubscribe_message = __( 'Please log in and go to your settings to unsubscribe from notifications.', 'buddypress' ); 3582 } elseif ( ! hash_equals( $check, $to_check ) ) { 3583 3584 $settings_link = site_url( 'wp-login.php' ); 3585 $result_message = __( 'Sorry the security check failed.', 'buddypress' ); 3586 $how_to_unsubscribe_message = __( 'Please log in and go to your settings to unsubscribe from notifications.', 'buddypress' ); 3587 3588 } elseif ( is_user_logged_in() && (int) $current_user->ID !== (int) $user_id ) { 3589 3590 $settings_link = esc_url( sprintf( 3591 '%s%s/notifications/', 3592 bp_core_get_user_domain( (int) $current_user->ID ), 3593 function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings' 3594 ) ); 3595 3596 $result_message = __( 'Something has gone wrong.', 'buddypress' ); 3597 $how_to_unsubscribe_message = __( 'Please go to your settings to unsubscribe from notifications.', 'buddypress' ); 3598 } else { 3599 3600 $settings_link = esc_url( sprintf( 3601 '%s%s/notifications/', 3602 bp_core_get_user_domain( $user_id ), 3603 function_exists( 'bp_get_settings_slug' ) ? bp_get_settings_slug() : 'settings' 3604 ) ); 3605 3606 // unsubscribe them by setting the usermeta to 'no' 3607 $notification_meta_key = $bp_email_schema[ $notification_type ]['unsubscribe']['meta_key']; 3608 $is_unsubscribed = bp_update_user_meta( $user_id, $notification_meta_key, 'no' ); 3609 3610 $result_message = ( empty( $is_unsubscribed ) && bp_get_user_meta( $user_id, $notification_meta_key, true ) !== 'no' ) ? __( 'Sorry, something has gone wrong with unsubscribing you from these emails.', 'buddypress' ) : $bp_email_schema[ $notification_type ]['unsubscribe']['message']; 3611 3612 $how_to_unsubscribe_message = __( 'You can change this or any other email notification preferences in your email settings.', 'buddypress' ); 3613 } 3614 3615 $message = sprintf( 3616 '%1$s <a href="%2$s">%3$s</a>', 3617 $result_message, 3618 $settings_link, 3619 $how_to_unsubscribe_message 3620 ); 3621 3622 bp_core_add_message( $message ); 3623 bp_core_redirect( esc_url( remove_query_arg( array_keys( $request ) ) ) ); 3624 } 3625 3626 /** 3627 * Creates unsubscribe link for notification emails. 3628 * 3629 * @since 3630 * 3631 * @param string $redirect_to The URL to which the unsubscribe query string is appended. 3632 * @param array $args { 3633 * 3634 * Used to build unsubscribe query string. 3635 * 3636 * @type string $notification_type Which notification type is being sent. 3637 * @type string $user_id The ID of the user to whom the notification is sent. 3638 * @type string $redirect_to Optional. The url to which the user will be redirected. Default is the activity directory. 3639 * 3640 * } 3641 * @return string The unsubscribe link. 3642 */ 3643 function bp_email_get_unsubscribe_link( $args = null ) { 3644 3645 $bp_emails_type_schema = bp_email_types_get_schema(); 3646 3647 if ( ! is_array( $args ) || ! isset( $args['notification_type'] ) || ! array_key_exists( $args['notification_type'], $bp_emails_type_schema ) ) { 3648 return site_url( 'wp-login.php' ); 3649 } 3650 3651 $notification_type = $unsubscribe_args['nt'] = esc_attr( $args['notification_type'] ); 3652 $user_id = $unsubscribe_args['uid'] = (int) $args['user_id']; 3653 3654 // If the activity type is not unsubscribable (ununsubscribable), return false. 3655 if ( empty( $bp_emails_type_schema[ $notification_type ]['unsubscribe'] ) ) { 3656 return false; 3657 } 3658 3659 $redirect_to = ( isset( $args['redirect_to'] ) ) ? isset( $args['redirect_to'] ) : bp_get_activity_directory_permalink(); 3660 3661 $check = bp_hash_array( $unsubscribe_args ); 3662 3663 $unsubscribe_args['nn'] = $check; 3664 $unsubscribe_args['action'] = 'unsubscribe'; 3665 3666 $unsubscribe_link = esc_url_raw( add_query_arg( $unsubscribe_args, $redirect_to ) ); 3667 3668 /** 3669 * Filters the unsubscribe link. 3670 * 3671 * @since 3672 * 3673 * @param string $redirect_to URL to which the unsubscribe query string is appended. 3674 * @param array $args Used to build unsubscribe query string. 3675 */ 3676 return apply_filters( 'bp_email_get_unsubscribe_link', $unsubscribe_link, $redirect_to, $args ); 3677 } 3678 -
src/bp-core/bp-core-options.php
893 893 */ 894 894 return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $default ) ); 895 895 } 896 897 /** 898 * Get a persistent salt not dependent on salts in wp-config.php. 899 * 900 * @return string 901 * 902 */ 903 function bp_get_salt() { 904 905 $salt = bp_get_option( 'bp_persistent_salt' ); 906 if ( ! $salt ) { 907 $salt = base64_encode( mcrypt_create_iv( 12, MCRYPT_DEV_URANDOM ) ); 908 bp_add_option( 'bp_persistent_salt', $salt ); 909 } 910 911 return $salt; 912 } 913 914 /** 915 * Get a function that makes a checkable hash for the given args. 916 * 917 * @param array $args Any array. 918 * 919 * @return string 920 * 921 */ 922 function bp_hash_array( $args ) { 923 924 $salt = bp_get_salt(); 925 926 // order doesn't matter 927 ksort( $args ); 928 929 $string = ( is_array( $args ) ) ? implode( ':', $args ) : (string) $args; 930 931 // should this return a substring like the nonce does? It's quite long. 932 $check = hash_hmac( 'md5', $string, $salt ); 933 934 return $check; 935 } -
src/bp-friends/bp-friends-notifications.php
32 32 return; 33 33 } 34 34 35 $unsubscribe_args = array( 36 'user_id' => (int) $friend_id, 37 'notification_type' => 'friends-request', 38 ); 39 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 40 35 41 $args = array( 36 42 'tokens' => array( 37 43 'friend-requests.url' => esc_url( bp_core_get_user_domain( $friend_id ) . bp_get_friends_slug() . '/requests/' ), … … 40 46 'initiator.id' => $initiator_id, 41 47 'initiator.url' => esc_url( bp_core_get_user_domain( $initiator_id ) ), 42 48 'initiator.name' => bp_core_get_user_displayname( $initiator_id ), 49 'unsubscribe' => $unsubscribe_link, 43 50 ), 44 51 ); 45 52 bp_send_email( 'friends-request', $friend_id, $args ); … … 63 70 return; 64 71 } 65 72 73 $unsubscribe_args = array( 74 'user_id' => (int) $initiator_id, 75 'notification_type' => 'friends-request-accepted', 76 ); 77 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 78 66 79 $args = array( 67 80 'tokens' => array( 68 81 'friend.id' => $friend_id, … … 70 83 'friend.name' => bp_core_get_user_displayname( $friend_id ), 71 84 'friendship.id' => $friendship_id, 72 85 'initiator.id' => $initiator_id, 86 'unsubscribe' => $unsubscribe_link, 73 87 ), 74 88 ); 75 89 bp_send_email( 'friends-request-accepted', $initiator_id, $args ); -
src/bp-groups/bp-groups-notifications.php
68 68 continue; 69 69 } 70 70 71 $unsubscribe_args = array( 72 'user_id' => (int) $user_id, 73 'notification_type' => 'groups-details-updated', 74 ); 75 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 76 71 77 $args = array( 72 78 'tokens' => array( 73 79 'changed_text' => $changed_text, … … 75 81 'group.id' => $group_id, 76 82 'group.url' => esc_url( bp_get_group_permalink( $group ) ), 77 83 'group.name' => $group->name, 84 'unsubscribe' => $unsubscribe_link, 78 85 ), 79 86 ); 80 87 bp_send_email( 'groups-details-updated', (int) $user_id, $args ); … … 115 122 'item_id' => $group_id, 116 123 'secondary_item_id' => $requesting_user_id, 117 124 'component_name' => buddypress()->groups->id, 118 'component_action' => 'new_membership_request' 125 'component_action' => 'new_membership_request', 119 126 ) ); 120 127 } 121 128 … … 124 131 return; 125 132 } 126 133 134 $unsubscribe_args = array( 135 'user_id' => (int) $admin_id, 136 'notification_type' => 'groups-membership-request', 137 ); 138 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 139 127 140 $group = groups_get_group( array( 'group_id' => $group_id ) ); 128 141 $args = array( 129 142 'tokens' => array( … … 136 149 'profile.url' => esc_url( bp_core_get_user_domain( $requesting_user_id ) ), 137 150 'requesting-user.id' => $requesting_user_id, 138 151 'requesting-user.name' => bp_core_get_user_displayname( $requesting_user_id ), 152 'unsubscribe' => $unsubscribe_link, 139 153 ), 140 154 ); 141 155 bp_send_email( 'groups-membership-request', (int) $admin_id, $args ); … … 172 186 return; 173 187 } 174 188 189 $unsubscribe_args = array( 190 'user_id' => (int) $requesting_user_id, 191 'notification_type' => 'notification_membership_request_completed', 192 ); 193 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $user_groups_link, $unsubscribe_args ) ); 194 175 195 $group = groups_get_group( array( 'group_id' => $group_id ) ); 176 196 $args = array( 177 197 'tokens' => array( … … 184 204 ); 185 205 186 206 if ( ! empty( $accepted ) ) { 207 208 $unsubscribe_args = array( 209 'user_id' => (int) $requesting_user_id, 210 'notification_type' => 'groups-membership-request-accepted', 211 ); 212 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 213 214 $args['tokens']['unsubscribe'] = $unsubscribe_link; 215 187 216 bp_send_email( 'groups-membership-request-accepted', (int) $requesting_user_id, $args ); 217 188 218 } else { 219 220 $unsubscribe_args = array( 221 'user_id' => (int) $requesting_user_id, 222 'notification_type' => 'groups-membership-request-rejected', 223 ); 224 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 225 226 $args['tokens']['unsubscribe'] = $unsubscribe_link; 227 189 228 bp_send_email( 'groups-membership-request-rejected', (int) $requesting_user_id, $args ); 190 229 } 191 230 } … … 226 265 return; 227 266 } 228 267 268 $unsubscribe_args = array( 269 'user_id' => (int) $user_id, 270 'notification_type' => 'groups-member-promoted', 271 ); 272 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 273 229 274 $group = groups_get_group( array( 'group_id' => $group_id ) ); 230 275 $args = array( 231 276 'tokens' => array( … … 235 280 'group.name' => $group->name, 236 281 'promoted_to' => $promoted_to, 237 282 'user.id' => $user_id, 283 'unsubscribe' => $unsubscribe_link, 238 284 ), 239 285 ); 240 286 bp_send_email( 'groups-member-promoted', (int) $user_id, $args ); … … 277 323 } 278 324 279 325 $invited_link = bp_core_get_user_domain( $invited_user_id ) . bp_get_groups_slug(); 326 327 $unsubscribe_args = array( 328 'user_id' => (int) $invited_user_id, 329 'notification_type' => 'groups-invitation', 330 ); 331 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 332 280 333 $args = array( 281 334 'tokens' => array( 282 335 'group' => $group, … … 286 339 'inviter.url' => bp_core_get_user_domain( $inviter_user_id ), 287 340 'inviter.id' => $inviter_user_id, 288 341 'invites.url' => esc_url( $invited_link . '/invites/' ), 342 'unsubscribe' => $unsubscribe_link, 289 343 ), 290 344 ); 291 345 bp_send_email( 'groups-invitation', (int) $invited_user_id, $args ); -
src/bp-messages/bp-messages-notifications.php
58 58 continue; 59 59 } 60 60 61 $unsubscribe_args = array( 62 'user_id' => (int) $recipient->user_id, 63 'notification_type' => 'messages-unread', 64 ); 65 $unsubscribe_link = esc_url_raw( bp_email_get_unsubscribe_link( $unsubscribe_args ) ); 66 61 67 $args = array( 62 68 'tokens' => array( 63 69 'usermessage' => wp_strip_all_tags( stripslashes( $message ) ), … … 64 70 'message.url' => esc_url( bp_core_get_user_domain( $recipient->user_id ) . bp_get_messages_slug() . '/view/' . $thread_id . '/' ), 65 71 'sender.name' => $sender_name, 66 72 'usersubject' => sanitize_text_field( stripslashes( $subject ) ), 73 'unsubscribe' => $unsubscribe_link, 67 74 ), 68 75 ); 69 76 bp_send_email( 'messages-unread', $ud, $args ); -
tests/phpunit/testcases/admin/functions.php
252 252 'hide_empty' => false, 253 253 ) ); 254 254 255 $correct_descriptions = bp_email_ get_type_schema();255 $correct_descriptions = bp_email_type_schema(); 256 256 foreach ( $d_terms as $d_term ) { 257 $correct_description = $correct_descriptions[ $d_term->slug ] ;257 $correct_description = $correct_descriptions[ $d_term->slug ]['description']; 258 258 $this->assertSame( $correct_description, $d_term->description ); 259 259 } 260 260 }