Better Notifications for WordPress - Version 1.6.12

Version Description

  • 1st March 2018 =
  • New: Lots of new global user shortcodes! It's always been a bit difficult to explain how the user shortcodes changes between notifications - sometimes they're for the author of a post, sometimes they're the recipient user. Now, all user shortcodes are used solely for the author and a new set of global user shortcodes are available for the recipient. Full details are on the Shortcodes documentation page.
  • Added: Preliminary changes for the upcoming Multisite add-on.
Download this release

Release Info

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

Code changes from version 1.6.11 to 1.6.12

Files changed (4) hide show
  1. README.txt +16 -10
  2. assets/js/bnfw.js +17 -2
  3. bnfw.php +1 -1
  4. includes/engine/class-bnfw-engine.php +18 -14
README.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: voltronik
3
  Donate link: https://betternotificationsforwp.com/donate/
4
  Tags: notification, email, push, sms, alert, HTML, customize, bulk, trigger, CC, BCC
5
- Requires at least: 3.5
6
  Tested up to: 4.9.4
7
  Requires PHP: 5.6
8
- Stable tag: 1.6.11
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -38,29 +38,28 @@ Power-up your notifications using add-ons:
38
 
39
  [Profile Builder](https://betternotificationsforwp.com/downloads/profile-builder/) - Adds compatibility and new notifications and shortcodes for Profile Builder Free, Hobbyist, and Pro plugins to Better Notifications for WordPress.
40
 
 
 
41
  ...and more coming soon!
42
 
43
  = Notifications =
44
  The notifications that are currently available to use are:
45
 
46
- **WordPress Defaults**
47
 
48
- * New Comment / Comment Awaiting Moderation
49
- * New Trackback
50
- * New Pingback
51
- * User Lost Password - For Admin
52
  * New User Registration - For Admin
 
53
  * Password Changed - For Admin
54
  * User Role Changed - For Admin
55
  * WordPress Core Automatic Background Updates
56
 
57
  **Transactional**
58
 
 
 
59
  * User Lost Password - For User
60
  * Password Changed - For User
61
  * User Email Changed - For Admin
62
- * New User Registration - For User
63
- * New User - Post-registration Email
64
  * User Role Changed - For User
65
  * Comment Reply
66
  * Profile Builder – Approval Request for Admin ([Profile Builder Add-on](https://betternotificationsforwp.com/downloads/profile-builder/))
@@ -76,8 +75,11 @@ The notifications that are currently available to use are:
76
  * Post Pending Review
77
  * New Private Post
78
  * Post Scheduled
 
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
 
82
  **Pages**
83
 
@@ -144,7 +146,7 @@ The possibilities are endless!
144
 
145
  Yes! There is an option for suppressing comments marked as SPAM in the plugin settings.
146
 
147
- = Does this plugin work with Multisite? =
148
 
149
  Yes and no - some notifications work, others don't, and some are missing entirely. I do plan on adding full Multisite support at a later date however, this will be in the form of an add-on.
150
 
@@ -198,6 +200,10 @@ An older version might work but this is untested. A lot of the newer features re
198
 
199
  == Changelog ==
200
 
 
 
 
 
201
  = 1.6.11 - 13th February 2018 =
202
  * Fixed: Update Reminder and Custom Field Updated notifications weren't showing for custom post types.
203
 
2
  Contributors: voltronik
3
  Donate link: https://betternotificationsforwp.com/donate/
4
  Tags: notification, email, push, sms, alert, HTML, customize, bulk, trigger, CC, BCC
5
+ Requires at least: 4.0
6
  Tested up to: 4.9.4
7
  Requires PHP: 5.6
8
+ Stable tag: 1.6.12
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
38
 
39
  [Profile Builder](https://betternotificationsforwp.com/downloads/profile-builder/) - Adds compatibility and new notifications and shortcodes for Profile Builder Free, Hobbyist, and Pro plugins to Better Notifications for WordPress.
40
 
41
+ [Multisite](https://betternotificationsforwp.com/downloads/multisite/) - Adds compatibility and new notifications and shortcodes for WordPress Multisite to Better Notifications for WordPress (Coming Soon).
42
+
43
  ...and more coming soon!
44
 
45
  = Notifications =
46
  The notifications that are currently available to use are:
47
 
48
+ **Admin**
49
 
 
 
 
 
50
  * New User Registration - For Admin
51
+ * User Lost Password - For Admin
52
  * Password Changed - For Admin
53
  * User Role Changed - For Admin
54
  * WordPress Core Automatic Background Updates
55
 
56
  **Transactional**
57
 
58
+ * New User Registration - For User
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/))
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
82
+ * New Pingback
83
 
84
  **Pages**
85
 
146
 
147
  Yes! There is an option for suppressing comments marked as SPAM in the plugin settings.
148
 
149
+ = Does this plugin and the add-ons work with Multisite? =
150
 
151
  Yes and no - some notifications work, others don't, and some are missing entirely. I do plan on adding full Multisite support at a later date however, this will be in the form of an add-on.
152
 
200
 
201
  == Changelog ==
202
 
203
+ = 1.6.12 - 1st March 2018 =
204
+ * New: Lots of new global user shortcodes! It's always been a bit difficult to explain how the user shortcodes changes between notifications - sometimes they're for the author of a post, sometimes they're the recipient user. Now, all user shortcodes are used solely for the author and a new set of global user shortcodes are available for the recipient. Full details are on the [Shortcodes](https://betternotificationsforwp.com/documentation/notifications/shortcodes/) documentation page.
205
+ * Added: Preliminary changes for the upcoming [Multisite](https://betternotificationsforwp.com/downloads/multisite/) add-on.
206
+
207
  = 1.6.11 - 13th February 2018 =
208
  * Fixed: Update Reminder and Custom Field Updated notifications weren't showing for custom post types.
209
 
assets/js/bnfw.js CHANGED
@@ -57,7 +57,9 @@ jQuery(document).ready(function($) {
57
 
58
  if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
59
  'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
60
- 'password-changed' === notification || 'email-changed' === notification || 'user-role' === notification ) {
 
 
61
 
62
  $('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
63
  $('#user-password-msg, #disable-autop, #email-formatting').show();
@@ -103,7 +105,9 @@ jQuery(document).ready(function($) {
103
 
104
  if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
105
  'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
106
- 'password-changed' === notification || 'email-changed' === notification || 'user-role' === notification ) {
 
 
107
 
108
  $('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
109
  $('#user-password-msg, #disable-autop, #email-formatting').show();
@@ -305,6 +309,17 @@ jQuery(document).ready(function($) {
305
  'To set your password, visit the following address: [password_url]';
306
 
307
  break;
 
 
 
 
 
 
 
 
 
 
 
308
  default:
309
  alert( "This is a new notification that is not available in WordPress by default and has been added by Better Notifications for WordPress. As such, it doesn't have any default content." );
310
  break;
57
 
58
  if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
59
  'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
60
+ 'password-changed' === notification || 'email-changed' === notification || 'user-role' === notification ||
61
+ 'multisite-new-user-invited' === notification || 'multisite-new-user-created' === notification || 'multisite-new-user-welcome' === notification ||
62
+ 'multisite-site-registered' === notification || 'multisite-site-created' === notification || 'multisite-site-welcome' === notification || 'multisite-site-deleted' === notification ) {
63
 
64
  $('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
65
  $('#user-password-msg, #disable-autop, #email-formatting').show();
105
 
106
  if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
107
  'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
108
+ 'password-changed' === notification || 'email-changed' === notification || 'user-role' === notification ||
109
+ 'multisite-new-user-invited' === notification || 'multisite-new-user-created' === notification || 'multisite-new-user-welcome' === notification ||
110
+ 'multisite-site-registered' === notification || 'multisite-site-created' === notification || 'multisite-site-welcome' === notification || 'multisite-site-deleted' === notification ) {
111
 
112
  $('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
113
  $('#user-password-msg, #disable-autop, #email-formatting').show();
309
  'To set your password, visit the following address: [password_url]';
310
 
311
  break;
312
+
313
+ case 'multisite-new-user-invited':
314
+ subject = '[[network_name] Activate [user_login]';
315
+ body = 'To activate your user, please click the following link:' +
316
+ '<br>' +
317
+ '[activation_link]' +
318
+ '<br>' +
319
+ 'After you activate, you will receive *another email* with your login.';
320
+
321
+ break;
322
+
323
  default:
324
  alert( "This is a new notification that is not available in WordPress by default and has been added by Better Notifications for WordPress. As such, it doesn't have any default content." );
325
  break;
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.6.11
7
  * Author: Made with Fuel
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: hello@betternotificationsforwp.com
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.6.12
7
  * Author: Made with Fuel
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: hello@betternotificationsforwp.com
includes/engine/class-bnfw-engine.php CHANGED
@@ -475,6 +475,8 @@ class BNFW_Engine {
475
  $message = str_replace( '[global_user_firstname]', $user->first_name, $message );
476
  $message = str_replace( '[global_user_lastname]', $user->last_name, $message );
477
  $message = str_replace( '[global_user_username]', $user->user_login, $message );
 
 
478
  }
479
 
480
  $message = str_replace( '[global_user_email]', $email, $message );
@@ -623,7 +625,7 @@ class BNFW_Engine {
623
  *
624
  * @return string Processed string.
625
  */
626
- public function user_shortcodes( $message, $user_id ) {
627
  $user_info = get_userdata( $user_id );
628
 
629
  if ( ! $user_info instanceof WP_User ) {
@@ -632,28 +634,30 @@ class BNFW_Engine {
632
 
633
  // deperecated
634
  $message = str_replace( '[ID]', $user_info->ID, $message );
635
-
636
- $message = str_replace( '[user_id]', $user_info->ID, $message );
637
- $message = str_replace( '[user_login]', $user_info->user_login, $message );
638
- $message = str_replace( '[user_nicename]', $user_info->user_nicename, $message );
639
- $message = str_replace( '[user_email]', $user_info->user_email, $message );
640
- $message = str_replace( '[user_url]', $user_info->user_url, $message );
641
- $message = str_replace( '[user_registered]', $user_info->user_registered, $message );
642
  $message = str_replace( '[display_name]', $user_info->display_name, $message );
643
- $message = str_replace( '[user_firstname]', $user_info->user_firstname, $message );
644
- $message = str_replace( '[user_lastname]', $user_info->user_lastname, $message );
645
  $message = str_replace( '[nickname]', $user_info->nickname, $message );
646
- $message = str_replace( '[user_description]', $user_info->user_description, $message );
647
- $message = str_replace( '[user_avatar]', get_avatar_url( $user_id ), $message );
648
- $message = str_replace( '[user_avatar]', get_avatar_url( $user_id ), $message );
649
  $message = str_replace( '[commenter_avatar]', get_avatar_url( $user_id ), $message );
650
 
 
 
 
 
 
 
 
 
 
 
 
 
 
651
  $user_capabilities = bnfw_format_user_capabilities( $user_info->wp_capabilities );
652
  if ( ! empty( $user_capabilities ) ) {
653
  $message = str_replace( '[wp_capabilities]', $user_capabilities, $message );
 
654
  }
655
 
656
- $message = apply_filters( 'bnfw_shortcodes_user', $message, $user_id );
657
  return $message;
658
  }
659
 
475
  $message = str_replace( '[global_user_firstname]', $user->first_name, $message );
476
  $message = str_replace( '[global_user_lastname]', $user->last_name, $message );
477
  $message = str_replace( '[global_user_username]', $user->user_login, $message );
478
+
479
+ $message = $this->user_shortcodes( $message, $user->ID, 'email_' );
480
  }
481
 
482
  $message = str_replace( '[global_user_email]', $email, $message );
625
  *
626
  * @return string Processed string.
627
  */
628
+ public function user_shortcodes( $message, $user_id, $prefix = '' ) {
629
  $user_info = get_userdata( $user_id );
630
 
631
  if ( ! $user_info instanceof WP_User ) {
634
 
635
  // deperecated
636
  $message = str_replace( '[ID]', $user_info->ID, $message );
 
 
 
 
 
 
 
637
  $message = str_replace( '[display_name]', $user_info->display_name, $message );
 
 
638
  $message = str_replace( '[nickname]', $user_info->nickname, $message );
 
 
 
639
  $message = str_replace( '[commenter_avatar]', get_avatar_url( $user_id ), $message );
640
 
641
+ $message = str_replace( '[' . $prefix . 'user_id]', $user_info->ID, $message );
642
+ $message = str_replace( '[' . $prefix . 'user_login]', $user_info->user_login, $message );
643
+ $message = str_replace( '[' . $prefix . 'user_nicename]', $user_info->user_nicename, $message );
644
+ $message = str_replace( '[' . $prefix . 'user_email]', $user_info->user_email, $message );
645
+ $message = str_replace( '[' . $prefix . 'user_url]', $user_info->user_url, $message );
646
+ $message = str_replace( '[' . $prefix . 'user_registered]', $user_info->user_registered, $message );
647
+ $message = str_replace( '[' . $prefix . 'user_display_name]', $user_info->display_name, $message );
648
+ $message = str_replace( '[' . $prefix . 'user_firstname]', $user_info->user_firstname, $message );
649
+ $message = str_replace( '[' . $prefix . 'user_lastname]', $user_info->user_lastname, $message );
650
+ $message = str_replace( '[' . $prefix . 'user_nickname]', $user_info->nickname, $message );
651
+ $message = str_replace( '[' . $prefix . 'user_description]', $user_info->user_description, $message );
652
+ $message = str_replace( '[' . $prefix . 'user_avatar]', get_avatar_url( $user_id ), $message );
653
+
654
  $user_capabilities = bnfw_format_user_capabilities( $user_info->wp_capabilities );
655
  if ( ! empty( $user_capabilities ) ) {
656
  $message = str_replace( '[wp_capabilities]', $user_capabilities, $message );
657
+ $message = str_replace( '[' . $prefix . 'user_wp_capabilities]', $user_capabilities, $message );
658
  }
659
 
660
+ $message = apply_filters( 'bnfw_shortcodes_user', $message, $user_id, $prefix );
661
  return $message;
662
  }
663