Version Description
Release Date: 4 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).
Download this release
Release Info
Developer | optimocha |
Plugin | Speed Booster Pack |
Version | 4.1.2 |
Comparing to | |
See all releases |
Code changes from version 4.1.1 to 4.1.2
- README.txt +15 -10
- admin/class-speed-booster-pack-admin.php +33 -245
- admin/js/speed-booster-pack-admin.js +36 -5
- includes/class-speed-booster-pack.php +4 -0
- includes/classes/class-sbp-advanced-cache-generator.php +74 -0
- includes/classes/class-sbp-cache.php +17 -20
- includes/classes/class-sbp-cloudflare.php +14 -2
- includes/classes/class-sbp-critical-css.php +0 -1
- includes/classes/class-sbp-lazy-loader.php +1 -1
- includes/classes/class-sbp-newsletter.php +79 -0
- includes/classes/class-sbp-tweaks.php +20 -11
- includes/classes/class-sbp-wp-dashboard.php +166 -0
- includes/sbp-helpers.php +128 -16
- speed-booster-pack.php +2 -2
- advanced-cache.php → templates/php/cache/advanced-cache.php +10 -38
- templates/php/wp-config/pagespeed_tricker.php +8 -0
- uninstall.php +7 -6
- vendor/simplehtmldom/simplehtmldom/HtmlDocument.php +1 -1
- vendor/simplehtmldom/simplehtmldom/HtmlNode.php +2 -2
README.txt
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
=== Speed Booster Pack ⚡ PageSpeed Optimization Suite ===
|
2 |
Plugin Name: Speed Booster Pack ⚡ PageSpeed Optimization Suite
|
3 |
Contributors: optimocha, speedboosterpack
|
4 |
-
Tags: speed, pagespeed, optimization,
|
5 |
-
Stable tag: 4.1.0
|
6 |
Requires at least: 4.6
|
7 |
Tested up to: 5.6
|
8 |
Requires PHP: 5.6
|
9 |
-
Stable tag: 4.1.
|
10 |
License: GPLv3 or later
|
11 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
12 |
|
@@ -105,6 +104,18 @@ All the time! We're always looking for new ways to get this plugin to a better s
|
|
105 |
|
106 |
== Changelog ==
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
*Release Date: 28 January 2021*
|
109 |
|
110 |
* **Improved**: Wrote better descriptions for certain settings.
|
@@ -165,10 +176,4 @@ All the time! We're always looking for new ways to get this plugin to a better s
|
|
165 |
* **Fixed**: The lazy load feature caused mixed content warnings in some edge cases, which is now fixed.
|
166 |
* **Updated**: Updated external libraries (lazyload.js and instantpage.js) to their latest versions.
|
167 |
|
168 |
-
*You can read the rest of the changelog on the [Speed Booster Pack documentation](https://speedboosterpack.com/docs/) page.
|
169 |
-
|
170 |
-
== Upgrade Notice ==
|
171 |
-
|
172 |
-
= 4.1.0 =
|
173 |
-
|
174 |
-
- We have brand new features called Manual Critical CSS and PageSpeed Tricker, plus a TON of improvements to our existing features. Update now and enjoy an even faster website!
|
1 |
=== Speed Booster Pack ⚡ PageSpeed Optimization Suite ===
|
2 |
Plugin Name: Speed Booster Pack ⚡ PageSpeed Optimization Suite
|
3 |
Contributors: optimocha, speedboosterpack
|
4 |
+
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 |
|
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 |
+
|
119 |
*Release Date: 28 January 2021*
|
120 |
|
121 |
* **Improved**: Wrote better descriptions for certain settings.
|
176 |
* **Fixed**: The lazy load feature caused mixed content warnings in some edge cases, which is now fixed.
|
177 |
* **Updated**: Updated external libraries (lazyload.js and instantpage.js) to their latest versions.
|
178 |
|
179 |
+
*You can read the rest of the changelog on the [Speed Booster Pack documentation](https://speedboosterpack.com/docs/) page.
|
|
|
|
|
|
|
|
|
|
|
|
admin/class-speed-booster-pack-admin.php
CHANGED
@@ -11,102 +11,10 @@
|
|
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 |
*
|
@@ -152,8 +60,6 @@ class Speed_Booster_Pack_Admin {
|
|
152 |
|
153 |
$this->load_dependencies();
|
154 |
|
155 |
-
add_action( 'csf_loaded', '\SpeedBooster\SBP_Cloudflare::check_credentials' );
|
156 |
-
|
157 |
add_action( 'csf_sbp_options_save_before', '\SpeedBooster\SBP_Cloudflare::reset_transient' );
|
158 |
|
159 |
add_action( 'csf_sbp_options_save_before', '\SpeedBooster\SBP_Cache::options_saved_listener' );
|
@@ -166,12 +72,6 @@ class Speed_Booster_Pack_Admin {
|
|
166 |
|
167 |
add_action( 'csf_sbp_options_saved', '\SpeedBooster\SBP_WP_Config_Injector::inject_wp_config' );
|
168 |
|
169 |
-
add_action( 'admin_bar_menu', [ $this, 'add_admin_bar_links' ], 90 );
|
170 |
-
|
171 |
-
add_action( 'init', [ $this, 'set_notices' ] );
|
172 |
-
|
173 |
-
$this->initialize_announce4wp();
|
174 |
-
|
175 |
$this->create_settings_page();
|
176 |
|
177 |
add_action( 'admin_enqueue_scripts', 'add_thickbox' );
|
@@ -183,9 +83,7 @@ class Speed_Booster_Pack_Admin {
|
|
183 |
* @since 4.0.0
|
184 |
*/
|
185 |
public function enqueue_styles() {
|
186 |
-
|
187 |
wp_enqueue_style( $this->plugin_name, SBP_URL . 'admin/css/speed-booster-pack-admin.css', array(), $this->version, 'all' );
|
188 |
-
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -199,7 +97,6 @@ class Speed_Booster_Pack_Admin {
|
|
199 |
|
200 |
public function load_dependencies() {
|
201 |
require_once SBP_LIB_PATH . 'codestar-framework/codestar-framework.php';
|
202 |
-
require_once SBP_LIB_PATH . 'announce4wp/announce4wp-client.php';
|
203 |
}
|
204 |
|
205 |
public function create_settings_page() {
|
@@ -282,7 +179,7 @@ class Speed_Booster_Pack_Admin {
|
|
282 |
'<strong>' . __( 'Special', 'speed-booster-pack' ) . '</strong>: ' . __( 'This module has features for specific cases like CDN usage, localizing tracker scripts, adding custom JavaScript code and optimizations for some popular plugins.', 'speed-booster-pack' ) . '</li><li>' .
|
283 |
'<strong>' . __( 'Tweaks', 'speed-booster-pack' ) . '</strong>: ' . __( 'This module lets you tweak the WordPress core and your page sources by dequeueing core scripts/styles, decluttering <head>, optimizing revisions and the Heartbeat API and so on.', 'speed-booster-pack' ) . '</li></ul>' .
|
284 |
'<p>' . __( 'Feel free to experiment, and don\'t forget to create exclude rules when necessary!', 'speed-booster-pack' ) . '</p>',
|
285 |
-
],
|
286 |
[
|
287 |
'type' => 'subheading',
|
288 |
'content' => __( 'Upcoming features', 'speed-booster-pack' ),
|
@@ -436,30 +333,35 @@ class Speed_Booster_Pack_Admin {
|
|
436 |
'id' => 'cf_rocket_loader_enable',
|
437 |
'class' => 'with-preloader',
|
438 |
'type' => 'switcher',
|
|
|
439 |
],
|
440 |
[
|
441 |
'title' => __( 'Development Mode', 'speed-booster-pack' ),
|
442 |
'id' => 'cf_dev_mode_enable',
|
443 |
'class' => 'with-preloader',
|
444 |
'type' => 'switcher',
|
|
|
445 |
],
|
446 |
[
|
447 |
'title' => __( 'Minify CSS', 'speed-booster-pack' ),
|
448 |
'id' => 'cf_css_minify_enable',
|
449 |
'class' => 'with-preloader',
|
450 |
'type' => 'switcher',
|
|
|
451 |
],
|
452 |
[
|
453 |
'title' => __( 'Minify HTML', 'speed-booster-pack' ),
|
454 |
'id' => 'cf_html_minify_enable',
|
455 |
'class' => 'with-preloader',
|
456 |
'type' => 'switcher',
|
|
|
457 |
],
|
458 |
[
|
459 |
'title' => __( 'Minify JS', 'speed-booster-pack' ),
|
460 |
'id' => 'cf_js_minify_enable',
|
461 |
'class' => 'with-preloader',
|
462 |
'type' => 'switcher',
|
|
|
463 |
],
|
464 |
[
|
465 |
'title' => __( 'Browser Cache TTL', 'speed-booster-pack' ),
|
@@ -491,6 +393,7 @@ class Speed_Booster_Pack_Admin {
|
|
491 |
16070400 => __( '6 months', 'speed-booster-pack' ),
|
492 |
31536000 => __( '1 year', 'speed-booster-pack' ),
|
493 |
],
|
|
|
494 |
],
|
495 |
[
|
496 |
'type' => 'content',
|
@@ -500,6 +403,7 @@ class Speed_Booster_Pack_Admin {
|
|
500 |
<span class="sbp-cloudflare-fetching">' . __( 'Fetching Cloudflare settings...', 'speed-booster-pack' ) . '</span>
|
501 |
</span>
|
502 |
<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>
|
|
|
503 |
<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>
|
504 |
<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>
|
505 |
',
|
@@ -624,6 +528,7 @@ class Speed_Booster_Pack_Admin {
|
|
624 |
'sanitize' => 'sbp_sanitize_strip_tags',
|
625 |
'desc' => sprintf( __( 'This CSS block will be injected into all pages if there\'s no critical CSS blocks with higher priority. %1$sLearn more about the template hierarchy of WordPress.%2$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/" rel="external noopener" target="_blank">', '</a>' ),
|
626 |
'dependency' => [ 'module_css|enable_criticalcss', '==|==', '1|1', '', 'visible' ],
|
|
|
627 |
],
|
628 |
[
|
629 |
'id' => 'criticalcss_codes',
|
@@ -639,6 +544,7 @@ class Speed_Booster_Pack_Admin {
|
|
639 |
'type' => 'code_editor',
|
640 |
// Z_TODO: Edit the following description.
|
641 |
'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>' ),
|
|
|
642 |
],
|
643 |
],
|
644 |
],
|
@@ -649,6 +555,7 @@ class Speed_Booster_Pack_Admin {
|
|
649 |
'id' => 'is_home',
|
650 |
'type' => 'code_editor',
|
651 |
'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>' ),
|
|
|
652 |
],
|
653 |
],
|
654 |
],
|
@@ -659,6 +566,7 @@ class Speed_Booster_Pack_Admin {
|
|
659 |
'id' => 'is_single',
|
660 |
'type' => 'code_editor',
|
661 |
'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>' ),
|
|
|
662 |
],
|
663 |
],
|
664 |
],
|
@@ -669,6 +577,7 @@ class Speed_Booster_Pack_Admin {
|
|
669 |
'id' => 'is_page',
|
670 |
'type' => 'code_editor',
|
671 |
'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>' ),
|
|
|
672 |
],
|
673 |
],
|
674 |
],
|
@@ -679,6 +588,7 @@ class Speed_Booster_Pack_Admin {
|
|
679 |
'id' => 'is_category',
|
680 |
'type' => 'code_editor',
|
681 |
'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>' ),
|
|
|
682 |
],
|
683 |
],
|
684 |
],
|
@@ -689,6 +599,7 @@ class Speed_Booster_Pack_Admin {
|
|
689 |
'id' => 'is_tag',
|
690 |
'type' => 'code_editor',
|
691 |
'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>' ),
|
|
|
692 |
],
|
693 |
],
|
694 |
],
|
@@ -699,6 +610,7 @@ class Speed_Booster_Pack_Admin {
|
|
699 |
'id' => 'is_archive',
|
700 |
'type' => 'code_editor',
|
701 |
'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>' ),
|
|
|
702 |
],
|
703 |
],
|
704 |
],
|
@@ -797,7 +709,7 @@ class Speed_Booster_Pack_Admin {
|
|
797 |
'class' => 'lazyload-exclude' . ( $should_disable_lazyload ? ' inactive-section' : null ),
|
798 |
'type' => 'code_editor',
|
799 |
'desc' => __( 'Excluding important images at the top of your pages (like your logo and such) is a good idea. One URL per line.', 'speed-booster-pack' ),
|
800 |
-
'dependency' => [ 'module_assets', '
|
801 |
'sanitize' => 'sbp_clear_http',
|
802 |
],
|
803 |
[
|
@@ -820,7 +732,7 @@ class Speed_Booster_Pack_Admin {
|
|
820 |
'type' => 'code_editor',
|
821 |
'desc' => __( 'If you encounter JavaScript errors on your error console, you can exclude JS file URLs or parts of inline JS here. One rule per line. Since each line will be taken as separate exclude rules, don\'t paste entire blocks of inline JS!', 'speed-booster-pack' ),
|
822 |
'default' => 'js/jquery/jquery.js' . PHP_EOL . 'js/jquery/jquery.min.js',
|
823 |
-
'dependency' => [ 'module_assets', '
|
824 |
],
|
825 |
[
|
826 |
'title' => __( 'Preload assets', 'speed-booster-pack' ),
|
@@ -837,6 +749,7 @@ class Speed_Booster_Pack_Admin {
|
|
837 |
'id' => 'preboost_include',
|
838 |
'type' => 'code_editor',
|
839 |
'desc' => __( 'Enter full URLs of the assets you want to preload. One URL per line.', 'speed-booster-pack' ),
|
|
|
840 |
],
|
841 |
],
|
842 |
'dependency' => [ 'module_assets', '==', '1', '', 'visible' ],
|
@@ -895,6 +808,7 @@ class Speed_Booster_Pack_Admin {
|
|
895 |
'after' => '</script>',
|
896 |
/* translators: %s = script tag */
|
897 |
'desc' => sprintf( __( 'Paste the inline JavaScript here. DON\'T include the %s tags or else you might break it!', 'speed-booster-pack' ), '<code><script></code>' ),
|
|
|
898 |
],
|
899 |
[
|
900 |
'title' => __( 'Placement', 'speed-booster-pack' ),
|
@@ -1085,6 +999,13 @@ class Speed_Booster_Pack_Admin {
|
|
1085 |
'default' => '1',
|
1086 |
'dependency' => [ 'module_tweaks', '==', '1', '', 'visible' ],
|
1087 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1088 |
[
|
1089 |
/* translators: %s = <head> */
|
1090 |
'title' => sprintf( __( 'Declutter %s', 'speed-booster-pack' ), '<code><head></code>' ),
|
@@ -1152,19 +1073,18 @@ class Speed_Booster_Pack_Admin {
|
|
1152 |
'title' => __( 'Tools', 'speed-booster-pack' ),
|
1153 |
'id' => 'tools',
|
1154 |
'icon' => 'fa fa-tools',
|
1155 |
-
'fields' =>
|
1156 |
-
|
1157 |
'type' => 'subheading',
|
1158 |
/* translators: %s = Speed Booster Pack */
|
1159 |
'content' => sprintf( __( 'Backup %s Settings', 'speed-booster-pack' ), SBP_PLUGIN_NAME ),
|
1160 |
-
|
1161 |
-
|
1162 |
'id' => 'backup',
|
1163 |
'type' => 'backup',
|
1164 |
'title' => '',
|
1165 |
-
|
1166 |
-
|
1167 |
-
),
|
1168 |
)
|
1169 |
);
|
1170 |
/* END Section: Tools */
|
@@ -1221,136 +1141,4 @@ class Speed_Booster_Pack_Admin {
|
|
1221 |
/* END Section: About */
|
1222 |
}
|
1223 |
}
|
1224 |
-
|
1225 |
-
public function add_admin_bar_links( WP_Admin_Bar $admin_bar ) {
|
1226 |
-
|
1227 |
-
if ( current_user_can( 'manage_options' ) ) {
|
1228 |
-
|
1229 |
-
$admin_bar->add_menu( [
|
1230 |
-
'id' => 'speed_booster_pack',
|
1231 |
-
'title' => 'Speed Booster',
|
1232 |
-
'href' => admin_url( 'admin.php?page=sbp-settings' ),
|
1233 |
-
'meta' => [
|
1234 |
-
'target' => '_self',
|
1235 |
-
'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>',
|
1236 |
-
],
|
1237 |
-
] );
|
1238 |
-
|
1239 |
-
if ( sbp_get_option( 'module_caching' ) && ! sbp_should_disable_feature( 'caching' ) ) {
|
1240 |
-
// Cache clear
|
1241 |
-
$clear_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cache' ), 'sbp_clear_total_cache', 'sbp_nonce' );
|
1242 |
-
$sbp_admin_menu = [
|
1243 |
-
'id' => 'sbp_clear_cache',
|
1244 |
-
'parent' => 'speed_booster_pack',
|
1245 |
-
'title' => __( 'Clear Cache', 'speed-booster-pack' ),
|
1246 |
-
'href' => $clear_cache_url,
|
1247 |
-
];
|
1248 |
-
|
1249 |
-
$admin_bar->add_node( $sbp_admin_menu );
|
1250 |
-
|
1251 |
-
// Cache warmup
|
1252 |
-
$warmup_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_warmup_cache' ), 'sbp_warmup_cache', 'sbp_nonce' );
|
1253 |
-
$sbp_admin_menu = [
|
1254 |
-
'id' => 'sbp_warmup_cache',
|
1255 |
-
'parent' => 'speed_booster_pack',
|
1256 |
-
'title' => __( 'Warmup Cache', 'speed-booster-pack' ),
|
1257 |
-
'href' => $warmup_cache_url,
|
1258 |
-
];
|
1259 |
-
|
1260 |
-
$admin_bar->add_node( $sbp_admin_menu );
|
1261 |
-
}
|
1262 |
-
|
1263 |
-
if ( sbp_get_option( 'localize_tracking_scripts' ) ) {
|
1264 |
-
$clear_tracking_scripts_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_refresh_localized_analytics' ), 'sbp_refresh_localized_analytics', 'sbp_nonce' );
|
1265 |
-
$sbp_admin_menu = [
|
1266 |
-
'id' => 'sbp_clear_localized_scripts',
|
1267 |
-
'parent' => 'speed_booster_pack',
|
1268 |
-
'title' => __( 'Clear Localized Scripts', 'speed-booster-pack' ),
|
1269 |
-
'href' => $clear_tracking_scripts_url,
|
1270 |
-
];
|
1271 |
-
|
1272 |
-
$admin_bar->add_node( $sbp_admin_menu );
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
if ( SBP_Cloudflare::is_cloudflare_active() ) {
|
1276 |
-
$clear_cloudflare_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_cloudflare_cache' ), 'sbp_clear_cloudflare_cache', 'sbp_nonce' );
|
1277 |
-
$sbp_admin_menu = [
|
1278 |
-
'id' => 'sbp_clear_cloudflare_cache',
|
1279 |
-
'parent' => 'speed_booster_pack',
|
1280 |
-
'title' => __( 'Clear Cloudflare Cache', 'speed-booster-pack' ),
|
1281 |
-
'href' => $clear_cloudflare_cache_url,
|
1282 |
-
];
|
1283 |
-
|
1284 |
-
$admin_bar->add_node( $sbp_admin_menu );
|
1285 |
-
}
|
1286 |
-
|
1287 |
-
if ( sbp_get_option( 'sucuri_enable' ) ) {
|
1288 |
-
$clear_sucuri_cache_url = wp_nonce_url( add_query_arg( 'sbp_action', 'sbp_clear_sucuri_cache' ), 'sbp_clear_sucuri_cache', 'sbp_nonce' );
|
1289 |
-
$sbp_admin_menu = [
|
1290 |
-
'id' => 'sbp_clear_sucuri_cache',
|
1291 |
-
'parent' => 'speed_booster_pack',
|
1292 |
-
'title' => __( 'Clear Sucuri Cache', 'speed-booster-pack' ),
|
1293 |
-
'href' => $clear_sucuri_cache_url,
|
1294 |
-
];
|
1295 |
-
|
1296 |
-
$admin_bar->add_node( $sbp_admin_menu );
|
1297 |
-
}
|
1298 |
-
}
|
1299 |
-
}
|
1300 |
-
|
1301 |
-
public function set_notices() {
|
1302 |
-
if ( SBP_Utils::is_plugin_active( 'autoptimize/autoptimize.php' ) && sbp_get_option( 'enable_criticalcss' ) && get_option( 'autoptimize_css_defer' ) && sbp_get_option( 'module_css' ) ) {
|
1303 |
-
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' );
|
1304 |
-
}
|
1305 |
-
|
1306 |
-
// Set Sucuri Notice
|
1307 |
-
if ( $transient_value = get_transient( 'sbp_clear_sucuri_cache' ) ) {
|
1308 |
-
$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' );
|
1309 |
-
$notice_type = $transient_value == '1' ? 'success' : 'error';
|
1310 |
-
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' );
|
1311 |
-
}
|
1312 |
-
|
1313 |
-
// Set Cloudflare Notice
|
1314 |
-
if ( $transient_value = get_transient( 'sbp_notice_cloudflare' ) ) {
|
1315 |
-
$notice_message = $transient_value == '1' ? __( 'Cloudflare cache cleared.', 'speed-booster-pack' ) : __( 'Error occured while clearing Cloudflare cache. Possible reason: Credentials invalid.', 'speed-booster-pack' );
|
1316 |
-
$notice_type = $transient_value == '1' ? 'success' : 'error';
|
1317 |
-
SBP_Notice_Manager::display_notice( 'sbp_notice_cloudflare', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( $notice_message, 'speed-booster-pack' ) . '</p>', $notice_type, true, 'flash' );
|
1318 |
-
}
|
1319 |
-
|
1320 |
-
// Set Cache Clear Notice
|
1321 |
-
if ( get_transient( 'sbp_notice_cache' ) ) {
|
1322 |
-
SBP_Notice_Manager::display_notice( 'sbp_notice_cache', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache cleared.', 'speed-booster-pack' ) . '</p>', 'success', true, 'flash' );
|
1323 |
-
}
|
1324 |
-
|
1325 |
-
// Set Localizer Cache Clear Notice
|
1326 |
-
if ( get_transient( 'sbp_notice_tracker_localizer' ) ) {
|
1327 |
-
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' );
|
1328 |
-
}
|
1329 |
-
|
1330 |
-
// Warmup Notice
|
1331 |
-
if ( get_transient( 'sbp_warmup_started' ) ) {
|
1332 |
-
SBP_Notice_Manager::display_notice( 'sbp_warmup_started', '<p><strong>' . SBP_PLUGIN_NAME . ':</strong> ' . __( 'Cache warmup started.', 'speed-booster-pack' ) . '</p>', 'success', true, 'recurrent' );
|
1333 |
-
}
|
1334 |
-
|
1335 |
-
// Warmup Notice
|
1336 |
-
if ( get_transient( 'sbp_warmup_complete' ) ) {
|
1337 |
-
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' );
|
1338 |
-
}
|
1339 |
-
|
1340 |
-
// WP-Config Inject File Error
|
1341 |
-
if ( get_transient( 'sbp_wp_config_inject_error' ) ) {
|
1342 |
-
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' );
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
// WP-Config File Error
|
1346 |
-
if ( get_transient( 'sbp_wp_config_error' ) ) {
|
1347 |
-
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' );
|
1348 |
-
}
|
1349 |
-
}
|
1350 |
-
|
1351 |
-
private function initialize_announce4wp() {
|
1352 |
-
if ( sbp_get_option( 'enable_external_notices' ) ) {
|
1353 |
-
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" );
|
1354 |
-
}
|
1355 |
-
}
|
1356 |
}
|
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 |
*
|
60 |
|
61 |
$this->load_dependencies();
|
62 |
|
|
|
|
|
63 |
add_action( 'csf_sbp_options_save_before', '\SpeedBooster\SBP_Cloudflare::reset_transient' );
|
64 |
|
65 |
add_action( 'csf_sbp_options_save_before', '\SpeedBooster\SBP_Cache::options_saved_listener' );
|
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 |
* @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 |
|
98 |
public function load_dependencies() {
|
99 |
require_once SBP_LIB_PATH . 'codestar-framework/codestar-framework.php';
|
|
|
100 |
}
|
101 |
|
102 |
public function create_settings_page() {
|
179 |
'<strong>' . __( 'Special', 'speed-booster-pack' ) . '</strong>: ' . __( 'This module has features for specific cases like CDN usage, localizing tracker scripts, adding custom JavaScript code and optimizations for some popular plugins.', 'speed-booster-pack' ) . '</li><li>' .
|
180 |
'<strong>' . __( 'Tweaks', 'speed-booster-pack' ) . '</strong>: ' . __( 'This module lets you tweak the WordPress core and your page sources by dequeueing core scripts/styles, decluttering <head>, optimizing revisions and the Heartbeat API and so on.', 'speed-booster-pack' ) . '</li></ul>' .
|
181 |
'<p>' . __( 'Feel free to experiment, and don\'t forget to create exclude rules when necessary!', 'speed-booster-pack' ) . '</p>',
|
182 |
+
],
|
183 |
[
|
184 |
'type' => 'subheading',
|
185 |
'content' => __( 'Upcoming features', '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' ),
|
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 |
<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 |
',
|
528 |
'sanitize' => 'sbp_sanitize_strip_tags',
|
529 |
'desc' => sprintf( __( 'This CSS block will be injected into all pages if there\'s no critical CSS blocks with higher priority. %1$sLearn more about the template hierarchy of WordPress.%2$s', 'speed-booster-pack' ), '<a href="https://developer.wordpress.org/themes/basics/template-hierarchy/" rel="external noopener" target="_blank">', '</a>' ),
|
530 |
'dependency' => [ 'module_css|enable_criticalcss', '==|==', '1|1', '', 'visible' ],
|
531 |
+
'settings' => [ 'lineWrapping' => true ],
|
532 |
],
|
533 |
[
|
534 |
'id' => 'criticalcss_codes',
|
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 |
],
|
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 |
],
|
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 |
],
|
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 |
],
|
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 |
],
|
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 |
],
|
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 |
],
|
709 |
'class' => 'lazyload-exclude' . ( $should_disable_lazyload ? ' inactive-section' : null ),
|
710 |
'type' => 'code_editor',
|
711 |
'desc' => __( 'Excluding important images at the top of your pages (like your logo and such) is a good idea. One URL per line.', 'speed-booster-pack' ),
|
712 |
+
'dependency' => [ 'module_assets|lazyload', '==|==', '1|1', '', 'visible|visible' ],
|
713 |
'sanitize' => 'sbp_clear_http',
|
714 |
],
|
715 |
[
|
732 |
'type' => 'code_editor',
|
733 |
'desc' => __( 'If you encounter JavaScript errors on your error console, you can exclude JS file URLs or parts of inline JS here. One rule per line. Since each line will be taken as separate exclude rules, don\'t paste entire blocks of inline JS!', 'speed-booster-pack' ),
|
734 |
'default' => 'js/jquery/jquery.js' . PHP_EOL . 'js/jquery/jquery.min.js',
|
735 |
+
'dependency' => [ 'module_assets|js_optimize', '==|!=', '1|off', '', 'visible|visible' ],
|
736 |
],
|
737 |
[
|
738 |
'title' => __( 'Preload assets', 'speed-booster-pack' ),
|
749 |
'id' => 'preboost_include',
|
750 |
'type' => 'code_editor',
|
751 |
'desc' => __( 'Enter full URLs of the assets you want to preload. One URL per line.', 'speed-booster-pack' ),
|
752 |
+
'dependency' => [ 'preboost_enable', '==', '1', '', 'visible' ],
|
753 |
],
|
754 |
],
|
755 |
'dependency' => [ 'module_assets', '==', '1', '', 'visible' ],
|
808 |
'after' => '</script>',
|
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><script></code>' ),
|
811 |
+
'settings' => [ 'lineWrapping' => true ],
|
812 |
],
|
813 |
[
|
814 |
'title' => __( 'Placement', 'speed-booster-pack' ),
|
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><head></code>' ),
|
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 |
/* END Section: About */
|
1142 |
}
|
1143 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1144 |
}
|
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 |
|
@@ -51,8 +51,10 @@
|
|
51 |
response = JSON.parse(response);
|
52 |
if (response.status === 'true') {
|
53 |
$('.sbp-cloudflare-correct').show();
|
54 |
-
} else {
|
55 |
$('.sbp-cloudflare-incorrect').show();
|
|
|
|
|
56 |
}
|
57 |
},
|
58 |
complete: function () {
|
@@ -153,12 +155,15 @@
|
|
153 |
} else if (response.status === 'empty_info') {
|
154 |
$('.sbp-cloudflare-warning').show();
|
155 |
} else {
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
158 |
$('.with-preloader::before, .with-preloader::after').remove();
|
159 |
}
|
160 |
},
|
161 |
-
complete: function() {
|
162 |
$('.sbp-cloudflare-test .sbp-cloudflare-spinner').hide();
|
163 |
$('.sbp-cloudflare-test').removeAttr('disabled').css('opacity', 1);
|
164 |
$('.sbp-cloudflare-fetching').remove();
|
@@ -188,4 +193,30 @@
|
|
188 |
|
189 |
});
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
})(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 |
|
51 |
response = JSON.parse(response);
|
52 |
if (response.status === 'true') {
|
53 |
$('.sbp-cloudflare-correct').show();
|
54 |
+
} else if (response.status === 'false') {
|
55 |
$('.sbp-cloudflare-incorrect').show();
|
56 |
+
} else {
|
57 |
+
$('.sbp-cloudflare-connection-issue').show();
|
58 |
}
|
59 |
},
|
60 |
complete: function () {
|
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 |
|
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);
|
includes/class-speed-booster-pack.php
CHANGED
@@ -24,12 +24,14 @@ 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_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,6 +155,8 @@ class Speed_Booster_Pack {
|
|
153 |
if ( ! $this->should_plugin_run() ) {
|
154 |
return false;
|
155 |
}
|
|
|
|
|
156 |
new SBP_Migrator();
|
157 |
new SBP_JS_Optimizer();
|
158 |
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_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 |
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();
|
includes/classes/class-sbp-advanced-cache-generator.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,6 +2,8 @@
|
|
2 |
|
3 |
namespace SpeedBooster;
|
4 |
|
|
|
|
|
5 |
// If this file is called directly, abort.
|
6 |
if ( ! defined( 'WPINC' ) ) {
|
7 |
die;
|
@@ -287,28 +289,23 @@ class SBP_Cache extends SBP_Abstract_Module {
|
|
287 |
public static function options_saved_listener( $saved_data ) {
|
288 |
$advanced_cache_path = WP_CONTENT_DIR . '/advanced-cache.php';
|
289 |
|
290 |
-
if (
|
291 |
-
|
292 |
-
if (
|
293 |
-
|
294 |
-
|
295 |
-
if ( $saved_data['module_caching'] ) {
|
296 |
-
$sbp_advanced_cache = SBP_PATH . '/advanced-cache.php';
|
297 |
|
298 |
-
|
299 |
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
'errors' => []
|
310 |
-
] );
|
311 |
-
}
|
312 |
}
|
313 |
}
|
314 |
}
|
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 |
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 |
}
|
includes/classes/class-sbp-cloudflare.php
CHANGED
@@ -116,6 +116,10 @@ class SBP_Cloudflare extends SBP_Abstract_Module {
|
|
116 |
return true;
|
117 |
}
|
118 |
|
|
|
|
|
|
|
|
|
119 |
return false;
|
120 |
}
|
121 |
|
@@ -202,10 +206,18 @@ class SBP_Cloudflare extends SBP_Abstract_Module {
|
|
202 |
'email' => $_POST['email'],
|
203 |
'api_key' => $_POST['api_key'],
|
204 |
'zone' => $_POST['zone_id'],
|
205 |
-
] )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
echo json_encode( [
|
208 |
-
'status' => $
|
209 |
] );
|
210 |
wp_die();
|
211 |
}
|
116 |
return true;
|
117 |
}
|
118 |
|
119 |
+
if ( !$result ) {
|
120 |
+
return null;
|
121 |
+
}
|
122 |
+
|
123 |
return false;
|
124 |
}
|
125 |
|
206 |
'email' => $_POST['email'],
|
207 |
'api_key' => $_POST['api_key'],
|
208 |
'zone' => $_POST['zone_id'],
|
209 |
+
] );
|
210 |
+
|
211 |
+
if ($status === true) {
|
212 |
+
$return_value = 'true';
|
213 |
+
} else if ($status === null) {
|
214 |
+
$return_value = 'null';
|
215 |
+
} else {
|
216 |
+
$return_value = 'false';
|
217 |
+
}
|
218 |
|
219 |
echo json_encode( [
|
220 |
+
'status' => $return_value,
|
221 |
] );
|
222 |
wp_die();
|
223 |
}
|
includes/classes/class-sbp-critical-css.php
CHANGED
@@ -23,7 +23,6 @@ class SBP_Critical_CSS extends SBP_Abstract_Module {
|
|
23 |
return $html;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
// Find Default Critical CSS Code if exists
|
28 |
$criticalcss_code = sbp_get_option( 'criticalcss_default' );
|
29 |
|
23 |
return $html;
|
24 |
}
|
25 |
|
|
|
26 |
// Find Default Critical CSS Code if exists
|
27 |
$criticalcss_code = sbp_get_option( 'criticalcss_default' );
|
28 |
|
includes/classes/class-sbp-lazy-loader.php
CHANGED
@@ -88,7 +88,7 @@ class SBP_Lazy_Loader extends SBP_Abstract_Module {
|
|
88 |
'wp-embedded-content',
|
89 |
];
|
90 |
$lazyload_exclusions = apply_filters( 'sbp_lazyload_exclusions', array_merge( $lazyload_exclusions, $default_lazyload_exclusions ) );
|
91 |
-
$placeholder = 'data:image/
|
92 |
|
93 |
// Find all images
|
94 |
preg_match_all( '/<(img|source|iframe)(.*?) (src=)[\'|"](.*?)[\'|"](.*?)>/is', $html, $resource_elements );
|
88 |
'wp-embedded-content',
|
89 |
];
|
90 |
$lazyload_exclusions = apply_filters( 'sbp_lazyload_exclusions', array_merge( $lazyload_exclusions, $default_lazyload_exclusions ) );
|
91 |
+
$placeholder = 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=';
|
92 |
|
93 |
// Find all images
|
94 |
preg_match_all( '/<(img|source|iframe)(.*?) (src=)[\'|"](.*?)[\'|"](.*?)>/is', $html, $resource_elements );
|
includes/classes/class-sbp-newsletter.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-tweaks.php
CHANGED
@@ -9,17 +9,17 @@ if ( ! defined( 'WPINC' ) ) {
|
|
9 |
|
10 |
class SBP_Tweaks extends SBP_Abstract_Module {
|
11 |
private $tweak_settings = [
|
12 |
-
'trim_query_strings'
|
13 |
-
'dequeue_emoji_scripts'
|
14 |
-
'disable_self_pingbacks'
|
15 |
-
'dequeue_dashicons'
|
16 |
-
'post_revisions'
|
17 |
-
'autosave_interval'
|
18 |
-
'dequeue_block_library'
|
19 |
-
'disable_post_embeds'
|
20 |
-
'instant_page'
|
21 |
-
'heartbeat_settings'
|
22 |
-
'declutter_head'
|
23 |
'declutter_shortlinks' => 'declutter_shortlinks',
|
24 |
'declutter_adjacent_posts_links' => 'declutter_adjacent_posts_links',
|
25 |
'declutter_wlw' => 'declutter_wlw',
|
@@ -28,6 +28,7 @@ class SBP_Tweaks extends SBP_Abstract_Module {
|
|
28 |
'declutter_feed_links' => 'declutter_feed_links',
|
29 |
'declutter_wp_version' => 'declutter_wp_version',
|
30 |
],
|
|
|
31 |
];
|
32 |
|
33 |
public function __construct() {
|
@@ -276,6 +277,14 @@ class SBP_Tweaks extends SBP_Abstract_Module {
|
|
276 |
wp_enqueue_script( 'sbp-ins-page', SBP_URL . 'public/js/inspage.js', false, '5.1.0', true );
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
private function declutter_shortlinks() {
|
280 |
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
|
281 |
}
|
9 |
|
10 |
class SBP_Tweaks extends SBP_Abstract_Module {
|
11 |
private $tweak_settings = [
|
12 |
+
'trim_query_strings' => 'trim_query_strings',
|
13 |
+
'dequeue_emoji_scripts' => 'dequeue_emoji_scripts',
|
14 |
+
'disable_self_pingbacks' => 'disable_self_pingbacks',
|
15 |
+
'dequeue_dashicons' => 'dequeue_dashicons',
|
16 |
+
'post_revisions' => 'post_revisions',
|
17 |
+
'autosave_interval' => 'autosave_interval',
|
18 |
+
'dequeue_block_library' => 'dequeue_block_library',
|
19 |
+
'disable_post_embeds' => 'disable_post_embeds',
|
20 |
+
'instant_page' => 'instant_page',
|
21 |
+
'heartbeat_settings' => 'heartbeat_settings',
|
22 |
+
'declutter_head' => [
|
23 |
'declutter_shortlinks' => 'declutter_shortlinks',
|
24 |
'declutter_adjacent_posts_links' => 'declutter_adjacent_posts_links',
|
25 |
'declutter_wlw' => 'declutter_wlw',
|
28 |
'declutter_feed_links' => 'declutter_feed_links',
|
29 |
'declutter_wp_version' => 'declutter_wp_version',
|
30 |
],
|
31 |
+
'dequeue_comment_reply_script' => 'dequeue_comment_reply_script',
|
32 |
];
|
33 |
|
34 |
public function __construct() {
|
277 |
wp_enqueue_script( 'sbp-ins-page', SBP_URL . 'public/js/inspage.js', false, '5.1.0', true );
|
278 |
}
|
279 |
|
280 |
+
private function dequeue_comment_reply_script() {
|
281 |
+
add_action( 'init', [ $this, 'comment_reply_script_handle' ] );
|
282 |
+
}
|
283 |
+
|
284 |
+
public function comment_reply_script_handle() {
|
285 |
+
wp_deregister_script( 'comment-reply' );
|
286 |
+
}
|
287 |
+
|
288 |
private function declutter_shortlinks() {
|
289 |
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
|
290 |
}
|
includes/classes/class-sbp-wp-dashboard.php
ADDED
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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,5 +1,11 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
if ( ! function_exists( 'sbp_get_filesystem' ) ) {
|
4 |
function sbp_get_filesystem() {
|
5 |
global $wp_filesystem;
|
@@ -46,47 +52,55 @@ if ( ! function_exists( 'sbp_delete_dir_recursively' ) ) {
|
|
46 |
if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
|
47 |
function sbp_get_hosting_restrictions() {
|
48 |
if ( isset( $_SERVER['KINSTA_CACHE_ZONE'] ) && $_SERVER['KINSTA_CACHE_ZONE'] ) {
|
49 |
-
return
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
-
if ( function_exists( 'is_wpe' ) || function_exists( 'is_wpe_snapshot' ) ) {
|
53 |
-
return [
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
$hosting_provider_constants = [
|
57 |
'GD_SYSTEM_PLUGIN_DIR' => [
|
58 |
'name' => 'GoDaddy',
|
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.' ), 'GoDaddy', 'GoDaddy' ),
|
61 |
],
|
62 |
'MM_BASE_DIR' => [
|
63 |
'name' => 'Bluehost',
|
64 |
-
'disabled_features' => [],
|
65 |
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Bluehost', 'Bluehost' ),
|
66 |
],
|
67 |
'PAGELYBIN' => [
|
68 |
'name' => 'Pagely',
|
69 |
-
'disabled_features' => [],
|
70 |
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pagely', 'Pagely' ),
|
71 |
],
|
72 |
'KINSTAMU_VERSION' => [
|
73 |
'name' => 'Kinsta',
|
74 |
-
'disabled_features' => [],
|
75 |
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
|
76 |
],
|
77 |
'FLYWHEEL_CONFIG_DIR' => [
|
78 |
'name' => 'Flywheel',
|
79 |
-
'disabled_features' => [],
|
80 |
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Flywheel', 'Flywheel' ),
|
81 |
],
|
82 |
'IS_PRESSABLE' => [
|
83 |
'name' => 'Pressable',
|
84 |
-
'disabled_features' => [],
|
85 |
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Pressable', 'Pressable' ),
|
86 |
],
|
87 |
'VIP_GO_ENV' => [
|
88 |
'name' => 'WordPress VIP',
|
89 |
-
'disabled_features' => [],
|
90 |
'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' ),
|
91 |
],
|
92 |
'KINSTA_CACHE_ZONE' => [
|
@@ -102,9 +116,10 @@ if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
|
|
102 |
}
|
103 |
}
|
104 |
|
105 |
-
return [
|
106 |
-
|
107 |
-
|
|
|
108 |
]; // Return this structure to avoid undefined index errors.
|
109 |
}
|
110 |
}
|
@@ -121,9 +136,10 @@ if ( ! function_exists( 'sbp_should_disable_feature' ) ) {
|
|
121 |
|
122 |
if ( ! get_option( 'permalink_structure' ) ) {
|
123 |
// BEYNTODO: Write text for error message.
|
124 |
-
return [
|
125 |
-
|
126 |
-
|
|
|
127 |
];
|
128 |
}
|
129 |
|
@@ -153,4 +169,100 @@ if ( ! function_exists( 'sbp_get_filesystem' ) ) {
|
|
153 |
|
154 |
return $wp_filesystem;
|
155 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
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;
|
52 |
if ( ! function_exists( 'sbp_get_hosting_restrictions' ) ) {
|
53 |
function sbp_get_hosting_restrictions() {
|
54 |
if ( isset( $_SERVER['KINSTA_CACHE_ZONE'] ) && $_SERVER['KINSTA_CACHE_ZONE'] ) {
|
55 |
+
return [
|
56 |
+
'name' => 'Kinsta',
|
57 |
+
'disabled_features' => [ 'caching' ],
|
58 |
+
'error_message' => sprintf( __( 'Since you\'re using %s, cache feature is completely disabled to ensure compatibility with internal caching system of %s.' ), 'Kinsta', 'Kinsta' ),
|
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 |
}
|
69 |
|
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' => [
|
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 |
|
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 |
|
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 |
}
|
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.
|
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.
|
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.2
|
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.2' );
|
36 |
|
37 |
/**
|
38 |
* Plugin website URL.
|
advanced-cache.php → templates/php/cache/advanced-cache.php
RENAMED
@@ -16,21 +16,13 @@ if ( ! empty( $_COOKIE ) ) {
|
|
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 )
|
32 |
// Get included rules
|
33 |
-
$include_query_strings = sbp_explode_lines(
|
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,19 +48,15 @@ if ( ! is_readable( $cache_file_path ) ) {
|
|
56 |
}
|
57 |
|
58 |
// Check if cache file is expired
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
return false;
|
63 |
-
}
|
64 |
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
return false;
|
71 |
-
}
|
72 |
}
|
73 |
|
74 |
// output cached file
|
@@ -101,12 +89,9 @@ function sbp_is_mobile() {
|
|
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 |
-
|
108 |
-
$cache_dir = WP_CONTENT_DIR . '/cache/speed-booster/mobile';
|
109 |
-
}
|
110 |
|
111 |
$path = sprintf(
|
112 |
'%s%s%s%s',
|
@@ -129,19 +114,6 @@ function get_cache_file_path() {
|
|
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 [];
|
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 |
}
|
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 |
|
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 |
return rtrim( $path, "/" ) . "/";
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
function sbp_explode_lines( $text ) {
|
118 |
if ( $text === '' ) {
|
119 |
return [];
|
templates/php/wp-config/pagespeed_tricker.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
?>
|
uninstall.php
CHANGED
@@ -114,10 +114,11 @@ if ( $wp_filesystem->exists( ABSPATH . 'wp-config.php' ) ) {
|
|
114 |
$wp_config_file = dirname( ABSPATH ) . '/wp-config.php';
|
115 |
}
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
$wp_filesystem->
|
121 |
-
|
122 |
-
|
|
|
123 |
}
|
114 |
$wp_config_file = dirname( ABSPATH ) . '/wp-config.php';
|
115 |
}
|
116 |
|
117 |
+
$wp_config_content = $wp_filesystem->get_contents( $wp_config_file );
|
118 |
+
$config_regex = '/\/\/ BEGIN SBP_WP_Config(.*?)\/\/ END SBP_WP_Config/si';
|
119 |
+
if ( preg_match( $config_regex, $wp_config_content ) ) {
|
120 |
+
if ($wp_filesystem->is_writable($wp_config_file)) {
|
121 |
+
$modified_wp_config_content = preg_replace( $config_regex, '', $wp_config_content );
|
122 |
+
$wp_filesystem->put_contents( $wp_config_file, $modified_wp_config_content );
|
123 |
+
}
|
124 |
}
|
vendor/simplehtmldom/simplehtmldom/HtmlDocument.php
CHANGED
@@ -220,7 +220,7 @@ class HtmlDocument
|
|
220 |
// end
|
221 |
$this->root->_[HtmlNode::HDOM_INFO_END] = $this->cursor;
|
222 |
$this->parse_charset();
|
223 |
-
$this->decode();
|
224 |
unset($this->doc);
|
225 |
|
226 |
// make load function chainable
|
220 |
// end
|
221 |
$this->root->_[HtmlNode::HDOM_INFO_END] = $this->cursor;
|
222 |
$this->parse_charset();
|
223 |
+
// $this->decode();
|
224 |
unset($this->doc);
|
225 |
|
226 |
// make load function chainable
|
vendor/simplehtmldom/simplehtmldom/HtmlNode.php
CHANGED
@@ -444,7 +444,7 @@ class HtmlNode
|
|
444 |
{
|
445 |
case self::HDOM_QUOTE_SINGLE:
|
446 |
$quote = '\'';
|
447 |
-
$val = htmlentities($val, ENT_QUOTES, $this->dom->target_charset);
|
448 |
break;
|
449 |
case self::HDOM_QUOTE_NO:
|
450 |
$quote = '';
|
@@ -452,7 +452,7 @@ class HtmlNode
|
|
452 |
case self::HDOM_QUOTE_DOUBLE:
|
453 |
default:
|
454 |
$quote = '"';
|
455 |
-
$val = htmlentities($val, ENT_COMPAT, $this->dom->target_charset);
|
456 |
}
|
457 |
|
458 |
$ret .= $key
|
444 |
{
|
445 |
case self::HDOM_QUOTE_SINGLE:
|
446 |
$quote = '\'';
|
447 |
+
// $val = htmlentities($val, ENT_QUOTES, $this->dom->target_charset);
|
448 |
break;
|
449 |
case self::HDOM_QUOTE_NO:
|
450 |
$quote = '';
|
452 |
case self::HDOM_QUOTE_DOUBLE:
|
453 |
default:
|
454 |
$quote = '"';
|
455 |
+
// $val = htmlentities($val, ENT_COMPAT, $this->dom->target_charset);
|
456 |
}
|
457 |
|
458 |
$ret .= $key
|