Version Description
Release Date: 13 February 2020
- Added: New feature - Optimize Google Fonts!
- Updated: Rewrote the whole JavaScript optimization feature! Hopefully it will work even better than our previous version. We also added a simple migration notice to not break current configurations, so be sure to migrate!
- Removed: JavaSript deferring feature has been removed - coming back in a future release!
- Removed: Deleted the non-working review nag.
-
Updated: Updated
lazyload.js
to 12.4.0. - Updated: Refactored the code a bit. Also cleaned up a lot of unnecessary stuff.
-
Fixed: Speed Booster Pack is disabled for all (almost) Page Builder instances, and even a few other plugins that have front-end editors! You can also temporarily disable SBP for a specific URL by adding
sbp_disable=1
at the end of a URL. - Fixed: Tabbed navigation in the settings page is working better now.
- Fixed: A small issue in the emoji disabler feature is fixed.
- Fixed: Some translatable strings are changed and a few untranslatable strings are fixed.
Download this release
Release Info
Developer | optimocha |
Plugin | Speed Booster Pack |
Version | 3.8.5 |
Comparing to | |
See all releases |
Code changes from version 3.8.4.3 to 3.8.5
- css/style.css +13 -2
- inc/class-sb-pack-review.php +0 -189
- inc/core.php +469 -230
- inc/css-optimizer.php +30 -29
- inc/js/admin-scripts.js +12 -9
- inc/js/lazyload.js +2 -3
- inc/sbp-minifier.php +119 -115
- inc/settings.php +97 -190
- inc/template/notice.php +18 -12
- inc/template/notices/migrate_js_to_footer.php +4 -0
- inc/template/options.php +725 -625
- readme.txt +19 -4
- speed-booster-pack.php +95 -117
- uninstall.php +6 -15
css/style.css
CHANGED
@@ -3,6 +3,13 @@ html {
|
|
3 |
box-sizing: border-box;
|
4 |
}
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
*,
|
7 |
*:before,
|
8 |
*:after {
|
@@ -424,7 +431,7 @@ html {
|
|
424 |
width: 100%;
|
425 |
}
|
426 |
|
427 |
-
.sbp-static-notice {
|
428 |
position: relative;
|
429 |
display: inline-block;
|
430 |
width: 100%;
|
@@ -437,11 +444,15 @@ html {
|
|
437 |
box-shadow: 3px 4px 6px -6px #c3bcbc;
|
438 |
}
|
439 |
|
440 |
-
.sbp-static-notice.bg-red {
|
441 |
background-color: #EF5350;
|
442 |
color: #ffffff;
|
443 |
}
|
444 |
|
|
|
|
|
|
|
|
|
445 |
.nav-tab, .nav-tab .dashicons {line-height:1;}
|
446 |
.nav-tab .dashicons {vertical-align:text-top;}
|
447 |
.nav-tab .dashicons-admin-generic {color:#4CAF50;}
|
3 |
box-sizing: border-box;
|
4 |
}
|
5 |
|
6 |
+
:target:before {
|
7 |
+
content:"";
|
8 |
+
display:block;
|
9 |
+
height:90px;
|
10 |
+
margin-top:-90px;
|
11 |
+
}
|
12 |
+
|
13 |
*,
|
14 |
*:before,
|
15 |
*:after {
|
431 |
width: 100%;
|
432 |
}
|
433 |
|
434 |
+
.sbp-static-notice, .sbp-warning {
|
435 |
position: relative;
|
436 |
display: inline-block;
|
437 |
width: 100%;
|
444 |
box-shadow: 3px 4px 6px -6px #c3bcbc;
|
445 |
}
|
446 |
|
447 |
+
.sbp-static-notice.bg-red, .sbp-warning.bg-red {
|
448 |
background-color: #EF5350;
|
449 |
color: #ffffff;
|
450 |
}
|
451 |
|
452 |
+
.sbp-warning {
|
453 |
+
margin: 0 0 10px;
|
454 |
+
}
|
455 |
+
|
456 |
.nav-tab, .nav-tab .dashicons {line-height:1;}
|
457 |
.nav-tab .dashicons {vertical-align:text-top;}
|
458 |
.nav-tab .dashicons-admin-generic {color:#4CAF50;}
|
inc/class-sb-pack-review.php
DELETED
@@ -1,189 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
-
die;
|
6 |
-
}
|
7 |
-
|
8 |
-
class SB_Pack_Review {
|
9 |
-
|
10 |
-
private static $instance;
|
11 |
-
private $when = array( 5, 15, 30 );
|
12 |
-
private $value;
|
13 |
-
private $messages;
|
14 |
-
private $link = 'https://wordpress.org/support/plugin/%s/reviews/#new-post';
|
15 |
-
private $slug = '';
|
16 |
-
private $option_name = '';
|
17 |
-
|
18 |
-
function __construct( $args ) {
|
19 |
-
|
20 |
-
if ( isset( $args['slug'] ) ) {
|
21 |
-
$this->slug = $args['slug'];
|
22 |
-
}
|
23 |
-
|
24 |
-
$this->value = $this->value();
|
25 |
-
|
26 |
-
$this->messages = array(
|
27 |
-
'notice' => __( "Hey, I noticed you're using Speed Booster Pack for %s day(s) - that's awesome! Could you please do me a BIG favor and give it a fair rating and a review on WordPress?", 'speed-booster-pack' ),
|
28 |
-
'rate' => __( 'Ok, you deserve it', 'speed-booster-pack' ),
|
29 |
-
'rated' => __( 'I already did', 'speed-booster-pack' ),
|
30 |
-
'no_rate' => __( 'No, not good enough', 'speed-booster-pack' ),
|
31 |
-
);
|
32 |
-
|
33 |
-
if ( isset( $args['messages'] ) ) {
|
34 |
-
$this->messages = wp_parse_args( $args['messages'], $this->messages );
|
35 |
-
}
|
36 |
-
|
37 |
-
$this->init();
|
38 |
-
|
39 |
-
}
|
40 |
-
|
41 |
-
public static function get_instance( $args ) {
|
42 |
-
if ( null === static::$instance ) {
|
43 |
-
static::$instance = new static( $args );
|
44 |
-
}
|
45 |
-
|
46 |
-
return static::$instance;
|
47 |
-
}
|
48 |
-
|
49 |
-
private function init() {
|
50 |
-
if ( ! is_admin() ) {
|
51 |
-
return;
|
52 |
-
}
|
53 |
-
|
54 |
-
add_action( 'wp_ajax_epsilon_review', array( $this, 'ajax' ) );
|
55 |
-
|
56 |
-
if ( $this->check() ) {
|
57 |
-
add_action( 'admin_notices', array( $this, 'five_star_wp_rate_notice' ) );
|
58 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
|
59 |
-
add_action( 'admin_print_footer_scripts', array( $this, 'ajax_script' ) );
|
60 |
-
}
|
61 |
-
|
62 |
-
}
|
63 |
-
|
64 |
-
private function check() {
|
65 |
-
|
66 |
-
$options = get_option( 'sbp_settings' );
|
67 |
-
$option = isset( $options['givemereview'] ) ? $options['givemereview'] : '';
|
68 |
-
$currDate = date( 'Y-m-d' );
|
69 |
-
if ( 'already-rated' == $option ) {
|
70 |
-
return false;
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( $this->value == $option ) {
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
-
if ( is_array( $this->when ) ) {
|
78 |
-
foreach ( $this->when as $et ) {
|
79 |
-
if ( date( 'Y-m-d', strtotime( $currDate . ' +' . $et . ' days' ) ) == $this->value ) {
|
80 |
-
return true;
|
81 |
-
}
|
82 |
-
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
}
|
87 |
-
|
88 |
-
private function value() {
|
89 |
-
|
90 |
-
$value = get_transient( 'sb_pack_review' );
|
91 |
-
|
92 |
-
if ( $value ) {
|
93 |
-
|
94 |
-
$current_time = time(); // or your date as well
|
95 |
-
$trans_date = strtotime($value);
|
96 |
-
$date_diff = $current_time - $trans_date;
|
97 |
-
|
98 |
-
return round($date_diff / (60 * 60 * 24));
|
99 |
-
}
|
100 |
-
|
101 |
-
$date = date( 'Y-m-d' );
|
102 |
-
set_transient( 'sb_pack_review', $date, 24 * 30 * HOUR_IN_SECONDS );
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
public function five_star_wp_rate_notice() {
|
107 |
-
|
108 |
-
$url = sprintf( $this->link, $this->slug );
|
109 |
-
|
110 |
-
?>
|
111 |
-
<div id="<?php echo $this->slug ?>-epsilon-review-notice" class="notice notice-success is-dismissible">
|
112 |
-
<p><?php echo sprintf( wp_kses_post( $this->messages['notice'] ), $this->value ); ?></p>
|
113 |
-
<p class="actions">
|
114 |
-
<a id="epsilon-rate" href="<?php echo esc_url( $url ) ?>"
|
115 |
-
class="button button-primary epsilon-review-button"><?php echo esc_html( $this->messages['rate'] ); ?></a>
|
116 |
-
<a id="epsilon-rated" href="#"
|
117 |
-
class="button button-secondary epsilon-review-button"><?php echo esc_html( $this->messages['rated'] ); ?></a>
|
118 |
-
<a id="epsilon-no-rate" href="#"
|
119 |
-
class="button button-secondary epsilon-review-button"><?php echo esc_html( $this->messages['no_rate'] ); ?></a>
|
120 |
-
</p>
|
121 |
-
</div>
|
122 |
-
<?php
|
123 |
-
}
|
124 |
-
|
125 |
-
public function ajax() {
|
126 |
-
|
127 |
-
check_ajax_referer( 'epsilon-review', 'security' );
|
128 |
-
|
129 |
-
$options = get_option( 'sbp_settings', array() );
|
130 |
-
|
131 |
-
if ( isset( $_POST['epsilon-review'] ) ) {
|
132 |
-
$options['givemereview'] = 'already-rated';
|
133 |
-
} else {
|
134 |
-
$options['givemereview'] = $this->value;
|
135 |
-
}
|
136 |
-
|
137 |
-
update_option( 'sbp_settings', $options );
|
138 |
-
|
139 |
-
wp_die( 'ok' );
|
140 |
-
|
141 |
-
}
|
142 |
-
|
143 |
-
public function enqueue() {
|
144 |
-
wp_enqueue_script( 'jquery' );
|
145 |
-
}
|
146 |
-
|
147 |
-
public function ajax_script() {
|
148 |
-
|
149 |
-
$ajax_nonce = wp_create_nonce( "epsilon-review" );
|
150 |
-
|
151 |
-
?>
|
152 |
-
|
153 |
-
<script type="text/javascript">
|
154 |
-
jQuery(document).ready(function ($) {
|
155 |
-
|
156 |
-
$('.epsilon-review-button').click(function (evt) {
|
157 |
-
var href = $(this).attr('href'),
|
158 |
-
id = $(this).attr('id');
|
159 |
-
|
160 |
-
evt.preventDefault();
|
161 |
-
|
162 |
-
var data = {
|
163 |
-
action: 'epsilon_review',
|
164 |
-
security: '<?php echo $ajax_nonce; ?>',
|
165 |
-
};
|
166 |
-
|
167 |
-
if ('epsilon-rated' === id) {
|
168 |
-
data['epsilon-review'] = 1;
|
169 |
-
}
|
170 |
-
|
171 |
-
$.post('<?php echo admin_url( 'admin-ajax.php' ) ?>', data, function (response) {
|
172 |
-
$('#<?php echo $this->slug ?>-epsilon-review-notice').slideUp('fast', function () {
|
173 |
-
$(this).remove();
|
174 |
-
});
|
175 |
-
|
176 |
-
if ('epsilon-rate' === id) {
|
177 |
-
window.location.href = href;
|
178 |
-
}
|
179 |
-
|
180 |
-
});
|
181 |
-
|
182 |
-
});
|
183 |
-
|
184 |
-
});
|
185 |
-
</script>
|
186 |
-
|
187 |
-
<?php
|
188 |
-
}
|
189 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inc/core.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
8 |
/*--------------------------------------------------------------------------------------------------------
|
9 |
-
|
10 |
---------------------------------------------------------------------------------------------------------*/
|
11 |
|
12 |
if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
@@ -16,127 +16,167 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
16 |
private $remote_ga_script = 'https://www.google-analytics.com/analytics.js';
|
17 |
private $local_ga_script;
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
public function __construct() {
|
|
|
|
|
|
|
20 |
|
21 |
-
global $sbp_options;
|
22 |
|
23 |
$this->local_ga_script = $this->local_cache_dir . 'speed-booster/analytics.js';
|
24 |
|
25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
-
|
28 |
-
|
|
|
29 |
}
|
30 |
|
31 |
-
add_action( 'after_setup_theme',
|
32 |
-
add_action( 'init',
|
33 |
|
34 |
//enable cdn rewrite
|
35 |
-
if( isset( $sbp_options[
|
36 |
-
add_action( 'template_redirect',
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
//enable lazy loading
|
40 |
-
if( isset( $sbp_options[
|
41 |
-
add_action( 'template_redirect',
|
42 |
-
add_action( 'wp_enqueue_scripts',
|
43 |
-
add_action( 'enqueue_embed_scripts',
|
44 |
}
|
45 |
|
46 |
// WooCommerce optimizing features
|
47 |
-
if( $this->sbp_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
48 |
/**
|
49 |
* @since 3.8.3
|
50 |
*/
|
51 |
-
if( isset( $sbp_options[
|
52 |
-
add_action( 'wp_enqueue_scripts',
|
53 |
}
|
54 |
|
55 |
/**
|
56 |
* @since 3.8
|
57 |
*/
|
58 |
// Disable Cart Fragments
|
59 |
-
if( isset( $sbp_options[
|
60 |
-
add_action( 'wp_enqueue_scripts',
|
61 |
}
|
62 |
|
63 |
/**
|
64 |
* Disable password strength meter
|
65 |
* @since 3.8.3
|
66 |
*/
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
|
72 |
// Start GA
|
73 |
-
if( isset( $sbp_options[
|
74 |
|
75 |
-
if( !wp_next_scheduled( 'sbp_update_ga' ) ) {
|
76 |
wp_schedule_event( time(), 'daily', 'sbp_update_ga' );
|
77 |
}
|
78 |
|
79 |
-
if( isset( $sbp_options[
|
80 |
-
add_filter( 'monsterinsights_frontend_output_analytics_src',
|
81 |
-
|
82 |
-
|
|
|
83 |
|
84 |
-
if( isset( $sbp_options[
|
85 |
$tracking_code_position = 'wp_footer';
|
86 |
-
}
|
87 |
-
else {
|
88 |
$tracking_code_position = 'wp_head';
|
89 |
}
|
90 |
-
add_action( $tracking_code_position,
|
91 |
}
|
92 |
-
}
|
93 |
-
else {
|
94 |
|
95 |
-
if( wp_next_scheduled( 'sbp_update_ga' ) ) {
|
96 |
wp_clear_scheduled_hook( 'sbp_update_ga' );
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
// End GA
|
102 |
|
103 |
$this->sbp_css_optimizer(); // CSS Optimizer functions
|
104 |
|
105 |
// Minifier
|
106 |
-
if ( ! is_admin() and isset( $sbp_options[
|
107 |
$this->sbp_minifier();
|
108 |
}
|
109 |
|
110 |
-
//
|
111 |
if ( ! is_admin() and isset( $sbp_options['defer_parsing'] ) ) {
|
112 |
-
add_filter( 'script_loader_tag',
|
113 |
}
|
114 |
|
115 |
-
//
|
116 |
-
if ( ! is_admin() and isset( $sbp_options[
|
117 |
-
add_filter( 'script_loader_src',
|
118 |
-
add_filter( 'style_loader_src',
|
119 |
}
|
120 |
|
121 |
/**
|
122 |
* @since 3.7
|
123 |
*/
|
124 |
// Disable emojis
|
125 |
-
if ( ! is_admin() && isset( $sbp_options[
|
126 |
-
add_action( 'init',
|
127 |
}
|
128 |
|
129 |
/**
|
130 |
* @since 3.8
|
131 |
*/
|
132 |
// Enable Instant Page
|
133 |
-
if( isset( $sbp_options[
|
134 |
-
add_action( 'wp_enqueue_scripts',
|
135 |
}
|
136 |
|
137 |
// Disable Self Pingbacks
|
138 |
if ( isset( $sbp_options['disable_self_pingbacks'] ) ) {
|
139 |
-
add_action( 'pre_ping',
|
140 |
}
|
141 |
|
142 |
// Remove REST API Links
|
@@ -146,19 +186,19 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
146 |
|
147 |
//Disable Dash icons
|
148 |
if ( isset( $sbp_options['disable_dashicons'] ) ) {
|
149 |
-
add_action( 'wp_enqueue_scripts',
|
150 |
}
|
151 |
|
152 |
if ( isset( $sbp_options['disable_google_maps'] ) ) {
|
153 |
-
add_action( 'wp_loaded',
|
154 |
}
|
155 |
|
156 |
-
if (
|
157 |
-
add_action( 'init',
|
158 |
}
|
159 |
|
160 |
if ( ! empty( $sbp_options['heartbeat_frequency'] ) ) {
|
161 |
-
add_filter( 'heartbeat_settings',
|
162 |
}
|
163 |
|
164 |
if ( ! empty( $sbp_options['limit_post_revisions'] ) && ! defined( 'WP_POST_REVISIONS' ) ) {
|
@@ -172,12 +212,52 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
172 |
/**
|
173 |
* @since 3.8.1
|
174 |
*/
|
175 |
-
if( ! empty( $sbp_options[
|
176 |
-
add_action( 'wp_default_scripts',
|
177 |
}
|
178 |
-
|
179 |
} // END public public function __construct
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
/**
|
182 |
* Check if a plugin is active or not.
|
183 |
* @since 3.8.3
|
@@ -217,21 +297,21 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
217 |
* @since 3.8.1
|
218 |
*/
|
219 |
/*--------------------------------------------------------------------------------------------------------
|
220 |
-
|
221 |
-
|
222 |
function sbp_remove_jquery_migrate( $scripts ) {
|
223 |
-
if ( ! is_admin() && isset( $scripts->registered[
|
224 |
-
$jquery_script = $scripts->registered[
|
225 |
|
226 |
if ( $jquery_script->deps ) { // Check whether the script has any dependencies
|
227 |
-
$jquery_script->deps = array_diff( $jquery_script->deps,
|
228 |
}
|
229 |
}
|
230 |
}
|
231 |
|
232 |
/*--------------------------------------------------------------------------------------------------------
|
233 |
-
|
234 |
-
|
235 |
function sbp_disable_dash_icons() {
|
236 |
if ( ! is_user_logged_in() ) {
|
237 |
wp_dequeue_style( 'dashicons' );
|
@@ -240,16 +320,16 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
240 |
}
|
241 |
|
242 |
/*--------------------------------------------------------------------------------------------------------
|
243 |
-
|
244 |
-
|
245 |
|
246 |
function sbp_disable_heartbeat() {
|
247 |
wp_deregister_script( 'heartbeat' );
|
248 |
}
|
249 |
|
250 |
/*--------------------------------------------------------------------------------------------------------
|
251 |
-
|
252 |
-
|
253 |
|
254 |
function sbp_heartbeat_frequency() {
|
255 |
global $sbp_options;
|
@@ -259,22 +339,24 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
259 |
}
|
260 |
|
261 |
/*--------------------------------------------------------------------------------------------------------
|
262 |
-
|
263 |
-
|
264 |
|
265 |
function sbp_disable_google_maps() {
|
266 |
-
ob_start(
|
267 |
}
|
268 |
|
269 |
function sbp_disable_google_maps_regex( $html ) {
|
270 |
-
$html = preg_replace( '/<script[^<>]*\/\/maps.(googleapis|google|gstatic).com\/[^<>]*><\/script>/i',
|
|
|
|
|
271 |
|
272 |
return $html;
|
273 |
}
|
274 |
|
275 |
/*--------------------------------------------------------------------------------------------------------
|
276 |
-
|
277 |
-
|
278 |
|
279 |
function sbp_disable_password_strength_meter() {
|
280 |
global $wp;
|
@@ -299,25 +381,24 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
299 |
}
|
300 |
|
301 |
/*--------------------------------------------------------------------------------------------------------
|
302 |
-
|
303 |
-
|
304 |
|
305 |
function sbp_init() {
|
306 |
|
307 |
global $sbp_options;
|
308 |
|
309 |
if ( ! is_admin() and isset( $sbp_options['sbp_css_async'] ) ) {
|
310 |
-
add_action( 'wp_print_styles',
|
311 |
-
add_action( 'wp_footer',
|
312 |
}
|
313 |
|
314 |
}
|
315 |
|
316 |
|
317 |
-
|
318 |
/*--------------------------------------------------------------------------------------------------------
|
319 |
-
|
320 |
-
|
321 |
|
322 |
function sbp_print_styles() {
|
323 |
global $sbp_styles_are_async;
|
@@ -336,7 +417,7 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
336 |
|
337 |
if ( ! isset( $sbp_options['sbp_footer_css'] ) ) {
|
338 |
|
339 |
-
$not_inlined =
|
340 |
|
341 |
foreach ( $sbp_styles as $style ) {
|
342 |
echo "<style type=\"text/css\" " . ( $style['media'] ? "media=\"{$style['media']}\"" : '' ) . ">";
|
@@ -348,8 +429,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
348 |
if ( ! empty( $not_inlined ) ) {
|
349 |
foreach ( $not_inlined as $style ) {
|
350 |
?>
|
351 |
-
|
352 |
-
|
353 |
}
|
354 |
}
|
355 |
}
|
@@ -359,8 +440,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
359 |
|
360 |
|
361 |
/*--------------------------------------------------------------------------------------------------------
|
362 |
-
|
363 |
-
|
364 |
|
365 |
function sbp_print_delayed_styles() {
|
366 |
global $sbp_styles;
|
@@ -374,7 +455,7 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
374 |
|
375 |
if ( isset( $sbp_options['sbp_footer_css'] ) ) {
|
376 |
|
377 |
-
$not_inlined =
|
378 |
foreach ( $sbp_styles as $style ) {
|
379 |
echo "<style type=\"text/css\" " . ( $style['media'] ? "media=\"{$style['media']}\"" : '' ) . ">";
|
380 |
if ( ! sbp_inline_css( $style['src'], $minify ) ) {
|
@@ -385,8 +466,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
385 |
if ( ! empty( $not_inlined ) ) {
|
386 |
foreach ( $not_inlined as $style ) {
|
387 |
?>
|
388 |
-
|
389 |
-
|
390 |
}
|
391 |
}
|
392 |
}
|
@@ -394,10 +475,10 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
394 |
|
395 |
|
396 |
/*--------------------------------------------------------------------------------------------------------
|
397 |
-
|
398 |
-
|
399 |
|
400 |
-
function
|
401 |
|
402 |
global $sbp_options;
|
403 |
|
@@ -409,13 +490,83 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
409 |
|
410 |
}
|
411 |
|
412 |
-
}
|
413 |
|
414 |
-
|
415 |
-
|
416 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
|
418 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
|
420 |
/**
|
421 |
* Default: add jQuery to header always
|
@@ -455,8 +606,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
455 |
*
|
456 |
* New solution, going forward so not to crash so many sites anymore
|
457 |
*
|
458 |
-
*
|
459 |
-
*
|
460 |
*
|
461 |
*/
|
462 |
if ( $js_footer_exceptions1 !== 'jquery-core' || $js_footer_exceptions2 !== 'jquery-core' || $js_footer_exceptions3 !== 'jquery-core' || $js_footer_exceptions4 !== 'jquery-core' ) {
|
@@ -464,7 +615,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
464 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
465 |
$script_src = $wp_scripts->registered['jquery-core']->src;
|
466 |
|
467 |
-
if ( strpos( $script_src,
|
|
|
468 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
469 |
} else {
|
470 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
@@ -473,7 +625,7 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
473 |
// deregister & dequeue the script
|
474 |
//wp_deregister_script( 'jquery-core' );
|
475 |
//wp_dequeue_script( 'jquery-core' );
|
476 |
-
$wp_scripts->registered[
|
477 |
}
|
478 |
|
479 |
|
@@ -490,7 +642,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
490 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
491 |
$script_src = $wp_scripts->registered[ $js_footer_exceptions1 ]->src;
|
492 |
|
493 |
-
if ( strpos( $script_src,
|
|
|
494 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
495 |
} else {
|
496 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
@@ -527,7 +680,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
527 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
528 |
$script_src = $wp_scripts->registered[ $js_footer_exceptions4 ]->src;
|
529 |
|
530 |
-
if ( strpos( $script_src,
|
|
|
531 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
532 |
} else {
|
533 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
@@ -582,28 +736,28 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
582 |
|
583 |
|
584 |
/*--------------------------------------------------------------------------------------------------------
|
585 |
-
|
586 |
-
|
587 |
|
588 |
function sbp_minifier() {
|
589 |
|
590 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/sbp-minifier.php' );
|
591 |
-
}
|
592 |
|
593 |
|
594 |
/*--------------------------------------------------------------------------------------------------------
|
595 |
-
|
596 |
-
|
597 |
|
598 |
function sbp_css_optimizer() {
|
599 |
|
600 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/css-optimizer.php' );
|
601 |
|
602 |
-
}
|
603 |
|
604 |
/*--------------------------------------------------------------------------------------------------------
|
605 |
-
|
606 |
-
|
607 |
|
608 |
function sbp_defer_parsing_of_js( $tag, $handle, $src ) {
|
609 |
|
@@ -633,7 +787,8 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
633 |
$array_with_values[] = $defer_exclude3;
|
634 |
$array_with_values[] = $defer_exclude4;
|
635 |
|
636 |
-
$array_with_values = apply_filters( 'sbp_exclude_defer_scripts',
|
|
|
637 |
$array_with_values = array_filter( $array_with_values ); // remove empty entries
|
638 |
|
639 |
|
@@ -643,14 +798,14 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
643 |
|
644 |
return $tag;
|
645 |
|
646 |
-
}
|
647 |
|
648 |
|
649 |
/*--------------------------------------------------------------------------------------------------------
|
650 |
-
|
651 |
-
|
652 |
|
653 |
-
function sbp_remove_query_strings( $src ) {
|
654 |
|
655 |
$output = preg_split( "/(\?rev|&ver|\?ver)/", $src );
|
656 |
|
@@ -659,41 +814,42 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
659 |
}
|
660 |
|
661 |
/*--------------------------------------------------------------------------------------------------------
|
662 |
-
|
663 |
-
|
664 |
function sbp_disable_emojis() {
|
665 |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
|
666 |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
|
|
|
667 |
remove_action( 'wp_print_styles', 'print_emoji_styles' );
|
668 |
remove_action( 'admin_print_styles', 'print_emoji_styles' );
|
669 |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
|
670 |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
|
671 |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
|
672 |
|
673 |
-
add_filter( 'tiny_mce_plugins',
|
674 |
-
add_filter( 'wp_resource_hints',
|
675 |
}
|
676 |
|
677 |
function sbp_disable_emojis_tinymce( $plugins ) {
|
678 |
if ( is_array( $plugins ) ) {
|
679 |
-
return array_diff( $plugins,
|
680 |
} else {
|
681 |
-
return
|
682 |
}
|
683 |
}
|
684 |
|
685 |
function sbp_disable_emojis_dns_prefetch( $urls, $relation_type ) {
|
686 |
if ( 'dns-prefetch' == $relation_type ) {
|
687 |
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' );
|
688 |
-
$urls
|
689 |
}
|
690 |
|
691 |
return $urls;
|
692 |
}
|
693 |
|
694 |
/*--------------------------------------------------------------------------------------------------------
|
695 |
-
|
696 |
-
|
697 |
|
698 |
function sbp_remove_self_ping( &$links ) {
|
699 |
|
@@ -707,69 +863,69 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
707 |
}
|
708 |
|
709 |
/*--------------------------------------------------------------------------------------------------------
|
710 |
-
|
711 |
-
|
712 |
|
713 |
function sbp_disable_cart_fragments() {
|
714 |
global $wp_scripts;
|
715 |
|
716 |
$handle = 'wc-cart-fragments';
|
717 |
|
718 |
-
$load_cart_fragments_path
|
719 |
$wp_scripts->registered[ $handle ]->src = null;
|
720 |
wp_add_inline_script(
|
721 |
'woocommerce',
|
722 |
'
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
);
|
749 |
}
|
750 |
|
751 |
/*--------------------------------------------------------------------------------------------------------
|
752 |
-
|
753 |
-
|
754 |
|
755 |
function sbp_enable_instant_page() {
|
756 |
wp_enqueue_script( 'sbp-ins-page', plugins_url( 'js/inspage.js', __FILE__ ), false, '2.0.0', true );
|
757 |
}
|
758 |
|
759 |
/*--------------------------------------------------------------------------------------------------------
|
760 |
-
|
761 |
-
|
762 |
|
763 |
public function sbp_junk_header_tags() {
|
764 |
|
765 |
global $sbp_options;
|
766 |
|
767 |
-
//
|
768 |
if ( isset( $sbp_options['remove_adjacent'] ) ) {
|
769 |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
|
770 |
}
|
771 |
|
772 |
-
//
|
773 |
if ( isset( $sbp_options['wml_link'] ) ) {
|
774 |
remove_action( 'wp_head', 'wlwmanifest_link' );
|
775 |
}
|
@@ -779,121 +935,200 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
779 |
remove_action( 'wp_head', 'rsd_link' );
|
780 |
}
|
781 |
|
782 |
-
//
|
783 |
if ( isset( $sbp_options['remove_wsl'] ) ) {
|
784 |
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
|
785 |
}
|
786 |
|
787 |
-
//
|
788 |
if ( isset( $sbp_options['wp_generator'] ) ) {
|
789 |
remove_action( 'wp_head', 'wp_generator' );
|
790 |
}
|
791 |
|
792 |
-
//
|
793 |
if ( isset( $sbp_options['remove_all_feeds'] ) ) {
|
794 |
-
remove_action( 'wp_head',
|
795 |
-
|
|
|
|
|
|
|
|
|
796 |
}
|
797 |
|
798 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
799 |
|
800 |
|
801 |
/*--------------------------------
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
function sbp_lazy_load_script() {
|
806 |
-
wp_enqueue_script( 'sbp-lazy-load', plugins_url( 'js/lazyload.js', __FILE__ ), false, '12.
|
807 |
-
wp_add_inline_script( 'sbp-lazy-load',
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
|
|
817 |
function sbp_lazy_load() {
|
818 |
-
ob_start(
|
819 |
}
|
820 |
|
821 |
function sbp_lazy_loader( $html ) {
|
822 |
$placeholder = 'data:image/svg+xml,%3Csvg%20xmlns%3D%27http://www.w3.org/2000/svg%27%20viewBox%3D%270%200%203%202%27%3E%3C/svg%3E';
|
823 |
-
$html
|
824 |
-
|
825 |
-
|
|
|
|
|
|
|
|
|
|
|
826 |
return $html;
|
827 |
}
|
828 |
|
829 |
|
830 |
/*--------------------------------
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
function sbp_cdn_rewrite() {
|
835 |
-
|
836 |
}
|
837 |
|
838 |
-
function sbp_cdn_rewriter($html) {
|
839 |
global $sbp_options;
|
840 |
$sbp_cdn_directories = $sbp_options['sbp_cdn_included_directories'];
|
841 |
|
842 |
//Prep Site URL
|
843 |
-
$escapedSiteURL = quotemeta(get_option('home'));
|
844 |
-
$regExURL
|
845 |
|
846 |
//Prep Included Directories
|
847 |
$directories = 'wp\-content|wp\-includes';
|
848 |
-
if(!empty($sbp_cdn_directories)) {
|
849 |
-
$directoriesArray = array_map('trim', explode(',', $sbp_cdn_directories));
|
850 |
-
if(count($directoriesArray) > 0) {
|
851 |
-
$directories = implode('|', array_map('quotemeta', array_filter($directoriesArray)));
|
852 |
}
|
853 |
}
|
854 |
|
855 |
//Rewrite URLs + Return
|
856 |
-
$regEx
|
857 |
-
$cdnHTML = preg_replace_callback($regEx,
|
|
|
858 |
return $cdnHTML;
|
859 |
}
|
860 |
|
861 |
-
function sbp_cdn_rewrite_url($url) {
|
862 |
global $sbp_options;
|
863 |
-
$sbp_cdn_url
|
864 |
$sbp_cdn_excluded = $sbp_options['sbp_cdn_exclusions'];
|
865 |
|
866 |
//Make Sure CDN URL is Set
|
867 |
-
if(!empty($sbp_cdn_url)) {
|
868 |
|
869 |
//Don't Rewrite if Excluded
|
870 |
-
if(!empty($sbp_cdn_excluded)) {
|
871 |
-
$exclusions = array_map('trim', explode(',', $sbp_cdn_excluded));
|
872 |
-
foreach($exclusions as $exclusion) {
|
873 |
-
if(!empty($exclusion) && stristr($url[0], $exclusion) != false) {
|
874 |
return $url[0];
|
875 |
}
|
876 |
}
|
877 |
}
|
878 |
|
879 |
//Don't Rewrite if Previewing
|
880 |
-
if(is_admin_bar_showing() && isset($_GET['preview']) && $_GET['preview'] == 'true') {
|
881 |
return $url[0];
|
882 |
}
|
883 |
|
884 |
//Prep Site URL
|
885 |
-
$siteURL = get_option('home');
|
886 |
-
$siteURL = substr($siteURL, strpos($siteURL, '//'));
|
887 |
|
888 |
//Replace URL w/ No HTTP/S Prefix
|
889 |
-
if(strpos($url[0], '//') === 0) {
|
890 |
-
return str_replace($siteURL, $sbp_cdn_url, $url[0]);
|
891 |
}
|
892 |
|
893 |
//Found Site URL, Replace Non Relative URL w/ HTTP/S Prefix
|
894 |
-
if(strstr($url[0], $siteURL)) {
|
895 |
-
return str_replace(
|
896 |
}
|
|
|
897 |
//Replace Relative URL
|
898 |
return $sbp_cdn_url . $url[0];
|
899 |
}
|
@@ -903,34 +1138,38 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
903 |
}
|
904 |
|
905 |
/*--------------------------------------------
|
906 |
-
|
907 |
-
|
908 |
|
909 |
function sbp_file_process() {
|
910 |
global $wp_filesystem;
|
911 |
|
912 |
-
require_once
|
913 |
WP_Filesystem();
|
914 |
|
915 |
return $wp_filesystem;
|
916 |
}
|
917 |
|
918 |
/*--------------------------------------------
|
919 |
-
|
920 |
-
|
921 |
|
922 |
//update analytics.js
|
923 |
function sbp_update_ga() {
|
924 |
-
$wp_filesystem
|
925 |
|
926 |
-
if(
|
927 |
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir, FS_CHMOD_DIR );
|
928 |
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir . 'speed-booster/', FS_CHMOD_DIR );
|
929 |
}
|
930 |
|
931 |
$file_content = $wp_filesystem->get_contents( $this->remote_ga_script );
|
932 |
|
933 |
-
if( $wp_filesystem->put_contents( WP_CONTENT_DIR . $this->local_ga_script,
|
|
|
|
|
|
|
|
|
934 |
|
935 |
return false;
|
936 |
}
|
@@ -941,17 +1180,17 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
941 |
global $sbp_options;
|
942 |
|
943 |
//dont print for logged in admins
|
944 |
-
if( current_user_can( 'manage_options' ) && empty( $sbp_options[
|
945 |
return;
|
946 |
}
|
947 |
|
948 |
-
if( isset( $sbp_options[
|
949 |
-
$wp_filesystem
|
950 |
-
$ga_script
|
951 |
|
952 |
-
if(
|
953 |
|
954 |
-
if(
|
955 |
$ga_script = $this->remote_ga_script;
|
956 |
}
|
957 |
}
|
@@ -959,23 +1198,23 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
959 |
echo "\n\n<!-- Local Analytics generated with Speed Booster Pack by Optimocha. -->\n";
|
960 |
echo "<script>\n";
|
961 |
echo "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','" . $ga_script . "','ga');\n";
|
962 |
-
echo "ga('create', '" . $sbp_options[
|
963 |
|
964 |
//disable display features
|
965 |
-
if( !empty( $sbp_options[
|
966 |
echo "ga('set', 'allowAdFeatures', false);\n";
|
967 |
}
|
968 |
|
969 |
//anonymize ip
|
970 |
-
if( !empty( $sbp_options[
|
971 |
echo "ga('set', 'anonymizeIp', true);\n";
|
972 |
}
|
973 |
|
974 |
echo "ga('send', 'pageview');\n";
|
975 |
|
976 |
//adjusted bounce rate
|
977 |
-
if( !empty( $sbp_options[
|
978 |
-
echo 'setTimeout("ga(' . "'send','event','adjusted bounce rate','" . $sbp_options[
|
979 |
}
|
980 |
|
981 |
echo "</script>\n";
|
@@ -983,5 +1222,5 @@ if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
|
983 |
}
|
984 |
}
|
985 |
|
986 |
-
}
|
987 |
-
}
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
8 |
/*--------------------------------------------------------------------------------------------------------
|
9 |
+
Plugin Core Functions
|
10 |
---------------------------------------------------------------------------------------------------------*/
|
11 |
|
12 |
if ( ! class_exists( 'Speed_Booster_Pack_Core' ) ) {
|
16 |
private $remote_ga_script = 'https://www.google-analytics.com/analytics.js';
|
17 |
private $local_ga_script;
|
18 |
|
19 |
+
const SCRIPT_TYPES = [
|
20 |
+
"application/ecmascript",
|
21 |
+
"application/javascript",
|
22 |
+
"application/x-ecmascript",
|
23 |
+
"application/x-javascript",
|
24 |
+
"text/ecmascript",
|
25 |
+
"text/javascript",
|
26 |
+
"text/javascript1.0",
|
27 |
+
"text/javascript1.1",
|
28 |
+
"text/javascript1.2",
|
29 |
+
"text/javascript1.3",
|
30 |
+
"text/javascript1.4",
|
31 |
+
"text/javascript1.5",
|
32 |
+
"text/jscript",
|
33 |
+
"text/livescript",
|
34 |
+
"text/x-ecmascript",
|
35 |
+
"text/x-javascript",
|
36 |
+
];
|
37 |
+
|
38 |
public function __construct() {
|
39 |
+
if ( $this->should_run() !== true ) {
|
40 |
+
return;
|
41 |
+
}
|
42 |
|
43 |
+
global $sbp_options, $sbp_cache;
|
44 |
|
45 |
$this->local_ga_script = $this->local_cache_dir . 'speed-booster/analytics.js';
|
46 |
|
47 |
+
$is_using_new_js_mover = ! ( get_option( 'sbp_js_footer_exceptions1' ) || get_option( 'sbp_js_footer_exceptions2' ) || get_option( 'sbp_js_footer_exceptions3' ) || get_option( 'sbp_js_footer_exceptions4' ) );
|
48 |
+
if ( $is_using_new_js_mover ) {
|
49 |
+
if ( isset( $sbp_options['jquery_to_footer'] ) ) {
|
50 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_move_scripts_to_footer' ] );
|
51 |
+
}
|
52 |
+
} else {
|
53 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_move_scripts_to_footer_deprecated' ] );
|
54 |
|
55 |
+
if ( ! is_admin() and isset( $sbp_options['jquery_to_footer'] ) ) {
|
56 |
+
add_action( 'wp_head', [ $this, 'sbp_scripts_to_head_deprecated' ] );
|
57 |
+
}
|
58 |
}
|
59 |
|
60 |
+
add_action( 'after_setup_theme', [ $this, 'sbp_junk_header_tags' ] );
|
61 |
+
add_action( 'init', [ $this, 'sbp_init' ] );
|
62 |
|
63 |
//enable cdn rewrite
|
64 |
+
if ( isset( $sbp_options['sbp_enable_cdn'] ) && $sbp_options['sbp_enable_cdn'] == "1" && isset( $sbp_options['sbp_cdn_url'] ) ) {
|
65 |
+
add_action( 'template_redirect', [ $this, 'sbp_cdn_rewrite' ] );
|
66 |
+
}
|
67 |
+
|
68 |
+
//enable Google fonts optimization
|
69 |
+
if ( isset( $sbp_options['sbp_optimize_fonts'] ) ) {
|
70 |
+
add_action( 'template_redirect', [ $this, 'sbp_optimize_fonts' ] );
|
71 |
}
|
72 |
|
73 |
//enable lazy loading
|
74 |
+
if ( isset( $sbp_options['sbp_enable_lazy_load'] ) ) {
|
75 |
+
add_action( 'template_redirect', [ $this, 'sbp_lazy_load' ] );
|
76 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_lazy_load_script' ] );
|
77 |
+
add_action( 'enqueue_embed_scripts', [ $this, 'sbp_lazy_load_script' ] );
|
78 |
}
|
79 |
|
80 |
// WooCommerce optimizing features
|
81 |
+
if ( $this->sbp_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
82 |
/**
|
83 |
* @since 3.8.3
|
84 |
*/
|
85 |
+
if ( isset( $sbp_options['dequeue_wc_scripts'] ) ) {
|
86 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_dequeue_wc_scripts' ] );
|
87 |
}
|
88 |
|
89 |
/**
|
90 |
* @since 3.8
|
91 |
*/
|
92 |
// Disable Cart Fragments
|
93 |
+
if ( isset( $sbp_options['disable_cart_fragments'] ) ) {
|
94 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_disable_cart_fragments' ], 999 );
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
* Disable password strength meter
|
99 |
* @since 3.8.3
|
100 |
*/
|
101 |
+
if ( isset( $sbp_options['disable_password_strength_meter'] ) ) {
|
102 |
+
add_action( 'wp_print_scripts', [ $this, 'sbp_disable_password_strength_meter' ], 100 );
|
103 |
+
}
|
104 |
}
|
105 |
|
106 |
// Start GA
|
107 |
+
if ( isset( $sbp_options['sbp_enable_local_analytics'] ) && $sbp_options['sbp_enable_local_analytics'] == "1" ) {
|
108 |
|
109 |
+
if ( ! wp_next_scheduled( 'sbp_update_ga' ) ) {
|
110 |
wp_schedule_event( time(), 'daily', 'sbp_update_ga' );
|
111 |
}
|
112 |
|
113 |
+
if ( isset( $sbp_options['sbp_monsterinsights'] ) && $sbp_options['sbp_monsterinsights'] == "1" ) {
|
114 |
+
add_filter( 'monsterinsights_frontend_output_analytics_src',
|
115 |
+
WP_CONTENT_URL . $this->local_ga_script,
|
116 |
+
1000 );
|
117 |
+
} else {
|
118 |
|
119 |
+
if ( isset( $sbp_options['sbp_tracking_position'] ) && $sbp_options['sbp_tracking_position'] == 'footer' ) {
|
120 |
$tracking_code_position = 'wp_footer';
|
121 |
+
} else {
|
|
|
122 |
$tracking_code_position = 'wp_head';
|
123 |
}
|
124 |
+
add_action( $tracking_code_position, [ $this, 'sbp_print_ga' ], 0 );
|
125 |
}
|
126 |
+
} else {
|
|
|
127 |
|
128 |
+
if ( wp_next_scheduled( 'sbp_update_ga' ) ) {
|
129 |
wp_clear_scheduled_hook( 'sbp_update_ga' );
|
130 |
}
|
131 |
}
|
132 |
|
133 |
+
// Enable Cache
|
134 |
+
// if (isset($sbp_options['sbp_html_cache']) && $sbp_options['sbp_html_cache'] == "1") {
|
135 |
+
// add_action('init', function () use ($sbp_cache) {
|
136 |
+
// $sbp_cache->sbp_enable_cache();
|
137 |
+
// });
|
138 |
+
// }
|
139 |
+
|
140 |
+
add_action( 'sbp_update_ga', [ $this, 'sbp_update_ga' ] );
|
141 |
// End GA
|
142 |
|
143 |
$this->sbp_css_optimizer(); // CSS Optimizer functions
|
144 |
|
145 |
// Minifier
|
146 |
+
if ( ! is_admin() and isset( $sbp_options['minify_html_js'] ) ) {
|
147 |
$this->sbp_minifier();
|
148 |
}
|
149 |
|
150 |
+
// Defer parsing of JavaScript
|
151 |
if ( ! is_admin() and isset( $sbp_options['defer_parsing'] ) ) {
|
152 |
+
add_filter( 'script_loader_tag', [ $this, 'sbp_defer_parsing_of_js' ], 10, 3 );
|
153 |
}
|
154 |
|
155 |
+
// Remove query strings from static resources
|
156 |
+
if ( ! is_admin() and isset( $sbp_options['query_strings'] ) ) {
|
157 |
+
add_filter( 'script_loader_src', [ $this, 'sbp_remove_query_strings' ], 15, 1 );
|
158 |
+
add_filter( 'style_loader_src', [ $this, 'sbp_remove_query_strings' ], 15, 1 );
|
159 |
}
|
160 |
|
161 |
/**
|
162 |
* @since 3.7
|
163 |
*/
|
164 |
// Disable emojis
|
165 |
+
if ( ! is_admin() && isset( $sbp_options['remove_emojis'] ) ) {
|
166 |
+
add_action( 'init', [ $this, 'sbp_disable_emojis' ] );
|
167 |
}
|
168 |
|
169 |
/**
|
170 |
* @since 3.8
|
171 |
*/
|
172 |
// Enable Instant Page
|
173 |
+
if ( isset( $sbp_options['enable_instant_page'] ) ) {
|
174 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_enable_instant_page' ] );
|
175 |
}
|
176 |
|
177 |
// Disable Self Pingbacks
|
178 |
if ( isset( $sbp_options['disable_self_pingbacks'] ) ) {
|
179 |
+
add_action( 'pre_ping', [ $this, 'sbp_remove_self_ping' ] );
|
180 |
}
|
181 |
|
182 |
// Remove REST API Links
|
186 |
|
187 |
//Disable Dash icons
|
188 |
if ( isset( $sbp_options['disable_dashicons'] ) ) {
|
189 |
+
add_action( 'wp_enqueue_scripts', [ $this, 'sbp_disable_dash_icons' ] );
|
190 |
}
|
191 |
|
192 |
if ( isset( $sbp_options['disable_google_maps'] ) ) {
|
193 |
+
add_action( 'wp_loaded', [ $this, 'sbp_disable_google_maps' ] );
|
194 |
}
|
195 |
|
196 |
+
if ( isset( $sbp_options['disable_heartbeat'] ) ) {
|
197 |
+
add_action( 'init', [ $this, 'sbp_disable_heartbeat' ], 1 );
|
198 |
}
|
199 |
|
200 |
if ( ! empty( $sbp_options['heartbeat_frequency'] ) ) {
|
201 |
+
add_filter( 'heartbeat_settings', [ $this, 'sbp_heartbeat_frequency' ], 1 );
|
202 |
}
|
203 |
|
204 |
if ( ! empty( $sbp_options['limit_post_revisions'] ) && ! defined( 'WP_POST_REVISIONS' ) ) {
|
212 |
/**
|
213 |
* @since 3.8.1
|
214 |
*/
|
215 |
+
if ( ! empty( $sbp_options['remove_jquery_migrate'] ) ) {
|
216 |
+
add_action( 'wp_default_scripts', [ $this, 'sbp_remove_jquery_migrate' ] );
|
217 |
}
|
|
|
218 |
} // END public public function __construct
|
219 |
|
220 |
+
private function should_run() {
|
221 |
+
|
222 |
+
/*
|
223 |
+
No Query String builders lst (TODO: find themify and x theme/cornerstone)
|
224 |
+
*/
|
225 |
+
$page_builders = [
|
226 |
+
"sbp_disable" => "1", // speed booster pack
|
227 |
+
"fb-edit" => "1", // fusion builder
|
228 |
+
"et_fb" => "1", // divi builder
|
229 |
+
"PageSpeed" => "off", // mod_pagespeed
|
230 |
+
"ao_noptimize" => "1", // autoptimize compat
|
231 |
+
"ao_noptirocket" => "1", // autoptimize & wp rocket compat
|
232 |
+
"fl_builder" => null, // beaver builder 1
|
233 |
+
"bt-beaverbuildertheme" => "show", // beaver builder 2
|
234 |
+
"ct_builder" => "true", // oxygen builder
|
235 |
+
"tve" => "true", // thrive architect
|
236 |
+
"preview" => "true", // wordpress core preview
|
237 |
+
"customize_changeset_uuid" => null, // wordpress core customizer
|
238 |
+
"action" => "elementor", // elementor
|
239 |
+
"ai-debug-blocks" => "1", // ad inserter
|
240 |
+
"tipi_builder" => "1", // tipi builder
|
241 |
+
"vc_action" => "vc_inline", // wpbakery page builder
|
242 |
+
"brizy" => "edit", // brizy builder
|
243 |
+
"siteorigin_panels_live_editor" => null, // siteorigin page builder
|
244 |
+
];
|
245 |
+
|
246 |
+
global $sbp_options;
|
247 |
+
|
248 |
+
foreach ( $page_builders as $page_builder => $value ) {
|
249 |
+
if ( isset( $_GET[ $page_builder ] ) && ( $value == $_GET[ $page_builder ] || null == $value ) ) {
|
250 |
+
return false;
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
if ( @$sbp_options['sbp_disable_temporarily'] == true ) {
|
255 |
+
return false;
|
256 |
+
}
|
257 |
+
|
258 |
+
return true;
|
259 |
+
}
|
260 |
+
|
261 |
/**
|
262 |
* Check if a plugin is active or not.
|
263 |
* @since 3.8.3
|
297 |
* @since 3.8.1
|
298 |
*/
|
299 |
/*--------------------------------------------------------------------------------------------------------
|
300 |
+
Remove JQuery Migrate
|
301 |
+
---------------------------------------------------------------------------------------------------------*/
|
302 |
function sbp_remove_jquery_migrate( $scripts ) {
|
303 |
+
if ( ! is_admin() && isset( $scripts->registered['jquery'] ) ) {
|
304 |
+
$jquery_script = $scripts->registered['jquery'];
|
305 |
|
306 |
if ( $jquery_script->deps ) { // Check whether the script has any dependencies
|
307 |
+
$jquery_script->deps = array_diff( $jquery_script->deps, [ 'jquery-migrate' ] );
|
308 |
}
|
309 |
}
|
310 |
}
|
311 |
|
312 |
/*--------------------------------------------------------------------------------------------------------
|
313 |
+
Disable Dash icons
|
314 |
+
---------------------------------------------------------------------------------------------------------*/
|
315 |
function sbp_disable_dash_icons() {
|
316 |
if ( ! is_user_logged_in() ) {
|
317 |
wp_dequeue_style( 'dashicons' );
|
320 |
}
|
321 |
|
322 |
/*--------------------------------------------------------------------------------------------------------
|
323 |
+
Disable Heartbeat
|
324 |
+
---------------------------------------------------------------------------------------------------------*/
|
325 |
|
326 |
function sbp_disable_heartbeat() {
|
327 |
wp_deregister_script( 'heartbeat' );
|
328 |
}
|
329 |
|
330 |
/*--------------------------------------------------------------------------------------------------------
|
331 |
+
Heartbeat Frequency
|
332 |
+
---------------------------------------------------------------------------------------------------------*/
|
333 |
|
334 |
function sbp_heartbeat_frequency() {
|
335 |
global $sbp_options;
|
339 |
}
|
340 |
|
341 |
/*--------------------------------------------------------------------------------------------------------
|
342 |
+
Disable Google Maps
|
343 |
+
---------------------------------------------------------------------------------------------------------*/
|
344 |
|
345 |
function sbp_disable_google_maps() {
|
346 |
+
ob_start( [ $this, 'sbp_disable_google_maps_regex' ] );
|
347 |
}
|
348 |
|
349 |
function sbp_disable_google_maps_regex( $html ) {
|
350 |
+
$html = preg_replace( '/<script[^<>]*\/\/maps.(googleapis|google|gstatic).com\/[^<>]*><\/script>/i',
|
351 |
+
'',
|
352 |
+
$html );
|
353 |
|
354 |
return $html;
|
355 |
}
|
356 |
|
357 |
/*--------------------------------------------------------------------------------------------------------
|
358 |
+
Disable Password Strength Meter
|
359 |
+
---------------------------------------------------------------------------------------------------------*/
|
360 |
|
361 |
function sbp_disable_password_strength_meter() {
|
362 |
global $wp;
|
381 |
}
|
382 |
|
383 |
/*--------------------------------------------------------------------------------------------------------
|
384 |
+
Init the CSS Optimizer actions
|
385 |
+
---------------------------------------------------------------------------------------------------------*/
|
386 |
|
387 |
function sbp_init() {
|
388 |
|
389 |
global $sbp_options;
|
390 |
|
391 |
if ( ! is_admin() and isset( $sbp_options['sbp_css_async'] ) ) {
|
392 |
+
add_action( 'wp_print_styles', [ $this, 'sbp_print_styles' ], 10 );
|
393 |
+
add_action( 'wp_footer', [ $this, 'sbp_print_delayed_styles' ], 11 );
|
394 |
}
|
395 |
|
396 |
}
|
397 |
|
398 |
|
|
|
399 |
/*--------------------------------------------------------------------------------------------------------
|
400 |
+
ACTION wp_print_styles
|
401 |
+
---------------------------------------------------------------------------------------------------------*/
|
402 |
|
403 |
function sbp_print_styles() {
|
404 |
global $sbp_styles_are_async;
|
417 |
|
418 |
if ( ! isset( $sbp_options['sbp_footer_css'] ) ) {
|
419 |
|
420 |
+
$not_inlined = [];
|
421 |
|
422 |
foreach ( $sbp_styles as $style ) {
|
423 |
echo "<style type=\"text/css\" " . ( $style['media'] ? "media=\"{$style['media']}\"" : '' ) . ">";
|
429 |
if ( ! empty( $not_inlined ) ) {
|
430 |
foreach ( $not_inlined as $style ) {
|
431 |
?>
|
432 |
+
<link rel="stylesheet" href="<?php echo $style['src'] ?>"
|
433 |
+
type="text/css" <?php echo $style['media'] ? "media=\"{$style['media']}\"" : '' ?> /><?php
|
434 |
}
|
435 |
}
|
436 |
}
|
440 |
|
441 |
|
442 |
/*--------------------------------------------------------------------------------------------------------
|
443 |
+
ACTION wp_footer
|
444 |
+
---------------------------------------------------------------------------------------------------------*/
|
445 |
|
446 |
function sbp_print_delayed_styles() {
|
447 |
global $sbp_styles;
|
455 |
|
456 |
if ( isset( $sbp_options['sbp_footer_css'] ) ) {
|
457 |
|
458 |
+
$not_inlined = [];
|
459 |
foreach ( $sbp_styles as $style ) {
|
460 |
echo "<style type=\"text/css\" " . ( $style['media'] ? "media=\"{$style['media']}\"" : '' ) . ">";
|
461 |
if ( ! sbp_inline_css( $style['src'], $minify ) ) {
|
466 |
if ( ! empty( $not_inlined ) ) {
|
467 |
foreach ( $not_inlined as $style ) {
|
468 |
?>
|
469 |
+
<link rel="stylesheet" href="<?php echo $style['src'] ?>"
|
470 |
+
type="text/css" <?php echo $style['media'] ? "media=\"{$style['media']}\"" : '' ?> /><?php
|
471 |
}
|
472 |
}
|
473 |
}
|
475 |
|
476 |
|
477 |
/*--------------------------------------------------------------------------------------------------------
|
478 |
+
Moves scripts to the footer to decrease page load times, while keeping stylesheets in the header
|
479 |
+
---------------------------------------------------------------------------------------------------------*/
|
480 |
|
481 |
+
function sbp_move_scripts_to_footer_deprecated() {
|
482 |
|
483 |
global $sbp_options;
|
484 |
|
490 |
|
491 |
}
|
492 |
|
493 |
+
} // END function sbp_move_scripts_to_footer
|
494 |
|
495 |
+
public function sbp_move_scripts_to_footer() {
|
496 |
+
ob_start( [ $this, 'sbp_move_scripts_to_footer_worker' ] );
|
497 |
+
}
|
498 |
+
|
499 |
+
public function sbp_move_scripts_to_footer_worker( $html ) {
|
500 |
+
$scripts_to_move = $this->sbp_get_scripts_to_move( $html );
|
501 |
+
$this->sbp_remove_scripts_to_move( $html, $scripts_to_move );
|
502 |
+
|
503 |
+
return $html;
|
504 |
+
}
|
505 |
+
|
506 |
+
private function sbp_remove_scripts_to_move( &$html, $scripts ) {
|
507 |
+
foreach ( $scripts as $script ) {
|
508 |
+
$html = str_ireplace( $script, '', $html );
|
509 |
+
}
|
510 |
+
|
511 |
+
$html = str_ireplace( '</body>', implode( PHP_EOL, $scripts ) . PHP_EOL . '</body>', $html );
|
512 |
+
}
|
513 |
+
|
514 |
+
private function sbp_get_scripts_to_move( $html ) {
|
515 |
+
global $sbp_js_footer_exceptions;
|
516 |
+
preg_match_all( '/<!--[\s\S]*?-->|<script[\s\S]*?>[\s\S]*?<\/script>/im', $html, $result );
|
517 |
+
$scripts = $result[0];
|
518 |
+
$includedScripts = [];
|
519 |
+
// Check types
|
520 |
+
foreach ( $scripts as $script ) {
|
521 |
+
preg_match( '/<script[\s\S]*?type=[\'|"](.*?)[\'|"][\s\S]*?>/im', $script, $result );
|
522 |
+
if ( substr( $script, 0, 4 ) != '<!--' ) {
|
523 |
+
if ( count( $result ) == 0 ) {
|
524 |
+
$includedScripts[] = $script;
|
525 |
+
} else {
|
526 |
+
$type = trim( str_replace( [ '"', "'" ], '', $result[1] ) );
|
527 |
+
if ( in_array( $type, self::SCRIPT_TYPES ) ) {
|
528 |
+
$includedScripts[] = $script;
|
529 |
+
}
|
530 |
+
}
|
531 |
+
}
|
532 |
+
}
|
533 |
+
|
534 |
+
for ( $i = 0; $i < count( $includedScripts ); $i ++ ) {
|
535 |
+
// Check if in excluded scripts
|
536 |
+
$script = $includedScripts[ $i ];
|
537 |
+
$script = trim( str_replace( [ '\n', '\r' ], '', $script ) );
|
538 |
+
preg_match( '/<script[\s\S]*?src=?[\'|"](.*?)[\'|"][\s\S]*?>/im', $script, $result );
|
539 |
+
if ( isset( $result[1] ) && trim( $result[1] ) ) {
|
540 |
+
$src = $result[1];
|
541 |
+
|
542 |
+
$src = str_replace( [ '\r', '\n' ], '', $src );
|
543 |
|
544 |
+
foreach ( $sbp_js_footer_exceptions as $exception ) {
|
545 |
+
if ( strpos( $src, $exception ) !== false ) {
|
546 |
+
unset( $includedScripts[ $i ] );
|
547 |
+
}
|
548 |
+
}
|
549 |
+
|
550 |
+
// if ( in_array( $src, $sbp_js_footer_exceptions ) ) {
|
551 |
+
// unset( $includedScripts[ $i ] );
|
552 |
+
// }
|
553 |
+
}
|
554 |
+
unset( $result );
|
555 |
+
preg_match( '/<script[\s\S]*?>(.*?)<\/script>/ims', $script, $result );
|
556 |
+
if ( isset( $result[1] ) && trim( $result[1] ) ) {
|
557 |
+
foreach ( $sbp_js_footer_exceptions as $exception ) {
|
558 |
+
if ( substr( $exception, 0, 1 ) !== '/' && strpos( trim( $result[1] ),
|
559 |
+
trim( $exception ) ) !== false ) {
|
560 |
+
unset( $includedScripts[ $i ] );
|
561 |
+
}
|
562 |
+
}
|
563 |
+
}
|
564 |
+
}
|
565 |
+
|
566 |
+
return $includedScripts;
|
567 |
+
}
|
568 |
+
|
569 |
+
public function sbp_scripts_to_head_deprecated() {
|
570 |
|
571 |
/**
|
572 |
* Default: add jQuery to header always
|
606 |
*
|
607 |
* New solution, going forward so not to crash so many sites anymore
|
608 |
*
|
609 |
+
* This should come BEFORE the fallback function, since jQuery should be ALWAYS
|
610 |
+
* the first loaded script.
|
611 |
*
|
612 |
*/
|
613 |
if ( $js_footer_exceptions1 !== 'jquery-core' || $js_footer_exceptions2 !== 'jquery-core' || $js_footer_exceptions3 !== 'jquery-core' || $js_footer_exceptions4 !== 'jquery-core' ) {
|
615 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
616 |
$script_src = $wp_scripts->registered['jquery-core']->src;
|
617 |
|
618 |
+
if ( strpos( $script_src,
|
619 |
+
'wp-includes' ) == true ) { // it's a local resource, append wordpress installation URL
|
620 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
621 |
} else {
|
622 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
625 |
// deregister & dequeue the script
|
626 |
//wp_deregister_script( 'jquery-core' );
|
627 |
//wp_dequeue_script( 'jquery-core' );
|
628 |
+
$wp_scripts->registered['jquery-core']->src = null;
|
629 |
}
|
630 |
|
631 |
|
642 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
643 |
$script_src = $wp_scripts->registered[ $js_footer_exceptions1 ]->src;
|
644 |
|
645 |
+
if ( strpos( $script_src,
|
646 |
+
'wp-includes' ) == true ) { // it's a local resource, append wordpress installation URL
|
647 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
648 |
} else {
|
649 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
680 |
// if the script actually exists, dequeue it and re-add it for header inclusion
|
681 |
$script_src = $wp_scripts->registered[ $js_footer_exceptions4 ]->src;
|
682 |
|
683 |
+
if ( strpos( $script_src,
|
684 |
+
'wp-includes' ) == true ) { // it's a local resource, append wordpress installation URL
|
685 |
echo '<script type="text/javascript" src="' . get_site_url() . esc_attr( $script_src ) . '"></script>';
|
686 |
} else {
|
687 |
echo '<script type="text/javascript" src="' . esc_attr( $script_src ) . '"></script>';
|
736 |
|
737 |
|
738 |
/*--------------------------------------------------------------------------------------------------------
|
739 |
+
Minify HTML and Javascripts
|
740 |
+
---------------------------------------------------------------------------------------------------------*/
|
741 |
|
742 |
function sbp_minifier() {
|
743 |
|
744 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/sbp-minifier.php' );
|
745 |
+
} // End function sbp_minifier()
|
746 |
|
747 |
|
748 |
/*--------------------------------------------------------------------------------------------------------
|
749 |
+
CSS Optimizer
|
750 |
+
---------------------------------------------------------------------------------------------------------*/
|
751 |
|
752 |
function sbp_css_optimizer() {
|
753 |
|
754 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/css-optimizer.php' );
|
755 |
|
756 |
+
} // End function sbp_css_optimizer()
|
757 |
|
758 |
/*--------------------------------------------------------------------------------------------------------
|
759 |
+
Defer parsing of JavaScript and exclusion files
|
760 |
+
---------------------------------------------------------------------------------------------------------*/
|
761 |
|
762 |
function sbp_defer_parsing_of_js( $tag, $handle, $src ) {
|
763 |
|
787 |
$array_with_values[] = $defer_exclude3;
|
788 |
$array_with_values[] = $defer_exclude4;
|
789 |
|
790 |
+
$array_with_values = apply_filters( 'sbp_exclude_defer_scripts',
|
791 |
+
$array_with_values ); // possibility of extending this via filters
|
792 |
$array_with_values = array_filter( $array_with_values ); // remove empty entries
|
793 |
|
794 |
|
798 |
|
799 |
return $tag;
|
800 |
|
801 |
+
} // END function sbp_defer_parsing_of_js
|
802 |
|
803 |
|
804 |
/*--------------------------------------------------------------------------------------------------------
|
805 |
+
Remove query strings from static resources
|
806 |
+
---------------------------------------------------------------------------------------------------------*/
|
807 |
|
808 |
+
function sbp_remove_query_strings( $src ) { // remove "?ver" string
|
809 |
|
810 |
$output = preg_split( "/(\?rev|&ver|\?ver)/", $src );
|
811 |
|
814 |
}
|
815 |
|
816 |
/*--------------------------------------------------------------------------------------------------------
|
817 |
+
Disable Emoji
|
818 |
+
---------------------------------------------------------------------------------------------------------*/
|
819 |
function sbp_disable_emojis() {
|
820 |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
|
821 |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
|
822 |
+
remove_filter( 'embed_head', 'print_emoji_detection_script' );
|
823 |
remove_action( 'wp_print_styles', 'print_emoji_styles' );
|
824 |
remove_action( 'admin_print_styles', 'print_emoji_styles' );
|
825 |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
|
826 |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
|
827 |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
|
828 |
|
829 |
+
add_filter( 'tiny_mce_plugins', [ $this, 'sbp_disable_emojis_tinymce' ] );
|
830 |
+
add_filter( 'wp_resource_hints', [ $this, 'sbp_disable_emojis_dns_prefetch' ], 10, 2 );
|
831 |
}
|
832 |
|
833 |
function sbp_disable_emojis_tinymce( $plugins ) {
|
834 |
if ( is_array( $plugins ) ) {
|
835 |
+
return array_diff( $plugins, [ 'wpemoji' ] );
|
836 |
} else {
|
837 |
+
return [];
|
838 |
}
|
839 |
}
|
840 |
|
841 |
function sbp_disable_emojis_dns_prefetch( $urls, $relation_type ) {
|
842 |
if ( 'dns-prefetch' == $relation_type ) {
|
843 |
$emoji_svg_url = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/2.2.1/svg/' );
|
844 |
+
$urls = array_diff( $urls, [ $emoji_svg_url ] );
|
845 |
}
|
846 |
|
847 |
return $urls;
|
848 |
}
|
849 |
|
850 |
/*--------------------------------------------------------------------------------------------------------
|
851 |
+
Disable Self Pingbacks
|
852 |
+
---------------------------------------------------------------------------------------------------------*/
|
853 |
|
854 |
function sbp_remove_self_ping( &$links ) {
|
855 |
|
863 |
}
|
864 |
|
865 |
/*--------------------------------------------------------------------------------------------------------
|
866 |
+
Disable Cart Fragments
|
867 |
+
---------------------------------------------------------------------------------------------------------*/
|
868 |
|
869 |
function sbp_disable_cart_fragments() {
|
870 |
global $wp_scripts;
|
871 |
|
872 |
$handle = 'wc-cart-fragments';
|
873 |
|
874 |
+
$load_cart_fragments_path = $wp_scripts->registered[ $handle ]->src;
|
875 |
$wp_scripts->registered[ $handle ]->src = null;
|
876 |
wp_add_inline_script(
|
877 |
'woocommerce',
|
878 |
'
|
879 |
+
function sbp_getCookie(name) {
|
880 |
+
var v = document.cookie.match("(^|;) ?" + name + "=([^;]*)(;|$)");
|
881 |
+
return v ? v[2] : null;
|
882 |
+
}
|
883 |
+
|
884 |
+
function sbp_check_wc_cart_script() {
|
885 |
+
var cart_src = "' . $load_cart_fragments_path . '";
|
886 |
+
var script_id = "sbp_loaded_wc_cart_fragments";
|
887 |
+
|
888 |
+
if( document.getElementById(script_id) !== null ) {
|
889 |
+
return false;
|
890 |
+
}
|
891 |
+
|
892 |
+
if( sbp_getCookie("woocommerce_cart_hash") ) {
|
893 |
+
var script = document.createElement("script");
|
894 |
+
script.id = script_id;
|
895 |
+
script.src = cart_src;
|
896 |
+
script.async = true;
|
897 |
+
document.head.appendChild(script);
|
898 |
+
}
|
899 |
+
}
|
900 |
+
|
901 |
+
sbp_check_wc_cart_script();
|
902 |
+
document.addEventListener("click", function(){setTimeout(sbp_check_wc_cart_script,1000);});
|
903 |
+
'
|
904 |
);
|
905 |
}
|
906 |
|
907 |
/*--------------------------------------------------------------------------------------------------------
|
908 |
+
Enable Instant Page
|
909 |
+
---------------------------------------------------------------------------------------------------------*/
|
910 |
|
911 |
function sbp_enable_instant_page() {
|
912 |
wp_enqueue_script( 'sbp-ins-page', plugins_url( 'js/inspage.js', __FILE__ ), false, '2.0.0', true );
|
913 |
}
|
914 |
|
915 |
/*--------------------------------------------------------------------------------------------------------
|
916 |
+
Remove junk header tags
|
917 |
+
---------------------------------------------------------------------------------------------------------*/
|
918 |
|
919 |
public function sbp_junk_header_tags() {
|
920 |
|
921 |
global $sbp_options;
|
922 |
|
923 |
+
// Remove Adjacent Posts links PREV/NEXT
|
924 |
if ( isset( $sbp_options['remove_adjacent'] ) ) {
|
925 |
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );
|
926 |
}
|
927 |
|
928 |
+
// Remove Windows Live Writer Manifest Link
|
929 |
if ( isset( $sbp_options['wml_link'] ) ) {
|
930 |
remove_action( 'wp_head', 'wlwmanifest_link' );
|
931 |
}
|
935 |
remove_action( 'wp_head', 'rsd_link' );
|
936 |
}
|
937 |
|
938 |
+
// Remove WordPress Shortlinks from WP Head
|
939 |
if ( isset( $sbp_options['remove_wsl'] ) ) {
|
940 |
remove_action( 'wp_head', 'wp_shortlink_wp_head' );
|
941 |
}
|
942 |
|
943 |
+
// Remove WP Generator/Version - for security reasons and cleaning the header
|
944 |
if ( isset( $sbp_options['wp_generator'] ) ) {
|
945 |
remove_action( 'wp_head', 'wp_generator' );
|
946 |
}
|
947 |
|
948 |
+
// Remove all feeds
|
949 |
if ( isset( $sbp_options['remove_all_feeds'] ) ) {
|
950 |
+
remove_action( 'wp_head',
|
951 |
+
'feed_links_extra',
|
952 |
+
3 ); // remove the feed links from the extra feeds such as category feeds
|
953 |
+
remove_action( 'wp_head',
|
954 |
+
'feed_links',
|
955 |
+
2 ); // remove the feed links from the general feeds: Post and Comment Feed
|
956 |
}
|
957 |
|
958 |
+
} // END public function sbp_junk_header_tags
|
959 |
+
|
960 |
+
function sbp_optimize_fonts() {
|
961 |
+
if ( ! is_embed() ) {
|
962 |
+
ob_start( [ $this, 'sbp_optimize_fonts_callback' ] );
|
963 |
+
}
|
964 |
+
}
|
965 |
+
|
966 |
+
// TODO: Refactor
|
967 |
+
function sbp_optimize_fonts_callback( $html ) {
|
968 |
+
$regex = "<link[^<>\/]+href=['\"?](https?:)?\/\/fonts\.googleapis\.com\/css\?(.*?)['\"?].*?>";
|
969 |
+
preg_match_all( "/" . $regex . "/i", $html, $gfont_links );
|
970 |
+
$process_array = $gfont_links[2];
|
971 |
+
if ( isset( $process_array ) ) {
|
972 |
+
$fontFamilies = [];
|
973 |
+
$attributes = [];
|
974 |
+
foreach ( $process_array as $link ) {
|
975 |
+
$link = str_replace( 'family=', '', $link );
|
976 |
+
$linkAttributes = explode( '&', $link );
|
977 |
+
if ( strpos( $linkAttributes[0], '|' ) === false ) {
|
978 |
+
$font = explode( ':', $linkAttributes[0] );
|
979 |
+
$fontName = $font[0];
|
980 |
+
$weights = explode( ',', $font[1] );
|
981 |
+
foreach ( $weights as $weight ) {
|
982 |
+
if ( ! in_array( $weight, $fontFamilies[ $fontName ] ) ) {
|
983 |
+
$fontFamilies[ $fontName ][] = $weight;
|
984 |
+
}
|
985 |
+
}
|
986 |
+
}
|
987 |
+
// Loop font families
|
988 |
+
foreach ( explode( '|', $linkAttributes[0] ) as $family ) {
|
989 |
+
$weights = explode( ':', $family )[1];
|
990 |
+
$weights = explode( ',', $weights );
|
991 |
+
$fontName = explode( ':', $family )[0];
|
992 |
+
// Loop weights
|
993 |
+
foreach ( $weights as $weight ) {
|
994 |
+
if ( ! in_array( $weight, $fontFamilies[ $fontName ] ) ) {
|
995 |
+
$fontFamilies[ $fontName ][] = $weight;
|
996 |
+
}
|
997 |
+
}
|
998 |
+
}
|
999 |
+
for ( $i = 1; $i < count( $linkAttributes ); $i ++ ) {
|
1000 |
+
$attribute = $linkAttributes[ $i ];
|
1001 |
+
$attribute = explode( '=', $attribute );
|
1002 |
+
$attributes[ $attribute[0] ][] = $attribute[1];
|
1003 |
+
}
|
1004 |
+
$fontFamilyStrings = [];
|
1005 |
+
foreach ( $fontFamilies as $fontName => $weights ) {
|
1006 |
+
$weights = array_filter( $weights );
|
1007 |
+
$fontFamilyStrings[] = $fontName . ( count( $weights ) > 0 ? ( ':' . implode( ',',
|
1008 |
+
$weights ) ) : null );
|
1009 |
+
}
|
1010 |
+
$subsets = array_unique( $attributes['subset'] );
|
1011 |
+
$subsets = implode( ',', $subsets );
|
1012 |
+
$subsets = $subsets ? '&subset=' . $subsets : '';
|
1013 |
+
}
|
1014 |
+
$gfont_link = 'https://fonts.googleapis.com/css?family=' . implode( '|',
|
1015 |
+
$fontFamilyStrings ) . '&display=swap' . $subsets;
|
1016 |
+
$html = preg_replace( '/' . $regex . '/i', '', $html );
|
1017 |
+
$html = str_ireplace( '</head>',
|
1018 |
+
'<link rel="dns-prefetch" href="//fonts.googleapis.com" />' . PHP_EOL . '<link rel="dns-prefetch" href="//fonts.gstatic.com" />' . PHP_EOL . '<link href="' . $gfont_link . '" rel="stylesheet"/>' . PHP_EOL . '</head>',
|
1019 |
+
$html );
|
1020 |
+
|
1021 |
+
return $html;
|
1022 |
+
}
|
1023 |
+
|
1024 |
+
return $html;
|
1025 |
+
}
|
1026 |
|
1027 |
|
1028 |
/*--------------------------------
|
1029 |
+
Lazy Loader (native with polyfill)
|
1030 |
+
---------------------------------*/
|
1031 |
+
|
1032 |
function sbp_lazy_load_script() {
|
1033 |
+
wp_enqueue_script( 'sbp-lazy-load', plugins_url( 'js/lazyload.js', __FILE__ ), false, '12.4', true );
|
1034 |
+
wp_add_inline_script( 'sbp-lazy-load',
|
1035 |
+
'
|
1036 |
+
(function() {
|
1037 |
+
var ll = new LazyLoad({
|
1038 |
+
elements_selector: "[loading=lazy]",
|
1039 |
+
use_native: true
|
1040 |
+
});
|
1041 |
+
})();
|
1042 |
+
' );
|
1043 |
+
}
|
1044 |
+
|
1045 |
function sbp_lazy_load() {
|
1046 |
+
ob_start( [ $this, 'sbp_lazy_loader' ] );
|
1047 |
}
|
1048 |
|
1049 |
function sbp_lazy_loader( $html ) {
|
1050 |
$placeholder = 'data:image/svg+xml,%3Csvg%20xmlns%3D%27http://www.w3.org/2000/svg%27%20viewBox%3D%270%200%203%202%27%3E%3C/svg%3E';
|
1051 |
+
$html = preg_replace( "/<(img|source|iframe)(.*?) (src=)(.*?)>/is",
|
1052 |
+
'<$1$2 $3"' . $placeholder . '" data-$3$4>',
|
1053 |
+
$html );
|
1054 |
+
$html = preg_replace( "/<(img|source|iframe)(.*?) (srcset=)(.*?)>/is",
|
1055 |
+
'<$1$2 $3"' . $placeholder . '" data-$3$4>',
|
1056 |
+
$html );
|
1057 |
+
$html = preg_replace( "/<(img|source|iframe)(.*?) ?(\/?)>/is", '<$1$2 loading="lazy" $3>', $html );
|
1058 |
+
|
1059 |
return $html;
|
1060 |
}
|
1061 |
|
1062 |
|
1063 |
/*--------------------------------
|
1064 |
+
CDN Rewrite URLs
|
1065 |
+
---------------------------------*/
|
1066 |
+
|
1067 |
function sbp_cdn_rewrite() {
|
1068 |
+
ob_start( [ $this, 'sbp_cdn_rewriter' ] );
|
1069 |
}
|
1070 |
|
1071 |
+
function sbp_cdn_rewriter( $html ) {
|
1072 |
global $sbp_options;
|
1073 |
$sbp_cdn_directories = $sbp_options['sbp_cdn_included_directories'];
|
1074 |
|
1075 |
//Prep Site URL
|
1076 |
+
$escapedSiteURL = quotemeta( get_option( 'home' ) );
|
1077 |
+
$regExURL = '(https?:|)' . substr( $escapedSiteURL, strpos( $escapedSiteURL, '//' ) );
|
1078 |
|
1079 |
//Prep Included Directories
|
1080 |
$directories = 'wp\-content|wp\-includes';
|
1081 |
+
if ( ! empty( $sbp_cdn_directories ) ) {
|
1082 |
+
$directoriesArray = array_map( 'trim', explode( ',', $sbp_cdn_directories ) );
|
1083 |
+
if ( count( $directoriesArray ) > 0 ) {
|
1084 |
+
$directories = implode( '|', array_map( 'quotemeta', array_filter( $directoriesArray ) ) );
|
1085 |
}
|
1086 |
}
|
1087 |
|
1088 |
//Rewrite URLs + Return
|
1089 |
+
$regEx = '#(?<=[(\"\'])(?:' . $regExURL . ')?/(?:((?:' . $directories . ')[^\"\')]+)|([^/\"\']+\.[^/\"\')]+))(?=[\"\')])#';
|
1090 |
+
$cdnHTML = preg_replace_callback( $regEx, [ $this, 'sbp_cdn_rewrite_url' ], $html );
|
1091 |
+
|
1092 |
return $cdnHTML;
|
1093 |
}
|
1094 |
|
1095 |
+
function sbp_cdn_rewrite_url( $url ) {
|
1096 |
global $sbp_options;
|
1097 |
+
$sbp_cdn_url = $sbp_options['sbp_cdn_url'];
|
1098 |
$sbp_cdn_excluded = $sbp_options['sbp_cdn_exclusions'];
|
1099 |
|
1100 |
//Make Sure CDN URL is Set
|
1101 |
+
if ( ! empty( $sbp_cdn_url ) ) {
|
1102 |
|
1103 |
//Don't Rewrite if Excluded
|
1104 |
+
if ( ! empty( $sbp_cdn_excluded ) ) {
|
1105 |
+
$exclusions = array_map( 'trim', explode( ',', $sbp_cdn_excluded ) );
|
1106 |
+
foreach ( $exclusions as $exclusion ) {
|
1107 |
+
if ( ! empty( $exclusion ) && stristr( $url[0], $exclusion ) != false ) {
|
1108 |
return $url[0];
|
1109 |
}
|
1110 |
}
|
1111 |
}
|
1112 |
|
1113 |
//Don't Rewrite if Previewing
|
1114 |
+
if ( is_admin_bar_showing() && isset( $_GET['preview'] ) && $_GET['preview'] == 'true' ) {
|
1115 |
return $url[0];
|
1116 |
}
|
1117 |
|
1118 |
//Prep Site URL
|
1119 |
+
$siteURL = get_option( 'home' );
|
1120 |
+
$siteURL = substr( $siteURL, strpos( $siteURL, '//' ) );
|
1121 |
|
1122 |
//Replace URL w/ No HTTP/S Prefix
|
1123 |
+
if ( strpos( $url[0], '//' ) === 0 ) {
|
1124 |
+
return str_replace( $siteURL, $sbp_cdn_url, $url[0] );
|
1125 |
}
|
1126 |
|
1127 |
//Found Site URL, Replace Non Relative URL w/ HTTP/S Prefix
|
1128 |
+
if ( strstr( $url[0], $siteURL ) ) {
|
1129 |
+
return str_replace( [ 'http:' . $siteURL, 'https:' . $siteURL ], $sbp_cdn_url, $url[0] );
|
1130 |
}
|
1131 |
+
|
1132 |
//Replace Relative URL
|
1133 |
return $sbp_cdn_url . $url[0];
|
1134 |
}
|
1138 |
}
|
1139 |
|
1140 |
/*--------------------------------------------
|
1141 |
+
File processor
|
1142 |
+
--------------------------------------------*/
|
1143 |
|
1144 |
function sbp_file_process() {
|
1145 |
global $wp_filesystem;
|
1146 |
|
1147 |
+
require_once( ABSPATH . '/wp-admin/includes/file.php' );
|
1148 |
WP_Filesystem();
|
1149 |
|
1150 |
return $wp_filesystem;
|
1151 |
}
|
1152 |
|
1153 |
/*--------------------------------------------
|
1154 |
+
Google Analytics
|
1155 |
+
--------------------------------------------*/
|
1156 |
|
1157 |
//update analytics.js
|
1158 |
function sbp_update_ga() {
|
1159 |
+
$wp_filesystem = $this->sbp_file_process();
|
1160 |
|
1161 |
+
if ( ! $wp_filesystem->exists( WP_CONTENT_DIR . $this->local_cache_dir . 'speed-booster/' ) ) {
|
1162 |
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir, FS_CHMOD_DIR );
|
1163 |
$wp_filesystem->mkdir( WP_CONTENT_DIR . $this->local_cache_dir . 'speed-booster/', FS_CHMOD_DIR );
|
1164 |
}
|
1165 |
|
1166 |
$file_content = $wp_filesystem->get_contents( $this->remote_ga_script );
|
1167 |
|
1168 |
+
if ( $wp_filesystem->put_contents( WP_CONTENT_DIR . $this->local_ga_script,
|
1169 |
+
$file_content,
|
1170 |
+
FS_CHMOD_FILE ) ) {
|
1171 |
+
return true;
|
1172 |
+
}
|
1173 |
|
1174 |
return false;
|
1175 |
}
|
1180 |
global $sbp_options;
|
1181 |
|
1182 |
//dont print for logged in admins
|
1183 |
+
if ( current_user_can( 'manage_options' ) && empty( $sbp_options['sbp_track_loggedin_admins'] ) ) {
|
1184 |
return;
|
1185 |
}
|
1186 |
|
1187 |
+
if ( isset( $sbp_options['sbp_ga_tracking_id'] ) && ! empty( $sbp_options['sbp_ga_tracking_id'] ) ) {
|
1188 |
+
$wp_filesystem = $this->sbp_file_process();
|
1189 |
+
$ga_script = WP_CONTENT_URL . $this->local_ga_script;
|
1190 |
|
1191 |
+
if ( ! $wp_filesystem->exists( WP_CONTENT_DIR . $this->local_ga_script ) ) {
|
1192 |
|
1193 |
+
if ( ! $this->sbp_update_ga() ) {
|
1194 |
$ga_script = $this->remote_ga_script;
|
1195 |
}
|
1196 |
}
|
1198 |
echo "\n\n<!-- Local Analytics generated with Speed Booster Pack by Optimocha. -->\n";
|
1199 |
echo "<script>\n";
|
1200 |
echo "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','" . $ga_script . "','ga');\n";
|
1201 |
+
echo "ga('create', '" . $sbp_options['sbp_ga_tracking_id'] . "', 'auto');\n";
|
1202 |
|
1203 |
//disable display features
|
1204 |
+
if ( ! empty( $sbp_options['sbp_disable_display_features'] ) && $sbp_options['sbp_disable_display_features'] == "1" ) {
|
1205 |
echo "ga('set', 'allowAdFeatures', false);\n";
|
1206 |
}
|
1207 |
|
1208 |
//anonymize ip
|
1209 |
+
if ( ! empty( $sbp_options['sbp_anonymize_ip'] ) && $sbp_options['sbp_anonymize_ip'] == "1" ) {
|
1210 |
echo "ga('set', 'anonymizeIp', true);\n";
|
1211 |
}
|
1212 |
|
1213 |
echo "ga('send', 'pageview');\n";
|
1214 |
|
1215 |
//adjusted bounce rate
|
1216 |
+
if ( ! empty( $sbp_options['sbp_bounce_rate'] ) ) {
|
1217 |
+
echo 'setTimeout("ga(' . "'send','event','adjusted bounce rate','" . $sbp_options['sbp_bounce_rate'] . " seconds')" . '"' . "," . $sbp_options['sbp_bounce_rate'] * 1000 . ");\n";
|
1218 |
}
|
1219 |
|
1220 |
echo "</script>\n";
|
1222 |
}
|
1223 |
}
|
1224 |
|
1225 |
+
} // END class Speed_Booster_Pack_Core
|
1226 |
+
} // END if(!class_exists('Speed_Booster_Pack_Core'))
|
inc/css-optimizer.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
@@ -13,16 +13,16 @@ function sbp_generate_styles_list() {
|
|
13 |
|
14 |
global $wp_styles;
|
15 |
|
16 |
-
$list =
|
17 |
if ( isset( $wp_styles->queue ) && is_array( $wp_styles->queue ) ) {
|
18 |
foreach ( $wp_styles->queue as $style ) {
|
19 |
if ( is_css_excluded( $style ) ) {
|
20 |
// load excluded stylesheet in render-blocking manner
|
21 |
} else {
|
22 |
-
$list[] =
|
23 |
'src' => $wp_styles->registered[ $style ]->src,
|
24 |
'media' => $wp_styles->registered[ $style ]->args,
|
25 |
-
|
26 |
}
|
27 |
}
|
28 |
}
|
@@ -60,7 +60,6 @@ function sbp_unregister_styles() {
|
|
60 |
---------------------------------------------------------------------------------------------------------*/
|
61 |
|
62 |
function sbp_inline_css( $url, $minify = true ) {
|
63 |
-
|
64 |
$base_url = get_bloginfo( 'wpurl' );
|
65 |
$path = false;
|
66 |
|
@@ -106,7 +105,9 @@ function sbp_rebuilding_css_urls( $css, $url ) {
|
|
106 |
// remove empty url() declarations
|
107 |
$css = preg_replace( "/url\(\s?\)/", "", $css );
|
108 |
// new regex expression
|
109 |
-
$css = preg_replace( "/url(?!\(['\"]?(data:|http:|https:))\(['\"]?([^\/][^'\"\)]*)['\"]?\)/i",
|
|
|
|
|
110 |
|
111 |
|
112 |
return $css;
|
@@ -121,15 +122,15 @@ function sbp_rebuilding_css_urls( $css, $url ) {
|
|
121 |
function sbp_minify_css( $css ) {
|
122 |
|
123 |
$css = sbp_remove_multiline_comments( $css );
|
124 |
-
$css = str_replace(
|
125 |
$cnt = 1;
|
126 |
|
127 |
while ( $cnt > 0 ) {
|
128 |
$css = str_replace( ' ', ' ', $css, $cnt );
|
129 |
}
|
130 |
|
131 |
-
$css = str_replace(
|
132 |
-
$css = str_replace(
|
133 |
$css = str_replace( ': ', ':', $css );
|
134 |
$css = str_replace( '; ', ';', $css );
|
135 |
$css = str_replace( ', ', ',', $css );
|
@@ -146,31 +147,31 @@ function sbp_remove_multiline_comments( $code, $method = 0 ) {
|
|
146 |
|
147 |
switch ( $method ) {
|
148 |
case 1:
|
149 |
-
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
|
155 |
case 0:
|
156 |
|
157 |
default :
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
}
|
168 |
-
|
169 |
-
$open_pos = strpos( $code, '/*', $open_pos );
|
170 |
}
|
171 |
|
172 |
-
|
173 |
}
|
|
|
|
|
|
|
174 |
}
|
175 |
|
176 |
return $code;
|
@@ -188,13 +189,13 @@ function sbp_style_exceptions() {
|
|
188 |
*
|
189 |
* @since 3.7
|
190 |
*/
|
191 |
-
$default =
|
192 |
'admin-bar',
|
193 |
'dashicons',
|
194 |
-
|
195 |
|
196 |
$array = explode( "\n", get_option( 'sbp_css_exceptions' ) );
|
197 |
-
$css_exceptions =
|
198 |
foreach ( $array as $key => $ex ) {
|
199 |
if ( trim( $ex ) != '' ) {
|
200 |
$css_exceptions[ $key ] = trim( $ex );
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
13 |
|
14 |
global $wp_styles;
|
15 |
|
16 |
+
$list = [];
|
17 |
if ( isset( $wp_styles->queue ) && is_array( $wp_styles->queue ) ) {
|
18 |
foreach ( $wp_styles->queue as $style ) {
|
19 |
if ( is_css_excluded( $style ) ) {
|
20 |
// load excluded stylesheet in render-blocking manner
|
21 |
} else {
|
22 |
+
$list[] = [
|
23 |
'src' => $wp_styles->registered[ $style ]->src,
|
24 |
'media' => $wp_styles->registered[ $style ]->args,
|
25 |
+
];
|
26 |
}
|
27 |
}
|
28 |
}
|
60 |
---------------------------------------------------------------------------------------------------------*/
|
61 |
|
62 |
function sbp_inline_css( $url, $minify = true ) {
|
|
|
63 |
$base_url = get_bloginfo( 'wpurl' );
|
64 |
$path = false;
|
65 |
|
105 |
// remove empty url() declarations
|
106 |
$css = preg_replace( "/url\(\s?\)/", "", $css );
|
107 |
// new regex expression
|
108 |
+
$css = preg_replace( "/url(?!\(['\"]?(data:|http:|https:))\(['\"]?([^\/][^'\"\)]*)['\"]?\)/i",
|
109 |
+
"url({$css_dir}/$2)",
|
110 |
+
$css );
|
111 |
|
112 |
|
113 |
return $css;
|
122 |
function sbp_minify_css( $css ) {
|
123 |
|
124 |
$css = sbp_remove_multiline_comments( $css );
|
125 |
+
$css = str_replace( [ "\t", "\n", "\r" ], ' ', $css );
|
126 |
$cnt = 1;
|
127 |
|
128 |
while ( $cnt > 0 ) {
|
129 |
$css = str_replace( ' ', ' ', $css, $cnt );
|
130 |
}
|
131 |
|
132 |
+
$css = str_replace( [ ' {', '{ ' ], '{', $css );
|
133 |
+
$css = str_replace( [ ' }', '} ', ';}' ], '}', $css );
|
134 |
$css = str_replace( ': ', ':', $css );
|
135 |
$css = str_replace( '; ', ';', $css );
|
136 |
$css = str_replace( ', ', ',', $css );
|
147 |
|
148 |
switch ( $method ) {
|
149 |
case 1:
|
150 |
+
{
|
151 |
|
152 |
+
$code = preg_replace( '/\s*(?!<\")\/\*[^\*]+\*\/(?!\")\s*/', '', $code );
|
153 |
+
break;
|
154 |
+
}
|
155 |
|
156 |
case 0:
|
157 |
|
158 |
default :
|
159 |
+
{
|
160 |
+
|
161 |
+
$open_pos = strpos( $code, '/*' );
|
162 |
+
while ( $open_pos !== false ) {
|
163 |
+
$close_pos = strpos( $code, '*/', $open_pos ) + 2;
|
164 |
+
if ( $close_pos ) {
|
165 |
+
$code = substr( $code, 0, $open_pos ) . substr( $code, $close_pos );
|
166 |
+
} else {
|
167 |
+
$code = substr( $code, 0, $open_pos );
|
|
|
|
|
|
|
168 |
}
|
169 |
|
170 |
+
$open_pos = strpos( $code, '/*', $open_pos );
|
171 |
}
|
172 |
+
|
173 |
+
break;
|
174 |
+
}
|
175 |
}
|
176 |
|
177 |
return $code;
|
189 |
*
|
190 |
* @since 3.7
|
191 |
*/
|
192 |
+
$default = [
|
193 |
'admin-bar',
|
194 |
'dashicons',
|
195 |
+
];
|
196 |
|
197 |
$array = explode( "\n", get_option( 'sbp_css_exceptions' ) );
|
198 |
+
$css_exceptions = [];
|
199 |
foreach ( $array as $key => $ex ) {
|
200 |
if ( trim( $ex ) != '' ) {
|
201 |
$css_exceptions[ $key ] = trim( $ex );
|
inc/js/admin-scripts.js
CHANGED
@@ -24,16 +24,14 @@
|
|
24 |
function admin_tab_switching() {
|
25 |
|
26 |
var nav_tab_selector = '.nav-tab-wrapper a';
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Default tab handling
|
30 |
-
*/
|
31 |
-
|
32 |
-
// make the first tab active by default
|
33 |
-
$( nav_tab_selector + ':first' ).addClass( 'nav-tab-active' );
|
34 |
|
35 |
// get the first tab href
|
36 |
-
|
|
|
|
|
|
|
|
|
37 |
|
38 |
// make all the tabs, except the first one hidden
|
39 |
$( '.sb-pack-tab' ).each( function( index, value ) {
|
@@ -42,6 +40,10 @@
|
|
42 |
}
|
43 |
} );
|
44 |
|
|
|
|
|
|
|
|
|
45 |
/**
|
46 |
* Listen for click events on nav-tab links
|
47 |
*/
|
@@ -51,6 +53,7 @@
|
|
51 |
$( this ).addClass( 'nav-tab-active' ).blur(); // add class to currently clicked selector
|
52 |
|
53 |
var clicked_tab = $( this ).attr( 'href' );
|
|
|
54 |
|
55 |
$( '.sb-pack-tab' ).each( function( index, value ) {
|
56 |
if ( '#' + $( this ).attr( 'id' ) !== clicked_tab ) {
|
@@ -62,7 +65,7 @@
|
|
62 |
} );
|
63 |
|
64 |
// prevent default behavior
|
65 |
-
event.preventDefault();
|
66 |
|
67 |
} );
|
68 |
}
|
24 |
function admin_tab_switching() {
|
25 |
|
26 |
var nav_tab_selector = '.nav-tab-wrapper a';
|
27 |
+
var initial_tab_href = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
// get the first tab href
|
30 |
+
if (window.location.hash) {
|
31 |
+
initial_tab_href = window.location.hash;
|
32 |
+
} else {
|
33 |
+
initial_tab_href = localStorage.getItem('sbp-current-page') || $(nav_tab_selector + ':first').attr('href');
|
34 |
+
}
|
35 |
|
36 |
// make all the tabs, except the first one hidden
|
37 |
$( '.sb-pack-tab' ).each( function( index, value ) {
|
40 |
}
|
41 |
} );
|
42 |
|
43 |
+
$( nav_tab_selector ).removeClass( 'nav-tab-active' ); // remove class from previous selector
|
44 |
+
$( nav_tab_selector + '[href=' + initial_tab_href + ']' ).addClass( 'nav-tab-active' ); // remove class from previous selector
|
45 |
+
window.location.hash = initial_tab_href;
|
46 |
+
|
47 |
/**
|
48 |
* Listen for click events on nav-tab links
|
49 |
*/
|
53 |
$( this ).addClass( 'nav-tab-active' ).blur(); // add class to currently clicked selector
|
54 |
|
55 |
var clicked_tab = $( this ).attr( 'href' );
|
56 |
+
localStorage.setItem('sbp-current-page', clicked_tab);
|
57 |
|
58 |
$( '.sb-pack-tab' ).each( function( index, value ) {
|
59 |
if ( '#' + $( this ).attr( 'id' ) !== clicked_tab ) {
|
65 |
} );
|
66 |
|
67 |
// prevent default behavior
|
68 |
+
// event.preventDefault();
|
69 |
|
70 |
} );
|
71 |
}
|
inc/js/lazyload.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
-
/* lazyload.js - v12.
|
2 |
* https://github.com/verlok/lazyload
|
3 |
* Copyright (c) 2019 Andrea Verlicchi; Licensed MIT */
|
4 |
-
function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.LazyLoad=e()}(this,function(){"use strict";var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,r=t&&"classList"in document.createElement("p"),o={elements_selector:"img",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},a=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var i=function(t,e){return t.getAttribute("data-"+e)},s=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},c=function(t){return"true"===i(t,"was-processed")},l=function(t,e){return s(t,"ll-timeout",e)},u=function(t){return i(t,"ll-timeout")},d=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},f=function(t,e){t._loadingCount+=e,0===t._elements.length&&0===t._loadingCount&&d(t._settings.callback_finish,t)},_=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},v=function(t,e,n){n&&t.setAttribute(e,n)},b=function(t,e){v(t,"sizes",i(t,e.data_sizes)),v(t,"srcset",i(t,e.data_srcset)),v(t,"src",i(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&_(n).forEach(function(t){b(t,e)});b(t,e)},IFRAME:function(t,e){v(t,"src",i(t,e.data_src))},VIDEO:function(t,e){_(t).forEach(function(t){v(t,"src",i(t,e.data_src))}),v(t,"src",i(t,e.data_src)),t.load()}},
|
5 |
-
//# sourceMappingURL=lazyload.min.js.map
|
1 |
+
/* lazyload.js - v12.4.0
|
2 |
* https://github.com/verlok/lazyload
|
3 |
* Copyright (c) 2019 Andrea Verlicchi; Licensed MIT */
|
4 |
+
function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function _iterableToArray(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.LazyLoad=e()}(this,function(){"use strict";var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,r=t&&"classList"in document.createElement("p"),o={elements_selector:"img",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},a=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var i=function(t,e){return t.getAttribute("data-"+e)},s=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},c=function(t){return"true"===i(t,"was-processed")},l=function(t,e){return s(t,"ll-timeout",e)},u=function(t){return i(t,"ll-timeout")},d=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},f=function(t,e){t._loadingCount+=e,0===t._elements.length&&0===t._loadingCount&&d(t._settings.callback_finish,t)},_=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},v=function(t,e,n){n&&t.setAttribute(e,n)},b=function(t,e){v(t,"sizes",i(t,e.data_sizes)),v(t,"srcset",i(t,e.data_srcset)),v(t,"src",i(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&_(n).forEach(function(t){b(t,e)});b(t,e)},IFRAME:function(t,e){v(t,"src",i(t,e.data_src))},VIDEO:function(t,e){_(t).forEach(function(t){v(t,"src",i(t,e.data_src))}),v(t,"poster",i(t,e.data_poster)),v(t,"src",i(t,e.data_src)),t.load()}},p=function(t,e){var n,r,o=e._settings,a=t.tagName,s=m[a];if(s)return s(t,o),f(e,1),void(e._elements=(n=e._elements,r=t,n.filter(function(t){return t!==r})));!function(t,e){var n=i(t,e.data_src),r=i(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,o)},g=function(t,e){r?t.classList.add(e):t.className+=(t.className?" ":"")+e},y=function(t,e){r?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},h=function(t,e,n){t.addEventListener(e,n)},E=function(t,e,n){t.removeEventListener(e,n)},w=function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)},A=function(t,e,n){var r=n._settings,o=e?r.class_loaded:r.class_error,a=e?r.callback_loaded:r.callback_error,i=t.target;y(i,r.class_loading),g(i,o),d(a,i,n),f(n,-1)},I=function(t,e){var n=function n(o){A(o,!0,e),w(t,n,r)},r=function r(o){A(o,!1,e),w(t,n,r)};!function(t,e,n){h(t,"load",e),h(t,"loadeddata",e),h(t,"error",n)}(t,n,r)},k=["IMG","IFRAME","VIDEO"],L=function(t,e){var n=e._observer;S(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},O=function(t){var e=u(t);e&&(clearTimeout(e),l(t,null))},x=function(t,e){var n=e._settings.load_delay,r=u(t);r||(r=setTimeout(function(){L(t,e),O(t)},n),l(t,r))},S=function(t,e,n){var r=e._settings;!n&&c(t)||(k.indexOf(t.tagName)>-1&&(I(t,e),g(t,r.class_loading)),p(t,e),function(t){s(t,"was-processed","true")}(t),d(r.callback_reveal,t,e),d(r.callback_set,t,e))},z=function(t){return!!n&&(t._observer=new IntersectionObserver(function(e){e.forEach(function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var r=n._settings;d(r.callback_enter,t,e,n),r.load_delay?x(t,n):L(t,n)}(e.target,e,t):function(t,e,n){var r=n._settings;d(r.callback_exit,t,e,n),r.load_delay&&O(t)}(e.target,e,t)})},{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},C=["IMG","IFRAME"],N=function(t,e){return function(t){return t.filter(function(t){return!c(t)})}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},M=function(t){var e=t._settings;_toConsumableArray(e.container.querySelectorAll("."+e.class_error)).forEach(function(t){y(t,e.class_error),function(t){s(t,"was-processed",null)}(t)}),t.update()},R=function(e,n){var r;this._settings=function(t){return _extends({},o,t)}(e),this._loadingCount=0,z(this),this.update(n),r=this,t&&window.addEventListener("online",function(t){M(r)})};return R.prototype={update:function(t){var n,r=this,o=this._settings;(this._elements=N(t,o),!e&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(o)&&((n=this)._elements.forEach(function(t){-1!==C.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),S(t,n))}),this._elements=N(t,o)),this._elements.forEach(function(t){r._observer.observe(t)})):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){S(t,this,e)},loadAll:function(){var t=this;this._elements.forEach(function(e){L(e,t)})}},t&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)a(t,n);else a(t,e)}(R,window.lazyLoadOptions),R});
|
|
inc/sbp-minifier.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
@@ -10,117 +10,121 @@ if( !defined( 'ABSPATH' ) ) {
|
|
10 |
---------------------------------------------------------------------------------------------------------*/
|
11 |
|
12 |
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
10 |
---------------------------------------------------------------------------------------------------------*/
|
11 |
|
12 |
|
13 |
+
class SBP_HTML_Minifier {
|
14 |
+
// Minify settings
|
15 |
+
protected $minify_css = true;
|
16 |
+
protected $minify_js = false;
|
17 |
+
protected $info_comment = true;
|
18 |
+
protected $remove_comments = true;
|
19 |
+
|
20 |
+
// Minify variables
|
21 |
+
protected $html;
|
22 |
+
|
23 |
+
public function __construct( $html ) {
|
24 |
+
if ( ! empty( $html ) ) {
|
25 |
+
$this->parseHTML( $html );
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
public function parseHTML( $html ) {
|
30 |
+
$this->html = $this->minifyHTML( $html );
|
31 |
+
|
32 |
+
if ( $this->info_comment ) {
|
33 |
+
$this->html .= "\n" . $this->bottomComment( $html, $this->html );
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function minifyHTML( $html ) {
|
38 |
+
$pattern = '/<(?<script>script).*?<\/script\s*>|<(?<style>style).*?<\/style\s*>|<!(?<comment>--).*?-->|<(?<tag>[\/\w.:-]*)(?:".*?"|\'.*?\'|[^\'">]+)*>|(?<text>((<[^!\/\w.:-])?[^<]*)+)|/si';
|
39 |
+
preg_match_all( $pattern, $html, $matches, PREG_SET_ORDER );
|
40 |
+
$overriding = false;
|
41 |
+
$raw_tag = false;
|
42 |
+
// Variable reused for output
|
43 |
+
$html = '';
|
44 |
+
foreach ( $matches as $token ) {
|
45 |
+
$tag = ( isset( $token['tag'] ) ) ? strtolower( $token['tag'] ) : null;
|
46 |
+
|
47 |
+
$content = $token[0];
|
48 |
+
|
49 |
+
if ( is_null( $tag ) ) {
|
50 |
+
if ( ! empty( $token['script'] ) ) {
|
51 |
+
$strip = $this->minify_js;
|
52 |
+
} elseif ( ! empty( $token['style'] ) ) {
|
53 |
+
$strip = $this->minify_css;
|
54 |
+
} elseif ( $content == '<!--sbp-html-minifier no minifier-->' ) {
|
55 |
+
$overriding = ! $overriding;
|
56 |
+
|
57 |
+
// Don't print the comments
|
58 |
+
continue;
|
59 |
+
} elseif ( $this->remove_comments ) {
|
60 |
+
if ( ! $overriding && $raw_tag != 'textarea' ) {
|
61 |
+
// Remove any HTML comments, except MSIE conditional comments
|
62 |
+
$content = preg_replace( '/<!--(?!\s*(?:\[if [^\]]+]|<!|>))(?:(?!-->).)*-->/s', '', $content );
|
63 |
+
}
|
64 |
+
}
|
65 |
+
} else {
|
66 |
+
if ( $tag == 'pre' || $tag == 'textarea' ) {
|
67 |
+
$raw_tag = $tag;
|
68 |
+
} elseif ( $tag == '/pre' || $tag == '/textarea' ) {
|
69 |
+
$raw_tag = false;
|
70 |
+
} else {
|
71 |
+
if ( $raw_tag || $overriding ) {
|
72 |
+
$strip = false;
|
73 |
+
} else {
|
74 |
+
$strip = true;
|
75 |
+
// Remove all empty attributes, except action, alt, content, src
|
76 |
+
$content = preg_replace( '/(\s+)(\w++(?<!\baction|\balt|\bcontent|\bsrc)="")/',
|
77 |
+
'$1',
|
78 |
+
$content );
|
79 |
+
// Remove all space before the end of self-closing XHTML tags
|
80 |
+
// JavaScript excluded
|
81 |
+
$content = str_replace( ' />', '/>', $content );
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( $strip ) {
|
87 |
+
$content = $this->removeWhiteSpace( $content );
|
88 |
+
}
|
89 |
+
|
90 |
+
$html .= $content;
|
91 |
+
}
|
92 |
+
|
93 |
+
return $html;
|
94 |
+
}
|
95 |
+
|
96 |
+
protected function removeWhiteSpace( $str ) {
|
97 |
+
$str = str_replace( "\t", ' ', $str );
|
98 |
+
$str = str_replace( "\n", '', $str );
|
99 |
+
$str = str_replace( "\r", '', $str );
|
100 |
+
|
101 |
+
while ( stristr( $str, ' ' ) ) {
|
102 |
+
$str = str_replace( ' ', ' ', $str );
|
103 |
+
}
|
104 |
+
|
105 |
+
return $str;
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function bottomComment( $raw, $minified ) {
|
109 |
+
$raw = strlen( $raw );
|
110 |
+
$minified = strlen( $minified );
|
111 |
+
$savings = ( $raw - $minified ) / $raw * 100;
|
112 |
+
$savings = round( $savings, 2 );
|
113 |
+
|
114 |
+
return '<!-- HTML minified; size reduced ' . $savings . '% (from ' . $raw . ' bytes down to ' . $minified . ' bytes) -->';
|
115 |
+
}
|
116 |
+
|
117 |
+
public function __toString() {
|
118 |
+
return $this->html;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
function sbp_html_minifier_finish( $html ) {
|
123 |
+
return new SBP_HTML_Minifier( $html );
|
124 |
+
}
|
125 |
+
|
126 |
+
function sbp_html_minifier_start() {
|
127 |
+
ob_start( 'sbp_html_minifier_finish' );
|
128 |
+
}
|
129 |
+
|
130 |
+
add_action( 'get_header', 'sbp_html_minifier_start' );
|
inc/settings.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
@@ -10,6 +10,72 @@ if ( ! class_exists( 'Speed_Booster_Pack_Options' ) ) {
|
|
10 |
class Speed_Booster_Pack_Options {
|
11 |
|
12 |
private $sbp_options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
/*--------------------------------------------------------------------------------------------------------
|
15 |
Construct the plugin object
|
@@ -17,139 +83,37 @@ if ( ! class_exists( 'Speed_Booster_Pack_Options' ) ) {
|
|
17 |
|
18 |
public function __construct() {
|
19 |
|
20 |
-
add_action( 'admin_init',
|
21 |
-
add_action( 'admin_menu',
|
22 |
-
add_action( 'wp_footer', array( $this, 'sbp_detected_scripts_handle' ), 999 );
|
23 |
-
add_action( 'wp_footer', array( $this, 'sbp_detected_scripts_src' ), 999 );
|
24 |
-
add_action( 'wp_footer', array( $this, 'sbp_detected_styles_handle' ), 999 );
|
25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
} // END public function __construct
|
27 |
|
28 |
|
29 |
public function sbp_admin_init() {
|
30 |
|
31 |
register_setting( 'speed_booster_settings_group', 'sbp_settings' );
|
32 |
-
register_setting( 'speed_booster_settings_group', 'sbp_integer' );
|
33 |
register_setting( 'speed_booster_settings_group', 'sbp_css_exceptions' );
|
34 |
-
register_setting( 'speed_booster_settings_group', '
|
35 |
-
|
36 |
-
register_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions1' );
|
37 |
-
register_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions2' );
|
38 |
-
register_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions3' );
|
39 |
-
register_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions4' );
|
40 |
-
|
41 |
-
register_setting( 'speed_booster_settings_group', 'sbp_defer_exceptions1' );
|
42 |
-
register_setting( 'speed_booster_settings_group', 'sbp_defer_exceptions2' );
|
43 |
-
register_setting( 'speed_booster_settings_group', 'sbp_defer_exceptions3' );
|
44 |
-
register_setting( 'speed_booster_settings_group', 'sbp_defer_exceptions4' );
|
45 |
|
46 |
} // END public function admin_init
|
47 |
|
48 |
-
|
49 |
-
/*--------------------------------------------------------------------------------------------------------
|
50 |
-
Get enqueued scripts handles
|
51 |
-
---------------------------------------------------------------------------------------------------------*/
|
52 |
-
|
53 |
-
public function sbp_detected_scripts_handle( $handles = array() ) {
|
54 |
-
|
55 |
-
global $wp_scripts;
|
56 |
-
|
57 |
-
|
58 |
-
// scripts
|
59 |
-
foreach ( $wp_scripts->registered as $registered ) {
|
60 |
-
$script_urls[ $registered->handle ] = $registered->src;
|
61 |
-
}
|
62 |
-
|
63 |
-
// if empty
|
64 |
-
if ( empty( $handles ) ) {
|
65 |
-
$handles = array_merge( $wp_scripts->done );
|
66 |
-
array_values( $handles );
|
67 |
-
}
|
68 |
-
// output of values
|
69 |
-
$get_enqueued_scripts_handle = '';
|
70 |
-
foreach ( $handles as $handle ) {
|
71 |
-
if ( ! empty( $script_urls[ $handle ] ) ) {
|
72 |
-
$get_enqueued_scripts_handle .= $handle . '<br />';
|
73 |
-
}
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
update_option( 'all_theme_scripts_handle', $get_enqueued_scripts_handle );
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
-
/*--------------------------------------------------------------------------------------------------------
|
82 |
-
Get enqueued scripts src path
|
83 |
-
---------------------------------------------------------------------------------------------------------*/
|
84 |
-
|
85 |
-
public function sbp_detected_scripts_src( $handles = array() ) {
|
86 |
-
|
87 |
-
global $wp_scripts;
|
88 |
-
|
89 |
-
// scripts
|
90 |
-
foreach ( $wp_scripts->registered as $registered ) {
|
91 |
-
$script_urls[ $registered->handle ] = $registered->src;
|
92 |
-
}
|
93 |
-
|
94 |
-
// if empty
|
95 |
-
if ( empty( $handles ) ) {
|
96 |
-
$handles = array_merge( $wp_scripts->done );
|
97 |
-
array_values( $handles );
|
98 |
-
}
|
99 |
-
// output of values
|
100 |
-
$get_enqueued_scripts_src = '';
|
101 |
-
foreach ( $handles as $handle ) {
|
102 |
-
if ( ! empty( $script_urls[ $handle ] ) ) {
|
103 |
-
$get_enqueued_scripts_src .= $script_urls[ $handle ] . '<br />';
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
update_option( 'all_theme_scripts_src', $get_enqueued_scripts_src );
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
|
113 |
-
/*--------------------------------------------------------------------------------------------------------
|
114 |
-
Get enqueued style handles
|
115 |
-
---------------------------------------------------------------------------------------------------------*/
|
116 |
-
|
117 |
-
public function sbp_detected_styles_handle( $handles = array() ) {
|
118 |
-
|
119 |
-
global $wp_styles;
|
120 |
-
|
121 |
-
|
122 |
-
// scripts
|
123 |
-
foreach ( $wp_styles->registered as $registered ) {
|
124 |
-
$style_urls[ $registered->handle ] = $registered->src;
|
125 |
-
}
|
126 |
-
|
127 |
-
// if empty
|
128 |
-
if ( empty( $handles ) ) {
|
129 |
-
$handles = array_merge( $wp_styles->queue );
|
130 |
-
array_values( $handles );
|
131 |
-
}
|
132 |
-
// output of values
|
133 |
-
$get_enqueued_styles_handle = '';
|
134 |
-
foreach ( $handles as $handle ) {
|
135 |
-
if ( ! empty( $style_urls[ $handle ] ) ) {
|
136 |
-
$get_enqueued_styles_handle .= $handle . '<br />';
|
137 |
-
}
|
138 |
-
|
139 |
-
}
|
140 |
-
|
141 |
-
update_option( 'all_theme_styles_handle', $get_enqueued_styles_handle );
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
|
146 |
/*--------------------------------------------------------------------------------------------------------
|
147 |
Sanitize Options
|
148 |
---------------------------------------------------------------------------------------------------------*/
|
149 |
|
150 |
public function sbp_sanitize( $input ) {
|
151 |
|
152 |
-
$output =
|
153 |
|
154 |
foreach ( $input as $key => $tigu ) {
|
155 |
|
@@ -181,16 +145,20 @@ if ( ! class_exists( 'Speed_Booster_Pack_Options' ) ) {
|
|
181 |
public function sbp_add_menu() {
|
182 |
|
183 |
global $sbp_settings_page;
|
184 |
-
$sbp_settings_page = add_menu_page( __( 'Speed Booster Options', 'speed-booster-pack' ),
|
185 |
-
|
186 |
-
'
|
187 |
-
|
|
|
|
|
|
|
|
|
|
|
188 |
|
189 |
} // END public function add_menu()
|
190 |
|
191 |
|
192 |
public function sbp_plugin_settings_page() {
|
193 |
-
|
194 |
if ( ! current_user_can( 'manage_options' ) ) {
|
195 |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
196 |
}
|
@@ -202,90 +170,29 @@ if ( ! class_exists( 'Speed_Booster_Pack_Options' ) ) {
|
|
202 |
|
203 |
global $sbp_options;
|
204 |
|
205 |
-
// Global variables used in plugin options page
|
206 |
-
$get_enqueued_scripts_handle = get_option( 'all_theme_scripts_handle' );
|
207 |
-
$get_enqueued_scripts_src = get_option( 'all_theme_scripts_src' );
|
208 |
-
$get_enqueued_styles_handle = get_option( 'all_theme_styles_handle' );
|
209 |
-
|
210 |
-
// fallback for image compression integer
|
211 |
-
if ( get_option( 'sbp_integer' ) ) {
|
212 |
-
$this->image_compression = get_option( 'sbp_integer' );
|
213 |
-
} else {
|
214 |
-
$this->image_compression = 75;
|
215 |
-
}
|
216 |
$this->plugin_url = plugin_dir_url( dirname( __FILE__ ) );
|
217 |
|
218 |
// fallback for stylesheets exception handle
|
219 |
-
|
220 |
-
$css_exceptions = get_option( 'sbp_css_exceptions' );
|
221 |
-
} else {
|
222 |
-
$css_exceptions = '';
|
223 |
-
}
|
224 |
-
|
225 |
-
/*--------------------------------------------------------------------------------------------------------*/
|
226 |
|
227 |
-
|
228 |
-
|
229 |
-
} else {
|
230 |
-
$js_footer_exceptions1 = '';
|
231 |
-
}
|
232 |
|
233 |
-
if ( get_option( 'sbp_js_footer_exceptions2' ) ) {
|
234 |
-
$js_footer_exceptions2 = get_option( 'sbp_js_footer_exceptions2' );
|
235 |
-
} else {
|
236 |
-
$js_footer_exceptions2 = '';
|
237 |
-
}
|
238 |
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
}
|
244 |
|
245 |
-
if ( get_option( 'sbp_js_footer_exceptions4' ) ) {
|
246 |
-
$js_footer_exceptions4 = get_option( 'sbp_js_footer_exceptions4' );
|
247 |
-
} else {
|
248 |
-
$js_footer_exceptions4 = '';
|
249 |
-
}
|
250 |
|
251 |
/*--------------------------------------------------------------------------------------------------------*/
|
252 |
|
253 |
|
254 |
-
|
255 |
-
if ( get_option( 'sbp_defer_exceptions1' ) ) {
|
256 |
-
$defer_exceptions1 = get_option( 'sbp_defer_exceptions1' );
|
257 |
-
} else {
|
258 |
-
$defer_exceptions1 = '';
|
259 |
-
}
|
260 |
-
|
261 |
-
if ( get_option( 'sbp_defer_exceptions2' ) ) {
|
262 |
-
$defer_exceptions2 = get_option( 'sbp_defer_exceptions2' );
|
263 |
-
} else {
|
264 |
-
$defer_exceptions2 = '';
|
265 |
-
}
|
266 |
-
|
267 |
-
if ( get_option( 'sbp_defer_exceptions3' ) ) {
|
268 |
-
$defer_exceptions3 = get_option( 'sbp_defer_exceptions3' );
|
269 |
-
} else {
|
270 |
-
$defer_exceptions3 = '';
|
271 |
-
}
|
272 |
-
|
273 |
-
if ( get_option( 'sbp_defer_exceptions4' ) ) {
|
274 |
-
$defer_exceptions4 = get_option( 'sbp_defer_exceptions4' );
|
275 |
-
} else {
|
276 |
-
$defer_exceptions4 = '';
|
277 |
-
}
|
278 |
-
|
279 |
-
/*--------------------------------------------------------------------------------------------------------*/
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
// Render the plugin options page HTML
|
284 |
include( SPEED_BOOSTER_PACK_PATH . 'inc/template/options.php' );
|
285 |
|
286 |
} // END public function sbp_plugin_settings_page()
|
287 |
|
288 |
-
|
289 |
} // END class Speed_Booster_Pack_Options
|
290 |
|
291 |
} // END if(!class_exists('Speed_Booster_Pack_Options'))
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
10 |
class Speed_Booster_Pack_Options {
|
11 |
|
12 |
private $sbp_options;
|
13 |
+
private $exclude_from_move = [
|
14 |
+
'html5.js',
|
15 |
+
'show_ads.js',
|
16 |
+
'histats.com/js',
|
17 |
+
'ws.amazon.com/widgets',
|
18 |
+
'/ads/',
|
19 |
+
'intensedebate.com',
|
20 |
+
'scripts.chitika.net/',
|
21 |
+
'jotform.com/',
|
22 |
+
'gist.github.com',
|
23 |
+
'forms.aweber.com',
|
24 |
+
'video.unrulymedia.com',
|
25 |
+
'stats.wp.com',
|
26 |
+
'stats.wordpress.com',
|
27 |
+
'widget.rafflecopter.com',
|
28 |
+
'widget-prime.rafflecopter.com',
|
29 |
+
'releases.flowplayer.org',
|
30 |
+
'c.ad6media.fr',
|
31 |
+
'cdn.stickyadstv.com',
|
32 |
+
'www.smava.de',
|
33 |
+
'contextual.media.net',
|
34 |
+
'app.getresponse.com',
|
35 |
+
'adserver.reklamstore.com',
|
36 |
+
's0.wp.com',
|
37 |
+
'wprp.zemanta.com',
|
38 |
+
'files.bannersnack.com',
|
39 |
+
'smarticon.geotrust.com',
|
40 |
+
'js.gleam.io',
|
41 |
+
'ir-na.amazon-adsystem.com',
|
42 |
+
'web.ventunotech.com',
|
43 |
+
'verify.authorize.net',
|
44 |
+
'ads.themoneytizer.com',
|
45 |
+
'embed.finanzcheck.de',
|
46 |
+
'imagesrv.adition.com',
|
47 |
+
'js.juicyads.com',
|
48 |
+
'form.jotformeu.com',
|
49 |
+
'speakerdeck.com',
|
50 |
+
'content.jwplatform.com',
|
51 |
+
'ads.investingchannel.com',
|
52 |
+
'app.ecwid.com',
|
53 |
+
'www.industriejobs.de',
|
54 |
+
's.gravatar.com',
|
55 |
+
'googlesyndication.com',
|
56 |
+
'a.optmstr.com',
|
57 |
+
'a.optmnstr.com',
|
58 |
+
'a.opmnstr.com',
|
59 |
+
'adthrive.com',
|
60 |
+
'mediavine.com',
|
61 |
+
'js.hsforms.net',
|
62 |
+
'googleadservices.com',
|
63 |
+
'f.convertkit.com',
|
64 |
+
'recaptcha/api.js',
|
65 |
+
'mailmunch.co',
|
66 |
+
'apps.shareaholic.com',
|
67 |
+
'dsms0mj1bbhn4.cloudfront.net',
|
68 |
+
'nutrifox.com',
|
69 |
+
'code.tidio.co',
|
70 |
+
'www.uplaunch.com',
|
71 |
+
'widget.reviewability.com',
|
72 |
+
'embed-cdn.gettyimages.com/widgets.js',
|
73 |
+
'app.mailerlite.com',
|
74 |
+
'ck.page',
|
75 |
+
'window.adsbygoogle',
|
76 |
+
'google_ad_client',
|
77 |
+
'googletag.display',
|
78 |
+
];
|
79 |
|
80 |
/*--------------------------------------------------------------------------------------------------------
|
81 |
Construct the plugin object
|
83 |
|
84 |
public function __construct() {
|
85 |
|
86 |
+
add_action( 'admin_init', [ $this, 'sbp_admin_init' ] );
|
87 |
+
add_action( 'admin_menu', [ $this, 'sbp_add_menu' ] );
|
|
|
|
|
|
|
88 |
|
89 |
+
// TODO: Move this to more appropriate place.
|
90 |
+
global $sbp_js_footer_exceptions;
|
91 |
+
$sbp_js_footer_exceptions = explode( PHP_EOL, get_option( 'sbp_js_footer_exceptions' ) );
|
92 |
+
$sbp_js_footer_exceptions = array_map( function ( $item ) {
|
93 |
+
$item = trim( $item );
|
94 |
+
|
95 |
+
return $item;
|
96 |
+
},
|
97 |
+
$sbp_js_footer_exceptions );
|
98 |
+
$sbp_js_footer_exceptions = array_merge( $this->exclude_from_move, $sbp_js_footer_exceptions );
|
99 |
} // END public function __construct
|
100 |
|
101 |
|
102 |
public function sbp_admin_init() {
|
103 |
|
104 |
register_setting( 'speed_booster_settings_group', 'sbp_settings' );
|
|
|
105 |
register_setting( 'speed_booster_settings_group', 'sbp_css_exceptions' );
|
106 |
+
register_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
|
108 |
} // END public function admin_init
|
109 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
/*--------------------------------------------------------------------------------------------------------
|
111 |
Sanitize Options
|
112 |
---------------------------------------------------------------------------------------------------------*/
|
113 |
|
114 |
public function sbp_sanitize( $input ) {
|
115 |
|
116 |
+
$output = [];
|
117 |
|
118 |
foreach ( $input as $key => $tigu ) {
|
119 |
|
145 |
public function sbp_add_menu() {
|
146 |
|
147 |
global $sbp_settings_page;
|
148 |
+
$sbp_settings_page = add_menu_page( __( 'Speed Booster Options', 'speed-booster-pack' ),
|
149 |
+
__( 'Speed Booster', 'speed-booster-pack' ),
|
150 |
+
'manage_options',
|
151 |
+
'sbp-options',
|
152 |
+
[
|
153 |
+
$this,
|
154 |
+
'sbp_plugin_settings_page',
|
155 |
+
],
|
156 |
+
plugin_dir_url( __FILE__ ) . 'images/icon-16x16.png' );
|
157 |
|
158 |
} // END public function add_menu()
|
159 |
|
160 |
|
161 |
public function sbp_plugin_settings_page() {
|
|
|
162 |
if ( ! current_user_can( 'manage_options' ) ) {
|
163 |
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
164 |
}
|
170 |
|
171 |
global $sbp_options;
|
172 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
173 |
$this->plugin_url = plugin_dir_url( dirname( __FILE__ ) );
|
174 |
|
175 |
// fallback for stylesheets exception handle
|
176 |
+
$css_exceptions = get_option( 'sbp_css_exceptions' );
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
+
// fallback for javascript exception handle
|
179 |
+
$js_footer_exceptions = get_option( 'sbp_js_footer_exceptions' );
|
|
|
|
|
|
|
180 |
|
|
|
|
|
|
|
|
|
|
|
181 |
|
182 |
+
$js_footer_exceptions1 = get_option( 'sbp_js_footer_exceptions1' );
|
183 |
+
$js_footer_exceptions2 = get_option( 'sbp_js_footer_exceptions2' );
|
184 |
+
$js_footer_exceptions3 = get_option( 'sbp_js_footer_exceptions3' );
|
185 |
+
$js_footer_exceptions4 = get_option( 'sbp_js_footer_exceptions4' );
|
|
|
186 |
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
/*--------------------------------------------------------------------------------------------------------*/
|
189 |
|
190 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
// Render the plugin options page HTML
|
192 |
include( SPEED_BOOSTER_PACK_PATH . 'inc/template/options.php' );
|
193 |
|
194 |
} // END public function sbp_plugin_settings_page()
|
195 |
|
|
|
196 |
} // END class Speed_Booster_Pack_Options
|
197 |
|
198 |
} // END if(!class_exists('Speed_Booster_Pack_Options'))
|
inc/template/notice.php
CHANGED
@@ -1,20 +1,26 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
-
|
6 |
}
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
<
|
11 |
-
<
|
|
|
|
|
|
|
|
|
12 |
<p>
|
13 |
-
<a href="admin.php?page=sbp-options" class="button button-primary button-hero"><?php esc_html_e('Get started',
|
14 |
-
|
|
|
|
|
15 |
</p>
|
16 |
<button type="button" onclick="sbp_dismissNotice();" class="notice-dismiss"><span
|
17 |
-
class="screen-reader-text"><?php esc_html_e('Dismiss this notice.', 'speed-booster-pack'); ?></span>
|
18 |
</button>
|
19 |
</div>
|
20 |
<style>
|
@@ -30,10 +36,10 @@ if( !defined( 'ABSPATH' ) ) {
|
|
30 |
<script>
|
31 |
function sbp_dismissNotice() {
|
32 |
jQuery("#sbp-notice").hide();
|
33 |
-
var data = {
|
34 |
-
jQuery.get('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', data, function(response) {
|
35 |
data = JSON.parse(response);
|
36 |
-
if(data["Status"] == 0) {
|
37 |
console.log("dismissed");
|
38 |
}
|
39 |
});
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
+
die;
|
6 |
}
|
7 |
|
8 |
+
?>
|
9 |
+
<div class="notice sbp-notice" id="sbp-notice">
|
10 |
+
<img src="<?php echo esc_url( plugins_url( 'images/logo.png', dirname( __FILE__ ) ) ); ?>" width="80">
|
11 |
+
<h1><?php esc_html_e( 'Welcome to Speed Booster Pack', 'speed-booster-pack' ); ?></h1>
|
12 |
+
<p><?php printf( esc_html__( 'Thank you for installing Speed Booster Pack! Check out the %sPlugin settings%s for new features that can make your site load faster.',
|
13 |
+
'speed-booster-pack' ),
|
14 |
+
'<a href="admin.php?page=sbp-options">',
|
15 |
+
'</a>' ); ?></p>
|
16 |
<p>
|
17 |
+
<a href="admin.php?page=sbp-options" class="button button-primary button-hero"><?php esc_html_e( 'Get started',
|
18 |
+
'speed-booster-pack' ); ?></a>
|
19 |
+
<a href="https://optimocha.com/?ref=sbp" class="button button-primary button-hero"
|
20 |
+
target="_blank"><?php esc_html_e( 'Pro Optimization Service', 'speed-booster-pack' ); ?></a>
|
21 |
</p>
|
22 |
<button type="button" onclick="sbp_dismissNotice();" class="notice-dismiss"><span
|
23 |
+
class="screen-reader-text"><?php esc_html_e( 'Dismiss this notice.', 'speed-booster-pack' ); ?></span>
|
24 |
</button>
|
25 |
</div>
|
26 |
<style>
|
36 |
<script>
|
37 |
function sbp_dismissNotice() {
|
38 |
jQuery("#sbp-notice").hide();
|
39 |
+
var data = {action: 'sbp_dismiss_notices'};
|
40 |
+
jQuery.get('<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>', data, function (response) {
|
41 |
data = JSON.parse(response);
|
42 |
+
if (data["Status"] == 0) {
|
43 |
console.log("dismissed");
|
44 |
}
|
45 |
});
|
inc/template/notices/migrate_js_to_footer.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<div class="notice notice-warning">
|
2 |
+
<p><?php _e( '<strong>ATTENTION:</strong> In Speed Booster Pack settings, we\'ve written the JS optimization feature from scratch, and it seems that option is active in your website. To help you switch to the newly written code, we\'ve also made a migration button in the "Advanced Settings" tab.', 'speed-booster-pack' ); ?> <a href="admin.php?page=sbp-options#advanced-options" target="_blank"></p>
|
3 |
+
<p><?php _e('Migrate Now', 'speed-booster-pack'); ?></a></p>
|
4 |
+
</div>
|
inc/template/options.php
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
-
if( !defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
8 |
// handle closed postboxes
|
9 |
-
$user_id
|
10 |
$option_name = 'closedpostboxes_' . 'toplevel_page_sbp-options'; // use the "pagehook" ID
|
11 |
$option_arr = get_user_option( $option_name, $user_id ); // get the options for that page
|
12 |
|
@@ -24,687 +24,787 @@ if ( is_array( $option_arr ) && in_array( 'defer-from-footer', $option_arr ) ) {
|
|
24 |
|
25 |
<div class="wrap">
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
|
31 |
-
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
42 |
|
43 |
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
44 |
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
|
45 |
<?php settings_fields( 'speed_booster_settings_group' ); ?>
|
46 |
|
47 |
<?php
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
//general options panel
|
51 |
-
'general-options' =>
|
52 |
//General section
|
53 |
-
'sections' =>
|
54 |
-
|
55 |
'type' => 'section',
|
56 |
-
'label' => 'Safe Optimizations',
|
57 |
-
'items' =>
|
58 |
-
'query_strings'
|
59 |
-
'type'
|
60 |
-
'label'
|
61 |
-
'tooltip'
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
'
|
78 |
-
|
79 |
-
|
80 |
-
'
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
'
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
'options_group' => 'sbp_settings',
|
93 |
-
|
94 |
-
'
|
95 |
-
'type'
|
96 |
-
'label'
|
97 |
-
'tooltip'
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
'
|
103 |
-
'
|
104 |
-
'
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
'
|
111 |
-
|
112 |
-
|
113 |
-
'
|
114 |
-
|
115 |
-
|
116 |
-
'
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
'
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
'15' => '15',
|
124 |
'30' => '30',
|
125 |
'45' => '45',
|
126 |
'60' => '60',
|
127 |
-
|
128 |
-
'options_group' => 'sbp_settings',
|
129 |
-
|
130 |
-
'limit_post_revisions' =>
|
131 |
-
'type'
|
132 |
-
'label'
|
133 |
-
'tooltip'
|
134 |
-
|
135 |
-
|
136 |
-
'
|
137 |
-
'
|
138 |
-
'
|
139 |
-
'
|
140 |
-
'
|
141 |
-
'
|
142 |
-
'
|
143 |
-
'
|
144 |
-
'
|
|
|
145 |
'false' => 'Disable',
|
146 |
-
|
147 |
-
'options_group' => 'sbp_settings',
|
148 |
-
|
149 |
-
'autosave_interval'
|
150 |
-
'type'
|
151 |
-
'label'
|
152 |
-
'tooltip'
|
153 |
-
|
|
|
154 |
'1' => __( '1 minute', 'speed-booster-pack' ),
|
155 |
'2' => __( '2 minutes', 'speed-booster-pack' ),
|
156 |
'3' => __( '3 minutes', 'speed-booster-pack' ),
|
157 |
'4' => __( '4 minutes', 'speed-booster-pack' ),
|
158 |
'5' => __( '5 minutes', 'speed-booster-pack' ),
|
159 |
-
|
160 |
'options_group' => 'sbp_settings',
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
//advanced options panel
|
167 |
-
'advanced-options' =>
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
'type' => 'section',
|
172 |
'label' => __( 'Advanced Optimizations', 'speed-booster-pack' ),
|
173 |
-
'items' =>
|
174 |
-
'
|
175 |
-
'type'
|
176 |
-
'label'
|
177 |
-
'tooltip'
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
'
|
184 |
-
'
|
185 |
-
|
186 |
-
|
187 |
-
'
|
188 |
-
|
189 |
-
|
190 |
-
'
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
'
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
'
|
201 |
-
|
202 |
-
'options_group' => 'sbp_settings',
|
203 |
-
|
204 |
-
'
|
205 |
-
'type'
|
206 |
-
'label'
|
207 |
-
|
208 |
-
'
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
'
|
214 |
-
'
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
'
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
'
|
224 |
-
|
225 |
-
'
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
231 |
'type' => 'section',
|
232 |
'label' => __( 'JavaScript Optimization', 'speed-booster-pack' ),
|
233 |
-
'items' =>
|
234 |
-
'
|
235 |
-
'type'
|
236 |
-
'
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
'
|
242 |
-
'
|
243 |
-
|
244 |
-
'options_group' => 'sbp_settings',
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
'type'
|
250 |
-
'label'
|
251 |
-
|
252 |
-
'
|
253 |
-
'
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
'type' => 'text',
|
258 |
-
),
|
259 |
-
'sbp_js_footer_exceptions3' => array(
|
260 |
-
'type' => 'text',
|
261 |
-
),
|
262 |
-
'sbp_js_footer_exceptions4' => array(
|
263 |
-
'type' => 'text',
|
264 |
-
),
|
265 |
-
//guidance
|
266 |
-
'guidance_options_js' => array(
|
267 |
-
'type' => 'guidance',
|
268 |
-
'label' => __( 'As a guidance, here is a list of script handles and script paths of each enqueued script detected by our plugin:', 'speed-booster-pack' ),
|
269 |
-
),
|
270 |
-
),
|
271 |
-
),
|
272 |
-
//Exclude scripts from being deferred
|
273 |
-
array(
|
274 |
-
'type' => 'section',
|
275 |
-
'label' => __( 'Exclude scripts from being deferred', 'speed-booster-pack' ),
|
276 |
-
'items' => array(
|
277 |
-
'sbp_defer_exceptions1' => array(
|
278 |
-
'type' => 'text',
|
279 |
-
),
|
280 |
-
'sbp_defer_exceptions2' => array(
|
281 |
-
'type' => 'text',
|
282 |
-
),
|
283 |
-
'sbp_defer_exceptions3' => array(
|
284 |
-
'type' => 'text',
|
285 |
-
),
|
286 |
-
'sbp_defer_exceptions4' => array(
|
287 |
-
'type' => 'text',
|
288 |
-
),
|
289 |
-
'info' => array(
|
290 |
-
'type' => 'guidance',
|
291 |
-
'description_only' => true,
|
292 |
-
'description' => __( 'Enter one by text field, the handle part of the JS files that you want to be excluded from defer parsing option. For example: <code>jquery-core</code> If you want to exclude more than 4 scripts, you can use the following filter: <code>sbp_exclude_defer_scripts</code> which takes an array of script handles as params. If you don\'t know how to handle this, feel free to post on our support forums.', 'speed-booster-pack' ),
|
293 |
-
),
|
294 |
-
),
|
295 |
-
),
|
296 |
-
//need even more speed section
|
297 |
-
array(
|
298 |
'type' => 'section',
|
299 |
'label' => __( 'CSS Optimization', 'speed-booster-pack' ),
|
300 |
-
'items' =>
|
301 |
-
'sbp_css_async' =>
|
302 |
-
'type'
|
303 |
-
'label'
|
304 |
-
'tooltip'
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
'
|
310 |
-
'
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
'
|
315 |
-
|
316 |
-
|
317 |
-
'
|
318 |
-
|
319 |
-
|
320 |
-
|
|
|
|
|
|
|
|
|
|
|
321 |
//other options section
|
322 |
-
|
323 |
'type' => 'section',
|
324 |
'label' => __( 'Exclude CSS', 'speed-booster-pack' ),
|
325 |
-
'items' =>
|
326 |
-
'sbp_css_exceptions'
|
327 |
-
'type'
|
328 |
-
'
|
329 |
-
'
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
'
|
360 |
-
|
361 |
-
|
362 |
-
'
|
363 |
-
'
|
364 |
-
'
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
'
|
370 |
-
'
|
371 |
-
'
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
'
|
386 |
-
'
|
387 |
-
|
388 |
-
'options_group' => 'sbp_settings',
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
402 |
'header' => 'Header (default)',
|
403 |
'footer' => 'Footer',
|
404 |
-
|
405 |
-
|
406 |
-
'sbp_disable_display_features' =>
|
407 |
-
'type'
|
408 |
-
'label'
|
409 |
-
'tooltip'
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
'
|
415 |
-
'
|
416 |
-
'
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
'
|
422 |
-
'
|
423 |
-
|
424 |
-
|
425 |
-
'
|
426 |
-
|
427 |
-
|
428 |
-
'
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
'
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
|
444 |
//Start the tabs
|
445 |
foreach ( $sbp_options_array as $k => $values ) { ?>
|
446 |
-
|
447 |
-
|
448 |
|
449 |
<?php
|
450 |
|
451 |
-
|
452 |
-
|
|
|
|
|
|
|
|
|
|
|
453 |
}
|
|
|
454 |
|
455 |
?>
|
456 |
|
457 |
<?php if ( isset( $values['label'] ) ) { ?>
|
458 |
-
|
459 |
-
|
460 |
}
|
461 |
|
462 |
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
?>
|
467 |
-
<div class="postbox" id="<?php echo $k . "-" . $section; ?>">
|
468 |
-
<h3 class="hndle ui-sortable-handle" style="cursor: pointer;"><?php echo ( isset( $section_value['label'] ) ) ? $section_value['label'] : ""; ?></h3>
|
469 |
-
<div class="inside">
|
470 |
-
<?php
|
471 |
-
|
472 |
-
//Start the options
|
473 |
-
foreach ( $section_value['items'] as $item => $item_value ) {
|
474 |
-
|
475 |
-
if ( 'checkbox' == $item_value['type'] ) { ?>
|
476 |
-
<div class="onoffswitch-wrapper">
|
477 |
-
<?php if ( isset( $item_value['tooltip'] ) ) { ?>
|
478 |
-
<span class="tooltip-right"
|
479 |
-
data-tooltip="<?php echo $item_value['tooltip']; ?>">
|
480 |
-
<i class="dashicons dashicons-editor-help"></i>
|
481 |
-
</span>
|
482 |
-
<?php } ?>
|
483 |
-
<span class="chekbox-title"><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></span>
|
484 |
-
|
485 |
-
<div class="onoffswitch">
|
486 |
-
<div class="epsilon-toggle">
|
487 |
-
<input class="epsilon-toggle__input" type="checkbox" id="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>" name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>" value="1" <?php checked( 1, isset( $sbp_options[ $item ] ) ); ?> >
|
488 |
-
<div class="epsilon-toggle__items">
|
489 |
-
<span class="epsilon-toggle__track"></span>
|
490 |
-
<span class="epsilon-toggle__thumb"></span>
|
491 |
-
<svg class="epsilon-toggle__off" width="6" height="6" aria-hidden="true" role="img" focusable="false" viewBox="0 0 6 6">
|
492 |
-
<path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path>
|
493 |
-
</svg>
|
494 |
-
<svg class="epsilon-toggle__on" width="2" height="6" aria-hidden="true" role="img" focusable="false" viewBox="0 0 2 6">
|
495 |
-
<path d="M0 0h2v6H0z"></path>
|
496 |
-
</svg>
|
497 |
-
</div>
|
498 |
-
</div>
|
499 |
-
<label for="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"></label>
|
500 |
-
</div>
|
501 |
-
</div>
|
502 |
-
<?php }
|
503 |
-
if ( 'select' == $item_value['type'] ) { ?>
|
504 |
-
<p>
|
505 |
-
<?php if ( isset( $item_value['tooltip'] ) ) { ?>
|
506 |
-
<span class="tooltip-right"
|
507 |
-
data-tooltip="<?php echo $item_value['tooltip']; ?>">
|
508 |
-
<i class="dashicons dashicons-editor-help"></i>
|
509 |
-
</span>
|
510 |
-
<?php } ?>
|
511 |
-
<label for="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>" class="<?php echo ( isset( $item_value['label'] ) ) ? 'label-text' : ''; ?>"><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></label>
|
512 |
-
<select id="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
513 |
-
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>">
|
514 |
-
<?php
|
515 |
-
foreach ( $item_value['options'] as $option_k => $op_v ) {
|
516 |
-
?>
|
517 |
-
<option value="<?php echo $option_k; ?>" <?php selected( $option_k, $sbp_options[ $item ], true ); ?> ><?php echo $op_v; ?></option>
|
518 |
-
<?php
|
519 |
-
}
|
520 |
-
?>
|
521 |
-
</select>
|
522 |
-
</p>
|
523 |
-
<?php }
|
524 |
|
525 |
-
|
526 |
-
|
|
|
|
|
|
|
527 |
<?php
|
528 |
-
$default_value = ( isset( $item_value['default'] ) ) ? $item_value['default'] : "";
|
529 |
-
if ( isset( $item_value['options_group'] ) ) {
|
530 |
-
$op_text = ( isset( $sbp_options[ $item ] ) && "" != $sbp_options[ $item ] ) ? $sbp_options[ $item ] : $default_value;
|
531 |
-
} else {
|
532 |
-
$op_text = ( get_option( $item ) ) ? get_option( $item ) : $default_value;
|
533 |
-
}
|
534 |
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
$all_script_handles = explode( '<br />', $all_script_handles );
|
594 |
-
|
595 |
-
foreach ( $all_script_handles as $key => $value ) {
|
596 |
-
if ( ! empty( $value ) ) {
|
597 |
-
echo '<p>' . esc_html( $value ) . '</p>';
|
598 |
}
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
604 |
<?php
|
605 |
-
$
|
|
|
|
|
|
|
|
|
|
|
606 |
|
607 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
608 |
|
609 |
-
|
610 |
-
if ( ! empty( $value ) ) {
|
611 |
-
$value = parse_url( $value );
|
612 |
-
echo '<p>' . esc_html( str_replace( '/wp-content', '', $value['path'] ) ) . '</p>';
|
613 |
-
}
|
614 |
|
615 |
-
}
|
616 |
-
?>
|
617 |
-
</div>
|
618 |
-
</div>
|
619 |
-
</div>
|
620 |
-
<?php
|
621 |
-
}
|
622 |
-
if ( isset( $item_value['description_only'] ) && $item_value['description_only'] ) {
|
623 |
?>
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
}
|
629 |
|
630 |
}
|
631 |
-
|
632 |
?>
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
|
3 |
// Security control for vulnerability attempts
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
5 |
die;
|
6 |
}
|
7 |
|
8 |
// handle closed postboxes
|
9 |
+
$user_id = get_current_user_id();
|
10 |
$option_name = 'closedpostboxes_' . 'toplevel_page_sbp-options'; // use the "pagehook" ID
|
11 |
$option_arr = get_user_option( $option_name, $user_id ); // get the options for that page
|
12 |
|
24 |
|
25 |
<div class="wrap">
|
26 |
|
27 |
+
<div class="sb-pack clearfix">
|
28 |
|
29 |
+
<div class="col-main">
|
30 |
|
31 |
+
<h1 class="admin-page-title"><?php echo esc_html( get_admin_page_title() ); ?></h1>
|
32 |
|
33 |
+
<h2 class="nav-tab-wrapper wp-clearfix">
|
34 |
+
<a class="nav-tab" href="#general-options"><span class="dashicons dashicons-admin-generic"></span> <?php _e( 'General', 'speed-booster-pack' ); ?></a>
|
35 |
+
<a class="nav-tab" href="#advanced-options"><span class="dashicons dashicons-admin-settings"></span> <?php _e( 'Advanced', 'speed-booster-pack' ); ?></a>
|
36 |
+
<a class="nav-tab" href="#cdn-options"><span class="dashicons dashicons-admin-site-alt"></span> <?php _e( 'CDN', 'speed-booster-pack' ); ?></a>
|
37 |
+
<a class="nav-tab" href="#google-analytics"><span class="dashicons dashicons-chart-area"></span> <?php _e( 'Google Analytics', 'speed-booster-pack' ); ?></a>
|
38 |
+
<a class="nav-tab" href="#optimize-more"><span class="dashicons dashicons-dashboard"></span> <?php _e( 'Optimize More', 'speed-booster-pack' ); ?></a>
|
39 |
+
</h2>
|
40 |
|
41 |
+
<form method="post" action="admin.php?page=sbp-options" id="migrate_js_mover_form">
|
42 |
+
<input type="hidden" name="migrate_js_mover" value="1">
|
43 |
+
</form>
|
44 |
+
|
45 |
+
<form method="post" id="sbp-form" action="options.php">
|
46 |
|
47 |
<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
|
48 |
<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
|
49 |
<?php settings_fields( 'speed_booster_settings_group' ); ?>
|
50 |
|
51 |
<?php
|
52 |
+
$is_using_new_version = ! ( get_option( 'sbp_js_footer_exceptions1' ) || get_option( 'sbp_js_footer_exceptions2' ) || get_option( 'sbp_js_footer_exceptions3' ) || get_option( 'sbp_js_footer_exceptions4' ) );
|
53 |
+
|
54 |
+
if ( ! $is_using_new_version ) {
|
55 |
+
$exception_inputs = [
|
56 |
+
'sbp_js_footer_exceptions1' => [
|
57 |
+
'type' => 'text',
|
58 |
+
],
|
59 |
+
'sbp_js_footer_exceptions2' => [
|
60 |
+
'type' => 'text',
|
61 |
+
],
|
62 |
+
'sbp_js_footer_exceptions3' => [
|
63 |
+
'type' => 'text',
|
64 |
+
],
|
65 |
+
'sbp_js_footer_exceptions4' => [
|
66 |
+
'type' => 'text',
|
67 |
+
],
|
68 |
+
];
|
69 |
+
} else {
|
70 |
+
$exception_inputs = [
|
71 |
+
'sbp_js_footer_exceptions' => [
|
72 |
+
'label' => __( 'Each line will be taken as a separate exclusion rule; you can exclude URLs, parts of URLs or parts of inline scripts. DON\'T enter whole blocks of inline scripts!', 'speed-booster-pack' ),
|
73 |
+
'type' => 'textarea',
|
74 |
+
'name' => 'js_footer_exceptions',
|
75 |
+
],
|
76 |
+
];
|
77 |
+
}
|
78 |
+
|
79 |
+
$sbp_options_array = [
|
80 |
//general options panel
|
81 |
+
'general-options' => [
|
82 |
//General section
|
83 |
+
'sections' => [
|
84 |
+
[
|
85 |
'type' => 'section',
|
86 |
+
'label' => __( 'Safe Optimizations' ),
|
87 |
+
'items' => [
|
88 |
+
'query_strings' => [
|
89 |
+
'type' => 'checkbox',
|
90 |
+
'label' => __( 'Remove query strings', 'speed-booster-pack' ),
|
91 |
+
'tooltip' => __( 'Since most proxies do not cache resources with a ? in their URL, this option allows you to remove any query strings (version numbers) from static resources like CSS & JS files, thus improving your speed scores in services like GTmetrix, PageSpeed, YSlow and Pingdom.',
|
92 |
+
'speed-booster-pack' ),
|
93 |
+
'options_group' => 'sbp_settings',
|
94 |
+
],
|
95 |
+
'remove_emojis' => [
|
96 |
+
'type' => 'checkbox',
|
97 |
+
'label' => __( 'Remove WordPress Emoji scripts', 'speed-booster-pack' ),
|
98 |
+
'tooltip' => __( 'Emojis are fun and all, but if you are aren’t using them they actually load a JavaScript file (wp-emoji-release.min.js) on every page of your website. For a lot of businesses, this is not needed and simply adds load time to your site. So we recommend disabling this.',
|
99 |
+
'speed-booster-pack' ),
|
100 |
+
'options_group' => 'sbp_settings',
|
101 |
+
],
|
102 |
+
'remove_wsl' => [
|
103 |
+
'type' => 'checkbox',
|
104 |
+
'label' => __( 'Remove WordPress Shortlink', 'speed-booster-pack' ),
|
105 |
+
'tooltip' => __( 'WordPress URL shortening is sometimes useful, but it automatically adds an ugly code in your header, so you can remove it.',
|
106 |
+
'speed-booster-pack' ),
|
107 |
+
'options_group' => 'sbp_settings',
|
108 |
+
],
|
109 |
+
'remove_adjacent' => [
|
110 |
+
'type' => 'checkbox',
|
111 |
+
'label' => __( 'Remove Adjacent Posts Links', 'speed-booster-pack' ),
|
112 |
+
'tooltip' => __( 'WordPress incorrectly implements this feature that supposedly should fix a pagination issues but it messes up, so there is no reason to keep these around. However, some browsers may use Adjacent Posts Links to navigate your site, although you can remove it if you run a well designed theme.',
|
113 |
+
'speed-booster-pack' ),
|
114 |
+
'options_group' => 'sbp_settings',
|
115 |
+
],
|
116 |
+
'wml_link' => [
|
117 |
+
'type' => 'checkbox',
|
118 |
+
'label' => __( 'Remove Windows Live Writer Manifest',
|
119 |
+
'speed-booster-pack' ),
|
120 |
+
'tooltip' => __( 'Windows Live Writer (WLW) is a Microsoft application for composing and managing blog posts offline and publish them later. If you are not using Windows Live Writer application, you can remove it from the WP head.',
|
121 |
+
'speed-booster-pack' ),
|
122 |
+
'options_group' => 'sbp_settings',
|
123 |
+
],
|
124 |
+
'wp_generator' => [
|
125 |
+
'type' => 'checkbox',
|
126 |
+
'label' => __( 'Remove WordPress Version', 'speed-booster-pack' ),
|
127 |
+
'tooltip' => __( 'Remove the META tag that reveals the WordPress version you use. Not exactly a speed-related matter, but you should consider it as an important security measure.',
|
128 |
+
'speed-booster-pack' ),
|
129 |
+
'options_group' => 'sbp_settings',
|
130 |
+
],
|
131 |
+
'disable_self_pingbacks' => [
|
132 |
+
'type' => 'checkbox',
|
133 |
+
'label' => __( 'Disable Self Pingbacks', 'speed-booster-pack' ),
|
134 |
+
'tooltip' => __( 'A pingback is a special type of comment that’s created when you link to another blog post, as long as the other blog is set to accept pingbacks.',
|
135 |
+
'speed-booster-pack' ),
|
136 |
+
'options_group' => 'sbp_settings',
|
137 |
+
],
|
138 |
+
'remove_jquery_migrate' => [
|
139 |
+
'type' => 'checkbox',
|
140 |
+
'label' => __( 'Remove jQuery Migrate', 'speed-booster-pack' ),
|
141 |
+
'tooltip' => __( 'Remove the jquery-migrate.js script that helps older jQuery plugins to be compatible with new jQuery versions. You safely turn this setting on if your jQuery plugins are all new.',
|
142 |
+
'speed-booster-pack' ),
|
143 |
+
'options_group' => 'sbp_settings',
|
144 |
+
],
|
145 |
+
'disable_dashicons' => [
|
146 |
+
'type' => 'checkbox',
|
147 |
+
'label' => __( 'Remove Dashicons', 'speed-booster-pack' ),
|
148 |
+
'tooltip' => __( 'Remove Dashicons from front end.',
|
149 |
+
'speed-booster-pack' ),
|
150 |
+
'options_group' => 'sbp_settings',
|
151 |
+
],
|
152 |
+
'disable_heartbeat' => [
|
153 |
+
'type' => 'checkbox',
|
154 |
+
'label' => __( 'Disable Heartbeat', 'speed-booster-pack' ),
|
155 |
+
'tooltip' => __( 'Disable heartbeat everywhere ( used for autosaving and revision tracking ).',
|
156 |
+
'speed-booster-pack' ),
|
157 |
+
'options_group' => 'sbp_settings',
|
158 |
+
],
|
159 |
+
'heartbeat_frequency' => [
|
160 |
+
'type' => 'select',
|
161 |
+
'label' => __( 'Heartbeat frequency', 'speed-booster-pack' ),
|
162 |
+
'tooltip' => __( 'Controls how often the WordPress Heartbeat API is allowed to run. ',
|
163 |
+
'speed-booster-pack' ),
|
164 |
+
'options' => [
|
165 |
'15' => '15',
|
166 |
'30' => '30',
|
167 |
'45' => '45',
|
168 |
'60' => '60',
|
169 |
+
],
|
170 |
+
'options_group' => 'sbp_settings',
|
171 |
+
],
|
172 |
+
'limit_post_revisions' => [
|
173 |
+
'type' => 'select',
|
174 |
+
'label' => __( 'Limit Post Revisions', 'speed-booster-pack' ),
|
175 |
+
'tooltip' => __( 'Controls how many revisions WordPress will save ',
|
176 |
+
'speed-booster-pack' ),
|
177 |
+
'options' => [
|
178 |
+
'1' => '1',
|
179 |
+
'2' => '2',
|
180 |
+
'3' => '3',
|
181 |
+
'4' => '4',
|
182 |
+
'5' => '5',
|
183 |
+
'10' => '10',
|
184 |
+
'15' => '15',
|
185 |
+
'20' => '20',
|
186 |
+
'25' => '25',
|
187 |
+
'30' => '30',
|
188 |
'false' => 'Disable',
|
189 |
+
],
|
190 |
+
'options_group' => 'sbp_settings',
|
191 |
+
],
|
192 |
+
'autosave_interval' => [
|
193 |
+
'type' => 'select',
|
194 |
+
'label' => __( 'Autosave interval', 'speed-booster-pack' ),
|
195 |
+
'tooltip' => __( 'Controls how WordPress will autosave posts and pages while editing.',
|
196 |
+
'speed-booster-pack' ),
|
197 |
+
'options' => [
|
198 |
'1' => __( '1 minute', 'speed-booster-pack' ),
|
199 |
'2' => __( '2 minutes', 'speed-booster-pack' ),
|
200 |
'3' => __( '3 minutes', 'speed-booster-pack' ),
|
201 |
'4' => __( '4 minutes', 'speed-booster-pack' ),
|
202 |
'5' => __( '5 minutes', 'speed-booster-pack' ),
|
203 |
+
],
|
204 |
'options_group' => 'sbp_settings',
|
205 |
+
],
|
206 |
+
],
|
207 |
+
],
|
208 |
+
],
|
209 |
+
],
|
210 |
//advanced options panel
|
211 |
+
'advanced-options' => [
|
212 |
+
'sections' => [
|
213 |
+
[
|
214 |
+
'type' => 'section',
|
|
|
215 |
'label' => __( 'Advanced Optimizations', 'speed-booster-pack' ),
|
216 |
+
'items' => [
|
217 |
+
'sbp_optimize_fonts' => [
|
218 |
+
'type' => 'checkbox',
|
219 |
+
'label' => __( 'Optimize Google Fonts', 'speed-booster-pack' ),
|
220 |
+
'tooltip' => __( 'This feature effectively gathers all the Google Font URLs in your pages together, combines all of them in one URL and adds the famous "font-display:swap" CSS feature.',
|
221 |
+
'speed-booster-pack' ),
|
222 |
+
// TODO: Tooltip will be changed
|
223 |
+
'options_group' => 'sbp_settings',
|
224 |
+
],
|
225 |
+
'sbp_enable_lazy_load' => [
|
226 |
+
'type' => 'checkbox',
|
227 |
+
'label' => __( '(BETA)', 'speed-booster-pack' ) . ' ' . __( 'Enable lazy loader', 'speed-booster-pack' ),
|
228 |
+
'tooltip' => __( 'Check this option if you want to enable native lazy loading with fallback.',
|
229 |
+
'speed-booster-pack' ),
|
230 |
+
'options_group' => 'sbp_settings',
|
231 |
+
],
|
232 |
+
'enable_instant_page' => [
|
233 |
+
'type' => 'checkbox',
|
234 |
+
'label' => __( 'Enable instant.page', 'speed-booster-pack' ),
|
235 |
+
'tooltip' => __( 'Check this option if you want to use the instant.page link preloader. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.',
|
236 |
+
'speed-booster-pack' ),
|
237 |
+
'options_group' => 'sbp_settings',
|
238 |
+
],
|
239 |
+
'disable_cart_fragments' => [
|
240 |
+
'type' => 'checkbox',
|
241 |
+
'label' => __( 'WooCommerce: Disable cart fragments',
|
242 |
+
'speed-booster-pack' ),
|
243 |
+
'tooltip' => __( 'Check this option to disable WooCommerce's "cart fragments" script, which overrides all caching function to update cart totals on each page load in your theme header. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.',
|
244 |
+
'speed-booster-pack' ),
|
245 |
+
'options_group' => 'sbp_settings',
|
246 |
+
],
|
247 |
+
'dequeue_wc_scripts' => [
|
248 |
+
'type' => 'checkbox',
|
249 |
+
'label' => __( '(BETA)', 'speed-booster-pack' ) . ' ' . __( 'Remove WooCommerce scripts in non-WC pages',
|
250 |
+
'speed-booster-pack' ),
|
251 |
+
'tooltip' => __( 'Check this option if you want to remove WooCommerce scripts in non-WooCommerce pages. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.',
|
252 |
+
'speed-booster-pack' ),
|
253 |
+
'options_group' => 'sbp_settings',
|
254 |
+
],
|
255 |
+
'disable_password_strength_meter' => [
|
256 |
+
'type' => 'checkbox',
|
257 |
+
'label' => __( '(BETA)', 'speed-booster-pack' ) . ' ' . __( 'WooCommerce: Disable password strength meter',
|
258 |
+
'speed-booster-pack' ),
|
259 |
+
'tooltip' => __( 'Check this option if you want to disable WooCommerce password strength meter. This is a new and experimental feature; use with caution. If something goes wrong, simply uncheck this option and save the settings.',
|
260 |
+
'speed-booster-pack' ),
|
261 |
+
'options_group' => 'sbp_settings',
|
262 |
+
],
|
263 |
+
'disable_google_maps' => [
|
264 |
+
'type' => 'checkbox',
|
265 |
+
'label' => __( 'Remove Google Maps', 'speed-booster-pack' ),
|
266 |
+
'tooltip' => __( 'Remove Google Maps from front end. ',
|
267 |
+
'speed-booster-pack' ),
|
268 |
+
'options_group' => 'sbp_settings',
|
269 |
+
],
|
270 |
+
'remove_rest_api_links' => [
|
271 |
+
'type' => 'checkbox',
|
272 |
+
'label' => __( 'Remove REST API Links', 'speed-booster-pack' ),
|
273 |
+
'tooltip' => __( 'The WordPress REST API provides API endpoints for WordPress data types that allow developers to interact with sites remotely by sending and receiving JSON (JavaScript Object Notation) objects.',
|
274 |
+
'speed-booster-pack' ),
|
275 |
+
'options_group' => 'sbp_settings',
|
276 |
+
],
|
277 |
+
'remove_all_feeds' => [
|
278 |
+
'type' => 'checkbox',
|
279 |
+
'label' => __( 'Remove all RSS feed links', 'speed-booster-pack' ),
|
280 |
+
'tooltip' => __( 'This option will remove all RSS feed links to cleanup your WordPress header. It is also useful on Unicorn – The W3C Markup Validation Service to get rid out the “feed does not validate” error.',
|
281 |
+
'speed-booster-pack' ),
|
282 |
+
'options_group' => 'sbp_settings',
|
283 |
+
],
|
284 |
+
'minify_html_js' => [
|
285 |
+
'type' => 'checkbox',
|
286 |
+
'label' => __( 'Minify HTML', 'speed-booster-pack' ),
|
287 |
+
'tooltip' => __( 'Activate this option only if you don’t want to use other minify plugins or other speed optimization plugin that has minify option included. If something goes wrong, simply uncheck this option and save the settings.',
|
288 |
+
'speed-booster-pack' ),
|
289 |
+
'options_group' => 'sbp_settings',
|
290 |
+
],
|
291 |
+
],
|
292 |
+
],
|
293 |
+
[
|
294 |
'type' => 'section',
|
295 |
'label' => __( 'JavaScript Optimization', 'speed-booster-pack' ),
|
296 |
+
'items' => [
|
297 |
+
'break_warning' => [
|
298 |
+
'type' => 'warning',
|
299 |
+
'text' => __( 'This feature has the MOST potential to break your site! Please use with caution and test your website after enabling this option. Excluding inline scripts and/or JavaScript file URLs below might help fix the issues you might encounter.',
|
300 |
+
'speed-booster-pack' ),
|
301 |
+
],
|
302 |
+
'jquery_to_footer' => [
|
303 |
+
'type' => 'checkbox',
|
304 |
+
'label' => __( 'Move scripts to footer', 'speed-booster-pack' ),
|
305 |
+
'tooltip' => __( 'This option move all scripts to the footer while keeping stylesheets in the header to improve page loading speed and get a higher score on the major speed testing sites such as GTmetrix or other website speed testing tools',
|
306 |
+
'speed-booster-pack' ),
|
307 |
+
'options_group' => 'sbp_settings',
|
308 |
+
],
|
309 |
+
],
|
310 |
+
],
|
311 |
+
[
|
312 |
+
'type' => 'section',
|
313 |
+
'label' => __( 'Exclude scripts from being moved to the footer',
|
314 |
+
'speed-booster-pack' ),
|
315 |
+
'description' => __( 'Enter one JS handle per text field. Read more <a href="https://optimocha.com/speed-booster-pack-documentation/#exclude-scripts-from-being-moved-to-the-footer-50">detailed instructions</a> on this option on plugin documentation.',
|
316 |
+
'speed-booster-pack' ),
|
317 |
+
'items' => $exception_inputs,
|
318 |
+
],
|
319 |
+
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
320 |
'type' => 'section',
|
321 |
'label' => __( 'CSS Optimization', 'speed-booster-pack' ),
|
322 |
+
'items' => [
|
323 |
+
'sbp_css_async' => [
|
324 |
+
'type' => 'checkbox',
|
325 |
+
'label' => __( 'Inline all CSS', 'speed-booster-pack' ),
|
326 |
+
'tooltip' => __( 'Checking this option will inline the contents of all your stylesheets. This helps with the annoying render blocking error Google Page Speed Insights displays.',
|
327 |
+
'speed-booster-pack' ),
|
328 |
+
'options_group' => 'sbp_settings',
|
329 |
+
],
|
330 |
+
'sbp_css_minify' => [
|
331 |
+
'type' => 'checkbox',
|
332 |
+
'label' => __( 'Minify all (previously) inlined CSS',
|
333 |
+
'speed-booster-pack' ),
|
334 |
+
'tooltip' => __( 'Minifying all inlined CSS styles will optimize the CSS delivery and will eliminate the annoying message on Google Page Speed regarding to render-blocking css.',
|
335 |
+
'speed-booster-pack' ),
|
336 |
+
'options_group' => 'sbp_settings',
|
337 |
+
],
|
338 |
+
'sbp_footer_css' => [
|
339 |
+
'type' => 'checkbox',
|
340 |
+
'label' => __( 'Move all inlined CSS into the footer',
|
341 |
+
'speed-booster-pack' ),
|
342 |
+
'tooltip' => __( 'Inserting all CSS styles inline to the footer is a sensitive option that will eliminate render-blocking CSS warning in Google Page Speed test. If there is something broken after activation, you need to disable this option. Please note that before enabling this sensitive option, it is strongly recommended that you also enable the “ Move scripts to the footer” option.',
|
343 |
+
'speed-booster-pack' ),
|
344 |
+
'options_group' => 'sbp_settings',
|
345 |
+
],
|
346 |
+
],
|
347 |
+
],
|
348 |
//other options section
|
349 |
+
[
|
350 |
'type' => 'section',
|
351 |
'label' => __( 'Exclude CSS', 'speed-booster-pack' ),
|
352 |
+
'items' => [
|
353 |
+
'sbp_css_exceptions' => [
|
354 |
+
'type' => 'textarea',
|
355 |
+
'name' => 'css_exceptions',
|
356 |
+
'label' => __( 'Exclude styles from being inlined and/or minified option: ',
|
357 |
+
'speed-booster-pack' ),
|
358 |
+
'description' => __( 'Enter one by line, the handles of CSS files or the final part of the style URL.',
|
359 |
+
'speed-booster-pack' ),
|
360 |
+
],
|
361 |
+
],
|
362 |
+
],
|
363 |
+
// [
|
364 |
+
// 'type' => 'section',
|
365 |
+
// 'label' => __( 'Debug', 'speed-booster-pack' ), // TODO: Check section title
|
366 |
+
// 'items' => [
|
367 |
+
// 'sbp_disable_temporarily' => [
|
368 |
+
// 'type' => 'checkbox',
|
369 |
+
// 'label' => __( 'Disable Temporarily', 'speed-booster-pack' ),
|
370 |
+
// // TODO: Change setting label
|
371 |
+
// 'tooltip' => __( 'This option disable Speed Booster Pack plugin features temporarily. If you want to do some bugfix or debug, it could be really useful. Don\'t forget to disable this option after you use it.',
|
372 |
+
// 'speed-booster-pack' ),
|
373 |
+
// // TODO: Change setting tooltip
|
374 |
+
// 'options_group' => 'sbp_settings',
|
375 |
+
// ],
|
376 |
+
// ],
|
377 |
+
// ],
|
378 |
+
],
|
379 |
+
],
|
380 |
+
'cdn-options' => [
|
381 |
+
'sections' => [
|
382 |
+
[
|
383 |
+
'type' => 'section',
|
384 |
+
'label' => __( 'CDN', 'speed-booster-pack' ),
|
385 |
+
'description' => __( 'CDN options that allow you to rewrite your site URLs with your CDN URLs.',
|
386 |
+
'speed-booster-pack' ),
|
387 |
+
'items' => [
|
388 |
+
'sbp_enable_cdn' => [
|
389 |
+
'type' => 'checkbox',
|
390 |
+
'label' => __( 'Enable CDN Rewrite', 'speed-booster-pack' ),
|
391 |
+
'tooltip' => __( 'Enables rewriting of your site URLs with your CDN URLs',
|
392 |
+
'speed-booster-pack' ),
|
393 |
+
'options_group' => 'sbp_settings',
|
394 |
+
],
|
395 |
+
'sbp_cdn_url' => [
|
396 |
+
'type' => 'text',
|
397 |
+
'label' => __( 'CDN URL', 'speed-booster-pack' ),
|
398 |
+
'tooltip' => __( 'Enter your CDN URL without the trailing slash. Example: https://cdn.example.com',
|
399 |
+
'speed-booster-pack' ),
|
400 |
+
'options_group' => 'sbp_settings',
|
401 |
+
],
|
402 |
+
'sbp_cdn_included_directories' => [
|
403 |
+
'type' => 'text',
|
404 |
+
'label' => __( 'Included Directories', 'speed-booster-pack' ),
|
405 |
+
'tooltip' => __( 'Enter any directories you would like to be included in CDN rewriting, separated by commas (,). Default: wp-content,wp-includes',
|
406 |
+
'speed-booster-pack' ),
|
407 |
+
'options_group' => 'sbp_settings',
|
408 |
+
'default' => 'wp-content,wp-includes',
|
409 |
+
],
|
410 |
+
'sbp_cdn_exclusions' => [
|
411 |
+
'type' => 'text',
|
412 |
+
'label' => __( 'CDN Exclusions', 'speed-booster-pack' ),
|
413 |
+
'tooltip' => __( 'Enter any directories or file extensions you would like to be excluded from CDN rewriting, separated by commas (,). Default: .php',
|
414 |
+
'speed-booster-pack' ),
|
415 |
+
'options_group' => 'sbp_settings',
|
416 |
+
'default' => '.php',
|
417 |
+
],
|
418 |
+
],
|
419 |
+
],
|
420 |
+
],
|
421 |
+
],
|
422 |
+
'google-analytics' => [
|
423 |
+
'sections' => [
|
424 |
+
[
|
425 |
+
'type' => 'section',
|
426 |
+
'label' => __( 'Google Analytics', 'speed-booster-pack' ),
|
427 |
+
'description' => __( 'Optimization options for Google Analytics.',
|
428 |
+
'speed-booster-pack' ),
|
429 |
+
'items' => [
|
430 |
+
'sbp_enable_local_analytics' => [
|
431 |
+
'type' => 'checkbox',
|
432 |
+
'label' => __( 'Enable Local Analytics', 'speed-booster-pack' ),
|
433 |
+
'tooltip' => __( 'Enable syncing of the Google Analytics script to your own server.',
|
434 |
+
'speed-booster-pack' ),
|
435 |
+
'options_group' => 'sbp_settings',
|
436 |
+
],
|
437 |
+
'sbp_ga_tracking_id' => [
|
438 |
+
'type' => 'text',
|
439 |
+
'label' => __( 'Tracking ID', 'speed-booster-pack' ),
|
440 |
+
'tooltip' => __( 'Enter your Google Analytics tracking ID',
|
441 |
+
'speed-booster-pack' ),
|
442 |
+
'options_group' => 'sbp_settings',
|
443 |
+
],
|
444 |
+
'sbp_tracking_position' => [
|
445 |
+
'type' => 'select',
|
446 |
+
'label' => __( 'Tracking code position', 'speed-booster-pack' ),
|
447 |
+
'tooltip' => __( 'Load your GA script in the header or footer of the site. Default - header',
|
448 |
+
'speed-booster-pack' ),
|
449 |
+
'options_group' => 'sbp_settings',
|
450 |
+
'options' => [
|
451 |
'header' => 'Header (default)',
|
452 |
'footer' => 'Footer',
|
453 |
+
],
|
454 |
+
],
|
455 |
+
'sbp_disable_display_features' => [
|
456 |
+
'type' => 'checkbox',
|
457 |
+
'label' => __( 'Disable Display Features', 'speed-booster-pack' ),
|
458 |
+
'tooltip' => __( 'Disable marketing and advertising which generates a 2nd HTTP request',
|
459 |
+
'speed-booster-pack' ),
|
460 |
+
'options_group' => 'sbp_settings',
|
461 |
+
],
|
462 |
+
'sbp_anonymize_ip' => [
|
463 |
+
'type' => 'checkbox',
|
464 |
+
'label' => __( 'Anonymize IP', 'speed-booster-pack' ),
|
465 |
+
'tooltip' => __( 'Shorten visitor IP to comply with privacy restrictions in some countries.',
|
466 |
+
'speed-booster-pack' ),
|
467 |
+
'options_group' => 'sbp_settings',
|
468 |
+
],
|
469 |
+
'sbp_track_loggedin_admins' => [
|
470 |
+
'type' => 'checkbox',
|
471 |
+
'label' => __( 'Track Admins', 'speed-booster-pack' ),
|
472 |
+
'tooltip' => __( 'Include logged in WordPress admins in your GA report.',
|
473 |
+
'speed-booster-pack' ),
|
474 |
+
'options_group' => 'sbp_settings',
|
475 |
+
],
|
476 |
+
'sbp_bounce_rate' => [
|
477 |
+
'type' => 'text',
|
478 |
+
'label' => __( 'Adjust Bounce Rate', 'speed-booster-pack' ),
|
479 |
+
'tooltip' => __( 'Set a timeout limit in seconds to better evaluate the quality of your traffic (1 - 100)',
|
480 |
+
'speed-booster-pack' ),
|
481 |
+
'options_group' => 'sbp_settings',
|
482 |
+
],
|
483 |
+
'sbp_monsterinsights' => [
|
484 |
+
'type' => 'checkbox',
|
485 |
+
'label' => __( 'MonsterInsights Integration', 'speed-booster-pack' ),
|
486 |
+
'tooltip' => __( 'Allows MonsterInsights to manage your Google Analytics while still using the locally hosted analytics.js generated by Speed Booster Pack',
|
487 |
+
'speed-booster-pack' ),
|
488 |
+
'options_group' => 'sbp_settings',
|
489 |
+
],
|
490 |
+
],
|
491 |
+
],
|
492 |
+
],
|
493 |
+
],
|
494 |
+
];
|
495 |
+
|
496 |
+
$sbp_alert_box = '<div class="sbp-static-notice bg-red"><span class="dashicons dashicons-warning"></span> ' . __( 'Activating these settings might cause conflicts with other plugins or your theme, resulting in broken styles or scripts. Use with caution!',
|
497 |
+
'speed-booster-pack' ) . '</div>';
|
498 |
+
|
499 |
+
$sbp_deprecated_js_footer_alert_box = '<div class="sbp-static-notice bg-yellow"><span class="dashicons dashicons-warning"></span> ' . __( 'We recoded the feature that moves all inline scripts and JavaScript files to footer. The old code is deprecated now and will be removed in the new versions. Right now, you\'re using the old feature and it\'s still working, but you need to migrate to the new feature as soon as possible. And make sure that you jot down the current JS optimization exclusion settings!',
|
500 |
+
'speed-booster-pack' ) . '<br /><br /><button type="submit" form="migrate_js_mover_form" class="button button-primary">' . __( 'Migrate to the new feature now!',
|
501 |
+
'speed-booster-pack' ) . '</button></div>';
|
502 |
+
|
503 |
+
?>
|
504 |
+
|
505 |
+
<?php /*
|
506 |
+
<div id="sbp-dashboard" class="sb-pack-tab">
|
507 |
+
|
508 |
+
<div class="feature-box postbox">
|
509 |
+
<div class="inside clearfix">
|
510 |
+
<img class="feature-box-left feature-box-image"
|
511 |
+
src="<?php echo SPEED_BOOSTER_PACK_URL ?>inc/images/optimocha.png" alt="Optimocha"/>
|
512 |
+
<div class="feature-box-right">
|
513 |
+
<h2 class="feature-box-title"><?php _e( 'Dashboard', 'speed-booster-pack' ) ?></h2>
|
514 |
+
<p class="feature-box-description"><?php _e( 'Optimocha is a tailored speed optimization service where you can get your website optimized by a speed optimization expert. With a one-time "investment", your website will be taken care of real people. <strong>A significant speed improvement is guaranteed</strong>, so can be sure that your investment will return to you with a faster website!',
|
515 |
+
'speed-booster-pack' ); ?></p>
|
516 |
+
<p class="feature-box-description"><?php _e( 'Or, if you\'d like to have someone maintain your website speed, keep everything up-to-date and ensure your website is secure all the time; you can purchase Optimocha\'s monthly optimization & maintenance packages. <strong>Annual payments have more and more benefits</strong>, be sure to check them out!',
|
517 |
+
'speed-booster-pack' ); ?></p>
|
518 |
+
</p>
|
519 |
+
</div>
|
520 |
+
</div>
|
521 |
+
</div>
|
522 |
+
|
523 |
+
</div><!--#optimize-more-->
|
524 |
+
*/ ?>
|
525 |
+
|
526 |
+
<?php
|
527 |
|
528 |
//Start the tabs
|
529 |
foreach ( $sbp_options_array as $k => $values ) { ?>
|
530 |
+
<!-- Tab sections -->
|
531 |
+
<div id="<?php echo $k; ?>" class="sb-pack-tab">
|
532 |
|
533 |
<?php
|
534 |
|
535 |
+
if ( $k == 'advanced-options' || $k == 'google-analytics' || $k == 'cdn-options' ) {
|
536 |
+
echo $sbp_alert_box;
|
537 |
+
}
|
538 |
+
|
539 |
+
if ( $k == 'advanced-options' ) {
|
540 |
+
if ( ! $is_using_new_version ) {
|
541 |
+
echo $sbp_deprecated_js_footer_alert_box;
|
542 |
}
|
543 |
+
}
|
544 |
|
545 |
?>
|
546 |
|
547 |
<?php if ( isset( $values['label'] ) ) { ?>
|
548 |
+
<h3><?php echo $values['label']; ?></h3>
|
549 |
+
<?php
|
550 |
}
|
551 |
|
552 |
|
553 |
+
//Start the sections
|
554 |
+
foreach ( $values['sections'] as $section => $section_value ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 |
|
556 |
+
?>
|
557 |
+
<div class="postbox" id="<?php echo $k . "-" . $section; ?>">
|
558 |
+
<h3 class="hndle ui-sortable-handle"
|
559 |
+
style="cursor: pointer;"><?php echo ( isset( $section_value['label'] ) ) ? $section_value['label'] : ""; ?></h3>
|
560 |
+
<div class="inside">
|
561 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
+
//Start the options
|
564 |
+
foreach ( $section_value['items'] as $item => $item_value ) {
|
565 |
+
|
566 |
+
if ( 'checkbox' == $item_value['type'] ) { ?>
|
567 |
+
<div class="onoffswitch-wrapper">
|
568 |
+
<?php if ( isset( $item_value['tooltip'] ) ) { ?>
|
569 |
+
<span class="tooltip-right"
|
570 |
+
data-tooltip="<?php echo $item_value['tooltip']; ?>">
|
571 |
+
<i class="dashicons dashicons-editor-help"></i>
|
572 |
+
</span>
|
573 |
+
<?php } ?>
|
574 |
+
<span class="chekbox-title"><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></span>
|
575 |
+
|
576 |
+
<div class="onoffswitch">
|
577 |
+
<div class="epsilon-toggle">
|
578 |
+
<input class="epsilon-toggle__input" type="checkbox"
|
579 |
+
id="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
580 |
+
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
581 |
+
value="1" <?php checked( 1,
|
582 |
+
isset( $sbp_options[ $item ] ) ); ?> >
|
583 |
+
<div class="epsilon-toggle__items">
|
584 |
+
<span class="epsilon-toggle__track"></span>
|
585 |
+
<span class="epsilon-toggle__thumb"></span>
|
586 |
+
<svg class="epsilon-toggle__off" width="6" height="6"
|
587 |
+
aria-hidden="true" role="img" focusable="false"
|
588 |
+
viewBox="0 0 6 6">
|
589 |
+
<path d="M3 1.5c.8 0 1.5.7 1.5 1.5S3.8 4.5 3 4.5 1.5 3.8 1.5 3 2.2 1.5 3 1.5M3 0C1.3 0 0 1.3 0 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"></path>
|
590 |
+
</svg>
|
591 |
+
<svg class="epsilon-toggle__on" width="2" height="6"
|
592 |
+
aria-hidden="true" role="img" focusable="false"
|
593 |
+
viewBox="0 0 2 6">
|
594 |
+
<path d="M0 0h2v6H0z"></path>
|
595 |
+
</svg>
|
596 |
+
</div>
|
597 |
+
</div>
|
598 |
+
<label for="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"></label>
|
599 |
+
</div>
|
600 |
+
</div>
|
601 |
+
<?php }
|
602 |
+
if ( 'select' == $item_value['type'] ) { ?>
|
603 |
+
<p>
|
604 |
+
<?php if ( isset( $item_value['tooltip'] ) ) { ?>
|
605 |
+
<span class="tooltip-right"
|
606 |
+
data-tooltip="<?php echo $item_value['tooltip']; ?>">
|
607 |
+
<i class="dashicons dashicons-editor-help"></i>
|
608 |
+
</span>
|
609 |
+
<?php } ?>
|
610 |
+
<label for="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
611 |
+
class="<?php echo ( isset( $item_value['label'] ) ) ? 'label-text' : ''; ?>"><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></label>
|
612 |
+
<select id="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
613 |
+
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>">
|
614 |
+
<?php
|
615 |
+
foreach ( $item_value['options'] as $option_k => $op_v ) {
|
616 |
+
?>
|
617 |
+
<option value="<?php echo $option_k; ?>" <?php selected( $option_k,
|
618 |
+
$sbp_options[ $item ],
|
619 |
+
true ); ?> ><?php echo $op_v; ?></option>
|
620 |
+
<?php
|
|
|
|
|
|
|
|
|
|
|
621 |
}
|
622 |
+
?>
|
623 |
+
</select>
|
624 |
+
</p>
|
625 |
+
<?php }
|
626 |
+
|
627 |
+
if ( 'link' == $item_value['type'] ) { ?>
|
628 |
+
<p>
|
629 |
+
<a href="<?php echo $item_value['url']; ?>"
|
630 |
+
class="button <?php echo $item_value['class']; ?>"><?php echo $item_value['text']; ?></a>
|
631 |
+
</p>
|
632 |
+
<?php }
|
633 |
+
|
634 |
+
if ( 'text' == $item_value['type'] ) { ?>
|
635 |
+
<p>
|
636 |
<?php
|
637 |
+
$default_value = ( isset( $item_value['default'] ) ) ? $item_value['default'] : "";
|
638 |
+
if ( isset( $item_value['options_group'] ) ) {
|
639 |
+
$op_text = ( isset( $sbp_options[ $item ] ) && "" != $sbp_options[ $item ] ) ? $sbp_options[ $item ] : $default_value;
|
640 |
+
} else {
|
641 |
+
$op_text = ( get_option( $item ) ) ? get_option( $item ) : $default_value;
|
642 |
+
}
|
643 |
|
644 |
+
?>
|
645 |
+
<?php if ( isset( $item_value['tooltip'] ) ) { ?>
|
646 |
+
<span class="tooltip-right"
|
647 |
+
data-tooltip="<?php echo $item_value['tooltip']; ?>">
|
648 |
+
<i class="dashicons dashicons-editor-help"></i>
|
649 |
+
</span>
|
650 |
+
<?php } ?>
|
651 |
+
<label for="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
652 |
+
class="<?php echo ( isset( $item_value['label'] ) ) ? 'label-text' : ''; ?>"><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></label>
|
653 |
+
|
654 |
+
<input id="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
655 |
+
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
656 |
+
type="text" value="<?php echo esc_attr( $op_text ); ?>"/>
|
657 |
+
</p>
|
658 |
+
<?php }
|
659 |
+
|
660 |
+
if ( 'textarea' === $item_value['type'] && 'css_exceptions' === $item_value['name'] ) { ?>
|
661 |
+
<h4><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></h4>
|
662 |
+
<p>
|
663 |
+
<textarea cols="50" rows="3"
|
664 |
+
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
665 |
+
id="<?php echo $item; ?>"><?php echo wp_kses_post( $css_exceptions ); ?></textarea>
|
666 |
+
</p>
|
667 |
+
<p class="description">
|
668 |
+
<?php echo isset( $item_value['description'] ) ? $item_value['description'] : ''; ?>
|
669 |
+
</p>
|
670 |
+
<?php }
|
671 |
+
|
672 |
+
if ( 'textarea' === $item_value['type'] && 'js_footer_exceptions' === $item_value['name'] ) { ?>
|
673 |
+
<h4><?php echo ( isset( $item_value['label'] ) ) ? $item_value['label'] : ''; ?></h4>
|
674 |
+
<p>
|
675 |
+
<textarea cols="50" rows="3"
|
676 |
+
name="<?php echo ( isset( $item_value['options_group'] ) ) ? $item_value['options_group'] . '[' . $item . ']' : $item; ?>"
|
677 |
+
id="<?php echo $item; ?>"><?php echo wp_kses_post( $js_footer_exceptions ); ?></textarea>
|
678 |
+
</p>
|
679 |
+
<p class="description">
|
680 |
+
<?php echo isset( $item_value['description'] ) ? $item_value['description'] : ''; ?>
|
681 |
+
</p>
|
682 |
+
<?php }
|
683 |
+
|
684 |
+
if ( 'warning' == $item_value['type'] ) {
|
685 |
+
?>
|
686 |
+
<div class="sbp-warning <?php echo isset( $item_value['background'] ) ? $item_value['background'] : 'bg-red' ?>">
|
687 |
+
<?php if ( isset( $item_value['icon'] ) ): ?><span
|
688 |
+
class="dashicons <?php echo $item_value['icon'] ?>"></span><?php endif; ?>
|
689 |
+
<?php echo $item_value['text']; ?>
|
690 |
+
</div>
|
691 |
+
<?php
|
692 |
+
}
|
693 |
|
694 |
+
}
|
|
|
|
|
|
|
|
|
695 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
696 |
?>
|
697 |
+
</div>
|
698 |
+
</div>
|
699 |
+
<?php
|
|
|
|
|
700 |
|
701 |
}
|
|
|
702 |
?>
|
703 |
+
</div> <!-- Tab sections -->
|
704 |
+
<?php } ?>
|
705 |
+
|
706 |
+
<div id="optimize-more" class="sb-pack-tab">
|
707 |
+
|
708 |
+
<div class="feature-box postbox">
|
709 |
+
<div class="inside clearfix">
|
710 |
+
<img class="feature-box-left feature-box-image"
|
711 |
+
src="<?php echo SPEED_BOOSTER_PACK_URL ?>inc/images/optimocha.png" alt="Optimocha"/>
|
712 |
+
<div class="feature-box-right">
|
713 |
+
<h2 class="feature-box-title"><?php _e( 'Speed up your website with Optimocha',
|
714 |
+
'speed-booster-pack' ) ?></h2>
|
715 |
+
<p class="feature-box-description"><?php _e( 'Optimocha is a tailored speed optimization service where you can get your website optimized by a speed optimization expert. With a one-time "investment", your website will be taken care of real people. <strong>A significant speed improvement is guaranteed</strong>, so can be sure that your investment will return to you with a faster website!',
|
716 |
+
'speed-booster-pack' ); ?></p>
|
717 |
+
<p class="feature-box-description"><?php _e( 'Or, if you\'d like to have someone maintain your website speed, keep everything up-to-date and ensure your website is secure all the time; you can purchase Optimocha\'s monthly optimization & maintenance packages. <strong>Annual payments have more and more benefits</strong>, be sure to check them out!',
|
718 |
+
'speed-booster-pack' ); ?></p>
|
719 |
+
<p class="feature-box-button"><a href="https://optimocha.com/?ref=sbp" target="_blank"
|
720 |
+
class="button button-primary button-large"><?php _e( "Speed Up Your Website!",
|
721 |
+
'speed-booster-pack' ); ?></a>
|
722 |
+
</p>
|
723 |
+
</div>
|
724 |
+
</div>
|
725 |
+
</div>
|
726 |
+
|
727 |
+
<div class="feature-box postbox">
|
728 |
+
<div class="inside clearfix">
|
729 |
+
<img class="feature-box-left feature-box-image"
|
730 |
+
src="<?php echo SPEED_BOOSTER_PACK_URL ?>inc/images/shortpixel.png" alt="ShortPixel"/>
|
731 |
+
<div class="feature-box-right">
|
732 |
+
<h2 class="feature-box-title"><?php _e( 'Optimize your images with ShortPixel',
|
733 |
+
'speed-booster-pack' ) ?></h2>
|
734 |
+
<p class="feature-box-description"><?php _e( 'Image optimization is essential for all websites - especially for sites with lots of images! ShortPixel Image Optimizer is probably the best image optimization plugin you can use in the WordPress ecosystem. By clicking the link below, <strong>you will get 50% more image optimization credits for the same price</strong>! The image optimization credits are good for unlimited websites and do not expire, so you can use your API key in all your websites, anytime you want.',
|
735 |
+
'speed-booster-pack' ); ?></p>
|
736 |
+
<p class="feature-box-button"><a href="https://optimocha.com/go/shortpixel"
|
737 |
+
target="_blank"
|
738 |
+
class="button button-primary button-large"><?php _e( "Optimize Your Images!",
|
739 |
+
'speed-booster-pack' ); ?></a>
|
740 |
+
</p>
|
741 |
+
</div>
|
742 |
+
</div>
|
743 |
+
</div>
|
744 |
+
|
745 |
+
<div class="feature-box postbox">
|
746 |
+
<div class="inside clearfix">
|
747 |
+
<img class="feature-box-left feature-box-image"
|
748 |
+
src="<?php echo SPEED_BOOSTER_PACK_URL ?>inc/images/wp-engine.png" alt="WP Engine"/>
|
749 |
+
<div class="feature-box-right">
|
750 |
+
<h2 class="feature-box-title"><?php _e( 'Get better hosting at WP Engine',
|
751 |
+
'speed-booster-pack' ) ?></h2>
|
752 |
+
<p class="feature-box-description"><?php _e( 'Choosing a good web hosting company make such a big difference, but often overlooked. It\'s understandable that people like to try cheap hosting packages in very large hosting companies, but if you\'re looking for a WordPress-centric hosting company with servers specially optimized for WordPress websites, be sure to check out WP Engine. Clicking the link below, <strong>you can get up to three months for free on annual payments!</strong>',
|
753 |
+
'speed-booster-pack' ); ?></p>
|
754 |
+
<p class="feature-box-button"><a href="https://optimocha.com/go/wpengine"
|
755 |
+
target="_blank"
|
756 |
+
class="button button-primary button-large"><?php _e( "Get Better Hosting!",
|
757 |
+
'speed-booster-pack' ); ?></a>
|
758 |
+
</p>
|
759 |
+
</div>
|
760 |
+
</div>
|
761 |
+
</div>
|
762 |
+
|
763 |
+
</div><!--#optimize-more-->
|
764 |
+
|
765 |
+
<div>
|
766 |
+
<?php submit_button( __( 'Save Changes', 'speed-booster-pack' ),
|
767 |
+
'primary large',
|
768 |
+
'submit',
|
769 |
+
false ); ?>
|
770 |
+
</div>
|
771 |
+
|
772 |
+
</form>
|
773 |
+
|
774 |
+
</div><!--/.col-main-->
|
775 |
+
|
776 |
+
<div class="col-side">
|
777 |
+
|
778 |
+
<div class="postbox">
|
779 |
+
<h3 class="hndle"><?php _e( 'Invest in More Speed!', 'speed-booster-pack' ); ?></h3>
|
780 |
+
<div class="inside">
|
781 |
+
<p><?php _e( 'People abandon pages that take more than a few seconds to load, which means slow pages lose you visitors (and money). You don’t want that to happen, do you?',
|
782 |
+
'speed-booster-pack' ) ?></p>
|
783 |
+
<p><?php _e( 'If you’re ready to <em>invest</em> in speeding up your website, click below for our professional, tailored speed optimization services!',
|
784 |
+
'speed-booster-pack' ); ?></a></p>
|
785 |
+
<p style="text-align:center"><a href="https://optimocha.com/?ref=sbp" target="_blank"
|
786 |
+
class="button button-primary button-large"><?php _e( "Speed Up Your Website!",
|
787 |
+
'speed-booster-pack' ); ?></a>
|
788 |
+
</p>
|
789 |
+
</div>
|
790 |
+
</div>
|
791 |
+
|
792 |
+
<div class="postbox">
|
793 |
+
<h3 class="hndle"><?php _e( 'Test Your Website', 'speed-booster-pack' ); ?></h3>
|
794 |
+
<div class="inside">
|
795 |
+
<p><?php _e( 'It\'s always a good idea to keep testing your website so you can track your website\'s speed. Click the buttons below to see how well your website performs in various speed test tools!',
|
796 |
+
'speed-booster-pack' ) ?></p>
|
797 |
+
<p style="text-align:center"><a href="https://gtmetrix.com/?url=<?php echo home_url( '/' ); ?>"
|
798 |
+
target="_blank"
|
799 |
+
class="button button-secondary"><?php _e( "Test on GTmetrix",
|
800 |
+
'speed-booster-pack' ); ?></a> <a
|
801 |
+
href="https://developers.google.com/speed/pagespeed/insights/?url=<?php echo home_url( '/' ); ?>"
|
802 |
+
target="_blank"
|
803 |
+
class="button button-secondary"><?php _e( "Test on Google PageSpeed",
|
804 |
+
'speed-booster-pack' ); ?></a>
|
805 |
+
</p>
|
806 |
+
</div>
|
807 |
+
</div>
|
808 |
+
</div>
|
809 |
+
</div><!--/.sb-pack-->
|
810 |
+
</div> <!-- end wrap div -->
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Plugin Name: Speed Booster Pack ⚡ PageSpeed & Performance Optimization
|
|
3 |
Contributors: optimocha
|
4 |
Tags: speed, pagespeed, optimization, performance, page speed
|
5 |
Requires at least: 4.6
|
6 |
-
Tested up to: 5.3
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.8.
|
9 |
License: GPLv3 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -95,13 +95,28 @@ All the time! We're always looking for new ways to get this plugin to a better s
|
|
95 |
|
96 |
== Changelog ==
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
= 3.8.4.3 =
|
99 |
|
100 |
*Release Date: 11 November 2019*
|
101 |
|
102 |
* Tested with WordPress 5.3.
|
103 |
-
* **Updated**: Updated instant.page to 3.0.0.
|
104 |
-
* **Updated**: Updated lazyload.js to 12.3.0.
|
105 |
* Changed the title of the plugin, and truncated the description.
|
106 |
|
107 |
= 3.8.4.2 =
|
3 |
Contributors: optimocha
|
4 |
Tags: speed, pagespeed, optimization, performance, page speed
|
5 |
Requires at least: 4.6
|
6 |
+
Tested up to: 5.3.2
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.8.5
|
9 |
License: GPLv3 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
95 |
|
96 |
== Changelog ==
|
97 |
|
98 |
+
= 3.8.5 =
|
99 |
+
|
100 |
+
*Release Date: 13 February 2020*
|
101 |
+
|
102 |
+
* **Added**: New feature - Optimize Google Fonts!
|
103 |
+
* **Updated**: Rewrote the whole JavaScript optimization feature! Hopefully it will work even better than our previous version. We also added a simple migration notice to not break current configurations, so be sure to migrate!
|
104 |
+
* **Removed**: JavaSript deferring feature has been removed - coming back in a future release!
|
105 |
+
* **Removed**: Deleted the non-working review nag.
|
106 |
+
* **Updated**: Updated `lazyload.js` to 12.4.0.
|
107 |
+
* **Updated**: Refactored the code a bit. Also cleaned up a lot of unnecessary stuff.
|
108 |
+
* **Fixed**: Speed Booster Pack is disabled for all (almost) Page Builder instances, and even a few other plugins that have front-end editors! You can also temporarily disable SBP for a specific URL by adding `sbp_disable=1` at the end of a URL.
|
109 |
+
* **Fixed**: Tabbed navigation in the settings page is working better now.
|
110 |
+
* **Fixed**: A small issue in the emoji disabler feature is fixed.
|
111 |
+
* **Fixed**: Some translatable strings are changed and a few _untranslatable_ strings are fixed.
|
112 |
+
|
113 |
= 3.8.4.3 =
|
114 |
|
115 |
*Release Date: 11 November 2019*
|
116 |
|
117 |
* Tested with WordPress 5.3.
|
118 |
+
* **Updated**: Updated `instant.page` to 3.0.0.
|
119 |
+
* **Updated**: Updated `lazyload.js` to 12.3.0.
|
120 |
* Changed the title of the plugin, and truncated the description.
|
121 |
|
122 |
= 3.8.4.2 =
|
speed-booster-pack.php
CHANGED
@@ -1,43 +1,38 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name:
|
4 |
-
* Plugin URI:
|
5 |
-
* Description:
|
6 |
-
* Author:
|
7 |
-
* Version:
|
8 |
-
* Author URI:
|
9 |
-
* License:
|
10 |
-
* License URI:
|
11 |
-
* Requires PHP:
|
12 |
-
* Text Domain
|
13 |
-
* Domain Path:
|
14 |
-
*
|
15 |
-
* Copyright 2015-2017
|
16 |
-
* Copyright 05/05/2017 - 10/04/2017
|
17 |
-
* Copyright 2017-2019
|
18 |
-
* Copyright 2019
|
19 |
-
*
|
20 |
-
*
|
21 |
-
*
|
22 |
-
*
|
23 |
-
*
|
24 |
-
*
|
25 |
-
*
|
26 |
-
*
|
27 |
-
*
|
28 |
-
*
|
29 |
-
*
|
30 |
-
*
|
31 |
-
*
|
32 |
-
|
33 |
-
*
|
34 |
-
* You should have received a copy of the GNU General Public License
|
35 |
-
* along with this program; if not, write to the Free software
|
36 |
-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
37 |
-
*/
|
38 |
|
39 |
// Security control for vulnerability attempts
|
40 |
-
if( !defined( 'ABSPATH' ) ) {
|
41 |
die;
|
42 |
}
|
43 |
|
@@ -46,25 +41,20 @@ if( !defined( 'ABSPATH' ) ) {
|
|
46 |
-----------------------------------------------------------------------------------------------------------*/
|
47 |
|
48 |
define( 'SPEED_BOOSTER_PACK_PATH', plugin_dir_path( __FILE__ ) );
|
49 |
-
define( 'SPEED_BOOSTER_PACK_URL',
|
50 |
-
define( 'SPEED_BOOSTER_PACK_VERSION', '3.8.
|
51 |
-
// Defining css position
|
52 |
-
define( 'SBP_FOOTER', 10 );
|
53 |
-
// Defining css last position
|
54 |
-
define( 'SBP_FOOTER_LAST', 99999 );
|
55 |
|
56 |
/*----------------------------------------------------------------------------------------------------------
|
57 |
Global Variables
|
58 |
-----------------------------------------------------------------------------------------------------------*/
|
59 |
|
60 |
-
$sbp_options = get_option( 'sbp_settings' );
|
61 |
|
62 |
/*----------------------------------------------------------------------------------------------------------
|
63 |
Main Plugin Class
|
64 |
-----------------------------------------------------------------------------------------------------------*/
|
65 |
|
66 |
if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
67 |
-
|
68 |
class Speed_Booster_Pack {
|
69 |
|
70 |
/*----------------------------------------------------------------------------------------------------------
|
@@ -75,13 +65,20 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
75 |
global $sbp_options;
|
76 |
|
77 |
// Enqueue admin scripts
|
78 |
-
add_action( 'admin_enqueue_scripts',
|
79 |
|
80 |
// load plugin textdomain
|
81 |
-
add_action( 'plugins_loaded',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
|
83 |
-
|
84 |
-
add_action(
|
85 |
|
86 |
// Load plugin settings page
|
87 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/settings.php' );
|
@@ -92,30 +89,26 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
92 |
$Speed_Booster_Pack_Core = new Speed_Booster_Pack_Core();
|
93 |
|
94 |
// Enqueue admin style
|
95 |
-
add_action( 'admin_enqueue_scripts',
|
96 |
-
|
97 |
|
98 |
// Filters
|
99 |
$this->path = plugin_basename( __FILE__ );
|
100 |
-
add_filter( "plugin_action_links_$this->path",
|
101 |
|
102 |
|
103 |
-
}
|
104 |
-
|
105 |
-
/*----------------------------------------------------------------------------------------------------------
|
106 |
-
Load plugin textdomain
|
107 |
-
-----------------------------------------------------------------------------------------------------------*/
|
108 |
-
|
109 |
-
function sbp_load_translation() {
|
110 |
-
load_plugin_textdomain( 'speed-booster-pack', false, SPEED_BOOSTER_PACK_PATH . '/lang/' );
|
111 |
-
}
|
112 |
-
|
113 |
|
114 |
/*----------------------------------------------------------------------------------------------------------
|
115 |
Display/dismiss admin notices if needed
|
116 |
-----------------------------------------------------------------------------------------------------------*/
|
117 |
|
118 |
function sbp_display_notices() {
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
if ( ! get_option( 'sbp_news' ) ) {
|
120 |
global $sbp_settings_page;
|
121 |
$screen = get_current_screen();
|
@@ -128,7 +121,7 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
128 |
function sbp_dismiss_notices() {
|
129 |
update_option( 'sbp_news', true );
|
130 |
|
131 |
-
return json_encode(
|
132 |
}
|
133 |
|
134 |
/*----------------------------------------------------------------------------------------------------------
|
@@ -136,26 +129,8 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
136 |
-----------------------------------------------------------------------------------------------------------*/
|
137 |
|
138 |
public static function sbp_activate() {
|
139 |
-
$sbp_options = get_option( 'sbp_settings', '' );
|
140 |
-
|
141 |
-
$url = get_site_url();
|
142 |
-
$response = wp_remote_get( $url, array() );
|
143 |
-
|
144 |
-
$get_enqueued_scripts_handle = get_option( 'all_theme_scripts_handle' );
|
145 |
-
$get_enqueued_scripts_src = get_option( 'all_theme_scripts_src' );
|
146 |
-
$get_enqueued_styles_handle = get_option( 'all_theme_styles_handle' );
|
147 |
-
|
148 |
-
if ( get_option( 'all_theme_scripts_handle' ) == '' ) {
|
149 |
-
update_option( 'all_theme_scripts_handle', $get_enqueued_scripts_handle );
|
150 |
-
}
|
151 |
-
|
152 |
-
if ( get_option( 'all_theme_scripts_src' ) == '' ) {
|
153 |
-
update_option( 'all_theme_scripts_src', $get_enqueued_scripts_src );
|
154 |
-
}
|
155 |
|
156 |
-
|
157 |
-
update_option( 'all_theme_styles_handle', $get_enqueued_styles_handle );
|
158 |
-
}
|
159 |
|
160 |
} // END public static function sb_activate
|
161 |
|
@@ -179,10 +154,12 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
179 |
if ( $hook != $sbp_settings_page ) {
|
180 |
return;
|
181 |
}
|
182 |
-
wp_enqueue_style( 'sbp-styles',
|
183 |
-
|
|
|
|
|
184 |
|
185 |
-
}
|
186 |
|
187 |
|
188 |
/*----------------------------------------------------------------------------------------------------------
|
@@ -198,16 +175,24 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
198 |
wp_enqueue_script( 'jquery-ui-slider' );
|
199 |
wp_enqueue_script( 'postbox' );
|
200 |
|
201 |
-
wp_enqueue_script( 'sbp-admin-scripts',
|
202 |
-
'
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
|
212 |
}
|
213 |
|
@@ -217,40 +202,33 @@ if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
217 |
-----------------------------------------------------------------------------------------------------------*/
|
218 |
|
219 |
function sbp_settings_link( $links ) {
|
220 |
-
|
221 |
$settings_link = ' <a href="admin.php?page=sbp-options">Settings</a > ';
|
222 |
array_unshift( $links, $settings_link );
|
223 |
-
|
224 |
|
225 |
return $links;
|
226 |
|
227 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
}// End class Speed_Booster_Pack
|
229 |
-
}
|
230 |
|
231 |
if ( class_exists( 'Speed_Booster_Pack' ) ) {
|
232 |
|
233 |
// Installation and uninstallation hooks
|
234 |
-
register_activation_hook( __FILE__,
|
235 |
-
register_deactivation_hook( __FILE__,
|
236 |
|
237 |
// instantiate the plugin class
|
238 |
$speed_booster_pack = new Speed_Booster_Pack();
|
239 |
|
240 |
-
}
|
241 |
-
|
242 |
-
// make sure to update the path to where you cloned the projects to!
|
243 |
-
|
244 |
-
//review function
|
245 |
-
function sb_pack_check_for_review() {
|
246 |
-
if ( ! is_admin() ) {
|
247 |
-
return;
|
248 |
-
}
|
249 |
-
require_once SPEED_BOOSTER_PACK_PATH . 'inc/class-sb-pack-review.php';
|
250 |
-
|
251 |
-
SB_Pack_Review::get_instance( array(
|
252 |
-
'slug' => 'speed-booster-pack',
|
253 |
-
) );
|
254 |
-
}
|
255 |
-
|
256 |
-
sb_pack_check_for_review();
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: Speed Booster Pack
|
4 |
+
* Plugin URI: https://wordpress.org/plugins/speed-booster-pack/
|
5 |
+
* Description: Speed optimization is vital for SEO. Optimize your PageSpeed scores today!
|
6 |
+
* Author: Optimocha
|
7 |
+
* Version: 3.8.5
|
8 |
+
* Author URI: https://optimocha.com/
|
9 |
+
* License: GPLv3 or later
|
10 |
+
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
+
* Requires PHP: 5.6
|
12 |
+
* Text Domain: speed-booster-pack
|
13 |
+
* Domain Path: /lang
|
14 |
+
*
|
15 |
+
* Copyright 2015-2017 Tiguan (office@tiguandesign.com)
|
16 |
+
* Copyright 05/05/2017 - 10/04/2017 ShortPixel (alex@shortpixel.com)
|
17 |
+
* Copyright 2017-2019 MachoThemes (office@machothemes.com)
|
18 |
+
* Copyright 2019 Optimocha (hey@optimocha.com)
|
19 |
+
*
|
20 |
+
* This program is free software; you can redistribute it and/or modify
|
21 |
+
* it under the terms of the GNU General Public License, version 3, as
|
22 |
+
* published by the Free Software Foundation.
|
23 |
+
*
|
24 |
+
* This program is distributed in the hope that it will be useful,
|
25 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
+
* GNU General Public License for more details.
|
28 |
+
*
|
29 |
+
* You should have received a copy of the GNU General Public License
|
30 |
+
* along with this program; if not, write to the Free software
|
31 |
+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
32 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
// Security control for vulnerability attempts
|
35 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
36 |
die;
|
37 |
}
|
38 |
|
41 |
-----------------------------------------------------------------------------------------------------------*/
|
42 |
|
43 |
define( 'SPEED_BOOSTER_PACK_PATH', plugin_dir_path( __FILE__ ) );
|
44 |
+
define( 'SPEED_BOOSTER_PACK_URL', preg_replace( '#^https?:#', '', plugin_dir_url( __FILE__ ) ) );
|
45 |
+
define( 'SPEED_BOOSTER_PACK_VERSION', '3.8.5' );
|
|
|
|
|
|
|
|
|
46 |
|
47 |
/*----------------------------------------------------------------------------------------------------------
|
48 |
Global Variables
|
49 |
-----------------------------------------------------------------------------------------------------------*/
|
50 |
|
51 |
+
$sbp_options = get_option( 'sbp_settings' ); // retrieve the plugin settings from the options table
|
52 |
|
53 |
/*----------------------------------------------------------------------------------------------------------
|
54 |
Main Plugin Class
|
55 |
-----------------------------------------------------------------------------------------------------------*/
|
56 |
|
57 |
if ( ! class_exists( 'Speed_Booster_Pack' ) ) {
|
|
|
58 |
class Speed_Booster_Pack {
|
59 |
|
60 |
/*----------------------------------------------------------------------------------------------------------
|
65 |
global $sbp_options;
|
66 |
|
67 |
// Enqueue admin scripts
|
68 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'sbp_admin_enqueue_scripts' ] );
|
69 |
|
70 |
// load plugin textdomain
|
71 |
+
add_action( 'plugins_loaded',
|
72 |
+
function () {
|
73 |
+
load_plugin_textdomain( 'speed-booster-pack' );
|
74 |
+
} );
|
75 |
+
|
76 |
+
// Display & dismiss notices
|
77 |
+
add_action( 'admin_notices', [ &$this, 'sbp_display_notices' ] );
|
78 |
+
add_action( 'wp_ajax_sbp_dismiss_notices', [ &$this, 'sbp_dismiss_notices' ] );
|
79 |
|
80 |
+
// Migrate to new JS Footer Mover function
|
81 |
+
add_action('admin_init', [$this, 'sbp_migrate_js_to_footer']);
|
82 |
|
83 |
// Load plugin settings page
|
84 |
require_once( SPEED_BOOSTER_PACK_PATH . 'inc/settings.php' );
|
89 |
$Speed_Booster_Pack_Core = new Speed_Booster_Pack_Core();
|
90 |
|
91 |
// Enqueue admin style
|
92 |
+
add_action( 'admin_enqueue_scripts', [ $this, 'sbp_enqueue_styles' ] );
|
|
|
93 |
|
94 |
// Filters
|
95 |
$this->path = plugin_basename( __FILE__ );
|
96 |
+
add_filter( "plugin_action_links_$this->path", [ $this, 'sbp_settings_link' ] );
|
97 |
|
98 |
|
99 |
+
} // END public function __construct
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
101 |
/*----------------------------------------------------------------------------------------------------------
|
102 |
Display/dismiss admin notices if needed
|
103 |
-----------------------------------------------------------------------------------------------------------*/
|
104 |
|
105 |
function sbp_display_notices() {
|
106 |
+
$is_using_new_version = ! ( get_option( 'sbp_js_footer_exceptions1' ) || get_option( 'sbp_js_footer_exceptions2' ) || get_option( 'sbp_js_footer_exceptions3' ) || get_option( 'sbp_js_footer_exceptions4' ) );
|
107 |
+
|
108 |
+
if ( ! $is_using_new_version ) {
|
109 |
+
include_once( SPEED_BOOSTER_PACK_PATH . 'inc/template/notices/migrate_js_to_footer.php' );
|
110 |
+
}
|
111 |
+
|
112 |
if ( ! get_option( 'sbp_news' ) ) {
|
113 |
global $sbp_settings_page;
|
114 |
$screen = get_current_screen();
|
121 |
function sbp_dismiss_notices() {
|
122 |
update_option( 'sbp_news', true );
|
123 |
|
124 |
+
return json_encode( [ "Status" => 0 ] );
|
125 |
}
|
126 |
|
127 |
/*----------------------------------------------------------------------------------------------------------
|
129 |
-----------------------------------------------------------------------------------------------------------*/
|
130 |
|
131 |
public static function sbp_activate() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
+
add_option( 'sbp_js_footer_exceptions', '/js/jquery/jquery.js' );
|
|
|
|
|
134 |
|
135 |
} // END public static function sb_activate
|
136 |
|
154 |
if ( $hook != $sbp_settings_page ) {
|
155 |
return;
|
156 |
}
|
157 |
+
wp_enqueue_style( 'sbp-styles',
|
158 |
+
plugin_dir_url( __FILE__ ) . 'css/style.css',
|
159 |
+
null,
|
160 |
+
SPEED_BOOSTER_PACK_VERSION );
|
161 |
|
162 |
+
}
|
163 |
|
164 |
|
165 |
/*----------------------------------------------------------------------------------------------------------
|
175 |
wp_enqueue_script( 'jquery-ui-slider' );
|
176 |
wp_enqueue_script( 'postbox' );
|
177 |
|
178 |
+
wp_enqueue_script( 'sbp-admin-scripts',
|
179 |
+
plugins_url( 'inc/js/admin-scripts.js', __FILE__ ),
|
180 |
+
[
|
181 |
+
'jquery',
|
182 |
+
'postbox',
|
183 |
+
'jquery-ui-slider',
|
184 |
+
],
|
185 |
+
SPEED_BOOSTER_PACK_VERSION,
|
186 |
+
true );
|
187 |
+
|
188 |
+
wp_enqueue_script( 'sbp-plugin-install',
|
189 |
+
plugins_url( 'inc/js/plugin-install.js', __FILE__ ),
|
190 |
+
[
|
191 |
+
'jquery',
|
192 |
+
'updates',
|
193 |
+
],
|
194 |
+
SPEED_BOOSTER_PACK_VERSION,
|
195 |
+
true );
|
196 |
|
197 |
}
|
198 |
|
202 |
-----------------------------------------------------------------------------------------------------------*/
|
203 |
|
204 |
function sbp_settings_link( $links ) {
|
205 |
+
$pro_link = ' <a href="https://optimocha.com/?ref=sbp" target="_blank">Pro Help</a > ';
|
206 |
$settings_link = ' <a href="admin.php?page=sbp-options">Settings</a > ';
|
207 |
array_unshift( $links, $settings_link );
|
208 |
+
array_unshift( $links, $pro_link );
|
209 |
|
210 |
return $links;
|
211 |
|
212 |
+
} // End function sbp_settings_link
|
213 |
+
|
214 |
+
public function sbp_migrate_js_to_footer() {
|
215 |
+
if ( isset( $_POST['migrate_js_mover'] ) ) {
|
216 |
+
for ( $i = 1; $i <= 4; $i ++ ) {
|
217 |
+
unregister_setting( 'speed_booster_settings_group', 'sbp_js_footer_exceptions' . $i );
|
218 |
+
delete_option( 'sbp_js_footer_exceptions' . $i );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
}
|
222 |
}// End class Speed_Booster_Pack
|
223 |
+
} // End if (!class_exists("Speed_Booster_Pack")) (1)
|
224 |
|
225 |
if ( class_exists( 'Speed_Booster_Pack' ) ) {
|
226 |
|
227 |
// Installation and uninstallation hooks
|
228 |
+
register_activation_hook( __FILE__, [ 'Speed_Booster_Pack', 'sbp_activate' ] );
|
229 |
+
register_deactivation_hook( __FILE__, [ 'Speed_Booster_Pack', 'sbp_deactivate' ] );
|
230 |
|
231 |
// instantiate the plugin class
|
232 |
$speed_booster_pack = new Speed_Booster_Pack();
|
233 |
|
234 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uninstall.php
CHANGED
@@ -4,30 +4,21 @@
|
|
4 |
*/
|
5 |
|
6 |
// Security control for vulnerability attempts
|
7 |
-
if( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
8 |
die;
|
9 |
}
|
10 |
|
11 |
// Database Tables and Options name Configrations
|
12 |
-
$option_names
|
13 |
-
$table_names = '';
|
14 |
|
15 |
-
if( !is_array( $option_names ) ) {
|
16 |
$option_names = [ $option_names ];
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
foreach( $option_names as $option_name ) {
|
24 |
-
|
25 |
-
if( empty( $option_name ) ) continue;
|
26 |
-
|
27 |
-
if( is_multisite() ) {
|
28 |
delete_site_option( $option_name );
|
29 |
-
}
|
30 |
-
else {
|
31 |
delete_option( $option_name );
|
32 |
}
|
33 |
}
|
4 |
*/
|
5 |
|
6 |
// Security control for vulnerability attempts
|
7 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
8 |
die;
|
9 |
}
|
10 |
|
11 |
// Database Tables and Options name Configrations
|
12 |
+
$option_names = [ 'sbp_settings', 'sbp_news', 'sbp_js_footer_exceptions', 'sbp_css_exceptions' ];
|
|
|
13 |
|
14 |
+
if ( ! is_array( $option_names ) ) {
|
15 |
$option_names = [ $option_names ];
|
16 |
}
|
17 |
|
18 |
+
foreach ( $option_names as $option_name ) {
|
19 |
+
if ( is_multisite() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
delete_site_option( $option_name );
|
21 |
+
} else {
|
|
|
22 |
delete_option( $option_name );
|
23 |
}
|
24 |
}
|