Speed Booster Pack - Version 4.5.4

Version Description

Release Date: 27 May 2022

  • Improved: Some code refactoring.
  • Improved: Lazy loading should perform even better now.
  • Fixed: Semi-important issue regarding an unintentional redirect.
  • Fixed: Some smaller, less-annoying bugs.
Download this release

Release Info

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

Code changes from version 4.5.3 to 4.5.4

README.txt CHANGED
@@ -5,7 +5,7 @@ Tags: speed, pagespeed, optimization, core web vitals, cache
5
  Requires at least: 4.6
6
  Tested up to: 6.0
7
  Requires PHP: 5.6
8
- Stable tag: 4.5.3
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -103,6 +103,15 @@ All the time! We're always looking for new ways to get this plugin to a better s
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
 
 
 
 
106
  = 4.5.3 =
107
 
108
  *Release Date: 18 May 2022*
5
  Requires at least: 4.6
6
  Tested up to: 6.0
7
  Requires PHP: 5.6
8
+ Stable tag: 4.5.4
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
103
 
104
  == Changelog ==
105
 
106
+ = 4.5.4 =
107
+
108
+ *Release Date: 27 May 2022*
109
+
110
+ * **Improved**: Some code refactoring.
111
+ * **Improved**: Lazy loading should perform even better now.
112
+ * **Fixed**: Semi-important issue regarding an unintentional redirect.
113
+ * **Fixed**: Some smaller, less-annoying bugs.
114
+
115
  = 4.5.3 =
116
 
117
  *Release Date: 18 May 2022*
admin/class-speed-booster-pack-admin.php CHANGED
@@ -147,6 +147,8 @@ class Speed_Booster_Pack_Admin {
147
 
148
  public static function redirect() {
149
 
 
 
150
  // Make sure it's the correct user
151
  if ( intval( get_option( 'sbp_activation_redirect', false ) ) === wp_get_current_user()->ID ) {
152
  // Make sure we don't redirect again after this one
147
 
148
  public static function redirect() {
149
 
150
+ if( ! get_option( 'sbp_activation_redirect' ) || ! current_user_can( 'manage_options' ) ) { return; }
151
+
152
  // Make sure it's the correct user
153
  if ( intval( get_option( 'sbp_activation_redirect', false ) ) === wp_get_current_user()->ID ) {
154
  // Make sure we don't redirect again after this one
includes/class-speed-booster-pack.php CHANGED
@@ -23,8 +23,6 @@ use SpeedBooster\SBP_CDN;
23
  use SpeedBooster\SBP_Compatibility_Checker;
24
  use SpeedBooster\SBP_Critical_CSS;
25
  use SpeedBooster\SBP_CSS_Minifier;
26
- // Z_TODO: Remove use
27
- use SpeedBooster\SBP_Custom_Code_Manager;
28
  use SpeedBooster\SBP_Database_Optimizer;
29
  use SpeedBooster\SBP_Image_Dimensions;
30
  use SpeedBooster\SBP_LiteSpeed_Cache;
@@ -97,23 +95,34 @@ class Speed_Booster_Pack {
97
  * @since 4.0.0
98
  */
99
  public function __construct() {
100
- if ( defined( 'SBP_VERSION' ) ) {
101
- $this->version = SBP_VERSION;
102
- } else {
103
- $this->version = '4.0.0';
104
- }
105
  $this->plugin_name = 'speed-booster-pack';
106
 
107
  $this->load_dependencies();
108
  $this->save_post_types();
109
  $this->set_locale();
110
- $this->init_modules();
111
  $this->define_admin_hooks();
112
- $this->define_public_hooks();
113
- $this->define_public_filters();
 
 
 
 
114
  }
115
 
116
  private function should_plugin_run() {
 
 
 
 
 
 
 
 
 
 
 
117
  $query_strings_to_exclude = [
118
  "sbp_disable" => "1", // speed booster pack
119
  "elementor-preview" => "elementor", // elementor
@@ -158,9 +167,6 @@ class Speed_Booster_Pack {
158
  * Every class has inner documentation.
159
  */
160
  private function init_modules() {
161
- if ( ! $this->should_plugin_run() ) {
162
- return;
163
- }
164
  new SBP_WP_Admin();
165
  new SBP_Database_Optimizer();
166
  new SBP_Newsletter();
@@ -178,8 +184,6 @@ class Speed_Booster_Pack {
178
  new SBP_HTML_Minifier();
179
  new SBP_Localize_Tracker();
180
  new SBP_Woocommerce();
181
- // Z_TODO: Remove instance
182
- new SBP_Custom_Code_Manager();
183
  new SBP_Cloudflare();
184
  new SBP_Notice_Manager();
185
  new SBP_Sucuri();
@@ -267,14 +271,18 @@ class Speed_Booster_Pack {
267
  */
268
  private function define_admin_hooks() {
269
 
270
- if ( ! is_admin() ) { return; }
 
 
271
 
272
- $plugin_admin = new Speed_Booster_Pack_Admin( $this->get_plugin_name(), $this->get_version() );
273
 
274
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
275
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
 
276
  $this->loader->add_action( 'admin_init', $plugin_admin, 'set_up_defaults' );
277
  $this->loader->add_action( 'admin_init', $plugin_admin, 'redirect' );
 
278
  }
279
 
280
  /**
@@ -288,21 +296,16 @@ class Speed_Booster_Pack {
288
 
289
  if ( is_admin() || wp_doing_cron() || wp_doing_ajax() ) { return; }
290
 
291
- $plugin_public = new Speed_Booster_Pack_Public( $this->get_plugin_name(), $this->get_version() );
292
 
293
  $this->loader->add_action( 'init', $plugin_public, 'template_redirect', 1 );
294
 
295
  // $this->loader->add_action( 'shutdown', $plugin_public, 'shutdown', PHP_INT_MAX );
296
 
297
  $this->loader->add_filter( 'wp_headers', $plugin_public, 'sbp_headers' );
298
- }
299
-
300
- /**
301
- * @since 4.1.2
302
- */
303
- private function define_public_filters() {
304
  add_filter( 'aioseo_flush_output_buffer', '__return_false' );
305
- add_filter( 'rocket_plugins_to_deactivate', '__return_empty_array' );
306
  }
307
 
308
  private function save_post_types() {
@@ -310,7 +313,7 @@ class Speed_Booster_Pack {
310
  $post_types = array_keys( get_post_types( [ 'public' => true ] ) );
311
  $saved_post_types = get_option( 'sbp_public_post_types' );
312
 
313
- if ( ! $saved_post_types || $saved_post_types != $post_types ) {
314
  update_option( 'sbp_public_post_types', $post_types );
315
  }
316
  });
@@ -325,17 +328,6 @@ class Speed_Booster_Pack {
325
  $this->loader->run();
326
  }
327
 
328
- /**
329
- * The name of the plugin used to uniquely identify it within the context of
330
- * WordPress and to define internationalization functionality.
331
- *
332
- * @return string The name of the plugin.
333
- * @since 4.0.0
334
- */
335
- public function get_plugin_name() {
336
- return $this->plugin_name;
337
- }
338
-
339
  /**
340
  * The reference to the class that orchestrates the hooks with the plugin.
341
  *
@@ -346,14 +338,4 @@ class Speed_Booster_Pack {
346
  return $this->loader;
347
  }
348
 
349
- /**
350
- * Retrieve the version number of the plugin.
351
- *
352
- * @return string The version number of the plugin.
353
- * @since 4.0.0
354
- */
355
- public function get_version() {
356
- return $this->version;
357
- }
358
-
359
  }
23
  use SpeedBooster\SBP_Compatibility_Checker;
24
  use SpeedBooster\SBP_Critical_CSS;
25
  use SpeedBooster\SBP_CSS_Minifier;
 
 
26
  use SpeedBooster\SBP_Database_Optimizer;
27
  use SpeedBooster\SBP_Image_Dimensions;
28
  use SpeedBooster\SBP_LiteSpeed_Cache;
95
  * @since 4.0.0
96
  */
97
  public function __construct() {
98
+
99
+ $this->version = SBP_VERSION;
 
 
 
100
  $this->plugin_name = 'speed-booster-pack';
101
 
102
  $this->load_dependencies();
103
  $this->save_post_types();
104
  $this->set_locale();
 
105
  $this->define_admin_hooks();
106
+
107
+ if ( $this->should_plugin_run() ) {
108
+ $this->init_modules();
109
+ $this->define_public_hooks();
110
+ }
111
+
112
  }
113
 
114
  private function should_plugin_run() {
115
+
116
+ if ( preg_match( '/(_wp-|\.txt|\.pdf|\.xml|\.svg|\.ico|wp-json|\.gz|\/feed\/?)/', $_SERVER['REQUEST_URI'] ) ) {
117
+ return false;
118
+ }
119
+
120
+ $login_path = parse_url( wp_login_url(), PHP_URL_PATH );
121
+
122
+ if( false !== stripos( $_SERVER[ 'REQUEST_URI' ], $login_path ) ) {
123
+ return false;
124
+ }
125
+
126
  $query_strings_to_exclude = [
127
  "sbp_disable" => "1", // speed booster pack
128
  "elementor-preview" => "elementor", // elementor
167
  * Every class has inner documentation.
168
  */
169
  private function init_modules() {
 
 
 
170
  new SBP_WP_Admin();
171
  new SBP_Database_Optimizer();
172
  new SBP_Newsletter();
184
  new SBP_HTML_Minifier();
185
  new SBP_Localize_Tracker();
186
  new SBP_Woocommerce();
 
 
187
  new SBP_Cloudflare();
188
  new SBP_Notice_Manager();
189
  new SBP_Sucuri();
271
  */
272
  private function define_admin_hooks() {
273
 
274
+ if ( ! is_admin() || wp_doing_cron() || wp_doing_ajax() ) { return; }
275
+
276
+ add_filter( 'rocket_plugins_to_deactivate', '__return_empty_array' );
277
 
278
+ $plugin_admin = new Speed_Booster_Pack_Admin( $this->plugin_name, SBP_VERSION );
279
 
280
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
281
  $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
282
+
283
  $this->loader->add_action( 'admin_init', $plugin_admin, 'set_up_defaults' );
284
  $this->loader->add_action( 'admin_init', $plugin_admin, 'redirect' );
285
+
286
  }
287
 
288
  /**
296
 
297
  if ( is_admin() || wp_doing_cron() || wp_doing_ajax() ) { return; }
298
 
299
+ $plugin_public = new Speed_Booster_Pack_Public( $this->plugin_name, SBP_VERSION );
300
 
301
  $this->loader->add_action( 'init', $plugin_public, 'template_redirect', 1 );
302
 
303
  // $this->loader->add_action( 'shutdown', $plugin_public, 'shutdown', PHP_INT_MAX );
304
 
305
  $this->loader->add_filter( 'wp_headers', $plugin_public, 'sbp_headers' );
306
+
 
 
 
 
 
307
  add_filter( 'aioseo_flush_output_buffer', '__return_false' );
308
+
309
  }
310
 
311
  private function save_post_types() {
313
  $post_types = array_keys( get_post_types( [ 'public' => true ] ) );
314
  $saved_post_types = get_option( 'sbp_public_post_types' );
315
 
316
+ if ( ! $saved_post_types || $saved_post_types != $post_types ) {
317
  update_option( 'sbp_public_post_types', $post_types );
318
  }
319
  });
328
  $this->loader->run();
329
  }
330
 
 
 
 
 
 
 
 
 
 
 
 
331
  /**
332
  * The reference to the class that orchestrates the hooks with the plugin.
333
  *
338
  return $this->loader;
339
  }
340
 
 
 
 
 
 
 
 
 
 
 
341
  }
includes/classes/class-sbp-lazy-loader.php CHANGED
@@ -19,7 +19,7 @@ class SBP_Lazy_Loader extends SBP_Abstract_Module {
19
  }
20
 
21
  add_action( 'set_current_user', [ $this, 'run_class' ] );
22
- add_action('wp_enqueue_scripts',[ $this, 'deregister_media_elements' ]);
23
  }
24
 
25
  public function run_class() {
@@ -34,7 +34,7 @@ class SBP_Lazy_Loader extends SBP_Abstract_Module {
34
  }
35
 
36
  function add_lazy_load_script() {
37
- wp_enqueue_script( 'sbp-lazy-load', SBP_URL . 'public/js/lazyload.js', false, '17.7.0', true );
38
  $lazy_loader_script = 'window.lazyLoadOptions = {
39
  elements_selector: "[loading=lazy]"
40
  };
@@ -76,8 +76,8 @@ class SBP_Lazy_Loader extends SBP_Abstract_Module {
76
  }
77
 
78
  function deregister_media_elements(){
79
- wp_deregister_script('wp-mediaelement');
80
- wp_deregister_style('wp-mediaelement');
81
  }
82
 
83
 
19
  }
20
 
21
  add_action( 'set_current_user', [ $this, 'run_class' ] );
22
+ add_action( 'wp_enqueue_scripts', [ $this, 'deregister_media_elements' ] );
23
  }
24
 
25
  public function run_class() {
34
  }
35
 
36
  function add_lazy_load_script() {
37
+ wp_enqueue_script( 'sbp-lazy-load', SBP_URL . 'public/js/lazyload.js', false, '17.7.0' );
38
  $lazy_loader_script = 'window.lazyLoadOptions = {
39
  elements_selector: "[loading=lazy]"
40
  };
76
  }
77
 
78
  function deregister_media_elements(){
79
+ wp_deregister_script( 'wp-mediaelement' );
80
+ wp_deregister_style( 'wp-mediaelement' );
81
  }
82
 
83
 
public/class-speed-booster-pack-public.php CHANGED
@@ -62,8 +62,13 @@ class Speed_Booster_Pack_Public {
62
  }
63
 
64
  public function output_buffer( $html ) {
 
 
 
 
 
65
  $html = apply_filters( 'sbp_output_buffer', $html );
66
- if ( $_SERVER[ 'REQUEST_METHOD' ] != 'GET' ) { return $html; }
67
  $html .= PHP_EOL . '<!-- Optimized by Speed Booster Pack v' . SBP_VERSION . ' -->';
68
 
69
  return $html;
62
  }
63
 
64
  public function output_buffer( $html ) {
65
+
66
+ if( is_embed() || $_SERVER[ 'REQUEST_METHOD' ] != 'GET' ) {
67
+ return $html;
68
+ }
69
+
70
  $html = apply_filters( 'sbp_output_buffer', $html );
71
+
72
  $html .= PHP_EOL . '<!-- Optimized by Speed Booster Pack v' . SBP_VERSION . ' -->';
73
 
74
  return $html;
speed-booster-pack.php CHANGED
@@ -6,7 +6,7 @@
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.5.3
10
  * Author: Optimocha
11
  * Author URI: https://optimocha.com
12
  * License: GPLv3 or later
@@ -19,85 +19,26 @@
19
  * Copyright 2019-... Optimocha (hey@optimocha.com)
20
  */
21
 
22
- // If this file is called directly, abort.
23
- if ( ! defined( 'WPINC' ) ) {
24
- die;
25
- }
26
-
27
- /**
28
- * Plugin name.
29
- */
30
- define( 'SBP_PLUGIN_NAME', 'Speed Booster Pack' );
31
-
32
- /**
33
- * Current plugin version.
34
- */
35
- define( 'SBP_VERSION', '4.5.3' );
36
-
37
- /**
38
- * Plugin website URL.
39
- */
40
- define( 'SBP_PLUGIN_HOME', 'https://speedboosterpack.com/' );
41
 
42
  /**
43
- * Plugin owner's name.
44
  */
45
- define( 'SBP_OWNER_NAME', 'Optimocha' );
46
-
47
- /**
48
- * Plugin owner's website URL.
49
- */
50
- define( 'SBP_OWNER_HOME', 'https://optimocha.com/' );
51
-
52
- /**
53
- * Plugin URL
54
- */
55
- define( 'SBP_URL', plugin_dir_url( __FILE__ ) );
56
-
57
- /**
58
- * Plugin Path
59
- */
60
- define( 'SBP_PATH', realpath( dirname( __FILE__ ) ) . '/' );
61
-
62
- /**
63
- * Plugin includes path
64
- */
65
- define( 'SBP_INC_PATH', SBP_PATH . 'includes/' );
66
-
67
- /**
68
- * Plugin libraries path
69
- */
70
- define( 'SBP_LIB_PATH', SBP_PATH . 'vendor/' );
71
-
72
- /**
73
- * Cache directory path
74
- */
75
- define( 'SBP_CACHE_DIR', WP_CONTENT_DIR . '/cache/speed-booster/' );
76
-
77
- /**
78
- * Cache directory URL
79
- */
80
- define( 'SBP_CACHE_URL', WP_CONTENT_URL . '/cache/speed-booster/' );
81
-
82
- /**
83
- * Path for localized script files.
84
- */
85
- define( 'SBP_UPLOADS_DIR', WP_CONTENT_DIR . '/uploads/speed-booster/' );
86
-
87
- /**
88
- * URL for localized script files.
89
- */
90
- define( 'SBP_UPLOADS_URL', WP_CONTENT_URL . '/uploads/speed-booster/' );
91
-
92
- /**
93
- * Plugin basename.
94
- */
95
- define( 'SBP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
96
-
97
- /**
98
- * Migrator script version.
99
- */
100
- define( 'SBP_MIGRATOR_VERSION', '45000' );
101
 
102
  /**
103
  * Load all plugin options
@@ -175,9 +116,6 @@ function sbp_autoloader( $class_name ) {
175
  * @since 4.0.0
176
  */
177
  function run_speed_booster_pack() {
178
- if ( preg_match( '/(_wp-|\.txt|\.pdf|\.xml|\.svg|\.ico|wp-json|\.gz|\/feed\/?)/', $_SERVER['REQUEST_URI'] ) ) {
179
- return;
180
- }
181
 
182
  $plugin = new Speed_Booster_Pack();
183
  $plugin->run();
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.5.4
10
  * Author: Optimocha
11
  * Author URI: https://optimocha.com
12
  * License: GPLv3 or later
19
  * Copyright 2019-... Optimocha (hey@optimocha.com)
20
  */
21
 
22
+ defined( 'ABSPATH' ) || exit;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  /**
25
+ * Plugin constants.
26
  */
27
+ define( 'SBP_VERSION', '4.5.4' ); // plugin version
28
+ define( 'SBP_PLUGIN_NAME', 'Speed Booster Pack' ); // plugin name
29
+ define( 'SBP_PLUGIN_HOME', 'https://speedboosterpack.com/' ); // plugin home
30
+ define( 'SBP_OWNER_NAME', 'Optimocha' ); // plugin owner name
31
+ define( 'SBP_OWNER_HOME', 'https://optimocha.com/' ); // plugin owner home
32
+ define( 'SBP_URL', plugin_dir_url( __FILE__ ) ); // plugin root URL
33
+ define( 'SBP_PATH', realpath( dirname( __FILE__ ) ) . '/' ); // plugin root directory path
34
+ define( 'SBP_INC_PATH', SBP_PATH . 'includes/' ); // plugin includes directory path
35
+ define( 'SBP_LIB_PATH', SBP_PATH . 'vendor/' ); // plugin 3rd party directory path
36
+ define( 'SBP_CACHE_DIR', WP_CONTENT_DIR . '/cache/speed-booster/' ); // plugin cache directory path
37
+ define( 'SBP_CACHE_URL', WP_CONTENT_URL . '/cache/speed-booster/' ); // plugin cache directory URL
38
+ define( 'SBP_UPLOADS_DIR', WP_CONTENT_DIR . '/uploads/speed-booster/' ); // plugin uploads path
39
+ define( 'SBP_UPLOADS_URL', WP_CONTENT_URL . '/uploads/speed-booster/' ); // plugin uploads URL
40
+ define( 'SBP_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); // plugin basename
41
+ define( 'SBP_MIGRATOR_VERSION', '45000' ); // plugin migrator version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  /**
44
  * Load all plugin options
116
  * @since 4.0.0
117
  */
118
  function run_speed_booster_pack() {
 
 
 
119
 
120
  $plugin = new Speed_Booster_Pack();
121
  $plugin->run();