WP Performance Score Booster - Version 1.9

Version Description

Download this release

Release Info

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

Code changes from version 1.8 to 1.9

admin-page.php CHANGED
@@ -19,9 +19,17 @@ function wppsb_admin_options() {
19
  $expire_caching = 'wppsb_expire_caching';
20
 
21
  // Read in existing option value from database
22
- $remove_query_strings_val = get_option($remove_query_strings);
23
- $enable_gzip_val = get_option($enable_gzip);
24
- $expire_caching_val = get_option($expire_caching);
 
 
 
 
 
 
 
 
25
 
26
  // See if the user has posted us some information
27
  // If they did, this hidden field will be set to 'Y'
@@ -37,14 +45,15 @@ function wppsb_admin_options() {
37
  update_option( $expire_caching, $expire_caching_val );
38
 
39
  flush_rewrite_rules();
40
- wppsb_save_mod_rewrite_rules();
41
 
42
  // Put the settings updated message on the screen
43
- ?>
44
- <div class="updated"><p><strong><?php _e('<strong>Settings Saved.</strong>', 'wp-performance-score-booster'); ?></strong></p></div>
45
  <?php
46
  }
47
- ?>
 
48
  <form method="post" name="options_form">
49
  <input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
50
  <table>
@@ -112,14 +121,14 @@ function wppsb_admin_options() {
112
  <div class="wppsb_admin_dev_sidebar_div">
113
  <!-- <img src="//www.gravatar.com/avatar/38b380cf488d8f8c4007cf2015dc16ac.jpg" width="100px" height="100px" /> <br /> -->
114
  <br />
115
- <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>
116
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-rate-this-16x16.png' . '" > '; ?> <a href="http://wordpress.org/support/view/plugin-reviews/wp-performance-score-booster" target="_blank"> <?php _e('Rate this plugin on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
117
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-wordpress-16x16.png' . '" > '; ?> <a href="http://wordpress.org/support/plugin/wp-performance-score-booster" target="_blank"> <?php _e('Get support on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
118
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-github-16x16.png' . '" > '; ?> <a href="https://github.com/dipakcg/wp-performance-score-booster" target="_blank"> <?php _e('Contribute development on GitHub', 'wp-performance-score-booster'); ?> </a> </span>
119
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-other-plugins-16x16.png' . '" > '; ?> <a href="http://profiles.wordpress.org/dipakcg#content-plugins" target="_blank"> <?php _e('Get my other plugins', 'wp-performance-score-booster'); ?> </a> </span>
120
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-twitter-16x16.png' . '" > '; ?>Follow me on Twitter: <a href="https://twitter.com/dipakcgajjar" target="_blank">@dipakcgajjar</a> </span>
121
  <br />
122
- <span class="wppsb_admin_dev_sidebar" style="float: right;"> <?php _e('Version:', 'wp-performance-score-booster'); ?> <strong> <?php echo get_option('wppsb_plugin_version'); ?> </strong> </span>
123
  </div>
124
  </td>
125
  </tr>
@@ -135,7 +144,7 @@ function wppsb_admin_options() {
135
  <hr style="margin: 1.5em 0 2em 0;" />
136
  <table cellspacing="0" cellpadding="0" class="wppsb_news_section"> <tr>
137
  <!-- News and Updates -->
138
- <td width="49%" valign="top">
139
  <h2><strong>News & Updates from Dipak C. Gajjar</strong></h2>
140
  <hr />
141
  <div class="wppsb_rss-widget">
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'
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>
121
  <div class="wppsb_admin_dev_sidebar_div">
122
  <!-- <img src="//www.gravatar.com/avatar/38b380cf488d8f8c4007cf2015dc16ac.jpg" width="100px" height="100px" /> <br /> -->
123
  <br />
124
+ <!-- <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> -->
125
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-rate-this-16x16.png' . '" > '; ?> <a href="http://wordpress.org/support/view/plugin-reviews/wp-performance-score-booster" target="_blank"> <?php _e('Rate this plugin on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
126
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-wordpress-16x16.png' . '" > '; ?> <a href="http://wordpress.org/support/plugin/wp-performance-score-booster" target="_blank"> <?php _e('Get support on WordPress.org', 'wp-performance-score-booster'); ?> </a> </span>
127
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-github-16x16.png' . '" > '; ?> <a href="https://github.com/dipakcg/wp-performance-score-booster" target="_blank"> <?php _e('Contribute development on GitHub', 'wp-performance-score-booster'); ?> </a> </span>
128
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-other-plugins-16x16.png' . '" > '; ?> <a href="http://profiles.wordpress.org/dipakcg#content-plugins" target="_blank"> <?php _e('Get my other plugins', 'wp-performance-score-booster'); ?> </a> </span>
129
  <span class="wppsb_admin_dev_sidebar"> <?php echo '<img src="' . WPPSB_URL . '/assets/images/wppsb-twitter-16x16.png' . '" > '; ?>Follow me on Twitter: <a href="https://twitter.com/dipakcgajjar" target="_blank">@dipakcgajjar</a> </span>
130
  <br />
131
+ <span class="wppsb_admin_dev_sidebar" style="float: right;"> <?php _e('Version:', 'wp-performance-score-booster'); ?> <strong> <?php echo $wppsb_plugin_version; ?> </strong> </span>
132
  </div>
133
  </td>
134
  </tr>
144
  <hr style="margin: 1.5em 0 2em 0;" />
145
  <table cellspacing="0" cellpadding="0" class="wppsb_news_section"> <tr>
146
  <!-- News and Updates -->
147
+ <td width="48%" valign="top">
148
  <h2><strong>News & Updates from Dipak C. Gajjar</strong></h2>
149
  <hr />
150
  <div class="wppsb_rss-widget">
assets/css/style.css CHANGED
@@ -3,7 +3,7 @@
3
  }
4
  .wppsb_admin_dev_sidebar_div {
5
  width:300px;
6
- height:255px;
7
  -webkit-border-radius: 10px;
8
  -moz-border-radius: 10px;
9
  border-radius: 20px 20px 20px 0;
@@ -89,4 +89,4 @@ td.wppsb_onoff {
89
  }
90
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-switch {
91
  right: 0px;
92
- }
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;
89
  }
90
  .wppsb_onoffswitch-checkbox:checked + .wppsb_onoffswitch-label .wppsb_onoffswitch-switch {
91
  right: 0px;
92
+ }
assets/css/style.min.css CHANGED
@@ -1 +1 @@
1
- .wppsb_settings{font-size:16px !important;}.wppsb_admin_dev_sidebar_div{width:300px;height:255px;-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: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}
data-processing.php CHANGED
@@ -8,16 +8,6 @@ function wppsb_remove_query_strings_q( $src ) {
8
  return $src;
9
  }
10
 
11
- // If 'Remove query strings" checkbox ticked, add filter otherwise remove filter
12
- if (get_option('wppsb_remove_query_strings') == 'on') {
13
- add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
14
- add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
15
- }
16
- else {
17
- remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_q');
18
- remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_q');
19
- }
20
-
21
  /* ========================================
22
  Enable GZIP Compression
23
  ======================================== */
@@ -97,24 +87,24 @@ EOD;
97
 
98
  // Special thanks to Marin Atanasov ( https://github.com/tyxla ) for contributing this awesome function.
99
  // Updates the htaccess file with the current rules if it is writable.
100
- function wppsb_save_mod_rewrite_rules() {
101
  if ( is_multisite() )
102
  return;
103
  global $wp_rewrite;
104
- $home_path = get_home_path();
105
- $htaccess_file = $home_path.'.htaccess';
106
 
107
  /*
108
  * If the file doesn't already exist check for write access to the directory
109
  * and whether we have some rules. Else check for write access to the file.
110
  */
111
- if ((!file_exists($htaccess_file) && is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks()) || is_writable($htaccess_file)) {
112
- if ( got_mod_rewrite() ) {
 
113
  $rules = explode( "\n", $wp_rewrite->mod_rewrite_rules() );
114
  $enable_gzip = 'wppsb_enable_gzip';
115
  $expire_caching = 'wppsb_expire_caching';
116
- $enable_gzip_val = get_option($enable_gzip);
117
- $expire_caching_val = get_option($expire_caching);
118
  $rules = array();
119
  if ($enable_gzip_val == 'on') {
120
  $rules = array_merge($rules, explode("\n", wppsb_enable_gzip_filter()));
8
  return $src;
9
  }
10
 
 
 
 
 
 
 
 
 
 
 
11
  /* ========================================
12
  Enable GZIP Compression
13
  ======================================== */
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()));
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === WP Performance Score Booster ===
2
  Contributors: dipakcg
3
- Tags: performance, speed, compression, caching, booster, query
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.8
7
- Stable tag: 1.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -58,6 +58,11 @@ Alternatively, you can open a [support thread](http://wordpress.org/support/plug
58
  1. Admin Settings
59
 
60
  == Changelog ==
 
 
 
 
 
61
  = 1.8, July 03, 2017 =
62
  * Added a feature that auto-backup .htaccess file before appending any rules (for GZIP and browser caching)
63
  * Improved uninstallation process
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: 4.9
7
+ Stable tag: 1.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
58
  1. Admin Settings
59
 
60
  == Changelog ==
61
+ = 1.9, November 28, 2017 =
62
+ * Completely rewritten
63
+ * Fixed few CSS bugs (admin settings)
64
+ * Removed Donate button
65
+
66
  = 1.8, July 03, 2017 =
67
  * Added a feature that auto-backup .htaccess file before appending any rules (for GZIP and browser caching)
68
  * Improved uninstallation process
uninstall.php CHANGED
@@ -1,17 +1,13 @@
1
  <?php
2
  if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit; // Exit if accessed directly.
3
 
4
- // Include to get get_home_path() function work
5
- require_once(ABSPATH . 'wp-admin/includes/file.php');
6
-
7
  delete_option( 'wppsb_plugin_version' );
8
  delete_option( 'wppsb_remove_query_strings' );
9
  delete_option( 'wppsb_enable_gzip' );
10
  delete_option( 'wppsb_expire_caching' );
11
 
12
- // Delete .htaccess backups (including directory)
13
- $home_path = get_home_path();
14
- delete_storage_dir($home_path . 'wp-content/wp-performance-score-booster');
15
 
16
  function delete_storage_dir($dir) {
17
  $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
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
 
9
+ // Delete .htaccess backups (including backup storage page directory)
10
+ delete_storage_dir( get_home_path() . 'wp-content/wp-performance-score-booster');
 
11
 
12
  function delete_storage_dir($dir) {
13
  $it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
wp-performance-score-booster.php CHANGED
@@ -3,7 +3,7 @@
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.8
7
  Author: Dipak C. Gajjar
8
  Author URI: https://dipakgajjar.com
9
  Text Domain: wp-performance-score-booster
@@ -11,31 +11,28 @@ Text Domain: wp-performance-score-booster
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
13
 
14
- // Include to get get_home_path() function work
15
- require_once(ABSPATH . 'wp-admin/includes/file.php');
16
 
17
  // Define plugin version for future releases
18
  if (!defined('WPPSB_PLUGIN_VERSION')) {
19
- define('WPPSB_PLUGIN_VERSION', 'wppsb_plugin_version');
20
  }
21
- if (!defined('WPPSB_PLUGIN_VERSION_NUM')) {
22
- define('WPPSB_PLUGIN_VERSION_NUM', '1.8');
23
- }
24
- update_option(WPPSB_PLUGIN_VERSION, WPPSB_PLUGIN_VERSION_NUM);
25
 
26
- /* Plugin Path */
27
- define( 'WPPSB_PATH', WP_PLUGIN_DIR . '/' . basename( dirname( __FILE__ ) ) );
28
- /* Plugin File */
29
- define( 'WPPSB_FILE', __FILE__ );
30
- /* Plugin URL */
31
- define( 'WPPSB_URL', plugins_url( '', __FILE__ ) );
32
- /* Storage path to store .htaccess backups */
33
- define( 'WPPSB_STORAGE_PATH', get_home_path() . 'wp-content/wp-performance-score-booster' );
34
 
35
- require_once 'admin-page.php'; // admin options page.
36
- require_once 'data-processing.php'; // process the data such as remove query strings, enable gzip and leverage browser caching.
 
 
 
37
 
38
- // Load plugin textdomain for language trnaslation
39
  function wppsb_load_plugin_textdomain() {
40
 
41
  $domain = 'wp-performance-score-booster';
@@ -47,26 +44,38 @@ function wppsb_load_plugin_textdomain() {
47
  load_plugin_textdomain( $domain, FALSE, basename( dirname( __FILE__ ) ) . '/languages/' );
48
 
49
  }
50
- add_action( 'init', 'wppsb_load_plugin_textdomain' );
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  // Add settings link on plugin page
53
  function dcg_settings_link($links) {
54
  // $settings_link = '<a href="admin.php?page=wp-performance-score-booster">Settings</a>';
55
- $settings_link = '<a href="options-general.php?page=wp-performance-score-booster">Settings</a>';
56
- array_unshift($links, $settings_link);
 
57
  return $links;
58
  }
59
- $plugin = plugin_basename(__FILE__);
60
- add_filter("plugin_action_links_$plugin", 'dcg_settings_link' );
61
 
62
  // Adding WordPress plugin meta links
63
  function wppsb_plugin_meta_links( $links, $file ) {
64
- $plugin = plugin_basename(__FILE__);
65
  // Create link
66
- if ( $file == $plugin ) {
67
  return array_merge(
68
  $links,
69
- array( '<a href="https://dipakgajjar.com/products/wordpress-speed-optimisation-service?utm_source=plugins%20page&utm_medium=text%20link&utm_campaign=wordplress%20plugins" style="color:#FF0000;" target="_blank">Order WordPress Speed Optimisation Service</a>' )
70
  );
71
  }
72
  return $links;
@@ -74,7 +83,6 @@ function wppsb_plugin_meta_links( $links, $file ) {
74
  add_filter( 'plugin_row_meta', 'wppsb_plugin_meta_links', 10, 2 );
75
 
76
  // Register with hook 'wp_enqueue_scripts', which can be used for front end CSS and JavaScript
77
- add_action( 'admin_init', 'wppsb_add_stylesheet' );
78
  function wppsb_add_stylesheet() {
79
  // Respects SSL, style.css is relative to the current file
80
  wp_register_style( 'wppsb-stylesheet', WPPSB_URL . '/assets/css/style.min.css' );
@@ -84,37 +92,84 @@ function wppsb_add_stylesheet() {
84
  // Add header
85
  function wppsb_add_header() {
86
  // Get the plugin version from options (in the database)
87
- $wppsb_plugin_version = get_option('wppsb_plugin_version');
88
  $head_comment = <<<EOD
89
- <!-- Performance scores of this site is tuned by WP Performance Score Booster plugin v$wppsb_plugin_version - http://wordpress.org/plugins/wp-performance-score-booster -->
90
  EOD;
91
  $head_comment = $head_comment . PHP_EOL;
92
  print ($head_comment);
93
  }
94
  add_action('wp_head', 'wppsb_add_header', 1);
95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  // Calling this function will make flush_rules to be called at the end of the PHP execution
97
  function wppsb_activate_plugin() {
98
 
99
- // Backup .htacces before appending any rules
100
- wppsb_htaccess_bakup();
101
 
102
  // Save default options value in the database
103
- update_option( 'wppsb_remove_query_strings', 'on' );
104
- add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
105
- add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
 
 
 
 
106
 
107
  if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) {
108
- update_option( 'wppsb_enable_gzip', 'on' );
109
  }
110
  else {
111
- update_option( 'wppsb_enable_gzip', '' );
112
  }
113
 
114
- update_option( 'wppsb_expire_caching', 'on' );
115
 
116
  flush_rewrite_rules();
117
- wppsb_save_mod_rewrite_rules();
118
  }
119
  register_activation_hook( __FILE__, 'wppsb_activate_plugin' );
120
 
@@ -123,29 +178,22 @@ function wppsb_htaccess_bakup() {
123
  mkdir( WPPSB_STORAGE_PATH, 0777, true );
124
  }
125
 
126
- $home_path = get_home_path();
127
- $htaccess_file = $home_path . '.htaccess'; // original .htaccess file
128
  $htaccess_bak = WPPSB_STORAGE_PATH . '/.htaccess.wppsb';
129
 
130
  copy($htaccess_file, $htaccess_bak);
131
-
132
- /* if (file_exists($htaccess_bak)) {
133
- copy($htaccess_file, $htaccess_bak . "." . date('mdYhis'));
134
- } else {
135
- copy($htaccess_file, $htaccess_bak);
136
- } */
137
  }
138
 
139
  // Remove filters/functions on plugin deactivation
140
  function wppsb_deactivate_plugin() {
141
 
142
  // Clear (off) all the options value (from database)
143
- update_option( 'wppsb_remove_query_strings', "" );
144
  update_option( 'wppsb_enable_gzip', "" );
145
- update_option( 'wppsb_expire_caching', "" );
146
 
147
  flush_rewrite_rules();
148
- wppsb_save_mod_rewrite_rules();
149
  }
150
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
151
  ?>
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
7
  Author: Dipak C. Gajjar
8
  Author URI: https://dipakgajjar.com
9
  Text Domain: wp-performance-score-booster
11
 
12
  if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
13
 
14
+ include_once ( ABSPATH . 'wp-admin/includes/file.php' ); // to get get_home_path() function work
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');
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
 
38
  $domain = 'wp-performance-score-booster';
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
+ add_action( 'admin_init', 'wppsb_master_admin_init' );
61
 
62
  // Add settings link on plugin page
63
  function dcg_settings_link($links) {
64
  // $settings_link = '<a href="admin.php?page=wp-performance-score-booster">Settings</a>';
65
+ $wppsb_links = array( '<a href="options-general.php?page=wp-performance-score-booster">Settings</a>' );
66
+ // array_unshift($links, $settings_link);
67
+ $links = array_merge($wppsb_links, $links);
68
  return $links;
69
  }
70
+ add_filter("plugin_action_links_" . plugin_basename(__FILE__), 'dcg_settings_link' );
 
71
 
72
  // Adding WordPress plugin meta links
73
  function wppsb_plugin_meta_links( $links, $file ) {
 
74
  // Create link
75
+ if ( $file == plugin_basename(__FILE__) ) {
76
  return array_merge(
77
  $links,
78
+ 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>' )
79
  );
80
  }
81
  return $links;
83
  add_filter( 'plugin_row_meta', 'wppsb_plugin_meta_links', 10, 2 );
84
 
85
  // Register with hook 'wp_enqueue_scripts', which can be used for front end CSS and JavaScript
 
86
  function wppsb_add_stylesheet() {
87
  // Respects SSL, style.css is relative to the current file
88
  wp_register_style( 'wppsb-stylesheet', WPPSB_URL . '/assets/css/style.min.css' );
92
  // Add header
93
  function wppsb_add_header() {
94
  // Get the plugin version from options (in the database)
95
+ global $wppsb_plugin_version;
96
  $head_comment = <<<EOD
97
+ <!-- Speed of this site is optimised by WP Performance Score Booster plugin v$wppsb_plugin_version - https://dipakgajjar.com/wp-performance-score-booster/ -->
98
  EOD;
99
  $head_comment = $head_comment . PHP_EOL;
100
  print ($head_comment);
101
  }
102
  add_action('wp_head', 'wppsb_add_header', 1);
103
 
104
+ // If 'Remove query strings" checkbox ticked, add filter otherwise remove filter
105
+ if ( $wppsb_remove_query_strings == 'on') {
106
+ add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
107
+ add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
108
+ }
109
+ else {
110
+ remove_filter( 'script_loader_src', 'wppsb_remove_query_strings_q');
111
+ remove_filter( 'style_loader_src', 'wppsb_remove_query_strings_q');
112
+ }
113
+
114
+ // Display admin notice to apply changes in the occurrence of update (when plugin updated)
115
+ function wppsb_apply_updates_notice() {
116
+ global $wppsb_plugin_version;
117
+ $notice_contents = "<p style=\"font-size: 15px; color: #FF9900;\">WP Performance Score Booster has been updated to version: " . WPPSB_PLUGIN_VERSION . "</p>";
118
+ $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>";
119
+ ?>
120
+ <div class="notice notice-success"><p><strong><?php _e($notice_contents, 'wp-performance-score-booster'); ?></strong></p></div>
121
+ <?php
122
+ }
123
+
124
+ // Check if plugin updated
125
+ function wppsb_update_checker() {
126
+ global $wppsb_plugin_version;
127
+ if ($wppsb_plugin_version != WPPSB_PLUGIN_VERSION) {
128
+ if ( is_plugin_active( plugin_basename( __FILE__ ) ) ) {
129
+ add_action( 'admin_notices', 'wppsb_apply_updates_notice' );
130
+ }
131
+ }
132
+ }
133
+
134
+ // If 'Apply Updates' clicked under admin notice (in case of plugin updated)
135
+ function wppsb_update_processor() {
136
+ global $wppsb_plugin_version , $wppsb_enable_gzip, $wppsb_expire_caching;
137
+ if ( isset($_GET['apply-updates']) && $_GET['apply-updates'] == 'true' ) {
138
+ if ($wppsb_plugin_version != WPPSB_PLUGIN_VERSION) {
139
+ update_option('wppsb_plugin_version', WPPSB_PLUGIN_VERSION);
140
+ flush_rewrite_rules();
141
+ wppsb_save_mod_rewrite_rules($wppsb_enable_gzip, $wppsb_expire_caching);
142
+ exit ( wp_redirect( admin_url( 'options-general.php?page=wp-performance-score-booster&update-applied=true' ) ) );
143
+ }
144
+ }
145
+ }
146
+
147
  // Calling this function will make flush_rules to be called at the end of the PHP execution
148
  function wppsb_activate_plugin() {
149
 
150
+ global $wppsb_remove_query_strings, $wppsb_enable_gzip, $wppsb_expire_caching;
151
+ wppsb_htaccess_bakup(); // Backup .htacces before appending any rules
152
 
153
  // Save default options value in the database
154
+ add_option( 'wppsb_plugin_version', WPPSB_PLUGIN_VERSION );
155
+ add_option( 'wppsb_remove_query_strings', $wppsb_remove_query_strings );
156
+
157
+ if ( $wppsb_remove_query_strings == 'on' ) {
158
+ add_filter( 'script_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
159
+ add_filter( 'style_loader_src', 'wppsb_remove_query_strings_q', 15, 1 );
160
+ }
161
 
162
  if (function_exists('ob_gzhandler') || ini_get('zlib.output_compression')) {
163
+ add_option( 'wppsb_enable_gzip', $wppsb_enable_gzip );
164
  }
165
  else {
166
+ add_option( 'wppsb_enable_gzip', '' );
167
  }
168
 
169
+ add_option( 'wppsb_expire_caching', $wppsb_expire_caching );
170
 
171
  flush_rewrite_rules();
172
+ wppsb_save_mod_rewrite_rules($wppsb_enable_gzip, $wppsb_expire_caching);
173
  }
174
  register_activation_hook( __FILE__, 'wppsb_activate_plugin' );
175
 
178
  mkdir( WPPSB_STORAGE_PATH, 0777, true );
179
  }
180
 
181
+ $htaccess_file = get_home_path() . '.htaccess'; // original .htaccess file
 
182
  $htaccess_bak = WPPSB_STORAGE_PATH . '/.htaccess.wppsb';
183
 
184
  copy($htaccess_file, $htaccess_bak);
 
 
 
 
 
 
185
  }
186
 
187
  // Remove filters/functions on plugin deactivation
188
  function wppsb_deactivate_plugin() {
189
 
190
  // Clear (off) all the options value (from database)
191
+ /* update_option( 'wppsb_remove_query_strings', "" );
192
  update_option( 'wppsb_enable_gzip', "" );
193
+ update_option( 'wppsb_expire_caching', "" ); */
194
 
195
  flush_rewrite_rules();
196
+ wppsb_save_mod_rewrite_rules('', '');
197
  }
198
  register_deactivation_hook( __FILE__, 'wppsb_deactivate_plugin' );
199
  ?>