WP Performance Score Booster - Version 1.1

Version Description

Download this release

Release Info

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

Code changes from version 1.0 to 1.1

assets/css/style.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wppsb_settings {
2
+ font-size: 16px !important;
3
+ }
4
+ .wppsb_admin_dev_sidebar_div {
5
+ width:300px;
6
+ height:300px;
7
+ -webkit-border-radius: 10px;
8
+ -moz-border-radius: 10px;
9
+ border-radius: 10px;
10
+ background-color:#FFFFFF;
11
+ padding: 20px 0 0 30px;
12
+ }
13
+ .wppsb_admin_dev_sidebar {
14
+ font-size: 13px;
15
+ margin: 0 20px 5px 0;
16
+ display: block;
17
+ }
18
+ .wppsb_admin_dev_sidebar a{
19
+ text-decoration: none;
20
+ }
assets/images/wppsb-github-16x16.png ADDED
Binary file
assets/images/wppsb-icon-24x24.png ADDED
Binary file
assets/images/wppsb-other-plugins-16x16.png ADDED
Binary file
assets/images/wppsb-rate-this-16x16.png ADDED
Binary file
assets/images/wppsb-support-this-16x16.png ADDED
Binary file
assets/images/wppsb-twitter-16x16.png ADDED
Binary file
assets/images/wppsb-wordpress-16x16.png ADDED
Binary file
readme.txt CHANGED
@@ -1,46 +1,45 @@
1
  === WP Performance Score Booster ===
2
  Contributors: dipakcg
3
- Tags: remove, query, strings, static, resources, gzip, compression, expire, caching, booster, speed, performance, pingdom, gtmetrix, yslow, pagespeed, cache
 
4
  Requires at least: 3.5
5
- Tested up to: 3.9.2
6
- Stable tag: 1.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
10
- Helps you to improve your website performance scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.
11
 
12
  == Description ==
13
-
14
- This plugin will remove any query strings from static resources like CSS & JS files, enables GZIP Compression (compress text, html, javascript, css, xml and so on) and expires caching (leverage browser caching) to improve your speed scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.
15
-
16
- If you're using a WordPress cache plugin, don't forget to empty your cache before testing your site performance after activating the plugin.
17
-
18
- Feel free to contact me if you have any questions about the plugin: [Dipak C. Gajjar](https://twitter.com/dipakcgajjar)
19
 
20
  == Installation ==
21
-
22
  1. Upload the `wp-performance-score-booster` folder to the `/wp-content/plugins/` directory
 
 
23
 
24
- 2. Activate the plugin through the 'Plugins' menu in WordPress.
 
25
 
26
- 3. That's it!
27
 
28
- == Frequently Asked Questions ==
29
-
30
- = What does this plugin do? =
31
-
32
- It helps you to improve your website scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix. It will remove any query strings from static resources like CSS & JS files, enables GZIP Compression (compress text, html, javascript, css, xml and so on) and expires caching (leverage browser caching).
33
-
34
  = Any specific requirements for this plugin to work? =
35
 
36
- Yes, First, GZIP compression should be enabled in your web-server (apache?), and second, .htaccess in your root folder must have write permissions (chmod 777).
37
-
38
- = Is that it? =
39
-
40
  Pretty much, yeah.
41
 
 
 
 
42
  == Changelog ==
43
- = 1.0 =
44
-
 
 
45
  * Initial release
46
 
 
 
1
  === WP Performance Score Booster ===
2
  Contributors: dipakcg
3
+ Tags: performance, load, speed, time, remove, query, strings, static, resources, gzip, compression, expire, caching, boost, pingdom, gtmetrix, yslow, 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: 4.0
7
+ Stable tag: 1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Helps you to improve your website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.
12
 
13
  == Description ==
14
+ This plugin helps you to improve your 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) and set expires caching (leverage browser caching) to improve your site performance scores.
 
 
 
 
 
15
 
16
  == Installation ==
 
17
  1. Upload the `wp-performance-score-booster` folder to the `/wp-content/plugins/` directory
18
+ 2. Activate the plugin through the \'Plugins\' menu in WordPress.
19
+ 3. That\'s it!
20
 
21
+ == Frequently Asked Questions ==
22
+ = What does this plugin do? =
23
 
24
+ It helps you to improve your website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix. It will remove any query strings from static resources like CSS & JS files, enables GZIP Compression (compress text, html, javascript, css, xml and so on) and expires caching (leverage browser caching).
25
 
 
 
 
 
 
 
26
  = Any specific requirements for this plugin to work? =
27
 
28
+ Yes, First, GZIP compression should be enabled in your web-server (apache?), and second, .htaccess in your root folder must have write permissions (chmod 777).
29
+
30
+ = Is that it? =
31
+
32
  Pretty much, yeah.
33
 
34
+ == Screenshots ==
35
+ 1. Admin Settings
36
+
37
  == Changelog ==
38
+ = 1.1, Aug 31, 2014 =
39
+ * Added Admin Options / Settings
40
+
41
+ = 1.0, Aug 26, 2014 =
42
  * Initial release
43
 
44
+ == Upgrade Notice ==
45
+ Added Admin Options / Settings.
wp-performance-score-booster.php CHANGED
@@ -2,24 +2,145 @@
2
  /*
3
  Plugin Name: WP Performance Score Booster
4
  Plugin URI: https://github.com/dipakcg/wp-performance-score-booster
5
- Description: Helps you to improve your website scores in services like PageSpeed, YSlow, Pingdoom and GTmetrix.
6
  Author: Dipak C. Gajjar
7
- Version: 1.0
8
  Author URI: http://www.dipakgajjar.com/
9
  */
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  // Remove query strings from static content
12
- function wppsb_remove_query_strings( $src ) {
13
  $rqs = explode( '?ver', $src );
14
  return $rqs[0];
15
  }
16
- add_filter( 'script_loader_src', 'wppsb_remove_query_strings', 15, 1 );
17
- add_filter( 'style_loader_src', 'wppsb_remove_query_strings', 15, 1 );
18
-
19
- function wppsb_add_to_htaccess( $rules ) {
20
 
21
- // Add the rewrite rules in .htaccess
22
- $htaccess_content = <<<EOD
 
23
  \n## Added by WP Performance Score Booster ##
24
  ## BEGIN : Enable GZIP Compression (compress text, html, javascript, css, xml and so on) ##
25
  <IfModule mod_deflate.c>
@@ -37,9 +158,15 @@ AddOutputFilterByType DEFLATE application/x-httpd-fastphp
37
  AddOutputFilterByType DEFLATE image/svg+xml
38
  SetOutputFilter DEFLATE
39
  </IfModule>
40
- ## END : Enable GZIP Compression ##
 
 
 
41
 
42
- ## Added by WP Performance Score Booster ##
 
 
 
43
  ## BEGIN : Expires Caching (Leverage Browser Caching) ##
44
  <IfModule mod_expires.c>
45
  ExpiresActive On
@@ -56,29 +183,55 @@ ExpiresDefault "access 2 week"
56
  </IfModule>
57
  ## END : Expires Caching (Leverage Browser Caching) ##\n\n
58
  EOD;
59
- return $htaccess_content . $rules;
60
  }
61
- add_filter('mod_rewrite_rules', 'wppsb_add_to_htaccess');
 
 
 
 
 
 
 
62
 
63
  // Calling this function will make flush_rules to be called at the end of the PHP execution
64
- function wppsb_enable_flush_rules() {
65
- global $wp_rewrite;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
 
67
- // Flush the rewrite rules
68
- $wp_rewrite->flush_rules();
69
  }
70
 
71
  // On plugin activation, call the function that will make flush_rules to be called at the end of the PHP execution
72
- register_activation_hook( __FILE__, 'wppsb_enable_flush_rules' );
73
 
74
  function wppsb_deactivate_plugin() {
75
- // This will remove the rewrite rules
76
- remove_filter('mod_rewrite_rules', 'wppsb_add_to_htaccess');
 
 
 
77
 
78
- global $wp_rewrite;
 
 
 
79
 
80
- // Flush the rewrite rules
81
- $wp_rewrite->flush_rules();
82
  }
83
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
84
  ?>
2
  /*
3
  Plugin Name: WP Performance Score Booster
4
  Plugin URI: https://github.com/dipakcg/wp-performance-score-booster
5
+ Description: Helps you to improve your website scores in services like PageSpeed, YSlow, Pingdom and GTmetrix.
6
  Author: Dipak C. Gajjar
7
+ Version: 1.1
8
  Author URI: http://www.dipakgajjar.com/
9
  */
10
 
11
+ // Register with hook 'wp_enqueue_scripts', which can be used for front end CSS and JavaScript
12
+ add_action( 'admin_init', 'wppsb_add_stylesheet' );
13
+ function wppsb_add_stylesheet() {
14
+ // Respects SSL, Style.css is relative to the current file
15
+ wp_register_style( 'wppsb-stylesheet', plugins_url('assets/css/style.css', __FILE__) );
16
+ wp_enqueue_style( 'wppsb-stylesheet' );
17
+ }
18
+
19
+ // Register admin menu
20
+ add_action( 'admin_menu', 'wppsb_add_admin_menu' );
21
+ function wppsb_add_admin_menu() {
22
+ // add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function);
23
+ add_menu_page( 'WP Performance Score Booster Options', 'WP Performance Score Booster', 'manage_options', 'wp-performance-score-booster', 'wppsb_admin_options', plugins_url('assets/images/wppsb-icon-24x24.png', __FILE__) );
24
+ }
25
+
26
+ function wppsb_admin_options() {
27
+ ?>
28
+ <div class="wrap">
29
+ <table width="100%" border="0">
30
+ <tr>
31
+ <td width="75%">
32
+ <h2><?php echo '<img src="' . plugins_url( 'assets/images/wppsb-icon-24x24.png' , __FILE__ ) . '" > '; ?> WP Performance Score Booster Settings</h2>
33
+ <hr />
34
+ <?php
35
+ if ( !current_user_can( 'manage_options' ) ) {
36
+ wp_die( __('You do not have sufficient permissions to access this page.') );
37
+ }
38
+
39
+ // Variables for the field and option names
40
+ $hidden_field_name = 'wppsb_submit_hidden';
41
+ $remove_query_strings = 'wppsb_remove_query_strings';
42
+ $enable_gzip = 'wppsb_enable_gzip';
43
+ $expire_caching = 'wppsb_expire_caching';
44
+
45
+ // Read in existing option value from database
46
+ $remove_query_strings_val = get_option($remove_query_strings);
47
+ $enable_gzip_val = get_option($enable_gzip);
48
+ $expire_caching_val = get_option($expire_caching);
49
+
50
+ // See if the user has posted us some information
51
+ // If they did, this hidden field will be set to 'Y'
52
+ if( isset($_POST[$hidden_field_name]) && $_POST[$hidden_field_name] == 'Y' ) {
53
+ // Read their posted value
54
+ $remove_query_strings_val = (isset($_POST[$remove_query_strings]) ? $_POST[$remove_query_strings] : "");
55
+ $enable_gzip_val = (isset($_POST[$enable_gzip]) ? $_POST[$enable_gzip] : "");
56
+ $expire_caching_val = (isset($_POST[$expire_caching]) ? $_POST[$expire_caching] : "");
57
+
58
+ // Save the posted value in the database
59
+ update_option( $remove_query_strings, $remove_query_strings_val );
60
+ update_option( $enable_gzip, $enable_gzip_val );
61
+ update_option( $expire_caching, $expire_caching_val );
62
+
63
+ // If 'Remove query strings" checkbox ticked, add filter otherwise remove filter
64
+ if ($remove_query_strings_val == 'on') {
65
+ add_filter( 'script_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
66
+ add_filter( 'style_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
67
+ }
68
+ else {
69
+ remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
70
+ remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
71
+ }
72
+
73
+ // If 'Enable GZIP" checkbox ticked, add filter otherwise remove filter
74
+ if ($enable_gzip_val == 'on') {
75
+ add_filter('mod_rewrite_rules', 'wppsb_enable_gzip_filter');
76
+ }
77
+ else {
78
+ remove_filter('mod_rewrite_rules', 'wppsb_enable_gzip_filter');
79
+ }
80
+
81
+ // If 'Expire caching" checkbox ticked, add filter otherwise remove filter
82
+ if ($expire_caching_val == 'on') {
83
+ add_filter('mod_rewrite_rules', 'wppsb_expire_caching_filter');
84
+ }
85
+ else {
86
+ remove_filter('mod_rewrite_rules', 'wppsb_expire_caching_filter');
87
+ }
88
+
89
+ flush_rewrite_rules();
90
+
91
+ // Put an settings updated message on the screen
92
+ ?>
93
+ <div class="updated"><p><strong>Settings Saved.</strong></p></div>
94
+ <?php
95
+ }
96
+ ?>
97
+ <form method="post" name="options_form">
98
+ <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
99
+ <p>
100
+ <input type="checkbox" name="<?php echo $remove_query_strings; ?>" <?php checked( $remove_query_strings_val == 'on',true); ?> /> &nbsp; <span class="wppsb_settings"> Remove query strings from static content </span>
101
+ </p>
102
+ <p>
103
+ <?php if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) { ?>
104
+ <input type="checkbox" name="<?php echo $enable_gzip; ?>" <?php checked( $enable_gzip_val == 'on',true); ?> /> &nbsp; <span class="wppsb_settings"> Enable GZIP compression (compress text, html, javascript, css, xml and so on)</span>
105
+ <?php }
106
+ else { ?>
107
+ <input type="checkbox" name="<?php echo $enable_gzip; ?>" disabled="true" <?php checked( $enable_gzip_val == 'on',true); ?> /> &nbsp; <span class="wppsb_settings"> Enable GZIP compression (compress text, html, javascript, css, xml and so on)</span> <br /> <span class="wppsb_settings" style="margin-left:30px; color:RED;">Your web server does not support GZIP compression. Contact your hosting provider to enable it.</span>
108
+ <?php } ?>
109
+ </p>
110
+ <p>
111
+ <input type="checkbox" name="<?php echo $expire_caching; ?>" <?php checked( $expire_caching_val == 'on',true); ?> /> &nbsp; <span class="wppsb_settings"> Set expire caching (Leverage Browser Caching) </span>
112
+ </p>
113
+ <p><input type="submit" value="<?php esc_attr_e('Save Changes') ?>" class="button button-primary" name="submit" /></p>
114
+ </form>
115
+ </td>
116
+ <td style="text-align: left;">
117
+ <div class="wppsb_admin_dev_sidebar_div">
118
+ <img src="http://www.gravatar.com/avatar/38b380cf488d8f8c4007cf2015dc16ac.jpg" width="100px" height="100px" /> <br />
119
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-support-this-16x16.png' , __FILE__ ) . '" > '; ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3S8BRPLWLNQ38" target="_blank"> Support this plugin and donate </a> </span>
120
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-rate-this-16x16.png' , __FILE__ ) . '" > '; ?> <a href="http://wordpress.org/support/view/plugin-reviews/wp-performance-score-booster" target="_blank"> Rate this plugin on WordPress.org </a> </span>
121
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-wordpress-16x16.png' , __FILE__ ) . '" > '; ?> <a href="http://wordpress.org/support/plugin/wp-performance-score-booster" target="_blank"> Get support on on WordPress.org </a> </span>
122
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-github-16x16.png' , __FILE__ ) . '" > '; ?> <a href="https://github.com/dipakcg/wp-performance-score-booster" target="_blank"> Contribute development on GitHub </a> </span>
123
+ <!-- <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-other-plugins-16x16.png' , __FILE__ ) . '" > '; ?> <a href="http://profiles.wordpress.org/dipakcg#content-plugins" target="_blank"> Get my other plugins </a> </span> -->
124
+ <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . plugins_url( 'assets/images/wppsb-twitter-16x16.png' , __FILE__ ) . '" > '; ?>Follow me on Twitter: <a href="https://twitter.com/dipakcgajjar" target="_blank">@dipakcgajjar</a> </span>
125
+ <br />
126
+ <span class="wppsb_admin_dev_sidebar" style="float: right;"> Version: <strong> 1.1 </strong> </span>
127
+ </div>
128
+ </td>
129
+ </tr>
130
+ </table>
131
+ </div>
132
+ <?php
133
+ }
134
+
135
  // Remove query strings from static content
136
+ function wppsb_remove_query_strings_filter( $src ) {
137
  $rqs = explode( '?ver', $src );
138
  return $rqs[0];
139
  }
 
 
 
 
140
 
141
+ // Enable GZIP Compression
142
+ function wppsb_enable_gzip_filter( $rules ) {
143
+ $gzip_htaccess_content = <<<EOD
144
  \n## Added by WP Performance Score Booster ##
145
  ## BEGIN : Enable GZIP Compression (compress text, html, javascript, css, xml and so on) ##
146
  <IfModule mod_deflate.c>
158
  AddOutputFilterByType DEFLATE image/svg+xml
159
  SetOutputFilter DEFLATE
160
  </IfModule>
161
+ ## END : Enable GZIP Compression ##\n\n
162
+ EOD;
163
+ return $gzip_htaccess_content . $rules;
164
+ }
165
 
166
+ // Enable expire caching
167
+ function wppsb_expire_caching_filter( $rules ) {
168
+ $expire_cache_htaccess_content = <<<EOD
169
+ \n## Added by WP Performance Score Booster ##
170
  ## BEGIN : Expires Caching (Leverage Browser Caching) ##
171
  <IfModule mod_expires.c>
172
  ExpiresActive On
183
  </IfModule>
184
  ## END : Expires Caching (Leverage Browser Caching) ##\n\n
185
  EOD;
186
+ return $expire_cache_htaccess_content . $rules;
187
  }
188
+
189
+ function wppsb_add_header() {
190
+ $head_comment = <<<EOD
191
+ <!-- Performance scores of this site is tuned by WP Performance Score Booster plugin v1.1 - http://wordpress.org/plugins/wp-performance-score-booster -->\n
192
+ EOD;
193
+ echo $head_comment;
194
+ }
195
+ add_action('wp_head', 'wppsb_add_header', 1);
196
 
197
  // Calling this function will make flush_rules to be called at the end of the PHP execution
198
+ function wppsb_activate_plugin() {
199
+
200
+ // Save default options value in the database
201
+ update_option( 'wppsb_remove_query_strings', 'on' );
202
+ add_filter( 'script_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
203
+ add_filter( 'style_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
204
+
205
+ if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) {
206
+ update_option( 'wppsb_enable_gzip', 'on' );
207
+ add_filter('mod_rewrite_rules', 'wppsb_enable_gzip_filter');
208
+ }
209
+ else {
210
+ update_option( 'wppsb_enable_gzip', '' );
211
+ }
212
+
213
+ update_option( 'wppsb_expire_caching', 'on' );
214
+ add_filter('mod_rewrite_rules', 'wppsb_expire_caching_filter');
215
 
216
+ flush_rewrite_rules();
 
217
  }
218
 
219
  // On plugin activation, call the function that will make flush_rules to be called at the end of the PHP execution
220
+ register_activation_hook( __FILE__, 'wppsb_activate_plugin' );
221
 
222
  function wppsb_deactivate_plugin() {
223
+ // Remove filters on plugin deactivate
224
+ remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
225
+ remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_filter', 15, 1 );
226
+ remove_filter('mod_rewrite_rules', 'wppsb_enable_gzip_filter');
227
+ remove_filter('mod_rewrite_rules', 'wppsb_expire_caching_filter');
228
 
229
+ // Delete default options value in the database
230
+ /* delete_option( 'wppsb_remove_query_strings' );
231
+ delete_option( 'wppsb_enable_gzip' );
232
+ delete_option( 'wppsb_expire_caching' ); */
233
 
234
+ flush_rewrite_rules();
 
235
  }
236
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
237
  ?>