Version Description
- 27th March 2020 =
- New: Three new notifications! "New Media Published", "Media Updated", "Media Comment" - complete with new shortcodes for caption, alt text, dimensions, etc.
- New: "User Logged In - For Admin" notification - sends a notification to the admin when users log in.
- New: "User Logged In - For User" notification - sends a notification to the user when they log in.
- New: "Published to Trash" notification - sends a notification when a published post is moved to the trash.
- Improved: Support for plugins that allow users to be assigned to multiple user roles.
Download this release
Release Info
| Developer | voltronik |
| Plugin | |
| Version | 1.7.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.7.6 to 1.7.7
- README.txt +19 -3
- assets/js/bnfw.js +22 -3
- bnfw.php +179 -7
- includes/admin/class-bnfw-notification.php +66 -10
- includes/engine/class-bnfw-engine.php +179 -2
README.txt
CHANGED
|
@@ -3,9 +3,9 @@ Contributors: voltronik
|
|
| 3 |
Donate link: https://betternotificationsforwp.com/donate/
|
| 4 |
Tags: notification, email, push, sms, alert, HTML, customize, bulk, trigger, CC, BCC
|
| 5 |
Requires at least: 4.0
|
| 6 |
-
Tested up to: 5.
|
| 7 |
Requires PHP: 5.6
|
| 8 |
-
Stable tag: 1.7.
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
|
@@ -58,6 +58,7 @@ The notifications that are currently available to use are:
|
|
| 58 |
* Password Changed - For Admin
|
| 59 |
* User Email Changed - For Admin
|
| 60 |
* User Role Changed - For Admin
|
|
|
|
| 61 |
* WordPress Core Automatic Background Updates
|
| 62 |
* Privacy – Confirm Action: Export Data Request – For Admin
|
| 63 |
* Privacy – Confirm Action: Erase Data Request – For Admin
|
|
@@ -71,6 +72,7 @@ The notifications that are currently available to use are:
|
|
| 71 |
* User Email Changed Confirmation - For User
|
| 72 |
* User Email Changed - For User
|
| 73 |
* User Role Changed - For User
|
|
|
|
| 74 |
* Comment Reply
|
| 75 |
* Privacy – Confirm Action: Export Data Request – For User
|
| 76 |
* Privacy – Confirm Action: Erase Data Request – For User
|
|
@@ -89,6 +91,7 @@ The notifications that are currently available to use are:
|
|
| 89 |
* Post Pending Review
|
| 90 |
* New Private Post
|
| 91 |
* Post Scheduled
|
|
|
|
| 92 |
* New Comment
|
| 93 |
* New Comment Awaiting Moderation
|
| 94 |
* Comment Approved
|
|
@@ -110,6 +113,12 @@ The notifications that are currently available to use are:
|
|
| 110 |
* Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
| 111 |
* Page - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
| 112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
**Posts**
|
| 114 |
|
| 115 |
* New Category
|
|
@@ -221,6 +230,13 @@ Yes, of course! The plugin is completely translation-friendly and if you send me
|
|
| 221 |
|
| 222 |
== Changelog ==
|
| 223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
= 1.7.6 - 30th January 2020 =
|
| 225 |
* New Notification: New Comment Approved. This is sent after the comment has been approved.
|
| 226 |
* New: You can now output the description for the first available category in any new Post/Page/Custom Post Type notification, as well as to New Comment, Comment Awaiting Moderation, and Comment Reply notifications using the shortcode `[post_category_description]`. You can also use the `[post_category_slug]` notification to output the first available category slug.
|
|
@@ -322,7 +338,7 @@ Yes, of course! The plugin is completely translation-friendly and if you send me
|
|
| 322 |
* New: If you want to allow other user roles to create or edit notifications, you can now grant them the 'bnfw' capability using a role editor.
|
| 323 |
* Added: A new notice will display at the top of all Notification screens explaining how you can improve email deliverability. You can dismiss this permanently at any time.
|
| 324 |
* Added: Inline help tips are now available when creating or editing a notification. Handy if you want to remember how something works but don't want to sift through the documentation.
|
| 325 |
-
* Added: Merged two pull
|
| 326 |
* Added: For faster support, there is now a Priority Support menu item in the BNFW Notifications menu. Priority Support is available to customers with an active subscription to an add-on.
|
| 327 |
* Improved: All date related shortcodes now output in the date and time format set in Settings > General in the WordPress Admin.
|
| 328 |
* Improved: The list of available notifications has been re-ordered to make more sense.
|
| 3 |
Donate link: https://betternotificationsforwp.com/donate/
|
| 4 |
Tags: notification, email, push, sms, alert, HTML, customize, bulk, trigger, CC, BCC
|
| 5 |
Requires at least: 4.0
|
| 6 |
+
Tested up to: 5.4
|
| 7 |
Requires PHP: 5.6
|
| 8 |
+
Stable tag: 1.7.7
|
| 9 |
License: GPLv2 or later
|
| 10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 11 |
|
| 58 |
* Password Changed - For Admin
|
| 59 |
* User Email Changed - For Admin
|
| 60 |
* User Role Changed - For Admin
|
| 61 |
+
* User Logged In - For Admin
|
| 62 |
* WordPress Core Automatic Background Updates
|
| 63 |
* Privacy – Confirm Action: Export Data Request – For Admin
|
| 64 |
* Privacy – Confirm Action: Erase Data Request – For Admin
|
| 72 |
* User Email Changed Confirmation - For User
|
| 73 |
* User Email Changed - For User
|
| 74 |
* User Role Changed - For User
|
| 75 |
+
* User Logged In - For User
|
| 76 |
* Comment Reply
|
| 77 |
* Privacy – Confirm Action: Export Data Request – For User
|
| 78 |
* Privacy – Confirm Action: Erase Data Request – For User
|
| 91 |
* Post Pending Review
|
| 92 |
* New Private Post
|
| 93 |
* Post Scheduled
|
| 94 |
+
* Published Post Moved to Trash
|
| 95 |
* New Comment
|
| 96 |
* New Comment Awaiting Moderation
|
| 97 |
* Comment Approved
|
| 113 |
* Page - Custom Field Updated ([Custom Fields Add-on](https://betternotificationsforwp.com/downloads/custom-fields/))
|
| 114 |
* Page - Update Reminder ([Reminders Add-on](https://betternotificationsforwp.com/downloads/update-reminder/))
|
| 115 |
|
| 116 |
+
**Media**
|
| 117 |
+
|
| 118 |
+
* New Media Published
|
| 119 |
+
* Media Updated
|
| 120 |
+
* Media - New Comment
|
| 121 |
+
|
| 122 |
**Posts**
|
| 123 |
|
| 124 |
* New Category
|
| 230 |
|
| 231 |
== Changelog ==
|
| 232 |
|
| 233 |
+
= 1.7.7 - 27th March 2020 =
|
| 234 |
+
* New: Three new notifications! "New Media Published", "Media Updated", "Media Comment" - complete with new shortcodes for caption, alt text, dimensions, etc.
|
| 235 |
+
* New: "User Logged In - For Admin" notification - sends a notification to the admin when users log in.
|
| 236 |
+
* New: "User Logged In - For User" notification - sends a notification to the user when they log in.
|
| 237 |
+
* New: "Published to Trash" notification - sends a notification when a published post is moved to the trash.
|
| 238 |
+
* Improved: Support for plugins that allow users to be assigned to multiple user roles.
|
| 239 |
+
|
| 240 |
= 1.7.6 - 30th January 2020 =
|
| 241 |
* New Notification: New Comment Approved. This is sent after the comment has been approved.
|
| 242 |
* New: You can now output the description for the first available category in any new Post/Page/Custom Post Type notification, as well as to New Comment, Comment Awaiting Moderation, and Comment Reply notifications using the shortcode `[post_category_description]`. You can also use the `[post_category_slug]` notification to output the first available category slug.
|
| 338 |
* New: If you want to allow other user roles to create or edit notifications, you can now grant them the 'bnfw' capability using a role editor.
|
| 339 |
* Added: A new notice will display at the top of all Notification screens explaining how you can improve email deliverability. You can dismiss this permanently at any time.
|
| 340 |
* Added: Inline help tips are now available when creating or editing a notification. Handy if you want to remember how something works but don't want to sift through the documentation.
|
| 341 |
+
* Added: Merged two pull request that came in via the GitHub clone of this plugin - ([#1](https://github.com/jackmcconnell/bnfw/pull/1) and [#2](https://github.com/jackmcconnell/bnfw/pull/2)).
|
| 342 |
* Added: For faster support, there is now a Priority Support menu item in the BNFW Notifications menu. Priority Support is available to customers with an active subscription to an add-on.
|
| 343 |
* Improved: All date related shortcodes now output in the date and time format set in Settings > General in the WordPress Admin.
|
| 344 |
* Improved: The list of available notifications has been re-ordered to make more sense.
|
assets/js/bnfw.js
CHANGED
|
@@ -15,13 +15,20 @@ jQuery(document).ready(function($) {
|
|
| 15 |
|
| 16 |
function toggle_fields() {
|
| 17 |
var show_fields = $('#show-fields').is(":checked");
|
| 18 |
-
|
|
|
|
| 19 |
if ( show_fields ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
$('#email, #cc, #bcc, #reply').show();
|
| 21 |
} else {
|
| 22 |
$('#email, #cc, #bcc, #reply').hide();
|
| 23 |
}
|
| 24 |
-
|
| 25 |
$( '#subject-wrapper' ).show();
|
| 26 |
}
|
| 27 |
|
|
@@ -44,7 +51,8 @@ jQuery(document).ready(function($) {
|
|
| 44 |
|
| 45 |
$("#notification, .bnfw-select2").select2();
|
| 46 |
$(".user-select2").select2({
|
| 47 |
-
tags: BNFW.enableTags
|
|
|
|
| 48 |
} );
|
| 49 |
$(".user-ajax-select2").select2( {
|
| 50 |
ajax: {
|
|
@@ -120,6 +128,9 @@ jQuery(document).ready(function($) {
|
|
| 120 |
toggle_fields();
|
| 121 |
toggle_users();
|
| 122 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
|
|
|
|
|
|
|
|
|
| 123 |
} else {
|
| 124 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
| 125 |
toggle_fields();
|
|
@@ -196,6 +207,9 @@ jQuery(document).ready(function($) {
|
|
| 196 |
toggle_fields();
|
| 197 |
toggle_users();
|
| 198 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
|
|
|
|
|
|
|
|
|
| 199 |
} else {
|
| 200 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
| 201 |
$('#user-password-msg').hide();
|
|
@@ -250,6 +264,8 @@ jQuery(document).ready(function($) {
|
|
| 250 |
case 'email-changed':
|
| 251 |
case 'email-changing':
|
| 252 |
case 'new-user':
|
|
|
|
|
|
|
| 253 |
case 'welcome-email':
|
| 254 |
case 'user-role':
|
| 255 |
case 'admin-role':
|
|
@@ -260,6 +276,9 @@ jQuery(document).ready(function($) {
|
|
| 260 |
case 'pending-post':
|
| 261 |
case 'future-post':
|
| 262 |
case 'newterm-category':
|
|
|
|
|
|
|
|
|
|
| 263 |
case 'newterm-post_tag':
|
| 264 |
notification_slug = notification;
|
| 265 |
break;
|
| 15 |
|
| 16 |
function toggle_fields() {
|
| 17 |
var show_fields = $('#show-fields').is(":checked");
|
| 18 |
+
var notification = $( "#notification" ).val();
|
| 19 |
+
if('user-login' === notification){
|
| 20 |
if ( show_fields ) {
|
| 21 |
+
$('#email, #reply').show();
|
| 22 |
+
} else {
|
| 23 |
+
$('#email, #reply').hide();
|
| 24 |
+
}
|
| 25 |
+
}else{
|
| 26 |
+
if ( show_fields ) {
|
| 27 |
$('#email, #cc, #bcc, #reply').show();
|
| 28 |
} else {
|
| 29 |
$('#email, #cc, #bcc, #reply').hide();
|
| 30 |
}
|
| 31 |
+
}
|
| 32 |
$( '#subject-wrapper' ).show();
|
| 33 |
}
|
| 34 |
|
| 51 |
|
| 52 |
$("#notification, .bnfw-select2").select2();
|
| 53 |
$(".user-select2").select2({
|
| 54 |
+
tags: BNFW.enableTags,
|
| 55 |
+
tokenSeparators: BNFW.enabletokenSeparators
|
| 56 |
} );
|
| 57 |
$(".user-ajax-select2").select2( {
|
| 58 |
ajax: {
|
| 128 |
toggle_fields();
|
| 129 |
toggle_users();
|
| 130 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
| 131 |
+
} else if ('user-login' === notification){
|
| 132 |
+
$('#cc, #bcc, #users, #exclude-users, #current-user, #post-author').hide();
|
| 133 |
+
$('#toggle-fields').show();
|
| 134 |
} else {
|
| 135 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
| 136 |
toggle_fields();
|
| 207 |
toggle_fields();
|
| 208 |
toggle_users();
|
| 209 |
$( '#user-password-msg, #current-user, #post-author' ).hide();
|
| 210 |
+
} else if ('user-login' === notification){
|
| 211 |
+
$('#cc, #bcc, #users, #exclude-users, #current-user, #post-author').hide();
|
| 212 |
+
$('#toggle-fields').show();
|
| 213 |
} else {
|
| 214 |
$('#toggle-fields, #users, #exclude-users, #email-formatting, #disable-autop, #current-user, #post-author').show();
|
| 215 |
$('#user-password-msg').hide();
|
| 264 |
case 'email-changed':
|
| 265 |
case 'email-changing':
|
| 266 |
case 'new-user':
|
| 267 |
+
case 'user-login':
|
| 268 |
+
case 'admin-user-login':
|
| 269 |
case 'welcome-email':
|
| 270 |
case 'user-role':
|
| 271 |
case 'admin-role':
|
| 276 |
case 'pending-post':
|
| 277 |
case 'future-post':
|
| 278 |
case 'newterm-category':
|
| 279 |
+
case 'new-media':
|
| 280 |
+
case 'comment-media':
|
| 281 |
+
case 'update-media':
|
| 282 |
case 'newterm-post_tag':
|
| 283 |
notification_slug = notification;
|
| 284 |
break;
|
bnfw.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
* Plugin Name: Better Notifications for WP
|
| 4 |
* Plugin URI: https://wordpress.org/plugins/bnfw/
|
| 5 |
* Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
|
| 6 |
-
* Version: 1.7.
|
| 7 |
* Author: Made with Fuel
|
| 8 |
* Author URI: https://betternotificationsforwp.com/
|
| 9 |
* Author Email: hello@betternotificationsforwp.com
|
|
@@ -92,6 +92,8 @@ class BNFW {
|
|
| 92 |
require_once 'includes/libraries/EDD_SL_Plugin_Updater.php';
|
| 93 |
}
|
| 94 |
|
|
|
|
|
|
|
| 95 |
require_once 'vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php';
|
| 96 |
|
| 97 |
require_once 'includes/license/class-bnfw-license.php';
|
|
@@ -135,6 +137,8 @@ class BNFW {
|
|
| 135 |
|
| 136 |
add_action( 'wp_insert_post' , array( $this, 'insert_post' ), 10, 3 );
|
| 137 |
|
|
|
|
|
|
|
| 138 |
add_action( 'auto-draft_to_publish' , array( $this, 'publish_post' ) );
|
| 139 |
add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
|
| 140 |
add_action( 'future_to_publish' , array( $this, 'publish_post' ) );
|
|
@@ -145,20 +149,30 @@ class BNFW {
|
|
| 145 |
add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
|
| 146 |
add_action( 'private_to_private' , array( $this, 'update_post' ) );
|
| 147 |
|
| 148 |
-
add_action( '
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
add_action( 'init' , array( $this, 'custom_post_type_hooks' ), 100 );
|
| 151 |
add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
|
| 152 |
|
| 153 |
-
add_action( 'transition_comment_status', array( $this, 'on_comment_status_change' ), 10, 3 );
|
| 154 |
add_action( 'comment_post' , array( $this, 'comment_post' ) );
|
| 155 |
add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
|
| 156 |
add_action( 'pingback_post' , array( $this, 'pingback_post' ) );
|
| 157 |
|
| 158 |
-
add_action( 'user_register', array( $this, 'user_register' ) );
|
| 159 |
|
| 160 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
| 161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
|
| 163 |
if ( version_compare( $wp_version, '4.4', '>=' ) ) {
|
| 164 |
add_filter( 'retrieve_password_title', array( $this, 'change_password_email_title' ), 10, 3 );
|
|
@@ -173,9 +187,9 @@ class BNFW {
|
|
| 173 |
add_filter( 'send_password_change_email', array( $this, 'should_password_changed_email_be_sent' ), 10, 3 );
|
| 174 |
add_filter( 'password_change_email' , array( $this, 'on_password_changed' ), 10, 2 );
|
| 175 |
|
| 176 |
-
add_filter( 'send_email_change_email', array( $this, 'should_email_changed_email_be_sent' ), 10, 3 );
|
| 177 |
add_filter( 'email_change_email' , array( $this, 'on_email_changed' ), 10, 2 );
|
| 178 |
-
add_filter( 'new_user_email_content', array( $this, 'on_email_changing' ), 10, 2 );
|
| 179 |
|
| 180 |
add_filter( 'auto_core_update_email' , array( $this, 'on_core_updated' ), 10, 4 );
|
| 181 |
|
|
@@ -406,6 +420,23 @@ class BNFW {
|
|
| 406 |
}
|
| 407 |
}
|
| 408 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 409 |
/**
|
| 410 |
* Fires when a post is pending for review.
|
| 411 |
*
|
|
@@ -425,6 +456,34 @@ class BNFW {
|
|
| 425 |
}
|
| 426 |
}
|
| 427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
/**
|
| 429 |
* Fires when a post is scheduled.
|
| 430 |
*
|
|
@@ -481,6 +540,10 @@ class BNFW {
|
|
| 481 |
if ( 'post' != $post->post_type ) {
|
| 482 |
$notification_type = 'comment-' . $post->post_type;
|
| 483 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 484 |
|
| 485 |
$this->send_notification( $notification_type, $comment_id );
|
| 486 |
}
|
|
@@ -795,6 +858,38 @@ class BNFW {
|
|
| 795 |
$this->send_notification( 'admin-user', $user_id );
|
| 796 |
}
|
| 797 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 798 |
/**
|
| 799 |
* Send notification about new users to site admin.
|
| 800 |
*
|
|
@@ -871,6 +966,83 @@ class BNFW {
|
|
| 871 |
}
|
| 872 |
}
|
| 873 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 874 |
/**
|
| 875 |
* Send notification based on type and ref id
|
| 876 |
*
|
| 3 |
* Plugin Name: Better Notifications for WP
|
| 4 |
* Plugin URI: https://wordpress.org/plugins/bnfw/
|
| 5 |
* Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
|
| 6 |
+
* Version: 1.7.7
|
| 7 |
* Author: Made with Fuel
|
| 8 |
* Author URI: https://betternotificationsforwp.com/
|
| 9 |
* Author Email: hello@betternotificationsforwp.com
|
| 92 |
require_once 'includes/libraries/EDD_SL_Plugin_Updater.php';
|
| 93 |
}
|
| 94 |
|
| 95 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
| 96 |
+
|
| 97 |
require_once 'vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php';
|
| 98 |
|
| 99 |
require_once 'includes/license/class-bnfw-license.php';
|
| 137 |
|
| 138 |
add_action( 'wp_insert_post' , array( $this, 'insert_post' ), 10, 3 );
|
| 139 |
|
| 140 |
+
add_action( 'publish_to_trash' , array( $this, 'trash_post' ));
|
| 141 |
+
|
| 142 |
add_action( 'auto-draft_to_publish' , array( $this, 'publish_post' ) );
|
| 143 |
add_action( 'draft_to_publish' , array( $this, 'publish_post' ) );
|
| 144 |
add_action( 'future_to_publish' , array( $this, 'publish_post' ) );
|
| 149 |
add_action( 'publish_to_publish' , array( $this, 'update_post' ) );
|
| 150 |
add_action( 'private_to_private' , array( $this, 'update_post' ) );
|
| 151 |
|
| 152 |
+
add_action( 'add_attachment' , array( $this, 'new_publish_media_notification' ), 10, 1 );
|
| 153 |
+
add_action( 'edit_attachment' , array( $this, 'media_attachment_data_update_notification' ), 10 );
|
| 154 |
+
|
| 155 |
+
add_action( 'transition_post_status' , array( $this, 'on_post_transition' ), 10, 3 );
|
| 156 |
|
| 157 |
add_action( 'init' , array( $this, 'custom_post_type_hooks' ), 100 );
|
| 158 |
add_action( 'create_term' , array( $this, 'create_term' ), 10, 3 );
|
| 159 |
|
| 160 |
+
add_action( 'transition_comment_status' , array( $this, 'on_comment_status_change' ), 10, 3 );
|
| 161 |
add_action( 'comment_post' , array( $this, 'comment_post' ) );
|
| 162 |
add_action( 'trackback_post' , array( $this, 'trackback_post' ) );
|
| 163 |
add_action( 'pingback_post' , array( $this, 'pingback_post' ) );
|
| 164 |
|
| 165 |
+
add_action( 'user_register' , array( $this, 'user_register' ) );
|
| 166 |
|
| 167 |
add_action( 'user_register' , array( $this, 'welcome_email' ) );
|
| 168 |
+
|
| 169 |
+
if ( is_plugin_active('members/members.php') ) {
|
| 170 |
+
add_action( 'profile_update' , array( $this, 'user_role_added' ), 10, 2 );
|
| 171 |
+
}else{
|
| 172 |
+
add_action( 'set_user_role' , array( $this, 'user_role_changed' ), 10, 3 );
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
add_action( 'wp_login' , array( $this, 'user_login' ),10,2);
|
| 176 |
|
| 177 |
if ( version_compare( $wp_version, '4.4', '>=' ) ) {
|
| 178 |
add_filter( 'retrieve_password_title', array( $this, 'change_password_email_title' ), 10, 3 );
|
| 187 |
add_filter( 'send_password_change_email', array( $this, 'should_password_changed_email_be_sent' ), 10, 3 );
|
| 188 |
add_filter( 'password_change_email' , array( $this, 'on_password_changed' ), 10, 2 );
|
| 189 |
|
| 190 |
+
add_filter( 'send_email_change_email' , array( $this, 'should_email_changed_email_be_sent' ), 10, 3 );
|
| 191 |
add_filter( 'email_change_email' , array( $this, 'on_email_changed' ), 10, 2 );
|
| 192 |
+
add_filter( 'new_user_email_content' , array( $this, 'on_email_changing' ), 10, 2 );
|
| 193 |
|
| 194 |
add_filter( 'auto_core_update_email' , array( $this, 'on_core_updated' ), 10, 4 );
|
| 195 |
|
| 420 |
}
|
| 421 |
}
|
| 422 |
|
| 423 |
+
|
| 424 |
+
/**
|
| 425 |
+
* Fires when a post is moved publish to trash.
|
| 426 |
+
*
|
| 427 |
+
*/
|
| 428 |
+
public function trash_post($post) {
|
| 429 |
+
if ($this->is_metabox_request()) {
|
| 430 |
+
return;
|
| 431 |
+
}
|
| 432 |
+
$post_id = $post->ID;
|
| 433 |
+
$post_type = $post->post_type;
|
| 434 |
+
|
| 435 |
+
if (BNFW_Notification::POST_TYPE != $post_type) {
|
| 436 |
+
$this->send_notification_async('trash-' . $post_type, $post_id);
|
| 437 |
+
}
|
| 438 |
+
}
|
| 439 |
+
|
| 440 |
/**
|
| 441 |
* Fires when a post is pending for review.
|
| 442 |
*
|
| 456 |
}
|
| 457 |
}
|
| 458 |
|
| 459 |
+
|
| 460 |
+
/**
|
| 461 |
+
* On Media Published.
|
| 462 |
+
*
|
| 463 |
+
* @param int $post_id Attachment post id.
|
| 464 |
+
*/
|
| 465 |
+
|
| 466 |
+
public function new_publish_media_notification( $post_id ) {
|
| 467 |
+
$post_type = get_post_type($post_id);
|
| 468 |
+
|
| 469 |
+
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
| 470 |
+
$this->send_notification_async( 'new-media', $post_id );
|
| 471 |
+
}
|
| 472 |
+
}
|
| 473 |
+
|
| 474 |
+
/**
|
| 475 |
+
* On Media Attachment Data Update.
|
| 476 |
+
*
|
| 477 |
+
* @param int $post_id Attachment post id.
|
| 478 |
+
*/
|
| 479 |
+
|
| 480 |
+
public function media_attachment_data_update_notification($post_id ) {
|
| 481 |
+
$post_type = get_post_type($post_id);
|
| 482 |
+
if (BNFW_Notification::POST_TYPE != $post_type && $post_type == 'attachment') {
|
| 483 |
+
$this->send_notification_async( 'update-media', $post_id );
|
| 484 |
+
}
|
| 485 |
+
}
|
| 486 |
+
|
| 487 |
/**
|
| 488 |
* Fires when a post is scheduled.
|
| 489 |
*
|
| 540 |
if ( 'post' != $post->post_type ) {
|
| 541 |
$notification_type = 'comment-' . $post->post_type;
|
| 542 |
}
|
| 543 |
+
|
| 544 |
+
if('attachment' == $post->post_type){
|
| 545 |
+
$notification_type = 'comment-media';
|
| 546 |
+
}
|
| 547 |
|
| 548 |
$this->send_notification( $notification_type, $comment_id );
|
| 549 |
}
|
| 858 |
$this->send_notification( 'admin-user', $user_id );
|
| 859 |
}
|
| 860 |
|
| 861 |
+
/**
|
| 862 |
+
* Send notification for user when user login.
|
| 863 |
+
*
|
| 864 |
+
* @since 1.0
|
| 865 |
+
* @param string $user_name
|
| 866 |
+
* @param object $user_data User object.
|
| 867 |
+
*/
|
| 868 |
+
public function user_login( $user_name, $user_data ) {
|
| 869 |
+
$user_id = $user_data->ID;
|
| 870 |
+
$notifications = $this->notifier->get_notifications( 'user-login' );
|
| 871 |
+
|
| 872 |
+
foreach ( $notifications as $notification ) {
|
| 873 |
+
$this->engine->send_user_login_email( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
| 874 |
+
}
|
| 875 |
+
|
| 876 |
+
$this->user_login_admin_notification($user_id);
|
| 877 |
+
}
|
| 878 |
+
|
| 879 |
+
/**
|
| 880 |
+
* Send notification for admin when user login.
|
| 881 |
+
*
|
| 882 |
+
* @since 1.0
|
| 883 |
+
* @param int $user_id
|
| 884 |
+
*/
|
| 885 |
+
public function user_login_admin_notification( $user_id ) {
|
| 886 |
+
$notifications = $this->notifier->get_notifications( 'admin-user-login' );
|
| 887 |
+
|
| 888 |
+
foreach ( $notifications as $notification ) {
|
| 889 |
+
$this->engine->send_user_login_email_for_admin( $this->notifier->read_settings( $notification->ID ), get_userdata( $user_id ) );
|
| 890 |
+
}
|
| 891 |
+
}
|
| 892 |
+
|
| 893 |
/**
|
| 894 |
* Send notification about new users to site admin.
|
| 895 |
*
|
| 966 |
}
|
| 967 |
}
|
| 968 |
|
| 969 |
+
/**
|
| 970 |
+
* Send notification when a user role added support User Role Editor by Members Plugin.
|
| 971 |
+
*
|
| 972 |
+
* @since 1.3.9
|
| 973 |
+
*
|
| 974 |
+
* @param int $user_id User ID
|
| 975 |
+
* @param string $new_role New User role
|
| 976 |
+
* @param array $old_roles Old User role
|
| 977 |
+
*/
|
| 978 |
+
public function user_role_added( $user_id, $old_user_data ) {
|
| 979 |
+
|
| 980 |
+
if(isset($_POST['members_user_roles']) && !empty($_POST['members_user_roles'])){
|
| 981 |
+
// Get the current user roles.
|
| 982 |
+
$old_roles = (array) $old_user_data->roles;
|
| 983 |
+
|
| 984 |
+
// Sanitize the posted roles.
|
| 985 |
+
$new_roles = array_map( 'members_sanitize_role', $_POST['members_user_roles'] );
|
| 986 |
+
|
| 987 |
+
sort($old_roles);
|
| 988 |
+
sort($new_roles);
|
| 989 |
+
$old_roles_str = implode('', $old_roles);
|
| 990 |
+
$new_roles_str = implode('', $new_roles);
|
| 991 |
+
if ( ! empty( $old_roles ) && $old_roles_str !== $new_roles_str) {
|
| 992 |
+
$notifications = $this->notifier->get_notifications( 'user-role' );
|
| 993 |
+
foreach ( $notifications as $notification ) {
|
| 994 |
+
|
| 995 |
+
/**
|
| 996 |
+
* Trigger User Role Changed - For User notification.
|
| 997 |
+
*
|
| 998 |
+
* @since 1.6.5
|
| 999 |
+
*/
|
| 1000 |
+
if ( apply_filters( 'bnfw_trigger_user-role-added_notification', true, $notification, $new_roles, $old_roles ) ) {
|
| 1001 |
+
$this->engine->send_user_role_added_email(
|
| 1002 |
+
$this->notifier->read_settings( $notification->ID ),
|
| 1003 |
+
$user_id,
|
| 1004 |
+
$old_roles,
|
| 1005 |
+
$new_roles
|
| 1006 |
+
);
|
| 1007 |
+
}
|
| 1008 |
+
}
|
| 1009 |
+
|
| 1010 |
+
$notifications = $this->notifier->get_notifications( 'admin-role' );
|
| 1011 |
+
foreach ( $notifications as $notification ) {
|
| 1012 |
+
|
| 1013 |
+
/**
|
| 1014 |
+
* Trigger User Role Changed - For User notification.
|
| 1015 |
+
*
|
| 1016 |
+
* @since 1.6.5
|
| 1017 |
+
*/
|
| 1018 |
+
if ( apply_filters( 'bnfw_trigger_user-role-added_notification', true, $notification, $new_roles, $old_roles ) ) {
|
| 1019 |
+
$setting = $this->notifier->read_settings( $notification->ID );
|
| 1020 |
+
$setting['message'] = $this->engine->handle_user_added_role_shortcodes( $setting['message'], $old_roles, $new_roles );
|
| 1021 |
+
$setting['subject'] = $this->engine->handle_user_added_role_shortcodes( $setting['subject'], $old_roles, $new_roles );
|
| 1022 |
+
|
| 1023 |
+
$this->engine->send_notification( $setting, $user_id );
|
| 1024 |
+
}
|
| 1025 |
+
}
|
| 1026 |
+
}
|
| 1027 |
+
}
|
| 1028 |
+
}
|
| 1029 |
+
|
| 1030 |
+
/**
|
| 1031 |
+
* Sanitizes a role name. This is a wrapper for the `sanitize_key()` WordPress function. Only
|
| 1032 |
+
* alphanumeric characters and underscores are allowed. Hyphens are also replaced with underscores.
|
| 1033 |
+
*
|
| 1034 |
+
* @since 1.0.0
|
| 1035 |
+
* @access public
|
| 1036 |
+
* @return int
|
| 1037 |
+
*/
|
| 1038 |
+
function members_sanitize_role( $role ) {
|
| 1039 |
+
|
| 1040 |
+
$_role = strtolower( $role );
|
| 1041 |
+
$_role = preg_replace( '/[^a-z0-9_\-\s]/', '', $_role );
|
| 1042 |
+
|
| 1043 |
+
return apply_filters( 'members_sanitize_role', str_replace( ' ', '_', $_role ), $role );
|
| 1044 |
+
}
|
| 1045 |
+
|
| 1046 |
/**
|
| 1047 |
* Send notification based on type and ref id
|
| 1048 |
*
|
includes/admin/class-bnfw-notification.php
CHANGED
|
@@ -200,6 +200,8 @@ class BNFW_Notification {
|
|
| 200 |
value="admin-email-changed" <?php selected( 'admin-email-changed', $setting['notification'] ); ?>><?php esc_html_e( 'User Email Changed - For Admin', 'bnfw' ); ?></option>
|
| 201 |
<option
|
| 202 |
value="admin-role" <?php selected( 'admin-role', $setting['notification'] ); ?>><?php esc_html_e( 'User Role Changed - For Admin', 'bnfw' ); ?></option>
|
|
|
|
|
|
|
| 203 |
<option
|
| 204 |
value="core-updated" <?php selected( 'core-updated', $setting['notification'] ); ?>><?php esc_html_e( 'WordPress Core Automatic Background Updates', 'bnfw' ); ?></option>
|
| 205 |
|
|
@@ -224,6 +226,8 @@ class BNFW_Notification {
|
|
| 224 |
value="welcome-email" <?php selected( 'welcome-email', $setting['notification'] ); ?>><?php esc_html_e( 'New User - Post-registration Email', 'bnfw' ); ?></option>
|
| 225 |
<option
|
| 226 |
value="user-password" <?php selected( 'user-password', $setting['notification'] ); ?>><?php esc_html_e( 'User Lost Password - For User', 'bnfw' ); ?></option>
|
|
|
|
|
|
|
| 227 |
<option
|
| 228 |
value="password-changed" <?php selected( 'password-changed', $setting['notification'] ); ?>><?php esc_html_e( 'Password Changed - For User', 'bnfw' ); ?></option>
|
| 229 |
<option value="email-changing" <?php selected( 'email-changing', $setting['notification'] ); ?>>
|
|
@@ -269,6 +273,8 @@ class BNFW_Notification {
|
|
| 269 |
value="private-post" <?php selected( 'private-post', $setting['notification'] ); ?>><?php esc_html_e( 'New Private Post', 'bnfw' ); ?></option>
|
| 270 |
<option
|
| 271 |
value="future-post" <?php selected( 'future-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Scheduled', 'bnfw' ); ?></option>
|
|
|
|
|
|
|
| 272 |
<option value="new-comment" <?php selected( 'new-comment', $setting['notification'] ); ?>>
|
| 273 |
<?php esc_html_e( 'New Comment', 'bnfw' ); ?>
|
| 274 |
</option>
|
|
@@ -311,6 +317,18 @@ class BNFW_Notification {
|
|
| 311 |
<?php do_action( 'bnfw_after_notification_options', 'page', 'Page', $setting ); ?>
|
| 312 |
</optgroup>
|
| 313 |
<?php do_action( 'bnfw_after_notification_options_optgroup', 'page', 'Page', $setting ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 314 |
<?php
|
| 315 |
$types = apply_filters( 'bnfw_notification_dropdown_posttypes', get_post_types( array(
|
| 316 |
'public' => true,
|
|
@@ -1121,7 +1139,15 @@ foreach ( $taxs as $tax ) {
|
|
| 1121 |
break;
|
| 1122 |
case 'users':
|
| 1123 |
$users = $this->get_names_from_users( $setting['users'] );
|
| 1124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1125 |
|
| 1126 |
if ( 'true' === $setting['only-post-author'] ) {
|
| 1127 |
echo esc_html__( ', Post Author', 'bnfw' );
|
|
@@ -1157,15 +1183,25 @@ foreach ( $taxs as $tax ) {
|
|
| 1157 |
$emails = array();
|
| 1158 |
$names_from_user_ids = array();
|
| 1159 |
|
| 1160 |
-
|
| 1161 |
-
|
| 1162 |
-
|
| 1163 |
-
|
| 1164 |
-
|
| 1165 |
-
|
| 1166 |
-
|
| 1167 |
-
|
| 1168 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1169 |
}
|
| 1170 |
}
|
| 1171 |
|
|
@@ -1234,6 +1270,12 @@ foreach ( $taxs as $tax ) {
|
|
| 1234 |
case 'new-user':
|
| 1235 |
$name = esc_html__( 'New User Registration - For User', 'bnfw' );
|
| 1236 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1237 |
case 'welcome-email':
|
| 1238 |
$name = esc_html__( 'New User - Post-registration Email', 'bnfw' );
|
| 1239 |
break;
|
|
@@ -1261,6 +1303,9 @@ foreach ( $taxs as $tax ) {
|
|
| 1261 |
case 'future-post':
|
| 1262 |
$name = esc_html__( 'Post Scheduled', 'bnfw' );
|
| 1263 |
break;
|
|
|
|
|
|
|
|
|
|
| 1264 |
case 'new-page':
|
| 1265 |
$name = esc_html__( 'New Page Published', 'bnfw' );
|
| 1266 |
break;
|
|
@@ -1288,6 +1333,17 @@ foreach ( $taxs as $tax ) {
|
|
| 1288 |
case 'data-erased':
|
| 1289 |
$name = esc_html__( 'Privacy - Data Erased - For User', 'bnfw' );
|
| 1290 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1291 |
default:
|
| 1292 |
$splited = explode( '-', $slug );
|
| 1293 |
$label = $splited[1];
|
| 200 |
value="admin-email-changed" <?php selected( 'admin-email-changed', $setting['notification'] ); ?>><?php esc_html_e( 'User Email Changed - For Admin', 'bnfw' ); ?></option>
|
| 201 |
<option
|
| 202 |
value="admin-role" <?php selected( 'admin-role', $setting['notification'] ); ?>><?php esc_html_e( 'User Role Changed - For Admin', 'bnfw' ); ?></option>
|
| 203 |
+
<option
|
| 204 |
+
value="admin-user-login" <?php selected( 'admin-user-login', $setting['notification'] ); ?>><?php esc_html_e( 'User Logged In - For Admin', 'bnfw' ); ?></option>
|
| 205 |
<option
|
| 206 |
value="core-updated" <?php selected( 'core-updated', $setting['notification'] ); ?>><?php esc_html_e( 'WordPress Core Automatic Background Updates', 'bnfw' ); ?></option>
|
| 207 |
|
| 226 |
value="welcome-email" <?php selected( 'welcome-email', $setting['notification'] ); ?>><?php esc_html_e( 'New User - Post-registration Email', 'bnfw' ); ?></option>
|
| 227 |
<option
|
| 228 |
value="user-password" <?php selected( 'user-password', $setting['notification'] ); ?>><?php esc_html_e( 'User Lost Password - For User', 'bnfw' ); ?></option>
|
| 229 |
+
<option
|
| 230 |
+
value="user-login" <?php selected( 'user-login', $setting['notification'] ); ?>><?php esc_html_e( 'User Logged In - For User', 'bnfw' ); ?></option>
|
| 231 |
<option
|
| 232 |
value="password-changed" <?php selected( 'password-changed', $setting['notification'] ); ?>><?php esc_html_e( 'Password Changed - For User', 'bnfw' ); ?></option>
|
| 233 |
<option value="email-changing" <?php selected( 'email-changing', $setting['notification'] ); ?>>
|
| 273 |
value="private-post" <?php selected( 'private-post', $setting['notification'] ); ?>><?php esc_html_e( 'New Private Post', 'bnfw' ); ?></option>
|
| 274 |
<option
|
| 275 |
value="future-post" <?php selected( 'future-post', $setting['notification'] ); ?>><?php esc_html_e( 'Post Scheduled', 'bnfw' ); ?></option>
|
| 276 |
+
<option
|
| 277 |
+
value="trash-post" <?php selected( 'trash-post', $setting['notification'] ); ?>><?php esc_html_e( 'Published Post Moved to Trash', 'bnfw' ); ?></option>
|
| 278 |
<option value="new-comment" <?php selected( 'new-comment', $setting['notification'] ); ?>>
|
| 279 |
<?php esc_html_e( 'New Comment', 'bnfw' ); ?>
|
| 280 |
</option>
|
| 317 |
<?php do_action( 'bnfw_after_notification_options', 'page', 'Page', $setting ); ?>
|
| 318 |
</optgroup>
|
| 319 |
<?php do_action( 'bnfw_after_notification_options_optgroup', 'page', 'Page', $setting ); ?>
|
| 320 |
+
|
| 321 |
+
<optgroup label="Media">
|
| 322 |
+
<option
|
| 323 |
+
value="new-media" <?php selected( 'new-media', $setting['notification'] ); ?>><?php esc_html_e( 'New Media Published', 'bnfw' ); ?></option>
|
| 324 |
+
<option
|
| 325 |
+
value="update-media" <?php selected( 'update-media', $setting['notification'] ); ?>><?php esc_html_e( 'Media Updated', 'bnfw' ); ?></option>
|
| 326 |
+
<option
|
| 327 |
+
value="comment-media" <?php selected( 'comment-media', $setting['notification'] ); ?>><?php esc_html_e( 'Media - New Comment', 'bnfw' ); ?></option>
|
| 328 |
+
<?php do_action( 'bnfw_after_notification_options', 'media', 'Media', $setting ); ?>
|
| 329 |
+
</optgroup>
|
| 330 |
+
<?php do_action( 'bnfw_after_notification_options_optgroup', 'media', 'Media', $setting ); ?>
|
| 331 |
+
|
| 332 |
<?php
|
| 333 |
$types = apply_filters( 'bnfw_notification_dropdown_posttypes', get_post_types( array(
|
| 334 |
'public' => true,
|
| 1139 |
break;
|
| 1140 |
case 'users':
|
| 1141 |
$users = $this->get_names_from_users( $setting['users'] );
|
| 1142 |
+
if (!empty($users)) {
|
| 1143 |
+
echo implode( ', ', $users );
|
| 1144 |
+
}
|
| 1145 |
+
else {
|
| 1146 |
+
if(isset($setting['new-user-role'])){
|
| 1147 |
+
$users = $this->get_names_from_users( $setting['new-user-role'] );
|
| 1148 |
+
echo implode( ', ', $users );
|
| 1149 |
+
}
|
| 1150 |
+
}
|
| 1151 |
|
| 1152 |
if ( 'true' === $setting['only-post-author'] ) {
|
| 1153 |
echo esc_html__( ', Post Author', 'bnfw' );
|
| 1183 |
$emails = array();
|
| 1184 |
$names_from_user_ids = array();
|
| 1185 |
|
| 1186 |
+
if ( is_array( $users ) ) {
|
| 1187 |
+
foreach ( $users as $user ) {
|
| 1188 |
+
if ( $this->starts_with( $user, 'role-' ) ) {
|
| 1189 |
+
$user_roles[] = ucfirst( str_replace( 'role-', '', $user ) );
|
| 1190 |
+
} elseif ( strpos( $user, '@' ) !== false ) {
|
| 1191 |
+
$emails[] = $user;
|
| 1192 |
+
} elseif ( absint( $user ) > 0 ) {
|
| 1193 |
+
$user_ids[] = absint( $user );
|
| 1194 |
+
} else {
|
| 1195 |
+
$emails[] = $user;
|
| 1196 |
+
}
|
| 1197 |
+
}
|
| 1198 |
+
}
|
| 1199 |
+
else {
|
| 1200 |
+
// User Roles not associated with a To/CC/BCC field
|
| 1201 |
+
$role = get_role( $users );
|
| 1202 |
+
|
| 1203 |
+
if ( !empty( $role ) ) {
|
| 1204 |
+
$user_roles = array( $role->name );
|
| 1205 |
}
|
| 1206 |
}
|
| 1207 |
|
| 1270 |
case 'new-user':
|
| 1271 |
$name = esc_html__( 'New User Registration - For User', 'bnfw' );
|
| 1272 |
break;
|
| 1273 |
+
case 'user-login':
|
| 1274 |
+
$name = esc_html__( 'User Logged In - For User', 'bnfw' );
|
| 1275 |
+
break;
|
| 1276 |
+
case 'admin-user-login':
|
| 1277 |
+
$name = esc_html__( 'User Logged In - For Admin', 'bnfw' );
|
| 1278 |
+
break;
|
| 1279 |
case 'welcome-email':
|
| 1280 |
$name = esc_html__( 'New User - Post-registration Email', 'bnfw' );
|
| 1281 |
break;
|
| 1303 |
case 'future-post':
|
| 1304 |
$name = esc_html__( 'Post Scheduled', 'bnfw' );
|
| 1305 |
break;
|
| 1306 |
+
case 'trash-post':
|
| 1307 |
+
$name = esc_html__( 'Published Post Moved to Trash', 'bnfw' );
|
| 1308 |
+
break;
|
| 1309 |
case 'new-page':
|
| 1310 |
$name = esc_html__( 'New Page Published', 'bnfw' );
|
| 1311 |
break;
|
| 1333 |
case 'data-erased':
|
| 1334 |
$name = esc_html__( 'Privacy - Data Erased - For User', 'bnfw' );
|
| 1335 |
break;
|
| 1336 |
+
case 'new-media':
|
| 1337 |
+
$name = esc_html__( 'New Media Published', 'bnfw' );
|
| 1338 |
+
break;
|
| 1339 |
+
case 'update-media':
|
| 1340 |
+
$name = esc_html__( 'Media Updated', 'bnfw' );
|
| 1341 |
+
break;
|
| 1342 |
+
case 'comment-media':
|
| 1343 |
+
$name = esc_html__( 'Media - New Comment', 'bnfw' );
|
| 1344 |
+
break;
|
| 1345 |
+
|
| 1346 |
+
|
| 1347 |
default:
|
| 1348 |
$splited = explode( '-', $slug );
|
| 1349 |
$label = $splited[1];
|
includes/engine/class-bnfw-engine.php
CHANGED
|
@@ -131,6 +131,63 @@ class BNFW_Engine {
|
|
| 131 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 132 |
}
|
| 133 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
/**
|
| 135 |
* Send comment reply notification email.
|
| 136 |
*
|
|
@@ -203,6 +260,40 @@ class BNFW_Engine {
|
|
| 203 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 204 |
}
|
| 205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
/**
|
| 207 |
* Handle User Role shortcodes.
|
| 208 |
*
|
|
@@ -232,6 +323,38 @@ class BNFW_Engine {
|
|
| 232 |
return $message;
|
| 233 |
}
|
| 234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 235 |
/**
|
| 236 |
* Handle shortcodes for filtered data notifications like `password_changed` and `email_changed`.
|
| 237 |
*
|
|
@@ -388,6 +511,12 @@ class BNFW_Engine {
|
|
| 388 |
case 'user-password':
|
| 389 |
case 'admin-user':
|
| 390 |
case 'welcome-email':
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 391 |
case 'new-user':
|
| 392 |
case 'user-role':
|
| 393 |
case 'admin-role':
|
|
@@ -426,13 +555,22 @@ class BNFW_Engine {
|
|
| 426 |
$message = $this->data_erased_shortcodes( $message, $extra_data );
|
| 427 |
break;
|
| 428 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
default:
|
| 430 |
$type = explode( '-', $notification, 2 );
|
| 431 |
if ( 'newterm' == $type[0] ) {
|
| 432 |
// handle new terms
|
| 433 |
$message = $this->taxonomy_shortcodes( $message, $type[1], $extra_data );
|
| 434 |
|
| 435 |
-
} elseif ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] || 'private' == $type[0] ) {
|
| 436 |
// handle new, update and pending posts
|
| 437 |
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
| 438 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
|
@@ -457,7 +595,7 @@ class BNFW_Engine {
|
|
| 457 |
} elseif ( 'uc' === $type[0] ) {
|
| 458 |
$message = $this->confirmed_action_shortcodes( $message, $extra_data );
|
| 459 |
$message = $this->handle_global_user_shortcodes( $message, $extra_data['admin_email'] );
|
| 460 |
-
|
| 461 |
break;
|
| 462 |
}
|
| 463 |
|
|
@@ -530,6 +668,41 @@ class BNFW_Engine {
|
|
| 530 |
return $message;
|
| 531 |
}
|
| 532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 533 |
/**
|
| 534 |
* Handle post shortcodes.
|
| 535 |
*
|
|
@@ -545,6 +718,10 @@ class BNFW_Engine {
|
|
| 545 |
return $message;
|
| 546 |
}
|
| 547 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 548 |
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
| 549 |
$post_content = apply_filters( 'the_content', $post_content );
|
| 550 |
$post_content = str_replace( ']]>', ']]>', $post_content );
|
| 131 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 132 |
}
|
| 133 |
|
| 134 |
+
/**
|
| 135 |
+
* Send user login notification email.
|
| 136 |
+
*
|
| 137 |
+
* @since 1.1
|
| 138 |
+
* @param array $setting Notification setting
|
| 139 |
+
* @param object $user User object
|
| 140 |
+
*/
|
| 141 |
+
public function send_user_login_email( $setting, $user) {
|
| 142 |
+
|
| 143 |
+
$trigger_notification = apply_filters( 'bnfw_trigger_user-login_notification', true, $setting, $user );
|
| 144 |
+
|
| 145 |
+
if ( ! $trigger_notification ) {
|
| 146 |
+
return;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
+
$user_id = $user->ID;
|
| 150 |
+
|
| 151 |
+
$subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
|
| 152 |
+
$message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $user_id );
|
| 153 |
+
$emails = $this->get_emails( $setting, $user_id );
|
| 154 |
+
$headers = $this->get_headers( $emails );
|
| 155 |
+
|
| 156 |
+
if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
|
| 157 |
+
$message = wpautop( $message );
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
if ( 'html' == $setting['email-formatting'] ) {
|
| 161 |
+
$headers[] = 'Content-type: text/html';
|
| 162 |
+
$message = apply_filters( 'bnfw_notification_message', $message, $setting );
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
| 166 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
| 167 |
+
|
| 168 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
/**
|
| 173 |
+
* Send user login notification email for admin.
|
| 174 |
+
*
|
| 175 |
+
* @since 1.1
|
| 176 |
+
* @param array $setting Notification setting
|
| 177 |
+
* @param object $user User object
|
| 178 |
+
*/
|
| 179 |
+
public function send_user_login_email_for_admin( $setting, $user) {
|
| 180 |
+
|
| 181 |
+
$trigger_notification = apply_filters( 'bnfw_trigger_user-login_notification', true, $setting, $user );
|
| 182 |
+
|
| 183 |
+
if ( ! $trigger_notification ) {
|
| 184 |
+
return;
|
| 185 |
+
}
|
| 186 |
+
$user_id = $user->ID;
|
| 187 |
+
|
| 188 |
+
$this->send_notification($setting,$user_id);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
/**
|
| 192 |
* Send comment reply notification email.
|
| 193 |
*
|
| 260 |
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 261 |
}
|
| 262 |
|
| 263 |
+
/**
|
| 264 |
+
* Send user role added support User Role Editor by Members Plugin.
|
| 265 |
+
*
|
| 266 |
+
* @since 1.3.9
|
| 267 |
+
*
|
| 268 |
+
* @param array $setting Notification setting
|
| 269 |
+
* @param int $user_id User ID
|
| 270 |
+
* @param array $old_role Old User Role.
|
| 271 |
+
* @param array $new_role New User Role.
|
| 272 |
+
*/
|
| 273 |
+
public function send_user_role_added_email( $setting, $user_id, $old_role, $new_role ) {
|
| 274 |
+
$subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $user_id );
|
| 275 |
+
$message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $user_id );
|
| 276 |
+
|
| 277 |
+
$subject = $this->handle_user_added_role_shortcodes( $subject, $old_role, $new_role );
|
| 278 |
+
$message = $this->handle_user_added_role_shortcodes( $message, $old_role, $new_role );
|
| 279 |
+
|
| 280 |
+
$headers = array();
|
| 281 |
+
if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
|
| 282 |
+
$message = wpautop( $message );
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
if ( 'html' == $setting['email-formatting'] ) {
|
| 286 |
+
$headers[] = 'Content-type: text/html';
|
| 287 |
+
$message = apply_filters( 'bnfw_user_role_changed_email_message', $message, $setting );
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
$user = get_user_by( 'id', $user_id );
|
| 291 |
+
|
| 292 |
+
$subject = $this->handle_global_user_shortcodes( $subject, $user->user_email );
|
| 293 |
+
$message = $this->handle_global_user_shortcodes( $message, $user->user_email );
|
| 294 |
+
wp_mail( $user->user_email, stripslashes( $subject ), $message, $headers );
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
/**
|
| 298 |
* Handle User Role shortcodes.
|
| 299 |
*
|
| 323 |
return $message;
|
| 324 |
}
|
| 325 |
|
| 326 |
+
/**
|
| 327 |
+
* Handle User Added Role shortcodes.
|
| 328 |
+
*
|
| 329 |
+
* @param string $message String that needs shortcode processing.
|
| 330 |
+
* @param array $old_role Old User Role.
|
| 331 |
+
* @param array $new_role New User Role.
|
| 332 |
+
*
|
| 333 |
+
* @return string Processed string.
|
| 334 |
+
*/
|
| 335 |
+
public function handle_user_added_role_shortcodes( $message, $old_roles, $new_roles ) {
|
| 336 |
+
$roles = wp_roles();
|
| 337 |
+
|
| 338 |
+
$old_role_name = array();
|
| 339 |
+
$new_role_name = array();
|
| 340 |
+
|
| 341 |
+
foreach ($old_roles as $key => $old_role) {
|
| 342 |
+
if ( isset( $roles->role_names[ $old_role ] ) ) {
|
| 343 |
+
$old_role_name[] = $roles->role_names[ $old_role ];
|
| 344 |
+
}
|
| 345 |
+
}
|
| 346 |
+
foreach ($new_roles as $key => $new_role) {
|
| 347 |
+
if ( isset( $roles->role_names[ $new_role ] ) ) {
|
| 348 |
+
$new_role_name[] = $roles->role_names[ $new_role ];
|
| 349 |
+
}
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
$message = str_replace( '[user_role_old]', implode(',', $old_role_name), $message );
|
| 353 |
+
$message = str_replace( '[user_role_new]', implode(',', $new_role_name), $message );
|
| 354 |
+
|
| 355 |
+
return $message;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
/**
|
| 359 |
* Handle shortcodes for filtered data notifications like `password_changed` and `email_changed`.
|
| 360 |
*
|
| 511 |
case 'user-password':
|
| 512 |
case 'admin-user':
|
| 513 |
case 'welcome-email':
|
| 514 |
+
case 'user-login':
|
| 515 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
| 516 |
+
break;
|
| 517 |
+
case 'admin-user-login':
|
| 518 |
+
$message = $this->user_shortcodes( $message, $extra_data );
|
| 519 |
+
break;
|
| 520 |
case 'new-user':
|
| 521 |
case 'user-role':
|
| 522 |
case 'admin-role':
|
| 555 |
$message = $this->data_erased_shortcodes( $message, $extra_data );
|
| 556 |
break;
|
| 557 |
|
| 558 |
+
case 'new-media':
|
| 559 |
+
case 'update-media':
|
| 560 |
+
$message = $this->post_shortcodes( $message, $extra_data );
|
| 561 |
+
$post = get_post( $extra_data );
|
| 562 |
+
if ( $post instanceof WP_Post ) {
|
| 563 |
+
$message = $this->user_shortcodes( $message, $post->post_author );
|
| 564 |
+
}
|
| 565 |
+
break;
|
| 566 |
+
|
| 567 |
default:
|
| 568 |
$type = explode( '-', $notification, 2 );
|
| 569 |
if ( 'newterm' == $type[0] ) {
|
| 570 |
// handle new terms
|
| 571 |
$message = $this->taxonomy_shortcodes( $message, $type[1], $extra_data );
|
| 572 |
|
| 573 |
+
} elseif ( 'new' == $type[0] || 'update' == $type[0] || 'pending' == $type[0] || 'future' == $type[0] || 'private' == $type[0] || 'trash' == $type[0]) {
|
| 574 |
// handle new, update and pending posts
|
| 575 |
$post_types = get_post_types( array( 'public' => true ), 'names' );
|
| 576 |
$post_types = array_diff( $post_types, array( BNFW_Notification::POST_TYPE ) );
|
| 595 |
} elseif ( 'uc' === $type[0] ) {
|
| 596 |
$message = $this->confirmed_action_shortcodes( $message, $extra_data );
|
| 597 |
$message = $this->handle_global_user_shortcodes( $message, $extra_data['admin_email'] );
|
| 598 |
+
}
|
| 599 |
break;
|
| 600 |
}
|
| 601 |
|
| 668 |
return $message;
|
| 669 |
}
|
| 670 |
|
| 671 |
+
/**
|
| 672 |
+
* Handle media post shortcodes.
|
| 673 |
+
*
|
| 674 |
+
* @since 1.0
|
| 675 |
+
* @param string $message
|
| 676 |
+
* @param int $post_id
|
| 677 |
+
* @return string
|
| 678 |
+
*/
|
| 679 |
+
public function media_post_shortcodes( $message, $post ) {
|
| 680 |
+
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
| 681 |
+
$post_content = apply_filters( 'the_content', $post_content );
|
| 682 |
+
$post_content = str_replace( ']]>', ']]>', $post_content );
|
| 683 |
+
$message = str_replace( '[ID]', $post->ID, $message );
|
| 684 |
+
$message = str_replace( '[media_date]', bnfw_format_date( $post->post_date ), $message );
|
| 685 |
+
$message = str_replace( '[media_date_gmt]', bnfw_format_date( $post->post_date_gmt ), $message );
|
| 686 |
+
$message = str_replace( '[media_description]', $post_content, $message );
|
| 687 |
+
$message = str_replace( '[media_title]', $post->post_title, $message );
|
| 688 |
+
$message = str_replace( '[media_alt_text]',get_post_meta($post->ID,'_wp_attachment_image_alt',true),$message);
|
| 689 |
+
$message = str_replace( '[media_caption]', $this->may_be_strip_shortcode( get_the_excerpt( $post ) ), $message );
|
| 690 |
+
$message = str_replace( '[media_status]', $post->post_status, $message );
|
| 691 |
+
$message = str_replace( '[media_modified]', bnfw_format_date( $post->post_modified ), $message );
|
| 692 |
+
$message = str_replace( '[media_modified_gmt]', bnfw_format_date( $post->post_modified_gmt ), $message );
|
| 693 |
+
$message = str_replace( '[media_content_filtered]', $post->post_content_filtered, $message );
|
| 694 |
+
$message = str_replace( '[media_type]', $post->post_type, $message );
|
| 695 |
+
$message = str_replace( '[media_mime_type]', $post->post_mime_type, $message );
|
| 696 |
+
$message = str_replace( '[media_slug]', $post->post_name, $message );
|
| 697 |
+
$dimensions = get_post_meta($post->ID,'_wp_attachment_metadata',true);
|
| 698 |
+
$media_dimensions = $dimensions['width'].' x '.$dimensions['height'];
|
| 699 |
+
$message = str_replace( '[media_dimensions]', $media_dimensions, $message );
|
| 700 |
+
$user_info = get_userdata( $post->post_author );
|
| 701 |
+
$message = str_replace( '[media_author]', $user_info->display_name, $message );
|
| 702 |
+
|
| 703 |
+
return $message;
|
| 704 |
+
}
|
| 705 |
+
|
| 706 |
/**
|
| 707 |
* Handle post shortcodes.
|
| 708 |
*
|
| 718 |
return $message;
|
| 719 |
}
|
| 720 |
|
| 721 |
+
if($post->post_type == 'attachment'){
|
| 722 |
+
$message = $this->media_post_shortcodes($message, $post);
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
$post_content = $this->may_be_strip_shortcode( $post->post_content );
|
| 726 |
$post_content = apply_filters( 'the_content', $post_content );
|
| 727 |
$post_content = str_replace( ']]>', ']]>', $post_content );
|
