Version Description
- 25th July 2016 =
- New: Global Site Shortcodes! Include these in any notification to output the site title (
[global_site_title]
), site tagline ([global_site_tagline]
), or site URL ([global_site_URL]
). - New: Global User Shortcodes! Include these in any notification to output the user's first name (
[global_user_firstname]
), user's last name ([global_user_lastname]
), or user's email address ([global_user_email]
). - New: The 'User Role Changed' notification has been split into two transactional notifications - one that can be sent to users and one that can be sent to admins.
- New: Shortcode
[featured_image]
. Outputs the URL for the featured image (if one is available). - New: Shortcode
[user_avatar]
. Outputs the User's avatar when used in a capable notification. - New: Shortcode
[commenter_avatar]
. Outputs the comment author's avatar for comment-based notifications. - Improved: 'Comment Reply' notifications are now available to use for Pages and Custom Post Types.
- Improved: When sending notifications to user roles in the 'To' field, it will now show how many users are in that role.
- Improved: The 'Lost Password - For User', 'User Role Changed - For Admin', and 'User Role Changed - For User' notifications now have the option to 'Stop additional paragraph and line break HTML from being inserted into my notifications' via the checkbox below the WYSIWYG editor on the Add New / Edit Notification screen.
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.5 |
Comparing to | |
See all releases |
Code changes from version 1.4.1 to 1.5
- README.txt +19 -4
- assets/js/bnfw.js +13 -8
- bnfw.php +9 -3
- includes/admin/class-bnfw-notification.php +33 -24
- includes/engine/class-bnfw-engine.php +66 -5
- includes/helpers/ajax-helpers.php +7 -1
- includes/helpers/helpers.php +7 -3
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: voltronik
|
|
3 |
Donate link: https://betternotificationsforwp.com/donate/
|
4 |
Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from, author
|
5 |
Requires at least: 3.5
|
6 |
-
Tested up to: 4.5.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -40,7 +40,8 @@ Notifications that are currently available to use are:
|
|
40 |
* Lost Password - For User
|
41 |
* New User Registration - For User
|
42 |
* New User - Post-registration Email
|
43 |
-
* User Role Changed
|
|
|
44 |
* Comment Reply
|
45 |
|
46 |
**Posts / Custom Post Types**
|
@@ -50,6 +51,7 @@ Notifications that are currently available to use are:
|
|
50 |
* Post Pending Review
|
51 |
* Post Scheduled
|
52 |
* Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
|
|
53 |
|
54 |
**Pages**
|
55 |
|
@@ -58,7 +60,9 @@ Notifications that are currently available to use are:
|
|
58 |
* Page Pending Review
|
59 |
* Page Scheduled
|
60 |
* Page - New Comment
|
|
|
61 |
* Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
|
|
62 |
|
63 |
**Posts**
|
64 |
|
@@ -154,7 +158,7 @@ This is most likely because it's `public` setting is set to `false`. Try changin
|
|
154 |
|
155 |
= Can I translate this plugin? =
|
156 |
|
157 |
-
Yes, of course! The plugin is completely translation-friendly and if you send me your .po file, I'll make sure to include it in the plugin and credit you
|
158 |
|
159 |
= Will this plugin work with versions of WordPress less than 3.5? =
|
160 |
|
@@ -174,6 +178,17 @@ An older version might work but this is untested. A lot of the newer features re
|
|
174 |
|
175 |
== Changelog ==
|
176 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
= 1.4.1 - 3rd June 2016 =
|
178 |
* Fixed: Multiple emails were being sent for a single notification for a small number of users. After lots of hunting and lots of testing, I'm hoping this should now be fixed.
|
179 |
* Fixed: The 'User Role Changed' notification was broken after the update to WordPress 4.5.
|
3 |
Donate link: https://betternotificationsforwp.com/donate/
|
4 |
Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from, author
|
5 |
Requires at least: 3.5
|
6 |
+
Tested up to: 4.5.3
|
7 |
+
Stable tag: 1.5
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
40 |
* Lost Password - For User
|
41 |
* New User Registration - For User
|
42 |
* New User - Post-registration Email
|
43 |
+
* User Role Changed - For Admin
|
44 |
+
* User Role Changed - For User
|
45 |
* Comment Reply
|
46 |
|
47 |
**Posts / Custom Post Types**
|
51 |
* Post Pending Review
|
52 |
* Post Scheduled
|
53 |
* Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
54 |
+
* Post - Update Reminder ([Update Reminder Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
55 |
|
56 |
**Pages**
|
57 |
|
60 |
* Page Pending Review
|
61 |
* Page Scheduled
|
62 |
* Page - New Comment
|
63 |
+
* Page - Comment Reply
|
64 |
* Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
65 |
+
* Page - Update Reminder ([Update Reminder Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
66 |
|
67 |
**Posts**
|
68 |
|
158 |
|
159 |
= Can I translate this plugin? =
|
160 |
|
161 |
+
Yes, of course! The plugin is completely translation-friendly and if you send me your .po file, I'll make sure to include it in the plugin and credit you in the changelog.
|
162 |
|
163 |
= Will this plugin work with versions of WordPress less than 3.5? =
|
164 |
|
178 |
|
179 |
== Changelog ==
|
180 |
|
181 |
+
= 1.5 - 25th July 2016 =
|
182 |
+
* New: Global Site Shortcodes! Include these in any notification to output the site title (`[global_site_title]`), site tagline (`[global_site_tagline]`), or site URL (`[global_site_URL]`).
|
183 |
+
* New: Global User Shortcodes! Include these in any notification to output the user's first name (`[global_user_firstname]`), user's last name (`[global_user_lastname]`), or user's email address (`[global_user_email]`).
|
184 |
+
* New: The 'User Role Changed' notification has been split into two transactional notifications - one that can be sent to users and one that can be sent to admins.
|
185 |
+
* New: Shortcode `[featured_image]`. Outputs the URL for the featured image (if one is available).
|
186 |
+
* New: Shortcode `[user_avatar]`. Outputs the User's avatar when used in a capable notification.
|
187 |
+
* New: Shortcode `[commenter_avatar]`. Outputs the comment author's avatar for comment-based notifications.
|
188 |
+
* Improved: 'Comment Reply' notifications are now available to use for Pages and Custom Post Types.
|
189 |
+
* Improved: When sending notifications to user roles in the 'To' field, it will now show how many users are in that role.
|
190 |
+
* Improved: The 'Lost Password - For User', 'User Role Changed - For Admin', and 'User Role Changed - For User' notifications now have the option to 'Stop additional paragraph and line break HTML from being inserted into my notifications' via the checkbox below the WYSIWYG editor on the Add New / Edit Notification screen.
|
191 |
+
|
192 |
= 1.4.1 - 3rd June 2016 =
|
193 |
* Fixed: Multiple emails were being sent for a single notification for a small number of users. After lots of hunting and lots of testing, I'm hoping this should now be fixed.
|
194 |
* Fixed: The 'User Role Changed' notification was broken after the update to WordPress 4.5.
|
assets/js/bnfw.js
CHANGED
@@ -43,13 +43,13 @@ jQuery(document).ready(function($) {
|
|
43 |
|
44 |
toggle_fields();
|
45 |
|
46 |
-
if ( 'new-user' === $('#notification').val() || 'welcome-email' === $('#notification').val() || 'reply-comment' === $('#notification').val() ) {
|
47 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
48 |
$('#user-password-msg').show();
|
49 |
} else if ( 'user-password' === $('#notification').val() || 'user-role' === notification ) {
|
50 |
-
$('#toggle-fields, #email, #cc, #bcc, #users, #
|
51 |
-
$('#user-password-msg, #email-formatting').show();
|
52 |
-
} else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
|
53 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
54 |
toggle_fields();
|
55 |
toggle_users();
|
@@ -67,13 +67,13 @@ jQuery(document).ready(function($) {
|
|
67 |
var $this = $(this),
|
68 |
notification = $this.val();
|
69 |
|
70 |
-
if ( 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() ) {
|
71 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
72 |
$('#user-password-msg').show();
|
73 |
} else if ( 'user-password' === $this.val() || 'user-role' === notification ) {
|
74 |
-
$('#toggle-fields, #email, #cc, #bcc, #users, #
|
75 |
-
$('#user-password-msg, #email-formatting').show();
|
76 |
-
} else if ( 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
|
77 |
$('#post-author').hide();
|
78 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
|
79 |
$('#user-password-msg').hide();
|
@@ -123,11 +123,13 @@ jQuery(document).ready(function($) {
|
|
123 |
case 'new-trackback':
|
124 |
case 'new-pingback':
|
125 |
case 'reply-comment':
|
|
|
126 |
case 'user-password':
|
127 |
case 'admin-password':
|
128 |
case 'new-user':
|
129 |
case 'welcome-email':
|
130 |
case 'user-role':
|
|
|
131 |
case 'admin-user':
|
132 |
case 'new-post':
|
133 |
case 'update-post':
|
@@ -148,6 +150,9 @@ jQuery(document).ready(function($) {
|
|
148 |
case 'comment':
|
149 |
notification_slug = splited[0] + '-post';
|
150 |
break;
|
|
|
|
|
|
|
151 |
case 'newterm':
|
152 |
notification_slug = 'newterm-category';
|
153 |
break;
|
43 |
|
44 |
toggle_fields();
|
45 |
|
46 |
+
if ( 'new-user' === $('#notification').val() || 'welcome-email' === $('#notification').val() || 'reply-comment' === $('#notification').val() || notification.startsWith( 'commentreply-' ) ) {
|
47 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
48 |
$('#user-password-msg').show();
|
49 |
} else if ( 'user-password' === $('#notification').val() || 'user-role' === notification ) {
|
50 |
+
$('#toggle-fields, #email, #cc, #bcc, #users, #current-user, #post-author').hide();
|
51 |
+
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
52 |
+
} else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() || 'admin-role' === notification ) {
|
53 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
54 |
toggle_fields();
|
55 |
toggle_users();
|
67 |
var $this = $(this),
|
68 |
notification = $this.val();
|
69 |
|
70 |
+
if ( 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() || notification.startsWith( 'commentreply-' ) ) {
|
71 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
72 |
$('#user-password-msg').show();
|
73 |
} else if ( 'user-password' === $this.val() || 'user-role' === notification ) {
|
74 |
+
$('#toggle-fields, #email, #cc, #bcc, #users, #current-user, #post-author').hide();
|
75 |
+
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
76 |
+
} else if ( 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() || 'admin-role' === notification ) {
|
77 |
$('#post-author').hide();
|
78 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
|
79 |
$('#user-password-msg').hide();
|
123 |
case 'new-trackback':
|
124 |
case 'new-pingback':
|
125 |
case 'reply-comment':
|
126 |
+
case 'commentreply-page':
|
127 |
case 'user-password':
|
128 |
case 'admin-password':
|
129 |
case 'new-user':
|
130 |
case 'welcome-email':
|
131 |
case 'user-role':
|
132 |
+
case 'admin-role':
|
133 |
case 'admin-user':
|
134 |
case 'new-post':
|
135 |
case 'update-post':
|
150 |
case 'comment':
|
151 |
notification_slug = splited[0] + '-post';
|
152 |
break;
|
153 |
+
case 'commentreply':
|
154 |
+
notification_slug = splited[0] + '-post';
|
155 |
+
break;
|
156 |
case 'newterm':
|
157 |
notification_slug = 'newterm-category';
|
158 |
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: Send customisable emails to your users for different WordPress notifications.
|
6 |
-
* Version: 1.
|
7 |
* Author: Voltronik
|
8 |
* Author URI: https://betternotificationsforwp.com/
|
9 |
* Author Email: hello@betternotificationsforwp.com
|
@@ -108,7 +108,7 @@ class BNFW {
|
|
108 |
public function hooks() {
|
109 |
global $wp_version;
|
110 |
|
111 |
-
register_activation_hook( __FILE__
|
112 |
|
113 |
// Some themes like P2, directly insert posts into DB.
|
114 |
$insert_post_themes = apply_filters( 'bnfw_insert_post_themes', array( 'P2', 'Syncope' ) );
|
@@ -296,7 +296,11 @@ class BNFW {
|
|
296 |
|
297 |
// comment reply notification.
|
298 |
if ( $the_comment->comment_parent > 0 ) {
|
299 |
-
$
|
|
|
|
|
|
|
|
|
300 |
if ( count( $notifications ) > 0 ) {
|
301 |
$parent = get_comment( $the_comment->comment_parent );
|
302 |
if ( $parent->comment_author_email != $the_comment->comment_author_email ) {
|
@@ -451,6 +455,8 @@ class BNFW {
|
|
451 |
foreach ( $notifications as $notification ) {
|
452 |
$this->engine->send_user_role_changed_email( $this->notifier->read_settings( $notification->ID ), $user_id );
|
453 |
}
|
|
|
|
|
454 |
}
|
455 |
}
|
456 |
|
3 |
* Plugin Name: Better Notifications for WordPress
|
4 |
* Plugin URI: https://wordpress.org/plugins/bnfw/
|
5 |
* Description: Send customisable emails to your users for different WordPress notifications.
|
6 |
+
* Version: 1.5
|
7 |
* Author: Voltronik
|
8 |
* Author URI: https://betternotificationsforwp.com/
|
9 |
* Author Email: hello@betternotificationsforwp.com
|
108 |
public function hooks() {
|
109 |
global $wp_version;
|
110 |
|
111 |
+
register_activation_hook( __FILE__, array( $this, 'activate' ) );
|
112 |
|
113 |
// Some themes like P2, directly insert posts into DB.
|
114 |
$insert_post_themes = apply_filters( 'bnfw_insert_post_themes', array( 'P2', 'Syncope' ) );
|
296 |
|
297 |
// comment reply notification.
|
298 |
if ( $the_comment->comment_parent > 0 ) {
|
299 |
+
$notification_type = 'reply-comment'; // old notification name
|
300 |
+
if ( 'post' != $post->post_type ) {
|
301 |
+
$notification_type = 'commentreply-' . $post->post_type;
|
302 |
+
}
|
303 |
+
$notifications = $this->notifier->get_notifications( $notification_type );
|
304 |
if ( count( $notifications ) > 0 ) {
|
305 |
$parent = get_comment( $the_comment->comment_parent );
|
306 |
if ( $parent->comment_author_email != $the_comment->comment_author_email ) {
|
455 |
foreach ( $notifications as $notification ) {
|
456 |
$this->engine->send_user_role_changed_email( $this->notifier->read_settings( $notification->ID ), $user_id );
|
457 |
}
|
458 |
+
|
459 |
+
$this->send_notification( 'admin-role', $user_id );
|
460 |
}
|
461 |
}
|
462 |
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -158,35 +158,37 @@ class BNFW_Notification {
|
|
158 |
<td>
|
159 |
<select name="notification" id="notification" class="select2" data-placeholder="Select the notification type" style="width:75%">
|
160 |
<optgroup label="WordPress Defaults">
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
</optgroup>
|
167 |
<optgroup label="Transactional">
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
173 |
</optgroup>
|
174 |
<optgroup label="Posts">
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
</optgroup>
|
183 |
<optgroup label="Page">
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
|
|
190 |
</optgroup>
|
191 |
<?php
|
192 |
$types = get_post_types( array(
|
@@ -206,6 +208,7 @@ class BNFW_Notification {
|
|
206 |
<option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
|
207 |
<option value="future-<?php echo $type; ?>" <?php selected( 'future-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Scheduled', 'bnfw' ); ?></option>
|
208 |
<option value="comment-<?php echo $type; ?>" <?php selected( 'comment-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'New Comment', 'bnfw' ); ?></option>
|
|
|
209 |
<?php do_action( 'bnfw_after_notification_options', $type, $label, $setting ); ?>
|
210 |
</optgroup>
|
211 |
<?php
|
@@ -848,7 +851,10 @@ class BNFW_Notification {
|
|
848 |
$name = __( 'New User Registration - For Admin', 'bnfw' );
|
849 |
break;
|
850 |
case 'user-role':
|
851 |
-
$name = __( 'User Role Changed', 'bnfw' );
|
|
|
|
|
|
|
852 |
break;
|
853 |
case 'new-post':
|
854 |
$name = __( 'New Post Published', 'bnfw' );
|
@@ -893,6 +899,9 @@ class BNFW_Notification {
|
|
893 |
case 'comment':
|
894 |
$name = $label . __( ' Comment', 'bnfw' );
|
895 |
break;
|
|
|
|
|
|
|
896 |
case 'newterm':
|
897 |
$tax = get_taxonomy( $splited[1] );
|
898 |
if ( ! $tax ) {
|
158 |
<td>
|
159 |
<select name="notification" id="notification" class="select2" data-placeholder="Select the notification type" style="width:75%">
|
160 |
<optgroup label="WordPress Defaults">
|
161 |
+
<option value="new-comment" <?php selected( 'new-comment', $setting['notification'] );?>><?php _e( 'New Comment / Awaiting Moderation', 'bnfw' ); ?></option>
|
162 |
+
<option value="new-trackback" <?php selected( 'new-trackback', $setting['notification'] );?>><?php _e( 'New Trackback', 'bnfw' );?></option>
|
163 |
+
<option value="new-pingback" <?php selected( 'new-pingback', $setting['notification'] );?>><?php _e( 'New Pingback', 'bnfw' );?></option>
|
164 |
+
<option value="admin-password" <?php selected( 'admin-password', $setting['notification'] );?>><?php _e( 'Lost Password - For Admin', 'bnfw' );?></option>
|
165 |
+
<option value="admin-user" <?php selected( 'admin-user', $setting['notification'] );?>><?php _e( 'New User Registration - For Admin', 'bnfw' );?></option>
|
166 |
</optgroup>
|
167 |
<optgroup label="Transactional">
|
168 |
+
<option value="user-password" <?php selected( 'user-password', $setting['notification'] );?>><?php _e( 'Lost Password - For User', 'bnfw' );?></option>
|
169 |
+
<option value="new-user" <?php selected( 'new-user', $setting['notification'] );?>><?php _e( 'New User Registration - For User', 'bnfw' );?></option>
|
170 |
+
<option value="welcome-email" <?php selected( 'welcome-email', $setting['notification'] );?>><?php _e( 'New User - Post-registration Email', 'bnfw' );?></option>
|
171 |
+
<option value="admin-role" <?php selected( 'admin-role', $setting['notification'] );?>><?php _e( 'User Role Changed - For Admin', 'bnfw' );?></option>
|
172 |
+
<option value="user-role" <?php selected( 'user-role', $setting['notification'] );?>><?php _e( 'User Role Changed - For User', 'bnfw' );?></option>
|
173 |
+
<option value="reply-comment" <?php selected( 'reply-comment', $setting['notification'] );?>><?php _e( 'Comment Reply', 'bnfw' );?></option>
|
174 |
</optgroup>
|
175 |
<optgroup label="Posts">
|
176 |
+
<option value="new-post" <?php selected( 'new-post', $setting['notification'] );?>><?php _e( 'New Post Published', 'bnfw' );?></option>
|
177 |
+
<option value="update-post" <?php selected( 'update-post', $setting['notification'] );?>><?php _e( 'Post Updated', 'bnfw' );?></option>
|
178 |
+
<option value="pending-post" <?php selected( 'pending-post', $setting['notification'] );?>><?php _e( 'Post Pending Review', 'bnfw' );?></option>
|
179 |
+
<option value="future-post" <?php selected( 'future-post', $setting['notification'] );?>><?php _e( 'Post Scheduled', 'bnfw' );?></option>
|
180 |
+
<option value="newterm-category" <?php selected( 'newterm-category', $setting['notification'] );?>><?php _e( 'New Category', 'bnfw' ); ?></option>
|
181 |
+
<option value="newterm-post_tag" <?php selected( 'newterm-post_tag', $setting['notification'] );?>><?php _e( 'New Tag', 'bnfw' ); ?></option>
|
182 |
+
<?php do_action( 'bnfw_after_notification_options', 'post', 'Post', $setting ); ?>
|
183 |
</optgroup>
|
184 |
<optgroup label="Page">
|
185 |
+
<option value="new-page" <?php selected( 'new-page', $setting['notification'] );?>><?php _e( 'New Page Published', 'bnfw' );?></option>
|
186 |
+
<option value="update-page" <?php selected( 'update-page', $setting['notification'] );?>><?php _e( 'Page Updated', 'bnfw' );?></option>
|
187 |
+
<option value="pending-page" <?php selected( 'pending-page', $setting['notification'] );?>><?php _e( 'Page Pending Review', 'bnfw' );?></option>
|
188 |
+
<option value="future-page" <?php selected( 'future-page', $setting['notification'] );?>><?php _e( 'Page Scheduled', 'bnfw' );?></option>
|
189 |
+
<option value="comment-page" <?php selected( 'comment-page', $setting['notification'] );?>><?php _e( 'Page - New Comment', 'bnfw' );?></option>
|
190 |
+
<option value="commentreply-page" <?php selected( 'commentreply-page', $setting['notification'] );?>><?php _e( 'Page - Comment Reply', 'bnfw' );?></option>
|
191 |
+
<?php do_action( 'bnfw_after_notification_options', 'page', 'Page', $setting ); ?>
|
192 |
</optgroup>
|
193 |
<?php
|
194 |
$types = get_post_types( array(
|
208 |
<option value="pending-<?php echo $type; ?>" <?php selected( 'pending-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Pending Review', 'bnfw' ); ?></option>
|
209 |
<option value="future-<?php echo $type; ?>" <?php selected( 'future-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Scheduled', 'bnfw' ); ?></option>
|
210 |
<option value="comment-<?php echo $type; ?>" <?php selected( 'comment-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'New Comment', 'bnfw' ); ?></option>
|
211 |
+
<option value="commentreply-<?php echo $type; ?>" <?php selected( 'commentreply-' . $type, $setting['notification'] );?>><?php echo "'$label' ", __( 'Comment Reply', 'bnfw' ); ?></option>
|
212 |
<?php do_action( 'bnfw_after_notification_options', $type, $label, $setting ); ?>
|
213 |
</optgroup>
|
214 |
<?php
|
851 |
$name = __( 'New User Registration - For Admin', 'bnfw' );
|
852 |
break;
|
853 |
case 'user-role':
|
854 |
+
$name = __( 'User Role Changed - For User', 'bnfw' );
|
855 |
+
break;
|
856 |
+
case 'admin-role':
|
857 |
+
$name = __( 'User Role Changed - For Admin', 'bnfw' );
|
858 |
break;
|
859 |
case 'new-post':
|
860 |
$name = __( 'New Post Published', 'bnfw' );
|
899 |
case 'comment':
|
900 |
$name = $label . __( ' Comment', 'bnfw' );
|
901 |
break;
|
902 |
+
case 'commentreply':
|
903 |
+
$name = $label . __( ' Comment Reply', 'bnfw' );
|
904 |
+
break;
|
905 |
case 'newterm':
|
906 |
$tax = get_taxonomy( $splited[1] );
|
907 |
if ( ! $tax ) {
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -28,6 +28,8 @@ class BNFW_Engine {
|
|
28 |
$headers[] = 'Content-type: text/html';
|
29 |
}
|
30 |
|
|
|
|
|
31 |
wp_mail( $email, stripslashes( $subject ), $message, $headers );
|
32 |
}
|
33 |
|
@@ -64,7 +66,7 @@ class BNFW_Engine {
|
|
64 |
|
65 |
if ( isset( $emails['to'] ) && is_array( $emails['to'] ) ) {
|
66 |
foreach ( $emails['to'] as $email ) {
|
67 |
-
wp_mail( $email, stripslashes( $subject ), $message, $headers );
|
68 |
}
|
69 |
}
|
70 |
}
|
@@ -102,6 +104,8 @@ class BNFW_Engine {
|
|
102 |
$headers[] = 'Content-type: text/html';
|
103 |
}
|
104 |
|
|
|
|
|
105 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
106 |
}
|
107 |
|
@@ -128,6 +132,8 @@ class BNFW_Engine {
|
|
128 |
$message = wpautop( $message );
|
129 |
}
|
130 |
|
|
|
|
|
131 |
wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
|
132 |
}
|
133 |
|
@@ -153,6 +159,9 @@ class BNFW_Engine {
|
|
153 |
}
|
154 |
|
155 |
$user = get_user_by( 'id', $user_id );
|
|
|
|
|
|
|
156 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
157 |
}
|
158 |
|
@@ -202,6 +211,7 @@ class BNFW_Engine {
|
|
202 |
case 'welcome-email':
|
203 |
case 'new-user':
|
204 |
case 'user-role':
|
|
|
205 |
// handle users (lost password and new user registration)
|
206 |
$message = $this->user_shortcodes( $message, $id );
|
207 |
break;
|
@@ -232,7 +242,7 @@ class BNFW_Engine {
|
|
232 |
$post = get_post( $id );
|
233 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
234 |
}
|
235 |
-
} else if ( 'comment' == $type[0] ) {
|
236 |
$message = $this->comment_shortcodes( $message, $id );
|
237 |
$comment = get_comment( $id );
|
238 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
@@ -243,10 +253,29 @@ class BNFW_Engine {
|
|
243 |
break;
|
244 |
}
|
245 |
|
|
|
|
|
246 |
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $id, $this );
|
247 |
return $message;
|
248 |
}
|
249 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
/**
|
251 |
* Handle post shortcodes.
|
252 |
*
|
@@ -288,6 +317,13 @@ class BNFW_Engine {
|
|
288 |
$message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
|
289 |
$message = str_replace( '[edit_post]', get_edit_post_link( $post->ID ), $message );
|
290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
if ( 'future' == $post->post_status ) {
|
292 |
$message = str_replace( '[post_scheduled_date]', $post->post_date, $message );
|
293 |
$message = str_replace( '[post_scheduled_date_gmt]', $post->post_date_gmt, $message );
|
@@ -355,13 +391,12 @@ class BNFW_Engine {
|
|
355 |
/**
|
356 |
* Handle user shortcodes.
|
357 |
*
|
358 |
-
* @access private
|
359 |
* @since 1.0
|
360 |
* @param unknown $message
|
361 |
* @param unknown $user_id
|
362 |
* @return unknown
|
363 |
*/
|
364 |
-
|
365 |
$user_info = get_userdata( $user_id );
|
366 |
|
367 |
// deperecated
|
@@ -378,6 +413,10 @@ class BNFW_Engine {
|
|
378 |
$message = str_replace( '[user_lastname]', $user_info->user_lastname, $message );
|
379 |
$message = str_replace( '[nickname]', $user_info->nickname, $message );
|
380 |
$message = str_replace( '[user_description]', $user_info->user_description, $message );
|
|
|
|
|
|
|
|
|
381 |
if ( is_array( $user_info->wp_capabilities ) ) {
|
382 |
$message = str_replace( '[wp_capabilities]', implode( ',', $user_info->wp_capabilities ), $message );
|
383 |
}
|
@@ -607,5 +646,27 @@ class BNFW_Engine {
|
|
607 |
|
608 |
return $headers;
|
609 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
610 |
}
|
611 |
-
?>
|
28 |
$headers[] = 'Content-type: text/html';
|
29 |
}
|
30 |
|
31 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $email );
|
32 |
+
$message = $this->handle_global_user_shortcodes( $message, $email );
|
33 |
wp_mail( $email, stripslashes( $subject ), $message, $headers );
|
34 |
}
|
35 |
|
66 |
|
67 |
if ( isset( $emails['to'] ) && is_array( $emails['to'] ) ) {
|
68 |
foreach ( $emails['to'] as $email ) {
|
69 |
+
wp_mail( $email, stripslashes( $this->handle_global_user_shortcodes( $subject, $email ) ), $this->handle_global_user_shortcodes( $message, $email ), $headers );
|
70 |
}
|
71 |
}
|
72 |
}
|
104 |
$headers[] = 'Content-type: text/html';
|
105 |
}
|
106 |
|
107 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
108 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
109 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
110 |
}
|
111 |
|
132 |
$message = wpautop( $message );
|
133 |
}
|
134 |
|
135 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $parent_comment->comment_author_email );
|
136 |
+
$message = $this->handle_global_user_shortcodes( $message, $parent_comment->comment_author_email );
|
137 |
wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
|
138 |
}
|
139 |
|
159 |
}
|
160 |
|
161 |
$user = get_user_by( 'id', $user_id );
|
162 |
+
|
163 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
164 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
165 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
166 |
}
|
167 |
|
211 |
case 'welcome-email':
|
212 |
case 'new-user':
|
213 |
case 'user-role':
|
214 |
+
case 'admin-role':
|
215 |
// handle users (lost password and new user registration)
|
216 |
$message = $this->user_shortcodes( $message, $id );
|
217 |
break;
|
242 |
$post = get_post( $id );
|
243 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
244 |
}
|
245 |
+
} else if ( 'comment' == $type[0] || 'commentreply' == $type[0] ) {
|
246 |
$message = $this->comment_shortcodes( $message, $id );
|
247 |
$comment = get_comment( $id );
|
248 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
253 |
break;
|
254 |
}
|
255 |
|
256 |
+
$message = $this->global_shortcodes( $message );
|
257 |
+
|
258 |
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $id, $this );
|
259 |
return $message;
|
260 |
}
|
261 |
|
262 |
+
/**
|
263 |
+
* Handle Global shortcodes.
|
264 |
+
*
|
265 |
+
* @since 1.5
|
266 |
+
*
|
267 |
+
* @param string $message String with shortcodes.
|
268 |
+
*
|
269 |
+
* @return string String after processing global shortcodes.
|
270 |
+
*/
|
271 |
+
private function global_shortcodes( $message ) {
|
272 |
+
$message = str_replace( '[global_site_title]', get_bloginfo( 'name' ), $message );
|
273 |
+
$message = str_replace( '[global_site_tagline]', get_bloginfo( 'description' ), $message );
|
274 |
+
$message = str_replace( '[global_site_url]', get_bloginfo( 'url' ), $message );
|
275 |
+
|
276 |
+
return $message;
|
277 |
+
}
|
278 |
+
|
279 |
/**
|
280 |
* Handle post shortcodes.
|
281 |
*
|
317 |
$message = str_replace( '[permalink]', get_permalink( $post->ID ), $message );
|
318 |
$message = str_replace( '[edit_post]', get_edit_post_link( $post->ID ), $message );
|
319 |
|
320 |
+
if ( has_post_thumbnail( $post->ID ) ) {
|
321 |
+
$image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
|
322 |
+
if ( is_array( $image_url ) ) {
|
323 |
+
$message = str_replace( '[featured_image]', $image_url[0], $message );
|
324 |
+
}
|
325 |
+
}
|
326 |
+
|
327 |
if ( 'future' == $post->post_status ) {
|
328 |
$message = str_replace( '[post_scheduled_date]', $post->post_date, $message );
|
329 |
$message = str_replace( '[post_scheduled_date_gmt]', $post->post_date_gmt, $message );
|
391 |
/**
|
392 |
* Handle user shortcodes.
|
393 |
*
|
|
|
394 |
* @since 1.0
|
395 |
* @param unknown $message
|
396 |
* @param unknown $user_id
|
397 |
* @return unknown
|
398 |
*/
|
399 |
+
public function user_shortcodes( $message, $user_id ) {
|
400 |
$user_info = get_userdata( $user_id );
|
401 |
|
402 |
// deperecated
|
413 |
$message = str_replace( '[user_lastname]', $user_info->user_lastname, $message );
|
414 |
$message = str_replace( '[nickname]', $user_info->nickname, $message );
|
415 |
$message = str_replace( '[user_description]', $user_info->user_description, $message );
|
416 |
+
$message = str_replace( '[user_avatar]', get_avatar_url( $user_id), $message );
|
417 |
+
$message = str_replace( '[user_avatar]', get_avatar_url( $user_id), $message );
|
418 |
+
$message = str_replace( '[commenter_avatar]', get_avatar_url( $user_id), $message );
|
419 |
+
|
420 |
if ( is_array( $user_info->wp_capabilities ) ) {
|
421 |
$message = str_replace( '[wp_capabilities]', implode( ',', $user_info->wp_capabilities ), $message );
|
422 |
}
|
646 |
|
647 |
return $headers;
|
648 |
}
|
649 |
+
|
650 |
+
/**
|
651 |
+
* Handle Global User Shortcodes.
|
652 |
+
*
|
653 |
+
* @param string $message String to be processed.
|
654 |
+
* @param string $email Email of the user.
|
655 |
+
*
|
656 |
+
* @return string Processed string.
|
657 |
+
*/
|
658 |
+
private function handle_global_user_shortcodes( $message, $email ) {
|
659 |
+
$user = get_user_by( 'email', $email );
|
660 |
+
|
661 |
+
if ( false === $user ) {
|
662 |
+
$message = str_replace( '[global_user_firstname]', $email, $message );
|
663 |
+
$message = str_replace( '[global_user_lastname]', $email, $message );
|
664 |
+
} else {
|
665 |
+
$message = str_replace( '[global_user_firstname]', $user->first_name, $message );
|
666 |
+
$message = str_replace( '[global_user_lastname]', $user->last_name, $message );
|
667 |
+
}
|
668 |
+
$message = str_replace( '[global_user_email]', $email, $message );
|
669 |
+
|
670 |
+
return $message;
|
671 |
+
}
|
672 |
}
|
|
includes/helpers/ajax-helpers.php
CHANGED
@@ -14,11 +14,17 @@ function bnfw_search_users() {
|
|
14 |
global $wp_roles;
|
15 |
|
16 |
$roles_data = array();
|
|
|
17 |
$roles = $wp_roles->get_names();
|
18 |
foreach ( $roles as $role ) {
|
|
|
|
|
|
|
|
|
|
|
19 |
$roles_data[] = array(
|
20 |
'id' => 'role-' . $role,
|
21 |
-
'text' => $role,
|
22 |
);
|
23 |
}
|
24 |
|
14 |
global $wp_roles;
|
15 |
|
16 |
$roles_data = array();
|
17 |
+
$user_count = count_users();
|
18 |
$roles = $wp_roles->get_names();
|
19 |
foreach ( $roles as $role ) {
|
20 |
+
$count = 0;
|
21 |
+
if ( isset( $user_count['avail_roles'][ strtolower( $role ) ] ) ) {
|
22 |
+
$count = $user_count['avail_roles'][ strtolower( $role ) ];
|
23 |
+
}
|
24 |
+
|
25 |
$roles_data[] = array(
|
26 |
'id' => 'role-' . $role,
|
27 |
+
'text' => $role . ' (' . $count . ' Users)',
|
28 |
);
|
29 |
}
|
30 |
|
includes/helpers/helpers.php
CHANGED
@@ -29,6 +29,8 @@ function bnfw_get_user_select_class() {
|
|
29 |
*/
|
30 |
function bnfw_render_users_dropdown( $selected_users ) {
|
31 |
global $wp_roles;
|
|
|
|
|
32 |
?>
|
33 |
<optgroup label="User Roles">
|
34 |
<?php
|
@@ -36,14 +38,16 @@ function bnfw_render_users_dropdown( $selected_users ) {
|
|
36 |
|
37 |
foreach ( $roles as $role ) {
|
38 |
$selected = selected( true, in_array( 'role-' . $role, $selected_users ), false );
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
?>
|
42 |
</optgroup>
|
43 |
<optgroup label="Users">
|
44 |
<?php
|
45 |
-
$user_count = count_users();
|
46 |
-
|
47 |
// if there are more than 100 users then use AJAX to load them dynamically.
|
48 |
// So just get only the selected users
|
49 |
if ( count( $selected_users ) > 0 && $user_count['total_users'] > 100 ) {
|
29 |
*/
|
30 |
function bnfw_render_users_dropdown( $selected_users ) {
|
31 |
global $wp_roles;
|
32 |
+
|
33 |
+
$user_count = count_users();
|
34 |
?>
|
35 |
<optgroup label="User Roles">
|
36 |
<?php
|
38 |
|
39 |
foreach ( $roles as $role ) {
|
40 |
$selected = selected( true, in_array( 'role-' . $role, $selected_users ), false );
|
41 |
+
$count = 0;
|
42 |
+
if ( isset( $user_count['avail_roles'][ strtolower( $role ) ] ) ) {
|
43 |
+
$count = $user_count['avail_roles'][ strtolower( $role ) ];
|
44 |
+
}
|
45 |
+
echo '<option value="role-', $role, '" ', $selected, '>', $role, ' (', $count, ' Users)', '</option>';
|
46 |
}
|
47 |
?>
|
48 |
</optgroup>
|
49 |
<optgroup label="Users">
|
50 |
<?php
|
|
|
|
|
51 |
// if there are more than 100 users then use AJAX to load them dynamically.
|
52 |
// So just get only the selected users
|
53 |
if ( count( $selected_users ) > 0 && $user_count['total_users'] > 100 ) {
|