bbPress - Version 2.5.6

Version Description

  • Improved notification & subscription email sending
Download this release

Release Info

Developer johnjamesjacoby
Plugin Icon 128x128 bbPress
Version 2.5.6
Comparing to
See all releases

Code changes from version 2.5.5 to 2.5.6

bbpress.php CHANGED
@@ -5,7 +5,7 @@
5
  *
6
  * bbPress is forum software with a twist from the creators of WordPress.
7
  *
8
- * $Id: bbpress.php 5631 2015-03-06 17:03:13Z johnjamesjacoby $
9
  *
10
  * @package bbPress
11
  * @subpackage Main
@@ -17,7 +17,7 @@
17
  * Description: bbPress is forum software with a twist from the creators of WordPress.
18
  * Author: The bbPress Community
19
  * Author URI: http://bbpress.org
20
- * Version: 2.5.5
21
  * Text Domain: bbpress
22
  * Domain Path: /languages/
23
  */
@@ -190,7 +190,7 @@ final class bbPress {
190
 
191
  /** Versions **********************************************************/
192
 
193
- $this->version = '2.5.5-5631';
194
  $this->db_version = '250';
195
 
196
  /** Paths *************************************************************/
5
  *
6
  * bbPress is forum software with a twist from the creators of WordPress.
7
  *
8
+ * $Id: bbpress.php 5644 2015-03-17 03:46:57Z johnjamesjacoby $
9
  *
10
  * @package bbPress
11
  * @subpackage Main
17
  * Description: bbPress is forum software with a twist from the creators of WordPress.
18
  * Author: The bbPress Community
19
  * Author URI: http://bbpress.org
20
+ * Version: 2.5.6
21
  * Text Domain: bbpress
22
  * Domain Path: /languages/
23
  */
190
 
191
  /** Versions **********************************************************/
192
 
193
+ $this->version = '2.5.6-5643';
194
  $this->db_version = '250';
195
 
196
  /** Paths *************************************************************/
includes/admin/js/replies.js CHANGED
@@ -11,4 +11,4 @@ jQuery( document ).ready(function() {
11
  }
12
  }
13
  );
14
- } );
11
  }
12
  }
13
  );
14
+ } );
includes/common/functions.php CHANGED
@@ -981,6 +981,33 @@ function bbp_check_for_blacklist( $anonymous_data = false, $author_id = 0, $titl
981
 
982
  /** Subscriptions *************************************************************/
983
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
984
  /**
985
  * Sends notification emails for new replies to subscribed topics
986
  *
@@ -992,10 +1019,15 @@ function bbp_check_for_blacklist( $anonymous_data = false, $author_id = 0, $titl
992
  * that limit the number of addresses in a BCC field (often to around 500.) In
993
  * those cases, we recommend unhooking this function and creating your own
994
  * custom emailer script.
995
- *
996
- * @since bbPress (r2668)
997
  *
998
  * @param int $reply_id ID of the newly made reply
 
 
 
 
 
999
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
1000
  * @uses bbp_get_reply_id() To validate the reply ID
1001
  * @uses bbp_get_topic_id() To validate the topic ID
@@ -1020,7 +1052,7 @@ function bbp_check_for_blacklist( $anonymous_data = false, $author_id = 0, $titl
1020
  * topic id and user id
1021
  * @return bool True on success, false on failure
1022
  */
1023
- function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) {
1024
 
1025
  // Bail if subscriptions are turned off
1026
  if ( !bbp_is_subscriptions_active() ) {
@@ -1062,7 +1094,6 @@ function bbp_notify_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $a
1062
  $reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
1063
  $reply_url = bbp_get_reply_url( $reply_id );
1064
  $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1065
- $do_not_reply = '<noreply@' . ltrim( get_home_url(), '^(http|https)://' ) . '>';
1066
 
1067
  // For plugins to filter messages per reply/topic/user
1068
  $message = sprintf( __( '%1$s wrote:
@@ -1095,14 +1126,20 @@ Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
1095
 
1096
  /** Users *****************************************************************/
1097
 
1098
- // Array to hold BCC's
1099
- $headers = array();
 
 
 
1100
 
1101
  // Setup the From header
1102
- $headers[] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
1103
-
1104
  // Get topic subscribers and bail if empty
1105
  $user_ids = bbp_get_topic_subscribers( $topic_id, true );
 
 
 
1106
  if ( empty( $user_ids ) ) {
1107
  return false;
1108
  }
@@ -1122,12 +1159,13 @@ Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
1122
  /** Send it ***************************************************************/
1123
 
1124
  // Custom headers
1125
- $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
 
1126
 
1127
  do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
1128
 
1129
  // Send notification email
1130
- wp_mail( $do_not_reply, $subject, $message, $headers );
1131
 
1132
  do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
1133
 
@@ -1145,10 +1183,14 @@ Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
1145
  * that limit the number of addresses in a BCC field (often to around 500.) In
1146
  * those cases, we recommend unhooking this function and creating your own
1147
  * custom emailer script.
1148
- *
1149
  * @since bbPress (r5156)
1150
  *
1151
  * @param int $topic_id ID of the newly made reply
 
 
 
 
1152
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
1153
  * @uses bbp_get_topic_id() To validate the topic ID
1154
  * @uses bbp_get_forum_id() To validate the forum ID
@@ -1180,6 +1222,13 @@ function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_
1180
  $topic_id = bbp_get_topic_id( $topic_id );
1181
  $forum_id = bbp_get_forum_id( $forum_id );
1182
 
 
 
 
 
 
 
 
1183
  /** Topic *****************************************************************/
1184
 
1185
  // Bail if topic is not published
@@ -1202,7 +1251,6 @@ function bbp_notify_forum_subscribers( $topic_id = 0, $forum_id = 0, $anonymous_
1202
  $topic_content = strip_tags( bbp_get_topic_content( $topic_id ) );
1203
  $topic_url = get_permalink( $topic_id );
1204
  $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
1205
- $do_not_reply = '<noreply@' . ltrim( get_home_url(), '^(http|https)://' ) . '>';
1206
 
1207
  // For plugins to filter messages per reply/topic/user
1208
  $message = sprintf( __( '%1$s wrote:
@@ -1235,14 +1283,20 @@ Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
1235
 
1236
  /** User ******************************************************************/
1237
 
1238
- // Array to hold BCC's
1239
- $headers = array();
 
 
 
1240
 
1241
  // Setup the From header
1242
- $headers[] = 'From: ' . get_bloginfo( 'name' ) . ' ' . $do_not_reply;
1243
-
1244
  // Get topic subscribers and bail if empty
1245
  $user_ids = bbp_get_forum_subscribers( $forum_id, true );
 
 
 
1246
  if ( empty( $user_ids ) ) {
1247
  return false;
1248
  }
@@ -1262,18 +1316,39 @@ Login and visit the topic to unsubscribe from these emails.', 'bbpress' ),
1262
  /** Send it ***************************************************************/
1263
 
1264
  // Custom headers
1265
- $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
 
1266
 
1267
  do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
1268
 
1269
  // Send notification email
1270
- wp_mail( $do_not_reply, $subject, $message, $headers );
1271
 
1272
  do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
1273
 
1274
  return true;
1275
  }
1276
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1277
  /** Login *********************************************************************/
1278
 
1279
  /**
981
 
982
  /** Subscriptions *************************************************************/
983
 
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
  /**
1012
  * Sends notification emails for new replies to subscribed topics
1013
  *
1019
  * that limit the number of addresses in a BCC field (often to around 500.) In
1020
  * those cases, we recommend unhooking this function and creating your own
1021
  * custom emailer script.
1022
+ *
1023
+ * @since bbPress (r5413)
1024
  *
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
+ *
1031
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
1032
  * @uses bbp_get_reply_id() To validate the reply ID
1033
  * @uses bbp_get_topic_id() To validate the topic ID
1052
  * topic id and user id
1053
  * @return bool True on success, false on failure
1054
  */
1055
+ function bbp_notify_topic_subscribers( $reply_id = 0, $topic_id = 0, $forum_id = 0, $anonymous_data = false, $reply_author = 0 ) {
1056
 
1057
  // Bail if subscriptions are turned off
1058
  if ( !bbp_is_subscriptions_active() ) {
1094
  $reply_content = strip_tags( bbp_get_reply_content( $reply_id ) );
1095
  $reply_url = bbp_get_reply_url( $reply_id );
1096
  $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
 
1097
 
1098
  // For plugins to filter messages per reply/topic/user
1099
  $message = sprintf( __( '%1$s wrote:
1126
 
1127
  /** Users *****************************************************************/
1128
 
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 );
1134
 
1135
  // Setup the From header
1136
+ $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
1137
+
1138
  // Get topic subscribers and bail if empty
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 );
1143
  if ( empty( $user_ids ) ) {
1144
  return false;
1145
  }
1159
  /** Send it ***************************************************************/
1160
 
1161
  // Custom headers
1162
+ $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
1163
+ $to_email = apply_filters( 'bbp_subscription_to_email', $no_reply );
1164
 
1165
  do_action( 'bbp_pre_notify_subscribers', $reply_id, $topic_id, $user_ids );
1166
 
1167
  // Send notification email
1168
+ wp_mail( $to_email, $subject, $message, $headers );
1169
 
1170
  do_action( 'bbp_post_notify_subscribers', $reply_id, $topic_id, $user_ids );
1171
 
1183
  * that limit the number of addresses in a BCC field (often to around 500.) In
1184
  * those cases, we recommend unhooking this function and creating your own
1185
  * custom emailer script.
1186
+ *
1187
  * @since bbPress (r5156)
1188
  *
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
+ *
1194
  * @uses bbp_is_subscriptions_active() To check if the subscriptions are active
1195
  * @uses bbp_get_topic_id() To validate the topic ID
1196
  * @uses bbp_get_forum_id() To validate the forum ID
1222
  $topic_id = bbp_get_topic_id( $topic_id );
1223
  $forum_id = bbp_get_forum_id( $forum_id );
1224
 
1225
+ /**
1226
+ * Necessary for backwards compatibility
1227
+ *
1228
+ * @see https://bbpress.trac.wordpress.org/ticket/2620
1229
+ */
1230
+ $user_id = 0;
1231
+
1232
  /** Topic *****************************************************************/
1233
 
1234
  // Bail if topic is not published
1251
  $topic_content = strip_tags( bbp_get_topic_content( $topic_id ) );
1252
  $topic_url = get_permalink( $topic_id );
1253
  $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
 
1254
 
1255
  // For plugins to filter messages per reply/topic/user
1256
  $message = sprintf( __( '%1$s wrote:
1283
 
1284
  /** User ******************************************************************/
1285
 
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 );
1291
 
1292
  // Setup the From header
1293
+ $headers = array( 'From: ' . get_bloginfo( 'name' ) . ' <' . $from_email . '>' );
1294
+
1295
  // Get topic subscribers and bail if empty
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 );
1300
  if ( empty( $user_ids ) ) {
1301
  return false;
1302
  }
1316
  /** Send it ***************************************************************/
1317
 
1318
  // Custom headers
1319
+ $headers = apply_filters( 'bbp_subscription_mail_headers', $headers );
1320
+ $to_email = apply_filters( 'bbp_subscription_to_email', $no_reply );
1321
 
1322
  do_action( 'bbp_pre_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
1323
 
1324
  // Send notification email
1325
+ wp_mail( $to_email, $subject, $message, $headers );
1326
 
1327
  do_action( 'bbp_post_notify_forum_subscribers', $topic_id, $forum_id, $user_ids );
1328
 
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 );
1350
+ }
1351
+
1352
  /** Login *********************************************************************/
1353
 
1354
  /**
includes/core/actions.php CHANGED
@@ -226,7 +226,7 @@ add_action( 'bbp_trash_topic', 'bbp_remove_topic_from_all_subscriptions'
226
  add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' );
227
  add_action( 'bbp_trash_forum', 'bbp_remove_forum_from_all_subscriptions' );
228
  add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions' );
229
- add_action( 'bbp_new_reply', 'bbp_notify_subscribers', 11, 5 );
230
  add_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 );
231
 
232
  // Sticky
226
  add_action( 'bbp_delete_topic', 'bbp_remove_topic_from_all_subscriptions' );
227
  add_action( 'bbp_trash_forum', 'bbp_remove_forum_from_all_subscriptions' );
228
  add_action( 'bbp_delete_forum', 'bbp_remove_forum_from_all_subscriptions' );
229
+ add_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 );
230
  add_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 );
231
 
232
  // Sticky
languages/bbpress.pot CHANGED
@@ -2,7 +2,7 @@
2
  # This file is distributed under the same license as the bbPress package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: bbPress 2.5.5\n"
6
  "Report-Msgid-Bugs-To: https://bbpress.trac.wordpress.org\n"
7
  "POT-Creation-Date: 2015-03-06 17:13:54+00:00\n"
8
  "MIME-Version: 1.0\n"
@@ -2670,7 +2670,7 @@ msgstr ""
2670
  msgid "<strong>ERROR</strong>: Invalid email address submitted!"
2671
  msgstr ""
2672
 
2673
- #: includes/common/functions.php:1068
2674
  msgid ""
2675
  "%1$s wrote:\n"
2676
  "\n"
@@ -2685,7 +2685,7 @@ msgid ""
2685
  "Login and visit the topic to unsubscribe from these emails."
2686
  msgstr ""
2687
 
2688
- #: includes/common/functions.php:1208
2689
  msgid ""
2690
  "%1$s wrote:\n"
2691
  "\n"
@@ -2700,7 +2700,7 @@ msgid ""
2700
  "Login and visit the topic to unsubscribe from these emails."
2701
  msgstr ""
2702
 
2703
- #: includes/common/functions.php:1949
2704
  msgid ""
2705
  "Conditional query tags do not work before the query is run. Before then, "
2706
  "they always return false."
@@ -4939,9 +4939,9 @@ msgstr ""
4939
  msgid "bbPress"
4940
  msgstr ""
4941
 
4942
- #. #-#-#-#-# plugin.pot (bbPress 2.5.5) #-#-#-#-#
4943
  #. Plugin URI of the plugin/theme
4944
- #. #-#-#-#-# plugin.pot (bbPress 2.5.5) #-#-#-#-#
4945
  #. Author URI of the plugin/theme
4946
  msgid "http://bbpress.org"
4947
  msgstr ""
2
  # This file is distributed under the same license as the bbPress package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: bbPress 2.5.6\n"
6
  "Report-Msgid-Bugs-To: https://bbpress.trac.wordpress.org\n"
7
  "POT-Creation-Date: 2015-03-06 17:13:54+00:00\n"
8
  "MIME-Version: 1.0\n"
2670
  msgid "<strong>ERROR</strong>: Invalid email address submitted!"
2671
  msgstr ""
2672
 
2673
+ #: includes/common/functions.php:1099
2674
  msgid ""
2675
  "%1$s wrote:\n"
2676
  "\n"
2685
  "Login and visit the topic to unsubscribe from these emails."
2686
  msgstr ""
2687
 
2688
+ #: includes/common/functions.php:1256
2689
  msgid ""
2690
  "%1$s wrote:\n"
2691
  "\n"
2700
  "Login and visit the topic to unsubscribe from these emails."
2701
  msgstr ""
2702
 
2703
+ #: includes/common/functions.php:2024
2704
  msgid ""
2705
  "Conditional query tags do not work before the query is run. Before then, "
2706
  "they always return false."
4939
  msgid "bbPress"
4940
  msgstr ""
4941
 
4942
+ #. #-#-#-#-# plugin.pot (bbPress 2.5.6) #-#-#-#-#
4943
  #. Plugin URI of the plugin/theme
4944
+ #. #-#-#-#-# plugin.pot (bbPress 2.5.6) #-#-#-#-#
4945
  #. Author URI of the plugin/theme
4946
  msgid "http://bbpress.org"
4947
  msgstr ""
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: matt, johnjamesjacoby, jmdodd, netweb
3
  Tags: forums, discussion, support, theme, akismet, multisite
4
  Requires at least: 3.6
5
  Tested up to: 4.1
6
- Stable tag: 2.5.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -42,6 +42,9 @@ We're keeping things as small and light as possible while still allowing for gre
42
 
43
  == Changelog ==
44
 
 
 
 
45
  = 2.5.5 =
46
  * Improved bulk editing of users
47
  * Improved suggesting of topics & authors for moderators
3
  Tags: forums, discussion, support, theme, akismet, multisite
4
  Requires at least: 3.6
5
  Tested up to: 4.1
6
+ Stable tag: 2.5.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
42
 
43
  == Changelog ==
44
 
45
+ = 2.5.6 =
46
+ * Improved notification & subscription email sending
47
+
48
  = 2.5.5 =
49
  * Improved bulk editing of users
50
  * Improved suggesting of topics & authors for moderators