WP Fastest Cache - Version 0.9.1.2

Version Description

  • to add webp extension for CDN
  • to replace the attribute which is data-bg-webp with cdn-url
  • to save the Cloudflare zone id instead of getting it via api continuously
  • to prevent calling cloudflare_clear_cache() function multiple times
Download this release

Release Info

Developer emrevona
Plugin Icon 128x128 WP Fastest Cache
Version 0.9.1.2
Comparing to
See all releases

Code changes from version 0.9.1.1 to 0.9.1.2

css/style.css CHANGED
@@ -247,11 +247,11 @@ form.delete-line .left .submit input{
247
  width: 165px;
248
  white-space: pre-line !important;
249
  }
250
- .revert:before{
251
  font-family: "dashicons";
252
  content: "\f531";
253
  }
254
- .revert{
255
  width:16px;
256
  height:16px;
257
  vertical-align: middle;
@@ -268,12 +268,12 @@ form.delete-line .left .submit input{
268
  background-color: white;
269
  }
270
 
271
- .revert:hover{
272
  border-color:#000;
273
  background-color: white;
274
  }
275
 
276
- .revert:active{
277
  background-color: #F5F5F5;
278
  }
279
 
247
  width: 165px;
248
  white-space: pre-line !important;
249
  }
250
+ td div.revert:before{
251
  font-family: "dashicons";
252
  content: "\f531";
253
  }
254
+ td div.revert{
255
  width:16px;
256
  height:16px;
257
  vertical-align: middle;
268
  background-color: white;
269
  }
270
 
271
+ td div.revert:hover{
272
  border-color:#000;
273
  background-color: white;
274
  }
275
 
276
+ td div.revert:active{
277
  background-color: #F5F5F5;
278
  }
279
 
inc/admin.php CHANGED
@@ -1728,7 +1728,7 @@
1728
 
1729
  Wpfc_New_Dialog.dialog("wpfc-modal-downloaderror", {close: "default"});
1730
 
1731
- var wpfc_api_url = '<?php echo "http://api.wpfastestcache.net/premium/newdownload/".str_replace(array("http://", "www."), "", $_SERVER["HTTP_HOST"])."/".get_option("WpFc_api_key"); ?>';
1732
  jQuery("div[id^='wpfc-modal-downloaderror'] a.wpfc-download-now").attr("href", wpfc_api_url);
1733
 
1734
  // jQuery("body").append(data);
1728
 
1729
  Wpfc_New_Dialog.dialog("wpfc-modal-downloaderror", {close: "default"});
1730
 
1731
+ var wpfc_api_url = '<?php echo "https://api.wpfastestcache.net/premium/newdownload/".str_replace(array("http://", "www."), "", $_SERVER["HTTP_HOST"])."/".get_option("WpFc_api_key"); ?>';
1732
  jQuery("div[id^='wpfc-modal-downloaderror'] a.wpfc-download-now").attr("href", wpfc_api_url);
1733
 
1734
  // jQuery("body").append(data);
inc/cache.php CHANGED
@@ -883,7 +883,7 @@
883
 
884
  public function cdn_rewrite($content){
885
  if($this->cdn){
886
- $content = preg_replace_callback("/(srcset|src|href|data-vc-parallax-image|data-bg|data-fullurl|data-mobileurl|data-img-url|data-cvpsrc|data-cvpset|data-thumb|data-bg-url|data-large_image|data-lazyload|data-lazy|data-source-url|data-srcsmall|data-srclarge|data-srcfull|data-slide-img|data-lazy-original)\s{0,2}\=\s{0,2}[\'\"]([^\'\"]+)[\'\"]/i", array($this, 'cdn_replace_urls'), $content);
887
 
888
  //url()
889
  $content = preg_replace_callback("/(url)\(([^\)\>]+)\)/i", array($this, 'cdn_replace_urls'), $content);
883
 
884
  public function cdn_rewrite($content){
885
  if($this->cdn){
886
+ $content = preg_replace_callback("/(srcset|src|href|data-vc-parallax-image|data-bg|data-bg-webp|data-fullurl|data-mobileurl|data-img-url|data-cvpsrc|data-cvpset|data-thumb|data-bg-url|data-large_image|data-lazyload|data-lazy|data-source-url|data-srcsmall|data-srclarge|data-srcfull|data-slide-img|data-lazy-original)\s{0,2}\=\s{0,2}[\'\"]([^\'\"]+)[\'\"]/i", array($this, 'cdn_replace_urls'), $content);
887
 
888
  //url()
889
  $content = preg_replace_callback("/(url)\(([^\)\>]+)\)/i", array($this, 'cdn_replace_urls'), $content);
inc/cdn.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
  class CdnWPFC{
3
  public static function cloudflare_clear_cache($email = false, $key = false, $zoneid = false){
 
 
 
 
4
  if(!$email && !$key && !$zoneid){
5
  if($cdn_values = get_option("WpFastestCacheCDN")){
6
  $std_obj = json_decode($cdn_values);
@@ -34,6 +38,18 @@
34
  );
35
 
36
  $response = wp_remote_request('https://api.cloudflare.com/client/v4/zones/'.$zoneid.'/purge_cache', $header);
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
38
  }
39
 
@@ -137,6 +153,13 @@
137
  }
138
 
139
  public static function cloudflare_get_zone_id($email = false, $key = false){
 
 
 
 
 
 
 
140
  $hostname = preg_replace("/^(https?\:\/\/)?(www\d*\.)?/", "", $_SERVER["HTTP_HOST"]);
141
 
142
  if(function_exists("idn_to_utf8")){
@@ -170,6 +193,8 @@
170
  $res = array("success" => true,
171
  "zoneid" => $zone_value->id,
172
  "plan" => $zone_value->plan->legacy_id);
 
 
173
  }
174
  }
175
 
@@ -185,6 +210,58 @@
185
  return $res;
186
  }
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  public static function cloudflare_remove_webp(){
189
  $path = ABSPATH.".htaccess";
190
 
1
  <?php
2
  class CdnWPFC{
3
  public static function cloudflare_clear_cache($email = false, $key = false, $zoneid = false){
4
+ if(isset($GLOBALS["wpfc_cloudflare_purge_cache_executed"])){
5
+ return;
6
+ }
7
+
8
  if(!$email && !$key && !$zoneid){
9
  if($cdn_values = get_option("WpFastestCacheCDN")){
10
  $std_obj = json_decode($cdn_values);
38
  );
39
 
40
  $response = wp_remote_request('https://api.cloudflare.com/client/v4/zones/'.$zoneid.'/purge_cache', $header);
41
+
42
+ if(!$response || is_wp_error($response)){
43
+ return array("success" => false, "error_message" => "Unable to disable rocket loader option");
44
+ }else{
45
+ $body = json_decode(wp_remote_retrieve_body($response));
46
+
47
+ if(!$body->success){
48
+ CdnWPFC::cloudflare_delete_zone_id_value();
49
+ }else{
50
+ $GLOBALS["wpfc_cloudflare_purge_cache_executed"] = true;
51
+ }
52
+ }
53
  }
54
  }
55
 
153
  }
154
 
155
  public static function cloudflare_get_zone_id($email = false, $key = false){
156
+ $cache_zone_id = CdnWPFC::cloudflare_get_zone_id_value();
157
+
158
+ if($cache_zone_id){
159
+ return $cache_zone_id;
160
+ }
161
+
162
+
163
  $hostname = preg_replace("/^(https?\:\/\/)?(www\d*\.)?/", "", $_SERVER["HTTP_HOST"]);
164
 
165
  if(function_exists("idn_to_utf8")){
193
  $res = array("success" => true,
194
  "zoneid" => $zone_value->id,
195
  "plan" => $zone_value->plan->legacy_id);
196
+
197
+ CdnWPFC::cloudflare_save_zone_id_value($res);
198
  }
199
  }
200
 
210
  return $res;
211
  }
212
 
213
+ public static function cloudflare_get_zone_id_value(){
214
+ if($data = get_option("WpFastestCacheCDN")){
215
+ $arr = json_decode($data);
216
+
217
+ if(is_array($arr)){
218
+ foreach ($arr as $cdn_key => $cdn_value) {
219
+ if($cdn_value->id == "cloudflare"){
220
+ return unserialize($cdn_value->zone_id);
221
+ }
222
+ }
223
+ }
224
+ }
225
+
226
+ return false;
227
+ }
228
+
229
+ public static function cloudflare_delete_zone_id_value(){
230
+ if($data = get_option("WpFastestCacheCDN")){
231
+ $arr = json_decode($data);
232
+
233
+ if(is_array($arr)){
234
+ foreach ($arr as $cdn_key => $cdn_value) {
235
+ if($cdn_value->id == "cloudflare"){
236
+ if(isset($cdn_value->zone_id)){
237
+ unset($cdn_value->zone_id);
238
+ }
239
+ }
240
+ }
241
+
242
+ update_option("WpFastestCacheCDN", json_encode($arr));
243
+ }
244
+ }
245
+ }
246
+
247
+ public static function cloudflare_save_zone_id_value($value){
248
+ if($data = get_option("WpFastestCacheCDN")){
249
+ $arr = json_decode($data);
250
+
251
+ if(is_array($arr)){
252
+ foreach ($arr as $cdn_key => &$cdn_value) {
253
+ if($cdn_value->id == "cloudflare"){
254
+ $value["time"] = time();
255
+ $cdn_value->zone_id = serialize($value);
256
+
257
+ }
258
+ }
259
+
260
+ update_option("WpFastestCacheCDN", json_encode($arr));
261
+ }
262
+ }
263
+ }
264
+
265
  public static function cloudflare_remove_webp(){
266
  $path = ABSPATH.".htaccess";
267
 
inc/css-utilities.php CHANGED
@@ -504,6 +504,8 @@
504
 
505
  if(!$matches[1]){
506
  $matches[1] = "";
 
 
507
  }else if(preg_match("/^(\/\/|http|\/\/fonts|data:image|data:application)/", $matches[1])){
508
  if(preg_match("/fonts\.googleapis\.com/", $matches[1])){ // for safari browser
509
  $matches[1] = '"'.$matches[1].'"';
504
 
505
  if(!$matches[1]){
506
  $matches[1] = "";
507
+ }else if(preg_match("/^\#/", $matches[1])){
508
+ $matches[1] = $matches[1];
509
  }else if(preg_match("/^(\/\/|http|\/\/fonts|data:image|data:application)/", $matches[1])){
510
  if(preg_match("/fonts\.googleapis\.com/", $matches[1])){ // for safari browser
511
  $matches[1] = '"'.$matches[1].'"';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://profiles.wordpress.org/emrevona/
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.5
7
- Stable tag: 0.9.1.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,12 @@ The free version is enough to speed up your site but in the premium version ther
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
127
  = 0.9.1.1 =
128
  * to prevent caching 403 forbidden page which is generated by iThemes Security plugin
129
  * to convert domain name from IDNA ASCII to Unicode for CDN
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.5
7
+ Stable tag: 0.9.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
124
 
125
  == Changelog ==
126
 
127
+ = 0.9.1.2 =
128
+ * to add webp extension for CDN
129
+ * to replace the attribute which is data-bg-webp with cdn-url
130
+ * to save the Cloudflare zone id instead of getting it via api continuously
131
+ * to prevent calling cloudflare_clear_cache() function multiple times
132
+
133
  = 0.9.1.1 =
134
  * to prevent caching 403 forbidden page which is generated by iThemes Security plugin
135
  * to convert domain name from IDNA ASCII to Unicode for CDN
templates/cdn/file_types.php CHANGED
@@ -18,6 +18,7 @@
18
  "swf",
19
  "ttf",
20
  "webm",
 
21
  "woff",
22
  "woff2"
23
  );
18
  "swf",
19
  "ttf",
20
  "webm",
21
+ "webp",
22
  "woff",
23
  "woff2"
24
  );
wpFastestCache.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Fastest Cache
4
  Plugin URI: http://wordpress.org/plugins/wp-fastest-cache/
5
  Description: The simplest and fastest WP Cache system
6
- Version: 0.9.1.1
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -1050,6 +1050,7 @@ GNU General Public License for more details.
1050
 
1051
  public function singleDeleteCache($comment_id = false, $post_id = false){
1052
  include_once('inc/cdn.php');
 
1053
  CdnWPFC::cloudflare_clear_cache();
1054
 
1055
  $to_clear_parents = true;
3
  Plugin Name: WP Fastest Cache
4
  Plugin URI: http://wordpress.org/plugins/wp-fastest-cache/
5
  Description: The simplest and fastest WP Cache system
6
+ Version: 0.9.1.2
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
1050
 
1051
  public function singleDeleteCache($comment_id = false, $post_id = false){
1052
  include_once('inc/cdn.php');
1053
+
1054
  CdnWPFC::cloudflare_clear_cache();
1055
 
1056
  $to_clear_parents = true;