Ticket #1949: wp_mail_filter_refactor_for_r2697.patch
File wp_mail_filter_refactor_for_r2697.patch, 39.5 KB (added by , 15 years ago) |
---|
-
bp-activity/bp-activity-notifications.php
15 15 if ( !$receiver_user_id = bp_core_get_userid($username) ) 16 16 continue; 17 17 18 / / Now email the user with the contents of the message (if they have enabled email notifications)18 /* Now email the user with the contents of the message (if they have enabled email notifications) */ 19 19 if ( 'no' != get_usermeta( $user_id, 'notification_activity_new_mention' ) ) { 20 20 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 21 22 21 $message_link = bp_activity_get_permalink( $activity_id ); 23 22 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . 'settings/notifications/'; 24 23 25 / / Set up and send the message24 /* Get email recipient data */ 26 25 $ud = bp_core_get_core_userdata( $receiver_user_id ); 27 $to = $ud->user_email; 28 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in an update', 'buddypress' ), stripslashes($poster_name) ); 26 $to = apply_filters( 'bp_activity_at_message_notification_to', $ud->user_email ); 29 27 30 $message = sprintf( __( 31 '%s mentioned you in an update: 28 /* Get blog name */ 29 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 32 30 33 "%s" 31 /* Filter content of comment */ 32 $content = bp_activity_filter_kses( stripslashes( $content ) ); 34 33 35 To view and respond to the message, log in and visit: %s 34 /* Allow filtering of email subject and body */ 35 $subject_text = apply_filters( 'bp_activity_at_message_notification_subject', __( '[%1$s] %2$s mentioned you in an update', 'buddypress' ), $blog_name, $poster_name ); 36 $message_text = apply_filters( 'bp_activity_at_message_notification_message', __( 37 '%1$s mentioned you in an update: 36 38 39 "%2$s" 40 41 To view and respond to the message, log in and visit: %3$s 42 37 43 --------------------- 38 ', 'buddypress' ), $poster_name, bp_activity_filter_kses( stripslashes($content) ), $message_link );44 ', 'buddypress' ), $poster_name, $content, $message_link ); 39 45 46 /* Prepare the email */ 47 $subject = sprintf( $subject_text, $blog_name, $poster_name ); 48 $message = sprintf( $message_text, $poster_name, $content, $message_link ); 49 50 /* Add link for user to turn off this notification */ 40 51 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 41 52 42 /* Send the message */ 43 $to = apply_filters( 'bp_activity_at_message_notification_to', $to ); 44 $subject = apply_filters( 'bp_activity_at_message_notification_subject', $subject ); 45 $message = apply_filters( 'bp_activity_at_message_notification_message', $message ); 46 53 /* Send the email */ 47 54 wp_mail( $to, $subject, $message ); 48 55 } 49 56 } … … 59 66 60 67 if ( $original_activity->user_id != $commenter_id && 'no' != get_usermeta( $original_activity->user_id, 'notification_activity_new_reply' ) ) { 61 68 $poster_name = bp_core_get_user_displayname( $commenter_id ); 69 $poster_name = stripslashes_deep( $poster_name ); 62 70 $thread_link = bp_activity_get_permalink( $activity_id ); 63 71 $settings_link = bp_core_get_user_domain( $original_activity->user_id ) . 'settings/notifications/'; 64 72 65 / / Set up and send the message73 /* Get email recipient data */ 66 74 $ud = bp_core_get_core_userdata( $original_activity->user_id ); 67 $to = $ud->user_email; 68 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your updates', 'buddypress' ), stripslashes_deep( $poster_name ) ); 75 $to = apply_filters( 'bp_activity_new_comment_notification_to', $ud->user_email ); 69 76 70 $message = sprintf( __( 71 '%s replied to one of your updates: 77 /* Get blog name */ 78 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 72 79 73 "%s" 80 /* Filter content of comment */ 81 $content = bp_activity_filter_kses( stripslashes( $content ) ); 74 82 75 To view your original update and all comments, log in and visit: %s 83 /* Allow filtering of email subject and body */ 84 $subject_text = apply_filters( 'bp_activity_new_comment_notification_subject', __( '[%1$s] %2$s replied to one of your updates', 'buddypress' ), $blog_name, $poster_name ); 85 $message_text = apply_filters( 'bp_activity_new_comment_notification_message', __( 86 '%1$s replied to one of your updates: 76 87 88 "%2$s" 89 90 To view your original update and all comments, log in and visit: %3$s 91 77 92 --------------------- 78 ', 'buddypress' ), $poster_name, bp_activity_filter_kses( stripslashes( $content ) ), $thread_link );93 ', 'buddypress' ), $poster_name, $content, $thread_link ); 79 94 95 /* Prepare the email */ 96 $subject = sprintf( $subject_text, $blog_name, $poster_name ); 97 $message = sprintf( $message_text, $poster_name, $content, $thread_link ); 98 99 /* Add link for user to turn off this notification */ 80 100 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 81 101 82 /* Send the message */ 83 $to = apply_filters( 'bp_activity_new_comment_notification_to', $to ); 84 $subject = apply_filters( 'bp_activity_new_comment_notification_subject', $subject ); 85 $message = apply_filters( 'bp_activity_new_comment_notification_message', $message ); 86 102 /* Send the email */ 87 103 wp_mail( $to, $subject, $message ); 88 104 } 89 105 … … 101 117 $thread_link = bp_activity_get_permalink( $activity_id ); 102 118 $settings_link = bp_core_get_user_domain( $parent_comment->user_id ) . 'settings/notifications/'; 103 119 104 / / Set up and send the message120 /* Get email recipient data */ 105 121 $ud = bp_core_get_core_userdata( $parent_comment->user_id ); 106 $to = $ud->user_email; 107 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s replied to one of your comments', 'buddypress' ), stripslashes_deep( $poster_name ) ); 122 $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $ud->user_email ); 108 123 109 $message = sprintf( __( 110 '%s replied to one of your comments: 124 /* Get blog name */ 125 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 111 126 112 "%s" 127 /* Filter content of comment */ 128 $content = bp_activity_filter_kses( stripslashes( $content ) ); 113 129 114 To view the original activity, your comment and all replies, log in and visit: %s 130 /* Allow filtering of email subject and body */ 131 $subject_text = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', __( '[%1$s] %2$s replied to one of your comments', 'buddypress' ), $blog_name, $poster_name ); 132 $message_text = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', __( 115 133 134 '%1$s replied to one of your comments: 135 136 "%2$s" 137 138 To view the original activity, your comment and all replies, log in and visit: %3$s 139 116 140 --------------------- 117 ', 'buddypress' ), $poster_name, bp_activity_filter_kses( stripslashes( $content ) ), $thread_link );141 ', 'buddypress' ), $poster_name, $content, $thread_link ); 118 142 119 143 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 120 144 121 /* Send the message */ 122 $to = apply_filters( 'bp_activity_new_comment_notification_comment_author_to', $to ); 123 $subject = apply_filters( 'bp_activity_new_comment_notification_comment_author_subject', $subject ); 124 $message = apply_filters( 'bp_activity_new_comment_notification_comment_author_message', $message ); 145 /* Prepare the email */ 146 $subject = sprintf( $subject_text, $blog_name, $poster_name ); 147 $message = sprintf( $message_text, $poster_name, $content, $thread_link ); 125 148 149 /* Add link for user to turn off this notification */ 150 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 151 152 /* Send the email */ 126 153 wp_mail( $to, $subject, $message ); 127 154 } 128 155 } -
bp-core/bp-core-activation.php
95 95 if ( !is_admin() && empty( $_GET['e'] ) ) 96 96 add_filter( 'wpmu_welcome_user_notification', 'bp_core_disable_welcome_email' ); 97 97 98 / / Notify user of signup success.98 /* Notify user of signup success. */ 99 99 function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key, $meta ) { 100 100 global $current_site; 101 101 102 / / Send email with activation link.103 $activate_url = bp_get_activation_page() . "?key=$key";104 $activate_url = clean_url( $activate_url);102 /* Send email with activation link. */ 103 $activate_url = bp_get_activation_page() . "?key=$key"; 104 $activate_url = clean_url( $activate_url ); 105 105 106 $admin_email = get_site_option( "admin_email" ); 106 /* Get admin email */ 107 $admin_email = get_site_option( 'admin_email' ); 107 108 108 109 if ( empty( $admin_email ) ) 109 110 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; 110 111 111 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 112 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 113 $message = sprintf(__("Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%s", 'buddypress' ), $activate_url, clean_url("http://{$domain}{$path}" ) ); 114 $subject = '[' . $from_name . '] ' . sprintf(__('Activate %s', 'buddypress' ), clean_url('http://' . $domain . $path)); 112 $from_name = ( '' == get_site_option( 'site_name' ) ) ? 'WordPress' : wp_specialchars( get_site_option( 'site_name' ) ); 113 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n"; 114 $site = clean_url( 'http://' . $domain . $path ); 115 115 116 /* Send the message*/116 /* Allow filtering of email recipient, subject, and body */ 117 117 $to = apply_filters( 'bp_core_activation_signup_blog_notification_to', $user_email ); 118 $subject = apply_filters( 'bp_core_activation_signup_blog_notification_subject', $subject);119 $message = apply_filters( 'bp_core_activation_signup_blog_notification_message', $message );118 $subject_text = apply_filters( 'bp_core_activation_signup_blog_notification_subject', __( '[%1$s] Activate %2$s', 'buddypress' ), $from_name, $site ); 119 $message_text = apply_filters( 'bp_core_activation_signup_blog_notification_message', __( 'Thanks for registering! To complete the activation of your account and blog, please click the following link:\n\n%1$s\n\n\n\nAfter you activate, you can visit your blog here:\n\n%2$s', 'buddypress' ), $activate_url, $site ); 120 120 121 /* Prepare the email */ 122 $subject = sprintf( $subject_text, $from_name, $site ); 123 $message = sprintf( $message_text, $activate_url, $site ); 124 125 /* Send the email */ 121 126 wp_mail( $to, $subject, $message, $message_headers ); 122 127 123 / / Return false to stop the original WPMU function from continuing128 /* Return false to stop the original WPMU function from continuing */ 124 129 return false; 125 130 } 126 131 if ( !is_admin() ) … … 129 134 function bp_core_activation_signup_user_notification( $user, $user_email, $key, $meta ) { 130 135 global $current_site; 131 136 132 $activate_url = bp_get_activation_page() . "?key=$key";137 $activate_url = bp_get_activation_page() . "?key=$key"; 133 138 $activate_url = clean_url($activate_url); 134 $admin_email = get_site_option( "admin_email");139 $admin_email = get_site_option( 'admin_email' ); 135 140 136 141 if ( empty( $admin_email ) ) 137 142 $admin_email = 'support@' . $_SERVER['SERVER_NAME']; … … 140 145 if ( is_admin() ) 141 146 $email = '&e=1'; 142 147 143 $from_name = ( '' == get_site_option( "site_name" ) ) ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) ); 144 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; 145 $message = sprintf( __( "Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n", 'buddypress' ), $activate_url . $email, clean_url("http://{$domain}{$path}" ) ); 146 $subject = '[' . $from_name . '] ' . __( 'Activate Your Account', 'buddypress' ); 148 $from_name = ( '' == get_site_option( 'site_name' ) ) ? 'WordPress' : wp_specialchars( get_site_option( 'site_name' ) ); 149 $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option( 'blog_charset' ) . "\"\n"; 147 150 148 /* Send the message*/151 /* Allow filtering of email recipient, subject, and body */ 149 152 $to = apply_filters( 'bp_core_activation_signup_user_notification_to', $user_email ); 150 $subject = apply_filters( 'bp_core_activation_signup_user_notification_subject', $subject);151 $message = apply_filters( 'bp_core_activation_signup_user_notification_message', $message);153 $subject_text = apply_filters( 'bp_core_activation_signup_user_notification_subject', __( '[%1$s] Activate Your Account', 'buddypress' ), $from_name ); 154 $message_text = apply_filters( 'bp_core_activation_signup_user_notification_message', __( 'Thanks for registering! To complete the activation of your account please click the following link:\n\n%s\n\n', 'buddypress' ), $activate_url ); 152 155 156 /* Prepare the email */ 157 $subject = sprintf( $subject_text, $from_name ); 158 $message = sprintf( $message_text, $activate_url ); 159 160 /* Send the email */ 153 161 wp_mail( $to, $subject, $message, $message_headers ); 154 162 155 / / Return false to stop the original WPMU function from continuing163 /* Return false to stop the original WPMU function from continuing */ 156 164 return false; 157 165 } 158 166 if ( !is_admin() || ( is_admin() && empty( $_POST['noconfirmation'] ) ) ) -
bp-friends/bp-friends-notifications.php
3 3 function friends_notification_new_request( $friendship_id, $initiator_id, $friend_id ) { 4 4 global $bp; 5 5 6 $initiator_name = bp_core_get_user_displayname( $initiator_id );7 8 6 if ( 'no' == get_usermeta( (int)$friend_id, 'notification_friends_friendship_request' ) ) 9 7 return false; 10 8 9 /* Get blog name */ 10 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 11 12 /* Get email recipient data */ 11 13 $ud = get_userdata( $friend_id ); 12 $initiator_ud = get_userdata( $initiator_id );13 14 14 $all_requests_link = bp_core_get_user_domain( $friend_id ) . BP_FRIENDS_SLUG . '/requests/'; 15 15 $settings_link = bp_core_get_user_domain( $friend_id ) . 'settings/notifications'; 16 $to = apply_filters( 'friends_notification_new_request_to', $ud->user_email ); 16 17 18 /* Get intiator data */ 19 $initiator_ud = get_userdata( $initiator_id ); 20 $initiator_name = bp_core_get_user_displayname( $initiator_id ); 17 21 $initiator_link = bp_core_get_user_domain( $initiator_id ); 18 22 19 // Set up and send the message 20 $to = $ud->user_email; 21 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New friendship request from %s', 'buddypress' ), $initiator_name ); 23 /* Allow filtering of email subject and body */ 24 $subject_text = apply_filters( 'friends_notification_new_request_subject', __( '[%1$s] New friendship request from %s', 'buddypress' ), $blog_name, $initiator_name ); 25 $message_text = apply_filters( 'friends_notification_new_request_message', __( 26 '%1$s wants to add you as a friend. 22 27 23 $message = sprintf( __( 24 "%s wants to add you as a friend. 28 To view %1$s\'s profile: %3$s 25 29 26 To view all of your pending friendship requests: % s30 To view all of your pending friendship requests: %2$s 27 31 28 To view %s's profile: %s29 30 32 --------------------- 31 ", 'buddypress' ), $initiator_name, $all_requests_link, $initiator_name, $initiator_link );33 ', 'buddypress' ), $initiator_name, $initiator_link, $all_requests_link ); 32 34 35 /* Prepare the email */ 36 $subject = sprintf( $subject_text, $blog_name, $initiator_name ); 37 $message = sprintf( $message_text, $initiator_name, $initiator_link, $all_requests_link ); 38 39 /* Add link for user to turn off this notification */ 33 40 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 34 41 35 /* Send the message */ 36 $to = apply_filters( 'friends_notification_new_request_to', $to ); 37 $subject = apply_filters( 'friends_notification_new_request_subject', $subject ); 38 $message = apply_filters( 'friends_notification_new_request_message', $message ); 39 42 /* Send the email */ 40 43 wp_mail( $to, $subject, $message ); 41 44 } 42 45 43 46 function friends_notification_accepted_request( $friendship_id, $initiator_id, $friend_id ) { 44 47 global $bp; 45 48 49 /* Create friendship */ 46 50 $friendship = new BP_Friends_Friendship( $friendship_id, false, false ); 47 51 48 $friend_name = bp_core_get_user_displayname( $friend_id );49 50 52 if ( 'no' == get_usermeta( (int)$initiator_id, 'notification_friends_friendship_accepted' ) ) 51 53 return false; 52 54 55 /* Get blog name */ 56 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 57 58 /* Get email recipient data */ 53 59 $ud = get_userdata( $initiator_id ); 60 $to = apply_filters( 'friends_notification_accepted_request_to', $ud->user_email ); 61 $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications'; 54 62 63 /* Get friend data */ 64 $friend_name = bp_core_get_user_displayname( $friend_id ); 55 65 $friend_link = bp_core_get_user_domain( $friend_id ); 56 $settings_link = bp_core_get_user_domain( $initiator_id ) . 'settings/notifications';57 66 58 // Set up and send the message59 $to = $ud->user_email;60 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s accepted your friendship request', 'buddypress' ), $friend_name );61 67 62 $message = sprintf( __( 63 '%s accepted your friend request. 68 /* Allow filtering of email subject and body */ 69 $subject_text = apply_filters( 'friends_notification_accepted_request_subject', __( '[%1$s] %2$s accepted your friendship request', 'buddypress' ), $blog_name, $friend_name ); 70 $message_text = apply_filters( 'friends_notification_accepted_request_message', __( 71 '%1$s accepted your friend request. 64 72 65 To view % s\'s profile: %s73 To view %1$s\'s profile: %2$s 66 74 67 75 --------------------- 68 ', 'buddypress' ), $friend_name, $friend_ name, $friend_link );76 ', 'buddypress' ), $friend_name, $friend_link ); 69 77 78 /* Prepare the email */ 79 $subject = sprintf( $subject_text, $blog_name, $friend_name ); 80 $message = sprintf( $message_text, $friend_name, $friend_link ); 81 82 /* Add link for user to turn off this notification */ 70 83 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 71 84 72 /* Send the message */ 73 $to = apply_filters( 'friends_notification_accepted_request_to', $to ); 74 $subject = apply_filters( 'friends_notification_accepted_request_subject', $subject ); 75 $message = apply_filters( 'friends_notification_accepted_request_message', $message ); 76 85 /* Send the email */ 77 86 wp_mail( $to, $subject, $message ); 78 87 } 79 88 -
bp-groups/bp-groups-notifications.php
3 3 function groups_notification_group_updated( $group_id ) { 4 4 global $bp; 5 5 6 /* Get group data */ 6 7 $group = new BP_Groups_Group( $group_id ); 7 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . __( 'Group Details Updated', 'buddypress' ); 8 $group_link = site_url( $bp->groups->slug . '/' . $group->slug ); 9 $user_ids = BP_Groups_Member::get_group_member_ids( $group->id ); 8 10 9 $user_ids = BP_Groups_Member::get_group_member_ids( $group->id ); 11 /* Get blog name */ 12 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 13 14 /* Email subject */ 15 $subject_text = apply_filters( 'groups_notification_group_updated_subject', __( '[%s] Group Details Updated', 'buddypress' ), $blog_name ); 16 10 17 foreach ( (array)$user_ids as $user_id ) { 11 18 if ( 'no' == get_usermeta( $user_id, 'notification_groups_group_updated' ) ) continue; 12 19 20 /* Get email recipient data */ 13 21 $ud = bp_core_get_core_userdata( $user_id ); 14 15 // Set up and send the message16 $to = $ud->user_email;17 18 $group_link = site_url( $bp->groups->slug . '/' . $group->slug );19 22 $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/'; 23 $to = apply_filters( 'groups_notification_group_updated_to', $ud->user_email ); 20 24 21 $message = sprintf( __( 22 'Group details for the group "%s" were updated: 25 /* Email text */ 26 $message_text = apply_filters( 'groups_notification_group_updated_message', __( 27 'Group details for the group "%1$s" were updated: 23 28 24 To view the group: % s29 To view the group: %2$s 25 30 26 31 --------------------- 27 32 ', 'buddypress' ), $group->name, $group_link ); 28 33 34 /* Prepare the email */ 35 $subject = sprintf( $subject_text, $blog_name ); 36 $message = sprintf( $message_text, $group->name, $group_link ); 37 38 /* Add link for user to turn off this notification */ 29 39 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 30 40 31 /* Send the message */ 32 $to = apply_filters( 'groups_notification_group_updated_to', $to ); 33 $subject = apply_filters( 'groups_notification_group_updated_subject', $subject ); 34 $message = apply_filters( 'groups_notification_group_updated_message', $message ); 35 41 /* Send the email */ 36 42 wp_mail( $to, $subject, $message ); 37 43 44 /* Unset specific user data to avoid duplicate emails */ 38 45 unset( $message, $to ); 39 46 } 40 47 } … … 47 54 if ( 'no' == get_usermeta( $admin_id, 'notification_groups_membership_request' ) ) 48 55 return false; 49 56 50 $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id );57 /* Get group data */ 51 58 $group = new BP_Groups_Group( $group_id ); 59 $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests'; 52 60 53 $ud = bp_core_get_core_userdata($admin_id); 54 $requesting_ud = bp_core_get_core_userdata($requesting_user_id); 61 /* Get email recipient data */ 62 $ud = bp_core_get_core_userdata( $admin_id ); 63 $to = apply_filters( 'groups_notification_new_membership_request_to', $ud->user_email ); 55 64 56 $group_requests = bp_get_group_permalink( $group ) . 'admin/membership-requests'; 65 /* Get requester data */ 66 $requesting_ud = bp_core_get_core_userdata( $requesting_user_id ); 67 $requesting_user_name = bp_core_get_user_displayname( $requesting_user_id ); 57 68 $profile_link = bp_core_get_user_domain( $requesting_user_id ); 58 69 $settings_link = bp_core_get_user_domain( $requesting_user_id ) . 'settings/notifications/'; 59 70 60 // Set up and send the message 61 $to = $ud->user_email; 62 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group: %s', 'buddypress' ), $group->name ); 71 /* Get blog name */ 72 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 63 73 64 $message = sprintf( __( 65 '%s wants to join the group "%s". 74 /* Allow filtering of email subject and body */ 75 $subject_text = apply_filters( 'groups_notification_new_membership_request_subject', __( '[%1$s] Membership request for group: %2$s', 'buddypress' ), $blog_name, $group->name ); 76 $message_text = apply_filters( 'groups_notification_new_membership_request_message', __( 77 '%1$s wants to join the group "%2$s". 66 78 67 79 Because you are the administrator of this group, you must either accept or reject the membership request. 68 80 69 81 To view all pending membership requests for this group, please visit: 70 % s82 %3$s 71 83 72 To view % s\'s profile: %s84 To view %1$s\'s profile: %4$s 73 85 74 86 --------------------- 75 ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $ requesting_user_name, $profile_link );87 ', 'buddypress' ), $requesting_user_name, $group->name, $group_requests, $profile_link ); 76 88 89 /* Prepare the email */ 90 $subject = sprintf( $subject_text, $blog_name, $group->name ); 91 $message = sprintf( $message_text, $requesting_user_name, $group->name, $group_requests, $profile_link ); 92 93 /* Add link for user to turn off this notification */ 77 94 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 78 95 79 /* Send the message */ 80 $to = apply_filters( 'groups_notification_new_membership_request_to', $to ); 81 $subject = apply_filters( 'groups_notification_new_membership_request_subject', $subject ); 82 $message = apply_filters( 'groups_notification_new_membership_request_message', $message ); 83 96 /* Send the email */ 84 97 wp_mail( $to, $subject, $message ); 85 98 } 86 99 87 100 function groups_notification_membership_request_completed( $requesting_user_id, $group_id, $accepted = true ) { 88 101 global $bp; 89 102 90 / / Post a screen notification first.103 /* Post a screen notification first. */ 91 104 if ( $accepted ) 92 105 bp_core_add_notification( $group_id, $requesting_user_id, 'groups', 'membership_request_accepted' ); 93 106 else … … 96 109 if ( 'no' == get_usermeta( $requesting_user_id, 'notification_membership_request_completed' ) ) 97 110 return false; 98 111 112 /* Get group data */ 99 113 $group = new BP_Groups_Group( $group_id ); 114 $group_link = bp_get_group_permalink( $group ); 100 115 101 $ud = bp_core_get_core_userdata($requesting_user_id); 102 103 $group_link = bp_get_group_permalink( $group ); 116 /* Get email recipient data */ 117 $ud = bp_core_get_core_userdata( $requesting_user_id ); 104 118 $settings_link = bp_core_get_user_domain( $requesting_user_id ) . 'settings/notifications/'; 119 $to = apply_filters( 'groups_notification_membership_request_completed_to', $ud->user_email ); 105 120 106 / / Set up and send the message107 $ to = $ud->user_email;121 /* Get blog name */ 122 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 108 123 124 /* Allow filtering of email subject and body */ 109 125 if ( $accepted ) { 110 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" accepted', 'buddypress' ), $group->name );111 $message = sprintf( __(112 'Your membership request for the group "% s" has been accepted.126 $subject_text = apply_filters( 'groups_notification_new_membership_request_subject', __( '[%1$s] Membership request for group "%2$s" accepted', 'buddypress' ), $blog_name, $group->name ); 127 $message_text = sprintf( __( 128 'Your membership request for the group "%1$s" has been accepted. 113 129 114 To view the group please login and visit: % s130 To view the group please login and visit: %2$s 115 131 116 132 --------------------- 117 133 ', 'buddypress' ), $group->name, $group_link ); 118 134 119 135 } else { 120 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'Membership request for group "%s" rejected', 'buddypress' ), $group->name );121 $message = sprintf( __(122 'Your membership request for the group "% s" has been rejected.136 $subject_text = apply_filters( 'groups_notification_new_membership_request_subject', __( '[%1$s] Membership request for group "%2$s" rejected', 'buddypress' ), $blog_name, $group->name ); 137 $message_text = sprintf( __( 138 'Your membership request for the group "%1$s" has been rejected. 123 139 124 To submit another request please log in and visit: % s140 To submit another request please log in and visit: %2$s 125 141 126 142 --------------------- 127 143 ', 'buddypress' ), $group->name, $group_link ); 128 144 } 129 145 146 /* Prepare the email */ 147 $subject = sprintf( $subject_text, $blog_name, $group->name ); 148 $message = sprintf( $message_text, $group->name, $group_link ); 149 150 /* Add link for user to turn off this notification */ 130 151 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 131 152 132 /* Send the message */ 133 $to = apply_filters( 'groups_notification_membership_request_completed_to', $to ); 134 $subject = apply_filters( 'groups_notification_membership_request_completed_subject', $subject ); 135 $message = apply_filters( 'groups_notification_membership_request_completed_message', $message ); 136 153 /* Send the email */ 137 154 wp_mail( $to, $subject, $message ); 138 155 } 139 156 … … 148 165 $type = 'member_promoted_to_mod'; 149 166 } 150 167 151 / / Post a screen notification first.168 /* Post a screen notification first. */ 152 169 bp_core_add_notification( $group_id, $user_id, 'groups', $type ); 153 170 154 171 if ( 'no' == get_usermeta( $user_id, 'notification_groups_admin_promotion' ) ) 155 172 return false; 156 173 174 /* Get group data */ 157 175 $group = new BP_Groups_Group( $group_id ); 158 $ ud = bp_core_get_core_userdata($user_id);176 $group_link = bp_get_group_permalink( $group ); 159 177 160 $group_link = bp_get_group_permalink( $group ); 178 /* Get email recipient data */ 179 $ud = bp_core_get_core_userdata( $user_id ); 161 180 $settings_link = bp_core_get_user_domain( $user_id ) . 'settings/notifications/'; 181 $to = apply_filters( 'groups_notification_promoted_member_to', $ud->user_email ); 162 182 163 / / Set up and send the message164 $ to = $ud->user_email;183 /* Get blog name */ 184 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 165 185 166 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have been promoted in the group: "%s"', 'buddypress' ), $group->name ); 186 /* Allow filtering of email subject and body */ 187 $subject_text = apply_filters( 'groups_notification_promoted_member_subject', __( '[%1$s] You have been promoted in the group: "%s"', 'buddypress' ), $blog_name, $group->name ); 188 $message_text = apply_filters( 'groups_notification_promoted_member_message', __( 189 'You have been promoted to %1$s for the group: "%2$s". 167 190 168 $message = sprintf( __( 169 'You have been promoted to %s for the group: "%s". 191 To view the group please visit: %3$s 170 192 171 To view the group please visit: %s172 173 193 --------------------- 174 194 ', 'buddypress' ), $promoted_to, $group->name, $group_link ); 175 195 196 /* Prepare the email */ 197 $subject = sprintf( $subject_text, $blog_name, $group->name ); 198 $message = sprintf( $message_text, $promoted_to, $group->name, $group_link ); 199 200 /* Add link for user to turn off this notification */ 176 201 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 177 202 178 /* Send the message */ 179 $to = apply_filters( 'groups_notification_promoted_member_to', $to ); 180 $subject = apply_filters( 'groups_notification_promoted_member_subject', $subject ); 181 $message = apply_filters( 'groups_notification_promoted_member_message', $message ); 182 203 /* Send the email */ 183 204 wp_mail( $to, $subject, $message ); 184 205 } 185 206 add_action( 'groups_promoted_member', 'groups_notification_promoted_member', 10, 2 ); … … 187 208 function groups_notification_group_invites( &$group, &$member, $inviter_user_id ) { 188 209 global $bp; 189 210 211 /* Get inviter data */ 190 212 $inviter_ud = bp_core_get_core_userdata( $inviter_user_id ); 191 213 $inviter_name = bp_core_get_userlink( $inviter_user_id, true, false, true ); 192 214 $inviter_link = bp_core_get_user_domain( $inviter_user_id ); 193 215 216 /* Get group data */ 194 217 $group_link = bp_get_group_permalink( $group ); 195 218 196 219 if ( !$member->invite_sent ) { 197 220 $invited_user_id = $member->user_id; 198 221 199 / / Post a screen notification first.222 /* Post a screen notification first. */ 200 223 bp_core_add_notification( $group->id, $invited_user_id, 'groups', 'group_invite' ); 201 224 202 225 if ( 'no' == get_usermeta( $invited_user_id, 'notification_groups_invite' ) ) 203 226 return false; 204 227 228 /* Get invited data */ 205 229 $invited_ud = bp_core_get_core_userdata($invited_user_id); 206 207 230 $settings_link = bp_core_get_user_domain( $invited_user_id ) . 'settings/notifications/'; 208 231 $invited_link = bp_core_get_user_domain( $invited_user_id ); 209 232 $invites_link = $invited_link . $bp->groups->slug . '/invites'; 233 $to = apply_filters( 'groups_notification_group_invites_to', $invited_ud->user_email ); 210 234 211 // Set up and send the message 212 $to = $invited_ud->user_email; 235 /* Allow filtering of email subject and body */ 236 $subject_text = apply_filters( 'groups_notification_group_invites_subject', __( '[%1$s] You have an invitation to the group: "%s"', 'buddypress' ), $blog_name, $group->name ); 237 $message_text = apply_filters( 'groups_notification_group_invites_message', __( 238 'One of your friends (%1$s) has invited you to the group "%2$s". 213 239 214 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'You have an invitation to the group: "%s"', 'buddypress' ), $group->name ); 240 To view your group invites visit: %3$s 215 241 216 $message = sprintf( __( 217 'One of your friends %s has invited you to the group: "%s". 242 To view the group visit: %4$s 218 243 219 To view your group invites visit: %s244 To view %1$s\'s profile visit: %5$s 220 245 221 To view the group visit: %s 246 --------------------- 247 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_link ); 222 248 223 To view %s\'s profile visit: %s 249 /* Prepare the email */ 250 $subject = sprintf( $subject_text, $blog_name, $group->name ); 251 $message = sprintf( $message_text, $inviter_name, $group->name, $invites_link, $group_link, $inviter_link ); 224 252 225 --------------------- 226 ', 'buddypress' ), $inviter_name, $group->name, $invites_link, $group_link, $inviter_name, $inviter_link ); 227 253 /* Add link for user to turn off this notification */ 228 254 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 229 255 230 /* Send the message */ 231 $to = apply_filters( 'groups_notification_group_invites_to', $to ); 232 $subject = apply_filters( 'groups_notification_group_invites_subject', $subject ); 233 $message = apply_filters( 'groups_notification_group_invites_message', $message ); 234 256 /* Send the email */ 235 257 wp_mail( $to, $subject, $message ); 236 258 } 237 259 } … … 247 269 if ( !$usernames = array_unique( $usernames[1] ) ) 248 270 return false; 249 271 272 /* Get group data */ 250 273 $group = new BP_Groups_Group( $group_id ); 251 274 252 275 foreach( (array)$usernames as $username ) { 253 if ( !$receiver_user_id = bp_core_get_userid($username) ) 254 continue; 276 if ( !$receiver_user_id = bp_core_get_userid( $username ) ) continue; 255 277 256 278 /* Check the user is a member of the group before sending the update. */ 257 if ( !groups_is_user_member( $receiver_user_id, $group_id ) ) 258 continue; 279 if ( !groups_is_user_member( $receiver_user_id, $group_id ) ) continue; 259 280 260 / / Now email the user with the contents of the message (if they have enabled email notifications)281 /* Now email the user with the contents of the message (if they have enabled email notifications) */ 261 282 if ( 'no' != get_usermeta( $user_id, 'notification_activity_new_mention' ) ) { 283 /* Get poster name */ 262 284 $poster_name = bp_core_get_user_displayname( $poster_user_id ); 285 $poster_name = stripslashes( $poster_name ); 263 286 287 /* Get activity data */ 264 288 $message_link = bp_activity_get_permalink( $activity_id ); 289 $content = bp_groups_filter_kses( stripslashes( $content ) ); 290 291 /* Get email recipient data */ 292 $ud = bp_core_get_core_userdata( $receiver_user_id ); 265 293 $settings_link = bp_core_get_user_domain( $receiver_user_id ) . 'settings/notifications/'; 294 $to = apply_filters( 'groups_at_message_notification_to', $ud->user_email ); 266 295 267 / / Set up and send the message268 $ ud = bp_core_get_core_userdata( $receiver_user_id);269 $ to = $ud->user_email;270 $subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( '%s mentioned you in the group "%s"', 'buddypress' ), stripslashes( $poster_name ), $group->name ); 296 /* Allow filtering of email subject and body */ 297 $subject_text = apply_filters( 'groups_at_message_notification_subject', __( '[%1$s] %s mentioned you in the group "%s"', 'buddypress' ), $blog_name, $poster_name, $group->name ); 298 $message_text = apply_filters( 'groups_at_message_notification_message', __( 299 '%1$s mentioned you in the group "%2$s": 271 300 272 $message = sprintf( __( 273 '%s mentioned you in the group "%s": 301 "%3$s" 274 302 275 "%s" 303 To view and/or respond to the message, log in and visit: %4$s 276 304 277 To view and respond to the message, log in and visit: %s278 279 305 --------------------- 280 ', 'buddypress' ), $poster_name, $group->name, bp_groups_filter_kses( stripslashes( $content ) ), $message_link );306 ', 'buddypress' ), $poster_name, $group->name, $content, $message_link ); 281 307 308 /* Prepare the email */ 309 $subject = sprintf( $subject_text, $blog_name, $poster_name, $group->name ); 310 $message = sprintf( $message_text, $poster_name, $group->name, $content, $message_link ); 311 312 /* Add link for user to turn off this notification */ 282 313 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 283 314 284 /* Send the message */ 285 $to = apply_filters( 'groups_at_message_notification_to', $to ); 286 $subject = apply_filters( 'groups_at_message_notification_subject', $subject ); 287 $message = apply_filters( 'groups_at_message_notification_message', $message ); 288 315 /* Send the email */ 289 316 wp_mail( $to, $subject, $message ); 290 317 } 291 318 } 292 319 } 293 320 add_action( 'bp_groups_posted_update', 'groups_at_message_notification', 10, 4 ); 294 321 295 296 322 ?> 297 No newline at end of file -
bp-messages/bp-messages-notifications.php
4 4 global $bp; 5 5 extract($args); 6 6 7 /* Email sender */ 7 8 $sender_name = bp_core_get_user_displayname( $sender_id ); 9 $sender_name = stripslashes( $sender_name ); 8 10 11 /* Get blog name */ 12 $blog_name = get_blog_option( BP_ROOT_BLOG, 'blogname' ); 13 14 /* Message subject */ 15 $subject = stripslashes( wp_filter_kses( $subject ) ); 16 $subject_text = apply_filters( 'messages_notification_new_message_subject', __( '[%1$s] New message from %2$s', 'buddypress' ), $blog_name, $sender_name ); 17 9 18 foreach( $recipients as $recipient ) { 10 19 if ( $sender_id == $recipient->user_id || 'no' == get_usermeta( $recipient->user_id, 'notification_messages_new_message' ) ) continue; 11 20 21 /* Get email recipient data */ 12 22 $ud = get_userdata( $recipient->user_id ); 13 23 $message_link = bp_core_get_user_domain( $recipient->user_id ) . BP_MESSAGES_SLUG .'/'; 14 24 $settings_link = bp_core_get_user_domain( $recipient->user_id ) . 'settings/notifications/'; 25 $to = apply_filters( 'messages_notification_new_message_to', $ud->user_email ); 15 26 16 // Set up and send the message 17 $email_to = $ud->user_email; 18 $email_subject = '[' . get_blog_option( BP_ROOT_BLOG, 'blogname' ) . '] ' . sprintf( __( 'New message from %s', 'buddypress' ), stripslashes( $sender_name ) ); 27 /* Message body */ 28 $content = stripslashes( wp_filter_kses( $content ) ); 29 $message_text = apply_filters( 'messages_notification_new_message_message', __( 30 '%1$s sent you a new message: 19 31 20 $email_content = sprintf( __( 21 '%s sent you a new message: 32 Subject: %2$s 22 33 23 Subject: %s 34 "%3$s" 24 35 25 "%s" 36 To view and read your messages please log in and visit: %4$s 26 37 27 To view and read your messages please log in and visit: %s28 29 38 --------------------- 30 ', 'buddypress' ), $sender_name, stripslashes( wp_filter_kses( $subject ) ), stripslashes( wp_filter_kses( $content ) ), $message_link );39 ', 'buddypress' ), $sender_name, $subject, $content, $message_link ); 31 40 32 $content .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 41 /* Prepare the email */ 42 $subject = sprintf( $subject_text, $blog_name, $sender_name ); 43 $message = sprintf( $message_text, $sender_name, $subject, $content, $message_link ); 33 44 34 /* Send the message */ 35 $email_to = apply_filters( 'messages_notification_new_message_to', $email_to ); 36 $email_subject = apply_filters( 'messages_notification_new_message_subject', $email_subject ); 37 $email_content = apply_filters( 'messages_notification_new_message_message', $email_content ); 45 /* Add link for user to turn off this notification */ 46 $message .= sprintf( __( 'To disable these notifications please log in and go to: %s', 'buddypress' ), $settings_link ); 38 47 39 wp_mail( $email_to, $email_subject, $email_content ); 48 /* Send the email */ 49 wp_mail( $to, $subject, $message ); 50 51 /* Unset specific user data to avoid duplicate emails */ 52 unset( $message, $to ); 40 53 } 41 54 } 42 55