WP Performance Score Booster - Version 2.0

Version Description

This version adds support for page preloading, improves compression and caching rules for faster speed, and has newly designed settings page. Recommended upgrade.

=

Download this release

Release Info

Developer dipakcg
Plugin Icon 128x128 WP Performance Score Booster
Version 2.0
Comparing to
See all releases

Code changes from version 1.9.2.2 to 2.0

admin-page.php CHANGED
@@ -1,206 +1,270 @@
1
  <?php
2
- function wppsb_admin_options() {
3
- ?>
4
- <div class="wrap">
5
- <table width="100%" border="0">
6
- <tr>
7
- <td width="75%">
8
- <h2><?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-icon-24x24.png' . '" > '; ?> <?php _e('WP Performance Score Booster Settings', 'wp-performance-score-booster'); ?></h2>
9
- <hr />
10
- <?php
11
- if ( !current_user_can( 'manage_options' ) ) {
12
- wp_die( __('You do not have sufficient permissions to access this page.') );
13
- }
14
-
15
- // Variables for the field and option names
16
- $hidden_field_name = 'wppsb_submit_hidden';
17
- $remove_query_strings = 'wppsb_remove_query_strings';
18
- $enable_gzip = 'wppsb_enable_gzip';
19
- $expire_caching = 'wppsb_expire_caching';
20
-
21
- // Read in existing option value from database
22
- global $wppsb_plugin_version, $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching;
23
- $remove_query_strings_val = $wppsb_remove_query_strings;
24
- $enable_gzip_val = $wppsb_enable_gzip;
25
- $expire_caching_val = $wppsb_expire_caching;
26
 
27
- // Display notice if clicked 'Apply Updates' button (applicable to plugin updates)
28
- if ( isset($_GET['update-applied']) && $_GET['update-applied'] == 'true' ) {
 
 
 
 
 
 
 
 
 
29
  ?>
30
- <div class="updated"><p><strong><?php _e('<strong>Update applied successfully!</strong>', 'wp-performance-score-booster'); ?></strong></p></div>
31
  <?php
32
- }
33
-
34
- // See if the user has posted us some information
35
- // If they did, this hidden field will be set to 'Y'
36
- if( isset($_POST[$hidden_field_name]) && $_POST[$hidden_field_name] == 'Y' ) {
37
- // Read their posted value
38
- $remove_query_strings_val = (isset($_POST[$remove_query_strings]) ? $_POST[$remove_query_strings] : "");
39
- $enable_gzip_val = (isset($_POST[$enable_gzip]) ? $_POST[$enable_gzip] : "");
40
- $expire_caching_val = (isset($_POST[$expire_caching]) ? $_POST[$expire_caching] : "");
41
-
42
- // Save the posted value in the database
43
- update_option( $remove_query_strings, $remove_query_strings_val );
44
- update_option( $enable_gzip, $enable_gzip_val );
45
- update_option( $expire_caching, $expire_caching_val );
46
-
47
- flush_rewrite_rules();
48
- wppsb_save_mod_rewrite_rules($enable_gzip_val, $expire_caching_val);
49
 
50
- // Put the settings updated message on the screen
51
- ?>
52
- <div class="updated"><p><strong><?php _e('<strong>Settings Saved.</strong>', 'wp-performance-score-booster'); ?></strong></p></div>
53
- <?php
54
- }
55
  ?>
 
 
 
56
 
57
- <form method="post" name="options_form">
58
- <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
59
- <table>
60
- <!-- Remove Query String -->
61
- <tr> <td class="wppsb_onoff">
62
- <div class="wppsb_onoffswitch">
63
- <input type="checkbox" name="<?php echo $remove_query_strings; ?>" <?php checked( $remove_query_strings_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $remove_query_strings; ?>" />
64
- <label class="wppsb_onoffswitch-label" for="<?php echo $remove_query_strings; ?>">
65
- <span class="wppsb_onoffswitch-inner"></span>
66
- <span class="wppsb_onoffswitch-switch"></span>
67
- </label>
68
- </div>
69
- </td> <td>
70
- <label for="<?php echo $remove_query_strings; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Remove query strings from static content', 'wp-performance-score-booster'); ?> </label>
71
- </td> </tr>
72
-
73
- <!-- Enable GZIP -->
74
- <tr>
75
- <?php if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) { // if web server supports GZIP ?>
76
- <td class="wppsb_onoff">
77
- <div class="wppsb_onoffswitch">
78
- <input type="checkbox" name="<?php echo $enable_gzip; ?>" <?php checked( $enable_gzip_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $enable_gzip; ?>" />
79
- <label class="wppsb_onoffswitch-label" for="<?php echo $enable_gzip; ?>">
80
- <span class="wppsb_onoffswitch-inner"></span>
81
- <span class="wppsb_onoffswitch-switch"></span>
82
- </label>
83
- </div>
84
- </td> <td>
85
- <label for="<?php echo $enable_gzip; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Enable GZIP compression <i>(compress text, html, javascript, css, xml and so on)</i>', 'wp-performance-score-booster'); ?> </label>
86
- </td>
87
- <?php }
88
- else { // if web server doesn't support GZIP ?>
89
- <td class="wppsb_onoff">
90
- <div class="wppsb_onoffswitch">
91
- <input type="checkbox" name="<?php echo $enable_gzip; ?>" disabled="true" <?php checked( $enable_gzip_val == 'off',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $enable_gzip; ?>" />
92
- <label class="wppsb_onoffswitch-label" for="<?php echo $enable_gzip; ?>">
93
- <span class="wppsb_onoffswitch-inner"></span>
94
- <span class="wppsb_onoffswitch-switch"></span>
95
- </label>
96
- </div>
97
- </td> <td>
98
- <span class="wppsb_settings"> <?php _e('Enable GZIP compression <i>(compress text, html, javascript, css, xml and so on)</i>', 'wp-performance-score-booster'); ?> </span> <br />
99
- <span class="wppsb_settings" style="color:RED; font-style: italic; font-size: 13px !important;"> <?php _e('Your web server does not support GZIP compression. Contact your hosting provider to enable it.', 'wp-performance-score-booster'); ?> </span>
100
- </td>
101
- <?php } ?>
102
- </tr>
103
-
104
- <!-- Leverage Browser Caching -->
105
- <tr> <td class="wppsb_onoff">
106
- <div class="wppsb_onoffswitch">
107
- <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
108
- <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
109
- <span class="wppsb_onoffswitch-inner"></span>
110
- <span class="wppsb_onoffswitch-switch"></span>
111
- </label>
112
- </div>
113
- </td> <td>
114
- <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Leverage Browser Caching <i>(set expire caching)</i>', 'wp-performance-score-booster'); ?> </label>
115
- </td> </tr>
116
-
117
- <!-- Extra Options - must be added in the future version -->
118
-
119
- <!--
120
- <tr> <td colspan="2"> <h2> <?php _e('More settings <i>(optional)</i>', 'wp-performance-score-booster'); ?> </h2> </td> </tr>
121
-
122
- <tr> <td class="wppsb_onoff">
123
- <div class="wppsb_onoffswitch">
124
- <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
125
- <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
126
- <span class="wppsb_onoffswitch-inner"></span>
127
- <span class="wppsb_onoffswitch-switch"></span>
128
- </label>
129
- </div>
130
- </td> <td>
131
- <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Disable Heartbeat API completely', 'wp-performance-score-booster'); ?> </label>
132
- </td> </tr>
133
-
134
- <tr> <td class="wppsb_onoff">
135
- <div class="wppsb_onoffswitch">
136
- <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
137
- <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
138
- <span class="wppsb_onoffswitch-inner"></span>
139
- <span class="wppsb_onoffswitch-switch"></span>
140
- </label>
141
- </div>
142
- </td> <td>
143
- <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Remove WordPress Emoji scripts', 'wp-performance-score-booster'); ?> </label>
144
- </td> </tr>
145
- -->
146
 
147
- </table>
148
- <p><input style="font-size: 15px; color: white; font-weight: bold;" type="submit" value="<?php esc_attr_e('Save Changes', 'wp-performance-score-booster'); ?>" class="button button-primary" name="submit" /></p>
149
- </form>
150
- </td>
151
- <td width="25%" valign="bottom" style="text-align: left;">
152
- <div class="wppsb_admin_dev_sidebar_div">
153
- <!-- <img src="//www.gravatar.com/avatar/38b380cf488d8f8c4007cf2015dc16ac.jpg" width="100px" height="100px" /> <br /> -->
154
- <br />
155
- <!-- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-support-this-16x16.png' . '" > '; ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38" target="_blank"> <?php _e('Donate and support this plugin', 'wp-performance-score-booster'); ?> </a> </span> -->
156
- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-rate-this-16x16.png' . '" > '; ?> <a href="//wordpress.org/support/plugin/wp-performance-score-booster/reviews/?rate=5#new-post" target="_blank"> <?php _e('Rate this plugin on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
157
- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-wordpress-16x16.png' . '" > '; ?> <a href="//wordpress.org/support/plugin/wp-performance-score-booster" target="_blank"> <?php _e('Get support on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
158
- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-github-16x16.png' . '" > '; ?> <a href="//github.com/dipakcg/wp-performance-score-booster" target="_blank"> <?php _e('Contribute development on GitHub', 'wp-performance-score-booster'); ?> </a> </span>
159
- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-other-plugins-16x16.png' . '" > '; ?> <a href="//profiles.wordpress.org/dipakcg#content-plugins" target="_blank"> <?php _e('Get my other plugins', 'wp-performance-score-booster'); ?> </a> </span>
160
- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-twitter-16x16.png' . '" > '; ?>Follow me on Twitter: <a href="//twitter.com/dipakcgajjar" target="_blank">@dipakcgajjar</a> </span>
161
- <br />
162
- <span class="wppsb_admin_dev_sidebar" style="float: right;"> <?php _e('Version:', 'wp-performance-score-booster'); ?> <strong> <?php echo $wppsb_plugin_version; ?> </strong> </span>
163
- </div>
164
- </td>
165
- </tr>
166
- </table>
167
- </div>
168
- <hr style="margin: 2em 0 1.5em 0;" />
169
  <?php
170
- // Promo - Ad contents
171
- $promo_content = wp_remote_fopen("https://dipakgajjar.com/public/promos.html");
172
- echo $promo_content;
 
 
 
 
 
 
173
  ?>
174
- <?php // Bottom - News and Tweets part ?>
175
- <hr style="margin: 1.5em 0 2em 0;" />
176
- <table cellspacing="0" cellpadding="0" class="wppsb_news_section"> <tr>
177
- <!-- News and Updates -->
178
- <td width="48%" valign="top">
179
- <h2><strong>News & Updates from Dipak C. Gajjar</strong></h2>
180
- <hr />
181
- <div class="wppsb_rss-widget">
182
- <?php
183
- /* Load the news content from site url */
184
- $news_content = wp_remote_fopen("https://dipakgajjar.com/public/news-and-updates.html");
185
- echo $news_content;
186
- ?>
187
- </div> </td>
188
- <!-- Referrals -->
189
- <td width="1%"> &nbsp; </td>
190
- <td width="51%" valign="top">
191
  <?php
192
- /* Load the referrals content from site url */
193
- $referrals_content = wp_remote_fopen("https://dipakgajjar.com/public/recommendations.html");
194
  echo $referrals_content;
195
  ?>
196
- </td> </tr> </table>
197
- <?php
 
198
  }
199
 
200
- // Register admin menu
201
- add_action( 'admin_menu', 'wppsb_add_admin_menu' );
202
- function wppsb_add_admin_menu() {
203
- // add_menu_page( __('WP Performance Score Booster Settings', 'wp-performance-score-booster'), __('WP Performance Score Booster', 'wp-performance-score-booster'), 'manage_options', 'wp-performance-score-booster', 'wppsb_admin_options', plugins_url('assets/images/wppsb-icon-24x24.png', __FILE__) );
204
- add_options_page( __('WP Performance Score Booster Settings', 'wp-performance-score-booster'), __('WP Performance Score Booster', 'wp-performance-score-booster'), 'manage_options', 'wp-performance-score-booster', 'wppsb_admin_options' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
- ?>
1
  <?php
2
+ // Register admin menu
3
+ function wppsb_admin_settings_setup() {
4
+ // add_menu_page( __('WP Performance Score Booster Settings', 'wp-performance-score-booster'), __('WP Performance Score Booster', 'wp-performance-score-booster'), 'manage_options', 'wp-performance-score-booster', 'wppsb_admin_options', plugins_url('assets/images/wppsb-icon-24x24.png', __FILE__) );
5
+ add_options_page( __('WP Performance Score Booster Settings', 'wp-performance-score-booster'), __('WP Performance Score Booster', 'wp-performance-score-booster'), 'manage_options', 'wp-performance-score-booster', 'wppsb_admin_settings_page' );
6
+ }
7
+ add_action( 'admin_menu', 'wppsb_admin_settings_setup' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ // Settings main page
10
+ function wppsb_admin_settings_page() {
11
+ global $wppsb_active_tab;
12
+ $wppsb_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'settings'; ?>
13
+
14
+ <h2><?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-icon-24x24.png' . '" > '; ?> <?php _e( 'WP Performance Score Booster', 'wp-performance-score-booster' ); ?></h2>
15
+
16
+ <h2 class="nav-tab-wrapper">
17
+ <?php
18
+ do_action( 'wppsb_settings_tab' );
19
+ do_action( 'wppsb_optimize_more_tab' );
20
  ?>
21
+ </h2>
22
  <?php
23
+ do_action( 'wppsb_settings_content' );
24
+ do_action( 'wppsb_optimize_more_content' );
25
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ // Settings tab
28
+ add_action( 'wppsb_settings_tab', 'wppsb_settings_tab_fn', 1 );
29
+ function wppsb_settings_tab_fn() {
30
+ global $wppsb_active_tab;
 
31
  ?>
32
+ <a class="nav-tab <?php echo $wppsb_active_tab == 'settings' || '' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=wp-performance-score-booster&tab=settings' ); ?>"><?php _e( 'Settings', 'wp-performance-score-booster' ); ?> </a>
33
+ <?php
34
+ }
35
 
36
+ // Settigns tab contents
37
+ add_action( 'wppsb_settings_content', 'wppsb_settings_content_fn' );
38
+ function wppsb_settings_content_fn() {
39
+ global $wppsb_active_tab;
40
+ if ( '' || 'settings' != $wppsb_active_tab ) {
41
+ return;
42
+ }
43
+
44
+ wppsb_admin_options();
45
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
+ // Optimize more tab
48
+ add_action( 'wppsb_optimize_more_tab', 'wppsb_optimize_more_tab_fn', 1 );
49
+ function wppsb_optimize_more_tab_fn() {
50
+ global $wppsb_active_tab;
51
+ ?>
52
+ <a class="nav-tab <?php echo $wppsb_active_tab == 'optimize-more' || '' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=wp-performance-score-booster&tab=optimize-more' ); ?>"><?php _e( 'Optimize More!', 'wp-performance-score-booster' ); ?> </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  <?php
54
+ }
55
+
56
+ // Optimize more tab content
57
+ add_action( 'wppsb_optimize_more_content', 'wppsb_optimize_more_content_fn' );
58
+ function wppsb_optimize_more_content_fn() {
59
+ global $wppsb_active_tab;
60
+ if ( '' || 'optimize-more' != $wppsb_active_tab ) {
61
+ return;
62
+ }
63
  ?>
64
+
65
+ <h3><?php _e( 'These products will improve your site\'s performance even more!', 'wp-performance-score-booster' ); ?></h3>
66
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  <?php
68
+ $referrals_content = wp_remote_fopen("https://dipakgajjar.com/public/recommendations_2.html");
 
69
  echo $referrals_content;
70
  ?>
71
+ <div class="clear"></div>
72
+ <div id='footer-thankyou'><?php _e( '* I only recommend the products that I use personally or for my clients.', 'wp-performance-score-booster' ); ?></div>
73
+ <?php
74
  }
75
 
76
+ // Admin option
77
+ function wppsb_admin_options() {
78
+ ?>
79
+ <div class="wrap">
80
+ <table width="100%" border="0">
81
+ <tr>
82
+ <td width="65%">
83
+ <?php
84
+ if ( !current_user_can( 'manage_options' ) ) {
85
+ wp_die( __('You do not have sufficient permissions to access this page.') );
86
+ }
87
+
88
+ // Read in existing option value from database
89
+ global $wppsb_plugin_version, $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching, $wppsb_instant_page_preload;
90
+
91
+ // Variables for the field and option names
92
+ $hidden_field_name = 'wppsb_submit_hidden';
93
+ $remove_query_strings = 'wppsb_remove_query_strings';
94
+ $enable_gzip = 'wppsb_enable_gzip';
95
+ $expire_caching = 'wppsb_expire_caching';
96
+ $instant_page_preload = 'wppsb_instant_page_preload';
97
+
98
+ $remove_query_strings_val = $wppsb_remove_query_strings;
99
+ $enable_gzip_val = $wppsb_enable_gzip;
100
+ $expire_caching_val = $wppsb_expire_caching;
101
+ $instant_page_preload_val = $wppsb_instant_page_preload;
102
+
103
+ // Display notice if clicked 'Apply Updates' button (applicable to plugin updates)
104
+ if ( isset($_GET['update-applied']) && $_GET['update-applied'] == 'true' ) {
105
+ ?>
106
+ <div class="updated" id='update-applied'><p><strong><?php _e( '<strong>WP Performance Score Booster - Update applied successfully!</strong>', 'wp-performance-score-booster' ); ?></strong></p></div>
107
+ <?php
108
+ }
109
+
110
+ // See if the user has posted us some information
111
+ // If they did, this hidden field will be set to 'Y'
112
+ if( isset( $_POST[$hidden_field_name] ) && $_POST[$hidden_field_name] == 'Y' ) {
113
+
114
+ if ( isset($_GET['update-applied']) && $_GET['update-applied'] == 'true' ) {
115
+ ?>
116
+ <script>
117
+ jQuery("#update-applied").css("display", "none");
118
+ </script>
119
+ <?php
120
+ }
121
+
122
+ // Read their posted value
123
+ $remove_query_strings_val = ( isset( $_POST[$remove_query_strings] ) ? $_POST[$remove_query_strings] : '' );
124
+ $enable_gzip_val = ( isset( $_POST[$enable_gzip] ) ? $_POST[$enable_gzip] : '' );
125
+ $expire_caching_val = ( isset( $_POST[$expire_caching] ) ? $_POST[$expire_caching] : '' );
126
+ $instant_page_preload_val = ( isset( $_POST[$instant_page_preload] ) ? $_POST[$instant_page_preload] : '' );
127
+
128
+ // Save the posted value in the database
129
+ update_option( $remove_query_strings, $remove_query_strings_val );
130
+ update_option( $enable_gzip, $enable_gzip_val );
131
+ update_option( $expire_caching, $expire_caching_val );
132
+ update_option( $instant_page_preload, $instant_page_preload_val );
133
+
134
+ flush_rewrite_rules();
135
+ wppsb_save_mod_rewrite_rules($enable_gzip_val, $expire_caching_val);
136
+
137
+ // Put the settings updated message on the screen
138
+ ?>
139
+ <div class="updated"><p><strong><?php _e( '<strong>Settings Saved.</strong>', 'wp-performance-score-booster' ); ?></strong></p></div>
140
+ <?php
141
+ }
142
+ ?>
143
+
144
+ <form method="post" name="options_form">
145
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
146
+ <table>
147
+
148
+ <!-- Remove Query String -->
149
+ <tr> <td class="wppsb_onoff">
150
+ <div class="wppsb_onoffswitch">
151
+ <input type="checkbox" name="<?php echo $remove_query_strings; ?>" <?php checked( $remove_query_strings_val == 'on', true ); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $remove_query_strings; ?>" />
152
+ <label class="wppsb_onoffswitch-label" for="<?php echo $remove_query_strings; ?>">
153
+ <span class="wppsb_onoffswitch-inner"></span>
154
+ <span class="wppsb_onoffswitch-switch"></span>
155
+ </label>
156
+ </div>
157
+ </td> <td>
158
+ <label for="<?php echo $remove_query_strings; ?>" class="wppsb_settings" style="display: inline;"> <?php _e( 'Remove query strings from static content', 'wp-performance-score-booster' ); ?> </label>
159
+ </td> </tr>
160
+
161
+ <!-- Enable GZIP -->
162
+ <tr>
163
+ <?php if ( function_exists( 'ob_gzhandler' ) || ini_get( 'zlib.output_compression' ) ) { // if web server supports GZIP ?>
164
+ <td class="wppsb_onoff">
165
+ <div class="wppsb_onoffswitch">
166
+ <input type="checkbox" name="<?php echo $enable_gzip; ?>" <?php checked( $enable_gzip_val == 'on', true ); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $enable_gzip; ?>" />
167
+ <label class="wppsb_onoffswitch-label" for="<?php echo $enable_gzip; ?>">
168
+ <span class="wppsb_onoffswitch-inner"></span>
169
+ <span class="wppsb_onoffswitch-switch"></span>
170
+ </label>
171
+ </div>
172
+ </td> <td>
173
+ <label for="<?php echo $enable_gzip; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Enable GZIP compression <i>(compress text, html, javascript, css, xml and so on)</i>', 'wp-performance-score-booster'); ?> </label>
174
+ </td>
175
+ <?php }
176
+ else { // if web server doesn't support GZIP ?>
177
+ <td class="wppsb_onoff">
178
+ <div class="wppsb_onoffswitch">
179
+ <input type="checkbox" name="<?php echo $enable_gzip; ?>" disabled="true" <?php checked( $enable_gzip_val == 'off', true ); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $enable_gzip; ?>" />
180
+ <label class="wppsb_onoffswitch-label" for="<?php echo $enable_gzip; ?>">
181
+ <span class="wppsb_onoffswitch-inner"></span>
182
+ <span class="wppsb_onoffswitch-switch"></span>
183
+ </label>
184
+ </div>
185
+ </td> <td>
186
+ <span class="wppsb_settings"> <?php _e('Enable GZIP compression <i>(compress text, html, javascript, css, xml and so on)</i>', 'wp-performance-score-booster'); ?> </span> <br />
187
+ <span class="wppsb_settings" style="color:RED; font-style: italic; font-size: 13px !important;"> <?php _e( 'Your web server does not support GZIP compression. Contact your hosting provider to enable it.', 'wp-performance-score-booster' ); ?> </span>
188
+ </td>
189
+ <?php } ?>
190
+ </tr>
191
+
192
+ <!-- Leverage Browser Caching -->
193
+ <tr> <td class="wppsb_onoff">
194
+ <div class="wppsb_onoffswitch">
195
+ <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on', true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
196
+ <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
197
+ <span class="wppsb_onoffswitch-inner"></span>
198
+ <span class="wppsb_onoffswitch-switch"></span>
199
+ </label>
200
+ </div>
201
+ </td> <td>
202
+ <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e( 'Leverage Browser Caching <i>(expires headers, for better cache control)</i>', 'wp-performance-score-booster' ); ?> </label>
203
+ </td> </tr>
204
+
205
+ <!-- Instant Page Preload -->
206
+ <tr> <td class="wppsb_onoff" id="td_section">
207
+ <div class="wppsb_onoffswitch">
208
+ <input type="checkbox" name="<?php echo $instant_page_preload; ?>" <?php checked( $instant_page_preload_val == 'on', true ); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $instant_page_preload; ?>" />
209
+ <label class="wppsb_onoffswitch-label" for="<?php echo $instant_page_preload; ?>">
210
+ <span class="wppsb_onoffswitch-inner"></span>
211
+ <span class="wppsb_onoffswitch-switch"></span>
212
+ </label>
213
+ </div>
214
+ </td> <td id="td_section">
215
+ <label for="<?php echo $instant_page_preload; ?>" class="wppsb_settings" style="display: inline;"> <?php _e( 'Page Preload <em>(preload a page right before a user clicks on a link)</em>', 'wp-performance-score-booster' ); ?> </label>
216
+ </td> </tr>
217
+
218
+ <!-- Extra Options - must be added in the future version -->
219
+
220
+ <!--
221
+ <tr> <td colspan="2"> <h2> <?php _e('More settings <i>(optional)</i>', 'wp-performance-score-booster'); ?> </h2> </td> </tr>
222
+
223
+ <tr> <td class="wppsb_onoff">
224
+ <div class="wppsb_onoffswitch">
225
+ <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
226
+ <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
227
+ <span class="wppsb_onoffswitch-inner"></span>
228
+ <span class="wppsb_onoffswitch-switch"></span>
229
+ </label>
230
+ </div>
231
+ </td> <td>
232
+ <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Disable Heartbeat API completely', 'wp-performance-score-booster'); ?> </label>
233
+ </td> </tr>
234
+
235
+ <tr> <td class="wppsb_onoff">
236
+ <div class="wppsb_onoffswitch">
237
+ <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> class="wppsb_onoffswitch-checkbox" id="<?php echo $expire_caching; ?>" />
238
+ <label class="wppsb_onoffswitch-label" for="<?php echo $expire_caching; ?>">
239
+ <span class="wppsb_onoffswitch-inner"></span>
240
+ <span class="wppsb_onoffswitch-switch"></span>
241
+ </label>
242
+ </div>
243
+ </td> <td>
244
+ <label for="<?php echo $expire_caching; ?>" class="wppsb_settings" style="display: inline;"> <?php _e('Remove WordPress Emoji scripts', 'wp-performance-score-booster'); ?> </label>
245
+ </td> </tr>
246
+ -->
247
+
248
+ </table>
249
+ <p><input id='wppsb_save_button' type="submit" value="<?php esc_attr_e('Save Changes', 'wp-performance-score-booster'); ?>" class="button button-primary" name="submit" /></p>
250
+ </form>
251
+ </td>
252
+
253
+ <td width="35%" class="wppsb_plugin_info">
254
+ <div class="wppsb_admin_dev_sidebar_div">
255
+ <!-- <img src="//www.gravatar.com/avatar/38b380cf488d8f8c4007cf2015dc16ac.jpg" width="100px" height="100px" /> <br /> -->
256
+ <br />
257
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-support-this-16x16.png' . '" > '; ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38" target="_blank"> <?php _e('Donate and support this plugin', 'wp-performance-score-booster'); ?> </a> </span>
258
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-rate-this-16x16.png' . '" width="16" height="16" > '; ?> <a href="//wordpress.org/support/plugin/wp-performance-score-booster/reviews/?rate=5#new-post" target="_blank"> <?php _e('Rate this plugin on WordPress', 'wp-performance-score-booster'); ?> </a> </span>
259
+ <!-- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-wordpress-16x16.png' . '" width="16" height="16" > '; ?> <a href="//wordpress.org/support/plugin/wp-performance-score-booster" target="_blank"> <?php _e('Get FREE support on WordPress', 'wp-performance-score-booster'); ?> </a> </span> -->
260
+ <!-- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-other-plugins-16x16.png' . '" > '; ?> <a href="//profiles.wordpress.org/dipakcg#content-plugins" target="_blank"> <?php _e('Get my other plugins', 'wp-performance-score-booster'); ?> </a> </span> -->
261
+ <span id="td_section" class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-icon-24x24.png' . '" width="16" height="16" > '; ?> <a href="//dipakgajjar.com/product/wordpress-speed-optimization-service/" target="_blank"> <?php _e('Order Speed Optimisation Service', 'wp-performance-score-booster'); ?> </a> </span>
262
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-twitter-16x16.png' . '" width="16" height="16" > '; ?> <a href="//twitter.com/dipakcgajjar" target="_blank"> <?php _e('Let\'s connect on Twitter: @dipakcgajjar', 'wp-performance-score-booster'); ?> </a> </span>
263
+ <span id="td_section" class="wppsb_admin_dev_sidebar" style="float: right;"> <?php _e('Version:', 'wp-performance-score-booster'); ?> <strong> <?php echo $wppsb_plugin_version; ?> </strong> </span>
264
+ </div>
265
+ </td>
266
+ </tr>
267
+ </table>
268
+ </div>
269
+ <?php
270
  }
 
assets/banner-772x250.png DELETED
Binary file
assets/css/style.css CHANGED
@@ -1,18 +1,20 @@
1
  .wppsb_settings {
2
- font-size: 16px !important;
3
  }
4
  .wppsb_admin_dev_sidebar_div {
5
- width:300px;
6
- height:225px;
 
7
  -webkit-border-radius: 10px;
8
  -moz-border-radius: 10px;
9
- border-radius: 20px 20px 20px 0;
10
- border: 1px solid #FF9900;
11
  background-color:#FFFFFF;
12
- padding: 10px 10px 0 30px;
 
13
  }
14
  .wppsb_admin_dev_sidebar {
15
- font-size: 14px;
16
  margin: 0 20px 10px 0;
17
  display: block;
18
  }
@@ -30,15 +32,13 @@
30
  padding: 20px 20px 20px 20px;
31
  width: 98%;
32
  }
33
-
34
  a.wppsb_rsswidget {
35
- font-size: 16px !important;
36
  text-decoration: none !important;
37
  }
38
  .wppsb_rss-widget ul li {
39
  margin-bottom: 25px !important;
40
  }
41
-
42
  td.wppsb_onoff {
43
  width: 75px;
44
  height: 40px;
@@ -46,42 +46,66 @@ td.wppsb_onoff {
46
  /* ========= */
47
 
48
  .wppsb_onoffswitch {
49
- position: relative; width: 70px;
50
- -webkit-user-select:none; -moz-user-select:none; -ms-user-select: none;
 
 
 
51
  }
52
  .wppsb_onoffswitch-checkbox {
53
  display: none !important;
54
  }
55
  .wppsb_onoffswitch-label {
56
- display: block; overflow: hidden; cursor: pointer;
57
- border: 2px solid #999999; border-radius: 20px;
 
 
 
58
  }
59
  .wppsb_onoffswitch-inner {
60
- display: block; width: 200%; margin-left: -100%;
 
 
61
  transition: margin 0.3s ease-in 0s;
62
  }
63
  .wppsb_onoffswitch-inner:before, .wppsb_onoffswitch-inner:after {
64
- display: block; float: left; width: 50%; padding: 0; /* height: 30px; line-height: 30px; */ height: 22px; line-height: 22px;
65
- font-size: 15px; color: white; font-family: Trebuchet, Arial, sans-serif; font-weight: bold;
 
 
 
 
 
 
 
 
66
  box-sizing: border-box;
67
  }
68
  .wppsb_onoffswitch-inner:before {
69
  content: "ON";
70
  padding-left: 10px;
71
- background-color: #5CA21E; color: #FFFFFF;
 
72
  }
73
  .wppsb_onoffswitch-inner:after {
74
  content: "OFF";
75
  padding-right: 10px;
76
- background-color: #EEEEEE; color: #999999;
 
77
  text-align: right;
78
  }
79
  .wppsb_onoffswitch-switch {
80
- display: block; /* width: 18px; */ width: 11px; margin: 6px;
 
 
 
81
  background: #FFFFFF;
82
- position: absolute; top: 0; bottom: 0;
83
- right: 43px;
84
- border: 2px solid #999999; border-radius: 20px;
 
 
 
85
  transition: all 0.3s ease-in 0s;
86
  }
87
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-inner {
@@ -89,4 +113,24 @@ td.wppsb_onoff {
89
  }
90
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-switch {
91
  right: 0px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  }
1
  .wppsb_settings {
2
+ font-size: 14px !important;
3
  }
4
  .wppsb_admin_dev_sidebar_div {
5
+ /* width:300px; */
6
+ display: table;
7
+ /* min-height:210px; */
8
  -webkit-border-radius: 10px;
9
  -moz-border-radius: 10px;
10
+ border-radius: 10px;
11
+ border: 1px solid #CCC;
12
  background-color:#FFFFFF;
13
+ padding: 0 10px 0 30px;
14
+ float: right;
15
  }
16
  .wppsb_admin_dev_sidebar {
17
+ font-size: 13px;
18
  margin: 0 20px 10px 0;
19
  display: block;
20
  }
32
  padding: 20px 20px 20px 20px;
33
  width: 98%;
34
  }
 
35
  a.wppsb_rsswidget {
36
+ font-size: 14px !important;
37
  text-decoration: none !important;
38
  }
39
  .wppsb_rss-widget ul li {
40
  margin-bottom: 25px !important;
41
  }
 
42
  td.wppsb_onoff {
43
  width: 75px;
44
  height: 40px;
46
  /* ========= */
47
 
48
  .wppsb_onoffswitch {
49
+ position: relative;
50
+ width: 65px;
51
+ -webkit-user-select:none;
52
+ -moz-user-select:none;
53
+ -ms-user-select: none;
54
  }
55
  .wppsb_onoffswitch-checkbox {
56
  display: none !important;
57
  }
58
  .wppsb_onoffswitch-label {
59
+ display: block;
60
+ overflow: hidden;
61
+ cursor: pointer;
62
+ border: 2px solid #999999;
63
+ border-radius: 20px;
64
  }
65
  .wppsb_onoffswitch-inner {
66
+ display: block;
67
+ width: 200%;
68
+ margin-left: -100%;
69
  transition: margin 0.3s ease-in 0s;
70
  }
71
  .wppsb_onoffswitch-inner:before, .wppsb_onoffswitch-inner:after {
72
+ display: block;
73
+ float:left;
74
+ width: 50%;
75
+ padding: 0;
76
+ /* height: 30px;
77
+ line-height: 30px; */
78
+ height: 22px;
79
+ line-height: 22px;
80
+ font-size: 13px;
81
+ color: white; /* font-family: Trebuchet, Arial, sans-serif; font-weight: bold; */
82
  box-sizing: border-box;
83
  }
84
  .wppsb_onoffswitch-inner:before {
85
  content: "ON";
86
  padding-left: 10px;
87
+ background-color: #5CA21E;
88
+ color: #FFFFFF;
89
  }
90
  .wppsb_onoffswitch-inner:after {
91
  content: "OFF";
92
  padding-right: 10px;
93
+ background-color: #EEEEEE;
94
+ color: #999999;
95
  text-align: right;
96
  }
97
  .wppsb_onoffswitch-switch {
98
+ display: block;
99
+ /* width: 18px; */
100
+ width: 11px;
101
+ margin: 6px;
102
  background: #FFFFFF;
103
+ position: absolute;
104
+ top: 0;
105
+ bottom: 0;
106
+ /* right: 43px; */
107
+ border: 2px solid #999999;
108
+ border-radius: 20px;
109
  transition: all 0.3s ease-in 0s;
110
  }
111
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-inner {
113
  }
114
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-switch {
115
  right: 0px;
116
+ }
117
+ #td_section {
118
+ padding-top: 20px;
119
+ }
120
+ .wppsb_plugin_info {
121
+ vertical-align: top;
122
+ text-align: left;
123
+ }
124
+ #wppsb_save_button {
125
+ font-size: 14px;
126
+ color: white;
127
+ font-weight: bold;
128
+ }
129
+ .update_notice {
130
+ font-size: 15px;
131
+ color: #FF9900;
132
+ }
133
+ #wppsb_notice_div {
134
+ margin-top: 25px;
135
+ margin-left:2px
136
  }
assets/css/style.min.css CHANGED
@@ -1 +1 @@
1
- .wppsb_settings{font-size:16px !important;}.wppsb_admin_dev_sidebar_div{width:300px;height:225px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:20px 20px 20px 0;border:1px solid #FF9900;background-color:#FFFFFF;padding:10px 10px 0 30px}.wppsb_admin_dev_sidebar{font-size:14px;margin:0 20px 10px 0;display:block}.wppsb_admin_dev_sidebar a{text-decoration:none}.wppsb_admin_dev_sidebar img{padding:0 5px 0 0;vertical-align:middle}.wppsb_news_section{border-radius:20px 20px 20px 0;border:1px solid #FF9900;background-color:#FFFFFF;padding:20px 20px 20px 20px;width:98%}a.wppsb_rsswidget{font-size:16px !important;text-decoration:none !important}.wppsb_rss-widget ul li{margin-bottom:25px !important}td.wppsb_onoff{width:75px;height:40px}.wppsb_onoffswitch{position:relative;width:70px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.wppsb_onoffswitch-checkbox{display:none !important}.wppsb_onoffswitch-label{display:block;overflow:hidden;cursor:pointer;border:2px solid #999999;border-radius:20px}.wppsb_onoffswitch-inner{display:block;width:200%;margin-left:-100%;transition:margin 0.3s ease-in 0s}.wppsb_onoffswitch-inner:before,.wppsb_onoffswitch-inner:after{display:block;float:left;width:50%;padding:0;height:22px;line-height:22px;font-size:15px;color:white;font-family:Trebuchet, Arial, sans-serif;font-weight:bold;box-sizing:border-box}.wppsb_onoffswitch-inner:before{content:"ON";padding-left:10px;background-color:#5CA21E;color:#FFFFFF}.wppsb_onoffswitch-inner:after{content:"OFF";padding-right:10px;background-color:#EEEEEE;color:#999999;text-align:right}.wppsb_onoffswitch-switch{display:block;width:11px;margin:6px;background:#FFFFFF;position:absolute;top:0;bottom:0;right:43px;border:2px solid #999999;border-radius:20px;transition:all 0.3s ease-in 0s}.wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-inner{margin-left:0}.wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-switch{right:0px}
1
+ .wppsb_settings{font-size:14px!important}.wppsb_admin_dev_sidebar_div{display:table;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;border:1px solid #ccc;background-color:#fff;padding:0 10px 0 30px;float:right}.wppsb_admin_dev_sidebar{font-size:13px;margin:0 20px 10px 0;display:block}.wppsb_admin_dev_sidebar a{text-decoration:none}.wppsb_admin_dev_sidebar img{padding:0 5px 0 0;vertical-align:middle}.wppsb_news_section{border-radius:20px 20px 20px 0;border:1px solid #f90;background-color:#fff;padding:20px 20px 20px 20px;width:98%}a.wppsb_rsswidget{font-size:14px!important;text-decoration:none!important}.wppsb_rss-widget ul li{margin-bottom:25px!important}td.wppsb_onoff{width:75px;height:40px}.wppsb_onoffswitch{position:relative;width:65px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}.wppsb_onoffswitch-checkbox{display:none!important}.wppsb_onoffswitch-label{display:block;overflow:hidden;cursor:pointer;border:2px solid #999;border-radius:20px}.wppsb_onoffswitch-inner{display:block;width:200%;margin-left:-100%;transition:margin .3s ease-in 0s}.wppsb_onoffswitch-inner:after,.wppsb_onoffswitch-inner:before{display:block;float:left;width:50%;padding:0;height:22px;line-height:22px;font-size:13px;color:#fff;box-sizing:border-box}.wppsb_onoffswitch-inner:before{content:"ON";padding-left:10px;background-color:#5ca21e;color:#fff}.wppsb_onoffswitch-inner:after{content:"OFF";padding-right:10px;background-color:#eee;color:#999;text-align:right}.wppsb_onoffswitch-switch{display:block;width:11px;margin:6px;background:#fff;position:absolute;top:0;bottom:0;border:2px solid #999;border-radius:20px;transition:all .3s ease-in 0s}.wppsb_onoffswitch-checkbox:checked+.wppsb_onoffswitch-label .wppsb_onoffswitch-inner{margin-left:0}.wppsb_onoffswitch-checkbox:checked+.wppsb_onoffswitch-label .wppsb_onoffswitch-switch{right:0}#td_section{padding-top:20px}.wppsb_plugin_info{vertical-align:top;text-align:left}#wppsb_save_button{font-size:14px;color:#fff;font-weight:700}.update_notice{font-size: 15px;color: #FF9900;}#wppsb_notice_div{margin-top:25px;margin-left:2px}
assets/js/page-preloader.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /*! instant.page v5.1.0 - (C) 2019-2020 Alexandre Dieulot - https://instant.page/license */
2
+ let t,e;const n=new Set,o=document.createElement("link"),i=o.relList&&o.relList.supports&&o.relList.supports("prefetch")&&window.IntersectionObserver&&"isIntersecting"in IntersectionObserverEntry.prototype,s="instantAllowQueryString"in document.body.dataset,a="instantAllowExternalLinks"in document.body.dataset,r="instantWhitelist"in document.body.dataset,c="instantMousedownShortcut"in document.body.dataset,d=1111;let l=65,u=!1,f=!1,m=!1;if("instantIntensity"in document.body.dataset){const t=document.body.dataset.instantIntensity;if("mousedown"==t.substr(0,"mousedown".length))u=!0,"mousedown-only"==t&&(f=!0);else if("viewport"==t.substr(0,"viewport".length))navigator.connection&&(navigator.connection.saveData||navigator.connection.effectiveType&&navigator.connection.effectiveType.includes("2g"))||("viewport"==t?document.documentElement.clientWidth*document.documentElement.clientHeight<45e4&&(m=!0):"viewport-all"==t&&(m=!0));else{const e=parseInt(t);isNaN(e)||(l=e)}}if(i){const n={capture:!0,passive:!0};if(f||document.addEventListener("touchstart",function(t){e=performance.now();const n=t.target.closest("a");if(!h(n))return;v(n.href)},n),u?c||document.addEventListener("mousedown",function(t){const e=t.target.closest("a");if(!h(e))return;v(e.href)},n):document.addEventListener("mouseover",function(n){if(performance.now()-e<d)return;const o=n.target.closest("a");if(!h(o))return;o.addEventListener("mouseout",p,{passive:!0}),t=setTimeout(()=>{v(o.href),t=void 0},l)},n),c&&document.addEventListener("mousedown",function(t){if(performance.now()-e<d)return;const n=t.target.closest("a");if(t.which>1||t.metaKey||t.ctrlKey)return;if(!n)return;n.addEventListener("click",function(t){1337!=t.detail&&t.preventDefault()},{capture:!0,passive:!1,once:!0});const o=new MouseEvent("click",{view:window,bubbles:!0,cancelable:!1,detail:1337});n.dispatchEvent(o)},n),m){let t;(t=window.requestIdleCallback?t=>{requestIdleCallback(t,{timeout:1500})}:t=>{t()})(()=>{const t=new IntersectionObserver(e=>{e.forEach(e=>{if(e.isIntersecting){const n=e.target;t.unobserve(n),v(n.href)}})});document.querySelectorAll("a").forEach(e=>{h(e)&&t.observe(e)})})}}function p(e){e.relatedTarget&&e.target.closest("a")==e.relatedTarget.closest("a")||t&&(clearTimeout(t),t=void 0)}function h(t){if(t&&t.href&&(!r||"instant"in t.dataset)&&(a||t.origin==location.origin||"instant"in t.dataset)&&["http:","https:"].includes(t.protocol)&&("http:"!=t.protocol||"https:"!=location.protocol)&&(s||!t.search||"instant"in t.dataset)&&!(t.hash&&t.pathname+t.search==location.pathname+location.search||"noInstant"in t.dataset))return!0}function v(t){if(n.has(t))return;const e=document.createElement("link");e.rel="prefetch",e.href=t,document.head.appendChild(e),n.add(t)}
data-processing.php CHANGED
@@ -1,123 +1,221 @@
1
  <?php
2
- /* ========================================
3
- Remove query strings from static content
4
- ======================================== */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  function wppsb_remove_query_strings_q( $src ) {
6
  if(strpos( $src, '?ver=' ))
7
  $src = remove_query_arg( 'ver', $src );
8
  return $src;
9
  }
10
 
11
- /* ========================================
12
- Enable GZIP Compression
13
- ======================================== */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  function wppsb_enable_gzip_filter( $rules = '' ) {
15
  $gzip_htaccess_content = <<<EOD
16
  \n## BEGIN GZIP Compression ##
17
  <IfModule mod_deflate.c>
18
- AddOutputFilterByType DEFLATE text/plain
19
- AddOutputFilterByType DEFLATE text/html
20
- AddOutputFilterByType DEFLATE text/xml
21
- AddOutputFilterByType DEFLATE text/css
22
- AddOutputFilterByType DEFLATE application/xml
23
- AddOutputFilterByType DEFLATE application/xhtml+xml
24
- AddOutputFilterByType DEFLATE application/rss+xml
25
- AddOutputFilterByType DEFLATE application/javascript
26
- AddOutputFilterByType DEFLATE application/x-javascript
27
- AddOutputFilterByType DEFLATE application/x-httpd-php
28
- AddOutputFilterByType DEFLATE application/x-httpd-fastphp
29
- AddOutputFilterByType DEFLATE image/svg+xml
30
- SetOutputFilter DEFLATE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  </IfModule>
32
  ## END GZIP Compression ##
33
  EOD;
34
  return $gzip_htaccess_content . $rules;
35
  }
36
 
37
- // Set Vary: Accept-Encoding Header (as a part of compression)
38
- function wppsb_vary_accept_encoding_filter( $rules = '' ) {
39
- $vary_accept_encoding_header = <<<EOD
40
- \n## BEGIN Vary: Accept-Encoding Header ##
41
- <IfModule mod_headers.c>
42
- <FilesMatch "\.(js|css|xml|gz)$">
43
- Header append Vary: Accept-Encoding
44
- </FilesMatch>
45
- </IfModule>
46
- ## END Vary: Accept-Encoding Header ##
47
- EOD;
48
- return $vary_accept_encoding_header . $rules;
49
- }
50
 
51
- /* ================================================
52
- Enable expire caching (Leverage browser caching)
53
- ================================================ */
54
  function wppsb_expire_caching_filter( $rules = '' ) {
55
  $expire_cache_htaccess_content = <<<EOD
56
- \n## BEGIN Leverage Browser Caching (Expires Caching) ##
57
  <IfModule mod_expires.c>
58
- ExpiresActive On
59
- ExpiresByType text/css "access 1 month"
60
- ExpiresByType text/html "access 1 month"
61
- ExpiresByType image/jpg "access 1 year"
62
- ExpiresByType image/jpeg "access 1 year"
63
- ExpiresByType image/gif "access 1 year"
64
- ExpiresByType image/png "access 1 year"
65
- ExpiresByType image/x-icon "access 1 year"
66
- ExpiresByType application/pdf "access 1 month"
67
- ExpiresByType application/javascript "access 1 month"
68
- ExpiresByType text/x-javascript "access 1 month"
69
- ExpiresByType application/x-shockwave-flash "access 1 month"
70
- ExpiresDefault "access 1 month"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  </IfModule>
72
- ## END Leverage Browser Caching (Expires Caching) ##
73
  EOD;
74
  return $expire_cache_htaccess_content . $rules;
75
  }
76
 
77
- function wppsb_disable_etag_filter( $rules = '' ) {
78
- $disable_etag_header_content = <<<EOD
79
- \n## BEGIN Disable ETag header ##
80
- Header unset Pragma
81
- Header unset ETag
 
 
 
 
 
 
 
82
  FileETag None
83
- ## END Disable ETag header ##
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  EOD;
85
- return $disable_etag_header_content . $rules;
86
  }
87
 
 
88
  // Special thanks to Marin Atanasov ( https://github.com/tyxla ) for contributing this awesome function.
89
  // Updates the htaccess file with the current rules if it is writable.
90
- function wppsb_save_mod_rewrite_rules($enable_gzip_val, $expire_caching_val) {
91
- if ( is_multisite() )
92
  return;
 
 
93
  global $wp_rewrite;
 
94
  $htaccess_file = get_home_path() . '.htaccess';
95
 
96
  /*
97
  * If the file doesn't already exist check for write access to the directory
98
  * and whether we have some rules. Else check for write access to the file.
99
  */
100
- if ((!file_exists($htaccess_file) && is_writable( get_home_path() ) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
101
- $mod_rewrite_enabled = function_exists('got_mod_rewrite') ? got_mod_rewrite() : false;
102
  if ( $mod_rewrite_enabled ) {
103
  $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
104
- $enable_gzip = 'wppsb_enable_gzip';
105
- $expire_caching = 'wppsb_expire_caching';
106
  // $enable_gzip_val = get_option($enable_gzip);
107
  // $expire_caching_val = get_option($expire_caching);
108
  $rules = array();
109
- if ($enable_gzip_val == 'on') {
110
- $rules = array_merge($rules, explode("\n", wppsb_enable_gzip_filter()));
111
- $rules = array_merge($rules, explode("\n", wppsb_vary_accept_encoding_filter()));
112
  }
113
- if ($expire_caching_val == 'on') {
114
- $rules = array_merge($rules, explode("\n", wppsb_expire_caching_filter()));
115
- $rules = array_merge($rules, explode("\n", wppsb_disable_etag_filter()));
116
  }
117
 
 
118
  return insert_with_markers( $htaccess_file, 'WP Performance Score Booster Settings', $rules );
 
119
  }
120
  }
121
  return false;
122
  }
123
- ?>
1
  <?php
2
+ /**********************************
3
+ * Remove query strings from static content
4
+ **********************************/
5
+ function wppsb_remove_query_string_init() {
6
+ global $wppsb_remove_query_strings;
7
+
8
+ // If 'Remove query strings" checkbox ticked, add filter otherwise remove filter
9
+ if ( $wppsb_remove_query_strings == 'on' ) {
10
+ // Disable the functionality under Admin to avoid any conflicts
11
+ if ( ! is_admin() ) {
12
+ add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
13
+ add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
14
+ }
15
+ } else {
16
+ remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_q');
17
+ remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_q');
18
+ }
19
+ }
20
+ add_action( 'wppsb_remove_query_string_action', 'wppsb_remove_query_string_init' );
21
+
22
  function wppsb_remove_query_strings_q( $src ) {
23
  if(strpos( $src, '?ver=' ))
24
  $src = remove_query_arg( 'ver', $src );
25
  return $src;
26
  }
27
 
28
+ /**********************************
29
+ * instant.page preoloader
30
+ **********************************/
31
+ function wppsb_enqueue_scripts() {
32
+ global $wppsb_instant_page_preload;
33
+
34
+ // Only enqueu instant.page script if option is selected under plugin settings
35
+ if ( $wppsb_instant_page_preload == 'on' ) {
36
+ wp_enqueue_script( 'wppsb-page-preload', WPPSB_URL . '/assets/js/page-preloader.js', array(), '5.1.0', true );
37
+ }
38
+ }
39
+ add_action( 'wp_enqueue_scripts', 'wppsb_enqueue_scripts' );
40
+
41
+ // This script loader is needed for instant.page preloader
42
+ function wppsb_script_loader_tag( $tag, $handle ) {
43
+ if ( 'wppsb-page-preload' === $handle ) {
44
+ $tag = str_replace( 'text/javascript', 'module', $tag );
45
+ }
46
+ return $tag;
47
+ }
48
+ add_filter( 'script_loader_tag', 'wppsb_script_loader_tag', 10, 2 );
49
+
50
+
51
+ /**********************************
52
+ * Enable GZIP Compression and Set Vary: Accept-Encoding Header (as a part of compression)
53
+ **********************************/
54
  function wppsb_enable_gzip_filter( $rules = '' ) {
55
  $gzip_htaccess_content = <<<EOD
56
  \n## BEGIN GZIP Compression ##
57
  <IfModule mod_deflate.c>
58
+ SetOutputFilter DEFLATE
59
+ <IfModule mod_setenvif.c>
60
+ <IfModule mod_headers.c>
61
+ SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
62
+ RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
63
+ SetEnvIfNoCase Request_URI \
64
+ \.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary
65
+ </IfModule>
66
+ </IfModule>
67
+ <IfModule mod_filter.c>
68
+ AddOutputFilterByType DEFLATE application/atom+xml \
69
+ application/javascript \
70
+ application/json \
71
+ application/rss+xml \
72
+ application/vnd.ms-fontobject \
73
+ application/x-font-ttf \
74
+ application/xhtml+xml \
75
+ application/xml \
76
+ font/opentype \
77
+ image/svg+xml \
78
+ image/x-icon \
79
+ text/css \
80
+ text/html \
81
+ text/plain \
82
+ text/x-component \
83
+ text/xml
84
+ </IfModule>
85
+ <IfModule mod_headers.c>
86
+ Header append Vary: Accept-Encoding
87
+ </IfModule>
88
+ </IfModule>
89
+ <IfModule mod_mime.c>
90
+ AddType text/html .html_gzip
91
+ AddEncoding gzip .html_gzip
92
+ </IfModule>
93
+ <IfModule mod_setenvif.c>
94
+ SetEnvIfNoCase Request_URI \.html_gzip$ no-gzip
95
  </IfModule>
96
  ## END GZIP Compression ##
97
  EOD;
98
  return $gzip_htaccess_content . $rules;
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ /**********************************
103
+ * Leverage Browser Caching (Expires headers) for better cache control
104
+ **********************************/
105
  function wppsb_expire_caching_filter( $rules = '' ) {
106
  $expire_cache_htaccess_content = <<<EOD
107
+ \n## BEGIN Leverage Browser Caching (Expires headers) for better cache control ##
108
  <IfModule mod_expires.c>
109
+ ExpiresActive on
110
+ ExpiresByType text/cache-manifest "access plus 0 seconds"
111
+ # Media files
112
+ ExpiresByType image/gif "access plus 4 months"
113
+ ExpiresByType image/png "access plus 4 months"
114
+ ExpiresByType image/jpeg "access plus 4 months"
115
+ ExpiresByType image/webp "access plus 4 months"
116
+ ExpiresByType video/ogg "access plus 1 month"
117
+ ExpiresByType audio/ogg "access plus 1 month"
118
+ ExpiresByType video/mp4 "access plus 1 month"
119
+ ExpiresByType video/webm "access plus 1 month"
120
+ ExpiresByType text/x-component "access plus 1 month"
121
+ # Webfonts
122
+ ExpiresByType font/ttf "access plus 4 months"
123
+ ExpiresByType font/otf "access plus 4 months"
124
+ ExpiresByType font/woff "access plus 4 months"
125
+ ExpiresByType font/woff2 "access plus 4 months"
126
+ ExpiresByType image/svg+xml "access plus 1 month"
127
+ ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
128
+ ExpiresByType text/css "access plus 1 year"
129
+ ExpiresByType application/javascript "access plus 1 year"
130
+ # HTML and Data
131
+ ExpiresByType text/html "access plus 0 seconds"
132
+ ExpiresByType text/xml "access plus 0 seconds"
133
+ ExpiresByType application/xml "access plus 0 seconds"
134
+ ExpiresByType application/json "access plus 0 seconds"
135
+ # Feed
136
+ ExpiresByType application/rss+xml "access plus 1 hour"
137
+ ExpiresByType application/atom+xml "access plus 1 hour"
138
+ # Favicon
139
+ ExpiresByType image/x-icon "access plus 1 week"
140
+ # Default
141
+ ExpiresDefault "access plus 2 days"
142
  </IfModule>
143
+ ## END Leverage Browser Caching (Expires headers) for better cache control ##
144
  EOD;
145
  return $expire_cache_htaccess_content . $rules;
146
  }
147
 
148
+
149
+ /**********************************
150
+ * Disable ETag and set Cache-Control headers
151
+ **********************************/
152
+ function wppsb_etag_headers_filter( $rules = '' ) {
153
+ $wppsb_plugin_version = WPPSB_PLUGIN_VERSION;
154
+ $etag_headers_content = <<<EOD
155
+ \n## BEGIN Disable ETag and set Cache-Control headers ##
156
+ <IfModule mod_headers.c>
157
+ Header unset ETag
158
+ </IfModule>
159
+ # Since we’re sending far-future expires, we don’t need ETags for static content.
160
  FileETag None
161
+ <IfModule mod_alias.c>
162
+ <FilesMatch "\.(css|htc|js|asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|wav|wma|wri|xla|xls|xlsx|xlt|xlw|zip)$">
163
+ <IfModule mod_headers.c>
164
+ Header unset Pragma
165
+ Header append Cache-Control "public"
166
+ </IfModule>
167
+ </FilesMatch>
168
+ <FilesMatch "\.(html|htm|rtf|rtx|txt|xsd|xsl|xml)$">
169
+ <IfModule mod_headers.c>
170
+ Header set X-Powered-By "WP Performance Score Booster/$wppsb_plugin_version"
171
+ Header unset Pragma
172
+ Header append Cache-Control "public"
173
+ Header unset Last-Modified
174
+ </IfModule>
175
+ </FilesMatch>
176
+ </IfModule>
177
+ ## END Disable ETag and set Cache-Control headers ##
178
  EOD;
179
+ return $etag_headers_content . $rules;
180
  }
181
 
182
+
183
  // Special thanks to Marin Atanasov ( https://github.com/tyxla ) for contributing this awesome function.
184
  // Updates the htaccess file with the current rules if it is writable.
185
+ function wppsb_save_mod_rewrite_rules( $enable_gzip_val, $expire_caching_val ) {
186
+ if ( is_multisite() ) {
187
  return;
188
+ }
189
+
190
  global $wp_rewrite;
191
+
192
  $htaccess_file = get_home_path() . '.htaccess';
193
 
194
  /*
195
  * If the file doesn't already exist check for write access to the directory
196
  * and whether we have some rules. Else check for write access to the file.
197
  */
198
+ if ( ( ! file_exists( $htaccess_file ) && is_writable( get_home_path() ) && $wp_rewrite->using_mod_rewrite_permalinks() ) || is_writable( $htaccess_file ) ) {
199
+ $mod_rewrite_enabled = function_exists( 'got_mod_rewrite' ) ? got_mod_rewrite() : false;
200
  if ( $mod_rewrite_enabled ) {
201
  $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
202
+ // $enable_gzip = 'wppsb_enable_gzip';
203
+ // $expire_caching = 'wppsb_expire_caching';
204
  // $enable_gzip_val = get_option($enable_gzip);
205
  // $expire_caching_val = get_option($expire_caching);
206
  $rules = array();
207
+ if ( $enable_gzip_val == 'on' ) {
208
+ $rules = array_merge( $rules, explode( '\n', wppsb_enable_gzip_filter() ) );
 
209
  }
210
+ if ( $expire_caching_val == 'on' ) {
211
+ $rules = array_merge( $rules, explode( '\n', wppsb_expire_caching_filter() ) );
212
+ $rules = array_merge( $rules, explode( '\n', wppsb_etag_headers_filter() ) );
213
  }
214
 
215
+ // chmod( $htaccess_file, 0777 );
216
  return insert_with_markers( $htaccess_file, 'WP Performance Score Booster Settings', $rules );
217
+ // chmod( $htaccess_file, 0644 );
218
  }
219
  }
220
  return false;
221
  }
 
readme.txt CHANGED
@@ -1,63 +1,80 @@
1
- === WP Performance Score Booster ===
2
  Contributors: dipakcg
3
- Tags: performance, speed, gzip, booster, query string
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38
5
  Requires at least: 3.5
6
- Tested up to: 5.0
7
- Stable tag: 1.9.2.2
 
8
  License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Speed-up page load times and improve website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.
12
 
13
  == Description ==
14
- This plugin speed-up page load times and improve website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.
15
 
16
  = This plugin will... =
17
  * Remove any query strings from static resources like CSS & JS files
18
  * Enable GZIP compression (compress text, html, javascript, css, xml and so on)
19
- * Add Vary: Accept-Encoding header, and
20
- * Set expires caching (leverage browser caching).
 
21
 
22
  [youtube https://www.youtube.com/watch?v=nEFZLFyZNcE]
23
 
24
  **Follow the development of this plugin on [GitHub](https://github.com/dipakcg/wp-performance-score-booster)**
25
 
26
- **P.S. It is always the best policy to open a [support thread](http://wordpress.org/support/plugin/wp-performance-score-booster#new-topic-0) first before posting any negative review.**
27
 
28
  == Installation ==
29
- 1. Upload the ‘wp-performance-score-booster’ folder to the ‘/wp-content/plugins/‘ directory
30
- 2. Activate the plugin through the ‘Plugins’ menu in WordPress.
31
- 3. That’s it!
 
 
 
32
 
33
  == Frequently Asked Questions ==
34
  = What does this plugin do? =
35
 
36
- It speed-up page load times and improve website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix. It will remove any query strings from static resources like CSS & JS files, enable GZIP compression (compress text, html, javascript, css, xml and so on), add Vary: Accept-Encoding header and set expires caching (leverage browser caching).
37
 
38
  = Any specific requirements for this plugin to work? =
39
 
40
- * GZIP compression should be enabled in your web-server (apache?). If not then you can ask your web hosting provider.
41
- * .htaccess in your WordPress root folder must have write permissions.
42
 
43
  = What if I get 500 Internal Server Error? =
44
 
45
  If you get "500 - Internal Server Error" after you activate the plugin, Follow the steps below:
46
 
47
- (1) Login to your FTP or open File Manager (ask your hosting provider)
48
- (2) Go to the WordPress installation folder and then `wp-content/wp-performance-score-booster` folder
49
- (3) Copy `.htaccess.wppsb` file
50
- (4) Now move back to WordPress installation folder and Rename the `.htaccess` file (to something like .htaccess.bak)
51
- (5) Paste `.htaccess.wppsb` file (copied from step 3) and rename it to `.htaccess`
 
 
52
 
53
- That's it! Your site should be up now.
54
 
55
- Alternatively, you can open a [support thread](http://wordpress.org/support/plugin/wp-performance-score-booster#new-topic-0)
 
 
 
 
 
56
 
57
  == Screenshots ==
58
  1. Admin Settings
59
 
60
  == Changelog ==
 
 
 
 
 
 
61
  = 1.9.2.2, December 19, 2018 =
62
  * Fixed "Remove any query strings from static resources" conflict in admin
63
 
@@ -137,3 +154,11 @@ Alternatively, you can open a [support thread](http://wordpress.org/support/plug
137
  = 1.0, August 26, 2014 =
138
  * Initial release.
139
  * Born of WP Performance Score Booster.
 
 
 
 
 
 
 
 
1
+ === WP Performance Score Booster – Optimize Speed, Enable Cache & Page Preload ===
2
  Contributors: dipakcg
3
+ Tags: performance, optimize, speed, query string, preload, gzip, gtmetrix, etag, compression, headers, cache, pagespeed
4
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38
5
  Requires at least: 3.5
6
+ Tested up to: 5.8
7
+ Requires PHP: 5.6
8
+ Stable tag: 2.0
9
  License: GPLv2 or later
 
10
 
11
+ Make website faster, speed up page load time and improve performance scores in services like GTmetrix, Pingdom, YSlow and PageSpeed.
12
 
13
  == Description ==
14
+ **WP Performance Score Booster makes website faster, speeds up page load time, and instantly improves website performance scores in services like GTmetrix, Pingdom, YSlow, and PageSpeed.**
15
 
16
  = This plugin will... =
17
  * Remove any query strings from static resources like CSS & JS files
18
  * Enable GZIP compression (compress text, html, javascript, css, xml and so on)
19
+ * Leverage browser caching (expires headers) for better cache control
20
+ * Preload a page (on mouse hover) right before a user click on a link
21
+ * Disable ETag and set Cache-Control headers
22
 
23
  [youtube https://www.youtube.com/watch?v=nEFZLFyZNcE]
24
 
25
  **Follow the development of this plugin on [GitHub](https://github.com/dipakcg/wp-performance-score-booster)**
26
 
27
+ **P.S. It is always the best policy to open a [support thread](https://wordpress.org/support/plugin/wp-performance-score-booster#new-topic-0) first before posting any negative review.**
28
 
29
  == Installation ==
30
+ Just install from your WordPress “Plugins > Add New” screen and all will be well. Manual installation is very straightforward as well:
31
+
32
+ 1. Download the plugin (.zip file).
33
+ 2. Unzip it, and uplaod `wp-performance-score-booster` folder to the `/wp-content/plugins/` directory.
34
+ 3. Activate the plugin through the `Plugins` menu in WordPress.
35
+ 4. That’s it!
36
 
37
  == Frequently Asked Questions ==
38
  = What does this plugin do? =
39
 
40
+ This plugin makes website faster, speed-up page load time and instantly improve website scores in services like GTmetrix, Pingdom, YSlow and PageSpeed.
41
 
42
  = Any specific requirements for this plugin to work? =
43
 
44
+ * GZIP compression ( `mod_deflat` module ) should be enabled in your web-server. If not then you can ask your web hosting provider to enable it for you.
45
+ * `.htaccess` in your WordPress root folder must have write permissions.
46
 
47
  = What if I get 500 Internal Server Error? =
48
 
49
  If you get "500 - Internal Server Error" after you activate the plugin, Follow the steps below:
50
 
51
+ 1. Login to your FTP or open File Manager (ask your hosting provider).
52
+ 2. Go to the WordPress installation root directory and then `wp-content/wp-performance-score-booster` directory.
53
+ 3. Copy `.htaccess.wppsb` file.
54
+ 4. Now move back to WordPress installation root directory and Rename the `.htaccess` file (to something like .htaccess.bak).
55
+ 5. Paste `.htaccess.wppsb` file (copied from step 3) and rename it to `.htaccess`.
56
+
57
+ That's it! Your site should be up and running now.
58
 
59
+ _• You can still open a [support thread](https://wordpress.org/support/plugin/wp-performance-score-booster#new-topic-0) if you have any issues._
60
 
61
+ = This plugin improved the performance of my site, how do I thank you? =
62
+
63
+ If this plugin has helped you in any way, you can:
64
+ - [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38): Donations help me to continue development and user support of this free awesome plugin for which I spend countless hours of my valuable time.
65
+ - [Review](https://wordpress.org/support/plugin/wp-performance-score-booster/reviews/?rate=5#new-post): Review this plugin with a 5-star rating.
66
+ - Recommend: Recommend this plugin to others.
67
 
68
  == Screenshots ==
69
  1. Admin Settings
70
 
71
  == Changelog ==
72
+ = 2.0, November 02, 2020 =
73
+ * New: Redesigned settings page
74
+ * New: Instant.page preloader that preload a page (on mouse hover) right before a user click on a link
75
+ * Improve: htaccess rules for better GZIP compression and leverage browser caching (expires headers) for better cache control
76
+ * Improve: Disable ETag and set Cache-Control headers
77
+
78
  = 1.9.2.2, December 19, 2018 =
79
  * Fixed "Remove any query strings from static resources" conflict in admin
80
 
154
  = 1.0, August 26, 2014 =
155
  * Initial release.
156
  * Born of WP Performance Score Booster.
157
+
158
+ == Upgrade Notice ==
159
+
160
+ = 2.0 =
161
+ This version adds support for page preloading, improves compression and caching rules for faster speed, and has newly designed settings page. Recommended upgrade.
162
+
163
+ == Credits ==
164
+ _• This plugin uses [instant.page](https://instant.page/) library for page preloading._
uninstall.php CHANGED
@@ -1,28 +1,52 @@
1
  <?php
2
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit; // Exit if accessed directly.
 
3
 
 
 
 
 
4
  delete_option( 'wppsb_plugin_version' );
5
  delete_option( 'wppsb_remove_query_strings' );
6
  delete_option( 'wppsb_enable_gzip' );
7
  delete_option( 'wppsb_expire_caching' );
 
8
  delete_option( 'wppsb_review_notice' );
9
  delete_option( 'wppsb_activation_date' );
10
 
11
- // Delete .htaccess backups (including backup storage page directory)
12
- delete_storage_dir( get_home_path() . 'wp-content/wp-performance-score-booster');
13
 
14
- function delete_storage_dir($dir) {
15
- $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
16
- $files = new RecursiveIteratorIterator($it,
17
- RecursiveIteratorIterator::CHILD_FIRST);
18
- foreach($files as $file) {
19
- if ($file->isDir()){
20
- rmdir($file->getRealPath());
21
- } else {
22
- unlink($file->getRealPath());
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  }
24
  }
25
- rmdir($dir);
26
- }
27
-
28
- ?>
 
 
1
  <?php
2
+ // Exit if accessed directly.
3
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;
4
 
5
+ // Load WP Performance Score Booster - plugin main file.
6
+ include_once( 'wp-performance-score-booster.php' );
7
+
8
+ /** Delete all the Plugin Options */
9
  delete_option( 'wppsb_plugin_version' );
10
  delete_option( 'wppsb_remove_query_strings' );
11
  delete_option( 'wppsb_enable_gzip' );
12
  delete_option( 'wppsb_expire_caching' );
13
+ delete_option( 'wppsb_instant_page_preload' );
14
  delete_option( 'wppsb_review_notice' );
15
  delete_option( 'wppsb_activation_date' );
16
 
 
 
17
 
18
+ /**********************************
19
+ * Delete the directory created for htaccess backup at the time of plugin activation
20
+ * location: wp-content/wp-performance-score-booster
21
+ **********************************/
22
+ wppsb_delete_dir( WPPSB_STORAGE_PATH );
23
+
24
+
25
+ /**********************************
26
+ * Delete directory and all the files within
27
+ **********************************/
28
+ function wppsb_delete_dir( $folderName ) {
29
+
30
+ if ( is_dir( $folderName ) ) {
31
+ $folderHandle = opendir( $folderName );
32
+ }
33
+
34
+ if ( !$folderHandle ) {
35
+ return false;
36
+ }
37
+
38
+ while( $file = readdir( $folderHandle ) ) {
39
+ if( $file != '.' && $file != '..' ) {
40
+ if( ! is_dir( $folderName. '/' . $file ) ) {
41
+ unlink( $folderName . '/' . $file );
42
+ } else {
43
+ wppsb_delete_dir( $folderName . '/' . $file );
44
+ }
45
  }
46
  }
47
+
48
+ closedir( $folderHandle );
49
+ rmdir( $folderName );
50
+
51
+ return true;
52
+ }
wp-performance-score-booster.php CHANGED
@@ -1,13 +1,18 @@
1
  <?php
2
- /*
3
- Plugin Name: WP Performance Score Booster
4
  Plugin URI: https://github.com/dipakcg/wp-performance-score-booster
5
- Description: Speed-up page load times and improve website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.
6
- Version: 1.9.2.2
7
  Author: Dipak C. Gajjar
8
  Author URI: https://dipakgajjar.com
 
9
  Text Domain: wp-performance-score-booster
10
- */
 
 
 
 
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
13
 
@@ -15,23 +20,38 @@ include_once ( ABSPATH . 'wp-admin/includes/file.php' ); // to get get_home_path
15
  include_once ( ABSPATH . 'wp-admin/includes/plugin.php' ); // to is_plugin_active()() function work
16
 
17
  // Define plugin version for future releases
18
- if (!defined('WPPSB_PLUGIN_VERSION')) {
19
- define('WPPSB_PLUGIN_VERSION', '1.9.2.2');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  }
21
 
22
- define( 'WPPSB_PATH', WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) ); // plugin Path
23
- define( 'WPPSB_FILE', __FILE__ ); // plugin file
24
- define( 'WPPSB_URL', plugins_url( '', __FILE__ ) ); // plugin url
25
- define( 'WPPSB_STORAGE_PATH', get_home_path() . 'wp-content/wp-performance-score-booster' ); // storage path to store .htaccess backups
26
 
27
- include_once 'admin-page.php'; // admin options page.
28
- include_once 'data-processing.php'; // process the data such as remove query strings, enable gzip and leverage browser caching.
 
 
 
 
 
29
 
30
- global $wppsb_plugin_version, $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching;
31
- $wppsb_plugin_version = ( get_option('wppsb_plugin_version') ? get_option('wppsb_plugin_version') : WPPSB_PLUGIN_VERSION );
32
- $wppsb_remove_query_strings = ( FALSE !== get_option('wppsb_remove_query_strings') ? get_option('wppsb_remove_query_strings') : 'on' );
33
- $wppsb_enable_gzip = ( FALSE !== get_option('wppsb_enable_gzip') ? get_option('wppsb_enable_gzip') : 'on' );
34
- $wppsb_expire_caching = ( FALSE !== get_option('wppsb_expire_caching') ? get_option('wppsb_expire_caching') : 'on' );
35
 
36
  function wppsb_load_plugin_textdomain() {
37
 
@@ -40,63 +60,54 @@ function wppsb_load_plugin_textdomain() {
40
 
41
  // wp-content/languages/plugin-name/plugin-name-de_DE.mo
42
  load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
 
43
  // wp-content/plugins/plugin-name/languages/plugin-name-de_DE.mo
44
- load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
45
 
46
  }
47
 
 
48
  // Call all the functions together to hook with init()
49
  function wppsb_master_init () {
 
50
  wppsb_load_plugin_textdomain(); // load plugin textdomain for language trnaslation
51
  wppsb_update_checker(); // Check if plugin updated
 
 
 
 
52
  }
53
  add_action( 'init', 'wppsb_master_init' );
54
 
 
55
  // Call all the functions together to hook with admin_init()
56
  function wppsb_master_admin_init () {
 
57
  wppsb_add_stylesheet(); // adds plugin stylesheet
58
  wppsb_update_processor(); // Reload the config (rewrite rules) after applying plugin updates
59
 
60
- /* BEGIN : Rate this plugin on wordpress */
61
- // check for admin notice dismissal
62
- if ( isset( $_POST['wppsb-already-reviewed'] ) ) {
63
- update_option( 'wppsb_review_notice', "" );
64
- if ( get_option( 'wppsb_activation_date' ) ) {
65
- delete_option( 'wppsb_activation_date' );
66
- }
67
- }
68
-
69
- // display admin notice after 30 days if clicked 'May be later'
70
- if ( isset( $_POST['wppsb-review-later'] ) ) {
71
- update_option( 'wppsb_review_notice', "" );
72
- update_option( 'wppsb_activation_date', strtotime( "now" ) );
73
- }
74
-
75
- $install_date = get_option( 'wppsb_activation_date' );
76
- $past_date = strtotime( '-30 days' );
77
-
78
- if ( FALSE !== get_option( 'wppsb_activation_date' ) && $past_date >= $install_date ) {
79
- update_option( 'wppsb_review_notice', "on" );
80
- delete_option( 'wppsb_activation_date' );
81
- }
82
- /* END : Rate this plugin on wordpress */
83
  }
84
  add_action( 'admin_init', 'wppsb_master_admin_init' );
85
 
 
86
  // Add settings link on plugin page
87
- function dcg_settings_link($links) {
 
88
  // $settings_link = '<a href="admin.php?page=wp-performance-score-booster">Settings</a>';
89
  $wppsb_links = array( '<a href="options-general.php?page=wp-performance-score-booster">Settings</a>' );
90
  // array_unshift($links, $settings_link);
91
- $links = array_merge($wppsb_links, $links);
 
92
  return $links;
93
  }
94
- add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'dcg_settings_link' );
 
95
 
96
  // Adding WordPress plugin meta links
97
  function wppsb_plugin_meta_links( $links, $file ) {
98
  // Create link
99
- if ( $file == plugin_basename(__FILE__) ) {
100
  return array_merge(
101
  $links,
102
  array( '<a href="https://dipakgajjar.com/products/wordpress-speed-optimization-service?utm_source=plugins%20page&utm_medium=text%20link&utm_campaign=wordplress%20plugins" style="color:#FF0000;" target="_blank">Order WordPress Speed Optimisation Service</a>' )
@@ -106,13 +117,12 @@ function wppsb_plugin_meta_links( $links, $file ) {
106
  }
107
  add_filter( 'plugin_row_meta', 'wppsb_plugin_meta_links', 10, 2 );
108
 
109
- // Register with hook 'wp_enqueue_scripts', which can be used for front end CSS and JavaScript
110
  function wppsb_add_stylesheet() {
111
- // Respects SSL, style.css is relative to the current file
112
- wp_register_style( 'wppsb-stylesheet', WPPSB_URL . '/assets/css/style.min.css' );
113
- wp_enqueue_style( 'wppsb-stylesheet' );
114
  }
115
 
 
116
  // Add header
117
  function wppsb_add_header() {
118
  // Get the plugin version from options (in the database)
@@ -121,103 +131,96 @@ function wppsb_add_header() {
121
  <!-- Speed of this site is optimised by WP Performance Score Booster plugin v$wppsb_plugin_version - https://dipakgajjar.com/wp-performance-score-booster/ -->
122
  EOD;
123
  $head_comment = $head_comment . PHP_EOL;
124
- print ($head_comment);
125
- }
126
- add_action('wp_head', 'wppsb_add_header', 1);
127
-
128
- // If 'Remove query strings" checkbox ticked, add filter otherwise remove filter
129
- if ( $wppsb_remove_query_strings == 'on') {
130
- // Disable the functionality under Admin to avoid any conflicts
131
- if ( ! is_admin() ) {
132
- add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
133
- add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
134
- }
135
- }
136
- else {
137
- remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_q');
138
- remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_q');
139
  }
 
 
140
 
141
  // Display admin notice to apply changes in the occurrence of update (when plugin updated)
142
  function wppsb_apply_updates_notice() {
143
  global $wppsb_plugin_version;
144
- $notice_contents = "<p style=\"font-size: 15px; color: #FF9900;\">WP Performance Score Booster has been updated to version: " . WPPSB_PLUGIN_VERSION . "</p>";
145
- $notice_contents .= "<p><a href=\"options-general.php?page=wp-performance-score-booster&apply-updates=true\" class=\"button button-primary\" style=\"font-size: 15px; color: #FFFFFF; font-weight: bold;\">Apply Changes</a></p>";
146
  ?>
147
- <div class="notice notice-success"><p><strong><?php _e($notice_contents, 'wp-performance-score-booster'); ?></strong></p></div>
148
  <?php
149
  }
150
 
 
151
  // Check if plugin updated
152
  function wppsb_update_checker() {
 
153
  global $wppsb_plugin_version;
154
- if ($wppsb_plugin_version != WPPSB_PLUGIN_VERSION) {
155
- if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
156
  add_action( 'admin_notices', 'wppsb_apply_updates_notice' );
157
  }
158
  }
 
159
  }
160
 
 
161
  // If 'Apply Updates' clicked under admin notice (in case of plugin updated)
162
  function wppsb_update_processor() {
163
- global $wppsb_plugin_version , $wppsb_enable_gzip, $wppsb_expire_caching;
164
- if ( isset($_GET['apply-updates']) && $_GET['apply-updates'] == 'true' ) {
165
- if ($wppsb_plugin_version != WPPSB_PLUGIN_VERSION) {
166
- update_option('wppsb_plugin_version', WPPSB_PLUGIN_VERSION);
 
 
 
 
 
 
 
 
 
 
167
  flush_rewrite_rules();
168
- wppsb_save_mod_rewrite_rules($wppsb_enable_gzip, $wppsb_expire_caching);
169
  exit ( wp_redirect( admin_url( 'options-general.php?page=wp-performance-score-booster&update-applied=true' ) ) );
170
  }
171
  }
 
172
  }
173
 
174
- // Calling this function will make flush_rules to be called at the end of the PHP execution
175
- function wppsb_activate_plugin() {
176
-
177
- global $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching;
178
- wppsb_htaccess_bakup(); // Backup .htacces before appending any rules
179
 
180
- /* Create transient data for submit review admin notice */
181
- // set_transient( 'wppsb_submit_review_transient', true, 360 );
182
-
183
- // Rate this plugin on wordpress - check for admin notice dismissal
184
- if ( FALSE === get_option( 'wppsb_review_notice' ) ) {
185
- add_option( 'wppsb_review_notice', "on" );
 
 
186
  }
187
 
188
- // Save default options value in the database
189
- add_option( 'wppsb_plugin_version', WPPSB_PLUGIN_VERSION );
190
- add_option( 'wppsb_remove_query_strings', $wppsb_remove_query_strings );
191
-
192
- if ( $wppsb_remove_query_strings == 'on' ) {
193
- add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
194
- add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
195
  }
196
 
197
- if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) {
198
- add_option( 'wppsb_enable_gzip', $wppsb_enable_gzip );
199
- }
200
- else {
201
- add_option( 'wppsb_enable_gzip', '' );
202
- }
203
-
204
- add_option( 'wppsb_expire_caching', $wppsb_expire_caching );
205
 
206
- flush_rewrite_rules();
207
- wppsb_save_mod_rewrite_rules($wppsb_enable_gzip, $wppsb_expire_caching);
 
 
208
  }
209
- register_activation_hook( __FILE__, 'wppsb_activate_plugin' );
210
 
211
 
212
  /* Add admin notice for requesting plugin review */
213
- add_action( 'admin_notices', 'wppsb_submit_review_notice' );
214
  function wppsb_submit_review_notice() {
215
  global $wppsb_plugin_version;
216
 
217
  /* Display review plugin notice if plugin updated */
218
  // only applies to older versions of the plugin (older than 1.9.1) where option isn't set
 
219
  if ( isset( $_GET['update-applied'] ) && $_GET['update-applied'] == 'true' ) {
220
- if ( FALSE === get_option('wppsb_review_notice' ) ) {
221
  update_option( 'wppsb_review_notice', "on" );
222
  }
223
  }
@@ -226,23 +229,23 @@ function wppsb_submit_review_notice() {
226
  // if( get_transient( 'wppsb_submit_review_transient' ) || !get_user_meta( $user_id, 'wppsb_submit_review_dismissed' ) ) {
227
  if( get_option( 'wppsb_review_notice') && get_option( 'wppsb_review_notice' ) == "on" ) {
228
 
229
- $notice_contents = "<p> Thank you for using <strong>WP Performance Score Booster</strong>. </p>";
230
- $notice_contents .= "<p> Could you please do me a BIG favour and give this plugin a 5-star rating on WordPress? It will help me spread the word and boost my motivation. Dipak C. Gajjar </p>";
231
- $notice_contents .= "<p> <a href=\"#\"id=\"letMeReview\" class=\"button button-primary\">Yes, you deserve it</a> &nbsp; <a href=\"#\" id=\"willReviewLater\" class=\"button button-primary\">Maybe later</a> &nbsp; <a href=\"#\" id=\"alredyReviewed\" class=\"button button-primary\">I already did it</a> </p>";
232
  ?>
233
- <div class="notice notice-info is-dismissible" id="wppsb-review-notice"> <?php _e($notice_contents, 'wp-performance-score-booster'); ?> </div>
234
  <script type="text/javascript">
235
  // set jQuery in noConflict mode. This helps to mitigate conflicts between jQuery scripts. jQuery conflicts are all too common with themes and plugins.
236
  var $j = jQuery.noConflict();
237
  $j(document).ready( function() {
238
  var loc = location.href;
239
  // loc += loc.indexOf("?") === -1 ? "?" : "&";
240
-
241
  $j("#letMeReview").on('click', function() {
242
  /*jQuery('.notice').slideUp("slow", function(){;
243
  window.open("//wordpress.org/support/plugin/wp-performance-score-booster/reviews/?rate=5#new-post", "_blank");
244
  });*/
245
- $j('.notice').slideUp();
246
  $j.ajax({
247
  url: loc,
248
  type: 'POST',
@@ -254,8 +257,9 @@ function wppsb_submit_review_notice() {
254
  }
255
  });
256
  });
 
257
  $j("#willReviewLater").on('click', function() {
258
- $j('.notice').slideUp();
259
  $j.ajax({
260
  url: loc,
261
  type: 'POST',
@@ -267,8 +271,20 @@ function wppsb_submit_review_notice() {
267
  } */
268
  });
269
  });
 
270
  $j("#alredyReviewed").on('click', function() {
271
- $j('.notice').slideUp();
 
 
 
 
 
 
 
 
 
 
 
272
  $j.ajax({
273
  url: loc,
274
  type: 'POST',
@@ -278,7 +294,8 @@ function wppsb_submit_review_notice() {
278
  });
279
  });
280
  /* If top-right X button clicked */
281
- $j(document).on('click', '#wppsb-review-notice .notice-dismiss', function() {
 
282
  $j.ajax({
283
  url: loc,
284
  type: 'POST',
@@ -287,34 +304,81 @@ function wppsb_submit_review_notice() {
287
  }
288
  });
289
  });
 
290
  });
291
  </script>
292
  <?php
293
  // delete_transient( 'wppsb_submit_review_transient' );
294
  }
295
  }
 
296
 
297
- function wppsb_htaccess_bakup() {
298
- if (!file_exists( WPPSB_STORAGE_PATH )) {
299
- mkdir( WPPSB_STORAGE_PATH, 0777, true );
 
 
 
 
 
 
 
 
300
  }
301
 
302
- $htaccess_file = get_home_path() . '.htaccess'; // original .htaccess file
303
- $htaccess_bak = WPPSB_STORAGE_PATH . '/.htaccess.wppsb';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
 
305
- copy($htaccess_file, $htaccess_bak);
 
306
  }
 
 
307
 
308
  // Remove filters/functions on plugin deactivation
309
  function wppsb_deactivate_plugin() {
310
 
311
- // Clear (off) all the options value (from database)
312
- /* update_option( 'wppsb_remove_query_strings', "" );
313
- update_option( 'wppsb_enable_gzip', "" );
314
- update_option( 'wppsb_expire_caching', "" ); */
315
-
316
  flush_rewrite_rules();
317
- wppsb_save_mod_rewrite_rules('', '');
318
  }
319
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
320
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /****************************************
3
+ Plugin Name: WP Performance Score Booster
4
  Plugin URI: https://github.com/dipakcg/wp-performance-score-booster
5
+ Description: Makes website faster, speeds up page load time, and instantly improves website performance scores in services like GTmetrix, Pingdom, YSlow, and PageSpeed.
6
+ Version: 2.0
7
  Author: Dipak C. Gajjar
8
  Author URI: https://dipakgajjar.com
9
+ License: GPL-2.0+
10
  Text Domain: wp-performance-score-booster
11
+ Contributors: dipakcg (for wordpress.org submission)
12
+ ****************************************/
13
+
14
+ // Exit if accessed directly.
15
+ if ( ! defined( 'ABSPATH' ) ) exit;
16
 
17
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
18
 
20
  include_once ( ABSPATH . 'wp-admin/includes/plugin.php' ); // to is_plugin_active()() function work
21
 
22
  // Define plugin version for future releases
23
+ if ( ! defined( 'WPPSB_PLUGIN_VERSION' ) ) {
24
+ define( 'WPPSB_PLUGIN_VERSION', '2.0' );
25
+ }
26
+
27
+ if ( ! defined( 'WPPSB_BASE' ) ) {
28
+ define( 'WPPSB_BASE', plugin_basename( __FILE__ ) ); // wp-performance-score-booster/wp-performance-score-booster.php
29
+ }
30
+
31
+ if ( ! defined( 'WPPSB_PATH' ) ) {
32
+ define( 'WPPSB_PATH', plugin_dir_path( __FILE__ ) ); // /home/user/var/www/wordpress/wp-content/plugins/wp-performance-score-booster/
33
+ }
34
+
35
+ if ( ! defined( 'WPPSB_URL' ) ) {
36
+ define( 'WPPSB_URL', plugin_dir_url( __FILE__ ) ); // http://example.com/wp-content/plugins/wp-performance-score-booster/
37
+ }
38
+
39
+ if ( ! defined( 'WPPSB_STORAGE_PATH' ) ) {
40
+ define( 'WPPSB_STORAGE_PATH', get_home_path() . 'wp-content/wp-performance-score-booster' ); // storage path to store .htaccess backups
41
+
42
  }
43
 
44
+ require_once WPPSB_PATH . 'admin-page.php'; // admin options page.
45
+ require_once WPPSB_PATH . 'data-processing.php'; // process the data such as remove query strings, enable gzip and leverage browser caching.
 
 
46
 
47
+ // Check if option values (from the database) exists in the database otherwise set on/active by default
48
+ global $wppsb_plugin_version, $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching, $wppsb_instant_page_preload;
49
+ $wppsb_plugin_version = ( get_option( 'wppsb_plugin_version' ) ? get_option( 'wppsb_plugin_version' ) : WPPSB_PLUGIN_VERSION );
50
+ $wppsb_remove_query_strings = ( FALSE !== get_option( 'wppsb_remove_query_strings' ) ? get_option( 'wppsb_remove_query_strings' ) : 'on' );
51
+ $wppsb_enable_gzip = ( FALSE !== get_option( 'wppsb_enable_gzip' ) ? get_option( 'wppsb_enable_gzip' ) : 'on' );
52
+ $wppsb_expire_caching = ( FALSE !== get_option( 'wppsb_expire_caching' ) ? get_option( 'wppsb_expire_caching' ) : 'on' );
53
+ $wppsb_instant_page_preload = ( FALSE !== get_option( 'wppsb_instant_page_preload' ) ? get_option( 'wppsb_instant_page_preload' ) : 'on' );
54
 
 
 
 
 
 
55
 
56
  function wppsb_load_plugin_textdomain() {
57
 
60
 
61
  // wp-content/languages/plugin-name/plugin-name-de_DE.mo
62
  load_textdomain( $domain, trailingslashit( WP_LANG_DIR ) . $domain . '/' . $domain . '-' . $locale . '.mo' );
63
+
64
  // wp-content/plugins/plugin-name/languages/plugin-name-de_DE.mo
65
+ load_plugin_textdomain( $domain, FALSE, WPPSB_PATH . '/languages/' );
66
 
67
  }
68
 
69
+
70
  // Call all the functions together to hook with init()
71
  function wppsb_master_init () {
72
+
73
  wppsb_load_plugin_textdomain(); // load plugin textdomain for language trnaslation
74
  wppsb_update_checker(); // Check if plugin updated
75
+
76
+ // Runs after WordPress load
77
+ do_action( 'wppsb_remove_query_string_action' );
78
+
79
  }
80
  add_action( 'init', 'wppsb_master_init' );
81
 
82
+
83
  // Call all the functions together to hook with admin_init()
84
  function wppsb_master_admin_init () {
85
+
86
  wppsb_add_stylesheet(); // adds plugin stylesheet
87
  wppsb_update_processor(); // Reload the config (rewrite rules) after applying plugin updates
88
 
89
+ do_action( 'wppsb_rating_system_action' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
  add_action( 'admin_init', 'wppsb_master_admin_init' );
92
 
93
+
94
  // Add settings link on plugin page
95
+ function dcg_settings_link( $links ) {
96
+
97
  // $settings_link = '<a href="admin.php?page=wp-performance-score-booster">Settings</a>';
98
  $wppsb_links = array( '<a href="options-general.php?page=wp-performance-score-booster">Settings</a>' );
99
  // array_unshift($links, $settings_link);
100
+ $links = array_merge( $wppsb_links, $links );
101
+
102
  return $links;
103
  }
104
+ add_filter( 'plugin_action_links_' . WPPSB_BASE, 'dcg_settings_link' );
105
+
106
 
107
  // Adding WordPress plugin meta links
108
  function wppsb_plugin_meta_links( $links, $file ) {
109
  // Create link
110
+ if ( $file === plugin_basename(__FILE__) ) {
111
  return array_merge(
112
  $links,
113
  array( '<a href="https://dipakgajjar.com/products/wordpress-speed-optimization-service?utm_source=plugins%20page&utm_medium=text%20link&utm_campaign=wordplress%20plugins" style="color:#FF0000;" target="_blank">Order WordPress Speed Optimisation Service</a>' )
117
  }
118
  add_filter( 'plugin_row_meta', 'wppsb_plugin_meta_links', 10, 2 );
119
 
120
+
121
  function wppsb_add_stylesheet() {
122
+ wp_enqueue_style( 'wppsb-stylesheet', WPPSB_URL . '/assets/css/style.min.css' );
 
 
123
  }
124
 
125
+
126
  // Add header
127
  function wppsb_add_header() {
128
  // Get the plugin version from options (in the database)
131
  <!-- Speed of this site is optimised by WP Performance Score Booster plugin v$wppsb_plugin_version - https://dipakgajjar.com/wp-performance-score-booster/ -->
132
  EOD;
133
  $head_comment = $head_comment . PHP_EOL;
134
+ print ( $head_comment );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  }
136
+ add_action( 'wp_head', 'wppsb_add_header', 1 );
137
+
138
 
139
  // Display admin notice to apply changes in the occurrence of update (when plugin updated)
140
  function wppsb_apply_updates_notice() {
141
  global $wppsb_plugin_version;
142
+ $notice_contents = '<p class="update_notice">WP Performance Score Booster has been updated to version: ' . WPPSB_PLUGIN_VERSION . '</p>';
143
+ $notice_contents .= '<p><a href="options-general.php?page=wp-performance-score-booster&apply-updates=true" class="button button-primary" id="wppsb_save_button">Apply Changes</a></p>';
144
  ?>
145
+ <div class="notice notice-success" id="wppsb_notice_div"><strong><?php _e( $notice_contents, 'wp-performance-score-booster' ); ?></strong></div>
146
  <?php
147
  }
148
 
149
+
150
  // Check if plugin updated
151
  function wppsb_update_checker() {
152
+
153
  global $wppsb_plugin_version;
154
+ if ( $wppsb_plugin_version !== WPPSB_PLUGIN_VERSION ) {
155
+ if ( is_plugin_active( WPPSB_BASE ) ) {
156
  add_action( 'admin_notices', 'wppsb_apply_updates_notice' );
157
  }
158
  }
159
+
160
  }
161
 
162
+
163
  // If 'Apply Updates' clicked under admin notice (in case of plugin updated)
164
  function wppsb_update_processor() {
165
+
166
+ global $wppsb_plugin_version, $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching, $wppsb_instant_page_preload;
167
+
168
+ if ( isset( $_GET['apply-updates'] ) && $_GET['apply-updates'] == 'true' ) {
169
+ if ( $wppsb_plugin_version != WPPSB_PLUGIN_VERSION ) {
170
+
171
+ update_option( 'wppsb_plugin_version', WPPSB_PLUGIN_VERSION );
172
+
173
+ if ( FALSE === get_option( 'wppsb_instant_page_preload' ) ) {
174
+ add_option( 'wppsb_instant_page_preload', $wppsb_instant_page_preload );
175
+ }
176
+
177
+ wppsb_htaccess_bakup(); // Backup .htacces before appending any rules
178
+
179
  flush_rewrite_rules();
180
+ wppsb_save_mod_rewrite_rules( $wppsb_enable_gzip, $wppsb_expire_caching );
181
  exit ( wp_redirect( admin_url( 'options-general.php?page=wp-performance-score-booster&update-applied=true' ) ) );
182
  }
183
  }
184
+
185
  }
186
 
 
 
 
 
 
187
 
188
+ // Plugin rating on wordpress.org
189
+ function wppsb_rating_checker() {
190
+ // check for admin notice dismissal
191
+ if ( isset( $_POST['wppsb-already-reviewed'] ) ) {
192
+ update_option( 'wppsb_review_notice', '' );
193
+ if ( get_option( 'wppsb_activation_date' ) ) {
194
+ delete_option( 'wppsb_activation_date' );
195
+ }
196
  }
197
 
198
+ // display admin notice after 30 days if clicked 'May be later'
199
+ if ( isset( $_POST['wppsb-review-later'] ) ) {
200
+ update_option( 'wppsb_review_notice', '' );
201
+ update_option( 'wppsb_activation_date', strtotime( 'now' ) );
 
 
 
202
  }
203
 
204
+ $install_date = get_option( 'wppsb_activation_date' );
205
+ $past_date = strtotime( '-30 days' );
 
 
 
 
 
 
206
 
207
+ if ( FALSE !== get_option( 'wppsb_activation_date' ) && $past_date >= $install_date ) {
208
+ update_option( 'wppsb_review_notice', 'on' );
209
+ delete_option( 'wppsb_activation_date' );
210
+ }
211
  }
212
+ add_action( 'wppsb_rating_system_action', 'wppsb_rating_checker' );
213
 
214
 
215
  /* Add admin notice for requesting plugin review */
 
216
  function wppsb_submit_review_notice() {
217
  global $wppsb_plugin_version;
218
 
219
  /* Display review plugin notice if plugin updated */
220
  // only applies to older versions of the plugin (older than 1.9.1) where option isn't set
221
+ // As version 2.0 is a major release, let's force users to submit review on wordpress.org
222
  if ( isset( $_GET['update-applied'] ) && $_GET['update-applied'] == 'true' ) {
223
+ if ( FALSE === get_option('wppsb_review_notice' || WPPSB_PLUGIN_VERSION == '2.0' ) ) {
224
  update_option( 'wppsb_review_notice', "on" );
225
  }
226
  }
229
  // if( get_transient( 'wppsb_submit_review_transient' ) || !get_user_meta( $user_id, 'wppsb_submit_review_dismissed' ) ) {
230
  if( get_option( 'wppsb_review_notice') && get_option( 'wppsb_review_notice' ) == "on" ) {
231
 
232
+ $notice_contents = '<p> Thank you for using <strong>WP Performance Score Booster</strong>. </p>';
233
+ $notice_contents .= '<p> Could you please do me a BIG favour and give this plugin a 5-star rating on WordPress? It won\'t take more than a minute, and help me spread the word and boost my motivation. - Dipak C. Gajjar </p>';
234
+ $notice_contents .= '<p> <a href="#" id="letMeReview" class="button button-primary">Yes, you deserve it</a> &nbsp; <a href="#" id="willReviewLater" class="button button-primary">Maybe later</a> &nbsp; <a href="#" id="alredyReviewed" class="button button-primary">I already did it</a> &nbsp; <a href="#" id="noThanks" class="button button-primary">No, Thanks</a> </p>';
235
  ?>
236
+ <div class="notice notice-info is-dismissible" id="wppsb_notice_div"> <?php _e( $notice_contents, 'wp-performance-score-booster' ); ?> </div>
237
  <script type="text/javascript">
238
  // set jQuery in noConflict mode. This helps to mitigate conflicts between jQuery scripts. jQuery conflicts are all too common with themes and plugins.
239
  var $j = jQuery.noConflict();
240
  $j(document).ready( function() {
241
  var loc = location.href;
242
  // loc += loc.indexOf("?") === -1 ? "?" : "&";
243
+ // Yes, you deserve it
244
  $j("#letMeReview").on('click', function() {
245
  /*jQuery('.notice').slideUp("slow", function(){;
246
  window.open("//wordpress.org/support/plugin/wp-performance-score-booster/reviews/?rate=5#new-post", "_blank");
247
  });*/
248
+ $j('#wppsb_notice_div').slideUp();
249
  $j.ajax({
250
  url: loc,
251
  type: 'POST',
257
  }
258
  });
259
  });
260
+ // Maybe later
261
  $j("#willReviewLater").on('click', function() {
262
+ $j('#wppsb_notice_div').slideUp();
263
  $j.ajax({
264
  url: loc,
265
  type: 'POST',
271
  } */
272
  });
273
  });
274
+ // I already did it
275
  $j("#alredyReviewed").on('click', function() {
276
+ $j('#wppsb_notice_div').slideUp();
277
+ $j.ajax({
278
+ url: loc,
279
+ type: 'POST',
280
+ data: {
281
+ "wppsb-already-reviewed": ''
282
+ }
283
+ });
284
+ });
285
+ // No, thanks
286
+ $j("#noThanks").on('click', function() {
287
+ $j('#wppsb_notice_div').slideUp();
288
  $j.ajax({
289
  url: loc,
290
  type: 'POST',
294
  });
295
  });
296
  /* If top-right X button clicked */
297
+ $j(document).on('click', '#wppsb_notice_div .notice-dismiss', function() {
298
+ $j('#wppsb_notice_div').slideUp();
299
  $j.ajax({
300
  url: loc,
301
  type: 'POST',
304
  }
305
  });
306
  });
307
+
308
  });
309
  </script>
310
  <?php
311
  // delete_transient( 'wppsb_submit_review_transient' );
312
  }
313
  }
314
+ add_action( 'admin_notices', 'wppsb_submit_review_notice' );
315
 
316
+
317
+ // Calling this function will make flush_rules to be called at the end of the PHP execution
318
+ function wppsb_activate_plugin() {
319
+
320
+ global $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching, $wppsb_instant_page_preload;
321
+
322
+ /* Yes, we're using add_option, not update_option intentionally just to force rewrite htaccess rules */
323
+
324
+ // Rate this plugin on wordpress.org - check for admin notice dismissal
325
+ if ( FALSE === get_option( 'wppsb_review_notice' ) ) {
326
+ add_option( 'wppsb_review_notice', "on" );
327
  }
328
 
329
+ // Save default options value in the database
330
+ add_option( 'wppsb_plugin_version', WPPSB_PLUGIN_VERSION );
331
+ add_option( 'wppsb_remove_query_strings', $wppsb_remove_query_strings );
332
+ add_option( 'wppsb_instant_page_preload', $wppsb_instant_page_preload );
333
+
334
+ // Check if GZIP / mod_deflate is enabled in hosting server?
335
+ if ( function_exists( 'ob_gzhandler' ) || ini_get( 'zlib.output_compression' ) ) {
336
+ add_option( 'wppsb_enable_gzip', $wppsb_enable_gzip );
337
+ }
338
+ else {
339
+ add_option( 'wppsb_enable_gzip', '' );
340
+ }
341
+
342
+ add_option( 'wppsb_expire_caching', $wppsb_expire_caching );
343
+
344
+ wppsb_htaccess_bakup(); // Backup .htacces before appending any rules
345
 
346
+ flush_rewrite_rules();
347
+ wppsb_save_mod_rewrite_rules( $wppsb_enable_gzip, $wppsb_expire_caching );
348
  }
349
+ register_activation_hook( __FILE__, 'wppsb_activate_plugin' );
350
+
351
 
352
  // Remove filters/functions on plugin deactivation
353
  function wppsb_deactivate_plugin() {
354
 
 
 
 
 
 
355
  flush_rewrite_rules();
356
+ wppsb_save_mod_rewrite_rules( '', '' );
357
  }
358
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
359
+
360
+
361
+ function wppsb_htaccess_bakup() {
362
+ if ( ! file_exists( WPPSB_STORAGE_PATH ) ) {
363
+ mkdir( WPPSB_STORAGE_PATH, 0777, true );
364
+ }
365
+
366
+ $htaccess_file = get_home_path() . '.htaccess'; // original .htaccess file
367
+ $htaccess_bak = WPPSB_STORAGE_PATH . '/.htaccess.wppsb';
368
+
369
+ if ( ! copy( $htaccess_file, $htaccess_bak ) ) {
370
+ echo 'Failed to backup .htaccess file!';
371
+ }
372
+ }
373
+
374
+
375
+ /**********************************
376
+ * DEBUG
377
+ **********************************/
378
+ /* function wppsb_save_error() {
379
+ update_option( 'wppsb_plugin_error', ob_get_contents() );
380
+ }
381
+
382
+ add_action( 'activated_plugin', 'wppsb_save_error' );
383
+
384
+ echo get_option( 'wppsb_plugin_error' ); */