Changeset 5643 for branches/2.5/includes/common/functions.php
- Timestamp:
- 03/17/2015 03:38:20 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.5/includes/common/functions.php
r5639 r5643 983 983 984 984 /** 985 * Get the "Do Not Reply" email address to use when sending subscription emails. 986 * 987 * We make some educated guesses here based on the home URL. Filters are 988 * available to customize this address further. In the future, we may consider 989 * using `admin_email` instead, though this is not normally publicized. 990 * 991 * We use `$_SERVER['SERVER_NAME']` here to mimic similar functionality in 992 * WordPress core. Previously, we used `get_home_url()` to use already validated 993 * user input, but it was causing issues in some installations. 994 * 995 * @since bbPress (r5409) 996 * 997 * @see wp_mail 998 * @see wp_notify_postauthor 999 * @link https://bbpress.trac.wordpress.org/ticket/2618 1000 * 1001 * @return string 1002 */ 1003 function bbp_get_do_not_reply_address() { 1004 $sitename = strtolower( $_SERVER['SERVER_NAME'] ); 1005 if ( substr( $sitename, 0, 4 ) === 'www.' ) { 1006 $sitename = substr( $sitename, 4 ); 1007 } 1008 return apply_filters( 'bbp_get_do_not_reply_address', 'noreply@' . $sitename ); 1009 } 1010 1011 /** 985 1012 * Sends notification emails for new replies to subscribed topics 986 1013 * … … 994 1021 * custom emailer script. 995 1022 * 996 * @since bbPress (r 2668)1023 * @since bbPress (r5413) 997 1024 * 998 1025 * @param int $reply_id ID of the newly made reply 1026 * @param int $topic_id ID of the topic of the reply 1027 * @param int $forum_id ID of the forum of the reply 1028 * @param mixed $anonymous_data Array of anonymous user data 1029 * @param int $reply_author ID of the topic author ID 1030 * 999 1031 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 1000 1032 * @uses bbp_get_reply_id() To validate the reply ID … … 1021 1053 * @return bool True on success, false on failure 1022 1054 */ 1023 function bbp_notify_ subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) {1055 function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) { 1024 1056 1025 1057 // Bail if subscriptions are turned off … … 1063 1095 $reply_url = bbp_get_reply_url( $reply_id ); 1064 1096 $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 1065 $do_not_reply = '<noreply@' . preg_replace( '@^https?://(www\.)?@i', '', get_home_url() ) . '>';1066 1097 1067 1098 // For plugins to filter messages per reply/topic/user … … 1096 1127 /** Users *****************************************************************/ 1097 1128 1098 // Array to hold BCC's 1099 $headers = array(); 1129 // Get the noreply@ address 1130 $no_reply = bbp_get_do_not_reply_address(); 1131 1132 // Setup "From" email address 1133 $from_email = apply_filters( 'bbp_subscription_from_email', $no_reply ); 1100 1134 1101 1135 // Setup the From header 1102 $headers [] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;1136 $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' ); 1103 1137 1104 1138 // Get topic subscribers and bail if empty 1105 1139 $user_ids = bbp_get_topic_subscribers( $topic_id, true ); 1140 1141 // Dedicated filter to manipulate user ID's to send emails to 1142 $user_ids = apply_filters( 'bbp_topic_subscription_user_ids', $user_ids ); 1106 1143 if ( empty( $user_ids ) ) { 1107 1144 return false; … … 1123 1160 1124 1161 // Custom headers 1125 $headers = apply_filters( 'bbp_subscription_mail_headers', $headers ); 1162 $headers = apply_filters( 'bbp_subscription_mail_headers', $headers ); 1163 $to_email = apply_filters( 'bbp_subscription_to_email', $no_reply ); 1126 1164 1127 1165 do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids ); 1128 1166 1129 1167 // Send notification email 1130 wp_mail( $ do_not_reply, $subject, $message, $headers );1168 wp_mail( $to_email, $subject, $message, $headers ); 1131 1169 1132 1170 do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids ); … … 1150 1188 * 1151 1189 * @param int $topic_id ID of the newly made reply 1190 * @param int $forum_id ID of the forum for the topic 1191 * @param mixed $anonymous_data Array of anonymous user data 1192 * @param int $topic_author ID of the topic author ID 1193 * 1152 1194 * @uses bbp_is_subscriptions_active() To check if the subscriptions are active 1153 1195 * @uses bbp_get_topic_id() To validate the topic ID … … 1181 1223 $forum_id = bbp_get_forum_id( $forum_id ); 1182 1224 1225 /** 1226 * Necessary for backwards compatibility 1227 * 1228 * @see https://bbpress.trac.wordpress.org/ticket/2620 1229 */ 1230 $user_id = 0; 1231 1183 1232 /** Topic *****************************************************************/ 1184 1233 … … 1203 1252 $topic_url = get_permalink( $topic_id ); 1204 1253 $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 1205 $do_not_reply = '<noreply@' . preg_replace( '@^https?://(www\.)?@i', '', get_home_url() ) . '>';1206 1254 1207 1255 // For plugins to filter messages per reply/topic/user … … 1236 1284 /** User ******************************************************************/ 1237 1285 1238 // Array to hold BCC's 1239 $headers = array(); 1286 // Get the noreply@ address 1287 $no_reply = bbp_get_do_not_reply_address(); 1288 1289 // Setup "From" email address 1290 $from_email = apply_filters( 'bbp_subscription_from_email', $no_reply ); 1240 1291 1241 1292 // Setup the From header 1242 $headers [] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;1293 $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' ); 1243 1294 1244 1295 // Get topic subscribers and bail if empty 1245 1296 $user_ids = bbp_get_forum_subscribers( $forum_id, true ); 1297 1298 // Dedicated filter to manipulate user ID's to send emails to 1299 $user_ids = apply_filters( 'bbp_forum_subscription_user_ids', $user_ids ); 1246 1300 if ( empty( $user_ids ) ) { 1247 1301 return false; … … 1263 1317 1264 1318 // Custom headers 1265 $headers = apply_filters( 'bbp_subscription_mail_headers', $headers ); 1319 $headers = apply_filters( 'bbp_subscription_mail_headers', $headers ); 1320 $to_email = apply_filters( 'bbp_subscription_to_email', $no_reply ); 1266 1321 1267 1322 do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids ); 1268 1323 1269 1324 // Send notification email 1270 wp_mail( $ do_not_reply, $subject, $message, $headers );1325 wp_mail( $to_email, $subject, $message, $headers ); 1271 1326 1272 1327 do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids ); 1273 1328 1274 1329 return true; 1330 } 1331 1332 /** 1333 * Sends notification emails for new replies to subscribed topics 1334 * 1335 * This function is deprecated. Please use: bbp_notify_topic_subscribers() 1336 * 1337 * @since bbPress (r2668) 1338 * @deprecated bbPress (r5412) 1339 * 1340 * @param int $reply_id ID of the newly made reply 1341 * @param int $topic_id ID of the topic of the reply 1342 * @param int $forum_id ID of the forum of the reply 1343 * @param mixed $anonymous_data Array of anonymous user data 1344 * @param int $reply_author ID of the topic author ID 1345 * 1346 * @return bool True on success, false on failure 1347 */ 1348 function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) { 1349 return bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id, $anonymous_data, $reply_author ); 1275 1350 } 1276 1351
Note: See TracChangeset
for help on using the changeset viewer.