Version Description
- 9th January 2016 =
- Happy New Year!
- New: Transactional notification for when a User Role Changed. This is sent to the user when their User Role is changed.
- Fixed: Ensure that at least one User or User Role is selected before saving a notification.
- Fixed: select2 v4 update and compatibility with Ultimate Member and ACF Pro.
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.3.9 |
Comparing to | |
See all releases |
Code changes from version 1.3.8 to 1.3.9
- README.txt +9 -2
- assets/js/bnfw.js +20 -3
- bnfw.php +17 -2
- includes/admin/class-bnfw-notification.php +38 -9
- includes/engine/class-bnfw-engine.php +33 -4
- includes/notification/post-notification.php +5 -27
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.4
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -38,6 +38,7 @@ Notifications that are currently available to use are:
|
|
38 |
* Lost Password (For User)
|
39 |
* New User Registration (For User)
|
40 |
* New User - Welcome Email
|
|
|
41 |
* Comment Reply
|
42 |
|
43 |
**Posts / Custom Post Types**
|
@@ -175,6 +176,12 @@ It might do but this is untested.
|
|
175 |
|
176 |
== Changelog ==
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
= 1.3.8 - 16th December 2015 =
|
179 |
* Fixed: Notifications weren't being sent out at all. After lots of testing, I think this should now be resolved.
|
180 |
* Fixed: An issue where quotes in the Subject field were causing part of/all the field content to be removed.
|
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.4.1
|
7 |
+
Stable tag: 1.3.9
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
38 |
* Lost Password (For User)
|
39 |
* New User Registration (For User)
|
40 |
* New User - Welcome Email
|
41 |
+
* User Role Changed
|
42 |
* Comment Reply
|
43 |
|
44 |
**Posts / Custom Post Types**
|
176 |
|
177 |
== Changelog ==
|
178 |
|
179 |
+
= 1.3.9 - 9th January 2016 =
|
180 |
+
* Happy New Year!
|
181 |
+
* New: Transactional notification for when a User Role Changed. This is sent to the user when their User Role is changed.
|
182 |
+
* Fixed: Ensure that at least one User or User Role is selected before saving a notification.
|
183 |
+
* Fixed: select2 v4 update and compatibility with Ultimate Member and ACF Pro.
|
184 |
+
|
185 |
= 1.3.8 - 16th December 2015 =
|
186 |
* Fixed: Notifications weren't being sent out at all. After lots of testing, I think this should now be resolved.
|
187 |
* Fixed: An issue where quotes in the Subject field were causing part of/all the field content to be removed.
|
assets/js/bnfw.js
CHANGED
@@ -18,6 +18,8 @@ jQuery(document).ready(function($) {
|
|
18 |
}
|
19 |
|
20 |
function init() {
|
|
|
|
|
21 |
$(".select2").select2();
|
22 |
$(".user-select2").select2( {
|
23 |
ajax: {
|
@@ -44,7 +46,7 @@ jQuery(document).ready(function($) {
|
|
44 |
if ( 'new-user' === $('#notification').val() || 'welcome-email' === $('#notification').val() || 'reply-comment' === $('#notification').val() ) {
|
45 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
46 |
$('#user-password-msg').show();
|
47 |
-
} else if ( 'user-password' === $('#notification').val() ) {
|
48 |
$('#toggle-fields, #email, #cc, #bcc, #users, #disable-autop, #current-user, #post-author').hide();
|
49 |
$('#user-password-msg, #email-formatting').show();
|
50 |
} else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
|
@@ -63,11 +65,13 @@ jQuery(document).ready(function($) {
|
|
63 |
|
64 |
init();
|
65 |
$('#notification').on('change', function() {
|
66 |
-
var $this = $(this)
|
|
|
|
|
67 |
if ( 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() ) {
|
68 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
69 |
$('#user-password-msg').show();
|
70 |
-
} else if ( 'user-password' === $this.val() ) {
|
71 |
$('#toggle-fields, #email, #cc, #bcc, #users, #disable-autop, #current-user, #post-author').hide();
|
72 |
$('#user-password-msg, #email-formatting').show();
|
73 |
} else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
|
@@ -95,6 +99,19 @@ jQuery(document).ready(function($) {
|
|
95 |
$( '#send-test-email' ).val( 'true' );
|
96 |
});
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$( '#shortcode-help' ).on( 'click', function() {
|
99 |
var notification = $( '#notification' ).val(),
|
100 |
notification_slug = '',
|
18 |
}
|
19 |
|
20 |
function init() {
|
21 |
+
var notification = $('#notification').val();
|
22 |
+
|
23 |
$(".select2").select2();
|
24 |
$(".user-select2").select2( {
|
25 |
ajax: {
|
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, #disable-autop, #current-user, #post-author').hide();
|
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() ) {
|
65 |
|
66 |
init();
|
67 |
$('#notification').on('change', function() {
|
68 |
+
var $this = $(this),
|
69 |
+
notification = $this.val();
|
70 |
+
|
71 |
if ( 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() ) {
|
72 |
$('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
|
73 |
$('#user-password-msg').show();
|
74 |
+
} else if ( 'user-password' === $this.val() || 'user-role' === notification ) {
|
75 |
$('#toggle-fields, #email, #cc, #bcc, #users, #disable-autop, #current-user, #post-author').hide();
|
76 |
$('#user-password-msg, #email-formatting').show();
|
77 |
} else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
|
99 |
$( '#send-test-email' ).val( 'true' );
|
100 |
});
|
101 |
|
102 |
+
// Validate before saving notification
|
103 |
+
$( '#publish' ).click(function() {
|
104 |
+
if ( $('#users').is(':visible') ) {
|
105 |
+
if ( null === $('#users-select').val() ) {
|
106 |
+
$('#bnfw_error').remove();
|
107 |
+
$('.wrap h1').after('<div class="error" id="bnfw_error"><p>You must choose at least one User or User Role to send the notification to before you can save</p></div>');
|
108 |
+
return false;
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
return true;
|
113 |
+
});
|
114 |
+
|
115 |
$( '#shortcode-help' ).on( 'click', function() {
|
116 |
var notification = $( '#notification' ).val(),
|
117 |
notification_slug = '',
|
bnfw.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Better Notifications for WordPress
|
4 |
* Plugin URI: http://wordpress.org/plugins/bnfw/
|
5 |
* Description: Send customisable emails to your users for different WordPress notifications.
|
6 |
-
* Version: 1.3.
|
7 |
* Author: Voltronik
|
8 |
* Author URI: https://betternotificationsforwp.com/
|
9 |
* Author Email: plugins@voltronik.co.uk
|
@@ -125,6 +125,7 @@ class BNFW {
|
|
125 |
|
126 |
add_action( 'user_register' , array( $this, 'user_register' ) );
|
127 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
|
|
128 |
|
129 |
add_action( 'lostpassword_post' , array( $this, 'on_lost_password' ) );
|
130 |
add_filter( 'retrieve_password_title' , array( $this, 'change_password_email_title' ) );
|
@@ -390,7 +391,7 @@ class BNFW {
|
|
390 |
* Send notification for new uses.
|
391 |
*
|
392 |
* @since 1.0
|
393 |
-
* @param
|
394 |
*/
|
395 |
function user_register( $user_id ) {
|
396 |
$this->send_notification( 'admin-user', $user_id );
|
@@ -409,6 +410,20 @@ class BNFW {
|
|
409 |
}
|
410 |
}
|
411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
412 |
/**
|
413 |
* Send notification based on type and ref id
|
414 |
*
|
3 |
* Plugin Name: Better Notifications for WordPress
|
4 |
* Plugin URI: http://wordpress.org/plugins/bnfw/
|
5 |
* Description: Send customisable emails to your users for different WordPress notifications.
|
6 |
+
* Version: 1.3.9
|
7 |
* Author: Voltronik
|
8 |
* Author URI: https://betternotificationsforwp.com/
|
9 |
* Author Email: plugins@voltronik.co.uk
|
125 |
|
126 |
add_action( 'user_register' , array( $this, 'user_register' ) );
|
127 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
128 |
+
add_action( 'set_user_role' , array( $this, 'user_role_changed' ), 10, 2 );
|
129 |
|
130 |
add_action( 'lostpassword_post' , array( $this, 'on_lost_password' ) );
|
131 |
add_filter( 'retrieve_password_title' , array( $this, 'change_password_email_title' ) );
|
391 |
* Send notification for new uses.
|
392 |
*
|
393 |
* @since 1.0
|
394 |
+
* @param int $user_id
|
395 |
*/
|
396 |
function user_register( $user_id ) {
|
397 |
$this->send_notification( 'admin-user', $user_id );
|
410 |
}
|
411 |
}
|
412 |
|
413 |
+
/**
|
414 |
+
* Send notification when a user role changes.
|
415 |
+
*
|
416 |
+
* @since 1.3.9
|
417 |
+
* @param int $user_id User ID
|
418 |
+
* @param string $new_role New User role
|
419 |
+
*/
|
420 |
+
public function user_role_changed( $user_id, $new_role ) {
|
421 |
+
$notifications = $this->notifier->get_notifications( 'user-role' );
|
422 |
+
foreach ( $notifications as $notification ) {
|
423 |
+
$this->engine->send_user_role_chnaged_email( $this->notifier->read_settings( $notification->ID ), $user_id );
|
424 |
+
}
|
425 |
+
}
|
426 |
+
|
427 |
/**
|
428 |
* Send notification based on type and ref id
|
429 |
*
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -168,8 +168,12 @@ class BNFW_Notification {
|
|
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 - Welcome Email', 'bnfw' );?></option>
|
|
|
171 |
<option value="reply-comment" <?php selected( 'reply-comment', $setting['notification'] );?>><?php _e( 'Comment Reply', 'bnfw' );?></option>
|
172 |
</optgroup>
|
|
|
|
|
|
|
173 |
<optgroup label="Posts">
|
174 |
<option value="new-post" <?php selected( 'new-post', $setting['notification'] );?>><?php _e( 'New Post Published', 'bnfw' );?></option>
|
175 |
<option value="update-post" <?php selected( 'update-post', $setting['notification'] );?>><?php _e( 'Post Updated', 'bnfw' );?></option>
|
@@ -323,7 +327,7 @@ class BNFW_Notification {
|
|
323 |
<?php _e( 'Send To', 'bnfw' ); ?>
|
324 |
</th>
|
325 |
<td>
|
326 |
-
<select multiple name="users[]" class="<?php echo bnfw_get_user_select_class(); ?>" data-placeholder="Select User Roles / Users" style="width:75%">
|
327 |
<?php bnfw_render_users_dropdown( $setting['users'] ); ?>
|
328 |
</select>
|
329 |
</td>
|
@@ -406,8 +410,14 @@ class BNFW_Notification {
|
|
406 |
wp_deregister_style( 'select2' );
|
407 |
wp_dequeue_style( 'select2' );
|
408 |
|
409 |
-
|
410 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
411 |
|
412 |
wp_enqueue_script( 'bnfw', plugins_url( '../assets/js/bnfw.js', dirname( __FILE__ ) ), array( 'select2' ), '0.1', true );
|
413 |
wp_enqueue_style( 'bnfw', plugins_url( '../assets/css/bnfw.css', dirname( __FILE__ ) ), array( 'dashicons', 'select2' ), '0.1' );
|
@@ -525,8 +535,8 @@ class BNFW_Notification {
|
|
525 |
* Read settings from post meta.
|
526 |
*
|
527 |
* @since 1.0
|
528 |
-
* @param
|
529 |
-
* @return
|
530 |
*/
|
531 |
public function read_settings( $post_id ) {
|
532 |
$setting = array();
|
@@ -569,6 +579,7 @@ class BNFW_Notification {
|
|
569 |
delete_post_meta( $post_id, self::META_KEY_PREFIX . 'user-roles' );
|
570 |
}
|
571 |
|
|
|
572 |
return $setting;
|
573 |
}
|
574 |
|
@@ -655,16 +666,21 @@ class BNFW_Notification {
|
|
655 |
* Get notifications based on type.
|
656 |
*
|
657 |
* @since 1.0
|
658 |
-
* @param
|
659 |
-
* @return
|
660 |
*/
|
661 |
-
public function get_notifications( $
|
|
|
|
|
|
|
|
|
662 |
$args = array(
|
663 |
'post_type' => self::POST_TYPE,
|
664 |
'meta_query' => array(
|
665 |
array(
|
666 |
'key' => self::META_KEY_PREFIX . 'notification',
|
667 |
-
'value' => $
|
|
|
668 |
),
|
669 |
array(
|
670 |
'key' => self::META_KEY_PREFIX . 'disabled',
|
@@ -742,6 +758,16 @@ class BNFW_Notification {
|
|
742 |
echo implode( ', ', $users );
|
743 |
break;
|
744 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
745 |
}
|
746 |
|
747 |
/**
|
@@ -809,6 +835,9 @@ class BNFW_Notification {
|
|
809 |
case 'admin-user':
|
810 |
$name = __( 'User Registration - For Admin', 'bnfw' );
|
811 |
break;
|
|
|
|
|
|
|
812 |
case 'new-post':
|
813 |
$name = __( 'New Post Published', 'bnfw' );
|
814 |
break;
|
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 - Welcome Email', 'bnfw' );?></option>
|
171 |
+
<option value="user-role" <?php selected( 'user-role', $setting['notification'] );?>><?php _e( 'User Role Changed', 'bnfw' );?></option>
|
172 |
<option value="reply-comment" <?php selected( 'reply-comment', $setting['notification'] );?>><?php _e( 'Comment Reply', 'bnfw' );?></option>
|
173 |
</optgroup>
|
174 |
+
<optgroup label="Others">
|
175 |
+
<option value="user-role" <?php selected( 'user-role', $setting['notification'] );?>><?php _e( 'User Role Changed', 'bnfw' );?></option>
|
176 |
+
</optgroup>
|
177 |
<optgroup label="Posts">
|
178 |
<option value="new-post" <?php selected( 'new-post', $setting['notification'] );?>><?php _e( 'New Post Published', 'bnfw' );?></option>
|
179 |
<option value="update-post" <?php selected( 'update-post', $setting['notification'] );?>><?php _e( 'Post Updated', 'bnfw' );?></option>
|
327 |
<?php _e( 'Send To', 'bnfw' ); ?>
|
328 |
</th>
|
329 |
<td>
|
330 |
+
<select multiple id="users-select" name="users[]" class="<?php echo bnfw_get_user_select_class(); ?>" data-placeholder="Select User Roles / Users" style="width:75%">
|
331 |
<?php bnfw_render_users_dropdown( $setting['users'] ); ?>
|
332 |
</select>
|
333 |
</td>
|
410 |
wp_deregister_style( 'select2' );
|
411 |
wp_dequeue_style( 'select2' );
|
412 |
|
413 |
+
// Ultimate Member plugin is giving us problems. They should upgrade
|
414 |
+
wp_deregister_script( 'um_minified' );
|
415 |
+
wp_dequeue_script( 'um_minified' );
|
416 |
+
wp_deregister_script( 'um_admin_scripts' );
|
417 |
+
wp_dequeue_script( 'um_admin_scripts' );
|
418 |
+
|
419 |
+
wp_enqueue_style( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/css/select2.min.css', array(), '4.0.1' );
|
420 |
+
wp_enqueue_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js', array( 'jquery' ), '4.0.1', true );
|
421 |
|
422 |
wp_enqueue_script( 'bnfw', plugins_url( '../assets/js/bnfw.js', dirname( __FILE__ ) ), array( 'select2' ), '0.1', true );
|
423 |
wp_enqueue_style( 'bnfw', plugins_url( '../assets/css/bnfw.css', dirname( __FILE__ ) ), array( 'dashicons', 'select2' ), '0.1' );
|
535 |
* Read settings from post meta.
|
536 |
*
|
537 |
* @since 1.0
|
538 |
+
* @param int $post_id
|
539 |
+
* @return array
|
540 |
*/
|
541 |
public function read_settings( $post_id ) {
|
542 |
$setting = array();
|
579 |
delete_post_meta( $post_id, self::META_KEY_PREFIX . 'user-roles' );
|
580 |
}
|
581 |
|
582 |
+
$setting['id'] = $post_id;
|
583 |
return $setting;
|
584 |
}
|
585 |
|
666 |
* Get notifications based on type.
|
667 |
*
|
668 |
* @since 1.0
|
669 |
+
* @param array|string $types
|
670 |
+
* @return array WP_Post objects
|
671 |
*/
|
672 |
+
public function get_notifications( $types ) {
|
673 |
+
if ( ! is_array( $types ) ) {
|
674 |
+
$types = array( $types );
|
675 |
+
}
|
676 |
+
|
677 |
$args = array(
|
678 |
'post_type' => self::POST_TYPE,
|
679 |
'meta_query' => array(
|
680 |
array(
|
681 |
'key' => self::META_KEY_PREFIX . 'notification',
|
682 |
+
'value' => $types,
|
683 |
+
'compare' => 'IN',
|
684 |
),
|
685 |
array(
|
686 |
'key' => self::META_KEY_PREFIX . 'disabled',
|
758 |
echo implode( ', ', $users );
|
759 |
break;
|
760 |
}
|
761 |
+
|
762 |
+
/**
|
763 |
+
* Invoked while displaying a custom column in notification table.
|
764 |
+
*
|
765 |
+
* @since 1.3.9
|
766 |
+
*
|
767 |
+
* @param string $column Column name
|
768 |
+
* @param int $post_id Post ID
|
769 |
+
*/
|
770 |
+
do_action( 'bnfw_notification_table_column', $column, $post_id );
|
771 |
}
|
772 |
|
773 |
/**
|
835 |
case 'admin-user':
|
836 |
$name = __( 'User Registration - For Admin', 'bnfw' );
|
837 |
break;
|
838 |
+
case 'user-role':
|
839 |
+
$name = __( 'User Role Changed', 'bnfw' );
|
840 |
+
break;
|
841 |
case 'new-post':
|
842 |
$name = __( 'New Post Published', 'bnfw' );
|
843 |
break;
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -131,6 +131,30 @@ class BNFW_Engine {
|
|
131 |
wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
|
132 |
}
|
133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
/**
|
135 |
* Handle shortcode for password reset email message.
|
136 |
*
|
@@ -151,10 +175,10 @@ class BNFW_Engine {
|
|
151 |
* Generate message for notification.
|
152 |
*
|
153 |
* @since 1.0
|
154 |
-
* @param
|
155 |
-
* @param
|
156 |
-
* @param
|
157 |
-
* @return
|
158 |
*/
|
159 |
private function handle_shortcodes( $message, $notification, $id ) {
|
160 |
switch ( $notification ) {
|
@@ -173,6 +197,7 @@ class BNFW_Engine {
|
|
173 |
case 'admin-user':
|
174 |
case 'welcome-email':
|
175 |
case 'new-user':
|
|
|
176 |
// handle users (lost password and new user registration)
|
177 |
$message = $this->user_shortcodes( $message, $id );
|
178 |
break;
|
@@ -437,6 +462,10 @@ class BNFW_Engine {
|
|
437 |
$user_ids = array();
|
438 |
$user_roles = array();
|
439 |
|
|
|
|
|
|
|
|
|
440 |
foreach ( $users as $user ) {
|
441 |
if ( $this->starts_with( $user, 'role-' ) ) {
|
442 |
$user_roles[] = str_replace( 'role-', '', $user );
|
131 |
wp_mail( $parent_comment->comment_author_email, stripslashes( $subject ), $message, $headers );
|
132 |
}
|
133 |
|
134 |
+
/**
|
135 |
+
* Send user role changed email.
|
136 |
+
*
|
137 |
+
* @since 1.3.9
|
138 |
+
* @param array $setting Notification setting
|
139 |
+
* @param object $user_id User ID
|
140 |
+
*/
|
141 |
+
public function send_user_role_chnaged_email( $setting, $user_id ) {
|
142 |
+
$subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
|
143 |
+
$message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $user_id );
|
144 |
+
|
145 |
+
$headers = array();
|
146 |
+
if ( 'html' == $setting['email-formatting'] ) {
|
147 |
+
$headers[] = 'Content-type: text/html';
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
|
151 |
+
$message = wpautop( $message );
|
152 |
+
}
|
153 |
+
|
154 |
+
$user = get_user_by( 'id', $user_id );
|
155 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
156 |
+
}
|
157 |
+
|
158 |
/**
|
159 |
* Handle shortcode for password reset email message.
|
160 |
*
|
175 |
* Generate message for notification.
|
176 |
*
|
177 |
* @since 1.0
|
178 |
+
* @param string $message
|
179 |
+
* @param string $notification
|
180 |
+
* @param int $id
|
181 |
+
* @return string
|
182 |
*/
|
183 |
private function handle_shortcodes( $message, $notification, $id ) {
|
184 |
switch ( $notification ) {
|
197 |
case 'admin-user':
|
198 |
case 'welcome-email':
|
199 |
case 'new-user':
|
200 |
+
case 'user-role':
|
201 |
// handle users (lost password and new user registration)
|
202 |
$message = $this->user_shortcodes( $message, $id );
|
203 |
break;
|
462 |
$user_ids = array();
|
463 |
$user_roles = array();
|
464 |
|
465 |
+
if ( empty( $users ) ) {
|
466 |
+
return array();
|
467 |
+
}
|
468 |
+
|
469 |
foreach ( $users as $user ) {
|
470 |
if ( $this->starts_with( $user, 'role-' ) ) {
|
471 |
$user_roles[] = str_replace( 'role-', '', $user );
|
includes/notification/post-notification.php
CHANGED
@@ -15,33 +15,11 @@
|
|
15 |
* @return array Filtered list of post notifications
|
16 |
*/
|
17 |
function bnfw_post_notifications( $notifications, $post_type ) {
|
18 |
-
$
|
19 |
-
$
|
20 |
-
|
21 |
-
$notifications[] =
|
22 |
-
|
23 |
-
'label' => 'New ' . $label . ' Published',
|
24 |
-
);
|
25 |
-
|
26 |
-
$notifications[] = array(
|
27 |
-
'type' => 'update-' . $post_type,
|
28 |
-
'label' => $label . ' Update',
|
29 |
-
);
|
30 |
-
|
31 |
-
$notifications[] = array(
|
32 |
-
'type' => 'pending-' . $post_type,
|
33 |
-
'label' => $label . ' Pending',
|
34 |
-
);
|
35 |
-
|
36 |
-
$notifications[] = array(
|
37 |
-
'type' => 'future-' . $post_type,
|
38 |
-
'label' => $label . ' Scheduled',
|
39 |
-
);
|
40 |
-
|
41 |
-
$notifications[] = array(
|
42 |
-
'type' => 'comment-' . $post_type,
|
43 |
-
'label' => $label . ' New Comment',
|
44 |
-
);
|
45 |
|
46 |
return $notifications;
|
47 |
}
|
15 |
* @return array Filtered list of post notifications
|
16 |
*/
|
17 |
function bnfw_post_notifications( $notifications, $post_type ) {
|
18 |
+
$notifications[] = 'new-' . $post_type;
|
19 |
+
$notifications[] = 'update-' . $post_type;
|
20 |
+
$notifications[] = 'pending-' . $post_type;
|
21 |
+
$notifications[] = 'future-' . $post_type;
|
22 |
+
$notifications[] = 'comment-' . $post_type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
return $notifications;
|
25 |
}
|