Better Notifications for WordPress - Version 1.8.6

Version Description

  • 26th April 2021 =
  • Fixed: Post Author and Update Author shortcodes now work as expected again following an issue introduced in WordPress 5.7.
  • Fixed: User Lost Password notifications now work correctly if users only log in with their email address.
  • Removed: <div> tags were being added when using the Insert Default Content button on a notification.
  • Updated persist-admin-noticed-dismissal 3rd party library to latest version.
  • Updated: EDD_SL_Plugin_Updater is now at the latest version for add-ons.
Download this release

Release Info

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

Code changes from version 1.8.5 to 1.8.6

README.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: voltronik
3
  Donate link: https://betternotificationsforwp.com/donate/
4
  Tags: notification, email, alert, message, notify, send, HTML, customize, bulk, trigger, CC, BCC
5
  Requires at least: 4.8
6
- Tested up to: 5.6
7
  Requires PHP: 5.6
8
- Stable tag: 1.8.5
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -241,6 +241,13 @@ Yes, of course! The plugin is completely translation-friendly and if you send me
241
 
242
  == Changelog ==
243
 
 
 
 
 
 
 
 
244
  = 1.8.5 - 18th December 2020 =
245
  * New: Shortcode - [user_old_email] and [user_new_email] can now be used in 'User Email Changed - For User' and 'User Email Changed - For Admin' notifications.
246
  * Fixed: 'User Role Changed' notifications weren't being sent out when editing users using bulk edit when plugins that allowed multiple user roles were being used.
3
  Donate link: https://betternotificationsforwp.com/donate/
4
  Tags: notification, email, alert, message, notify, send, HTML, customize, bulk, trigger, CC, BCC
5
  Requires at least: 4.8
6
+ Tested up to: 5.7.2
7
  Requires PHP: 5.6
8
+ Stable tag: 1.8.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
241
 
242
  == Changelog ==
243
 
244
+ = 1.8.6 - 26th April 2021 =
245
+ * Fixed: Post Author and Update Author shortcodes now work as expected again following an issue introduced in WordPress 5.7.
246
+ * Fixed: User Lost Password notifications now work correctly if users only log in with their email address.
247
+ * Removed: `<div>` tags were being added when using the Insert Default Content button on a notification.
248
+ * Updated persist-admin-noticed-dismissal 3rd party library to latest version.
249
+ * Updated: EDD_SL_Plugin_Updater is now at the latest version for add-ons.
250
+
251
  = 1.8.5 - 18th December 2020 =
252
  * New: Shortcode - [user_old_email] and [user_new_email] can now be used in 'User Email Changed - For User' and 'User Email Changed - For Admin' notifications.
253
  * Fixed: 'User Role Changed' notifications weren't being sent out when editing users using bulk edit when plugins that allowed multiple user roles were being used.
assets/img/icon-256x256.png CHANGED
Binary file
assets/js/bnfw.js CHANGED
@@ -633,7 +633,7 @@ jQuery(document).ready(function($) {
633
 
634
  if ( body !== '' ) {
635
  if ( tinyMCE && tinyMCE.editors && tinyMCE.editors['notification_message'] ) {
636
- tinyMCE.editors['notification_message'].selection.setContent( '<div>' + body + '</div>' );
637
  }
638
  }
639
 
633
 
634
  if ( body !== '' ) {
635
  if ( tinyMCE && tinyMCE.editors && tinyMCE.editors['notification_message'] ) {
636
+ tinyMCE.editors['notification_message'].selection.setContent( body );
637
  }
638
  }
639
 
bnfw.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Better Notifications for WP
5
  * Plugin URI: https://wordpress.org/plugins/bnfw/
6
  * Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
7
- * Version: 1.8.5
8
  * Requires at least: 4.8
9
  * Requires PHP: 5.6
10
  * Author: Made with Fuel
@@ -524,7 +524,7 @@ class BNFW {
524
 
525
  $notification_type = 'approve-' . $post->post_type . '-comment';
526
 
527
- $this->send_notification( $notification_type, $comment->comment_ID );
528
 
529
  // Send new comment notification after comment approve
530
  $notification_type = 'new-comment'; // old notification name
@@ -631,7 +631,7 @@ class BNFW {
631
  */
632
  function on_lost_password() {
633
  $user_login = sanitize_text_field( $_POST[ 'user_login' ] );
634
- $user = get_user_by( 'login', $user_login );
635
  if ( $user ) {
636
  $this->send_notification( 'admin-password', $user->ID );
637
  }
@@ -1194,8 +1194,8 @@ class BNFW {
1194
  * @param string $type Notification type.
1195
  * @param mixed $ref_id Reference data.
1196
  */
1197
- public function send_notification( $type, $ref_id ) {
1198
- $notifications = $this->notifier->get_notifications( $type );
1199
  foreach ( $notifications as $notification ) {
1200
  $this->engine->send_notification( $this->notifier->read_settings( $notification->ID ), $ref_id );
1201
  }
@@ -1474,6 +1474,43 @@ class BNFW {
1474
  return ( isset( $_GET[ 'meta-box-loader' ] ) || isset( $_GET[ 'meta_box' ] ) );
1475
  }
1476
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1477
  }
1478
 
1479
  /* ------------------------------------------------------------------------ *
4
  * Plugin Name: Better Notifications for WP
5
  * Plugin URI: https://wordpress.org/plugins/bnfw/
6
  * Description: Supercharge your WordPress notifications using a WYSIWYG editor and shortcodes. Default and new notifications available. Add more power with Add-ons.
7
+ * Version: 1.8.6
8
  * Requires at least: 4.8
9
  * Requires PHP: 5.6
10
  * Author: Made with Fuel
524
 
525
  $notification_type = 'approve-' . $post->post_type . '-comment';
526
 
527
+ $this->send_notification( $notification_type, $comment->comment_ID, false );
528
 
529
  // Send new comment notification after comment approve
530
  $notification_type = 'new-comment'; // old notification name
631
  */
632
  function on_lost_password() {
633
  $user_login = sanitize_text_field( $_POST[ 'user_login' ] );
634
+ $user = get_user_by( 'login', $user_login ) ?: get_user_by( 'email', $user_login );
635
  if ( $user ) {
636
  $this->send_notification( 'admin-password', $user->ID );
637
  }
1194
  * @param string $type Notification type.
1195
  * @param mixed $ref_id Reference data.
1196
  */
1197
+ public function send_notification( $type, $ref_id, $include_disabled = true ) {
1198
+ $notifications = $this->notifier->get_notifications( $type , $include_disabled);
1199
  foreach ( $notifications as $notification ) {
1200
  $this->engine->send_notification( $this->notifier->read_settings( $notification->ID ), $ref_id );
1201
  }
1474
  return ( isset( $_GET[ 'meta-box-loader' ] ) || isset( $_GET[ 'meta_box' ] ) );
1475
  }
1476
 
1477
+
1478
+ /**
1479
+ * Check if Gutenberg is active.
1480
+ *
1481
+ *
1482
+ * @return bool
1483
+ * @since 1.3
1484
+ */
1485
+ public function is_gutenberg_active() {
1486
+ $gutenberg = false;
1487
+ $block_editor = false;
1488
+
1489
+ if ( has_filter( 'replace_editor', 'gutenberg_init' ) ) {
1490
+ // Gutenberg is installed and activated.
1491
+ $gutenberg = true;
1492
+ }
1493
+
1494
+ if ( version_compare( $GLOBALS['wp_version'], '5.0-beta', '>' ) ) {
1495
+ // Block editor.
1496
+ $block_editor = true;
1497
+ }
1498
+
1499
+ if ( ! $gutenberg && ! $block_editor ) {
1500
+ return false;
1501
+ }
1502
+
1503
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
1504
+
1505
+ if ( ! is_plugin_active( 'classic-editor/classic-editor.php' ) ) {
1506
+ return true;
1507
+ }
1508
+
1509
+ $use_block_editor = ( get_option( 'classic-editor-replace' ) === 'no-replace' );
1510
+
1511
+ return $use_block_editor;
1512
+ }
1513
+
1514
  }
1515
 
1516
  /* ------------------------------------------------------------------------ *
includes/admin/class-bnfw-notification.php CHANGED
@@ -39,8 +39,26 @@ class BNFW_Notification {
39
  add_action( 'admin_enqueue_scripts', array( $this, 'is_assets_needed' ) );
40
 
41
  add_action( 'admin_notices', array( $this, 'show_help_notice' ) );
 
 
42
  }
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  /**
45
  * Register bnfw_notification custom post type.
46
  *
39
  add_action( 'admin_enqueue_scripts', array( $this, 'is_assets_needed' ) );
40
 
41
  add_action( 'admin_notices', array( $this, 'show_help_notice' ) );
42
+
43
+ add_action('admin_print_scripts',array($this,'gutenberg_flag'));
44
  }
45
 
46
+ /**
47
+ * Flag variable to check if gutenberge is active
48
+ * added fix for gutenberge
49
+ *
50
+ * @since 1.3
51
+ */
52
+ public function gutenberg_flag(){
53
+ $bnfw = BNFW::Factory();
54
+ ?>
55
+ <script type="text/javascript">
56
+ var bnfw_gutenberge_is_active = <?php echo ($bnfw->is_gutenberg_active())? 'true;' : 'false;'; ?>
57
+ </script>
58
+ <?php
59
+ }
60
+
61
+
62
  /**
63
  * Register bnfw_notification custom post type.
64
  *
includes/engine/class-bnfw-engine.php CHANGED
@@ -841,7 +841,13 @@ class BNFW_Engine {
841
 
842
  $message = str_replace( '[author_link]', get_author_posts_url( $post->post_author ), $message );
843
 
844
- if ( $last_id = get_post_meta( $post->ID, '_edit_last', true ) ) {
 
 
 
 
 
 
845
  if ( $post->post_author != $last_id ) {
846
  $last_user_info = get_userdata( $last_id );
847
  } else {
841
 
842
  $message = str_replace( '[author_link]', get_author_posts_url( $post->post_author ), $message );
843
 
844
+ if ( $last_id = get_post_meta( $post->ID, '_edit_lock', true ) ) {
845
+
846
+ $last_id = explode(':',$last_id);
847
+ if(count($last_id) > 1){
848
+ $last_id = end($last_id);
849
+ }
850
+
851
  if ( $post->post_author != $last_id ) {
852
  $last_user_info = get_userdata( $last_id );
853
  } else {
includes/libraries/EDD_SL_Plugin_Updater.php CHANGED
@@ -7,18 +7,18 @@ if ( ! defined( 'ABSPATH' ) ) exit;
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
- * @version 1.6.18
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
14
- private $api_url = '';
15
- private $api_data = array();
16
- private $name = '';
17
- private $slug = '';
18
- private $version = '';
19
- private $wp_override = false;
20
- private $cache_key = '';
21
-
22
  private $health_check_timeout = 5;
23
 
24
  /**
@@ -106,32 +106,50 @@ class EDD_SL_Plugin_Updater {
106
  return $_transient_data;
107
  }
108
 
109
- $version_info = $this->get_cached_version_info();
110
-
111
- if ( false === $version_info ) {
112
- $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
113
-
114
- $this->set_version_info_cache( $version_info );
115
-
 
116
  }
 
 
117
 
118
- if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
119
-
120
- if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
121
-
122
- $_transient_data->response[ $this->name ] = $version_info;
123
 
124
- // Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
125
- $_transient_data->response[ $this->name ]->plugin = $this->name;
 
 
 
 
 
 
126
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
 
129
- $_transient_data->last_checked = time();
130
- $_transient_data->checked[ $this->name ] = $this->version;
 
131
 
 
132
  }
133
 
134
- return $_transient_data;
135
  }
136
 
137
  /**
@@ -167,7 +185,7 @@ class EDD_SL_Plugin_Updater {
167
 
168
  if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
169
 
170
- $version_info = $this->get_cached_version_info();
171
 
172
  if ( false === $version_info ) {
173
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
@@ -185,6 +203,10 @@ class EDD_SL_Plugin_Updater {
185
  $version_info->icons = $this->convert_object_to_array( $version_info->icons );
186
  }
187
 
 
 
 
 
188
  $this->set_version_info_cache( $version_info );
189
  }
190
 
@@ -193,12 +215,12 @@ class EDD_SL_Plugin_Updater {
193
  }
194
 
195
  if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
196
-
197
  $update_cache->response[ $this->name ] = $version_info;
198
-
 
199
  }
200
 
201
- $update_cache->last_checked = time();
202
  $update_cache->checked[ $this->name ] = $this->version;
203
 
204
  set_site_transient( 'update_plugins', $update_cache );
@@ -283,10 +305,8 @@ class EDD_SL_Plugin_Updater {
283
  )
284
  );
285
 
286
- $cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
287
-
288
  // Get the transient where we store the api request for this plugin for 24 hours
289
- $edd_api_request_transient = $this->get_cached_version_info( $cache_key );
290
 
291
  //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
292
  if ( empty( $edd_api_request_transient ) ) {
@@ -294,7 +314,7 @@ class EDD_SL_Plugin_Updater {
294
  $api_response = $this->api_request( 'plugin_information', $to_send );
295
 
296
  // Expires in 3 hours
297
- $this->set_version_info_cache( $api_response, $cache_key );
298
 
299
  if ( false !== $api_response ) {
300
  $_data = $api_response;
@@ -319,6 +339,11 @@ class EDD_SL_Plugin_Updater {
319
  $_data->icons = $this->convert_object_to_array( $_data->icons );
320
  }
321
 
 
 
 
 
 
322
  if( ! isset( $_data->plugin ) ) {
323
  $_data->plugin = $this->name;
324
  }
@@ -339,9 +364,12 @@ class EDD_SL_Plugin_Updater {
339
  * @return array
340
  */
341
  private function convert_object_to_array( $data ) {
 
 
 
342
  $new_data = array();
343
  foreach ( $data as $key => $value ) {
344
- $new_data[ $key ] = $value;
345
  }
346
 
347
  return $new_data;
@@ -400,16 +428,16 @@ class EDD_SL_Plugin_Updater {
400
  }
401
 
402
  if ( false === $edd_plugin_url_available[ $store_hash ] ) {
403
- return;
404
  }
405
 
406
  $data = array_merge( $this->api_data, $_data );
407
 
408
  if ( $data['slug'] != $this->slug ) {
409
- return;
410
  }
411
 
412
- if( $this->api_url == trailingslashit ( home_url() ) ) {
413
  return false; // Don't allow a plugin to ping itself
414
  }
415
 
@@ -445,7 +473,7 @@ class EDD_SL_Plugin_Updater {
445
  $request->icons = maybe_unserialize( $request->icons );
446
  }
447
 
448
- if( ! empty( $request->sections ) ) {
449
  foreach( $request->sections as $key => $section ) {
450
  $request->$key = (array) $section;
451
  }
@@ -454,6 +482,9 @@ class EDD_SL_Plugin_Updater {
454
  return $request;
455
  }
456
 
 
 
 
457
  public function show_changelog() {
458
 
459
  global $edd_plugin_data;
@@ -475,9 +506,7 @@ class EDD_SL_Plugin_Updater {
475
  }
476
 
477
  $data = $edd_plugin_data[ $_REQUEST['slug'] ];
478
- $beta = ! empty( $data['beta'] ) ? true : false;
479
- $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
480
- $version_info = $this->get_cached_version_info( $cache_key );
481
 
482
  if( false === $version_info ) {
483
 
@@ -498,7 +527,6 @@ class EDD_SL_Plugin_Updater {
498
  $version_info = json_decode( wp_remote_retrieve_body( $request ) );
499
  }
500
 
501
-
502
  if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
503
  $version_info->sections = maybe_unserialize( $version_info->sections );
504
  } else {
@@ -511,17 +539,28 @@ class EDD_SL_Plugin_Updater {
511
  }
512
  }
513
 
514
- $this->set_version_info_cache( $version_info, $cache_key );
515
 
 
 
516
  }
517
 
518
- if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
519
- echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
 
 
 
520
  }
521
 
522
  exit;
523
  }
524
 
 
 
 
 
 
 
525
  public function get_cached_version_info( $cache_key = '' ) {
526
 
527
  if( empty( $cache_key ) ) {
@@ -544,6 +583,12 @@ class EDD_SL_Plugin_Updater {
544
 
545
  }
546
 
 
 
 
 
 
 
547
  public function set_version_info_cache( $value = '', $cache_key = '' ) {
548
 
549
  if( empty( $cache_key ) ) {
@@ -557,6 +602,8 @@ class EDD_SL_Plugin_Updater {
557
 
558
  update_option( $cache_key, $data, 'no' );
559
 
 
 
560
  }
561
 
562
  /**
7
  * Allows plugins to use their own update API.
8
  *
9
  * @author Easy Digital Downloads
10
+ * @version 1.8.0
11
  */
12
  class EDD_SL_Plugin_Updater {
13
 
14
+ private $api_url = '';
15
+ private $api_data = array();
16
+ private $name = '';
17
+ private $slug = '';
18
+ private $version = '';
19
+ private $wp_override = false;
20
+ private $cache_key = '';
21
+ private $beta = false;
22
  private $health_check_timeout = 5;
23
 
24
  /**
106
  return $_transient_data;
107
  }
108
 
109
+ $current = $this->get_repo_api_data();
110
+ if ( false !== $current && is_object( $current ) && isset( $current->new_version ) ) {
111
+ if ( version_compare( $this->version, $current->new_version, '<' ) ) {
112
+ $_transient_data->response[ $this->name ] = $current;
113
+ } else {
114
+ // Populating the no_update information is required to support auto-updates in WordPress 5.5.
115
+ $_transient_data->no_update[ $this->name ] = $current;
116
+ }
117
  }
118
+ $_transient_data->last_checked = time();
119
+ $_transient_data->checked[ $this->name ] = $this->version;
120
 
121
+ return $_transient_data;
122
+ }
 
 
 
123
 
124
+ /**
125
+ * Get repo API data from store.
126
+ * Save to cache.
127
+ *
128
+ * @return \stdClass
129
+ */
130
+ public function get_repo_api_data() {
131
+ $version_info = $this->get_cached_version_info();
132
 
133
+ if ( false === $version_info ) {
134
+ $version_info = $this->api_request(
135
+ 'plugin_latest_version',
136
+ array(
137
+ 'slug' => $this->slug,
138
+ 'beta' => $this->beta,
139
+ )
140
+ );
141
+ if ( ! $version_info ) {
142
+ return false;
143
  }
144
 
145
+ // This is required for your plugin to support auto-updates in WordPress 5.5.
146
+ $version_info->plugin = $this->name;
147
+ $version_info->id = $this->name;
148
 
149
+ $this->set_version_info_cache( $version_info );
150
  }
151
 
152
+ return $version_info;
153
  }
154
 
155
  /**
185
 
186
  if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
187
 
188
+ $version_info = $this->get_repo_api_data();
189
 
190
  if ( false === $version_info ) {
191
  $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
203
  $version_info->icons = $this->convert_object_to_array( $version_info->icons );
204
  }
205
 
206
+ if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) {
207
+ $version_info->contributors = $this->convert_object_to_array( $version_info->contributors );
208
+ }
209
+
210
  $this->set_version_info_cache( $version_info );
211
  }
212
 
215
  }
216
 
217
  if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
 
218
  $update_cache->response[ $this->name ] = $version_info;
219
+ } else {
220
+ $update_cache->no_update[ $this->name ] = $version_info;
221
  }
222
 
223
+ $update_cache->last_checked = time();
224
  $update_cache->checked[ $this->name ] = $this->version;
225
 
226
  set_site_transient( 'update_plugins', $update_cache );
305
  )
306
  );
307
 
 
 
308
  // Get the transient where we store the api request for this plugin for 24 hours
309
+ $edd_api_request_transient = $this->get_cached_version_info();
310
 
311
  //If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
312
  if ( empty( $edd_api_request_transient ) ) {
314
  $api_response = $this->api_request( 'plugin_information', $to_send );
315
 
316
  // Expires in 3 hours
317
+ $this->set_version_info_cache( $api_response );
318
 
319
  if ( false !== $api_response ) {
320
  $_data = $api_response;
339
  $_data->icons = $this->convert_object_to_array( $_data->icons );
340
  }
341
 
342
+ // Convert contributors into an associative array, since we're getting an object, but Core expects an array.
343
+ if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
344
+ $_data->contributors = $this->convert_object_to_array( $_data->contributors );
345
+ }
346
+
347
  if( ! isset( $_data->plugin ) ) {
348
  $_data->plugin = $this->name;
349
  }
364
  * @return array
365
  */
366
  private function convert_object_to_array( $data ) {
367
+ if ( ! is_array( $data ) && ! is_object( $data ) ) {
368
+ return array();
369
+ }
370
  $new_data = array();
371
  foreach ( $data as $key => $value ) {
372
+ $new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
373
  }
374
 
375
  return $new_data;
428
  }
429
 
430
  if ( false === $edd_plugin_url_available[ $store_hash ] ) {
431
+ return false;
432
  }
433
 
434
  $data = array_merge( $this->api_data, $_data );
435
 
436
  if ( $data['slug'] != $this->slug ) {
437
+ return false;
438
  }
439
 
440
+ if ( $this->api_url == trailingslashit ( home_url() ) ) {
441
  return false; // Don't allow a plugin to ping itself
442
  }
443
 
473
  $request->icons = maybe_unserialize( $request->icons );
474
  }
475
 
476
+ if ( ! empty( $request->sections ) ) {
477
  foreach( $request->sections as $key => $section ) {
478
  $request->$key = (array) $section;
479
  }
482
  return $request;
483
  }
484
 
485
+ /**
486
+ * If available, show the changelog for sites in a multisite install.
487
+ */
488
  public function show_changelog() {
489
 
490
  global $edd_plugin_data;
506
  }
507
 
508
  $data = $edd_plugin_data[ $_REQUEST['slug'] ];
509
+ $version_info = $this->get_cached_version_info();
 
 
510
 
511
  if( false === $version_info ) {
512
 
527
  $version_info = json_decode( wp_remote_retrieve_body( $request ) );
528
  }
529
 
 
530
  if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
531
  $version_info->sections = maybe_unserialize( $version_info->sections );
532
  } else {
539
  }
540
  }
541
 
542
+ $this->set_version_info_cache( $version_info );
543
 
544
+ // Delete the unneeded option
545
+ delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
546
  }
547
 
548
+ if ( isset( $version_info->sections ) ) {
549
+ $sections = $this->convert_object_to_array( $version_info->sections );
550
+ if ( ! empty( $sections['changelog'] ) ) {
551
+ echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
552
+ }
553
  }
554
 
555
  exit;
556
  }
557
 
558
+ /**
559
+ * Gets the plugin's cached version information from the database.
560
+ *
561
+ * @param string $cache_key
562
+ * @return boolean|string
563
+ */
564
  public function get_cached_version_info( $cache_key = '' ) {
565
 
566
  if( empty( $cache_key ) ) {
583
 
584
  }
585
 
586
+ /**
587
+ * Adds the plugin version information to the database.
588
+ *
589
+ * @param string $value
590
+ * @param string $cache_key
591
+ */
592
  public function set_version_info_cache( $value = '', $cache_key = '' ) {
593
 
594
  if( empty( $cache_key ) ) {
602
 
603
  update_option( $cache_key, $data, 'no' );
604
 
605
+ // Delete the duplicate option
606
+ delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
607
  }
608
 
609
  /**
includes/notification/post-notification.php CHANGED
@@ -21,10 +21,12 @@ function bnfw_post_notifications( $notifications, $post_type ) {
21
  $notifications[] = 'future-' . $post_type;
22
  $notifications[] = 'comment-' . $post_type;
23
  $notifications[] = 'moderate-' . $post_type . '-comment';
 
24
  if($post_type == 'post'){
25
  $notifications[] = 'new-comment';
26
  $notifications[] = 'new-trackback';
27
  $notifications[] = 'new-pingback';
 
28
  }
29
  return $notifications;
30
  }
21
  $notifications[] = 'future-' . $post_type;
22
  $notifications[] = 'comment-' . $post_type;
23
  $notifications[] = 'moderate-' . $post_type . '-comment';
24
+ $notifications[] = 'approve-' . $post_type . '-comment';
25
  if($post_type == 'post'){
26
  $notifications[] = 'new-comment';
27
  $notifications[] = 'new-trackback';
28
  $notifications[] = 'new-pingback';
29
+ $notifications[] = 'approve-comment';
30
  }
31
  return $notifications;
32
  }
vendor/persist-admin-notices-dismissal/CHANGES.md ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### 1.4.4
2
+ * Added support for extra dismissible links via `.dismiss-this` CSS class.
3
+
4
+ #### 1.4.3
5
+ * Added filter hook `pand_dismiss_notice_js_url` in case you're using this in a theme or a local environment that doesn't quite find the correct URL.
6
+ * Added filter hook `pand_theme_loader` that returns a boolean for simpler usage of the `pand_dismiss_notice_js_url` hook
7
+
8
+ #### 1.4.2
9
+ * No changes to `class PAnD`
10
+ * Updated `.gitignore` and `.gitattributes`
11
+ * Now use classmap in composer's autoloader, should be more efficient
12
+
13
+ #### 1.4.1
14
+ * Fixed the `forever` setting with options
15
+
16
+ #### 1.4.0
17
+ * WPCS 1.1.0 linting done
18
+ * Switched from storing timeout in transients to storing in the options table, this should play much better with object caching
19
+
20
+ #### 1.3.x
21
+ * Uses transients to store timeout
vendor/persist-admin-notices-dismissal/README.md CHANGED
@@ -42,7 +42,7 @@ function sample_admin_notice__success() {
42
  if ( ! PAnD::is_admin_notice_active( 'disable-done-notice-forever' ) ) {
43
  return;
44
  }
45
-
46
  ?>
47
  <div data-dismissible="disable-done-notice-forever" class="updated notice notice-success is-dismissible">
48
  <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
@@ -61,7 +61,7 @@ Just add the following in your main plugin file.
61
  ```php
62
  add_action( 'admin_init', array( 'PAnD', 'init' ) );
63
  ```
64
-
65
  #### Usage Instructions and Examples
66
  If you have two notices displayed when certain actions are triggered; firstly, choose a string to uniquely identify them, e.g. `notice-one` and `notice-two`
67
 
@@ -104,5 +104,25 @@ add_action( 'admin_notices', 'sample_admin_notice__success1' );
104
  add_action( 'admin_notices', 'sample_admin_notice__success2' );
105
  ```
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  Cool beans. Isn't it?
42
  if ( ! PAnD::is_admin_notice_active( 'disable-done-notice-forever' ) ) {
43
  return;
44
  }
45
+
46
  ?>
47
  <div data-dismissible="disable-done-notice-forever" class="updated notice notice-success is-dismissible">
48
  <p><?php _e( 'Done!', 'sample-text-domain' ); ?></p>
61
  ```php
62
  add_action( 'admin_init', array( 'PAnD', 'init' ) );
63
  ```
64
+
65
  #### Usage Instructions and Examples
66
  If you have two notices displayed when certain actions are triggered; firstly, choose a string to uniquely identify them, e.g. `notice-one` and `notice-two`
67
 
104
  add_action( 'admin_notices', 'sample_admin_notice__success2' );
105
  ```
106
 
107
+ Please note that if you cleanup after your plugin deletion please try to make the removal of stored options as specific as possible. Otherwise you may end up deleting the stored options from other projects.
108
+
109
+ A filter hook is available to return the proper URL to the Javascript file. An example usage is as follows, especially if this is being used in a theme.
110
+
111
+ ```php
112
+ add_filter( 'pand_theme_loader', '__return_true' );
113
+ ```
114
+
115
+ The `pand_theme_loader` runs the following hook if `true`. You can directly change the URL to the Javascript file by using another hook in the following manner by changing the return value.
116
+
117
+ ```php
118
+ add_filter(
119
+ 'pand_dismiss_notice_js_url',
120
+ function( $js_url, $composer_path ) {
121
+ return get_stylesheet_directory_uri() . $composer_path;
122
+ },
123
+ 10,
124
+ 2
125
+ );
126
+ ```
127
 
128
  Cool beans. Isn't it?
vendor/persist-admin-notices-dismissal/composer.json CHANGED
@@ -1,15 +1,27 @@
1
  {
2
  "name": "collizo4sky/persist-admin-notices-dismissal",
3
  "description": "Simple library to persist dismissal of admin notices across pages in WordPress dashboard.",
 
 
 
4
  "authors": [
5
  {
6
  "name": "Collins Agbonghama",
7
- "email": "me@w3guy.com"
 
8
  }
9
  ],
 
 
 
 
 
 
 
 
10
  "autoload": {
11
- "files": [
12
  "persist-admin-notices-dismissal.php"
13
  ]
14
  }
15
- }
1
  {
2
  "name": "collizo4sky/persist-admin-notices-dismissal",
3
  "description": "Simple library to persist dismissal of admin notices across pages in WordPress dashboard.",
4
+ "version": "1.4.4",
5
+ "type": "library",
6
+ "license": "GPL-3.0-or-later",
7
  "authors": [
8
  {
9
  "name": "Collins Agbonghama",
10
+ "email": "me@w3guy.com",
11
+ "role": "developer"
12
  }
13
  ],
14
+ "prefer-stable": true,
15
+ "require": {
16
+ "php": ">=5.4"
17
+ },
18
+ "support": {
19
+ "issues": "https://github.com/w3guy/persist-admin-notices-dismissal/issues",
20
+ "source": "https://github.com/w3guy/persist-admin-notices-dismissal"
21
+ },
22
  "autoload": {
23
+ "classmap": [
24
  "persist-admin-notices-dismissal.php"
25
  ]
26
  }
27
+ }
vendor/persist-admin-notices-dismissal/dismiss-notice.js CHANGED
@@ -1,29 +1,34 @@
1
  (function ($) {
2
- //shorthand for ready event.
3
- $(function () {
4
- $('div[data-dismissible] button.notice-dismiss').click(function (event) {
5
- event.preventDefault();
6
- var $this = $(this);
 
 
7
 
8
- var attr_value, option_name, dismissible_length, data;
9
 
10
- attr_value = $this.parent().attr('data-dismissible').split('-');
11
 
12
- // remove the dismissible length from the attribute value and rejoin the array.
13
- dismissible_length = attr_value.pop();
14
 
15
- option_name = attr_value.join('-');
16
 
17
- data = {
18
- 'action': 'dismiss_admin_notice',
19
- 'option_name': option_name,
20
- 'dismissible_length': dismissible_length,
21
- 'nonce': dismissible_notice.nonce
22
- };
23
 
24
- // We can also pass the url value separately from ajaxurl for front end AJAX implementations
25
- $.post(ajaxurl, data);
26
- });
27
- })
 
 
 
28
 
29
  }(jQuery));
1
  (function ($) {
2
+ //shorthand for ready event.
3
+ $(
4
+ function () {
5
+ $( 'div[data-dismissible] button.notice-dismiss, div[data-dismissible] .dismiss-this' ).on("click",
6
+ function (event) {
7
+ event.preventDefault();
8
+ var $this = $( this );
9
 
10
+ var attr_value, option_name, dismissible_length, data;
11
 
12
+ attr_value = $this.closest("div[data-dismissible]").attr( 'data-dismissible' ).split( '-' );
13
 
14
+ // remove the dismissible length from the attribute value and rejoin the array.
15
+ dismissible_length = attr_value.pop();
16
 
17
+ option_name = attr_value.join( '-' );
18
 
19
+ data = {
20
+ 'action': 'dismiss_admin_notice',
21
+ 'option_name': option_name,
22
+ 'dismissible_length': dismissible_length,
23
+ 'nonce': dismissible_notice.nonce
24
+ };
25
 
26
+ // We can also pass the url value separately from ajaxurl for front end AJAX implementations
27
+ $.post( ajaxurl, data );
28
+ $this.closest("div[data-dismissible]").hide('slow');
29
+ }
30
+ );
31
+ }
32
+ )
33
 
34
  }(jQuery));
vendor/persist-admin-notices-dismissal/persist-admin-notices-dismissal.php CHANGED
@@ -1,9 +1,8 @@
1
  <?php
2
-
3
  /**
4
  * Persist Admin notices Dismissal
5
  *
6
- * Copyright (C) 2016 Agbonghama Collins <http://w3guy.com>
7
  *
8
  * This program is free software: you can redistribute it and/or modify
9
  * it under the terms of the GNU General Public License as published by
@@ -19,10 +18,8 @@
19
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
  *
21
  * @package Persist Admin notices Dismissal
22
- * @author Agbonghama Collins
23
- * @author Andy Fragen
24
  * @license http://www.gnu.org/licenses GNU General Public License
25
- * @version 1.3.2
26
  */
27
 
28
  /**
@@ -45,6 +42,24 @@ if ( ! class_exists( 'PAnD' ) ) {
45
  public static function init() {
46
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
47
  add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  /**
@@ -52,11 +67,25 @@ if ( ! class_exists( 'PAnD' ) ) {
52
  */
53
  public static function load_script() {
54
 
55
- if(is_customize_preview()) return;
 
 
56
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  wp_enqueue_script(
58
  'dismissible-notices',
59
- plugins_url( 'dismiss-notice.js', __FILE__ ),
60
  array( 'jquery', 'common' ),
61
  false,
62
  true
@@ -76,19 +105,17 @@ if ( ! class_exists( 'PAnD' ) ) {
76
  * Uses check_ajax_referer to verify nonce.
77
  */
78
  public static function dismiss_admin_notice() {
79
- $option_name = sanitize_text_field( $_POST['option_name'] );
80
- $dismissible_length = sanitize_text_field( $_POST['dismissible_length'] );
81
- $transient = 0;
82
-
83
- if ( 'forever' != $dismissible_length ) {
84
- // If $dismissible_length is not an integer default to 1
85
- $dismissible_length = ( 0 == absint( $dismissible_length ) ) ? 1 : $dismissible_length;
86
- $transient = absint( $dismissible_length ) * DAY_IN_SECONDS;
87
  $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
88
  }
89
 
90
  check_ajax_referer( 'dismissible-notice', 'nonce' );
91
- set_site_transient( $option_name, $dismissible_length, $transient );
92
  wp_die();
93
  }
94
 
@@ -103,9 +130,9 @@ if ( ! class_exists( 'PAnD' ) ) {
103
  $array = explode( '-', $arg );
104
  $length = array_pop( $array );
105
  $option_name = implode( '-', $array );
106
- $db_record = get_site_transient( $option_name );
107
 
108
- if ( 'forever' == $db_record ) {
109
  return false;
110
  } elseif ( absint( $db_record ) >= time() ) {
111
  return false;
@@ -114,6 +141,47 @@ if ( ! class_exists( 'PAnD' ) ) {
114
  }
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  }
118
 
119
  }
1
  <?php
 
2
  /**
3
  * Persist Admin notices Dismissal
4
  *
5
+ * Copyright (C) 2016 Collins Agbonghama <https://w3guy.com>
6
  *
7
  * This program is free software: you can redistribute it and/or modify
8
  * it under the terms of the GNU General Public License as published by
18
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
  *
20
  * @package Persist Admin notices Dismissal
21
+ * @author Collins Agbonghama, Andy Fragen
 
22
  * @license http://www.gnu.org/licenses GNU General Public License
 
23
  */
24
 
25
  /**
42
  public static function init() {
43
  add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_script' ) );
44
  add_action( 'wp_ajax_dismiss_admin_notice', array( __CLASS__, 'dismiss_admin_notice' ) );
45
+
46
+ /**
47
+ * Filter to activate another filter providing a simpler use case.
48
+ *
49
+ * @since 1.4.3
50
+ *
51
+ * @param bool
52
+ */
53
+ if ( apply_filters( 'pand_theme_loader', false ) ) {
54
+ add_filter(
55
+ 'pand_dismiss_notice_js_url',
56
+ function( $js_url, $composer_path ) {
57
+ return get_stylesheet_directory_uri() . $composer_path;
58
+ },
59
+ 10,
60
+ 2
61
+ );
62
+ }
63
  }
64
 
65
  /**
67
  */
68
  public static function load_script() {
69
 
70
+ if ( is_customize_preview() ) {
71
+ return;
72
+ }
73
 
74
+ $js_url = plugins_url( 'dismiss-notice.js', __FILE__ );
75
+ $composer_path = '/vendor/collizo4sky/persist-admin-notices-dismissal/dismiss-notice.js';
76
+
77
+ /**
78
+ * Filter dismiss-notice.js URL.
79
+ *
80
+ * @since 1.4.3
81
+ *
82
+ * @param string $js_url URL to the Javascript file.
83
+ * @param string $composer_path Relative path of Javascript file from composer install.
84
+ */
85
+ $js_url = apply_filters( 'pand_dismiss_notice_js_url', $js_url, $composer_path );
86
  wp_enqueue_script(
87
  'dismissible-notices',
88
+ $js_url,
89
  array( 'jquery', 'common' ),
90
  false,
91
  true
105
  * Uses check_ajax_referer to verify nonce.
106
  */
107
  public static function dismiss_admin_notice() {
108
+ $option_name = isset( $_POST['option_name'] ) ? sanitize_text_field( wp_unslash( $_POST['option_name'] ) ) : '';
109
+ $dismissible_length = isset( $_POST['dismissible_length'] ) ? sanitize_text_field( wp_unslash( $_POST['dismissible_length'] ) ) : 0;
110
+
111
+ if ( 'forever' !== $dismissible_length ) {
112
+ // If $dismissible_length is not an integer default to 1.
113
+ $dismissible_length = ( 0 === absint( $dismissible_length ) ) ? 1 : $dismissible_length;
 
 
114
  $dismissible_length = strtotime( absint( $dismissible_length ) . ' days' );
115
  }
116
 
117
  check_ajax_referer( 'dismissible-notice', 'nonce' );
118
+ self::set_admin_notice_cache( $option_name, $dismissible_length );
119
  wp_die();
120
  }
121
 
130
  $array = explode( '-', $arg );
131
  $length = array_pop( $array );
132
  $option_name = implode( '-', $array );
133
+ $db_record = self::get_admin_notice_cache( $option_name );
134
 
135
+ if ( 'forever' === $db_record ) {
136
  return false;
137
  } elseif ( absint( $db_record ) >= time() ) {
138
  return false;
141
  }
142
  }
143
 
144
+ /**
145
+ * Returns admin notice cached timeout.
146
+ *
147
+ * @access public
148
+ *
149
+ * @param string|bool $id admin notice name or false.
150
+ *
151
+ * @return array|bool The timeout. False if expired.
152
+ */
153
+ public static function get_admin_notice_cache( $id = false ) {
154
+ if ( ! $id ) {
155
+ return false;
156
+ }
157
+ $cache_key = 'pand-' . md5( $id );
158
+ $timeout = get_site_option( $cache_key );
159
+ $timeout = 'forever' === $timeout ? time() + 60 : $timeout;
160
+
161
+ if ( empty( $timeout ) || time() > $timeout ) {
162
+ return false;
163
+ }
164
+
165
+ return $timeout;
166
+ }
167
+
168
+ /**
169
+ * Sets admin notice timeout in site option.
170
+ *
171
+ * @access public
172
+ *
173
+ * @param string $id Data Identifier.
174
+ * @param string|bool $timeout Timeout for admin notice.
175
+ *
176
+ * @return bool
177
+ */
178
+ public static function set_admin_notice_cache( $id, $timeout ) {
179
+ $cache_key = 'pand-' . md5( $id );
180
+ update_site_option( $cache_key, $timeout );
181
+
182
+ return true;
183
+ }
184
+
185
  }
186
 
187
  }