Version Description
- 12th December 2016 =
- Merry Christmas & Happy New Year!
- New: Anonymous tracking of the features you use in BNFW is now an opt-in checkbox on the Notifications > Settings page. Please consider checking this box to help make BNFW even better. You'll also receive a 10% off coupon code when you sign-up to the mailing list too.
- New: Notifications for privately published posts / pages / custom post types.
- New: Notification and accompanying shortcode for customising WordPress Core Automatic Background Updates (Success / Fail / Critical).
- New: Notification for User Password Changed.
- New: Notification for User Email Changed.
- New: Shortcodes for showing the old and new user role when used in conjunction with the User Role Changed notifications.
- New: You can now add a 'Reply To' name and email address in the Additional Email Fields for all notifications that support it.
- 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'.
- New: All transactional notifications can now be set to either HTML or Plain Text.
- New: Better compatibility with Theme My Login.
- Improved: Re-worded a checkbox to be more understandable. It did say, "Disable this Notification for the User that triggered it", but now says, "Do not send this Notification to the User that triggered it".
- Improved: Compatibility with Mashshare.
- Fixed: Global User Shortcodes weren't being outputted correctly in the 'Lost Password - For User' notification.
- Fixed: Child themes weren't being registered correctly in the filter when using the front-end forms filter.
- Fixed: The number of options within notifications was being limited to the number of blog posts WordPress was set to show.
- Fixed: The 'Shortcode Help' button wasn't linking to the BNFW website correctly for some BNFW add-ons.
Download this release
Release Info
Developer | voltronik |
Plugin | Better Notifications for WordPress |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5.3 to 1.6
- README.txt +30 -2
- assets/css/bnfw.css +4 -0
- assets/js/bnfw.js +43 -16
- bnfw.php +113 -6
- includes/admin/bnfw-settings.php +43 -5
- includes/admin/class-bnfw-notification.php +71 -17
- includes/engine/class-bnfw-engine.php +141 -23
- includes/helpers/helpers.php +15 -0
README.txt
CHANGED
@@ -3,8 +3,8 @@ 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.
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -34,6 +34,9 @@ Notifications that are currently available to use are:
|
|
34 |
* New Pingback
|
35 |
* Lost Password - For Admin
|
36 |
* New User Registration - For Admin
|
|
|
|
|
|
|
37 |
|
38 |
**Transactional**
|
39 |
|
@@ -49,6 +52,7 @@ Notifications that are currently available to use are:
|
|
49 |
* New Post Published
|
50 |
* Post Updated
|
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/))
|
@@ -58,6 +62,7 @@ Notifications that are currently available to use are:
|
|
58 |
* New Page Published
|
59 |
* Page Updated
|
60 |
* Page Pending Review
|
|
|
61 |
* Page Scheduled
|
62 |
* Page - New Comment
|
63 |
* Page - Comment Reply
|
@@ -120,6 +125,10 @@ Yes! There is an option for suppressing comments marked as SPAM by Akismet in th
|
|
120 |
|
121 |
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.
|
122 |
|
|
|
|
|
|
|
|
|
123 |
= What isn't this plugin? =
|
124 |
|
125 |
It's not designed to send out newsletters. There is no send-this-out-on-this-date style functionality included. There are many other great plugins available that you could use for that instead. Additionally, users cannot currently unsubscribe automatically from notifications so you'll have to work out how you manage unsubscribers manually.
|
@@ -178,6 +187,25 @@ An older version might work but this is untested. A lot of the newer features re
|
|
178 |
|
179 |
== Changelog ==
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
= 1.5.3 - 13th September 2016 =
|
182 |
* Fixed: User Roles in the 'User Roles / Users' admin column were being displayed only in lowercase.
|
183 |
* Fixed: The `[wp_capabilities]` shortcode wasn't outputting properly. It now displays the higher-level capabilities that the user has.
|
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.7
|
7 |
+
Stable tag: 1.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
34 |
* New Pingback
|
35 |
* Lost Password - For Admin
|
36 |
* New User Registration - For Admin
|
37 |
+
* User Password Changed
|
38 |
+
* User Email Changed
|
39 |
+
* WordPress Core Automatic Background Updates
|
40 |
|
41 |
**Transactional**
|
42 |
|
52 |
* New Post Published
|
53 |
* Post Updated
|
54 |
* Post Pending Review
|
55 |
+
* New Private Post
|
56 |
* Post Scheduled
|
57 |
* Post - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
58 |
* Post - Update Reminder ([Update Reminder Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
62 |
* New Page Published
|
63 |
* Page Updated
|
64 |
* Page Pending Review
|
65 |
+
* New Private Page
|
66 |
* Page Scheduled
|
67 |
* Page - New Comment
|
68 |
* Page - Comment Reply
|
125 |
|
126 |
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.
|
127 |
|
128 |
+
= Can I send notifications to email addresses that aren't WordPress users? =
|
129 |
+
|
130 |
+
No. This is to prevent SPAM and/or abuse of the plugin and to abide by anti-SPAM laws in various countries.
|
131 |
+
|
132 |
= What isn't this plugin? =
|
133 |
|
134 |
It's not designed to send out newsletters. There is no send-this-out-on-this-date style functionality included. There are many other great plugins available that you could use for that instead. Additionally, users cannot currently unsubscribe automatically from notifications so you'll have to work out how you manage unsubscribers manually.
|
187 |
|
188 |
== Changelog ==
|
189 |
|
190 |
+
= 1.6 - 12th December 2016 =
|
191 |
+
* Merry Christmas & Happy New Year!
|
192 |
+
* New: Anonymous tracking of the features you use in BNFW is now an opt-in checkbox on the Notifications > Settings page. Please consider checking this box to help make BNFW even better. You'll also receive a 10% off coupon code when you sign-up to the [mailing list](http://voltronik.us2.list-manage2.com/subscribe?u=57c012217219b2d81dda0085f&id=28eebdab28) too.
|
193 |
+
* New: Notifications for privately published posts / pages / custom post types.
|
194 |
+
* New: Notification and accompanying shortcode for customising WordPress Core Automatic Background Updates (Success / Fail / Critical).
|
195 |
+
* New: Notification for User Password Changed.
|
196 |
+
* New: Notification for User Email Changed.
|
197 |
+
* New: Shortcodes for showing the old and new user role when used in conjunction with the User Role Changed notifications.
|
198 |
+
* New: You can now add a 'Reply To' name and email address in the Additional Email Fields for all notifications that support it.
|
199 |
+
* 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'.
|
200 |
+
* New: All transactional notifications can now be set to either HTML or Plain Text.
|
201 |
+
* New: Better compatibility with [Theme My Login](https://en-gb.wordpress.org/plugins/theme-my-login/).
|
202 |
+
* Improved: Re-worded a checkbox to be more understandable. It did say, "Disable this Notification for the User that triggered it", but now says, "Do not send this Notification to the User that triggered it".
|
203 |
+
* Improved: Compatibility with Mashshare.
|
204 |
+
* Fixed: Global User Shortcodes weren't being outputted correctly in the 'Lost Password - For User' notification.
|
205 |
+
* Fixed: Child themes weren't being registered correctly in the filter when using the front-end forms filter.
|
206 |
+
* Fixed: The number of options within notifications was being limited to the number of blog posts WordPress was set to show.
|
207 |
+
* Fixed: The 'Shortcode Help' button wasn't linking to the BNFW website correctly for some BNFW add-ons.
|
208 |
+
|
209 |
= 1.5.3 - 13th September 2016 =
|
210 |
* Fixed: User Roles in the 'User Roles / Users' admin column were being displayed only in lowercase.
|
211 |
* Fixed: The `[wp_capabilities]` shortcode wasn't outputting properly. It now displays the higher-level capabilities that the user has.
|
assets/css/bnfw.css
CHANGED
@@ -16,6 +16,10 @@
|
|
16 |
padding: 15px;
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
19 |
/* Fix 'jump' when hovering over 'x' in select2 box */
|
20 |
/*ul.select2-choices li.select2-search-choice a {
|
21 |
-webkit-transition-property: none;
|
16 |
padding: 15px;
|
17 |
}
|
18 |
|
19 |
+
.manage-column.column-disabled {
|
20 |
+
width: 8% !important;
|
21 |
+
}
|
22 |
+
|
23 |
/* Fix 'jump' when hovering over 'x' in select2 box */
|
24 |
/*ul.select2-choices li.select2-search-choice a {
|
25 |
-webkit-transition-property: none;
|
assets/js/bnfw.js
CHANGED
@@ -3,9 +3,9 @@ jQuery(document).ready(function($) {
|
|
3 |
var show_fields = $('#show-fields').is(":checked");
|
4 |
|
5 |
if ( show_fields ) {
|
6 |
-
$('#email, #cc, #bcc').show();
|
7 |
} else {
|
8 |
-
$('#email, #cc, #bcc').hide();
|
9 |
}
|
10 |
}
|
11 |
|
@@ -15,6 +15,10 @@ jQuery(document).ready(function($) {
|
|
15 |
} else {
|
16 |
$( '#users, #current-user' ).show();
|
17 |
}
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
function init() {
|
@@ -47,17 +51,24 @@ jQuery(document).ready(function($) {
|
|
47 |
|
48 |
toggle_fields();
|
49 |
|
50 |
-
if ( '
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
$('#toggle-fields, #email, #cc, #bcc, #users, #current-user, #post-author').hide();
|
55 |
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
56 |
-
} else if ( 'new-comment' ===
|
57 |
-
|
|
|
|
|
58 |
toggle_fields();
|
59 |
toggle_users();
|
60 |
-
$('#user-password-msg').hide();
|
|
|
|
|
|
|
|
|
|
|
61 |
} else {
|
62 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
63 |
toggle_fields();
|
@@ -71,18 +82,23 @@ jQuery(document).ready(function($) {
|
|
71 |
var $this = $(this),
|
72 |
notification = $this.val();
|
73 |
|
74 |
-
if ( '
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
$('#toggle-fields, #email, #cc, #bcc, #users, #current-user, #post-author').hide();
|
79 |
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
80 |
-
} else if ( 'admin-password' ===
|
81 |
$('#post-author').hide();
|
82 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
|
83 |
$('#user-password-msg').hide();
|
84 |
toggle_fields();
|
85 |
toggle_users();
|
|
|
|
|
|
|
|
|
|
|
86 |
} else {
|
87 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
88 |
$('#user-password-msg').hide();
|
@@ -130,12 +146,15 @@ jQuery(document).ready(function($) {
|
|
130 |
case 'commentreply-page':
|
131 |
case 'user-password':
|
132 |
case 'admin-password':
|
|
|
|
|
133 |
case 'new-user':
|
134 |
case 'welcome-email':
|
135 |
case 'user-role':
|
136 |
case 'admin-role':
|
137 |
case 'admin-user':
|
138 |
case 'new-post':
|
|
|
139 |
case 'update-post':
|
140 |
case 'pending-post':
|
141 |
case 'future-post':
|
@@ -150,6 +169,7 @@ jQuery(document).ready(function($) {
|
|
150 |
case 'new':
|
151 |
case 'update':
|
152 |
case 'pending':
|
|
|
153 |
case 'future':
|
154 |
case 'comment':
|
155 |
notification_slug = splited[0] + '-post';
|
@@ -160,6 +180,13 @@ jQuery(document).ready(function($) {
|
|
160 |
case 'newterm':
|
161 |
notification_slug = 'newterm-category';
|
162 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
163 |
}
|
164 |
|
165 |
break;
|
3 |
var show_fields = $('#show-fields').is(":checked");
|
4 |
|
5 |
if ( show_fields ) {
|
6 |
+
$('#email, #cc, #bcc, #reply').show();
|
7 |
} else {
|
8 |
+
$('#email, #cc, #bcc, #reply').hide();
|
9 |
}
|
10 |
}
|
11 |
|
15 |
} else {
|
16 |
$( '#users, #current-user' ).show();
|
17 |
}
|
18 |
+
|
19 |
+
if ( 'new-comment' === $( '#notification' ).val() ) {
|
20 |
+
$( '#current-user' ).show();
|
21 |
+
}
|
22 |
}
|
23 |
|
24 |
function init() {
|
51 |
|
52 |
toggle_fields();
|
53 |
|
54 |
+
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
55 |
+
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
56 |
+
'user-role' === notification ) {
|
57 |
+
|
58 |
+
$('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
|
59 |
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
60 |
+
} else if ( 'new-comment' === notification || 'new-trackback' === notification || 'new-pingback' === notification ||
|
61 |
+
'admin-password' === notification || 'admin-user' === notification || 'admin-role' === notification ) {
|
62 |
+
|
63 |
+
$( '#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author' ).show();
|
64 |
toggle_fields();
|
65 |
toggle_users();
|
66 |
+
$( '#user-password-msg' ).hide();
|
67 |
+
} else if ( 'password-changed' === notification || 'email-changed' === notification || 'core-updated' === notification ) {
|
68 |
+
$( '#toggle-fields, #users, #email-formatting, #disable-autop' ).show();
|
69 |
+
toggle_fields();
|
70 |
+
toggle_users();
|
71 |
+
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
72 |
} else {
|
73 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
74 |
toggle_fields();
|
82 |
var $this = $(this),
|
83 |
notification = $this.val();
|
84 |
|
85 |
+
if ( 'reply-comment' === notification || notification.startsWith( 'commentreply-' ) ||
|
86 |
+
'new-user' === notification || 'welcome-email' === notification || 'user-password' === notification ||
|
87 |
+
'user-role' === notification ) {
|
88 |
+
|
89 |
+
$('#toggle-fields, #email, #cc, #bcc, #reply, #users, #current-user, #post-author').hide();
|
90 |
$('#user-password-msg, #disable-autop, #email-formatting').show();
|
91 |
+
} else if ( 'admin-password' === notification || 'admin-user' === notification || 'admin-role' === notification ) {
|
92 |
$('#post-author').hide();
|
93 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
|
94 |
$('#user-password-msg').hide();
|
95 |
toggle_fields();
|
96 |
toggle_users();
|
97 |
+
} else if ( 'password-changed' === notification || 'email-changed' === notification || 'core-updated' === notification ) {
|
98 |
+
$( '#toggle-fields, #users, #email-formatting, #disable-autop' ).show();
|
99 |
+
toggle_fields();
|
100 |
+
toggle_users();
|
101 |
+
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
102 |
} else {
|
103 |
$('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
104 |
$('#user-password-msg').hide();
|
146 |
case 'commentreply-page':
|
147 |
case 'user-password':
|
148 |
case 'admin-password':
|
149 |
+
case 'password-changed':
|
150 |
+
case 'email-changed':
|
151 |
case 'new-user':
|
152 |
case 'welcome-email':
|
153 |
case 'user-role':
|
154 |
case 'admin-role':
|
155 |
case 'admin-user':
|
156 |
case 'new-post':
|
157 |
+
case 'core-updated':
|
158 |
case 'update-post':
|
159 |
case 'pending-post':
|
160 |
case 'future-post':
|
169 |
case 'new':
|
170 |
case 'update':
|
171 |
case 'pending':
|
172 |
+
case 'private':
|
173 |
case 'future':
|
174 |
case 'comment':
|
175 |
notification_slug = splited[0] + '-post';
|
180 |
case 'newterm':
|
181 |
notification_slug = 'newterm-category';
|
182 |
break;
|
183 |
+
// ideally these should be in the add-ons. But hardcoding them here for now
|
184 |
+
case 'customfield':
|
185 |
+
notification_slug = 'customfield-post';
|
186 |
+
break;
|
187 |
+
case 'updatereminder':
|
188 |
+
notification_slug = 'updatereminder-post';
|
189 |
+
break;
|
190 |
}
|
191 |
|
192 |
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
|
@@ -121,15 +121,22 @@ class BNFW {
|
|
121 |
*/
|
122 |
$trigger_insert_post = apply_filters( 'bnfw_trigger_insert_post', false );
|
123 |
|
124 |
-
if ( in_array( $current_theme, $insert_post_themes ) || $trigger_insert_post ) {
|
125 |
add_action( 'wp_insert_post' , array( $this, 'insert_post' ), 10, 3 );
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
|
|
128 |
add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
|
129 |
add_action( 'future_to_publish' , array( $this, 'publish_post' ) );
|
130 |
add_action( 'pending_to_publish' , array( $this, 'publish_post' ) );
|
131 |
add_action( 'private_to_publish' , array( $this, 'publish_post' ) );
|
|
|
132 |
add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
|
|
|
133 |
add_action( 'init' , array( $this, 'custom_post_type_hooks' ), 100 );
|
134 |
add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
|
135 |
|
@@ -149,6 +156,11 @@ class BNFW {
|
|
149 |
add_action( 'lostpassword_post' , array( $this, 'on_lost_password' ) );
|
150 |
add_filter( 'retrieve_password_message' , array( $this, 'change_password_email_message' ), 10, 4 );
|
151 |
|
|
|
|
|
|
|
|
|
|
|
152 |
add_filter( 'plugin_action_links' , array( $this, 'plugin_action_links' ), 10, 4 );
|
153 |
add_action( 'shutdown' , array( $this, 'on_shutdown' ) );
|
154 |
}
|
@@ -233,6 +245,21 @@ class BNFW {
|
|
233 |
}
|
234 |
}
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
/**
|
237 |
* Fires when a post is updated.
|
238 |
*
|
@@ -371,8 +398,7 @@ class BNFW {
|
|
371 |
$setting = $this->notifier->read_settings( end( $notifications )->ID );
|
372 |
|
373 |
if ( '' === $user_data ) {
|
374 |
-
return $this->engine->
|
375 |
-
|
376 |
} else {
|
377 |
return $setting['subject'];
|
378 |
}
|
@@ -413,6 +439,75 @@ class BNFW {
|
|
413 |
return $message;
|
414 |
}
|
415 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
/**
|
417 |
* Set the email formatting to HTML.
|
418 |
*
|
@@ -467,10 +562,22 @@ class BNFW {
|
|
467 |
if ( ! empty( $old_role ) ) {
|
468 |
$notifications = $this->notifier->get_notifications( 'user-role' );
|
469 |
foreach ( $notifications as $notification ) {
|
470 |
-
$this->engine->send_user_role_changed_email(
|
|
|
|
|
|
|
|
|
|
|
471 |
}
|
472 |
|
473 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
}
|
476 |
|
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.6
|
7 |
* Author: Voltronik
|
8 |
* Author URI: https://betternotificationsforwp.com/
|
9 |
* Author Email: hello@betternotificationsforwp.com
|
121 |
*/
|
122 |
$trigger_insert_post = apply_filters( 'bnfw_trigger_insert_post', false );
|
123 |
|
124 |
+
if ( in_array( $current_theme->get( 'Name' ), $insert_post_themes ) || $trigger_insert_post ) {
|
125 |
add_action( 'wp_insert_post' , array( $this, 'insert_post' ), 10, 3 );
|
126 |
}
|
127 |
|
128 |
+
add_action( 'draft_to_private' , array( $this, 'private_post' ) );
|
129 |
+
add_action( 'future_to_private' , array( $this, 'private_post' ) );
|
130 |
+
add_action( 'pending_to_private' , array( $this, 'private_post' ) );
|
131 |
+
add_action( 'publish_to_private' , array( $this, 'private_post' ) );
|
132 |
+
|
133 |
add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
|
134 |
add_action( 'future_to_publish' , array( $this, 'publish_post' ) );
|
135 |
add_action( 'pending_to_publish' , array( $this, 'publish_post' ) );
|
136 |
add_action( 'private_to_publish' , array( $this, 'publish_post' ) );
|
137 |
+
|
138 |
add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
|
139 |
+
|
140 |
add_action( 'init' , array( $this, 'custom_post_type_hooks' ), 100 );
|
141 |
add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
|
142 |
|
156 |
add_action( 'lostpassword_post' , array( $this, 'on_lost_password' ) );
|
157 |
add_filter( 'retrieve_password_message' , array( $this, 'change_password_email_message' ), 10, 4 );
|
158 |
|
159 |
+
add_filter( 'password_change_email' , array( $this, 'on_password_changed' ), 10, 2 );
|
160 |
+
add_filter( 'email_change_email' , array( $this, 'on_email_changed' ), 10, 2 );
|
161 |
+
|
162 |
+
add_filter( 'auto_core_update_email' , array( $this, 'on_core_updated' ), 10, 4 );
|
163 |
+
|
164 |
add_filter( 'plugin_action_links' , array( $this, 'plugin_action_links' ), 10, 4 );
|
165 |
add_action( 'shutdown' , array( $this, 'on_shutdown' ) );
|
166 |
}
|
245 |
}
|
246 |
}
|
247 |
|
248 |
+
/**
|
249 |
+
* Fires when a private post is created.
|
250 |
+
*
|
251 |
+
* @since 1.6
|
252 |
+
* @param object $post Post Object
|
253 |
+
*/
|
254 |
+
public function private_post( $post ) {
|
255 |
+
$post_id = $post->ID;
|
256 |
+
$post_type = $post->post_type;
|
257 |
+
|
258 |
+
if ( BNFW_Notification::POST_TYPE != $post_type ) {
|
259 |
+
$this->send_notification_async( 'private-' . $post_type, $post_id );
|
260 |
+
}
|
261 |
+
}
|
262 |
+
|
263 |
/**
|
264 |
* Fires when a post is updated.
|
265 |
*
|
398 |
$setting = $this->notifier->read_settings( end( $notifications )->ID );
|
399 |
|
400 |
if ( '' === $user_data ) {
|
401 |
+
return $this->engine->handle_shortcodes( $setting['subject'], 'user-password', $user_data->ID );
|
|
|
402 |
} else {
|
403 |
return $setting['subject'];
|
404 |
}
|
439 |
return $message;
|
440 |
}
|
441 |
|
442 |
+
/**
|
443 |
+
* On Password Changed.
|
444 |
+
*
|
445 |
+
* @since 1.6
|
446 |
+
*
|
447 |
+
* @param array $email_data Email Data.
|
448 |
+
* @param array $user User data.
|
449 |
+
*
|
450 |
+
* @return array Modified Email Data
|
451 |
+
*/
|
452 |
+
public function on_password_changed( $email_data, $user ) {
|
453 |
+
return $this->handle_filtered_data_notification( 'password-changed', $email_data, $user['ID'] );
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* On Email Changed.
|
458 |
+
*
|
459 |
+
* @since 1.6
|
460 |
+
*
|
461 |
+
* @param array $email_data Email Data.
|
462 |
+
* @param array $user User data.
|
463 |
+
*
|
464 |
+
* @return array Modified Email Data
|
465 |
+
*/
|
466 |
+
public function on_email_changed( $email_data, $user ) {
|
467 |
+
return $this->handle_filtered_data_notification( 'email-changed', $email_data, $user['ID'] );
|
468 |
+
}
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Send notification on core updated event.
|
472 |
+
*
|
473 |
+
* @since 1.6
|
474 |
+
*
|
475 |
+
* @param array $email_data Email Data.
|
476 |
+
* @param string $type The type of email being sent. Can be one of
|
477 |
+
* 'success', 'fail', 'manual', 'critical'.
|
478 |
+
* @param object $core_update The update offer that was attempted.
|
479 |
+
* @param mixed $result The result for the core update. Can be WP_Error.
|
480 |
+
*
|
481 |
+
* @return array Modified Email Data.
|
482 |
+
*/
|
483 |
+
public function on_core_updated( $email_data, $type, $core_update, $result ) {
|
484 |
+
return $this->handle_filtered_data_notification( 'core-updated', $email_data, $type );
|
485 |
+
}
|
486 |
+
|
487 |
+
/**
|
488 |
+
* Process User update notifications.
|
489 |
+
*
|
490 |
+
* @since 1.6
|
491 |
+
*
|
492 |
+
* @param string $notification_name Notification Name.
|
493 |
+
* @param array $email_data Email Data.
|
494 |
+
* @param string|int $extra_data User Id.
|
495 |
+
*
|
496 |
+
* @return array Modified Email Data.
|
497 |
+
*/
|
498 |
+
private function handle_filtered_data_notification( $notification_name, $email_data, $extra_data ) {
|
499 |
+
$notifications = $this->notifier->get_notifications( $notification_name );
|
500 |
+
if ( count( $notifications ) > 0 ) {
|
501 |
+
// Ideally there should be only one notification for this type.
|
502 |
+
// If there are multiple notification then we will read data about only the last one
|
503 |
+
$setting = $this->notifier->read_settings( end( $notifications )->ID );
|
504 |
+
|
505 |
+
$email_data = $this->engine->handle_filtered_data_notification( $email_data, $setting, $extra_data );
|
506 |
+
}
|
507 |
+
|
508 |
+
return $email_data;
|
509 |
+
}
|
510 |
+
|
511 |
/**
|
512 |
* Set the email formatting to HTML.
|
513 |
*
|
562 |
if ( ! empty( $old_role ) ) {
|
563 |
$notifications = $this->notifier->get_notifications( 'user-role' );
|
564 |
foreach ( $notifications as $notification ) {
|
565 |
+
$this->engine->send_user_role_changed_email(
|
566 |
+
$this->notifier->read_settings( $notification->ID ),
|
567 |
+
$user_id,
|
568 |
+
$old_role[0],
|
569 |
+
$new_role
|
570 |
+
);
|
571 |
}
|
572 |
|
573 |
+
$notifications = $this->notifier->get_notifications( 'admin-role' );
|
574 |
+
foreach ( $notifications as $notification ) {
|
575 |
+
$setting = $this->notifier->read_settings( $notification->ID );
|
576 |
+
$setting['message'] = $this->engine->handle_user_role_shortcodes( $setting['message'], $old_role[0], $new_role );
|
577 |
+
$setting['subject'] = $this->engine->handle_user_role_shortcodes( $setting['subject'], $old_role[0], $new_role );
|
578 |
+
|
579 |
+
$this->engine->send_notification( $setting , $user_id );
|
580 |
+
}
|
581 |
}
|
582 |
}
|
583 |
|
includes/admin/bnfw-settings.php
CHANGED
@@ -58,18 +58,26 @@ function bnfw_menu_item_links() {
|
|
58 |
global $submenu;
|
59 |
|
60 |
if ( current_user_can( 'manage_options' ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
// Documentation Link
|
62 |
$submenu['edit.php?post_type=bnfw_notification'][500] = array(
|
63 |
'<div id="bnfw-menu-item-documentation" style="color: #73daeb;">Documentation</div>',
|
64 |
'manage_options',
|
65 |
-
|
66 |
);
|
67 |
|
68 |
// Add-ons Link
|
69 |
$submenu['edit.php?post_type=bnfw_notification'][600] = array(
|
70 |
'<div id="bnfw-menu-item-addons" style="color: #ff6f59;">Add-ons</div>',
|
71 |
'manage_options',
|
72 |
-
|
73 |
);
|
74 |
}
|
75 |
}
|
@@ -131,13 +139,12 @@ function bnfw_general_options() {
|
|
131 |
)
|
132 |
);
|
133 |
|
134 |
-
// Register -
|
135 |
register_setting(
|
136 |
'bnfw-settings',
|
137 |
'bnfw_email_format'
|
138 |
);
|
139 |
|
140 |
-
// Suppress notifications for SPAM comments
|
141 |
add_settings_field(
|
142 |
'bnfw_email_format', // Field ID
|
143 |
esc_html__( 'Default Email Format', 'bnfw' ), // Label to the left
|
@@ -149,6 +156,22 @@ function bnfw_general_options() {
|
|
149 |
)
|
150 |
);
|
151 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
add_action( 'admin_init', 'bnfw_general_options', 10 );
|
@@ -201,6 +224,21 @@ function bnfw_email_format_radio( $args ) {
|
|
201 |
<input type="radio" value="text"
|
202 |
name="bnfw_email_format" <?php checked( $email_format, 'text', true ); ?>><?php esc_html_e( 'Plain Text', 'bnfw' ); ?>
|
203 |
</label>
|
204 |
-
<p><i><?php echo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
<?php
|
206 |
}
|
58 |
global $submenu;
|
59 |
|
60 |
if ( current_user_can( 'manage_options' ) ) {
|
61 |
+
$doc_url = 'https://betternotificationsforwp.com/documentation/';
|
62 |
+
$store_url = 'https://betternotificationsforwp.com/store/';
|
63 |
+
|
64 |
+
if ( bnfw_is_tracking_allowed() ) {
|
65 |
+
$doc_url .= '?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Documentation"&utm_medium=referral';
|
66 |
+
$store_url .= '?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Add-on"&utm_medium=referral';
|
67 |
+
}
|
68 |
+
|
69 |
// Documentation Link
|
70 |
$submenu['edit.php?post_type=bnfw_notification'][500] = array(
|
71 |
'<div id="bnfw-menu-item-documentation" style="color: #73daeb;">Documentation</div>',
|
72 |
'manage_options',
|
73 |
+
$doc_url,
|
74 |
);
|
75 |
|
76 |
// Add-ons Link
|
77 |
$submenu['edit.php?post_type=bnfw_notification'][600] = array(
|
78 |
'<div id="bnfw-menu-item-addons" style="color: #ff6f59;">Add-ons</div>',
|
79 |
'manage_options',
|
80 |
+
$store_url,
|
81 |
);
|
82 |
}
|
83 |
}
|
139 |
)
|
140 |
);
|
141 |
|
142 |
+
// Register - Email Format setting
|
143 |
register_setting(
|
144 |
'bnfw-settings',
|
145 |
'bnfw_email_format'
|
146 |
);
|
147 |
|
|
|
148 |
add_settings_field(
|
149 |
'bnfw_email_format', // Field ID
|
150 |
esc_html__( 'Default Email Format', 'bnfw' ), // Label to the left
|
156 |
)
|
157 |
);
|
158 |
|
159 |
+
// Register - Allow tracking setting
|
160 |
+
register_setting(
|
161 |
+
'bnfw-settings',
|
162 |
+
'bnfw_allow_tracking'
|
163 |
+
);
|
164 |
+
|
165 |
+
add_settings_field(
|
166 |
+
'bnfw_allow_tracking', // Field ID
|
167 |
+
esc_html__( 'Allow Usage Tracking?', 'bnfw' ), // Label to the left
|
168 |
+
'bnfw_render_allow_tracking', // Name of function that renders options on the page
|
169 |
+
'bnfw-settings', // Page to show on
|
170 |
+
'bnfw_general_options_section', // Associate with which settings section?
|
171 |
+
array(
|
172 |
+
esc_html__( 'Allow Better Notifications for WordPress to anonymously track how this plugin is used and help make the plugin better. Opt-in to tracking and the mailing list and instantly receive a coupon code worth 10% off any BNFW add-on via email. You can opt-out and unsubscribe at any time.', 'bnfw' )
|
173 |
+
)
|
174 |
+
);
|
175 |
}
|
176 |
|
177 |
add_action( 'admin_init', 'bnfw_general_options', 10 );
|
224 |
<input type="radio" value="text"
|
225 |
name="bnfw_email_format" <?php checked( $email_format, 'text', true ); ?>><?php esc_html_e( 'Plain Text', 'bnfw' ); ?>
|
226 |
</label>
|
227 |
+
<p><i><?php echo $args[0]; ?></i></p>
|
228 |
+
<?php
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* Render allow tracking checkbox.
|
233 |
+
*
|
234 |
+
* @since 1.6
|
235 |
+
*
|
236 |
+
* @param array $args
|
237 |
+
*/
|
238 |
+
function bnfw_render_allow_tracking( $args ) {
|
239 |
+
?>
|
240 |
+
<input type="checkbox" id="bnfw_allow_tracking" name="bnfw_allow_tracking"
|
241 |
+
value="on" <?php checked( 'on', get_option( 'bnfw_allow_tracking' ), true ); ?>>
|
242 |
+
<label for="bnfw_allow_tracking"><?php echo esc_html( $args[0] ); ?></label>
|
243 |
<?php
|
244 |
}
|
includes/admin/class-bnfw-notification.php
CHANGED
@@ -164,6 +164,12 @@ class BNFW_Notification {
|
|
164 |
value="admin-password" <?php selected( 'admin-password', $setting['notification'] ); ?>><?php esc_html_e( 'Lost Password - For Admin', 'bnfw' ); ?></option>
|
165 |
<option
|
166 |
value="admin-user" <?php selected( 'admin-user', $setting['notification'] ); ?>><?php esc_html_e( 'New User Registration - For Admin', 'bnfw' ); ?></option>
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
</optgroup>
|
168 |
<optgroup label="Transactional">
|
169 |
<option
|
@@ -186,6 +192,8 @@ class BNFW_Notification {
|
|
186 |
value="update-post" <?php selected( 'update-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Updated', 'bnfw' ); ?></option>
|
187 |
<option
|
188 |
value="pending-post" <?php selected( 'pending-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Pending Review', 'bnfw' ); ?></option>
|
|
|
|
|
189 |
<option
|
190 |
value="future-post" <?php selected( 'future-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Scheduled', 'bnfw' ); ?></option>
|
191 |
<option
|
@@ -201,6 +209,8 @@ class BNFW_Notification {
|
|
201 |
value="update-page" <?php selected( 'update-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Updated', 'bnfw' ); ?></option>
|
202 |
<option
|
203 |
value="pending-page" <?php selected( 'pending-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Pending Review', 'bnfw' ); ?></option>
|
|
|
|
|
204 |
<option
|
205 |
value="future-page" <?php selected( 'future-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Scheduled', 'bnfw' ); ?></option>
|
206 |
<option
|
@@ -229,6 +239,8 @@ class BNFW_Notification {
|
|
229 |
value="update-<?php echo esc_attr( $type ); ?>" <?php selected( 'update-' . $type, $setting['notification'] ); ?>><?php echo "'$label' " . esc_html__( 'Update ', 'bnfw' ); ?></option>
|
230 |
<option
|
231 |
value="pending-<?php echo esc_attr( $type ); ?>" <?php selected( 'pending-' . $type, $setting['notification'] ); ?>><?php echo "'$label' ", esc_html__( 'Pending Review', 'bnfw' ); ?></option>
|
|
|
|
|
232 |
<option
|
233 |
value="future-<?php echo esc_attr( $type ); ?>" <?php selected( 'future-' . $type, $setting['notification'] ); ?>><?php echo "'$label' ", esc_html__( 'Scheduled', 'bnfw' ); ?></option>
|
234 |
<option
|
@@ -306,7 +318,7 @@ class BNFW_Notification {
|
|
306 |
<td>
|
307 |
<input type="checkbox" id="show-fields" name="show-fields"
|
308 |
value="true" <?php checked( $setting['show-fields'], 'true', true ); ?>>
|
309 |
-
<label for="show-fields"><?php esc_html_e( 'Set "From" Name & Email, CC, BCC', 'bnfw' ); ?></label>
|
310 |
</td>
|
311 |
</tr>
|
312 |
|
@@ -322,6 +334,18 @@ class BNFW_Notification {
|
|
322 |
</td>
|
323 |
</tr>
|
324 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
<tr valign="top" id="cc">
|
326 |
<th scope="row">
|
327 |
<?php esc_html_e( 'CC', 'bnfw' ); ?>
|
@@ -359,6 +383,17 @@ class BNFW_Notification {
|
|
359 |
</td>
|
360 |
</tr>
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
<tr valign="top" id="users">
|
363 |
<th scope="row">
|
364 |
<?php esc_html_e( 'Send To', 'bnfw' ); ?>
|
@@ -372,17 +407,6 @@ class BNFW_Notification {
|
|
372 |
</td>
|
373 |
</tr>
|
374 |
|
375 |
-
<tr valign="top" id="current-user">
|
376 |
-
<th></th>
|
377 |
-
<td>
|
378 |
-
<label>
|
379 |
-
<input type="checkbox" name="disable-current-user"
|
380 |
-
value="true" <?php checked( 'true', $setting['disable-current-user'] ); ?>>
|
381 |
-
<?php esc_html_e( 'Disable this Notification for the User that triggered it', 'bnfw' ); ?>
|
382 |
-
</label>
|
383 |
-
</td>
|
384 |
-
</tr>
|
385 |
-
|
386 |
<tr valign="top">
|
387 |
<th scope="row">
|
388 |
<?php esc_html_e( 'Subject', 'bnfw' ); ?>
|
@@ -402,8 +426,15 @@ class BNFW_Notification {
|
|
402 |
<span
|
403 |
class="dashicons dashicons-editor-help"></span> <?php esc_html_e( 'Need some help?', 'bnfw' ); ?>
|
404 |
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
405 |
<p>
|
406 |
-
<a href="
|
407 |
target="_blank" class="button-secondary"><?php esc_html_e( 'Documentation', 'bnfw' ); ?></a>
|
408 |
</p>
|
409 |
<p>
|
@@ -600,6 +631,8 @@ class BNFW_Notification {
|
|
600 |
'notification' => '',
|
601 |
'from-name' => '',
|
602 |
'from-email' => '',
|
|
|
|
|
603 |
'cc' => array(),
|
604 |
'bcc' => array(),
|
605 |
'users' => array(),
|
@@ -761,6 +794,9 @@ class BNFW_Notification {
|
|
761 |
);
|
762 |
}
|
763 |
|
|
|
|
|
|
|
764 |
$wp_query = new WP_Query();
|
765 |
$posts = $wp_query->query( $args );
|
766 |
|
@@ -824,7 +860,7 @@ class BNFW_Notification {
|
|
824 |
}
|
825 |
break;
|
826 |
case 'type':
|
827 |
-
echo $this->
|
828 |
break;
|
829 |
case 'subject':
|
830 |
echo ! empty( $setting['subject'] ) ? $setting['subject'] : '';
|
@@ -881,11 +917,11 @@ class BNFW_Notification {
|
|
881 |
/**
|
882 |
* Get name of the notification based on slug.
|
883 |
*
|
884 |
-
* @param
|
885 |
*
|
886 |
-
* @return
|
887 |
*/
|
888 |
-
private function
|
889 |
$name = '';
|
890 |
switch ( $slug ) {
|
891 |
case 'new-comment':
|
@@ -906,6 +942,15 @@ class BNFW_Notification {
|
|
906 |
case 'admin-password':
|
907 |
$name = esc_html__( 'Lost Password - For Admin', 'bnfw' );
|
908 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
909 |
case 'new-user':
|
910 |
$name = esc_html__( 'New User Registration - For User', 'bnfw' );
|
911 |
break;
|
@@ -930,9 +975,15 @@ class BNFW_Notification {
|
|
930 |
case 'pending-post':
|
931 |
$name = esc_html__( 'Post Pending Review', 'bnfw' );
|
932 |
break;
|
|
|
|
|
|
|
933 |
case 'future-post':
|
934 |
$name = esc_html__( 'Post Scheduled', 'bnfw' );
|
935 |
break;
|
|
|
|
|
|
|
936 |
case 'newterm-category':
|
937 |
$name = esc_html__( 'New Category', 'bnfw' );
|
938 |
break;
|
@@ -961,6 +1012,9 @@ class BNFW_Notification {
|
|
961 |
case 'future':
|
962 |
$name = $label . esc_html__( ' Scheduled', 'bnfw' );
|
963 |
break;
|
|
|
|
|
|
|
964 |
case 'comment':
|
965 |
$name = $label . esc_html__( ' Comment', 'bnfw' );
|
966 |
break;
|
164 |
value="admin-password" <?php selected( 'admin-password', $setting['notification'] ); ?>><?php esc_html_e( 'Lost Password - For Admin', 'bnfw' ); ?></option>
|
165 |
<option
|
166 |
value="admin-user" <?php selected( 'admin-user', $setting['notification'] ); ?>><?php esc_html_e( 'New User Registration - For Admin', 'bnfw' ); ?></option>
|
167 |
+
<option
|
168 |
+
value="password-changed" <?php selected( 'password-changed', $setting['notification'] ); ?>><?php esc_html_e( 'User Password Changed', 'bnfw' ); ?></option>
|
169 |
+
<option
|
170 |
+
value="email-changed" <?php selected( 'email-changed', $setting['notification'] ); ?>><?php esc_html_e( 'User Email Changed', 'bnfw' ); ?></option>
|
171 |
+
<option
|
172 |
+
value="core-updated" <?php selected( 'core-updated', $setting['notification'] ); ?>><?php esc_html_e( 'WordPress Core Automatic Background Updates', 'bnfw' ); ?></option>
|
173 |
</optgroup>
|
174 |
<optgroup label="Transactional">
|
175 |
<option
|
192 |
value="update-post" <?php selected( 'update-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Updated', 'bnfw' ); ?></option>
|
193 |
<option
|
194 |
value="pending-post" <?php selected( 'pending-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Pending Review', 'bnfw' ); ?></option>
|
195 |
+
<option
|
196 |
+
value="private-post" <?php selected( 'private-post', $setting['notification'] ); ?>><?php esc_html_e( 'New Private Post', 'bnfw' ); ?></option>
|
197 |
<option
|
198 |
value="future-post" <?php selected( 'future-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Scheduled', 'bnfw' ); ?></option>
|
199 |
<option
|
209 |
value="update-page" <?php selected( 'update-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Updated', 'bnfw' ); ?></option>
|
210 |
<option
|
211 |
value="pending-page" <?php selected( 'pending-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Pending Review', 'bnfw' ); ?></option>
|
212 |
+
<option
|
213 |
+
value="private-page" <?php selected( 'private-page', $setting['notification'] ); ?>><?php esc_html_e( 'New Private Page', 'bnfw' ); ?></option>
|
214 |
<option
|
215 |
value="future-page" <?php selected( 'future-page', $setting['notification'] ); ?>><?php esc_html_e( 'Page Scheduled', 'bnfw' ); ?></option>
|
216 |
<option
|
239 |
value="update-<?php echo esc_attr( $type ); ?>" <?php selected( 'update-' . $type, $setting['notification'] ); ?>><?php echo "'$label' " . esc_html__( 'Update ', 'bnfw' ); ?></option>
|
240 |
<option
|
241 |
value="pending-<?php echo esc_attr( $type ); ?>" <?php selected( 'pending-' . $type, $setting['notification'] ); ?>><?php echo "'$label' ", esc_html__( 'Pending Review', 'bnfw' ); ?></option>
|
242 |
+
<option
|
243 |
+
value="private-<?php echo esc_attr( $type ); ?>" <?php selected( 'private-' . $type, $setting['notification'] ); ?>><?php echo esc_html__( 'New Private ', 'bnfw' ), "'$label'"; ?></option>
|
244 |
<option
|
245 |
value="future-<?php echo esc_attr( $type ); ?>" <?php selected( 'future-' . $type, $setting['notification'] ); ?>><?php echo "'$label' ", esc_html__( 'Scheduled', 'bnfw' ); ?></option>
|
246 |
<option
|
318 |
<td>
|
319 |
<input type="checkbox" id="show-fields" name="show-fields"
|
320 |
value="true" <?php checked( $setting['show-fields'], 'true', true ); ?>>
|
321 |
+
<label for="show-fields"><?php esc_html_e( 'Set "From" Name & Email, Reply To, CC, BCC', 'bnfw' ); ?></label>
|
322 |
</td>
|
323 |
</tr>
|
324 |
|
334 |
</td>
|
335 |
</tr>
|
336 |
|
337 |
+
<tr valign="top" id="reply">
|
338 |
+
<th scope="row">
|
339 |
+
<?php esc_html_e( 'Reply To', 'bnfw' ); ?>
|
340 |
+
</th>
|
341 |
+
<td>
|
342 |
+
<input type="text" name="reply-name" value="<?php echo esc_attr( $setting['reply-name'] ); ?>"
|
343 |
+
placeholder="Name" style="width: 37.35%">
|
344 |
+
<input type="email" name="reply-email" value="<?php echo esc_attr( $setting['reply-email'] ); ?>"
|
345 |
+
placeholder="Email" style="width: 37.3%">
|
346 |
+
</td>
|
347 |
+
</tr>
|
348 |
+
|
349 |
<tr valign="top" id="cc">
|
350 |
<th scope="row">
|
351 |
<?php esc_html_e( 'CC', 'bnfw' ); ?>
|
383 |
</td>
|
384 |
</tr>
|
385 |
|
386 |
+
<tr valign="top" id="current-user">
|
387 |
+
<th></th>
|
388 |
+
<td>
|
389 |
+
<label>
|
390 |
+
<input type="checkbox" name="disable-current-user"
|
391 |
+
value="true" <?php checked( 'true', $setting['disable-current-user'] ); ?>>
|
392 |
+
<?php esc_html_e( 'Do not send this Notification to the User that triggered it', 'bnfw' ); ?>
|
393 |
+
</label>
|
394 |
+
</td>
|
395 |
+
</tr>
|
396 |
+
|
397 |
<tr valign="top" id="users">
|
398 |
<th scope="row">
|
399 |
<?php esc_html_e( 'Send To', 'bnfw' ); ?>
|
407 |
</td>
|
408 |
</tr>
|
409 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
410 |
<tr valign="top">
|
411 |
<th scope="row">
|
412 |
<?php esc_html_e( 'Subject', 'bnfw' ); ?>
|
426 |
<span
|
427 |
class="dashicons dashicons-editor-help"></span> <?php esc_html_e( 'Need some help?', 'bnfw' ); ?>
|
428 |
</p>
|
429 |
+
<?php
|
430 |
+
$doc_url = 'https://betternotificationsforwp.com/documentation/';
|
431 |
+
|
432 |
+
if ( bnfw_is_tracking_allowed() ) {
|
433 |
+
$doc_url .= "?utm_source=WP%20Admin%20Notification%20Editor%20-%20'Documentation'&utm_medium=referral";
|
434 |
+
}
|
435 |
+
?>
|
436 |
<p>
|
437 |
+
<a href="<?php echo $doc_url; ?>"
|
438 |
target="_blank" class="button-secondary"><?php esc_html_e( 'Documentation', 'bnfw' ); ?></a>
|
439 |
</p>
|
440 |
<p>
|
631 |
'notification' => '',
|
632 |
'from-name' => '',
|
633 |
'from-email' => '',
|
634 |
+
'reply-name' => '',
|
635 |
+
'reply-email' => '',
|
636 |
'cc' => array(),
|
637 |
'bcc' => array(),
|
638 |
'users' => array(),
|
794 |
);
|
795 |
}
|
796 |
|
797 |
+
$args['posts_per_page'] = -1;
|
798 |
+
$args['nopagging'] = true;
|
799 |
+
|
800 |
$wp_query = new WP_Query();
|
801 |
$posts = $wp_query->query( $args );
|
802 |
|
860 |
}
|
861 |
break;
|
862 |
case 'type':
|
863 |
+
echo $this->get_notification_name( $setting['notification'] );
|
864 |
break;
|
865 |
case 'subject':
|
866 |
echo ! empty( $setting['subject'] ) ? $setting['subject'] : '';
|
917 |
/**
|
918 |
* Get name of the notification based on slug.
|
919 |
*
|
920 |
+
* @param string $slug Notification Slug.
|
921 |
*
|
922 |
+
* @return string Notification Name.
|
923 |
*/
|
924 |
+
private function get_notification_name( $slug ) {
|
925 |
$name = '';
|
926 |
switch ( $slug ) {
|
927 |
case 'new-comment':
|
942 |
case 'admin-password':
|
943 |
$name = esc_html__( 'Lost Password - For Admin', 'bnfw' );
|
944 |
break;
|
945 |
+
case 'password-changed':
|
946 |
+
$name = esc_html__( 'User Password Changed', 'bnfw' );
|
947 |
+
break;
|
948 |
+
case 'email-changed':
|
949 |
+
$name = esc_html__( 'User Email Changed', 'bnfw' );
|
950 |
+
break;
|
951 |
+
case 'core-updated':
|
952 |
+
$name = esc_html__( 'WordPress Core Automatic Background Updates', 'bnfw' );
|
953 |
+
break;
|
954 |
case 'new-user':
|
955 |
$name = esc_html__( 'New User Registration - For User', 'bnfw' );
|
956 |
break;
|
975 |
case 'pending-post':
|
976 |
$name = esc_html__( 'Post Pending Review', 'bnfw' );
|
977 |
break;
|
978 |
+
case 'private-post':
|
979 |
+
$name = esc_html__( 'New Private Post', 'bnfw' );
|
980 |
+
break;
|
981 |
case 'future-post':
|
982 |
$name = esc_html__( 'Post Scheduled', 'bnfw' );
|
983 |
break;
|
984 |
+
case 'new-page':
|
985 |
+
$name = esc_html__( 'New Page Published', 'bnfw' );
|
986 |
+
break;
|
987 |
case 'newterm-category':
|
988 |
$name = esc_html__( 'New Category', 'bnfw' );
|
989 |
break;
|
1012 |
case 'future':
|
1013 |
$name = $label . esc_html__( ' Scheduled', 'bnfw' );
|
1014 |
break;
|
1015 |
+
case 'private':
|
1016 |
+
$name = esc_html__( 'New Private ', 'bnfw' ) . $label;
|
1017 |
+
break;
|
1018 |
case 'comment':
|
1019 |
$name = $label . esc_html__( ' Comment', 'bnfw' );
|
1020 |
break;
|
includes/engine/class-bnfw-engine.php
CHANGED
@@ -155,11 +155,16 @@ class BNFW_Engine {
|
|
155 |
*
|
156 |
* @param array $setting Notification setting
|
157 |
* @param int $user_id User ID
|
|
|
|
|
158 |
*/
|
159 |
-
public function send_user_role_changed_email( $setting, $user_id ) {
|
160 |
$subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
|
161 |
$message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $user_id );
|
162 |
|
|
|
|
|
|
|
163 |
$headers = array();
|
164 |
if ( 'html' == $setting['email-formatting'] ) {
|
165 |
$headers[] = 'Content-type: text/html';
|
@@ -176,19 +181,92 @@ class BNFW_Engine {
|
|
176 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
/**
|
180 |
* Handle shortcode for password reset email message.
|
181 |
*
|
182 |
* @since 1.1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
*/
|
184 |
public function handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data ) {
|
|
|
|
|
185 |
if ( '' != $user_login ) {
|
186 |
// For WordPress version 4.1.0 or less, we could have empty user_login
|
187 |
-
$message = $this->
|
|
|
188 |
|
189 |
$reset_link = wp_login_url() . "?action=rp&key=$key&login=$user_login";
|
190 |
$message = str_replace( '[password_reset_link]', $reset_link, $message );
|
191 |
}
|
|
|
192 |
return $message;
|
193 |
}
|
194 |
|
@@ -196,20 +274,23 @@ class BNFW_Engine {
|
|
196 |
* Generate message for notification.
|
197 |
*
|
198 |
* @since 1.0
|
199 |
-
* @
|
200 |
-
*
|
201 |
-
* @param
|
202 |
-
* @
|
|
|
|
|
|
|
203 |
*/
|
204 |
-
|
205 |
switch ( $notification ) {
|
206 |
case 'new-comment':
|
207 |
case 'new-trackback':
|
208 |
case 'new-pingback':
|
209 |
case 'reply-comment':
|
210 |
// handle new comments, trackbacks and pingbacks
|
211 |
-
$message = $this->comment_shortcodes( $message, $
|
212 |
-
$comment = get_comment( $
|
213 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
214 |
if ( 0 != $comment->user_id ) {
|
215 |
$message = $this->user_shortcodes( $message, $comment->user_id );
|
@@ -223,39 +304,46 @@ class BNFW_Engine {
|
|
223 |
case 'new-user':
|
224 |
case 'user-role':
|
225 |
case 'admin-role':
|
|
|
|
|
226 |
// handle users (lost password and new user registration)
|
227 |
-
$message = $this->user_shortcodes( $message, $
|
228 |
break;
|
229 |
|
230 |
case 'new-category':
|
231 |
// handle new category
|
232 |
-
$message = $this->taxonomy_shortcodes( $message, 'category', $
|
233 |
break;
|
234 |
|
235 |
case 'new-post_tag':
|
236 |
// handle new tag
|
237 |
-
$message = $this->taxonomy_shortcodes( $message, 'post_tag', $
|
|
|
|
|
|
|
|
|
|
|
238 |
break;
|
239 |
|
240 |
default:
|
241 |
$type = explode( '-', $notification, 2 );
|
242 |
if ( 'newterm' == $type[0] ) {
|
243 |
// handle new terms
|
244 |
-
$message = $this->taxonomy_shortcodes( $message, $type[1], $
|
245 |
|
246 |
-
} else if ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] ) {
|
247 |
// handle new, update and pending posts
|
248 |
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
249 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
250 |
|
251 |
if ( in_array( $type[1], $post_types ) ) {
|
252 |
-
$message = $this->post_shortcodes( $message, $
|
253 |
-
$post = get_post( $
|
254 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
255 |
}
|
256 |
} else if ( 'comment' == $type[0] || 'commentreply' == $type[0] ) {
|
257 |
-
$message = $this->comment_shortcodes( $message, $
|
258 |
-
$comment = get_comment( $
|
259 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
260 |
if ( 0 != $comment->user_id ) {
|
261 |
$message = $this->user_shortcodes( $message, $comment->user_id );
|
@@ -266,7 +354,7 @@ class BNFW_Engine {
|
|
266 |
|
267 |
$message = $this->global_shortcodes( $message );
|
268 |
|
269 |
-
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $
|
270 |
return $message;
|
271 |
}
|
272 |
|
@@ -295,7 +383,7 @@ class BNFW_Engine {
|
|
295 |
* @param int $post_id
|
296 |
* @return string
|
297 |
*/
|
298 |
-
|
299 |
$post = get_post( $post_id );
|
300 |
|
301 |
$post_content = apply_filters( 'the_content', $post->post_content );
|
@@ -411,7 +499,7 @@ class BNFW_Engine {
|
|
411 |
*
|
412 |
* @return string Processed string.
|
413 |
*/
|
414 |
-
|
415 |
$user_info = get_userdata( $user_id );
|
416 |
|
417 |
// deperecated
|
@@ -462,6 +550,23 @@ class BNFW_Engine {
|
|
462 |
return $message;
|
463 |
}
|
464 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
/**
|
466 |
* Get the list of emails from the notification settings.
|
467 |
*
|
@@ -490,8 +595,9 @@ class BNFW_Engine {
|
|
490 |
$post_id = $comment->comment_post_ID;
|
491 |
}
|
492 |
|
493 |
-
$
|
494 |
-
|
|
|
495 |
$emails['to'] = array( $author->user_email );
|
496 |
}
|
497 |
} else {
|
@@ -514,6 +620,14 @@ class BNFW_Engine {
|
|
514 |
$emails['from'] = get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>' ;
|
515 |
}
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
if ( ! empty( $setting['cc'] ) ) {
|
518 |
$emails['cc'] = $this->get_emails_from_users( $setting['cc'], $exclude );
|
519 |
}
|
@@ -666,6 +780,10 @@ class BNFW_Engine {
|
|
666 |
$headers[] = 'From:' . $emails['from'];
|
667 |
}
|
668 |
|
|
|
|
|
|
|
|
|
669 |
if ( ! empty( $emails['cc'] ) ) {
|
670 |
$headers[] = 'Cc:' . implode( ',', $emails['cc'] );
|
671 |
}
|
155 |
*
|
156 |
* @param array $setting Notification setting
|
157 |
* @param int $user_id User ID
|
158 |
+
* @param array $old_role Old User Role.
|
159 |
+
* @param array $new_role New User Role.
|
160 |
*/
|
161 |
+
public function send_user_role_changed_email( $setting, $user_id, $old_role, $new_role ) {
|
162 |
$subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
|
163 |
$message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $user_id );
|
164 |
|
165 |
+
$subject = $this->handle_user_role_shortcodes( $subject, $old_role, $new_role );
|
166 |
+
$message = $this->handle_user_role_shortcodes( $message, $old_role, $new_role );
|
167 |
+
|
168 |
$headers = array();
|
169 |
if ( 'html' == $setting['email-formatting'] ) {
|
170 |
$headers[] = 'Content-type: text/html';
|
181 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
182 |
}
|
183 |
|
184 |
+
/**
|
185 |
+
* Handle User Role shortcodes.
|
186 |
+
*
|
187 |
+
* @param string $message String that needs shortcode processing.
|
188 |
+
* @param array $old_role Old User Role.
|
189 |
+
* @param array $new_role New User Role.
|
190 |
+
*
|
191 |
+
* @return string Processed string.
|
192 |
+
*/
|
193 |
+
public function handle_user_role_shortcodes( $message, $old_role, $new_role ) {
|
194 |
+
$roles = wp_roles();
|
195 |
+
|
196 |
+
$old_role_name = '';
|
197 |
+
$new_role_name = '';
|
198 |
+
|
199 |
+
if ( isset( $roles->role_names[$old_role] ) ) {
|
200 |
+
$old_role_name = $roles->role_names[$old_role];
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( isset( $roles->role_names[$new_role] ) ) {
|
204 |
+
$new_role_name = $roles->role_names[$new_role];
|
205 |
+
}
|
206 |
+
|
207 |
+
$message = str_replace( '[user_role_old]', $old_role_name, $message );
|
208 |
+
$message = str_replace( '[user_role_new]', $new_role_name, $message );
|
209 |
+
|
210 |
+
return $message;
|
211 |
+
}
|
212 |
+
|
213 |
+
/**
|
214 |
+
* Handle shortcodes for filtered data notifications like `password_changed` and `email_changed`.
|
215 |
+
*
|
216 |
+
* @since 1.6
|
217 |
+
*
|
218 |
+
* @param array $email_data Email data.
|
219 |
+
* @param array $setting Notification settings.
|
220 |
+
* @param string|int $extra_data Extra data.
|
221 |
+
*
|
222 |
+
* @return array Modified email data.
|
223 |
+
*/
|
224 |
+
public function handle_filtered_data_notification( $email_data, $setting, $extra_data ) {
|
225 |
+
$email_data['message'] = $this->handle_shortcodes( $setting['message'], $setting['notification'], $extra_data );
|
226 |
+
$email_data['subject'] = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $extra_data );
|
227 |
+
|
228 |
+
$emails = $this->get_emails( $setting, $extra_data );
|
229 |
+
$headers = $this->get_headers( $emails );
|
230 |
+
|
231 |
+
if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
|
232 |
+
$email_data['message'] = wpautop( $email_data['message'] );
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( 'html' == $setting['email-formatting'] ) {
|
236 |
+
$headers[] = 'Content-type: text/html';
|
237 |
+
} else {
|
238 |
+
$headers[] = 'Content-type: text/plain';
|
239 |
+
}
|
240 |
+
|
241 |
+
$email_data['headers'] = $headers;
|
242 |
+
|
243 |
+
return $email_data;
|
244 |
+
}
|
245 |
+
|
246 |
/**
|
247 |
* Handle shortcode for password reset email message.
|
248 |
*
|
249 |
* @since 1.1
|
250 |
+
*
|
251 |
+
* @param $setting
|
252 |
+
* @param $key
|
253 |
+
* @param $user_login
|
254 |
+
* @param $user_data
|
255 |
+
*
|
256 |
+
* @return mixed|string
|
257 |
*/
|
258 |
public function handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data ) {
|
259 |
+
$message = '';
|
260 |
+
|
261 |
if ( '' != $user_login ) {
|
262 |
// For WordPress version 4.1.0 or less, we could have empty user_login
|
263 |
+
$message = $this->handle_shortcodes( $setting['message'], 'user-password', $user_data->ID );
|
264 |
+
$message = $this->handle_global_user_shortcodes( $message, $user_data->user_email );
|
265 |
|
266 |
$reset_link = wp_login_url() . "?action=rp&key=$key&login=$user_login";
|
267 |
$message = str_replace( '[password_reset_link]', $reset_link, $message );
|
268 |
}
|
269 |
+
|
270 |
return $message;
|
271 |
}
|
272 |
|
274 |
* Generate message for notification.
|
275 |
*
|
276 |
* @since 1.0
|
277 |
+
* public since @since 1.6
|
278 |
+
*
|
279 |
+
* @param string $message String may have shortcode.
|
280 |
+
* @param string $notification Notification name.
|
281 |
+
* @param string|int $extra_data Additional data for shortcode.
|
282 |
+
*
|
283 |
+
* @return string Processed string.
|
284 |
*/
|
285 |
+
public function handle_shortcodes( $message, $notification, $extra_data ) {
|
286 |
switch ( $notification ) {
|
287 |
case 'new-comment':
|
288 |
case 'new-trackback':
|
289 |
case 'new-pingback':
|
290 |
case 'reply-comment':
|
291 |
// handle new comments, trackbacks and pingbacks
|
292 |
+
$message = $this->comment_shortcodes( $message, $extra_data );
|
293 |
+
$comment = get_comment( $extra_data );
|
294 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
295 |
if ( 0 != $comment->user_id ) {
|
296 |
$message = $this->user_shortcodes( $message, $comment->user_id );
|
304 |
case 'new-user':
|
305 |
case 'user-role':
|
306 |
case 'admin-role':
|
307 |
+
case 'password-changed':
|
308 |
+
case 'email-changed':
|
309 |
// handle users (lost password and new user registration)
|
310 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
311 |
break;
|
312 |
|
313 |
case 'new-category':
|
314 |
// handle new category
|
315 |
+
$message = $this->taxonomy_shortcodes( $message, 'category', $extra_data );
|
316 |
break;
|
317 |
|
318 |
case 'new-post_tag':
|
319 |
// handle new tag
|
320 |
+
$message = $this->taxonomy_shortcodes( $message, 'post_tag', $extra_data );
|
321 |
+
break;
|
322 |
+
|
323 |
+
case 'core-updated':
|
324 |
+
// handle core updated type
|
325 |
+
$message = $this->core_updated_shortcodes( $message, $extra_data );
|
326 |
break;
|
327 |
|
328 |
default:
|
329 |
$type = explode( '-', $notification, 2 );
|
330 |
if ( 'newterm' == $type[0] ) {
|
331 |
// handle new terms
|
332 |
+
$message = $this->taxonomy_shortcodes( $message, $type[1], $extra_data );
|
333 |
|
334 |
+
} else if ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] || 'private' == $type[0] ) {
|
335 |
// handle new, update and pending posts
|
336 |
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
337 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
338 |
|
339 |
if ( in_array( $type[1], $post_types ) ) {
|
340 |
+
$message = $this->post_shortcodes( $message, $extra_data );
|
341 |
+
$post = get_post( $extra_data );
|
342 |
$message = $this->user_shortcodes( $message, $post->post_author );
|
343 |
}
|
344 |
} else if ( 'comment' == $type[0] || 'commentreply' == $type[0] ) {
|
345 |
+
$message = $this->comment_shortcodes( $message, $extra_data );
|
346 |
+
$comment = get_comment( $extra_data );
|
347 |
$message = $this->post_shortcodes( $message, $comment->comment_post_ID );
|
348 |
if ( 0 != $comment->user_id ) {
|
349 |
$message = $this->user_shortcodes( $message, $comment->user_id );
|
354 |
|
355 |
$message = $this->global_shortcodes( $message );
|
356 |
|
357 |
+
$message = apply_filters( 'bnfw_shortcodes', $message, $notification, $extra_data, $this );
|
358 |
return $message;
|
359 |
}
|
360 |
|
383 |
* @param int $post_id
|
384 |
* @return string
|
385 |
*/
|
386 |
+
private function post_shortcodes( $message, $post_id ) {
|
387 |
$post = get_post( $post_id );
|
388 |
|
389 |
$post_content = apply_filters( 'the_content', $post->post_content );
|
499 |
*
|
500 |
* @return string Processed string.
|
501 |
*/
|
502 |
+
private function user_shortcodes( $message, $user_id ) {
|
503 |
$user_info = get_userdata( $user_id );
|
504 |
|
505 |
// deperecated
|
550 |
return $message;
|
551 |
}
|
552 |
|
553 |
+
/**
|
554 |
+
* Handle Core Updated Shortcodes.
|
555 |
+
*
|
556 |
+
* @since 1.6
|
557 |
+
*
|
558 |
+
* @param string $message Original message with shortcodes.
|
559 |
+
* @param string $type The type of email being sent. Can be one of
|
560 |
+
* 'success', 'fail', 'manual', 'critical'.
|
561 |
+
*
|
562 |
+
* @return string Modified content.
|
563 |
+
*/
|
564 |
+
private function core_updated_shortcodes( $message, $type ) {
|
565 |
+
$message = str_replace( '[core_update_status]', $type, $message );
|
566 |
+
|
567 |
+
return $message;
|
568 |
+
}
|
569 |
+
|
570 |
/**
|
571 |
* Get the list of emails from the notification settings.
|
572 |
*
|
595 |
$post_id = $comment->comment_post_ID;
|
596 |
}
|
597 |
|
598 |
+
$post_author = get_post_field( 'post_author', $post_id );
|
599 |
+
$author = get_user_by( 'id', $post_author );
|
600 |
+
if ( false !== $author && $post_author != $exclude ) {
|
601 |
$emails['to'] = array( $author->user_email );
|
602 |
}
|
603 |
} else {
|
620 |
$emails['from'] = get_option( 'blogname' ) . ' <' . get_option( 'admin_email' ) . '>' ;
|
621 |
}
|
622 |
|
623 |
+
if ( ! empty( $setting['reply-name'] ) ) {
|
624 |
+
$emails['reply-name'] = $setting['reply-name'];
|
625 |
+
}
|
626 |
+
|
627 |
+
if ( ! empty( $setting['reply-email'] ) ) {
|
628 |
+
$emails['reply-email'] = $setting['reply-email'];
|
629 |
+
}
|
630 |
+
|
631 |
if ( ! empty( $setting['cc'] ) ) {
|
632 |
$emails['cc'] = $this->get_emails_from_users( $setting['cc'], $exclude );
|
633 |
}
|
780 |
$headers[] = 'From:' . $emails['from'];
|
781 |
}
|
782 |
|
783 |
+
if ( ! empty( $emails['reply-email'] ) ) {
|
784 |
+
$headers[] = 'Reply-To:' . $emails['reply-name'] . '<' . $emails['reply-email'] . '>';
|
785 |
+
}
|
786 |
+
|
787 |
if ( ! empty( $emails['cc'] ) ) {
|
788 |
$headers[] = 'Cc:' . implode( ',', $emails['cc'] );
|
789 |
}
|
includes/helpers/helpers.php
CHANGED
@@ -127,3 +127,18 @@ function bnfw_format_user_capabilities( $wp_capabilities ) {
|
|
127 |
|
128 |
return implode( ', ', $capabilities );
|
129 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
|
128 |
return implode( ', ', $capabilities );
|
129 |
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Has the user opted-in for tracking?
|
133 |
+
*
|
134 |
+
* @return bool True if tracking is allowed, False otherwise.
|
135 |
+
*/
|
136 |
+
function bnfw_is_tracking_allowed() {
|
137 |
+
$tracking_allowed = false;
|
138 |
+
|
139 |
+
if ( get_option( 'bnfw_allow_tracking' ) == 'on' ) {
|
140 |
+
$tracking_allowed = true;
|
141 |
+
}
|
142 |
+
|
143 |
+
return $tracking_allowed;
|
144 |
+
}
|