Speed Booster Pack - Version 4.1.3

Version Description

Release Date: 23 March 2021

  • Improved: Cloudflare integration improvements.
  • Improved: Hosting compatibility improvements.
  • Improved: Settings panel improvements.
  • Fixed: HTML encoding/decoding issues with the SimpleHtmlDom library.
  • Fixed: Changed the placeholder image data URI when lazy loading is active (used to show a broken image icon).
  • Fixed: Kinsta compatibility improvements caused some PHP warnings - not anymore.
Download this release

Release Info

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

Code changes from version 4.1.2 to 4.1.3

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: 5.6
7
  Requires PHP: 5.6
8
- Stable tag: 4.1.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -104,15 +104,16 @@ All the time! We're always looking for new ways to get this plugin to a better s
104
 
105
  == Changelog ==
106
 
107
- = 4.1.2 =
108
 
109
- *Release Date: 4 March 2021*
110
 
111
  * **Improved**: Cloudflare integration improvements.
112
  * **Improved**: Hosting compatibility improvements.
113
  * **Improved**: Settings panel improvements.
114
  * **Fixed**: HTML encoding/decoding issues with the SimpleHtmlDom library.
115
  * **Fixed**: Changed the placeholder image data URI when lazy loading is active (used to show a broken image icon).
 
116
 
117
  = 4.1.1 =
118
 
5
  Requires at least: 4.6
6
  Tested up to: 5.6
7
  Requires PHP: 5.6
8
+ Stable tag: 4.1.3
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
104
 
105
  == Changelog ==
106
 
107
+ = 4.1.3 =
108
 
109
+ *Release Date: 23 March 2021*
110
 
111
  * **Improved**: Cloudflare integration improvements.
112
  * **Improved**: Hosting compatibility improvements.
113
  * **Improved**: Settings panel improvements.
114
  * **Fixed**: HTML encoding/decoding issues with the SimpleHtmlDom library.
115
  * **Fixed**: Changed the placeholder image data URI when lazy loading is active (used to show a broken image icon).
116
+ * **Fixed**: Kinsta compatibility improvements caused some PHP warnings - not anymore.
117
 
118
  = 4.1.1 =
119
 
admin/class-speed-booster-pack-admin.php CHANGED
@@ -11,10 +11,102 @@
11
  */
12
 
13
  // If this file is called directly, abort.
 
 
 
 
14
  if ( ! defined( 'WPINC' ) ) {
15
  die;
16
  }
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * The admin-specific functionality of the plugin.
20
  *
@@ -72,6 +164,12 @@ class Speed_Booster_Pack_Admin {
72
 
73
  add_action( 'csf_sbp_options_saved', '\SpeedBooster\SBP_WP_Config_Injector::inject_wp_config' );
74
 
 
 
 
 
 
 
75
  $this->create_settings_page();
76
 
77
  add_action( 'admin_enqueue_scripts', 'add_thickbox' );
@@ -83,7 +181,9 @@ class Speed_Booster_Pack_Admin {
83
  * @since 4.0.0
84
  */
85
  public function enqueue_styles() {
 
86
  wp_enqueue_style( $this->plugin_name, SBP_URL . 'admin/css/speed-booster-pack-admin.css', array(), $this->version, 'all' );
 
87
  }
88
 
89
  /**
@@ -97,6 +197,7 @@ class Speed_Booster_Pack_Admin {
97
 
98
  public function load_dependencies() {
99
  require_once SBP_LIB_PATH . 'codestar-framework/codestar-framework.php';
 
100
  }
101
 
102
  public function create_settings_page() {
@@ -329,46 +430,46 @@ class Speed_Booster_Pack_Admin {
329
  'desc' => __( 'You can find your zone ID in the Overview tab on your Cloudflare panel.', 'speed-booster-pack' ),
330
  ],
331
  [
332
- 'title' => __( 'Rocket Loader', 'speed-booster-pack' ),
333
- 'id' => 'cf_rocket_loader_enable',
334
- 'class' => 'with-preloader',
335
- 'type' => 'switcher',
336
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
337
  ],
338
  [
339
- 'title' => __( 'Development Mode', 'speed-booster-pack' ),
340
- 'id' => 'cf_dev_mode_enable',
341
- 'class' => 'with-preloader',
342
- 'type' => 'switcher',
343
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
344
  ],
345
  [
346
- 'title' => __( 'Minify CSS', 'speed-booster-pack' ),
347
- 'id' => 'cf_css_minify_enable',
348
- 'class' => 'with-preloader',
349
- 'type' => 'switcher',
350
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
351
  ],
352
  [
353
- 'title' => __( 'Minify HTML', 'speed-booster-pack' ),
354
- 'id' => 'cf_html_minify_enable',
355
- 'class' => 'with-preloader',
356
- 'type' => 'switcher',
357
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
358
  ],
359
  [
360
- 'title' => __( 'Minify JS', 'speed-booster-pack' ),
361
- 'id' => 'cf_js_minify_enable',
362
- 'class' => 'with-preloader',
363
- 'type' => 'switcher',
364
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
365
  ],
366
  [
367
- 'title' => __( 'Browser Cache TTL', 'speed-booster-pack' ),
368
- 'id' => 'cf_browser_cache_ttl',
369
- 'class' => 'with-preloader',
370
- 'type' => 'select',
371
- 'options' => [
372
  0 => __( 'Respect Existing Headers', 'speed-booster-pack' ),
373
  1800 => __( '30 minutes', 'speed-booster-pack' ),
374
  3600 => __( '1 hour', 'speed-booster-pack' ),
@@ -393,7 +494,7 @@ class Speed_Booster_Pack_Admin {
393
  16070400 => __( '6 months', 'speed-booster-pack' ),
394
  31536000 => __( '1 year', 'speed-booster-pack' ),
395
  ],
396
- 'dependency' => ['cloudflare_enable', '==', '1', '', 'visible'],
397
  ],
398
  [
399
  'type' => 'content',
@@ -403,7 +504,7 @@ class Speed_Booster_Pack_Admin {
403
  <span class="sbp-cloudflare-fetching">' . __( 'Fetching Cloudflare settings...', 'speed-booster-pack' ) . '</span>
404
  </span>
405
  <span class="sbp-cloudflare-info-text sbp-cloudflare-incorrect" style="color:red; vertical-align: middle;"><i class="fa fa-exclamation-triangle"></i> ' . __( 'Your Cloudflare credentials are incorrect.', 'speed-booster-pack' ) . '</span>
406
- <span class="sbp-cloudflare-info-text sbp-cloudflare-connection-issue" style="color:red; vertical-align: middle;"><i class="fa fa-exclamation-triangle"></i> ' . __( 'Error occured while connecting Cloudflare.', 'speed-booster-pack' ) . '</span>
407
  <span class="sbp-cloudflare-info-text sbp-cloudflare-correct" style="color:green; vertical-align: middle;"><i class="fa fa-check-circle"></i> ' . __( 'Your Cloudflare credentials are correct.', 'speed-booster-pack' ) . '</span>
408
  <span class="sbp-cloudflare-info-text sbp-cloudflare-warning" style="color:orange; vertical-align: middle;"><i class="fa fa-exclamation-circle"></i> ' . __( 'Enter your Cloudflare credentials and save settings to see CloudFlare options.', 'speed-booster-pack' ) . '</span>
409
  ',
@@ -435,7 +536,7 @@ class Speed_Booster_Pack_Admin {
435
  'title' => __( 'Connect to Sucuri', 'speed-booster-pack' ),
436
  'id' => 'sucuri_enable',
437
  'type' => 'switcher',
438
- 'desc' => sprintf( __( 'When you connect your Sucuri account, you\'ll be able to clear your Sucuri cache via your admin bar. Plus, every time %1$s Cache\'s cache is cleared, Sucuri\'s cache will be cleared as well.', 'speed-booster-pack' ), SBP_PLUGIN_NAME ),
439
  ],
440
  [
441
  'title' => __( 'Sucuri API key', 'speed-booster-pack' ),
@@ -540,11 +641,11 @@ class Speed_Booster_Pack_Admin {
540
  'title' => 'is_front_page',
541
  'fields' => [
542
  [
543
- 'id' => 'is_front_page',
544
- 'type' => 'code_editor',
545
  // Z_TODO: Edit the following description.
546
- 'desc' => sprintf( __( 'This CSS block will be injected into the front page of your website. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_front_page/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_front_page()</code>' ), '</a>' ),
547
- 'settings' => [ 'lineWrapping' => true ],
548
  ],
549
  ],
550
  ],
@@ -552,10 +653,10 @@ class Speed_Booster_Pack_Admin {
552
  'title' => 'is_home',
553
  'fields' => [
554
  [
555
- 'id' => 'is_home',
556
- 'type' => 'code_editor',
557
- 'desc' => sprintf( __( 'This CSS block will be injected into the blog homepage of your website. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_home/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_home()</code>' ), '</a>' ),
558
- 'settings' => [ 'lineWrapping' => true ],
559
  ],
560
  ],
561
  ],
@@ -563,10 +664,10 @@ class Speed_Booster_Pack_Admin {
563
  'title' => 'is_single',
564
  'fields' => [
565
  [
566
- 'id' => 'is_single',
567
- 'type' => 'code_editor',
568
- 'desc' => sprintf( __( 'This CSS block will be injected into all single posts. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_single/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_single()</code>' ), '</a>' ),
569
- 'settings' => [ 'lineWrapping' => true ],
570
  ],
571
  ],
572
  ],
@@ -574,10 +675,10 @@ class Speed_Booster_Pack_Admin {
574
  'title' => 'is_page',
575
  'fields' => [
576
  [
577
- 'id' => 'is_page',
578
- 'type' => 'code_editor',
579
- 'desc' => sprintf( __( 'This CSS block will be injected into all static pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_page/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_page()</code>' ), '</a>' ),
580
- 'settings' => [ 'lineWrapping' => true ],
581
  ],
582
  ],
583
  ],
@@ -585,10 +686,10 @@ class Speed_Booster_Pack_Admin {
585
  'title' => 'is_category',
586
  'fields' => [
587
  [
588
- 'id' => 'is_category',
589
- 'type' => 'code_editor',
590
- 'desc' => sprintf( __( 'This CSS block will be injected into all category archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_category/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_category()</code>' ), '</a>' ),
591
- 'settings' => [ 'lineWrapping' => true ],
592
  ],
593
  ],
594
  ],
@@ -596,10 +697,10 @@ class Speed_Booster_Pack_Admin {
596
  'title' => 'is_tag',
597
  'fields' => [
598
  [
599
- 'id' => 'is_tag',
600
- 'type' => 'code_editor',
601
- 'desc' => sprintf( __( 'This CSS block will be injected into all tag archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_tag/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_tag()</code>' ), '</a>' ),
602
- 'settings' => [ 'lineWrapping' => true ],
603
  ],
604
  ],
605
  ],
@@ -607,10 +708,10 @@ class Speed_Booster_Pack_Admin {
607
  'title' => 'is_archive',
608
  'fields' => [
609
  [
610
- 'id' => 'is_archive',
611
- 'type' => 'code_editor',
612
- 'desc' => sprintf( __( 'This CSS block will be injected into all archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_archive/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_archive()</code>' ), '</a>' ),
613
- 'settings' => [ 'lineWrapping' => true ],
614
  ],
615
  ],
616
  ],
@@ -626,7 +727,7 @@ class Speed_Booster_Pack_Admin {
626
  'dependency' => [ 'module_css|enable_criticalcss', '==|==', '1|1', '', 'visible' ],
627
  ],
628
  [
629
- 'type' => 'subheading',
630
  'title' => __( 'Inline & Minify CSS', 'speed-booster-pack' ),
631
  ],
632
  [
@@ -802,13 +903,13 @@ class Speed_Booster_Pack_Admin {
802
  'sanitize' => false,
803
  'fields' => [
804
  [
805
- 'id' => 'custom_codes_item',
806
- 'type' => 'code_editor',
807
- 'before' => '&lt;script&gt;',
808
- 'after' => '&lt;/script&gt;',
809
  /* translators: %s = script tag */
810
- 'desc' => sprintf( __( 'Paste the inline JavaScript here. DON\'T include the %s tags or else you might break it!', 'speed-booster-pack' ), '<code>&lt;script&gt;</code>' ),
811
- 'settings' => [ 'lineWrapping' => true ],
812
  ],
813
  [
814
  'title' => __( 'Placement', 'speed-booster-pack' ),
@@ -999,13 +1100,6 @@ class Speed_Booster_Pack_Admin {
999
  'default' => '1',
1000
  'dependency' => [ 'module_tweaks', '==', '1', '', 'visible' ],
1001
  ],
1002
- [
1003
- 'title' => __( 'Dequeue Comment Reply Script', 'speed-booster-pack' ), // B_TODO: Translations
1004
- 'desc' => __( 'Disables comment reply script.', 'speed-booster-pack' ), // B_TODO: Translations
1005
- 'id' => 'dequeue_comment_reply_script',
1006
- 'type' => 'switcher',
1007
- 'dependency' => ['module_tweaks', '==', '1', '', 'visible'],
1008
- ],
1009
  [
1010
  /* translators: %s = <head> */
1011
  'title' => sprintf( __( 'Declutter %s', 'speed-booster-pack' ), '<code>&lt;head&gt;</code>' ),
@@ -1073,18 +1167,19 @@ class Speed_Booster_Pack_Admin {
1073
  'title' => __( 'Tools', 'speed-booster-pack' ),
1074
  'id' => 'tools',
1075
  'icon' => 'fa fa-tools',
1076
- 'fields' => [
1077
- [
1078
  'type' => 'subheading',
1079
  /* translators: %s = Speed Booster Pack */
1080
  'content' => sprintf( __( 'Backup %s Settings', 'speed-booster-pack' ), SBP_PLUGIN_NAME ),
1081
- ],
1082
- [
1083
  'id' => 'backup',
1084
  'type' => 'backup',
1085
  'title' => '',
1086
- ],
1087
- ],
 
1088
  )
1089
  );
1090
  /* END Section: Tools */
@@ -1141,4 +1236,136 @@ class Speed_Booster_Pack_Admin {
1141
  /* END Section: About */
1142
  }
1143
  }
1144
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  */
12
 
13
  // If this file is called directly, abort.
14
+ use SpeedBooster\SBP_Cloudflare;
15
+ use SpeedBooster\SBP_Notice_Manager;
16
+ use SpeedBooster\SBP_Utils;
17
+
18
  if ( ! defined( 'WPINC' ) ) {
19
  die;
20
  }
21
 
22
+ /**
23
+ * Returns absolute value of a number. Returns 1 if value is zero.
24
+ *
25
+ * @param $value
26
+ *
27
+ * @return float|int
28
+ * @since 4.0.0
29
+ *
30
+ */
31
+ function sbp_posabs( $value ) {
32
+ if ( 0 == $value ) {
33
+ return 1;
34
+ }
35
+
36
+ return absint( $value );
37
+ }
38
+
39
+ /**
40
+ * Removes http(s?):// and trailing slash from the url
41
+ *
42
+ * @param $url
43
+ *
44
+ * @return string
45
+ * @since 4.0.0
46
+ *
47
+ */
48
+ function sbp_clear_cdn_url( $url ) {
49
+ return preg_replace( "#^[^:/.]*[:/]+#i", "", rtrim( $url, '/' ) );
50
+ }
51
+
52
+ /**
53
+ * Removes http:// from the url
54
+ *
55
+ * @param $url
56
+ *
57
+ * @return string
58
+ * @since 4.0.0
59
+ *
60
+ */
61
+ function sbp_clear_http( $url ) {
62
+ return str_replace( "http://", "//", $url );
63
+ }
64
+
65
+ /**
66
+ * Trims and strips the tags from given value. Takes one dimensional array or string as argument. Returns the modified value.
67
+ *
68
+ * @param $value array|string
69
+ *
70
+ * @return array|string
71
+ */
72
+ function sbp_sanitize_strip_tags( $value ) {
73
+ if ( is_array( $value ) ) {
74
+ $value = array_map(
75
+ function ( $item ) {
76
+ return trim( strip_tags( $item ) );
77
+ },
78
+ $value
79
+ );
80
+ } else {
81
+ $value = trim( strip_tags( $value ) );
82
+ }
83
+
84
+ return $value;
85
+ }
86
+
87
+ /**
88
+ * Sanitizes excluded URLs for caching
89
+ *
90
+ * @param $urls
91
+ *
92
+ * @return string
93
+ * @since 4.0.0
94
+ *
95
+ */
96
+ function sbp_sanitize_caching_urls( $urls ) {
97
+ $urls = SBP_Utils::explode_lines( $urls );
98
+ foreach ( $urls as &$url ) {
99
+ $url = preg_replace( '#^https?://(.*?)#', '\1', $url );
100
+ $url = preg_replace( '#(.*?)\#(.*?)$#', '\1', $url );
101
+ $url = preg_replace( '#(.*?)\?(.*?)$#', '\1', $url );
102
+ $url = preg_replace( '#(.*?)\/$#', '\1', $url );
103
+ }
104
+
105
+ $urls = array_unique( $urls );
106
+
107
+ return implode( PHP_EOL, $urls );
108
+ }
109
+
110
  /**
111
  * The admin-specific functionality of the plugin.
112
  *
164
 
165
  add_action( 'csf_sbp_options_saved', '\SpeedBooster\SBP_WP_Config_Injector::inject_wp_config' );
166
 
167
+ add_action( 'admin_bar_menu', [ $this, 'add_admin_bar_links' ], 90 );
168
+
169
+ add_action( 'init', [ $this, 'set_notices' ] );
170
+
171
+ $this->initialize_announce4wp();
172
+
173
  $this->create_settings_page();
174
 
175
  add_action( 'admin_enqueue_scripts', 'add_thickbox' );
181
  * @since 4.0.0
182
  */
183
  public function enqueue_styles() {
184
+
185
  wp_enqueue_style( $this->plugin_name, SBP_URL . 'admin/css/speed-booster-pack-admin.css', array(), $this->version, 'all' );
186
+
187
  }
188
 
189
  /**
197
 
198
  public function load_dependencies() {
199
  require_once SBP_LIB_PATH . 'codestar-framework/codestar-framework.php';
200
+ require_once SBP_LIB_PATH . 'announce4wp/announce4wp-client.php';
201
  }
202
 
203
  public function create_settings_page() {
430
  'desc' => __( 'You can find your zone ID in the Overview tab on your Cloudflare panel.', 'speed-booster-pack' ),
431
  ],
432
  [
433
+ 'title' => __( 'Rocket Loader', 'speed-booster-pack' ),
434
+ 'id' => 'cf_rocket_loader_enable',
435
+ 'class' => 'with-preloader',
436
+ 'type' => 'switcher',
437
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
438
  ],
439
  [
440
+ 'title' => __( 'Development Mode', 'speed-booster-pack' ),
441
+ 'id' => 'cf_dev_mode_enable',
442
+ 'class' => 'with-preloader',
443
+ 'type' => 'switcher',
444
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
445
  ],
446
  [
447
+ 'title' => __( 'Minify CSS', 'speed-booster-pack' ),
448
+ 'id' => 'cf_css_minify_enable',
449
+ 'class' => 'with-preloader',
450
+ 'type' => 'switcher',
451
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
452
  ],
453
  [
454
+ 'title' => __( 'Minify HTML', 'speed-booster-pack' ),
455
+ 'id' => 'cf_html_minify_enable',
456
+ 'class' => 'with-preloader',
457
+ 'type' => 'switcher',
458
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
459
  ],
460
  [
461
+ 'title' => __( 'Minify JS', 'speed-booster-pack' ),
462
+ 'id' => 'cf_js_minify_enable',
463
+ 'class' => 'with-preloader',
464
+ 'type' => 'switcher',
465
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
466
  ],
467
  [
468
+ 'title' => __( 'Browser Cache TTL', 'speed-booster-pack' ),
469
+ 'id' => 'cf_browser_cache_ttl',
470
+ 'class' => 'with-preloader',
471
+ 'type' => 'select',
472
+ 'options' => [
473
  0 => __( 'Respect Existing Headers', 'speed-booster-pack' ),
474
  1800 => __( '30 minutes', 'speed-booster-pack' ),
475
  3600 => __( '1 hour', 'speed-booster-pack' ),
494
  16070400 => __( '6 months', 'speed-booster-pack' ),
495
  31536000 => __( '1 year', 'speed-booster-pack' ),
496
  ],
497
+ 'dependency' => [ 'cloudflare_enable', '==', '1', '', 'visible' ],
498
  ],
499
  [
500
  'type' => 'content',
504
  <span class="sbp-cloudflare-fetching">' . __( 'Fetching Cloudflare settings...', 'speed-booster-pack' ) . '</span>
505
  </span>
506
  <span class="sbp-cloudflare-info-text sbp-cloudflare-incorrect" style="color:red; vertical-align: middle;"><i class="fa fa-exclamation-triangle"></i> ' . __( 'Your Cloudflare credentials are incorrect.', 'speed-booster-pack' ) . '</span>
507
+ <span class="sbp-cloudflare-info-text sbp-cloudflare-connection-issue" style="color:red; vertical-align: middle;"><i class="fa fa-exclamation-triangle"></i> ' . __( 'Error occured while connecting to Cloudflare.', 'speed-booster-pack' ) . '</span>
508
  <span class="sbp-cloudflare-info-text sbp-cloudflare-correct" style="color:green; vertical-align: middle;"><i class="fa fa-check-circle"></i> ' . __( 'Your Cloudflare credentials are correct.', 'speed-booster-pack' ) . '</span>
509
  <span class="sbp-cloudflare-info-text sbp-cloudflare-warning" style="color:orange; vertical-align: middle;"><i class="fa fa-exclamation-circle"></i> ' . __( 'Enter your Cloudflare credentials and save settings to see CloudFlare options.', 'speed-booster-pack' ) . '</span>
510
  ',
536
  'title' => __( 'Connect to Sucuri', 'speed-booster-pack' ),
537
  'id' => 'sucuri_enable',
538
  'type' => 'switcher',
539
+ 'desc' => sprintf( __( 'When you connect your Sucuri account, you\'ll be able to clear your Sucuri cache via your admin bar. Plus, every time %1$s Cache\'s cache is cleared, Sucuri\'s cache will be cleared as well.', 'speed-booster-pack' ), SBP_PLUGIN_NAME ),
540
  ],
541
  [
542
  'title' => __( 'Sucuri API key', 'speed-booster-pack' ),
641
  'title' => 'is_front_page',
642
  'fields' => [
643
  [
644
+ 'id' => 'is_front_page',
645
+ 'type' => 'code_editor',
646
  // Z_TODO: Edit the following description.
647
+ 'desc' => sprintf( __( 'This CSS block will be injected into the front page of your website. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_front_page/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_front_page()</code>' ), '</a>' ),
648
+ 'settings' => [ 'lineWrapping' => true ],
649
  ],
650
  ],
651
  ],
653
  'title' => 'is_home',
654
  'fields' => [
655
  [
656
+ 'id' => 'is_home',
657
+ 'type' => 'code_editor',
658
+ 'desc' => sprintf( __( 'This CSS block will be injected into the blog homepage of your website. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_home/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_home()</code>' ), '</a>' ),
659
+ 'settings' => [ 'lineWrapping' => true ],
660
  ],
661
  ],
662
  ],
664
  'title' => 'is_single',
665
  'fields' => [
666
  [
667
+ 'id' => 'is_single',
668
+ 'type' => 'code_editor',
669
+ 'desc' => sprintf( __( 'This CSS block will be injected into all single posts. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_single/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_single()</code>' ), '</a>' ),
670
+ 'settings' => [ 'lineWrapping' => true ],
671
  ],
672
  ],
673
  ],
675
  'title' => 'is_page',
676
  'fields' => [
677
  [
678
+ 'id' => 'is_page',
679
+ 'type' => 'code_editor',
680
+ 'desc' => sprintf( __( 'This CSS block will be injected into all static pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_page/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_page()</code>' ), '</a>' ),
681
+ 'settings' => [ 'lineWrapping' => true ],
682
  ],
683
  ],
684
  ],
686
  'title' => 'is_category',
687
  'fields' => [
688
  [
689
+ 'id' => 'is_category',
690
+ 'type' => 'code_editor',
691
+ 'desc' => sprintf( __( 'This CSS block will be injected into all category archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_category/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_category()</code>' ), '</a>' ),
692
+ 'settings' => [ 'lineWrapping' => true ],
693
  ],
694
  ],
695
  ],
697
  'title' => 'is_tag',
698
  'fields' => [
699
  [
700
+ 'id' => 'is_tag',
701
+ 'type' => 'code_editor',
702
+ 'desc' => sprintf( __( 'This CSS block will be injected into all tag archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_tag/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_tag()</code>' ), '</a>' ),
703
+ 'settings' => [ 'lineWrapping' => true ],
704
  ],
705
  ],
706
  ],
708
  'title' => 'is_archive',
709
  'fields' => [
710
  [
711
+ 'id' => 'is_archive',
712
+ 'type' => 'code_editor',
713
+ 'desc' => sprintf( __( 'This CSS block will be injected into all archive pages. %1$s%2$s%3$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/reference/functions/is_archive/" rel="external noopener" target="_blank">', sprintf( __( 'Learn more about %s.', 'speed-booster-pack' ), '<code>is_archive()</code>' ), '</a>' ),
714
+ 'settings' => [ 'lineWrapping' => true ],
715
  ],
716
  ],
717
  ],
727
  'dependency' => [ 'module_css|enable_criticalcss', '==|==', '1|1', '', 'visible' ],
728
  ],
729
  [
730
+ 'type' => 'subheading',
731
  'title' => __( 'Inline & Minify CSS', 'speed-booster-pack' ),
732
  ],
733
  [
903
  'sanitize' => false,
904
  'fields' => [
905
  [
906
+ 'id' => 'custom_codes_item',
907
+ 'type' => 'code_editor',
908
+ 'before' => '&lt;script&gt;',
909
+ 'after' => '&lt;/script&gt;',
910
  /* translators: %s = script tag */
911
+ 'desc' => sprintf( __( 'Paste the inline JavaScript here. DON\'T include the %s tags or else you might break it!', 'speed-booster-pack' ), '<code>&lt;script&gt;</code>' ),
912
+ 'settings' => [ 'lineWrapping' => true ],
913
  ],
914
  [
915
  'title' => __( 'Placement', 'speed-booster-pack' ),
1100
  'default' => '1',
1101
  'dependency' => [ 'module_tweaks', '==', '1', '', 'visible' ],
1102
  ],
 
 
 
 
 
 
 
1103
  [
1104
  /* translators: %s = <head> */
1105
  'title' => sprintf( __( 'Declutter %s', 'speed-booster-pack' ), '<code>&lt;head&gt;</code>' ),
1167
  'title' => __( 'Tools', 'speed-booster-pack' ),
1168
  'id' => 'tools',
1169
  'icon' => 'fa fa-tools',
1170
+ 'fields' => array(
1171
+ array(
1172
  'type' => 'subheading',
1173
  /* translators: %s = Speed Booster Pack */
1174
  'content' => sprintf( __( 'Backup %s Settings', 'speed-booster-pack' ), SBP_PLUGIN_NAME ),
1175
+ ),
1176
+ array(
1177
  'id' => 'backup',
1178
  'type' => 'backup',
1179
  'title' => '',
1180
+ ),
1181
+
1182
+ ),
1183
  )
1184
  );
1185
  /* END Section: Tools */
1236
  /* END Section: About */
1237
  }
1238
  }
1239
+
1240
+ public function add_admin_bar_links( WP_Admin_Bar $admin_bar ) {
1241
+
1242
+ if ( current_user_can( 'manage_options' ) ) {
1243
+
1244
+ $admin_bar->add_menu( [
1245
+ 'id' => 'speed_booster_pack',
1246
+ 'title' => 'Speed Booster',
1247
+ 'href' => admin_url( 'admin.php?page=sbp-settings' ),
1248
+ 'meta' => [
1249
+ 'target' => '_self',
1250
+ 'html' => '<style>#wpadminbar #wp-admin-bar-speed_booster_pack .ab-item{background:url("' . SBP_URL . 'admin/images/icon.svg") no-repeat 5px center;padding-left:25px;filter: brightness(0.7) sepia(1) hue-rotate(50deg) saturate(1.5);}#wpadminbar #wp-admin-bar-speed_booster_pack .ab-item:hover{color:white;}</style>',
1251
+ ],
1252
+ ] );
1253
+
1254
+ if ( sbp_get_option( 'module_caching' ) && ! sbp_should_disable_feature( 'caching' ) ) {
1255
+ // Cache clear
1256
+ $clear_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cache' ), 'sbp_clear_total_cache', 'sbp_nonce' );
1257
+ $sbp_admin_menu = [
1258
+ 'id' => 'sbp_clear_cache',
1259
+ 'parent' => 'speed_booster_pack',
1260
+ 'title' => __( 'Clear Cache', 'speed-booster-pack' ),
1261
+ 'href' => $clear_cache_url,
1262
+ ];
1263
+
1264
+ $admin_bar->add_node( $sbp_admin_menu );
1265
+
1266
+ // Cache warmup
1267
+ $warmup_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_warmup_cache' ), 'sbp_warmup_cache', 'sbp_nonce' );
1268
+ $sbp_admin_menu = [
1269
+ 'id' => 'sbp_warmup_cache',
1270
+ 'parent' => 'speed_booster_pack',
1271
+ 'title' => __( 'Warmup Cache', 'speed-booster-pack' ),
1272
+ 'href' => $warmup_cache_url,
1273
+ ];
1274
+
1275
+ $admin_bar->add_node( $sbp_admin_menu );
1276
+ }
1277
+
1278
+ if ( sbp_get_option( 'localize_tracking_scripts' ) ) {
1279
+ $clear_tracking_scripts_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_refresh_localized_analytics' ), 'sbp_refresh_localized_analytics', 'sbp_nonce' );
1280
+ $sbp_admin_menu = [
1281
+ 'id' => 'sbp_clear_localized_scripts',
1282
+ 'parent' => 'speed_booster_pack',
1283
+ 'title' => __( 'Clear Localized Scripts', 'speed-booster-pack' ),
1284
+ 'href' => $clear_tracking_scripts_url,
1285
+ ];
1286
+
1287
+ $admin_bar->add_node( $sbp_admin_menu );
1288
+ }
1289
+
1290
+ if ( SBP_Cloudflare::is_cloudflare_active() ) {
1291
+ $clear_cloudflare_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cloudflare_cache' ), 'sbp_clear_cloudflare_cache', 'sbp_nonce' );
1292
+ $sbp_admin_menu = [
1293
+ 'id' => 'sbp_clear_cloudflare_cache',
1294
+ 'parent' => 'speed_booster_pack',
1295
+ 'title' => __( 'Clear Cloudflare Cache', 'speed-booster-pack' ),
1296
+ 'href' => $clear_cloudflare_cache_url,
1297
+ ];
1298
+
1299
+ $admin_bar->add_node( $sbp_admin_menu );
1300
+ }
1301
+
1302
+ if ( sbp_get_option( 'sucuri_enable' ) ) {
1303
+ $clear_sucuri_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_sucuri_cache' ), 'sbp_clear_sucuri_cache', 'sbp_nonce' );
1304
+ $sbp_admin_menu = [
1305
+ 'id' => 'sbp_clear_sucuri_cache',
1306
+ 'parent' => 'speed_booster_pack',
1307
+ 'title' => __( 'Clear Sucuri Cache', 'speed-booster-pack' ),
1308
+ 'href' => $clear_sucuri_cache_url,
1309
+ ];
1310
+
1311
+ $admin_bar->add_node( $sbp_admin_menu );
1312
+ }
1313
+ }
1314
+ }
1315
+
1316
+ public function set_notices() {
1317
+ if ( SBP_Utils::is_plugin_active( 'autoptimize/autoptimize.php' ) && sbp_get_option( 'enable_criticalcss' ) && get_option( 'autoptimize_css_defer' ) && sbp_get_option( 'module_css' ) ) {
1318
+ SBP_Notice_Manager::display_notice( 'autoptimize_inline_defer_css', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . sprintf( __( 'It looks like Autoptimize is active on your site. Autoptimize\'s "defer and inline css" feature may cause conflict with %s.', 'speed-booster-pack' ), SBP_PLUGIN_NAME ) . '</p>', 'warning' );
1319
+ }
1320
+
1321
+ // Set Sucuri Notice
1322
+ if ( $transient_value = get_transient( 'sbp_clear_sucuri_cache' ) ) {
1323
+ $notice_message = $transient_value == '1' ? __( 'Sucuri cache cleared.', 'speed-booster-pack' ) : __( 'Error occured while clearing Sucuri cache. ', 'speed-booster-pack' ) . get_transient( 'sbp_sucuri_error' );
1324
+ $notice_type = $transient_value == '1' ? 'success' : 'error';
1325
+ SBP_Notice_Manager::display_notice( 'sbp_clear_sucuri_cache', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( $notice_message, 'speed-booster-pack' ) . '</p>', $notice_type, true, 'flash' );
1326
+ }
1327
+
1328
+ // Set Cloudflare Notice
1329
+ if ( $transient_value = get_transient( 'sbp_notice_cloudflare' ) ) {
1330
+ $notice_message = $transient_value == '1' ? __( 'Cloudflare cache cleared.', 'speed-booster-pack' ) : __( 'Error occured while clearing Cloudflare cache. Possible reason: Credentials invalid.', 'speed-booster-pack' );
1331
+ $notice_type = $transient_value == '1' ? 'success' : 'error';
1332
+ SBP_Notice_Manager::display_notice( 'sbp_notice_cloudflare', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( $notice_message, 'speed-booster-pack' ) . '</p>', $notice_type, true, 'flash' );
1333
+ }
1334
+
1335
+ // Set Cache Clear Notice
1336
+ if ( get_transient( 'sbp_notice_cache' ) ) {
1337
+ SBP_Notice_Manager::display_notice( 'sbp_notice_cache', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache cleared.', 'speed-booster-pack' ) . '</p>', 'success', true, 'flash' );
1338
+ }
1339
+
1340
+ // Set Localizer Cache Clear Notice
1341
+ if ( get_transient( 'sbp_notice_tracker_localizer' ) ) {
1342
+ SBP_Notice_Manager::display_notice( 'sbp_notice_tracker_localizer', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Localized scripts are cleared.', 'speed-booster-pack' ) . '</p>', 'success', true, 'flash' );
1343
+ }
1344
+
1345
+ // Warmup Notice
1346
+ if ( get_transient( 'sbp_warmup_started' ) ) {
1347
+ SBP_Notice_Manager::display_notice( 'sbp_warmup_started', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache warmup started.', 'speed-booster-pack' ) . '</p>', 'success', true, 'recurrent' );
1348
+ }
1349
+
1350
+ // Warmup Notice
1351
+ if ( get_transient( 'sbp_warmup_complete' ) ) {
1352
+ SBP_Notice_Manager::display_notice( 'sbp_warmup_complete', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Static cache files created.', 'speed-booster-pack' ) . '</p>', 'info', true, 'recurrent' );
1353
+ }
1354
+
1355
+ // WP-Config Inject File Error
1356
+ if ( get_transient( 'sbp_wp_config_inject_error' ) ) {
1357
+ SBP_Notice_Manager::display_notice( 'sbp_wp_config_inject_error', '<p><strong>' . SBP_PLUGIN_NAME . '</strong> ' . __( 'Can not write plugins/speed-booster-pack/includes/wp-config-options/wp-config-inject.php file. Some ' . SBP_PLUGIN_NAME . ' features may not work. Please check your file permissions.', 'speed-booster-pack' ) . '</p>', 'error', true, 'recurrent' );
1358
+ }
1359
+
1360
+ // WP-Config File Error
1361
+ if ( get_transient( 'sbp_wp_config_error' ) ) {
1362
+ SBP_Notice_Manager::display_notice( 'sbp_wp_config_error', '<p><strong>' . SBP_PLUGIN_NAME . '</strong> ' . __( 'Can not write wp-config.php file. Some ' . SBP_PLUGIN_NAME . ' features may not work. Please check your file permissions.', 'speed-booster-pack' ) . '</p>', 'error', true, 'recurrent' );
1363
+ }
1364
+ }
1365
+
1366
+ private function initialize_announce4wp() {
1367
+ if ( sbp_get_option( 'enable_external_notices' ) ) {
1368
+ new Announce4WP_Client( 'speed-booster-pack.php', SBP_PLUGIN_NAME, "sbp", "https://speedboosterpack.com/wp-json/a4wp/v1/" . SBP_VERSION . "/news.json", "toplevel_page_sbp-settings" );
1369
+ }
1370
+ }
1371
+ }
admin/js/speed-booster-pack-admin.js CHANGED
@@ -28,7 +28,7 @@
28
  * Although scripts in the WordPress core, Plugins and Themes may be
29
  * practising this, we should strive to set a better example in our own work.
30
  */
31
- $(window).on('load', function () {
32
  $('span .sbp-cloudflare-test').attr('disabled', 'disabled').css('opacity', '0.6');
33
  });
34
 
@@ -155,15 +155,12 @@
155
  } else if (response.status === 'empty_info') {
156
  $('.sbp-cloudflare-warning').show();
157
  } else {
158
- if (response.status === 'null') {
159
- $('.sbp-cloudflare-connection-issue').show();
160
- } else {
161
- $('.sbp-cloudflare-incorrect').show();
162
- }
163
  $('.with-preloader::before, .with-preloader::after').remove();
164
  }
165
  },
166
- complete: function () {
167
  $('.sbp-cloudflare-test .sbp-cloudflare-spinner').hide();
168
  $('.sbp-cloudflare-test').removeAttr('disabled').css('opacity', 1);
169
  $('.sbp-cloudflare-fetching').remove();
@@ -193,30 +190,4 @@
193
 
194
  });
195
 
196
- $(document).on('submit', "#sbp-subscribe-newsletter-form", function (e) {
197
- e.preventDefault();
198
- var $form = $("#subscribe-newsletter-form");
199
- var name = $form.find('input[name="first_name"]').val();
200
- var email = $form.find('input[name="email"]').val();
201
- var gdpr = $form.find('input[name="gdpr"]').val();
202
- $('#sbp-newsletter-subscribe-button').attr('disabled', 'disabled').css('text-shadow', 'none');
203
- $.ajax({
204
- type: 'POST',
205
- url: 'https://sendfox.com/form/104ezx/3o64jv',
206
- data: {first_name: name, email: email, gdpr: gdpr},
207
- success: function (data, statusText) {
208
- $('.sbp-newsletter-success').show();
209
- $('.sbp-subscribe-content-wrapper').hide();
210
- $('#sbp-subscribe-newsletter-form').parent().parent().find('> p').hide();
211
- if (statusText === 'success') {
212
- $.ajax({
213
- type: 'POST',
214
- url: ajaxurl,
215
- data: {action: 'sbp_hide_newsletter_pointer'}
216
- });
217
- }
218
- }
219
- });
220
- });
221
-
222
  })(jQuery);
28
  * Although scripts in the WordPress core, Plugins and Themes may be
29
  * practising this, we should strive to set a better example in our own work.
30
  */
31
+ $(window).on('load', function() {
32
  $('span .sbp-cloudflare-test').attr('disabled', 'disabled').css('opacity', '0.6');
33
  });
34
 
155
  } else if (response.status === 'empty_info') {
156
  $('.sbp-cloudflare-warning').show();
157
  } else {
158
+
159
+ $('.sbp-cloudflare-incorrect').show();
 
 
 
160
  $('.with-preloader::before, .with-preloader::after').remove();
161
  }
162
  },
163
+ complete: function() {
164
  $('.sbp-cloudflare-test .sbp-cloudflare-spinner').hide();
165
  $('.sbp-cloudflare-test').removeAttr('disabled').css('opacity', 1);
166
  $('.sbp-cloudflare-fetching').remove();
190
 
191
  });
192
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  })(jQuery);
templates/php/cache/advanced-cache.php → advanced-cache.php RENAMED
@@ -16,13 +16,21 @@ if ( ! empty( $_COOKIE ) ) {
16
  }
17
  }
18
 
 
 
 
 
 
 
 
 
19
  // Set default file name
20
  $filename = 'index.html';
21
 
22
  // Check for query strings
23
- if ( ! empty( $_GET ) ) {
24
  // Get included rules
25
- $include_query_strings = sbp_explode_lines( '{{__CACHING_QUERY_STRING_INCLUDES__}}' );
26
 
27
  $query_string_file_name = '';
28
  // Put all query string parameters in order to generate same filename even if parameter order is different
@@ -48,15 +56,19 @@ if ( ! is_readable( $cache_file_path ) ) {
48
  }
49
 
50
  // Check if cache file is expired
51
- $caching_expiry = '{{__CACHING_EXPIRY__}}' * HOUR_IN_SECONDS;
52
- if ( ( filemtime( $cache_file_path ) + $caching_expiry ) < time() ) {
53
- return false;
 
 
54
  }
55
 
56
- $exclude_urls = sbp_explode_lines( '{{__CACHING_EXCLUDE_URLS__}}' );
57
- $current_url = rtrim( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '/' );
58
- if ( count( $exclude_urls ) > 0 && in_array( $current_url, $exclude_urls ) ) {
59
- return false;
 
 
60
  }
61
 
62
  // output cached file
@@ -89,9 +101,12 @@ function sbp_is_mobile() {
89
 
90
  // generate cache path
91
  function get_cache_file_path() {
 
92
  $cache_dir = WP_CONTENT_DIR . '/cache/speed-booster';
93
 
94
- '__SEPARATE_MOBILE_CACHING__';
 
 
95
 
96
  $path = sprintf(
97
  '%s%s%s%s',
@@ -114,6 +129,19 @@ function get_cache_file_path() {
114
  return rtrim( $path, "/" ) . "/";
115
  }
116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  function sbp_explode_lines( $text ) {
118
  if ( $text === '' ) {
119
  return [];
16
  }
17
  }
18
 
19
+ // Get settings
20
+ $settings_file = WP_CONTENT_DIR . '/cache/speed-booster/settings.json';
21
+ $settings = sbp_parse_settings_file( $settings_file );
22
+
23
+ if ( ! $settings ) {
24
+ return false;
25
+ }
26
+
27
  // Set default file name
28
  $filename = 'index.html';
29
 
30
  // Check for query strings
31
+ if ( ! empty( $_GET ) && isset( $settings['caching_include_query_strings'] ) ) {
32
  // Get included rules
33
+ $include_query_strings = sbp_explode_lines( $settings['caching_include_query_strings'] );
34
 
35
  $query_string_file_name = '';
36
  // Put all query string parameters in order to generate same filename even if parameter order is different
56
  }
57
 
58
  // Check if cache file is expired
59
+ if ( isset( $settings['caching_expiry'] ) && ! empty( $settings['caching_expiry'] ) ) {
60
+ $caching_expiry = $settings['caching_expiry'] * HOUR_IN_SECONDS;
61
+ if ( ( filemtime( $cache_file_path ) + $caching_expiry ) < time() ) {
62
+ return false;
63
+ }
64
  }
65
 
66
+ if ( isset( $settings['caching_exclude_urls'] ) ) {
67
+ $exclude_urls = sbp_explode_lines( $settings['caching_exclude_urls'] );
68
+ $current_url = rtrim( $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], '/' );
69
+ if ( count( $exclude_urls ) > 0 && in_array( $current_url, $exclude_urls ) ) {
70
+ return false;
71
+ }
72
  }
73
 
74
  // output cached file
101
 
102
  // generate cache path
103
  function get_cache_file_path() {
104
+ global $settings;
105
  $cache_dir = WP_CONTENT_DIR . '/cache/speed-booster';
106
 
107
+ if ( sbp_is_mobile() && isset( $settings['caching_separate_mobile'] ) && $settings['caching_separate_mobile'] ) {
108
+ $cache_dir = WP_CONTENT_DIR . '/cache/speed-booster/mobile';
109
+ }
110
 
111
  $path = sprintf(
112
  '%s%s%s%s',
129
  return rtrim( $path, "/" ) . "/";
130
  }
131
 
132
+ // read settings file
133
+ function sbp_parse_settings_file( $settings_file ) {
134
+ if ( ! file_exists( $settings_file ) ) {
135
+ return false;
136
+ }
137
+
138
+ if ( ! $settings = json_decode( file_get_contents( $settings_file ), true ) ) {
139
+ return false;
140
+ }
141
+
142
+ return $settings;
143
+ }
144
+
145
  function sbp_explode_lines( $text ) {
146
  if ( $text === '' ) {
147
  return [];
includes/class-speed-booster-pack.php CHANGED
@@ -24,14 +24,12 @@ use SpeedBooster\SBP_Compatibility_Checker;
24
  use SpeedBooster\SBP_Critical_CSS;
25
  use SpeedBooster\SBP_CSS_Minifier;
26
  use SpeedBooster\SBP_Custom_Code_Manager;
27
- use SpeedBooster\SBP_WP_Dashboard;
28
  use SpeedBooster\SBP_Font_Optimizer;
29
  use SpeedBooster\SBP_HTML_Minifier;
30
  use SpeedBooster\SBP_JS_Optimizer;
31
  use SpeedBooster\SBP_Lazy_Loader;
32
  use SpeedBooster\SBP_Localize_Tracker;
33
  use SpeedBooster\SBP_Migrator;
34
- use SpeedBooster\SBP_Newsletter;
35
  use SpeedBooster\SBP_Notice_Manager;
36
  use SpeedBooster\SBP_Preboost;
37
  use SpeedBooster\SBP_Special;
@@ -155,8 +153,6 @@ class Speed_Booster_Pack {
155
  if ( ! $this->should_plugin_run() ) {
156
  return false;
157
  }
158
- new SBP_WP_Dashboard();
159
- new SBP_Newsletter();
160
  new SBP_Migrator();
161
  new SBP_JS_Optimizer();
162
  new SBP_Tweaks();
24
  use SpeedBooster\SBP_Critical_CSS;
25
  use SpeedBooster\SBP_CSS_Minifier;
26
  use SpeedBooster\SBP_Custom_Code_Manager;
 
27
  use SpeedBooster\SBP_Font_Optimizer;
28
  use SpeedBooster\SBP_HTML_Minifier;
29
  use SpeedBooster\SBP_JS_Optimizer;
30
  use SpeedBooster\SBP_Lazy_Loader;
31
  use SpeedBooster\SBP_Localize_Tracker;
32
  use SpeedBooster\SBP_Migrator;
 
33
  use SpeedBooster\SBP_Notice_Manager;
34
  use SpeedBooster\SBP_Preboost;
35
  use SpeedBooster\SBP_Special;
153
  if ( ! $this->should_plugin_run() ) {
154
  return false;
155
  }
 
 
156
  new SBP_Migrator();
157
  new SBP_JS_Optimizer();
158
  new SBP_Tweaks();
includes/classes/class-sbp-advanced-cache-generator.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
-
3
- namespace SpeedBooster;
4
-
5
- // If this file is called directly, abort.
6
- if ( ! defined( 'WPINC' ) ) {
7
- die;
8
- }
9
-
10
- class SBP_Advanced_Cache_Generator {
11
- private static $options = [];
12
- private static $advanced_cache_template = SBP_PATH . 'templates/php/cache/advanced-cache.php';
13
- private static $placeholders = [
14
- '\'__SEPARATE_MOBILE_CACHING__\';' => [
15
- 'option_name' => 'caching_separate_mobile',
16
- 'method_name' => 'separate_mobile_caching',
17
- ],
18
- '\'{{__CACHING_QUERY_STRING_INCLUDES__}}\'' => [
19
- 'option_name' => 'caching_include_query_strings',
20
- 'method_name' => 'caching_query_string_includes',
21
- ],
22
- '\'{{__CACHING_EXPIRY__}}\'' => [
23
- 'option_name' => 'caching_expiry',
24
- 'method_name' => 'caching_expiry',
25
- ],
26
- '\'{{__CACHING_EXCLUDE_URLS__}}\'' => [
27
- 'option_name' => 'caching_exclude_urls',
28
- 'method_name' => 'caching_exclude_urls',
29
- ],
30
- ];
31
-
32
- public static function generate_advanced_cache_file( $options = [] ) {
33
- self::$options = $options;
34
- $wp_filesystem = sbp_get_filesystem();
35
- $file_content = $wp_filesystem->get_contents( self::$advanced_cache_template );
36
- foreach ( self::$placeholders as $placeholder => $props ) {
37
- $method_name = 'SpeedBooster\SBP_Advanced_Cache_Generator::' . $props['method_name'];
38
- if ( ! method_exists( SBP_Advanced_Cache_Generator::class, $props['method_name'] ) ) {
39
- continue;
40
- }
41
- $option_value = false;
42
- if ( self::$options === [] ) {
43
- $option_value = sbp_get_option( $props['option_name'] );
44
- } else {
45
- $option_value = isset( self::$options[ $props['option_name'] ] ) ? self::$options[ $props['option_name'] ] : '';
46
- }
47
- $replace_content = '';
48
- if ( $option_value ) {
49
- $replace_content = call_user_func( $method_name );
50
- }
51
- $file_content = str_replace( "$placeholder", $replace_content, $file_content );
52
- }
53
-
54
- return $file_content;
55
- }
56
-
57
- private static function separate_mobile_caching() {
58
- return 'if ( sbp_is_mobile() ) {
59
- $cache_dir = WP_CONTENT_DIR . \'/cache/speed-booster/mobile\';
60
- }';
61
- }
62
-
63
- private static function caching_query_string_includes() {
64
- return '\'' . self::$options['caching_include_query_strings'] . '\'';
65
- }
66
-
67
- private static function caching_exclude_urls() {
68
- return '\'' . self::$options['caching_exclude_urls'] . '\'';
69
- }
70
-
71
- private static function caching_expiry() {
72
- return self::$options['caching_expiry'];
73
- }
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/class-sbp-cache.php CHANGED
@@ -2,8 +2,6 @@
2
 
3
  namespace SpeedBooster;
4
 
5
- use SpeedBooster\SBP_Advanced_Cache_Generator;
6
-
7
  // If this file is called directly, abort.
8
  if ( ! defined( 'WPINC' ) ) {
9
  die;
@@ -289,23 +287,28 @@ class SBP_Cache extends SBP_Abstract_Module {
289
  public static function options_saved_listener( $saved_data ) {
290
  $advanced_cache_path = WP_CONTENT_DIR . '/advanced-cache.php';
291
 
292
- if ( sbp_should_disable_feature('caching') === false ) {
293
- // Delete or recreate advanced-cache.php
294
- if ( $saved_data['module_caching'] ) {
295
- $advanced_cache_file_content = SBP_Advanced_Cache_Generator::generate_advanced_cache_file($saved_data);
296
- SBP_Cache::set_wp_cache_constant( true );
297
 
298
- file_put_contents( WP_CONTENT_DIR . '/advanced-cache.php', $advanced_cache_file_content );
299
 
300
- self::create_settings_json( $saved_data );
301
- } else {
302
- SBP_Cache::set_wp_cache_constant( false );
303
- if ( file_exists( $advanced_cache_path ) ) {
304
- if ( ! unlink( $advanced_cache_path ) ) {
305
- return wp_send_json_error( [
306
- 'notice' => esc_html__( 'advanced-cache.php can not be removed. Please remove it manually.', 'speed-booster-pack' ),
307
- 'errors' => []
308
- ] );
 
 
 
 
 
 
 
 
 
309
  }
310
  }
311
  }
2
 
3
  namespace SpeedBooster;
4
 
 
 
5
  // If this file is called directly, abort.
6
  if ( ! defined( 'WPINC' ) ) {
7
  die;
287
  public static function options_saved_listener( $saved_data ) {
288
  $advanced_cache_path = WP_CONTENT_DIR . '/advanced-cache.php';
289
 
290
+ if ( ! isset( $_SERVER['KINSTA_CACHE_ZONE'] ) && ( ! defined( 'IS_PRESSABLE' ) || ! IS_PRESSABLE ) ) {
 
 
 
 
291
 
292
+ if ( sbp_get_option( 'module_caching' ) !== $saved_data['module_caching'] ) {
293
 
294
+ // Delete or recreate advanced-cache.php
295
+ if ( $saved_data['module_caching'] ) {
296
+ $sbp_advanced_cache = SBP_PATH . '/advanced-cache.php';
297
+
298
+ SBP_Cache::set_wp_cache_constant( true );
299
+
300
+ file_put_contents( WP_CONTENT_DIR . '/advanced-cache.php', file_get_contents( $sbp_advanced_cache ) );
301
+
302
+ self::create_settings_json( $saved_data );
303
+ } else {
304
+ SBP_Cache::set_wp_cache_constant( false );
305
+ if ( file_exists( $advanced_cache_path ) ) {
306
+ if ( ! unlink( $advanced_cache_path ) ) {
307
+ return wp_send_json_error( [
308
+ 'notice' => esc_html__( 'advanced-cache.php can not be removed. Please remove it manually.', 'speed-booster-pack' ),
309
+ 'errors' => []
310
+ ] );
311
+ }
312
  }
313
  }
314
  }
includes/classes/class-sbp-critical-css.php CHANGED
@@ -23,6 +23,7 @@ class SBP_Critical_CSS extends SBP_Abstract_Module {
23
  return $html;
24
  }
25
 
 
26
  // Find Default Critical CSS Code if exists
27
  $criticalcss_code = sbp_get_option( 'criticalcss_default' );
28
 
23
  return $html;
24
  }
25
 
26
+
27
  // Find Default Critical CSS Code if exists
28
  $criticalcss_code = sbp_get_option( 'criticalcss_default' );
29
 
includes/classes/class-sbp-newsletter.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
-
3
- namespace SpeedBooster;
4
-
5
- // Exit if accessed directly
6
- if ( ! defined( 'ABSPATH' ) ) {
7
- exit;
8
- }
9
-
10
- class SBP_Newsletter {
11
- public function __construct() {
12
- // Only admins can view SpeedBoosterPack things.
13
- if ( ! get_transient( 'sbp_hide_newsletter_pointer' ) ) {
14
- add_action( 'admin_enqueue_scripts', [ $this, 'my_admin_enqueue_scripts' ] );
15
- }
16
-
17
- add_action( 'wp_ajax_sbp_hide_newsletter_pointer', [ $this, 'hide_newsletter_pointer' ] );
18
- }
19
-
20
- function my_admin_enqueue_scripts() {
21
- if ( current_user_can( 'manage_options' ) ) {
22
- wp_enqueue_style( 'wp-pointer' );
23
- wp_enqueue_script( 'wp-pointer' );
24
- add_action( 'admin_print_footer_scripts', [ $this, 'my_admin_print_footer_scripts' ] );
25
- }
26
- }
27
-
28
- function my_admin_print_footer_scripts() {
29
- $current_user = wp_get_current_user();
30
- $pointer_content = sprintf( __( '<h3>%s</h3>', 'speed-booster-pack' ), SBP_PLUGIN_NAME );
31
- $pointer_content .= sprintf( __( '<p>If you want updates from %s, enter your email and hit the subscribe button!</p>\'+', 'speed-booster-pack' ), SBP_PLUGIN_NAME );
32
- $pointer_content .= '\'<div>\'+
33
- \'<form method="POST" action="https://sendfox.com/form/104ezx/3o64jv" id="sbp-subscribe-newsletter-form">\'+
34
- \'<div class="sbp-subscribe-content-wrapper">\'+
35
- \'<div>\'+
36
- \'<div class="mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">\'+
37
- \'<input type="text" name="first_name" class="form-control" placeholder="Name" hidden value="' . $current_user->display_name . '" style="display:none">\'+
38
- \'<input type="text" value="' . $current_user->user_email . '" name="email" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">\'+
39
- \'<input type="hidden" name="ml-submit" value="1" />\'+
40
- \'</div>\'+
41
- \'<input type="submit" value="Subscribe" name="subscribe" id="sbp-newsletter-subscribe-button" class="button mc-newsletter-sent" style="background: #0085ba; border-color: #006799; padding: 0px 16px; text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799; height: 40px; margin-top: 1px; color: #fff; box-shadow: 0 1px 0 #006799;">\'+
42
- \'</div>\'+
43
- \'<div style="padding: 20px;"><label><input type="checkbox" name="gdpr" value="1" required=""> <span>I agree to receive email updates and promotions.</span></label></div>\'+
44
- \'</div>\'+
45
- \'<div style="padding: 10px 20px; color: darkgreen; display: none;" class="sbp-newsletter-success">' . __( 'You have successfully subscribed to our newsletter.', 'speed-booster-pack' ) . '</div>\'+
46
- \'</form>\'+
47
- \'</div>';
48
- ?>
49
- <script type="text/javascript">
50
- //<![CDATA[
51
- jQuery(document).ready(function ($) {
52
- $('#toplevel_page_sbp-settings').pointer({
53
- content: '<?php echo $pointer_content; ?>',
54
- position: {
55
- edge: 'left',
56
- align: 'center',
57
- },
58
- close: function () {
59
- $.post(ajaxurl, {
60
- action: 'sbp_hide_newsletter_pointer'
61
- });
62
- }
63
- }).pointer('open');
64
- });
65
- //]]>
66
- </script>
67
- <?php
68
- }
69
-
70
- public function hide_newsletter_pointer() {
71
- if ( isset( $_POST['action'] ) && $_POST['action'] == 'sbp_hide_newsletter_pointer' && current_user_can( 'manage_options' ) ) {
72
- set_transient( 'sbp_hide_newsletter_pointer', '1' );
73
- echo json_encode( [ 'status' => 'success', 'message' => 'hidden' ] );
74
- wp_die();
75
- }
76
- }
77
- }
78
-
79
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/classes/class-sbp-wp-dashboard.php DELETED
@@ -1,166 +0,0 @@
1
- <?php
2
-
3
- namespace SpeedBooster;
4
-
5
- use SpeedBooster\SBP_Notice_Manager;
6
-
7
- // If this file is called directly, abort.
8
- if ( ! defined( 'WPINC' ) ) {
9
- die;
10
- }
11
-
12
- class SBP_WP_Dashboard {
13
- public function __construct() {
14
- add_action( 'admin_bar_menu', [ $this, 'add_admin_bar_links' ], 90 );
15
- if ( is_admin() ) {
16
- require_once SBP_LIB_PATH . 'announce4wp/announce4wp-client.php';
17
- $this->set_notices();
18
- $this->initialize_announce4wp();
19
- }
20
- }
21
-
22
- public function add_admin_bar_links( \WP_Admin_Bar $admin_bar ) {
23
- if ( current_user_can( 'manage_options' ) ) {
24
-
25
- $admin_bar->add_menu( [
26
- 'id' => 'speed_booster_pack',
27
- 'title' => 'Speed Booster',
28
- 'href' => admin_url( 'admin.php?page=sbp-settings' ),
29
- 'meta' => [
30
- 'target' => '_self',
31
- 'html' => '<style>#wpadminbar #wp-admin-bar-speed_booster_pack .ab-item{background:url("' . SBP_URL . 'admin/images/icon.svg") no-repeat 5px center;padding-left:25px;filter: brightness(0.7) sepia(1) hue-rotate(50deg) saturate(1.5);}#wpadminbar #wp-admin-bar-speed_booster_pack .ab-item:hover{color:white;}</style>',
32
- ],
33
- ] );
34
-
35
- if ( sbp_get_option( 'module_caching' ) && ! sbp_should_disable_feature( 'caching' ) ) {
36
- // Cache clear
37
- $clear_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cache' ), 'sbp_clear_total_cache', 'sbp_nonce' );
38
- $sbp_admin_menu = [
39
- 'id' => 'sbp_clear_cache',
40
- 'parent' => 'speed_booster_pack',
41
- 'title' => __( 'Clear Cache', 'speed-booster-pack' ),
42
- 'href' => $clear_cache_url,
43
- ];
44
-
45
- $admin_bar->add_node( $sbp_admin_menu );
46
-
47
- // Cache warmup
48
- $warmup_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_warmup_cache' ), 'sbp_warmup_cache', 'sbp_nonce' );
49
- $sbp_admin_menu = [
50
- 'id' => 'sbp_warmup_cache',
51
- 'parent' => 'speed_booster_pack',
52
- 'title' => __( 'Warmup Cache', 'speed-booster-pack' ),
53
- 'href' => $warmup_cache_url,
54
- ];
55
-
56
- $admin_bar->add_node( $sbp_admin_menu );
57
- }
58
-
59
- if ( sbp_get_option( 'localize_tracking_scripts' ) ) {
60
- $clear_tracking_scripts_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_localized_analytics' ), 'sbp_clear_localized_analytics', 'sbp_nonce' );
61
- $sbp_admin_menu = [
62
- 'id' => 'sbp_clear_localized_scripts',
63
- 'parent' => 'speed_booster_pack',
64
- 'title' => __( 'Clear Localized Scripts', 'speed-booster-pack' ),
65
- 'href' => $clear_tracking_scripts_url,
66
- ];
67
-
68
- $admin_bar->add_node( $sbp_admin_menu );
69
- }
70
-
71
- if ( SBP_Cloudflare::is_cloudflare_active() ) {
72
- $clear_cloudflare_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cloudflare_cache' ), 'sbp_clear_cloudflare_cache', 'sbp_nonce' );
73
- $sbp_admin_menu = [
74
- 'id' => 'sbp_clear_cloudflare_cache',
75
- 'parent' => 'speed_booster_pack',
76
- 'title' => __( 'Clear Cloudflare Cache', 'speed-booster-pack' ),
77
- 'href' => $clear_cloudflare_cache_url,
78
- ];
79
-
80
- $admin_bar->add_node( $sbp_admin_menu );
81
- }
82
-
83
- if ( sbp_get_option( 'sucuri_enable' ) ) {
84
- $clear_sucuri_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_sucuri_cache' ), 'sbp_clear_sucuri_cache', 'sbp_nonce' );
85
- $sbp_admin_menu = [
86
- 'id' => 'sbp_clear_sucuri_cache',
87
- 'parent' => 'speed_booster_pack',
88
- 'title' => __( 'Clear Sucuri Cache', 'speed-booster-pack' ),
89
- 'href' => $clear_sucuri_cache_url,
90
- ];
91
-
92
- $admin_bar->add_node( $sbp_admin_menu );
93
- }
94
- }
95
- }
96
-
97
- public function set_notices() {
98
- // Set Sucuri Notice
99
- if ( $transient_value = get_transient( 'sbp_clear_sucuri_cache' ) ) {
100
- $notice_message = $transient_value == '1' ? __( 'Sucuri cache cleared.', 'speed-booster-pack' ) : __( 'Error occured while clearing Sucuri cache. ', 'speed-booster-pack' ) . get_transient( 'sbp_sucuri_error' );
101
- $notice_type = $transient_value == '1' ? 'success' : 'error';
102
- SBP_Notice_Manager::display_notice( 'sbp_clear_sucuri_cache', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( $notice_message, 'speed-booster-pack' ) . '</p>', $notice_type, true, 'flash' );
103
- }
104
-
105
- // Set Cloudflare Notice
106
- if ( $transient_value = get_transient( 'sbp_notice_cloudflare' ) ) {
107
- $notice_message = $transient_value == '1' ? __( 'Cloudflare cache cleared.', 'speed-booster-pack' ) : __( 'Error occured while clearing Cloudflare cache. Possible reason: Credentials invalid.', 'speed-booster-pack' );
108
- $notice_type = $transient_value == '1' ? 'success' : 'error';
109
- SBP_Notice_Manager::display_notice( 'sbp_notice_cloudflare', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( $notice_message, 'speed-booster-pack' ) . '</p>', $notice_type, true, 'flash' );
110
- }
111
-
112
- // Set Cache Clear Notice
113
- if ( get_transient( 'sbp_notice_cache' ) ) {
114
- SBP_Notice_Manager::display_notice( 'sbp_notice_cache', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache cleared.', 'speed-booster-pack' ) . '</p>', 'success', true, 'flash' );
115
- }
116
-
117
- // Set Localizer Cache Clear Notice
118
- if ( get_transient( 'sbp_notice_tracker_localizer' ) ) {
119
- SBP_Notice_Manager::display_notice( 'sbp_notice_tracker_localizer', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Localized scripts are cleared.', 'speed-booster-pack' ) . '</p>', 'success', true, 'flash' );
120
- }
121
-
122
- // Warmup Notice
123
- if ( get_transient( 'sbp_warmup_started' ) ) {
124
- // BEYNTODO: Add translator note
125
- SBP_Notice_Manager::display_notice( 'sbp_warmup_started', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache warmup started.', 'speed-booster-pack' ) . '</p>', 'success', true, 'recurrent' );
126
- }
127
-
128
- // Warmup Notice
129
- if ( get_transient( 'sbp_warmup_complete' ) ) {
130
- // BEYNTODO: Add translator note
131
- SBP_Notice_Manager::display_notice( 'sbp_warmup_complete', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Static cache files created.', 'speed-booster-pack' ) . '</p>', 'success', true, 'recurrent' );
132
- }
133
-
134
- // WP-Config Inject File Error
135
- if ( get_transient( 'sbp_wp_config_inject_error' ) ) {
136
- SBP_Notice_Manager::display_notice( 'sbp_wp_config_inject_error', '<p><strong>' . SBP_PLUGIN_NAME . '</strong> ' . __( 'Can not write plugins/speed-booster-pack/includes/wp-config-options/wp-config-inject.php file. Some ' . SBP_PLUGIN_NAME . ' features may not work. Please check your file permissions.', 'speed-booster-pack' ) . '</p>', 'error', true, 'recurrent' );
137
- }
138
-
139
- // WP-Config File Error
140
- if ( get_transient( 'sbp_wp_config_error' ) ) {
141
- SBP_Notice_Manager::display_notice( 'sbp_wp_config_error', '<p><strong>' . SBP_PLUGIN_NAME . '</strong> ' . __( 'Can not write wp-config.php file. Some ' . SBP_PLUGIN_NAME . ' features may not work. Please check your file permissions.', 'speed-booster-pack' ) . '</p>', 'error', true, 'recurrent' );
142
- }
143
-
144
- // WP-Config File Error
145
- if ( get_transient( 'sbp_warmup_errors' ) ) {
146
- $list = '';
147
- $errors = get_transient( 'sbp_warmup_errors' );
148
- if ( is_array( $errors ) ) {
149
- foreach ( $errors as $error ) {
150
- $extras = [];
151
- if ( isset( $error['options']['user-agent'] ) && $error['options']['user-agent'] === 'Mobile' ) {
152
- $extras[] = '(Mobile)';
153
- }
154
- $list .= '<li><a href="' . $error['url'] . '" target="_blank">' . $error['url'] . ' ' . implode( ' ', $extras ) . '</a></li>';
155
- }
156
- SBP_Notice_Manager::display_notice( 'sbp_warmup_errors', '<p><strong>' . SBP_PLUGIN_NAME . '</strong> ' . __( 'Cache warmup completed but following pages may not be cached. Please check this pages are available. (Hover this notice to see all errors)', 'speed-booster-pack' ) . '</p><ul class="warmup-cache-error-list">' . $list . '</ul>', 'error', true, 'recurrent' );
157
- }
158
- }
159
- }
160
-
161
- private function initialize_announce4wp() {
162
- if ( sbp_get_option( 'enable_external_notices' ) ) {
163
- new \Announce4WP_Client( 'speed-booster-pack.php', SBP_PLUGIN_NAME, "sbp", "https://speedboosterpack.com/wp-json/a4wp/v1/" . SBP_VERSION . "/news.json", "toplevel_page_sbp-settings" );
164
- }
165
- }
166
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/sbp-helpers.php CHANGED
@@ -1,11 +1,5 @@
1
  <?php
2
 
3
- use SpeedBooster\SBP_Utils;
4
-
5
- if ( ! defined( 'WPINC' ) ) {
6
- die;
7
- }
8
-
9
  if ( ! function_exists( 'sbp_get_filesystem' ) ) {
10
  function sbp_get_filesystem() {
11
  global $wp_filesystem;
@@ -59,10 +53,10 @@ if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
59
  ];
60
  }
61
 
62
- if ( function_exists( 'is_wpe' ) || function_exists( 'is_wpe_snapshot' ) ) {
63
  return [
64
  'name' => 'WP Engine',
65
- 'disabled_features' => [ 'caching' ],
66
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'WP Engine', 'WP Engine' ),
67
  ];
68
  }
@@ -70,42 +64,42 @@ if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
70
  $hosting_provider_constants = [
71
  'GD_SYSTEM_PLUGIN_DIR' => [
72
  'name' => 'GoDaddy',
73
- 'disabled_features' => [ 'caching' ],
74
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'GoDaddy', 'GoDaddy' ),
75
  ],
76
  'MM_BASE_DIR' => [
77
  'name' => 'Bluehost',
78
- 'disabled_features' => [ 'caching' ],
79
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Bluehost', 'Bluehost' ),
80
  ],
81
  'PAGELYBIN' => [
82
  'name' => 'Pagely',
83
- 'disabled_features' => [ 'caching' ],
84
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pagely', 'Pagely' ),
85
  ],
86
  'KINSTAMU_VERSION' => [
87
  'name' => 'Kinsta',
88
- 'disabled_features' => [ 'caching' ],
89
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
90
  ],
91
  'FLYWHEEL_CONFIG_DIR' => [
92
  'name' => 'Flywheel',
93
- 'disabled_features' => [ 'caching' ],
94
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Flywheel', 'Flywheel' ),
95
  ],
96
  'IS_PRESSABLE' => [
97
  'name' => 'Pressable',
98
- 'disabled_features' => [ 'caching' ],
99
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pressable', 'Pressable' ),
100
  ],
101
  'VIP_GO_ENV' => [
102
  'name' => 'WordPress VIP',
103
- 'disabled_features' => [ 'caching' ],
104
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'WordPress VIP', 'WordPress VIP' ),
105
  ],
106
  'KINSTA_CACHE_ZONE' => [
107
  'name' => 'Kinsta',
108
- 'disabled_features' => [ 'caching', 'lazyload' ],
109
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
110
  ],
111
  ];
@@ -116,10 +110,9 @@ if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
116
  }
117
  }
118
 
119
- return [
120
- 'name' => null,
121
- 'disabled_features' => [],
122
- 'error_message' => ''
123
  ]; // Return this structure to avoid undefined index errors.
124
  }
125
  }
@@ -136,10 +129,9 @@ if ( ! function_exists( 'sbp_should_disable_feature' ) ) {
136
 
137
  if ( ! get_option( 'permalink_structure' ) ) {
138
  // BEYNTODO: Write text for error message.
139
- return [
140
- 'name' => 'Permalink',
141
- 'disabled_features' => [ 'caching' ],
142
- 'error_message' => __( 'You should use Permalinks to enable caching module.', 'speed-booster-pack' )
143
  ];
144
  }
145
 
@@ -169,100 +161,4 @@ if ( ! function_exists( 'sbp_get_filesystem' ) ) {
169
 
170
  return $wp_filesystem;
171
  }
172
- }
173
-
174
- if ( ! function_exists( 'sbp_posabs' ) ) {
175
- /**
176
- * Returns absolute value of a number. Returns 1 if value is zero.
177
- *
178
- * @param $value
179
- *
180
- * @return float|int
181
- * @since 4.0.0
182
- *
183
- */
184
- function sbp_posabs( $value ) {
185
- if ( 0 == $value ) {
186
- return 1;
187
- }
188
-
189
- return absint( $value );
190
- }
191
- }
192
-
193
- if ( ! function_exists( 'sbp_clear_cdn_url' ) ) {
194
- /**
195
- * Removes http(s?):// and trailing slash from the url
196
- *
197
- * @param $url
198
- *
199
- * @return string
200
- * @since 4.0.0
201
- *
202
- */
203
- function sbp_clear_cdn_url( $url ) {
204
- return preg_replace( "#^[^:/.]*[:/]+#i", "", rtrim( $url, '/' ) );
205
- }
206
- }
207
-
208
- if ( ! function_exists( 'sbp_clear_http' ) ) {
209
- /**
210
- * Removes http:// from the url
211
- *
212
- * @param $url
213
- *
214
- * @return string
215
- * @since 4.0.0
216
- *
217
- */
218
- function sbp_clear_http( $url ) {
219
- return str_replace( "http://", "//", $url );
220
- }
221
- }
222
-
223
- if ( ! function_exists( 'sbp_sanitize_strip_tags' ) ) {
224
- /**
225
- * Trims and strips the tags from given value. Takes one dimensional array or string as argument. Returns the modified value.
226
- *
227
- * @param $value array|string
228
- *
229
- * @return array|string
230
- */
231
- function sbp_sanitize_strip_tags( $value ) {
232
- if ( is_array( $value ) ) {
233
- $value = array_map(
234
- function ( $item ) {
235
- return trim( strip_tags( $item ) );
236
- },
237
- $value
238
- );
239
- } else {
240
- $value = trim( strip_tags( $value ) );
241
- }
242
-
243
- return $value;
244
- }
245
- }
246
-
247
- if ( ! function_exists( 'sbp_sanitize_caching_urls' ) ) {
248
- /**
249
- * Sanitizes excluded URLs for caching
250
- *
251
- * @param $urls
252
- *
253
- * @return string
254
- * @since 4.0.0
255
- *
256
- */
257
- function sbp_sanitize_caching_urls( $urls ) {
258
- $urls = SBP_Utils::explode_lines( $urls );
259
- foreach ( $urls as &$url ) {
260
- $url = ltrim( $url, 'https://' );
261
- $url = ltrim( $url, 'http://' );
262
- $url = ltrim( $url, '//' );
263
- $url = rtrim( $url, '/' );
264
- }
265
-
266
- return implode( PHP_EOL, $urls );
267
- }
268
  }
1
  <?php
2
 
 
 
 
 
 
 
3
  if ( ! function_exists( 'sbp_get_filesystem' ) ) {
4
  function sbp_get_filesystem() {
5
  global $wp_filesystem;
53
  ];
54
  }
55
 
56
+ if ( function_exists( 'is_wpe' ) || function_exists( 'is_wpe_snapshot' ) ) { // Z_TODO: Check here
57
  return [
58
  'name' => 'WP Engine',
59
+ 'disabled_features' => [],
60
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'WP Engine', 'WP Engine' ),
61
  ];
62
  }
64
  $hosting_provider_constants = [
65
  'GD_SYSTEM_PLUGIN_DIR' => [
66
  'name' => 'GoDaddy',
67
+ 'disabled_features' => [],
68
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'GoDaddy', 'GoDaddy' ),
69
  ],
70
  'MM_BASE_DIR' => [
71
  'name' => 'Bluehost',
72
+ 'disabled_features' => [],
73
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Bluehost', 'Bluehost' ),
74
  ],
75
  'PAGELYBIN' => [
76
  'name' => 'Pagely',
77
+ 'disabled_features' => [],
78
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pagely', 'Pagely' ),
79
  ],
80
  'KINSTAMU_VERSION' => [
81
  'name' => 'Kinsta',
82
+ 'disabled_features' => [],
83
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
84
  ],
85
  'FLYWHEEL_CONFIG_DIR' => [
86
  'name' => 'Flywheel',
87
+ 'disabled_features' => [],
88
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Flywheel', 'Flywheel' ),
89
  ],
90
  'IS_PRESSABLE' => [
91
  'name' => 'Pressable',
92
+ 'disabled_features' => [],
93
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pressable', 'Pressable' ),
94
  ],
95
  'VIP_GO_ENV' => [
96
  'name' => 'WordPress VIP',
97
+ 'disabled_features' => [],
98
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'WordPress VIP', 'WordPress VIP' ),
99
  ],
100
  'KINSTA_CACHE_ZONE' => [
101
  'name' => 'Kinsta',
102
+ 'disabled_features' => [ 'caching' ],
103
  'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
104
  ],
105
  ];
110
  }
111
  }
112
 
113
+ return [ 'name' => null,
114
+ 'disabled_features' => [],
115
+ 'error_message' => ''
 
116
  ]; // Return this structure to avoid undefined index errors.
117
  }
118
  }
129
 
130
  if ( ! get_option( 'permalink_structure' ) ) {
131
  // BEYNTODO: Write text for error message.
132
+ return [ 'name' => 'Permalink',
133
+ 'disabled_features' => [ 'caching' ],
134
+ 'error_message' => __( 'You must enable permalinks to use caching.', 'speed-booster-pack' )
 
135
  ];
136
  }
137
 
161
 
162
  return $wp_filesystem;
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }
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.1.2
10
  * Author: Optimocha
11
  * Author URI: https://optimocha.com
12
  * License: GPLv3 or later
@@ -32,7 +32,7 @@ define( 'SBP_PLUGIN_NAME', 'Speed Booster Pack' );
32
  /**
33
  * Current plugin version.
34
  */
35
- define( 'SBP_VERSION', '4.1.2' );
36
 
37
  /**
38
  * Plugin website URL.
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.1.3
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.1.3' );
36
 
37
  /**
38
  * Plugin website URL.
templates/php/wp-config/pagespeed_tricker.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
-
3
- if(preg_match('/Lighthouse/i',$_SERVER['HTTP_USER_AGENT'])) {
4
- echo "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"UTF-8\"></head><body style=\"background:#0cce6b;font:bold 15vw sans-serif;color:#fff\">You\'ve got a perfect score. Good for you. Now go and speed up your website for real, actual people.</body></html>";
5
- exit;
6
- }
7
-
8
- ?>