Better Notifications for WordPress - Version 1.7.1

Version Description

  • 5th November 2018 =
  • New: Full support for the new Subscriptions (GDPR Compliancy) add-on.
  • Fixed: Comments marked as SPAM were triggering the 'New Comment Awaiting Moderation' notification.
  • Fixed: An issue relating to the 'New Comment Awaiting Moderation' notification not saving when used in conjunction with the Send To Any Email and Custom Fields add-ons.
  • Fixed: A couple of minor javascript errors relating to BNFW add-ons.
Download this release

Release Info

Developer voltronik
Plugin Icon 128x128 Better Notifications for WordPress
Version 1.7.1
Comparing to
See all releases

Code changes from version 1.7 to 1.7.1

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: notification, email, push, sms, alert, HTML, customize, bulk, trigger, CC,
5
  Requires at least: 4.0
6
  Tested up to: 4.9.8
7
  Requires PHP: 5.6
8
- Stable tag: 1.7
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -26,6 +26,8 @@ You want all the users in the Editor role to be notified via email when a new po
26
  = Premium Add-ons =
27
  Power-up your notifications using add-ons:
28
 
 
 
29
  [Conditional Notifications](https://betternotificationsforwp.com/downloads/conditional-notifications/) - Limit certain notifications depending on which categories, tags, post formats, or terms you choose.
30
 
31
  [Custom Fields](https://betternotificationsforwp.com/downloads/custom-fields/) - Provides a number of new shortcodes allowing you to include data from custom fields and custom user fields created using [ACF](https://wordpress.org/plugins/advanced-custom-fields/).
@@ -52,6 +54,8 @@ The notifications that are currently available to use are:
52
  * Password Changed - For Admin
53
  * User Role Changed - For Admin
54
  * WordPress Core Automatic Background Updates
 
 
55
 
56
  **Transactional**
57
 
@@ -59,9 +63,13 @@ The notifications that are currently available to use are:
59
  * New User - Post-registration Email
60
  * User Lost Password - For User
61
  * Password Changed - For User
62
- * User Email Changed - For Admin
63
  * User Role Changed - For User
64
  * Comment Reply
 
 
 
 
65
  * Profile Builder – Approval Request for Admin ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
66
  * Profile Builder – Email Confirmation ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
67
  * Profile Builder – Account Approved ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
@@ -75,7 +83,8 @@ The notifications that are currently available to use are:
75
  * Post Pending Review
76
  * New Private Post
77
  * Post Scheduled
78
- * New Comment / Comment Awaiting Moderation
 
79
  * Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
80
  * Post - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
81
  * New Trackback
@@ -89,6 +98,7 @@ The notifications that are currently available to use are:
89
  * New Private Page
90
  * Page Scheduled
91
  * Page - New Comment
 
92
  * Page - Comment Reply
93
  * Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
94
  * Page - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
@@ -199,6 +209,12 @@ Yes, of course! The plugin is completely translation-friendly and if you send me
199
 
200
  == Changelog ==
201
 
 
 
 
 
 
 
202
  = 1.7 - 5th September 2018 =
203
  * A huge update packed full of new features and bug fixes, especially for those that like privacy and comment notifications!
204
  * New: Six GDPR / Privacy Notifications. These allow you to override all the new notifications that WordPress 4.9.6 introduced relating to exporting and erasing user data. These are: Privacy – Confirm Action: Export Data Request – For User, Privacy – Confirm Action: Erase Data Request – For User, Privacy – Data Export – For User, Privacy – Data Erased – For User, Privacy – Confirm Action: Export Data Request – For Admin, Privacy – Confirm Action: Erase Data Request – For Admin.
@@ -332,7 +348,7 @@ Fixed: When a 'Lost Password – For User' notification had been set-up but disa
332
  * New: Notifications for privately published posts / pages / custom post types.
333
  * New: Notification and accompanying shortcode for customising WordPress Core Automatic Background Updates (Success / Fail / Critical).
334
  * New: Notification for User Password Changed.
335
- * New: Notification for User Email Changed - For Admin.
336
  * New: Shortcodes for showing the old and new user role when used in conjunction with the User Role Changed notifications.
337
  * New: You can now add a 'Reply To' name and email address in the Additional Email Fields for all notifications that support it.
338
  * New: You can now prevent yourself from receiving notifications of comments or replies to comments on one of your posts by combining the two checkboxes 'Send this notification to the Author only' and 'Do not send this Notification to the User that triggered it'.
5
  Requires at least: 4.0
6
  Tested up to: 4.9.8
7
  Requires PHP: 5.6
8
+ Stable tag: 1.7.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
26
  = Premium Add-ons =
27
  Power-up your notifications using add-ons:
28
 
29
+ [Subscriptions (GDPR Compliancy)](https://betternotificationsforwp.com/downloads/subscriptions-gdpr/) - Allow users to manage their subscriptions for BNFW notifications.
30
+
31
  [Conditional Notifications](https://betternotificationsforwp.com/downloads/conditional-notifications/) - Limit certain notifications depending on which categories, tags, post formats, or terms you choose.
32
 
33
  [Custom Fields](https://betternotificationsforwp.com/downloads/custom-fields/) - Provides a number of new shortcodes allowing you to include data from custom fields and custom user fields created using [ACF](https://wordpress.org/plugins/advanced-custom-fields/).
54
  * Password Changed - For Admin
55
  * User Role Changed - For Admin
56
  * WordPress Core Automatic Background Updates
57
+ * Privacy – Confirm Action: Export Data Request – For Admin
58
+ * Privacy – Confirm Action: Erase Data Request – For Admin
59
 
60
  **Transactional**
61
 
63
  * New User - Post-registration Email
64
  * User Lost Password - For User
65
  * Password Changed - For User
66
+ * User Email Changed - For User
67
  * User Role Changed - For User
68
  * Comment Reply
69
+ * Privacy – Confirm Action: Export Data Request – For User
70
+ * Privacy – Confirm Action: Erase Data Request – For User
71
+ * Privacy – Data Export – For User
72
+ * Privacy – Data Erased – For User
73
  * Profile Builder – Approval Request for Admin ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
74
  * Profile Builder – Email Confirmation ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
75
  * Profile Builder – Account Approved ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
83
  * Post Pending Review
84
  * New Private Post
85
  * Post Scheduled
86
+ * New Comment
87
+ * New Comment Awaiting Moderation
88
  * Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
89
  * Post - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
90
  * New Trackback
98
  * New Private Page
99
  * Page Scheduled
100
  * Page - New Comment
101
+ * Page - New Comment Awaiting Moderation
102
  * Page - Comment Reply
103
  * Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
104
  * Page - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
209
 
210
  == Changelog ==
211
 
212
+ = 1.7.1 - 5th November 2018 =
213
+ * New: Full support for the new [Subscriptions (GDPR Compliancy)](https://betternotificationsforwp.com/downloads/subscriptions-gdpr/) add-on.
214
+ * Fixed: Comments marked as SPAM were triggering the 'New Comment Awaiting Moderation' notification.
215
+ * Fixed: An issue relating to the 'New Comment Awaiting Moderation' notification not saving when used in conjunction with the Send To Any Email and Custom Fields add-ons.
216
+ * Fixed: A couple of minor javascript errors relating to BNFW add-ons.
217
+
218
  = 1.7 - 5th September 2018 =
219
  * A huge update packed full of new features and bug fixes, especially for those that like privacy and comment notifications!
220
  * New: Six GDPR / Privacy Notifications. These allow you to override all the new notifications that WordPress 4.9.6 introduced relating to exporting and erasing user data. These are: Privacy – Confirm Action: Export Data Request – For User, Privacy – Confirm Action: Erase Data Request – For User, Privacy – Data Export – For User, Privacy – Data Erased – For User, Privacy – Confirm Action: Export Data Request – For Admin, Privacy – Confirm Action: Erase Data Request – For Admin.
348
  * New: Notifications for privately published posts / pages / custom post types.
349
  * New: Notification and accompanying shortcode for customising WordPress Core Automatic Background Updates (Success / Fail / Critical).
350
  * New: Notification for User Password Changed.
351
+ * New: Notification for User Email Changed - For User.
352
  * New: Shortcodes for showing the old and new user role when used in conjunction with the User Role Changed notifications.
353
  * New: You can now add a 'Reply To' name and email address in the Additional Email Fields for all notifications that support it.
354
  * New: You can now prevent yourself from receiving notifications of comments or replies to comments on one of your posts by combining the two checkboxes 'Send this notification to the Author only' and 'Do not send this Notification to the User that triggered it'.
assets/js/bnfw.js CHANGED
@@ -197,6 +197,8 @@ jQuery(document).ready(function($) {
197
 
198
  switch( notification ) {
199
  case 'new-comment':
 
 
200
  case 'new-trackback':
201
  case 'new-pingback':
202
  case 'reply-comment':
@@ -225,15 +227,25 @@ jQuery(document).ready(function($) {
225
  splited = notification.split( '-' );
226
  switch( splited[0] ) {
227
  case 'new':
 
 
228
  case 'update':
 
 
229
  case 'pending':
 
 
230
  case 'private':
 
 
231
  case 'future':
 
 
232
  case 'comment':
233
- notification_slug = splited[0] + '-comment';
234
  break;
235
  case 'moderate':
236
- notification_slug = splited[0] + 'moderate-comment';
237
  break;
238
  case 'commentreply':
239
  notification_slug = splited[0] + '-post';
197
 
198
  switch( notification ) {
199
  case 'new-comment':
200
+ case 'moderate-comment':
201
+ case 'moderate-post-comment':
202
  case 'new-trackback':
203
  case 'new-pingback':
204
  case 'reply-comment':
227
  splited = notification.split( '-' );
228
  switch( splited[0] ) {
229
  case 'new':
230
+ notification_slug = 'new-post';
231
+ break;
232
  case 'update':
233
+ notification_slug = 'update-post';
234
+ break;
235
  case 'pending':
236
+ notification_slug = 'pending-post';
237
+ break;
238
  case 'private':
239
+ notification_slug = 'private-post';
240
+ break;
241
  case 'future':
242
+ notification_slug = 'future-post';
243
+ break;
244
  case 'comment':
245
+ notification_slug = 'new-comment';
246
  break;
247
  case 'moderate':
248
+ notification_slug = 'moderate-comment';
249
  break;
250
  case 'commentreply':
251
  notification_slug = splited[0] + '-post';
bnfw.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: https://wordpress.org/plugins/bnfw/
5
  * Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
6
- * Version: 1.7
7
  * Author: Made with Fuel
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: hello@betternotificationsforwp.com
@@ -401,15 +401,19 @@ class BNFW {
401
  $post = get_post( $the_comment->comment_post_ID );
402
 
403
  if ( '1' !== $the_comment->comment_approved ) {
404
- $notification_type = 'moderate-' . $post->post_type . '-comment';
 
 
 
405
  } else {
406
  $notification_type = 'new-comment'; // old notification name
 
407
  if ( 'post' != $post->post_type ) {
408
  $notification_type = 'comment-' . $post->post_type;
409
  }
410
- }
411
 
412
- $this->send_notification( $notification_type, $comment_id );
 
413
 
414
  // comment reply notification.
415
  if ( $this->can_send_comment_notification( $the_comment ) ) {
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: https://wordpress.org/plugins/bnfw/
5
  * Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
6
+ * Version: 1.7.1
7
  * Author: Made with Fuel
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: hello@betternotificationsforwp.com
401
  $post = get_post( $the_comment->comment_post_ID );
402
 
403
  if ( '1' !== $the_comment->comment_approved ) {
404
+ if ( $this->can_send_comment_notification( $the_comment ) ) {
405
+ $notification_type = 'moderate-' . $post->post_type . '-comment';
406
+ $this->send_notification( $notification_type, $comment_id );
407
+ }
408
  } else {
409
  $notification_type = 'new-comment'; // old notification name
410
+
411
  if ( 'post' != $post->post_type ) {
412
  $notification_type = 'comment-' . $post->post_type;
413
  }
 
414
 
415
+ $this->send_notification( $notification_type, $comment_id );
416
+ }
417
 
418
  // comment reply notification.
419
  if ( $this->can_send_comment_notification( $the_comment ) ) {
includes/admin/class-bnfw-notification.php CHANGED
@@ -938,30 +938,37 @@ foreach ( $taxs as $tax ) {
938
  *
939
  * @return array WP_Post objects
940
  */
941
- public function get_notifications( $types, $exclude_disabled = true ) {
942
  if ( ! is_array( $types ) ) {
943
  $types = array( $types );
944
  }
945
 
946
  $args = array(
947
- 'post_type' => self::POST_TYPE,
948
- 'meta_query' => array(
949
- array(
950
- 'key' => self::META_KEY_PREFIX . 'notification',
951
- 'value' => $types,
952
- 'compare' => 'IN',
953
- ),
954
- ),
955
  );
956
 
 
 
 
 
 
 
 
 
 
 
957
  if ( $exclude_disabled ) {
958
- $args['meta_query'][] = array(
959
  'key' => self::META_KEY_PREFIX . 'disabled',
960
  'value' => 'true',
961
  'compare' => '!=',
962
  );
963
  }
964
 
 
 
 
 
965
  $args['posts_per_page'] = -1;
966
  $args['nopagging'] = true;
967
 
938
  *
939
  * @return array WP_Post objects
940
  */
941
+ public function get_notifications( $types = array(), $exclude_disabled = true ) {
942
  if ( ! is_array( $types ) ) {
943
  $types = array( $types );
944
  }
945
 
946
  $args = array(
947
+ 'post_type' => self::POST_TYPE,
 
 
 
 
 
 
 
948
  );
949
 
950
+ $meta_query = array();
951
+
952
+ if ( ! empty( $types ) ) {
953
+ $meta_query[] = array(
954
+ 'key' => self::META_KEY_PREFIX . 'notification',
955
+ 'value' => $types,
956
+ 'compare' => 'IN',
957
+ );
958
+ }
959
+
960
  if ( $exclude_disabled ) {
961
+ $meta_query[] = array(
962
  'key' => self::META_KEY_PREFIX . 'disabled',
963
  'value' => 'true',
964
  'compare' => '!=',
965
  );
966
  }
967
 
968
+ if ( ! empty( $meta_query ) ) {
969
+ $args['meta_query'] = $meta_query;
970
+ }
971
+
972
  $args['posts_per_page'] = -1;
973
  $args['nopagging'] = true;
974
 
includes/engine/class-bnfw-engine.php CHANGED
@@ -66,6 +66,8 @@ class BNFW_Engine {
66
  $headers[] = 'Content-type: text/plain';
67
  }
68
 
 
 
69
  if ( isset( $emails['to'] ) && is_array( $emails['to'] ) ) {
70
  foreach ( $emails['to'] as $email ) {
71
  wp_mail( $email, stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ), $this->handle_global_user_shortcodes( $message, $email ), $headers );
@@ -824,11 +826,14 @@ class BNFW_Engine {
824
  * Get the list of emails from the notification settings.
825
  *
826
  * @since 1.0
 
827
  * @param array $setting Notification settings
828
- * @param int $id
 
 
829
  * @return array Emails
830
  */
831
- public function get_emails( $setting, $id ) {
832
  global $current_user;
833
 
834
  $emails = array();
@@ -851,9 +856,9 @@ class BNFW_Engine {
851
  */
852
  $emails['to'] = apply_filters( 'bnfw_to_emails', $to_emails, $setting, $id );
853
 
854
- if ( 'true' === $setting['only-post-author'] ) {
855
-
856
  $post_id = $id;
 
857
  if ( bnfw_is_comment_notification( $setting['notification'] ) ) {
858
  $comment = get_comment( $id );
859
  $post_id = $comment->comment_post_ID;
@@ -955,7 +960,7 @@ class BNFW_Engine {
955
  $emails_from_user_roles = $this->get_emails_from_role( $user_roles, $exclude );
956
 
957
  if ( ! empty( $setting ) ) {
958
- if ( $this->starts_with( $setting['notification'], 'comment-' ) ) {
959
  // for new comment notifications, we need to use post id instead of comment id.
960
  $post_id = bnfw_get_post_id_from_comment( $post_id );
961
  }
66
  $headers[] = 'Content-type: text/plain';
67
  }
68
 
69
+ $emails = apply_filters( 'bnfw_emails', $emails, $setting );
70
+
71
  if ( isset( $emails['to'] ) && is_array( $emails['to'] ) ) {
72
  foreach ( $emails['to'] as $email ) {
73
  wp_mail( $email, stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ), $this->handle_global_user_shortcodes( $message, $email ), $headers );
826
  * Get the list of emails from the notification settings.
827
  *
828
  * @since 1.0
829
+ *
830
  * @param array $setting Notification settings
831
+ * @param int $id
832
+ * @param bool $process_post_authors
833
+ *
834
  * @return array Emails
835
  */
836
+ public function get_emails( $setting, $id, $process_post_authors = true ) {
837
  global $current_user;
838
 
839
  $emails = array();
856
  */
857
  $emails['to'] = apply_filters( 'bnfw_to_emails', $to_emails, $setting, $id );
858
 
859
+ if ( $process_post_authors && 'true' === $setting['only-post-author'] ) {
 
860
  $post_id = $id;
861
+
862
  if ( bnfw_is_comment_notification( $setting['notification'] ) ) {
863
  $comment = get_comment( $id );
864
  $post_id = $comment->comment_post_ID;
960
  $emails_from_user_roles = $this->get_emails_from_role( $user_roles, $exclude );
961
 
962
  if ( ! empty( $setting ) ) {
963
+ if ( $this->starts_with( $setting['notification'], 'comment-' ) || $this->starts_with( $setting['notification'], 'moderate-' ) ) {
964
  // for new comment notifications, we need to use post id instead of comment id.
965
  $post_id = bnfw_get_post_id_from_comment( $post_id );
966
  }