Speed Booster Pack - Version 4.0.1

Version Description

Release Date: 31 July 2020

  • Fixed: Small issues with the external notices are resolved.
Download this release

Release Info

Developer optimocha
Plugin Icon 128x128 Speed Booster Pack
Version 4.0.1
Comparing to
See all releases

Code changes from version 4.0.0 to 4.0.1

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: speed, pagespeed, optimization, performance, cache
5
  Requires at least: 4.6
6
  Tested up to: 5.5
7
  Requires PHP: 5.6
8
- Stable tag: 4.0.0
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -101,11 +101,13 @@ All the time! We're always looking for new ways to get this plugin to a better s
101
  == Screenshots ==
102
  1. Plugin options page
103
 
104
- == Upgrade Notice ==
105
 
106
- Speed Booster Pack v4.0 is written from scratch! With the new options framework, your current options will be migrated to the new codebase but make sure you review your options after updating the plugin to the latest version.
107
 
108
- == Changelog ==
 
 
109
 
110
  = 4.0.0 =
111
 
5
  Requires at least: 4.6
6
  Tested up to: 5.5
7
  Requires PHP: 5.6
8
+ Stable tag: 4.0.1
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
101
  == Screenshots ==
102
  1. Plugin options page
103
 
104
+ == Changelog ==
105
 
106
+ = 4.0.1 =
107
 
108
+ *Release Date: 31 July 2020*
109
+
110
+ * **Fixed**: Small issues with the external notices are resolved.
111
 
112
  = 4.0.0 =
113
 
includes/classes/class-sbp-migrator.php CHANGED
@@ -59,7 +59,7 @@ class SBP_Migrator {
59
  });
60
  });
61
  })';
62
- wp_add_inline_script( 'jquery', $dismiss_notice_script, 'footer' );
63
  } );
64
  add_action( 'admin_notices', [ $this, 'display_update_notice' ] );
65
  }
@@ -77,6 +77,7 @@ class SBP_Migrator {
77
  $this->migrate_declutter_settings();
78
  $this->migrate_cdn_settings();
79
  $this->migrate_exclude_rules();
 
80
  update_option( 'sbp_options', $this->sbp_options );
81
  wp_redirect( admin_url( 'admin.php?page=sbp-settings' ) );
82
  }
@@ -138,6 +139,10 @@ ga('send', 'pageview');";
138
  }
139
  }
140
 
 
 
 
 
141
  private function migrate_exclude_rules() {
142
  $exclude_options = [
143
  'sbp_lazyload_exclusions' => 'lazyload_exclude',
59
  });
60
  });
61
  })';
62
+ wp_add_inline_script( 'jquery', $dismiss_notice_script );
63
  } );
64
  add_action( 'admin_notices', [ $this, 'display_update_notice' ] );
65
  }
77
  $this->migrate_declutter_settings();
78
  $this->migrate_cdn_settings();
79
  $this->migrate_exclude_rules();
80
+ $this->enable_external_notices();
81
  update_option( 'sbp_options', $this->sbp_options );
82
  wp_redirect( admin_url( 'admin.php?page=sbp-settings' ) );
83
  }
139
  }
140
  }
141
 
142
+ private function enable_external_notices() {
143
+ $this->sbp_options['enable_external_notices'] = '1';
144
+ }
145
+
146
  private function migrate_exclude_rules() {
147
  $exclude_options = [
148
  'sbp_lazyload_exclusions' => 'lazyload_exclude',
includes/libs/announce4wp/announce4wp-client.php CHANGED
@@ -4,20 +4,20 @@ if ( ! class_exists( "Announce4WP_Client" ) ) {
4
  class Announce4WP_Client {
5
  private $api_endpoint_url = '';
6
  private $service_id = '';
7
- private $transient_name = '';
8
  private $settings_screen = '';
9
  private $plugin_name = '';
10
  private $plugin_file_name = '';
 
11
 
12
  public function __construct( $plugin_file_name, $plugin_name, $service_id, $api_endpoint_url, $settings_screen ) {
13
- $this->service_id = $service_id;
14
- $this->api_endpoint_url = $api_endpoint_url;
15
- $this->settings_screen = $settings_screen;
16
- $this->plugin_file_name = $plugin_file_name;
17
- $this->plugin_name = $plugin_name;
18
- $this->transient_name = 'a4wp_' . $this->service_id . '_announcements';
19
 
20
- add_action( 'admin_init', [ $this, 'save_notices' ] );
21
 
22
  // Enqueue Dismiss Script
23
  add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
@@ -29,32 +29,41 @@ if ( ! class_exists( "Announce4WP_Client" ) ) {
29
  add_action( 'wp_ajax_a4wp_dismiss_notice', [ $this, 'dismiss_notice' ] );
30
  }
31
 
32
- public function save_notices() {
33
- if ( ! current_user_can( 'manage_options' ) ) {
34
- return;
35
- }
36
 
37
- if ( get_transient( $this->transient_name ) ) {
38
  return;
39
  }
40
 
41
- $remote_notices = $this->fetch_notices();
42
- if ( ! $remote_notices ) {
 
43
  return;
44
  }
45
 
46
- // Update transient
47
- set_transient( $this->transient_name, $remote_notices, 12 * HOUR_IN_SECONDS );
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
- private function fetch_notices() {
51
- $notices = wp_remote_get( $this->api_endpoint_url );
52
- if ( $notices instanceof WP_Error ) {
53
- return false;
54
  }
55
- $notices = json_decode( $notices['body'], true );
56
 
57
- return $notices;
 
58
  }
59
 
60
  public function enqueue_scripts() {
@@ -100,16 +109,16 @@ if ( ! class_exists( "Announce4WP_Client" ) ) {
100
  }
101
 
102
  public function display_notices() {
103
- $announcements = get_transient( $this->transient_name );
104
- if ( is_array( $announcements ) && isset( $announcements['normal_notices'] ) ) {
105
- foreach ( $announcements['normal_notices'] as $notice ) {
106
  $attributes = $this->parse_attributes( $notice['rules'] );
107
  $this->print_notice( $attributes, $notice );
108
  }
109
  }
110
 
111
- if ( is_array( $announcements ) && isset( $announcements["important_notices"] ) ) {
112
- foreach ( $announcements["important_notices"] as $notice ) {
113
  $attributes = $this->parse_attributes( $notice['rules'] );
114
  $this->print_notice( $attributes, $notice, true );
115
  }
4
  class Announce4WP_Client {
5
  private $api_endpoint_url = '';
6
  private $service_id = '';
 
7
  private $settings_screen = '';
8
  private $plugin_name = '';
9
  private $plugin_file_name = '';
10
+ private $option_name = '';
11
 
12
  public function __construct( $plugin_file_name, $plugin_name, $service_id, $api_endpoint_url, $settings_screen ) {
13
+ $this->service_id = $service_id;
14
+ $this->api_endpoint_url = $api_endpoint_url;
15
+ $this->settings_screen = $settings_screen;
16
+ $this->plugin_file_name = $plugin_file_name;
17
+ $this->plugin_name = $plugin_name;
18
+ $this->option_name = $this->service_id . '_announcements';
19
 
20
+ add_action( 'admin_init', [ $this, 'get_notices' ] );
21
 
22
  // Enqueue Dismiss Script
23
  add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
29
  add_action( 'wp_ajax_a4wp_dismiss_notice', [ $this, 'dismiss_notice' ] );
30
  }
31
 
32
+ public function get_notices() {
 
 
 
33
 
34
+ if( ! current_user_can( 'manage_options' ) || wp_doing_ajax() ) {
35
  return;
36
  }
37
 
38
+ $notices = get_option( $this->option_name );
39
+
40
+ if( $notices && time() < $notices['expiry'] ) {
41
  return;
42
  }
43
 
44
+ $notices_expiry = 24 * 3600;
45
+ $error_expiry = 3600;
46
+
47
+ $data = wp_remote_get( $this->api_endpoint_url );
48
+
49
+ if ( is_array( $data ) && ! is_wp_error( $data ) ) {
50
+
51
+ update_option( $this->option_name, [
52
+ 'data' => json_decode( $data['body'], true ),
53
+ 'expiry' => time() + $notices_expiry
54
+ ] );
55
+
56
+ } else {
57
+
58
+ update_option( $this->option_name, [
59
+ 'data' => 'error',
60
+ 'expiry' => time() + $error_expiry
61
+ ] );
62
 
 
 
 
 
63
  }
 
64
 
65
+ return;
66
+
67
  }
68
 
69
  public function enqueue_scripts() {
109
  }
110
 
111
  public function display_notices() {
112
+ $announcements = get_option( $this->option_name );
113
+ if ( is_array( $announcements['data'] ) && isset( $announcements['data']['normal_notices'] ) ) {
114
+ foreach ( $announcements['data']['normal_notices'] as $notice ) {
115
  $attributes = $this->parse_attributes( $notice['rules'] );
116
  $this->print_notice( $attributes, $notice );
117
  }
118
  }
119
 
120
+ if ( is_array( $announcements['data'] ) && isset( $announcements['data']["important_notices"] ) ) {
121
+ foreach ( $announcements['data']["important_notices"] as $notice ) {
122
  $attributes = $this->parse_attributes( $notice['rules'] );
123
  $this->print_notice( $attributes, $notice, true );
124
  }
speed-booster-pack.php CHANGED
@@ -1,15 +1,12 @@
1
  <?php
2
 
3
  /**
4
- * @link https://speedboosterpack.com
5
- * @since 4.0.0
6
- * @package Speed_Booster_Pack
7
  *
8
  * @wordpress-plugin
9
  * Plugin Name: Speed Booster Pack
10
  * Plugin URI: https://speedboosterpack.com
11
  * Description: PageSpeed optimization is vital for SEO: A faster website equals better conversions. Optimize & cache your site with this smart plugin!
12
- * Version: 4.0.0
13
  * Author: Optimocha
14
  * Author URI: https://optimocha.com
15
  * License: GPLv3 or later
@@ -35,7 +32,7 @@ define( 'SBP_PLUGIN_NAME', 'Speed Booster Pack' );
35
  /**
36
  * Current plugin version.
37
  */
38
- define( 'SBP_VERSION', '4.0.0' );
39
 
40
  /**
41
  * Plugin website URL.
1
  <?php
2
 
3
  /**
 
 
 
4
  *
5
  * @wordpress-plugin
6
  * Plugin Name: Speed Booster Pack
7
  * Plugin URI: https://speedboosterpack.com
8
  * Description: PageSpeed optimization is vital for SEO: A faster website equals better conversions. Optimize & cache your site with this smart plugin!
9
+ * Version: 4.0.1
10
  * Author: Optimocha
11
  * Author URI: https://optimocha.com
12
  * License: GPLv3 or later
32
  /**
33
  * Current plugin version.
34
  */
35
+ define( 'SBP_VERSION', '4.0.1' );
36
 
37
  /**
38
  * Plugin website URL.
uninstall.php CHANGED
@@ -30,4 +30,6 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
30
  die;
31
  }
32
 
33
- delete_option( 'sbp_options' );
 
 
30
  die;
31
  }
32
 
33
+ delete_option( 'sbp_options' );
34
+ delete_option( 'sbp_notice_error' );
35
+ delete_option( 'sbp_transient_error' );