Better Notifications for WordPress - Version 1.3.6

Version Description

  • 11th December 2015 =
  • Merry Christmas to you all!
  • New: Password Reset notifications can now be in HTML or Plain Text.
  • Improved: The Users / User Role select box now utilises live search instead of showing all users in a long list if you have more than 100 users. This should be a huge performance improvement if your site has a lot of users.
  • Updated: select2.js library updated to v4.
  • Fixed: Compatibility with password reset notifications in WordPress 4.1.0 and below.
  • Fixed: An issue where the 'Tag' label was showing incorrectly in the 'All Notifications' screen.
  • I've added a short disclaimer to the Description Tab regarding spam and overuse/abuse of this plugin which I recommend a quick read through.
Download this release

Release Info

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

Code changes from version 1.3.4 to 1.3.6

README.txt CHANGED
@@ -1,10 +1,12 @@
1
  === Better Notifications for WordPress ===
2
  Contributors: voltronik
 
3
  Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from, author
4
  Requires at least: 3.5
5
- Tested up to: 4.3.1
6
- Stable tag: 1.3.4
7
  License: GPLv2 or later
 
8
 
9
  Send customisable emails to your users for different WordPress notifications.
10
 
@@ -66,11 +68,11 @@ If you'd like to see a notification in the list above, please drop me a line in
66
 
67
  Having problems? Please let me know via this plugin's forum so I can address them and let it act as a source of information for future reference and other users.
68
 
69
- Like this plugin? Please leave it a great review!
70
- Don't think the plugin is worthy of 5 stars? Let me know on the forum and I'll do my best to help.
71
 
72
- > Want to add categories and sub-categories via the WordPress front-end?
73
- > Try my [Front-end Categories](https://wordpress.org/plugins/front-end-categories/ "Front-end Categories WordPress Plugin") plugin.
74
 
75
 
76
 
@@ -79,7 +81,7 @@ Don't think the plugin is worthy of 5 stars? Let me know on the forum and I'll d
79
  1. Upload the 'bnfw' plugin folder to the '/wp-content/plugins/' directory or install it via your WordPress Admin.
80
  2. Activate the plugin through the 'Plugins' menu in WordPress.
81
  3. Use the settings in the new 'Notifications' Menu item in the sidebar to configure the plugin.
82
- 4. (Optional) Install a plugin to use SMTP instead of `wp_mail()`.
83
  5. Test by creating a notification with some [shortcodes](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WordPress").
84
 
85
 
@@ -107,9 +109,13 @@ The possibilities are endless!
107
 
108
  Yes! There is an option for suppressing comments marked as SPAM by Akismet in the plugin settings.
109
 
 
 
 
 
110
  = What isn't this plugin? =
111
 
112
- 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.
113
 
114
  = How do I set-up WordPress to work with this plugin correctly? =
115
 
@@ -161,7 +167,7 @@ It might do but this is untested.
161
 
162
  1. All Notifications
163
 
164
- 2. Add New Notification
165
 
166
  3. Plugin Settings
167
 
@@ -169,6 +175,21 @@ It might do but this is untested.
169
 
170
  == Changelog ==
171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  = 1.3.4 - 2nd October 2015 =
173
  * New: Choose automatic or manual paragraph / line breaks in the WYSIWYG editor. This fixes an issue where they were inserted automatically when they weren't desired. The checkbox for this is below the WYSIWYG editor.
174
  * New: You can now add images to your notifications using the 'Add Media' button above the WYSIWYG editor.
1
  === Better Notifications for WordPress ===
2
  Contributors: voltronik
3
+ Donate link: https://betternotificationsforwp.com/donate/
4
  Tags: notifications, email, mail, alerts, roles, user, users, admin, HTML, plain, wp_mail, shortcode, customize, post, page, updated, pending review, scheduled, category, tag, term, custom post type, comment, akismet, trackback, pingback, lost password, welcome, new user, bulk, notice, trigger, CC, BCC, from, author
5
  Requires at least: 3.5
6
+ Tested up to: 4.4
7
+ Stable tag: 1.3.6
8
  License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
  Send customisable emails to your users for different WordPress notifications.
12
 
68
 
69
  Having problems? Please let me know via this plugin's forum so I can address them and let it act as a source of information for future reference and other users.
70
 
71
+ Like this plugin? Please leave it [a great review](https://wordpress.org/support/view/plugin-reviews/bnfw?rate=5#postform)!
72
+ Don't think the plugin is worthy of 5 stars? Let me know on the forum and I'll do my best to help.
73
 
74
+ > DISCLAIMER
75
+ > This is an incredibly useful and highly rated plugin however, it's possible that overuse or abuse of this plugin could upset your users by sending them too many notifications. By downloading / installing / using this plugin, you take full responsibility of the management / quantity / types of notifications that are sent out from it including abiding by any SPAM laws in your country / operating areas, dealing with / responding to subscription / unsubscription requests, complaints, and so on. I accept no liability or responsibility for spam or abuse of this plugin from the user(s) of or anyone that may receive notifications as a result of the use of this plugin. I'm trusting you, please don't abuse your users.
76
 
77
 
78
 
81
  1. Upload the 'bnfw' plugin folder to the '/wp-content/plugins/' directory or install it via your WordPress Admin.
82
  2. Activate the plugin through the 'Plugins' menu in WordPress.
83
  3. Use the settings in the new 'Notifications' Menu item in the sidebar to configure the plugin.
84
+ 4. (Optional) Install a plugin to use SMTP instead of `wp_mail()`. I recommend [Postman SMTP Mailer/Email Log](https://wordpress.org/plugins/postman-smtp/).
85
  5. Test by creating a notification with some [shortcodes](https://betternotificationsforwp.com/shortcodes/ "Shortcodes for use in Better Notifications for WordPress").
86
 
87
 
109
 
110
  Yes! There is an option for suppressing comments marked as SPAM by Akismet in the plugin settings.
111
 
112
+ = Does this plugin work with Multisite? =
113
+
114
+ 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 most likely be in the form of an add-on.
115
+
116
  = What isn't this plugin? =
117
 
118
+ 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.
119
 
120
  = How do I set-up WordPress to work with this plugin correctly? =
121
 
167
 
168
  1. All Notifications
169
 
170
+ 2. Add New / Edit Notification
171
 
172
  3. Plugin Settings
173
 
175
 
176
  == Changelog ==
177
 
178
+ = 1.3.6 - 11th December 2015 =
179
+ * Merry Christmas to you all!
180
+ * New: Password Reset notifications can now be in HTML or Plain Text.
181
+ * Improved: The Users / User Role select box now utilises live search instead of showing all users in a long list if you have more than 100 users. This should be a huge performance improvement if your site has a lot of users.
182
+ * Updated: select2.js library updated to v4.
183
+ * Fixed: Compatibility with password reset notifications in WordPress 4.1.0 and below.
184
+ * Fixed: An issue where the 'Tag' label was showing incorrectly in the 'All Notifications' screen.
185
+ * I've added a short disclaimer to the [Description Tab](https://wordpress.org/plugins/bnfw/) regarding spam and overuse/abuse of this plugin which I recommend a quick read through.
186
+
187
+ = 1.3.5 - 9th October 2015 =
188
+ * Fixed: A large bug that was causing issues with Password URL shortcodes in the 'New User Registration - For User' and 'Password Reset - For User' notifications.
189
+ * Fixed: An issue where the 'disabled wpautop' checkbox was appearing on transactional emails.
190
+ * Fixed: Some labels in the 'All Notifications' screen weren't formatted correctly.
191
+ * Fixed: Translations weren't referenced correctly. Auto-translation will be [done by WordPress.org automatically](https://make.wordpress.org/plugins/2015/09/01/plugin-translations-on-wordpress-org/) at some point in the future.
192
+
193
  = 1.3.4 - 2nd October 2015 =
194
  * New: Choose automatic or manual paragraph / line breaks in the WYSIWYG editor. This fixes an issue where they were inserted automatically when they weren't desired. The checkbox for this is below the WYSIWYG editor.
195
  * New: You can now add images to your notifications using the 'Add Media' button above the WYSIWYG editor.
assets/css/bnfw.css CHANGED
@@ -9,11 +9,20 @@
9
 
10
 
11
  /* Fix 'jump' when hovering over 'x' in select2 box */
12
- ul.select2-choices li.select2-search-choice a {
13
  -webkit-transition-property: none;
14
  transition-property: none;
15
  -webkit-transition-duration: 0s;
16
  transition-duration: 0s;
17
  -webkit-transition-timing-function: initial;
18
  transition-timing-function: initial;
19
- }
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  /* Fix 'jump' when hovering over 'x' in select2 box */
12
+ /*ul.select2-choices li.select2-search-choice a {
13
  -webkit-transition-property: none;
14
  transition-property: none;
15
  -webkit-transition-duration: 0s;
16
  transition-duration: 0s;
17
  -webkit-transition-timing-function: initial;
18
  transition-timing-function: initial;
19
+ }*/
20
+
21
+ /* Select2 4.0 */
22
+ .select2-container--default .select2-selection--multiple {
23
+ line-height: 0;
24
+ }
25
+
26
+ ul.select2-selection__rendered {
27
+ line-height: 1.3;
28
+ }
assets/images/select2-spinner.gif DELETED
Binary file
assets/images/select2.png DELETED
Binary file
assets/images/select2@2x.png DELETED
Binary file
assets/js/bnfw.js CHANGED
@@ -19,19 +19,42 @@ jQuery(document).ready(function($) {
19
 
20
  function init() {
21
  $(".select2").select2();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  toggle_fields();
23
 
24
- if ( 'user-password' === $('#notification').val() || 'new-user' === $('#notification').val() || 'welcome-email' === $('#notification').val() || 'reply-comment' === $('#notification').val() ) {
25
- $('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #current-user, #post-author').hide();
26
  $('#user-password-msg').show();
 
 
 
27
  } else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
28
- $('#toggle-fields, #users, #email-formatting, #current-user').show();
29
  $('#only-post-author').prop( 'checked', false );
30
  $('#post-author').hide();
31
  toggle_fields();
32
  $('#user-password-msg').hide();
33
  } else {
34
- $('#toggle-fields, #users, #email-formatting, #current-user, #post-author').show();
35
  toggle_fields();
36
  toggle_users();
37
  $('#user-password-msg').hide();
@@ -41,16 +64,19 @@ jQuery(document).ready(function($) {
41
  init();
42
  $('#notification').on('change', function() {
43
  var $this = $(this);
44
- if ( 'user-password' === $this.val() || 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() ) {
45
- $('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #current-user, #post-author').hide();
46
  $('#user-password-msg').show();
 
 
 
47
  } else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
48
  $('#post-author').hide();
49
- $('#toggle-fields, #users, #email-formatting, #current-user').show();
50
  $('#user-password-msg').hide();
51
  toggle_fields();
52
  } else {
53
- $('#toggle-fields, #users, #email-formatting, #current-user, #post-author').show();
54
  $('#user-password-msg').hide();
55
  toggle_fields();
56
  }
@@ -111,6 +137,6 @@ jQuery(document).ready(function($) {
111
  break;
112
  }
113
 
114
- $(this).attr( 'href', 'https://betternotificationsforwp.com/shortcodes/?notification=' + notification_slug );
115
  });
116
  });
19
 
20
  function init() {
21
  $(".select2").select2();
22
+ $(".user-select2").select2( {
23
+ ajax: {
24
+ url: ajaxurl,
25
+ dataType: 'json',
26
+ data: function( params ) {
27
+ return {
28
+ action: 'bnfw_search_users',
29
+ query: params.term,
30
+ page: params.page
31
+ };
32
+ },
33
+ processResults: function( data, page ) {
34
+ return {
35
+ results: data
36
+ };
37
+ }
38
+ },
39
+ minimumInputLength: 3
40
+ } );
41
+
42
  toggle_fields();
43
 
44
+ if ( 'new-user' === $('#notification').val() || 'welcome-email' === $('#notification').val() || 'reply-comment' === $('#notification').val() ) {
45
+ $('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
46
  $('#user-password-msg').show();
47
+ } else if ( 'user-password' === $('#notification').val() ) {
48
+ $('#toggle-fields, #email, #cc, #bcc, #users, #disable-autop, #current-user, #post-author').hide();
49
+ $('#user-password-msg, #email-formatting').show();
50
  } else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
51
+ $('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
52
  $('#only-post-author').prop( 'checked', false );
53
  $('#post-author').hide();
54
  toggle_fields();
55
  $('#user-password-msg').hide();
56
  } else {
57
+ $('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
58
  toggle_fields();
59
  toggle_users();
60
  $('#user-password-msg').hide();
64
  init();
65
  $('#notification').on('change', function() {
66
  var $this = $(this);
67
+ if ( 'new-user' === $this.val() || 'welcome-email' === $this.val() || 'reply-comment' === $this.val() ) {
68
+ $('#toggle-fields, #email, #cc, #bcc, #users, #email-formatting, #disable-autop, #current-user, #post-author').hide();
69
  $('#user-password-msg').show();
70
+ } else if ( 'user-password' === $this.val() ) {
71
+ $('#toggle-fields, #email, #cc, #bcc, #users, #disable-autop, #current-user, #post-author').hide();
72
+ $('#user-password-msg, #email-formatting').show();
73
  } else if ( 'new-comment' === $('#notification').val() || 'new-trackback' === $('#notification').val() || 'new-pingback' === $('#notification').val() || 'admin-password' === $('#notification').val() || 'admin-user' === $('#notification').val() ) {
74
  $('#post-author').hide();
75
+ $('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user').show();
76
  $('#user-password-msg').hide();
77
  toggle_fields();
78
  } else {
79
+ $('#toggle-fields, #users, #email-formatting, #disable-autop, #current-user, #post-author').show();
80
  $('#user-password-msg').hide();
81
  toggle_fields();
82
  }
137
  break;
138
  }
139
 
140
+ $(this).attr( 'href', 'https://betternotificationsforwp.com/shortcodes/?notification=' + notification_slug + '&utm_source=WP%20Admin%20Notification%20Editor%20-%20"Shortcode%20Help"&utm_medium=referral' );
141
  });
142
  });
bnfw.php CHANGED
@@ -3,18 +3,18 @@
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: http://wordpress.org/plugins/bnfw/
5
  * Description: Send customisable emails to your users for different WordPress notifications.
6
- * Version: 1.3.4
7
  * Author: Voltronik
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: plugins@voltronik.co.uk
10
  * License: GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  * Text Domain: bnfw
13
- * Domain Path: languages/
14
  */
15
 
16
  /**
17
- * Copyright © 2014 Voltronik (plugins@voltronik.co.uk)
18
  * This program is free software; you can redistribute it and/or modify
19
  * it under the terms of the GNU General Public License, version 2, as
20
  * published by the Free Software Foundation.
@@ -74,11 +74,23 @@ class BNFW {
74
  * @since 1.0
75
  */
76
  public function includes() {
77
- // Load Engine and post type
 
 
 
 
 
78
  require_once 'includes/engine/class-bnfw-engine.php';
79
- require_once 'includes/admin/class-bnfw-notification.php';
80
  require_once 'includes/overrides.php';
81
 
 
 
 
 
 
 
 
 
82
  // Load Admin Pages
83
  if ( is_admin() ) {
84
  require_once 'includes/admin/bnfw-settings.php';
@@ -335,19 +347,43 @@ class BNFW {
335
  *
336
  * @since 1.1
337
  */
338
- public function change_password_email_message( $message, $key, $user_login, $user_data ) {
339
  $notifications = $this->notifier->get_notifications( 'user-password' );
340
  if ( count( $notifications ) > 0 ) {
341
  // Ideally there should be only one notification for this type.
342
  // If there are multiple notification then we will read data about only the last one
343
  $setting = $this->notifier->read_settings( end( $notifications )->ID );
344
 
 
 
 
 
 
 
345
  return $this->engine->handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data );
346
  }
347
 
348
  return $message;
349
  }
350
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351
  /**
352
  * Send notification for new uses.
353
  *
3
  * Plugin Name: Better Notifications for WordPress
4
  * Plugin URI: http://wordpress.org/plugins/bnfw/
5
  * Description: Send customisable emails to your users for different WordPress notifications.
6
+ * Version: 1.3.6
7
  * Author: Voltronik
8
  * Author URI: https://betternotificationsforwp.com/
9
  * Author Email: plugins@voltronik.co.uk
10
  * License: GPLv2 or later
11
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
  * Text Domain: bnfw
13
+ * Domain Path: /languages
14
  */
15
 
16
  /**
17
+ * Copyright © 2015 Voltronik (plugins@voltronik.co.uk)
18
  * This program is free software; you can redistribute it and/or modify
19
  * it under the terms of the GNU General Public License, version 2, as
20
  * published by the Free Software Foundation.
74
  * @since 1.0
75
  */
76
  public function includes() {
77
+ // Load license related classes
78
+ require_once 'includes/libraries/EDD_SL_Plugin_Updater.php';
79
+ require_once 'includes/license/class-bnfw-license.php';
80
+ require_once 'includes/license/class-bnfw-license-setting.php';
81
+
82
+ // Load Engine
83
  require_once 'includes/engine/class-bnfw-engine.php';
 
84
  require_once 'includes/overrides.php';
85
 
86
+ // Load notification post type and notification helpers
87
+ require_once 'includes/admin/class-bnfw-notification.php';
88
+ require_once 'includes/notification/post-notification.php';
89
+
90
+ // helpers
91
+ require_once 'includes/helpers/helpers.php';
92
+ require_once 'includes/helpers/ajax-helpers.php';
93
+
94
  // Load Admin Pages
95
  if ( is_admin() ) {
96
  require_once 'includes/admin/bnfw-settings.php';
347
  *
348
  * @since 1.1
349
  */
350
+ public function change_password_email_message( $message, $key, $user_login = '', $user_data = '' ) {
351
  $notifications = $this->notifier->get_notifications( 'user-password' );
352
  if ( count( $notifications ) > 0 ) {
353
  // Ideally there should be only one notification for this type.
354
  // If there are multiple notification then we will read data about only the last one
355
  $setting = $this->notifier->read_settings( end( $notifications )->ID );
356
 
357
+ if ( 'html' == $setting['email-formatting'] ) {
358
+ add_filter( 'wp_mail_content_type', array( $this, 'set_html_content_type' ) );
359
+ } else {
360
+ add_filter( 'wp_mail_content_type', array( $this, 'set_text_content_type' ) );
361
+ }
362
+
363
  return $this->engine->handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data );
364
  }
365
 
366
  return $message;
367
  }
368
 
369
+ /**
370
+ * Set the email formatting to HTML.
371
+ *
372
+ * @since 1.4
373
+ */
374
+ public function set_html_content_type() {
375
+ return 'text/html';
376
+ }
377
+
378
+ /**
379
+ * Set the email formatting to text.
380
+ *
381
+ * @since 1.4
382
+ */
383
+ public function set_text_content_type() {
384
+ return 'text/plain';
385
+ }
386
+
387
  /**
388
  * Send notification for new uses.
389
  *
includes/admin/bnfw-settings.php CHANGED
@@ -54,26 +54,26 @@ function bnfw_settings_page() {
54
  /**
55
  * External Menu Item Links
56
  */
57
-
58
  function bnfw_menu_item_links() {
59
  global $submenu;
60
 
61
  // Documentation Link
62
- $submenu['edit.php?post_type=bnfw_notification'][400] = array(
63
  '<div id="bnfw-menu-item-documentation">Documentation</div>',
64
  'manage_options',
65
- 'https://betternotificationsforwp.com/documentation/?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Documentation"&utm_medium=referral&utm_campaign=' . home_url()
66
  );
67
 
68
  // Add-ons Link
69
- $submenu['edit.php?post_type=bnfw_notification'][500] = array(
70
  '<div id="bnfw-menu-item-addons" style="color: #ff6f59;">Add-ons</div>',
71
  'manage_options',
72
- 'https://betternotificationsforwp.com/store/?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Add-on"&utm_medium=referral&utm_campaign=' . home_url()
73
  );
74
  }
75
 
76
- function bnfw_menu_item_link_targets() { ?>
 
77
 
78
  <!-- Documentation Link -->
79
  <script type="text/javascript">
@@ -148,7 +148,7 @@ function bnfw_general_options() {
148
  );
149
 
150
  }
151
- add_action( 'admin_init', 'bnfw_general_options' );
152
 
153
  /* ------------------------------------------------------------------------ *
154
  * Settings Page - Settings Section Callbacks
@@ -191,7 +191,7 @@ function bnfw_email_format_radio( $args ) {
191
  <br />
192
  <label>
193
  <input type="radio" value="text" name="bnfw_email_format" <?php checked( $email_format, 'text', true ); ?>><?php _e( 'Plain Text', 'bnfw' ); ?>
194
- </label>
195
  <p><i><?php echo $args[0]; ?></i></p>
196
  <?php
197
  }
54
  /**
55
  * External Menu Item Links
56
  */
 
57
  function bnfw_menu_item_links() {
58
  global $submenu;
59
 
60
  // Documentation Link
61
+ $submenu['edit.php?post_type=bnfw_notification'][400] = array(
62
  '<div id="bnfw-menu-item-documentation">Documentation</div>',
63
  'manage_options',
64
+ 'https://betternotificationsforwp.com/documentation/?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Documentation"&amp;utm_medium=referral',
65
  );
66
 
67
  // Add-ons Link
68
+ $submenu['edit.php?post_type=bnfw_notification'][500] = array(
69
  '<div id="bnfw-menu-item-addons" style="color: #ff6f59;">Add-ons</div>',
70
  'manage_options',
71
+ 'https://betternotificationsforwp.com/store/?utm_source=WP%20Admin%20Submenu%20Item%20-%20"Add-on"&amp;utm_medium=referral',
72
  );
73
  }
74
 
75
+ function bnfw_menu_item_link_targets() {
76
+ ?>
77
 
78
  <!-- Documentation Link -->
79
  <script type="text/javascript">
148
  );
149
 
150
  }
151
+ add_action( 'admin_init', 'bnfw_general_options', 10 );
152
 
153
  /* ------------------------------------------------------------------------ *
154
  * Settings Page - Settings Section Callbacks
191
  <br />
192
  <label>
193
  <input type="radio" value="text" name="bnfw_email_format" <?php checked( $email_format, 'text', true ); ?>><?php _e( 'Plain Text', 'bnfw' ); ?>
194
+ </label>
195
  <p><i><?php echo $args[0]; ?></i></p>
196
  <?php
197
  }
includes/admin/class-bnfw-notification.php CHANGED
@@ -242,7 +242,7 @@ class BNFW_Notification {
242
  <td>&nbsp;</td>
243
  <td>
244
  <div>
245
- <p style="margin-top: 0;"><?php esc_html_e( "This notification doesn't support additional email fields or shortcodes in the subject line.", 'bnfw' ); ?></p>
246
  </div>
247
  </td>
248
  </tr>
@@ -290,8 +290,8 @@ class BNFW_Notification {
290
  </th>
291
 
292
  <td>
293
- <select multiple name="cc[]" class="select2" data-placeholder="Select User Roles / Users" style="width:75%">
294
- <?php $this->render_users_dropdown( $setting['cc'] ); ?>
295
  </select>
296
  </td>
297
  </tr>
@@ -302,8 +302,8 @@ class BNFW_Notification {
302
  </th>
303
 
304
  <td>
305
- <select multiple name="bcc[]" class="select2" data-placeholder="Select User Roles / Users" style="width:75%">
306
- <?php $this->render_users_dropdown( $setting['bcc'] ); ?>
307
  </select>
308
  </td>
309
  </tr>
@@ -323,8 +323,8 @@ class BNFW_Notification {
323
  <?php _e( 'Send To', 'bnfw' ); ?>
324
  </th>
325
  <td>
326
- <select multiple name="users[]" class="select2" data-placeholder="Select User Roles / Users" style="width:75%">
327
- <?php $this->render_users_dropdown( $setting['users'] ); ?>
328
  </select>
329
  </td>
330
  </tr>
@@ -357,7 +357,7 @@ class BNFW_Notification {
357
  <span class="dashicons dashicons-editor-help"></span> <?php _e( 'Need some help?', 'bnfw' ); ?>
358
  </p>
359
  <p>
360
- <a href="https://betternotificationsforwp.com/documentation/?utm_source=WP%20Admin%20Notification%20Editor%20-%20'Documentation'&amp;utm_medium=referral&amp;utm_campaign=<?php echo home_url(); ?>" target="_blank" class="button-secondary"><?php _e( 'Documentation', 'bnfw' ); ?></a>
361
  </p>
362
  <p>
363
  <a href="" target="_blank" id="shortcode-help" class="button-secondary"><?php _e( 'Shortcode Help', 'bnfw' ); ?></a>
@@ -367,10 +367,12 @@ class BNFW_Notification {
367
  <td>
368
  <?php wp_editor( $setting['message'], 'notification_message', array( 'media_buttons' => true ) ); ?>
369
  <p> &nbsp; </p>
370
- <label>
371
- <input type="checkbox" name="disable-autop" value="true" <?php checked( 'true', $setting['disable-autop'] ); ?>>
372
- <?php _e( 'Stop additional paragraph and line break HTML from being inserted into my notifications', 'bnfw' ); ?>
373
- </label>
 
 
374
  </td>
375
  </tr>
376
 
@@ -379,36 +381,6 @@ class BNFW_Notification {
379
  <?php
380
  }
381
 
382
- /**
383
- * Render users dropdown.
384
- *
385
- * @since 1.2
386
- */
387
- public function render_users_dropdown( $selected_users ) {
388
- global $wp_roles;
389
- ?>
390
- <optgroup label="User Roles">
391
- <?php
392
- $roles = $wp_roles->get_names();
393
-
394
- foreach ( $roles as $role ) {
395
- $selected = selected( true, in_array( 'role-' . $role, $selected_users ), false );
396
- echo '<option value="role-', $role, '" ', $selected, '>', $role, '</option>';
397
- }
398
- ?>
399
- </optgroup>
400
- <optgroup label="Users">
401
- <?php
402
- $users = get_users( array(
403
- 'order_by' => 'email',
404
- ) );
405
-
406
- foreach ( $users as $user ) {
407
- $selected = selected( true, in_array( $user->ID, $selected_users ), false );
408
- echo '<option value="', $user->ID, '" ', $selected, '>', $user->user_login, '</option>';
409
- }
410
- }
411
-
412
  /**
413
  * Should we enqueue assets?
414
  *
@@ -429,11 +401,16 @@ class BNFW_Notification {
429
  public function enqueue_assets() {
430
  wp_dequeue_script( 'autosave' );
431
 
432
- wp_enqueue_style( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.5.2/select2.min.css', array(), '3.5.2' );
433
- wp_enqueue_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.5.2/select2.min.js', array( 'jquery' ), '3.5.2', true );
 
 
 
 
 
434
 
435
- wp_enqueue_script( 'bnfw', plugins_url( '../assets/js/bnfw.js', dirname( __FILE__ ) ), array( 'jquery' ), '0.1', true );
436
- wp_enqueue_style( 'bnfw', plugins_url( '../assets/css/bnfw.css', dirname( __FILE__ ) ), array( 'dashicons' ), '0.1' );
437
  }
438
 
439
  /**
@@ -827,7 +804,7 @@ class BNFW_Notification {
827
  $name = __( 'User Registration - For User', 'bnfw' );
828
  break;
829
  case 'welcome-email':
830
- $name = __( 'New User - Welcome email', 'bnfw' );
831
  break;
832
  case 'admin-user':
833
  $name = __( 'User Registration - For Admin', 'bnfw' );
@@ -876,7 +853,8 @@ class BNFW_Notification {
876
  $name = $label . __( ' Comment', 'bnfw' );
877
  break;
878
  case 'newterm':
879
- $name = __( 'New term in ', 'bnfw' ) . $splited[1];
 
880
  break;
881
  }
882
  break;
242
  <td>&nbsp;</td>
243
  <td>
244
  <div>
245
+ <p style="margin-top: 0;"><?php esc_html_e( "This notification doesn't support additional email fields.", 'bnfw' ); ?></p>
246
  </div>
247
  </td>
248
  </tr>
290
  </th>
291
 
292
  <td>
293
+ <select multiple name="cc[]" class="<?php echo bnfw_get_user_select_class(); ?>" data-placeholder="Select User Roles / Users" style="width:75%">
294
+ <?php bnfw_render_users_dropdown( $setting['cc'] ); ?>
295
  </select>
296
  </td>
297
  </tr>
302
  </th>
303
 
304
  <td>
305
+ <select multiple name="bcc[]" class="<?php echo bnfw_get_user_select_class(); ?>" data-placeholder="Select User Roles / Users" style="width:75%">
306
+ <?php bnfw_render_users_dropdown( $setting['bcc'] ); ?>
307
  </select>
308
  </td>
309
  </tr>
323
  <?php _e( 'Send To', 'bnfw' ); ?>
324
  </th>
325
  <td>
326
+ <select multiple name="users[]" class="<?php echo bnfw_get_user_select_class(); ?>" data-placeholder="Select User Roles / Users" style="width:75%">
327
+ <?php bnfw_render_users_dropdown( $setting['users'] ); ?>
328
  </select>
329
  </td>
330
  </tr>
357
  <span class="dashicons dashicons-editor-help"></span> <?php _e( 'Need some help?', 'bnfw' ); ?>
358
  </p>
359
  <p>
360
+ <a href="https://betternotificationsforwp.com/documentation/?utm_source=WP%20Admin%20Notification%20Editor%20-%20'Documentation'&amp;utm_medium=referral" target="_blank" class="button-secondary"><?php _e( 'Documentation', 'bnfw' ); ?></a>
361
  </p>
362
  <p>
363
  <a href="" target="_blank" id="shortcode-help" class="button-secondary"><?php _e( 'Shortcode Help', 'bnfw' ); ?></a>
367
  <td>
368
  <?php wp_editor( $setting['message'], 'notification_message', array( 'media_buttons' => true ) ); ?>
369
  <p> &nbsp; </p>
370
+ <div id="disable-autop">
371
+ <label>
372
+ <input type="checkbox" name="disable-autop" value="true" <?php checked( 'true', $setting['disable-autop'] ); ?>>
373
+ <?php _e( 'Stop additional paragraph and line break HTML from being inserted into my notifications', 'bnfw' ); ?>
374
+ </label>
375
+ </div>
376
  </td>
377
  </tr>
378
 
381
  <?php
382
  }
383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  /**
385
  * Should we enqueue assets?
386
  *
401
  public function enqueue_assets() {
402
  wp_dequeue_script( 'autosave' );
403
 
404
+ wp_deregister_script( 'select2' );
405
+ wp_dequeue_script( 'select2' );
406
+ wp_deregister_style( 'select2' );
407
+ wp_dequeue_style( 'select2' );
408
+
409
+ wp_enqueue_style( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1-rc.1/css/select2.min.css', array(), '4.0.1' );
410
+ wp_enqueue_script( 'select2', '//cdnjs.cloudflare.com/ajax/libs/select2/4.0.1-rc.1/js/select2.min.js', array( 'jquery' ), '4.0.1', true );
411
 
412
+ wp_enqueue_script( 'bnfw', plugins_url( '../assets/js/bnfw.js', dirname( __FILE__ ) ), array( 'select2' ), '0.1', true );
413
+ wp_enqueue_style( 'bnfw', plugins_url( '../assets/css/bnfw.css', dirname( __FILE__ ) ), array( 'dashicons', 'select2' ), '0.1' );
414
  }
415
 
416
  /**
804
  $name = __( 'User Registration - For User', 'bnfw' );
805
  break;
806
  case 'welcome-email':
807
+ $name = __( 'New User - Welcome Email', 'bnfw' );
808
  break;
809
  case 'admin-user':
810
  $name = __( 'User Registration - For Admin', 'bnfw' );
853
  $name = $label . __( ' Comment', 'bnfw' );
854
  break;
855
  case 'newterm':
856
+ $tax = get_taxonomy( $splited[1] );
857
+ $name = __( 'New Term in ', 'bnfw' ) . $tax->labels->name;
858
  break;
859
  }
860
  break;
includes/engine/class-bnfw-engine.php CHANGED
@@ -39,24 +39,33 @@ class BNFW_Engine {
39
  * @param int $id
40
  */
41
  public function send_notification( $setting, $id ) {
42
- $subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $id );
43
- $message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $id );
44
- $emails = $this->get_emails( $setting, $id );
45
- $headers = $this->get_headers( $emails );
46
-
47
- if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
48
- $message = wpautop( $message );
49
- }
 
 
 
 
 
 
 
 
50
 
51
- if ( 'html' == $setting['email-formatting'] ) {
52
- $headers[] = 'Content-type: text/html';
53
- } else {
54
- $headers[] = 'Content-type: text/plain';
55
- }
56
 
57
- if ( is_array( $emails['to'] ) ) {
58
- foreach ( $emails['to'] as $email ) {
59
- wp_mail( $email, stripslashes( $subject ), $message, $headers );
 
60
  }
61
  }
62
  }
@@ -128,11 +137,13 @@ class BNFW_Engine {
128
  * @since 1.1
129
  */
130
  public function handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data ) {
131
- $message = $this->user_shortcodes( $setting['message'], $user_data->ID );
132
-
133
- $reset_link = wp_login_url() . "?action=rp&key=$key&login=$user_login";
134
- $message = str_replace( '[password_reset_link]', $reset_link, $message );
135
 
 
 
 
136
  return $message;
137
  }
138
 
@@ -389,6 +400,9 @@ class BNFW_Engine {
389
  $to_emails = $this->get_emails_from_users( $setting['users'], $exclude );
390
  }
391
 
 
 
 
392
  $emails['to'] = apply_filters( 'bnfw_to_emails', $to_emails, $setting, $id );
393
  }
394
 
39
  * @param int $id
40
  */
41
  public function send_notification( $setting, $id ) {
42
+ /**
43
+ * BNFW - Whether notification is enabled?
44
+ *
45
+ * @since 1.3.6
46
+ */
47
+ $notification_enabled = apply_filters( 'bnfw_notification_enabled', true, $id, $notification_details );
48
+
49
+ if ( 'false' != $notification_enabled ) {
50
+ $subject = $this->handle_shortcodes( $setting['subject'], $setting['notification'], $id );
51
+ $message = $this->handle_shortcodes( $setting['message'], $setting['notification'], $id );
52
+ $emails = $this->get_emails( $setting, $id );
53
+ $headers = $this->get_headers( $emails );
54
+
55
+ if ( 'true' != $setting['disable-autop'] && 'html' == $setting['email-formatting'] ) {
56
+ $message = wpautop( $message );
57
+ }
58
 
59
+ if ( 'html' == $setting['email-formatting'] ) {
60
+ $headers[] = 'Content-type: text/html';
61
+ } else {
62
+ $headers[] = 'Content-type: text/plain';
63
+ }
64
 
65
+ if ( is_array( $emails['to'] ) ) {
66
+ foreach ( $emails['to'] as $email ) {
67
+ wp_mail( $email, stripslashes( $subject ), $message, $headers );
68
+ }
69
  }
70
  }
71
  }
137
  * @since 1.1
138
  */
139
  public function handle_password_reset_shortcodes( $setting, $key, $user_login, $user_data ) {
140
+ if ( '' != $user_login ) {
141
+ // For WordPress version 4.1.0 or less, we could have empty user_login
142
+ $message = $this->user_shortcodes( $setting['message'], $user_data->ID );
 
143
 
144
+ $reset_link = wp_login_url() . "?action=rp&key=$key&login=$user_login";
145
+ $message = str_replace( '[password_reset_link]', $reset_link, $message );
146
+ }
147
  return $message;
148
  }
149
 
400
  $to_emails = $this->get_emails_from_users( $setting['users'], $exclude );
401
  }
402
 
403
+ /**
404
+ * BNFW get to emails.
405
+ */
406
  $emails['to'] = apply_filters( 'bnfw_to_emails', $to_emails, $setting, $id );
407
  }
408
 
includes/helpers/ajax-helpers.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BNFW AJAX Helper functions.
4
+ *
5
+ * @since 1.4
6
+ */
7
+
8
+ /**
9
+ * BNFW Search User AJAX Handler.
10
+ *
11
+ * @since 1.3.6
12
+ */
13
+ function bnfw_search_users() {
14
+ global $wp_roles;
15
+
16
+ $query = sanitize_text_field( $_GET['query'] );
17
+ $users = get_users( array(
18
+ 'order_by' => 'email',
19
+ 'search' => "$query*",
20
+ 'number' => 100,
21
+ 'fields' => array( 'ID', 'user_login' ),
22
+ ) );
23
+
24
+ $user_data = array();
25
+ foreach ( $users as $user ) {
26
+ $user_data[] = array(
27
+ 'id' => $user->ID,
28
+ 'text' => $user->user_login,
29
+ );
30
+ }
31
+
32
+ $data = array(
33
+ array(
34
+ 'id' => 1,
35
+ 'text' => __( 'Users', 'bnfw' ),
36
+ 'children' => $user_data,
37
+ ),
38
+ );
39
+
40
+ $roles_data = array();
41
+ $roles = $wp_roles->get_names();
42
+ foreach ( $roles as $role ) {
43
+ $roles_data[] = array(
44
+ 'id' => 'role-' . $role,
45
+ 'text' => $role,
46
+ );
47
+ }
48
+
49
+ $data[] = array(
50
+ 'id' => 2,
51
+ 'text' => __( 'User Roles', 'bnfw' ),
52
+ 'children' => $roles_data,
53
+ );
54
+
55
+ echo json_encode( $data );
56
+ wp_die();
57
+ }
58
+ add_action( 'wp_ajax_bnfw_search_users', 'bnfw_search_users' );
includes/helpers/helpers.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * General BNFW Helpers.
4
+ *
5
+ * @since 1.3.6
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || exit; // Exit if accessed directly
9
+
10
+ /**
11
+ * Dynamically determine the class name for select2 user dropdown based on user count.
12
+ *
13
+ * @since 1.3.6
14
+ */
15
+ function bnfw_get_user_select_class() {
16
+ $user_count = count_users();
17
+
18
+ if ( $user_count['total_users'] > 100 ) {
19
+ return 'user-select2';
20
+ } else {
21
+ return 'select2';
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Render users dropdown.
27
+ *
28
+ * @since 1.3.6
29
+ */
30
+ function bnfw_render_users_dropdown( $selected_users ) {
31
+ global $wp_roles;
32
+ ?>
33
+ <optgroup label="User Roles">
34
+ <?php
35
+ $roles = $wp_roles->get_names();
36
+
37
+ foreach ( $roles as $role ) {
38
+ $selected = selected( true, in_array( 'role-' . $role, $selected_users ), false );
39
+ echo '<option value="role-', $role, '" ', $selected, '>', $role, '</option>';
40
+ }
41
+ ?>
42
+ </optgroup>
43
+ <optgroup label="Users">
44
+ <?php
45
+ $user_count = count_users();
46
+
47
+ // if there are more than 100 users then use AJAX to load them dynamically.
48
+ // So just get only the selected users
49
+ if ( count( $selected_users ) > 0 && $user_count['total_users'] > 100 ) {
50
+ $users = get_users( array(
51
+ 'include' => $selected_users,
52
+ 'order_by' => 'email',
53
+ 'fields' => array( 'ID', 'user_login' ),
54
+ ) );
55
+ } else {
56
+ $users = get_users( array(
57
+ 'order_by' => 'email',
58
+ 'number' => 100,
59
+ 'fields' => array( 'ID', 'user_login' ),
60
+ ) );
61
+ }
62
+
63
+ foreach ( $users as $user ) {
64
+ $selected = selected( true, in_array( $user->ID, $selected_users ), false );
65
+ echo '<option value="', $user->ID, '" ', $selected, '>', $user->user_login, '</option>';
66
+ }
67
+ }
includes/libraries/EDD_SL_Plugin_Updater.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // uncomment this line for testing
4
+ //set_site_transient( 'update_plugins', null );
5
+
6
+ // Exit if accessed directly
7
+ if ( ! defined( 'ABSPATH' ) ) exit;
8
+
9
+ /**
10
+ * Allows plugins to use their own update API.
11
+ *
12
+ * @author Pippin Williamson
13
+ * @version 1.6.2
14
+ */
15
+ class EDD_SL_Plugin_Updater {
16
+ private $api_url = '';
17
+ private $api_data = array();
18
+ private $name = '';
19
+ private $slug = '';
20
+ private $version = '';
21
+
22
+ /**
23
+ * Class constructor.
24
+ *
25
+ * @uses plugin_basename()
26
+ * @uses hook()
27
+ *
28
+ * @param string $_api_url The URL pointing to the custom API endpoint.
29
+ * @param string $_plugin_file Path to the plugin file.
30
+ * @param array $_api_data Optional data to send with API calls.
31
+ */
32
+ function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
+ $this->api_url = trailingslashit( $_api_url );
34
+ $this->api_data = $_api_data;
35
+ $this->name = plugin_basename( $_plugin_file );
36
+ $this->slug = basename( $_plugin_file, '.php' );
37
+ $this->version = $_api_data['version'];
38
+
39
+ // Set up hooks.
40
+ $this->init();
41
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
42
+
43
+ }
44
+
45
+ /**
46
+ * Set up WordPress filters to hook into WP's update process.
47
+ *
48
+ * @uses add_filter()
49
+ *
50
+ * @return void
51
+ */
52
+ public function init() {
53
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
55
+
56
+ remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
57
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
58
+ }
59
+
60
+ /**
61
+ * Check for Updates at the defined API endpoint and modify the update array.
62
+ *
63
+ * This function dives into the update API just when WordPress creates its update array,
64
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
65
+ * It is reassembled from parts of the native WordPress plugin update code.
66
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
67
+ *
68
+ * @uses api_request()
69
+ *
70
+ * @param array $_transient_data Update array build by WordPress.
71
+ * @return array Modified update array with custom plugin data.
72
+ */
73
+ function check_update( $_transient_data ) {
74
+
75
+ global $pagenow;
76
+
77
+ if( ! is_object( $_transient_data ) ) {
78
+ $_transient_data = new stdClass;
79
+ }
80
+
81
+ if( 'plugins.php' == $pagenow && is_multisite() ) {
82
+ return $_transient_data;
83
+ }
84
+
85
+ if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
86
+
87
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
88
+
89
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
90
+
91
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
92
+
93
+ $_transient_data->response[ $this->name ] = $version_info;
94
+
95
+ }
96
+
97
+ $_transient_data->last_checked = time();
98
+ $_transient_data->checked[ $this->name ] = $this->version;
99
+
100
+ }
101
+
102
+ }
103
+
104
+ return $_transient_data;
105
+ }
106
+
107
+ /**
108
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
109
+ *
110
+ * @param string $file
111
+ * @param array $plugin
112
+ */
113
+ public function show_update_notification( $file, $plugin ) {
114
+
115
+ if( ! current_user_can( 'update_plugins' ) ) {
116
+ return;
117
+ }
118
+
119
+ if( ! is_multisite() ) {
120
+ return;
121
+ }
122
+
123
+ if ( $this->name != $file ) {
124
+ return;
125
+ }
126
+
127
+ // Remove our filter on the site transient
128
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
129
+
130
+ $update_cache = get_site_transient( 'update_plugins' );
131
+
132
+ $update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
133
+
134
+ if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
135
+
136
+ $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
137
+ $version_info = get_transient( $cache_key );
138
+
139
+ if( false === $version_info ) {
140
+
141
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
142
+
143
+ set_transient( $cache_key, $version_info, 3600 );
144
+ }
145
+
146
+
147
+ if( ! is_object( $version_info ) ) {
148
+ return;
149
+ }
150
+
151
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
152
+
153
+ $update_cache->response[ $this->name ] = $version_info;
154
+
155
+ }
156
+
157
+ $update_cache->last_checked = time();
158
+ $update_cache->checked[ $this->name ] = $this->version;
159
+
160
+ set_site_transient( 'update_plugins', $update_cache );
161
+
162
+ } else {
163
+
164
+ $version_info = $update_cache->response[ $this->name ];
165
+
166
+ }
167
+
168
+ // Restore our filter
169
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
170
+
171
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
172
+
173
+ // build a plugin list row, with update notification
174
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
175
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
176
+
177
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
178
+
179
+ if ( empty( $version_info->download_link ) ) {
180
+ printf(
181
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'bnfw' ),
182
+ esc_html( $version_info->name ),
183
+ esc_url( $changelog_link ),
184
+ esc_html( $version_info->new_version )
185
+ );
186
+ } else {
187
+ printf(
188
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'bnfw' ),
189
+ esc_html( $version_info->name ),
190
+ esc_url( $changelog_link ),
191
+ esc_html( $version_info->new_version ),
192
+ esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
193
+ );
194
+ }
195
+
196
+ echo '</div></td></tr>';
197
+ }
198
+ }
199
+
200
+
201
+ /**
202
+ * Updates information on the "View version x.x details" page with custom data.
203
+ *
204
+ * @uses api_request()
205
+ *
206
+ * @param mixed $_data
207
+ * @param string $_action
208
+ * @param object $_args
209
+ * @return object $_data
210
+ */
211
+ function plugins_api_filter( $_data, $_action = '', $_args = null ) {
212
+
213
+
214
+ if ( $_action != 'plugin_information' ) {
215
+
216
+ return $_data;
217
+
218
+ }
219
+
220
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
221
+
222
+ return $_data;
223
+
224
+ }
225
+
226
+ $to_send = array(
227
+ 'slug' => $this->slug,
228
+ 'is_ssl' => is_ssl(),
229
+ 'fields' => array(
230
+ 'banners' => false, // These will be supported soon hopefully
231
+ 'reviews' => false
232
+ )
233
+ );
234
+
235
+ $api_response = $this->api_request( 'plugin_information', $to_send );
236
+
237
+ if ( false !== $api_response ) {
238
+ $_data = $api_response;
239
+ }
240
+
241
+ return $_data;
242
+ }
243
+
244
+
245
+ /**
246
+ * Disable SSL verification in order to prevent download update failures
247
+ *
248
+ * @param array $args
249
+ * @param string $url
250
+ * @return object $array
251
+ */
252
+ function http_request_args( $args, $url ) {
253
+ // If it is an https request and we are performing a package download, disable ssl verification
254
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
255
+ $args['sslverify'] = false;
256
+ }
257
+ return $args;
258
+ }
259
+
260
+ /**
261
+ * Calls the API and, if successfull, returns the object delivered by the API.
262
+ *
263
+ * @uses get_bloginfo()
264
+ * @uses wp_remote_post()
265
+ * @uses is_wp_error()
266
+ *
267
+ * @param string $_action The requested action.
268
+ * @param array $_data Parameters for the API action.
269
+ * @return false|object
270
+ */
271
+ private function api_request( $_action, $_data ) {
272
+
273
+ global $wp_version;
274
+
275
+ $data = array_merge( $this->api_data, $_data );
276
+
277
+ if ( $data['slug'] != $this->slug ) {
278
+ return;
279
+ }
280
+
281
+ if( $this->api_url == home_url() ) {
282
+ return false; // Don't allow a plugin to ping itself
283
+ }
284
+
285
+ $api_params = array(
286
+ 'edd_action' => 'get_version',
287
+ 'license' => ! empty( $data['license'] ) ? $data['license'] : '',
288
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
289
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
290
+ 'slug' => $data['slug'],
291
+ 'author' => $data['author'],
292
+ 'url' => home_url()
293
+ );
294
+
295
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
296
+
297
+ if ( ! is_wp_error( $request ) ) {
298
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
299
+ }
300
+
301
+ if ( $request && isset( $request->sections ) ) {
302
+ $request->sections = maybe_unserialize( $request->sections );
303
+ } else {
304
+ $request = false;
305
+ }
306
+
307
+ return $request;
308
+ }
309
+
310
+ public function show_changelog() {
311
+
312
+
313
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
314
+ return;
315
+ }
316
+
317
+ if( empty( $_REQUEST['plugin'] ) ) {
318
+ return;
319
+ }
320
+
321
+ if( empty( $_REQUEST['slug'] ) ) {
322
+ return;
323
+ }
324
+
325
+ if( ! current_user_can( 'update_plugins' ) ) {
326
+ wp_die( __( 'You do not have permission to install plugin updates', 'bnfw' ), __( 'Error', 'bnfw' ), array( 'response' => 403 ) );
327
+ }
328
+
329
+ $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
330
+
331
+ if( $response && isset( $response->sections['changelog'] ) ) {
332
+ echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
333
+ }
334
+
335
+
336
+ exit;
337
+ }
338
+
339
+ }
includes/license/class-bnfw-license-setting.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * BNFW License setting Handler.
4
+ *
5
+ * @since v1.4
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || exit; // Exit if accessed directly
9
+
10
+ function bnfw_license_settings() {
11
+ $settings = apply_filters( 'bnfw_settings_licenses', array() );
12
+
13
+ if ( ! empty( $settings ) ) {
14
+
15
+ // Set-up - General Options Section
16
+ add_settings_section(
17
+ 'bnfw_license_section', // Section ID
18
+ __( 'Addon Licenses', 'bnfw' ), // Title above settings section
19
+ '__return_false', // Name of function that renders a description of the settings section
20
+ 'bnfw-settings' // Page to show on
21
+ );
22
+
23
+ foreach ( $settings as $option ) {
24
+ $name = isset( $option['name'] ) ? $option['name'] : '';
25
+ add_settings_field(
26
+ 'bnfw_licenses[' . $option['id'] . ']',
27
+ $name,
28
+ 'bnfw_license_key_callback',
29
+ 'bnfw-settings',
30
+ 'bnfw_license_section',
31
+ array(
32
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
33
+ 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
34
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
35
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
36
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
37
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
38
+ 'min' => isset( $option['min'] ) ? $option['min'] : null,
39
+ 'max' => isset( $option['max'] ) ? $option['max'] : null,
40
+ 'step' => isset( $option['step'] ) ? $option['step'] : null,
41
+ 'chosen' => isset( $option['chosen'] ) ? $option['chosen'] : null,
42
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
43
+ 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
44
+ 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
45
+ 'faux' => isset( $option['faux'] ) ? $option['faux'] : false,
46
+ )
47
+ );
48
+ }
49
+
50
+ register_setting(
51
+ 'bnfw-settings',
52
+ 'bnfw_licenses'
53
+ );
54
+ }
55
+ }
56
+ add_action( 'admin_init', 'bnfw_license_settings', 11 );
57
+
58
+ /**
59
+ * Register the new license field type
60
+ *
61
+ * @return void
62
+ */
63
+ function bnfw_license_key_callback( $args ) {
64
+ $bnfw_options = get_option( 'bnfw_licenses' );
65
+
66
+ if ( isset( $bnfw_options[ $args['id'] ] ) ) {
67
+ $value = $bnfw_options[ $args['id'] ];
68
+ } else {
69
+ $value = isset( $args['std'] ) ? $args['std'] : '';
70
+ }
71
+
72
+ $size = isset( $args['size'] ) && ! is_null( $args['size'] ) ? $args['size'] : 'regular';
73
+ $html = '<input type="text" class="' . $size . '-text" id="bnfw_licenses[' . $args['id'] . ']" name="bnfw_licenses[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
74
+
75
+ if ( 'valid' == get_option( $args['options']['is_valid_license_option'] ) ) {
76
+ $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'bnfw' ) . '"/>';
77
+ }
78
+
79
+ $html .= '<label for="bnfw_licenses[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
80
+
81
+ echo $html;
82
+ }
includes/license/class-bnfw-license.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License handler for BNFW
4
+ *
5
+ * @since 1.4
6
+ */
7
+
8
+ defined( 'ABSPATH' ) || exit; // Exit if accessed directly
9
+
10
+ /**
11
+ * BNFW_License Class
12
+ */
13
+ class BNFW_License {
14
+ private $file;
15
+ private $license;
16
+ private $item_name;
17
+ private $item_shortname;
18
+ private $version;
19
+ private $author;
20
+ private $api_url = 'https://betternotificationsforwp.com/';
21
+
22
+ /**
23
+ * Class constructor
24
+ *
25
+ * @param string $_file
26
+ * @param string $_item_name
27
+ * @param string $_version
28
+ * @param string $_author
29
+ * @param string $_optname
30
+ * @param string $_api_url
31
+ */
32
+ function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) {
33
+ $bnfw_options = get_option( 'bnfw_licenses' );
34
+
35
+ $this->file = $_file;
36
+ $this->item_name = $_item_name;
37
+ $this->item_shortname = 'bnfw_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
38
+ $this->version = $_version;
39
+ $this->license = isset( $bnfw_options[ $this->item_shortname . '_license_key' ] ) ? trim( $bnfw_options[ $this->item_shortname . '_license_key' ] ) : '';
40
+ $this->author = $_author;
41
+ $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url;
42
+
43
+ // Setup hooks
44
+ $this->hooks();
45
+ $this->auto_updater();
46
+ }
47
+
48
+ /**
49
+ * Setup hooks
50
+ *
51
+ * @access private
52
+ * @return void
53
+ */
54
+ private function hooks() {
55
+ // Register settings
56
+ add_filter( 'bnfw_settings_licenses', array( $this, 'settings' ), 1 );
57
+
58
+ // Activate license key on settings save
59
+ add_action( 'admin_init', array( $this, 'activate_license' ) );
60
+
61
+ // Deactivate license key
62
+ add_action( 'admin_init', array( $this, 'deactivate_license' ) );
63
+ }
64
+
65
+ /**
66
+ * Auto updater
67
+ *
68
+ * @access private
69
+ * @return void
70
+ */
71
+ private function auto_updater() {
72
+ // Setup the updater
73
+ $edd_updater = new EDD_SL_Plugin_Updater(
74
+ $this->api_url,
75
+ $this->file,
76
+ array(
77
+ 'version' => $this->version,
78
+ 'license' => $this->license,
79
+ 'item_name' => $this->item_name,
80
+ 'author' => $this->author
81
+ )
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Add license field to settings
87
+ *
88
+ * @access public
89
+ * @param array $settings
90
+ * @return array
91
+ */
92
+ public function settings( $settings ) {
93
+ $bnfw_license_settings = array(
94
+ array(
95
+ 'id' => $this->item_shortname . '_license_key',
96
+ 'name' => sprintf( __( '%1$s License Key', 'bnfw' ), $this->item_name ),
97
+ 'desc' => '',
98
+ 'type' => 'license_key',
99
+ 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
100
+ 'size' => 'regular',
101
+ ),
102
+ );
103
+
104
+ return array_merge( $settings, $bnfw_license_settings );
105
+ }
106
+
107
+ /**
108
+ * Activate the license key
109
+ *
110
+ * @access public
111
+ * @return void
112
+ */
113
+ public function activate_license() {
114
+ if ( ! isset( $_POST['bnfw_licenses'] ) )
115
+ return;
116
+
117
+ if ( ! isset( $_POST['bnfw_licenses'][ $this->item_shortname . '_license_key' ] ) )
118
+ return;
119
+
120
+ if ( 'valid' == get_option( $this->item_shortname . '_license_active' ) )
121
+ return;
122
+
123
+ $license = sanitize_text_field( $_POST['bnfw_licenses'][ $this->item_shortname . '_license_key' ] );
124
+
125
+ // Data to send to the API
126
+ $api_params = array(
127
+ 'edd_action' => 'activate_license',
128
+ 'license' => $license,
129
+ 'item_name' => urlencode( $this->item_name )
130
+ );
131
+
132
+ // Call the API
133
+ $response = wp_remote_get(
134
+ esc_url_raw( add_query_arg( $api_params, $this->api_url ) ),
135
+ array(
136
+ 'timeout' => 15,
137
+ 'body' => $api_params,
138
+ 'sslverify' => false
139
+ )
140
+ );
141
+
142
+ // Make sure there are no errors
143
+ if ( is_wp_error( $response ) )
144
+ return;
145
+
146
+ // Decode license data
147
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
148
+
149
+ update_option( $this->item_shortname . '_license_active', $license_data->license );
150
+ }
151
+
152
+ /**
153
+ * Deactivate the license key
154
+ *
155
+ * @access public
156
+ * @return void
157
+ */
158
+ public function deactivate_license() {
159
+ if ( ! isset( $_POST['bnfw_licenses'] ) )
160
+ return;
161
+
162
+ if ( ! isset( $_POST['bnfw_licenses'][ $this->item_shortname . '_license_key' ] ) )
163
+ return;
164
+
165
+ // Run on deactivate button press
166
+ if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate' ] ) ) {
167
+
168
+ // Data to send to the API
169
+ $api_params = array(
170
+ 'edd_action' => 'deactivate_license',
171
+ 'license' => $this->license,
172
+ 'item_name' => urlencode( $this->item_name )
173
+ );
174
+
175
+ // Call the API
176
+ $response = wp_remote_get(
177
+ esc_url_raw( add_query_arg( $api_params, $this->api_url ) ),
178
+ array(
179
+ 'timeout' => 15,
180
+ 'sslverify' => false
181
+ )
182
+ );
183
+
184
+ // Make sure there are no errors
185
+ if ( is_wp_error( $response ) )
186
+ return;
187
+
188
+ // Decode the license data
189
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
190
+
191
+ if ( $license_data->license == 'deactivated' )
192
+ delete_option( $this->item_shortname . '_license_active' );
193
+ }
194
+ }
195
+ }
includes/notification/post-notification.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Handle post notifications.
4
+ *
5
+ * @since 1.3.6
6
+ */
7
+
8
+ /**
9
+ * Define the list of post notifications.
10
+ *
11
+ * @since 1.3.6
12
+ *
13
+ * @param array $notifications List of post notifications
14
+ * @param string $post_type Post type
15
+ * @return array Filtered list of post notifications
16
+ */
17
+ function bnfw_post_notifications( $notifications, $post_type ) {
18
+ $post_obj = get_post_type_object( $post_type );
19
+ $label = $post_obj->labels->singular_name;
20
+
21
+ $notifications[] = array(
22
+ 'type' => 'new-' . $post_type,
23
+ 'label' => 'New ' . $label . ' Published',
24
+ );
25
+
26
+ $notifications[] = array(
27
+ 'type' => 'update-' . $post_type,
28
+ 'label' => $label . ' Update',
29
+ );
30
+
31
+ $notifications[] = array(
32
+ 'type' => 'pending-' . $post_type,
33
+ 'label' => $label . ' Pending',
34
+ );
35
+
36
+ $notifications[] = array(
37
+ 'type' => 'future-' . $post_type,
38
+ 'label' => $label . ' Scheduled',
39
+ );
40
+
41
+ $notifications[] = array(
42
+ 'type' => 'comment-' . $post_type,
43
+ 'label' => $label . ' New Comment',
44
+ );
45
+
46
+ return $notifications;
47
+ }
48
+ add_filter( 'bnfw_post_notifications', 'bnfw_post_notifications', 10, 2 );
includes/overrides.php CHANGED
@@ -9,13 +9,15 @@
9
  *
10
  * A new user registration notification is also sent to admin email.
11
  *
12
- * @param int $user_id User ID.
13
- * @param string $notify (optional) Optional. Whether admin and user should be notified ('both') or
14
- * only the admin ('admin' or empty).
 
 
15
  */
16
  if ( ! function_exists( 'wp_new_user_notification' ) ) {
17
- function wp_new_user_notification( $user_id, $notify = '' ) {
18
- global $wp_version;
19
 
20
  $bnfw = BNFW::factory();
21
  $user = get_userdata( $user_id );
@@ -24,6 +26,14 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) {
24
  // for WordPress 4.3 and above
25
  global $wpdb;
26
 
 
 
 
 
 
 
 
 
27
  // The blogname option is escaped with esc_html on the way into the database in sanitize_option
28
  // we want to reverse this for the plain text arena of emails.
29
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
@@ -36,21 +46,13 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) {
36
  @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
37
  }
38
 
39
- // Generate something random for a password reset key.
40
- $key = wp_generate_password( 20, false );
41
-
42
- if ( $bnfw->notifier->notification_exists( 'new-user' ) ) {
43
- $notifications = $bnfw->notifier->get_notifications( 'new-user' );
44
- $password_url = network_site_url( "wp-login.php?action=rp&key=" . $key . "&login=" . rawurlencode( $user->user_login ), 'login' );
45
- foreach ( $notifications as $notification ) {
46
- $bnfw->engine->send_registration_email( $bnfw->notifier->read_settings( $notification->ID ), $user, $password_url );
47
- }
48
- }
49
-
50
  if ( 'admin' === $notify || empty( $notify ) ) {
51
  return;
52
  }
53
 
 
 
 
54
  /** This action is documented in wp-login.php */
55
  do_action( 'retrieve_password_key', $user->user_login, $key );
56
 
@@ -62,17 +64,25 @@ if ( ! function_exists( 'wp_new_user_notification' ) ) {
62
  $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
63
  $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
64
 
65
- $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
66
- $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
67
- $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
 
 
 
 
 
 
 
68
 
69
- $message .= wp_login_url() . "\r\n";
70
 
71
- wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
 
72
  } else {
73
 
74
  // for WordPress below 4.3
75
- $plaintext_pass = $notify;
76
 
77
  // The blogname option is escaped with esc_html on the way into the database in sanitize_option
78
  // we want to reverse this for the plain text arena of emails.
9
  *
10
  * A new user registration notification is also sent to admin email.
11
  *
12
+ * @param int $user_id User ID.
13
+ * @param null $deprecated Not used (argument deprecated).
14
+ * @param string $notify Optional. Type of notification that should happen. Accepts 'admin' or an empty
15
+ * string (admin only), or 'both' (admin and user). The empty string value was kept
16
+ * for backward-compatibility purposes with the renamed parameter. Default empty.
17
  */
18
  if ( ! function_exists( 'wp_new_user_notification' ) ) {
19
+ function wp_new_user_notification( $user_id, $deprecated = null, $notify = '' ) {
20
+ global $wp_version, $wp_hasher;;
21
 
22
  $bnfw = BNFW::factory();
23
  $user = get_userdata( $user_id );
26
  // for WordPress 4.3 and above
27
  global $wpdb;
28
 
29
+ if ( version_compare( $wp_version, '4.3', '=' ) ) {
30
+ $notify = $deprecated;
31
+ } else {
32
+ if ( $deprecated !== null ) {
33
+ _deprecated_argument( __FUNCTION__, '4.3.1' );
34
+ }
35
+ }
36
+
37
  // The blogname option is escaped with esc_html on the way into the database in sanitize_option
38
  // we want to reverse this for the plain text arena of emails.
39
  $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
46
  @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
47
  }
48
 
 
 
 
 
 
 
 
 
 
 
 
49
  if ( 'admin' === $notify || empty( $notify ) ) {
50
  return;
51
  }
52
 
53
+ // Generate something random for a password reset key.
54
+ $key = wp_generate_password( 20, false );
55
+
56
  /** This action is documented in wp-login.php */
57
  do_action( 'retrieve_password_key', $user->user_login, $key );
58
 
64
  $hashed = time() . ':' . $wp_hasher->HashPassword( $key );
65
  $wpdb->update( $wpdb->users, array( 'user_activation_key' => $hashed ), array( 'user_login' => $user->user_login ) );
66
 
67
+ if ( $bnfw->notifier->notification_exists( 'new-user' ) ) {
68
+ $notifications = $bnfw->notifier->get_notifications( 'new-user' );
69
+ $password_url = network_site_url( "wp-login.php?action=rp&key=" . $key . "&login=" . rawurlencode( $user->user_login ), 'login' );
70
+ foreach ( $notifications as $notification ) {
71
+ $bnfw->engine->send_registration_email( $bnfw->notifier->read_settings( $notification->ID ), $user, $password_url );
72
+ }
73
+ } else {
74
+ $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
75
+ $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
76
+ $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user->user_login), 'login') . ">\r\n\r\n";
77
 
78
+ $message .= wp_login_url() . "\r\n";
79
 
80
+ wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
81
+ }
82
  } else {
83
 
84
  // for WordPress below 4.3
85
+ $plaintext_pass = $deprecated;
86
 
87
  // The blogname option is escaped with esc_html on the way into the database in sanitize_option
88
  // we want to reverse this for the plain text arena of emails.
languages/{pt_BR.mo → bnfw-pt_BR.mo} RENAMED
File without changes
languages/{pt_BR.po → bnfw-pt_BR.po} RENAMED
File without changes