WP Fastest Cache - Version 0.8.7.0

Version Description

  • to avoid removing www prefix from photon cdn-url
  • to prevent to empty origin-url on cdn wizard
  • [FEATURE] to clear cache of post via post list
  • preload for woocommorce product category
  • to clear cache of tag and cat after product update
  • to check that SG Optimizer is active or not
  • [FEATURE] Preload for tags
  • [FEATURE] Preload for attachments
  • [FEATURE] exclude categories, tags, posts and pages
Download this release

Release Info

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

Code changes from version 0.8.6.9 to 0.8.7.0

Files changed (9) hide show
  1. inc/admin.php +22 -5
  2. inc/cache.php +43 -13
  3. inc/column.php +35 -0
  4. js/cdn/cdn.js +24 -1
  5. js/column.js +39 -0
  6. readme.txt +13 -2
  7. templates/exclude.php +26 -12
  8. templates/preload.php +8 -4
  9. wpFastestCache.php +111 -40
inc/admin.php CHANGED
@@ -334,8 +334,8 @@
334
  return array("You have to set <strong><u><a href='".admin_url()."options-permalink.php"."'>permalinks</a></u></strong>", "error");
335
  }else if($res = $this->checkSuperCache($path, $htaccess)){
336
  return $res;
337
- // }else if($this->isPluginActive('wp-hide-security-enhancer/wp-hide.php')){
338
- // return array("WP Hide & Security Enhancer needs to be deactived<br>", "error");
339
  }else if($this->isPluginActive('adrotate/adrotate.php') || $this->isPluginActive('adrotate-pro/adrotate.php')){
340
  return $this->warningIncompatible("AdRotate");
341
  }else if($this->isPluginActive('mobilepress/mobilepress.php')){
@@ -394,12 +394,20 @@
394
  }
395
 
396
  if($webp){
 
 
 
 
 
 
 
 
397
  $data = "# BEGIN WEBPWpFastestCache"."\n".
398
  "<IfModule mod_rewrite.c>"."\n".
399
  "RewriteEngine On"."\n".
400
  "RewriteCond %{HTTP_ACCEPT} image/webp"."\n".
401
- "RewriteCond %{REQUEST_URI} jpg|png"."\n".
402
- "RewriteCond %{DOCUMENT_ROOT}/$1.webp -f"."\n".
403
  "RewriteRule ^(.*) \"/$1.webp\" [L]"."\n".
404
  "</IfModule>"."\n".
405
  "<IfModule mod_headers.c>"."\n".
@@ -600,6 +608,7 @@
600
  if(ABSPATH == "//"){
601
  $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f"."\n";
602
  }else{
 
603
  $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f [or]"."\n";
604
  // to escape spaces
605
  $tmp_WPFC_WP_CONTENT_DIR = str_replace(" ", "\ ", WPFC_WP_CONTENT_DIR);
@@ -801,6 +810,8 @@
801
  $wpFastestCachePreload_post = isset($this->options->wpFastestCachePreload_post) ? 'checked="checked"' : "";
802
  $wpFastestCachePreload_category = isset($this->options->wpFastestCachePreload_category) ? 'checked="checked"' : "";
803
  $wpFastestCachePreload_page = isset($this->options->wpFastestCachePreload_page) ? 'checked="checked"' : "";
 
 
804
  $wpFastestCachePreload_number = isset($this->options->wpFastestCachePreload_number) ? $this->options->wpFastestCachePreload_number : 4;
805
 
806
 
@@ -1176,7 +1187,9 @@
1176
  "topclassprinting.com",
1177
  "camilazivit.com.br",
1178
  "spycoupon.in",
1179
- "groovypost.com"
 
 
1180
  );
1181
 
1182
  if(in_array(get_bloginfo('language'), $tester_arr) || in_array(str_replace("www.", "", $_SERVER["HTTP_HOST"]), $tester_arr)){ ?>
@@ -1654,6 +1667,10 @@
1654
  <select name="wpfc-exclude-rule-prefix">
1655
  <option selected="" value=""></option>
1656
  <option value="homepage">Home Page</option>
 
 
 
 
1657
  <option value="startwith">Start With</option>
1658
  <option value="contain">Contain</option>
1659
  <option value="exact">Exact</option>
334
  return array("You have to set <strong><u><a href='".admin_url()."options-permalink.php"."'>permalinks</a></u></strong>", "error");
335
  }else if($res = $this->checkSuperCache($path, $htaccess)){
336
  return $res;
337
+ }else if($this->isPluginActive('sg-cachepress/sg-cachepress.php')){
338
+ return array("SG Optimizer needs to be deactive", "error");
339
  }else if($this->isPluginActive('adrotate/adrotate.php') || $this->isPluginActive('adrotate-pro/adrotate.php')){
340
  return $this->warningIncompatible("AdRotate");
341
  }else if($this->isPluginActive('mobilepress/mobilepress.php')){
394
  }
395
 
396
  if($webp){
397
+ if(ABSPATH == "//"){
398
+ $RewriteCond = "RewriteCond %{DOCUMENT_ROOT}/$1.webp -f"."\n";
399
+ }else{
400
+ $RewriteCond = "RewriteCond %{DOCUMENT_ROOT}/$1.webp -f [or]"."\n";
401
+ $RewriteCond = $RewriteCond."RewriteCond ".ABSPATH."$1.webp -f"."\n";
402
+ }
403
+
404
+
405
  $data = "# BEGIN WEBPWpFastestCache"."\n".
406
  "<IfModule mod_rewrite.c>"."\n".
407
  "RewriteEngine On"."\n".
408
  "RewriteCond %{HTTP_ACCEPT} image/webp"."\n".
409
+ "RewriteCond %{REQUEST_URI} \.(jpe?g|png)"."\n".
410
+ $RewriteCond.
411
  "RewriteRule ^(.*) \"/$1.webp\" [L]"."\n".
412
  "</IfModule>"."\n".
413
  "<IfModule mod_headers.c>"."\n".
608
  if(ABSPATH == "//"){
609
  $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f"."\n";
610
  }else{
611
+ //WARNING: If you change the following lines, you need to update webp as well
612
  $data = $data."RewriteCond %{DOCUMENT_ROOT}/".WPFC_WP_CONTENT_BASENAME."/cache/all/$1/index.html -f [or]"."\n";
613
  // to escape spaces
614
  $tmp_WPFC_WP_CONTENT_DIR = str_replace(" ", "\ ", WPFC_WP_CONTENT_DIR);
810
  $wpFastestCachePreload_post = isset($this->options->wpFastestCachePreload_post) ? 'checked="checked"' : "";
811
  $wpFastestCachePreload_category = isset($this->options->wpFastestCachePreload_category) ? 'checked="checked"' : "";
812
  $wpFastestCachePreload_page = isset($this->options->wpFastestCachePreload_page) ? 'checked="checked"' : "";
813
+ $wpFastestCachePreload_tag = isset($this->options->wpFastestCachePreload_tag) ? 'checked="checked"' : "";
814
+ $wpFastestCachePreload_attachment = isset($this->options->wpFastestCachePreload_attachment) ? 'checked="checked"' : "";
815
  $wpFastestCachePreload_number = isset($this->options->wpFastestCachePreload_number) ? $this->options->wpFastestCachePreload_number : 4;
816
 
817
 
1187
  "topclassprinting.com",
1188
  "camilazivit.com.br",
1189
  "spycoupon.in",
1190
+ "groovypost.com",
1191
+ "parkviewhomes.info",
1192
+ "myparkviewhomes.com"
1193
  );
1194
 
1195
  if(in_array(get_bloginfo('language'), $tester_arr) || in_array(str_replace("www.", "", $_SERVER["HTTP_HOST"]), $tester_arr)){ ?>
1667
  <select name="wpfc-exclude-rule-prefix">
1668
  <option selected="" value=""></option>
1669
  <option value="homepage">Home Page</option>
1670
+ <option value="category">Categories</option>
1671
+ <option value="tag">Tags</option>
1672
+ <option value="post">Posts</option>
1673
+ <option value="page">Pages</option>
1674
  <option value="startwith">Start With</option>
1675
  <option value="contain">Contain</option>
1676
  <option value="exact">Exact</option>
inc/cache.php CHANGED
@@ -23,6 +23,28 @@
23
  $this->set_content_url();
24
  }
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  public function set_content_url(){
27
  $content_url = content_url();
28
 
@@ -213,13 +235,13 @@
213
  return 0;
214
  }
215
 
216
- // http://mobiledetect.net/ does not contain the following user-agents
217
- if(preg_match("/Nokia309|Casper_VIA/i", $_SERVER['HTTP_USER_AGENT'])){
218
  return 0;
219
  }
220
 
221
- if($this->exclude_page()){
222
- //echo "<!-- Wp Fastest Cache: Exclude Page -->"."\n";
223
  return 0;
224
  }
225
 
@@ -268,7 +290,8 @@
268
  if($create_cache){
269
  $this->startTime = microtime(true);
270
 
271
- add_action( 'get_footer', array($this, "wp_print_scripts_action"));
 
272
 
273
  ob_start(array($this, "callback"));
274
  }
@@ -325,7 +348,7 @@
325
  return false;
326
  }
327
 
328
- public function exclude_page(){
329
  $preg_match_rule = "";
330
  $request_url = trim($_SERVER["REQUEST_URI"], "/");
331
 
@@ -334,12 +357,12 @@
334
  foreach((array)$this->exclude_rules as $key => $value){
335
  $value->type = isset($value->type) ? $value->type : "page";
336
 
337
- if(isset($value->prefix) && $value->prefix && $value->type == "page"){
338
  $value->content = trim($value->content);
339
  $value->content = trim($value->content, "/");
340
 
341
- if($value->prefix == "homepage"){
342
- if($request_url == "/" || $request_url == ""){
343
  return true;
344
  }
345
  }else if($value->prefix == "exact"){
@@ -411,6 +434,13 @@
411
  }
412
  }
413
 
 
 
 
 
 
 
 
414
  if(preg_match("/Mediapartners-Google|Google\sWireless\sTranscoder/i", $_SERVER['HTTP_USER_AGENT'])){
415
  return $buffer;
416
  }else if($this->is_xml($buffer)){
@@ -441,7 +471,7 @@
441
  return $buffer;
442
  }else if(!$this->cacheFilePath){
443
  return $buffer."<!-- permalink_structure ends with slash (/) but REQUEST_URI does not end with slash (/) -->";
444
- }else{
445
  $content = $buffer;
446
 
447
  if(isset($this->options->wpFastestCacheRenderBlocking) && method_exists("WpFastestCachePowerfulHtml", "render_blocking")){
@@ -572,9 +602,9 @@
572
 
573
  public function cdn_rewrite($content){
574
  if($this->cdn){
575
- $content = preg_replace_callback("/(srcset|src|href|data-lazyload|data-source-url|data-srcsmall|data-srclarge|data-srcfull|data-slide-img|data-lazy-original)\s{0,2}\=[\'\"]([^\'\"]+)[\'\"]/i", array($this, 'cdn_replace_urls'), $content);
576
  //url()
577
- $content = preg_replace_callback("/(url)\(([^\)]+)\)/i", array($this, 'cdn_replace_urls'), $content);
578
  //{"concatemoji":"http:\/\/your_url.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.7"}
579
  $content = preg_replace_callback("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", array($this, 'cdn_replace_urls'), $content);
580
  //<script>var loaderRandomImages=["https:\/\/www.site.com\/wp-content\/uploads\/2016\/12\/image.jpg"];</script>
@@ -729,7 +759,7 @@
729
  public function is_amp($content){
730
  $request_uri = trim($_SERVER["REQUEST_URI"], "/");
731
 
732
- if(preg_match("/amp$/", $request_uri)){
733
  if(preg_match("/<html[^\>]+amp[^\>]*>/i", $content)){
734
  return true;
735
  }
23
  $this->set_content_url();
24
  }
25
 
26
+ public function detect_current_page_type(){
27
+ if(preg_match("/\?/", $_SERVER["REQUEST_URI"])){
28
+ return true;
29
+ }
30
+
31
+ if(preg_match("/^\/wp-json/", $_SERVER["REQUEST_URI"])){
32
+ return true;
33
+ }
34
+
35
+ if(is_front_page()){
36
+ echo "<!--WPFC_PAGE_TYPE_homepage-->";
37
+ }else if(is_category()){
38
+ echo "<!--WPFC_PAGE_TYPE_category-->";
39
+ }else if(is_tag()){
40
+ echo "<!--WPFC_PAGE_TYPE_tag-->";
41
+ }else if(is_singular('post')){
42
+ echo "<!--WPFC_PAGE_TYPE_post-->";
43
+ }else if(is_page()){
44
+ echo "<!--WPFC_PAGE_TYPE_page-->";
45
+ }
46
+ }
47
+
48
  public function set_content_url(){
49
  $content_url = content_url();
50
 
235
  return 0;
236
  }
237
 
238
+ if($this->exclude_page()){
239
+ //echo "<!-- Wp Fastest Cache: Exclude Page -->"."\n";
240
  return 0;
241
  }
242
 
243
+ // http://mobiledetect.net/ does not contain the following user-agents
244
+ if(preg_match("/Nokia309|Casper_VIA/i", $_SERVER['HTTP_USER_AGENT'])){
245
  return 0;
246
  }
247
 
290
  if($create_cache){
291
  $this->startTime = microtime(true);
292
 
293
+ add_action('wp', array($this, "detect_current_page_type"));
294
+ add_action('get_footer', array($this, "wp_print_scripts_action"));
295
 
296
  ob_start(array($this, "callback"));
297
  }
348
  return false;
349
  }
350
 
351
+ public function exclude_page($buffer = false){
352
  $preg_match_rule = "";
353
  $request_url = trim($_SERVER["REQUEST_URI"], "/");
354
 
357
  foreach((array)$this->exclude_rules as $key => $value){
358
  $value->type = isset($value->type) ? $value->type : "page";
359
 
360
+ if($buffer && isset($value->prefix) && $value->prefix && ($value->type == "page")){
361
  $value->content = trim($value->content);
362
  $value->content = trim($value->content, "/");
363
 
364
+ if(preg_match("/^(homepage|category|tag|post|page)$/", $value->prefix)){
365
+ if(preg_match('/<\!--WPFC_PAGE_TYPE_'.$value->prefix.'-->/i', $buffer)){
366
  return true;
367
  }
368
  }else if($value->prefix == "exact"){
434
  }
435
  }
436
 
437
+ if($this->exclude_page($buffer)){
438
+ $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
439
+ return $buffer;
440
+ }
441
+
442
+ $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
443
+
444
  if(preg_match("/Mediapartners-Google|Google\sWireless\sTranscoder/i", $_SERVER['HTTP_USER_AGENT'])){
445
  return $buffer;
446
  }else if($this->is_xml($buffer)){
471
  return $buffer;
472
  }else if(!$this->cacheFilePath){
473
  return $buffer."<!-- permalink_structure ends with slash (/) but REQUEST_URI does not end with slash (/) -->";
474
+ }else{
475
  $content = $buffer;
476
 
477
  if(isset($this->options->wpFastestCacheRenderBlocking) && method_exists("WpFastestCachePowerfulHtml", "render_blocking")){
602
 
603
  public function cdn_rewrite($content){
604
  if($this->cdn){
605
+ $content = preg_replace_callback("/(srcset|src|href|data-bg-url|data-lazyload|data-source-url|data-srcsmall|data-srclarge|data-srcfull|data-slide-img|data-lazy-original)\s{0,2}\=[\'\"]([^\'\"]+)[\'\"]/i", array($this, 'cdn_replace_urls'), $content);
606
  //url()
607
+ $content = preg_replace_callback("/(url)\(([^\)\>]+)\)/i", array($this, 'cdn_replace_urls'), $content);
608
  //{"concatemoji":"http:\/\/your_url.com\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.7"}
609
  $content = preg_replace_callback("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", array($this, 'cdn_replace_urls'), $content);
610
  //<script>var loaderRandomImages=["https:\/\/www.site.com\/wp-content\/uploads\/2016\/12\/image.jpg"];</script>
759
  public function is_amp($content){
760
  $request_uri = trim($_SERVER["REQUEST_URI"], "/");
761
 
762
+ if(preg_match("/^amp/", $request_uri) || preg_match("/amp$/", $request_uri)){
763
  if(preg_match("/<html[^\>]+amp[^\>]*>/i", $content)){
764
  return true;
765
  }
inc/column.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WpFastestCacheColumn{
3
+ public function __construct(){}
4
+
5
+ public function add(){
6
+ add_filter('manage_posts_columns', array($this, 'wpfc_clear_column_head'));
7
+ add_action('manage_posts_custom_column', array($this, 'wpfc_clear_column_content'), 10, 2);
8
+ add_action('admin_enqueue_scripts', array($this, 'load_js'));
9
+ add_action('wp_ajax_wpfc_clear_cache_column', array($this, "clear_cache_column"));
10
+ }
11
+
12
+ public function clear_cache_column(){
13
+ $GLOBALS["wp_fastest_cache"]->singleDeleteCache(false, esc_sql($_GET["id"]));
14
+
15
+ die(json_encode(array("success" => true)));
16
+ }
17
+
18
+ public function load_js(){
19
+ wp_enqueue_script("wpfc-column", plugins_url("wp-fastest-cache/js/column.js"), array(), time(), true);
20
+ }
21
+
22
+ public function wpfc_clear_column_head($defaults) {
23
+ $defaults['wpfc_column_clear_cache'] = 'Cache';
24
+ return $defaults;
25
+ }
26
+
27
+ public function wpfc_clear_column_content($column_name, $post_ID) {
28
+ if($column_name == "wpfc_column_clear_cache"){
29
+ echo '<button wpfc-clear-column="'.$post_ID.'" class="button wpfc-clear-column-action">
30
+ <span>Clear</span>
31
+ </button>';
32
+ }
33
+ }
34
+ }
35
+ ?>
js/cdn/cdn.js CHANGED
@@ -209,6 +209,27 @@ var WpfcCDN = {
209
  var self = this;
210
  var modal = jQuery("#wpfc-modal-" + self.id);
211
  var cdn_url = modal.find("#cdn-url").val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  modal.find("#cdn-url-loading").show();
213
  modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html("");
214
  jQuery.ajax({
@@ -220,6 +241,8 @@ var WpfcCDN = {
220
  modal.find("#cdn-url-loading").hide();
221
  if(res.success){
222
  self.show_page("next");
 
 
223
  }else{
224
  modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html(res.error_message);
225
  }
@@ -228,7 +251,7 @@ var WpfcCDN = {
228
  modal.find("#cdn-url-loading").hide();
229
  alert("unknown error");
230
  }
231
- });
232
  },
233
  show_page: function(type){
234
  var current_page = jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible");
209
  var self = this;
210
  var modal = jQuery("#wpfc-modal-" + self.id);
211
  var cdn_url = modal.find("#cdn-url").val();
212
+ var origin_url = modal.find("#origin-url").val();
213
+
214
+ if(!cdn_url || !origin_url){
215
+ if(!cdn_url){
216
+ modal.find("#cdn-url").css("background-color", "red");
217
+ }else{
218
+ modal.find("#cdn-url").css("background-color", "white");
219
+ }
220
+
221
+ if(!origin_url){
222
+ modal.find("#origin-url").css("background-color", "red");
223
+ }else{
224
+ modal.find("#origin-url").css("background-color", "white");
225
+ }
226
+
227
+ return;
228
+ }else{
229
+ modal.find("#cdn-url").css("background-color", "white");
230
+ modal.find("#origin-url").css("background-color", "white");
231
+ }
232
+
233
  modal.find("#cdn-url-loading").show();
234
  modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html("");
235
  jQuery.ajax({
241
  modal.find("#cdn-url-loading").hide();
242
  if(res.success){
243
  self.show_page("next");
244
+ modal.find("#cdn-url").css("background-color", "white");
245
+ modal.find("#origin-url").css("background-color", "white");
246
  }else{
247
  modal.find(".wpfc-cdn-pages-container div.wiz-cont:visible #cdn-url").nextAll("label").html(res.error_message);
248
  }
251
  modal.find("#cdn-url-loading").hide();
252
  alert("unknown error");
253
  }
254
+ });
255
  },
256
  show_page: function(type){
257
  var current_page = jQuery("#wpfc-modal-" + this.id).find(".wpfc-cdn-pages-container div.wiz-cont:visible");
js/column.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ if(window.attachEvent) {
2
+ window.attachEvent('onload', wpfc_column_button_action);
3
+ } else {
4
+ if(window.onload) {
5
+ var curronload_1 = window.onload;
6
+ var newonload_1 = function(evt) {
7
+ curronload_1(evt);
8
+ wpfc_column_button_action(evt);
9
+ };
10
+ window.onload = newonload_1;
11
+ } else {
12
+ window.onload = wpfc_column_button_action;
13
+ }
14
+ }
15
+ function wpfc_column_button_action(){
16
+ jQuery(document).ready(function(){
17
+ jQuery("button.button.wpfc-clear-column-action:visible").click(function(e){
18
+
19
+ jQuery(e.currentTarget).attr("disabled", true);
20
+
21
+ jQuery.ajax({
22
+ type: 'GET',
23
+ url: ajaxurl,
24
+ data : {"action": "wpfc_clear_cache_column", "id" : jQuery(e.currentTarget).attr("wpfc-clear-column")},
25
+ dataType : "json",
26
+ cache: false,
27
+ success: function(data){
28
+ if(typeof data.success != "undefined" && data.success == true){
29
+ jQuery(e.currentTarget).attr("disabled", false);
30
+ }else{
31
+ alert("Clear Cache Error");
32
+ }
33
+ }
34
+ });
35
+
36
+ return false;
37
+ });
38
+ });
39
+ }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: emrevona
3
  Donate link: http://profiles.wordpress.org/emrevona/
4
  Tags: cache, performance, wp-cache, total cache, super cache
5
  Requires at least: 3.3
6
- Tested up to: 4.7.5
7
- Stable tag: 0.8.6.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -101,6 +101,17 @@ Wpfc does not support Wordpress Multisite yet.
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
 
 
 
 
 
104
  = 0.8.6.9 =
105
  * <strong>[FEATURE]</strong> to clear cache of the post tags and the post categories after new post
106
  * <strong>[FEATURE]</strong> WebP [<a target="_blank" href="http://www.wpfastestcache.com/premium/image-optimization/">Details</a>]
3
  Donate link: http://profiles.wordpress.org/emrevona/
4
  Tags: cache, performance, wp-cache, total cache, super cache
5
  Requires at least: 3.3
6
+ Tested up to: 4.8
7
+ Stable tag: 0.8.7.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 0.8.7.0 =
105
+ * to avoid removing www prefix from photon cdn-url
106
+ * to prevent to empty origin-url on cdn wizard
107
+ * <strong>[FEATURE]</strong> to clear cache of post via post list
108
+ * preload for woocommorce product category
109
+ * to clear cache of tag and cat after product update
110
+ * to check that SG Optimizer is active or not
111
+ * <strong>[FEATURE]</strong> Preload for tags
112
+ * <strong>[FEATURE]</strong> Preload for attachments
113
+ * <strong>[FEATURE]</strong> exclude categories, tags, posts and pages
114
+
115
  = 0.8.6.9 =
116
  * <strong>[FEATURE]</strong> to clear cache of the post tags and the post categories after new post
117
  * <strong>[FEATURE]</strong> WebP [<a target="_blank" href="http://www.wpfastestcache.com/premium/image-optimization/">Details</a>]
templates/exclude.php CHANGED
@@ -91,6 +91,10 @@
91
  <select name="wpfc-exclude-rule-prefix">
92
  <option selected="" value=""></option>
93
  <option value="homepage">Home Page</option>
 
 
 
 
94
  <option value="startwith">Starts With</option>
95
  <option value="contain">Contains</option>
96
  <option value="exact">Is Equal To</option>
@@ -176,16 +180,16 @@
176
  var clone_modal_id = "wpfc-modal-exclude-" + new Date().getTime();
177
 
178
  clone_modal.find("select").change(function(e){
179
- if(jQuery(this).val() == "homepage"){
180
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
181
- clone_modal.find("input[name='wpfc-exclude-rule-content']").val("home");
182
  }else{
183
  clone_modal.find("input[name='wpfc-exclude-rule-content']").show();
184
  clone_modal.find("input[name='wpfc-exclude-rule-content']").val("");
185
  }
186
  });
187
 
188
- if(e.prefix == "homepage"){
189
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
190
  }
191
 
@@ -239,8 +243,6 @@
239
  self.save(function(){
240
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("prefix", prefix);
241
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("content", content);
242
- // jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-prefix").text(self.get_text(prefix));
243
- // jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-content").text('"' + content + '"');
244
 
245
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-url").html(self.create_url_description(prefix, content, type));
246
 
@@ -271,6 +273,14 @@
271
  title = "Contains: " + content;
272
  }else if(prefix == "homepage"){
273
  title = "Home Page";
 
 
 
 
 
 
 
 
274
  }
275
 
276
  return title;
@@ -291,7 +301,15 @@
291
  }
292
 
293
  if(type == "page" || type == "css" || type == "js"){
294
- return "<?php echo home_url();?>" + "/" + request_uri;
 
 
 
 
 
 
 
 
295
  }else if(type == "useragent"){
296
  return "User-Agent: " + request_uri;
297
  }else if(type == "cookie"){
@@ -347,9 +365,9 @@
347
 
348
 
349
  clone_modal.find("select").change(function(){
350
- if(jQuery(this).val() == "homepage"){
351
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
352
- clone_modal.find("input[name='wpfc-exclude-rule-content']").val("home");
353
  }else{
354
  clone_modal.find("input[name='wpfc-exclude-rule-content']").show();
355
  clone_modal.find("input[name='wpfc-exclude-rule-content']").val("");
@@ -440,10 +458,6 @@
440
  });
441
  }
442
  },
443
- get_text: function(value){
444
- var obj = {"exact" : "Is Equal To","startwith" : "Starts With","contain" : "Contains", "homepage" : "Home Page"};
445
- return obj[value];
446
- },
447
  is_empty_values: function(prefix, content){
448
  if(prefix){
449
  jQuery("#wpfc-wizard-exclude select[name='wpfc-exclude-rule-prefix']").css({'border-color': '#ddd'});
91
  <select name="wpfc-exclude-rule-prefix">
92
  <option selected="" value=""></option>
93
  <option value="homepage">Home Page</option>
94
+ <option value="category">Categories</option>
95
+ <option value="tag">Tags</option>
96
+ <option value="post">Posts</option>
97
+ <option value="page">Pages</option>
98
  <option value="startwith">Starts With</option>
99
  <option value="contain">Contains</option>
100
  <option value="exact">Is Equal To</option>
180
  var clone_modal_id = "wpfc-modal-exclude-" + new Date().getTime();
181
 
182
  clone_modal.find("select").change(function(e){
183
+ if(jQuery(this).val().match(/^(homepage|category|tag|post|page)$/)){
184
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
185
+ clone_modal.find("input[name='wpfc-exclude-rule-content']").val(jQuery(this).val());
186
  }else{
187
  clone_modal.find("input[name='wpfc-exclude-rule-content']").show();
188
  clone_modal.find("input[name='wpfc-exclude-rule-content']").val("");
189
  }
190
  });
191
 
192
+ if(e.prefix.match(/^(homepage|category|tag|post|page)$/)){
193
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
194
  }
195
 
243
  self.save(function(){
244
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("prefix", prefix);
245
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").attr("content", content);
 
 
246
 
247
  jQuery("div.wpfc-exclude-item[wpfc-exclude-item-number='" + number + "']").find(".wpfc-exclude-item-url").html(self.create_url_description(prefix, content, type));
248
 
273
  title = "Contains: " + content;
274
  }else if(prefix == "homepage"){
275
  title = "Home Page";
276
+ }else if(prefix == "tag"){
277
+ title = "Tags";
278
+ }else if(prefix == "category"){
279
+ title = "Categories";
280
+ }else if(prefix == "post"){
281
+ title = "Posts";
282
+ }else if(prefix == "page"){
283
+ title = "Pages";
284
  }
285
 
286
  return title;
301
  }
302
 
303
  if(type == "page" || type == "css" || type == "js"){
304
+ if(prefix.match(/^(homepage|category|tag|post|page)$/)){
305
+ if(prefix == "homepage"){
306
+ return "The " + b_start + "homepage" + b_end + " has been excluded";
307
+ }else{
308
+ return "All" + " " + b_start + this.create_title(prefix).toLowerCase() + b_end + " " + "have been excluded";
309
+ }
310
+ }else{
311
+ return "<?php echo home_url();?>" + "/" + request_uri;
312
+ }
313
  }else if(type == "useragent"){
314
  return "User-Agent: " + request_uri;
315
  }else if(type == "cookie"){
365
 
366
 
367
  clone_modal.find("select").change(function(){
368
+ if(jQuery(this).val().match(/^(homepage|category|tag|post|page)$/)){
369
  clone_modal.find("input[name='wpfc-exclude-rule-content']").hide();
370
+ clone_modal.find("input[name='wpfc-exclude-rule-content']").val(jQuery(this).val());
371
  }else{
372
  clone_modal.find("input[name='wpfc-exclude-rule-content']").show();
373
  clone_modal.find("input[name='wpfc-exclude-rule-content']").val("");
458
  });
459
  }
460
  },
 
 
 
 
461
  is_empty_values: function(prefix, content){
462
  if(prefix){
463
  jQuery("#wpfc-wizard-exclude select[name='wpfc-exclude-rule-prefix']").css({'border-color': '#ddd'});
templates/preload.php CHANGED
@@ -44,10 +44,14 @@
44
  <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox" <?php echo $wpFastestCachePreload_page; ?> id="wpFastestCachePreload_page" name="wpFastestCachePreload_page"></label>
45
  <label for="wpFastestCachePreload_page">Pages</label>
46
  </div>
47
- <!-- <div class="wiz-input-cont" style="margin-right: 5px;">
48
- <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox"></label>
49
- <label>Tags</label>
50
- </div> -->
 
 
 
 
51
 
52
  <div class="wiz-input-cont" style="width: 91% !important;margin-bottom: 0px !important;">
53
  <label class="mc-input-label" style="float:left;">
44
  <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox" <?php echo $wpFastestCachePreload_page; ?> id="wpFastestCachePreload_page" name="wpFastestCachePreload_page"></label>
45
  <label for="wpFastestCachePreload_page">Pages</label>
46
  </div>
47
+ <div class="wiz-input-cont" style="margin-right: 5px;">
48
+ <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox" <?php echo $wpFastestCachePreload_tag; ?> id="wpFastestCachePreload_tag" name="wpFastestCachePreload_tag"></label>
49
+ <label for="wpFastestCachePreload_tag">Tages</label>
50
+ </div>
51
+ <div class="wiz-input-cont">
52
+ <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox" <?php echo $wpFastestCachePreload_attachment; ?> id="wpFastestCachePreload_attachment" name="wpFastestCachePreload_attachment"></label>
53
+ <label for="wpFastestCachePreload_attachment">Attachments</label>
54
+ </div>
55
 
56
  <div class="wiz-input-cont" style="width: 91% !important;margin-bottom: 0px !important;">
57
  <label class="mc-input-label" style="float:left;">
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.8.6.9
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -152,6 +152,7 @@ GNU General Public License for more details.
152
  add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
153
  add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
154
  add_action('wp_loaded', array($this, "load_admin_toolbar"));
 
155
 
156
  $this->admin();
157
  }
@@ -599,6 +600,13 @@ GNU General Public License for more details.
599
  }
600
  }
601
 
 
 
 
 
 
 
 
602
  public function load_admin_toolbar(){
603
  if(!defined('WPFC_HIDE_TOOLBAR') || (defined('WPFC_HIDE_TOOLBAR') && !WPFC_HIDE_TOOLBAR)){
604
  $show = false;
@@ -738,6 +746,7 @@ GNU General Public License for more details.
738
  delete_option("WpFastestCacheCSSSIZE");
739
  delete_option("WpFastestCacheJS");
740
  delete_option("WpFastestCacheJSSIZE");
 
741
 
742
  foreach ((array)_get_cron_array() as $cron_key => $cron_value) {
743
  foreach ( (array) $cron_value as $hook => $events ) {
@@ -874,29 +883,23 @@ GNU General Public License for more details.
874
  // to clear cache of homepage
875
  $this->deleteHomePageCache();
876
 
877
- // to clear cache of cats which contains the post (only first page)
878
- foreach (wp_get_post_categories($post_id) as $cat_key => $cat_id) {
879
- $url = get_category_link($cat_id);
880
 
881
- if(preg_match("/^http/", $url)){
882
- $path = preg_replace("/https?\:\/\/[^\/]+/i", "", $url);
883
- $path = trim($path, "/");
884
-
885
- @unlink($this->getWpContentDir()."/cache/all/".$path."/index.html");
886
- @unlink($this->getWpContentDir()."/cache/wpfc-mobile-cache/".$path."/index.html");
887
- }
888
- }
889
 
890
- // to clear cache of tags which contains the post (only first page)
891
- foreach (wp_get_post_tags($post_id) as $tag_key => $tag_id) {
892
- $url = get_tag_link($tag_id);
893
 
894
- if(preg_match("/^http/", $url)){
895
- $path = preg_replace("/https?\:\/\/[^\/]+/i", "", $url);
896
- $path = trim($path, "/");
897
 
898
- @unlink($this->getWpContentDir()."/cache/all/".$path."/index.html");
899
- @unlink($this->getWpContentDir()."/cache/wpfc-mobile-cache/".$path."/index.html");
 
900
  }
901
  }
902
  }
@@ -1143,7 +1146,7 @@ GNU General Public License for more details.
1143
  // 'suppress_filters' => true
1144
  // ), ARRAY_A);
1145
  global $wpdb;
1146
- $recent_posts = $GLOBALS['wpdb']->get_results("SELECT SQL_CALC_FOUND_ROWS ".$wpdb->prefix."posts.ID FROM ".$wpdb->prefix."posts WHERE 1=1 AND (".$wpdb->prefix."posts.post_type = 'post' OR ".$wpdb->prefix."posts.post_type = 'product') AND ((".$wpdb->prefix."posts.post_status = 'publish')) ORDER BY ".$wpdb->prefix."posts.ID DESC LIMIT ".$pre_load->post.", ".$number, ARRAY_A);
1147
 
1148
 
1149
  if(count($recent_posts) > 0){
@@ -1163,6 +1166,27 @@ GNU General Public License for more details.
1163
  }
1164
  }
1165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1166
 
1167
  // PAGE
1168
  if($number > 0 && $pre_load->page > -1){
@@ -1198,24 +1222,28 @@ GNU General Public License for more details.
1198
 
1199
  // CATEGORY
1200
  if($number > 0 && $pre_load->category > -1){
1201
- $categories = get_terms("category", array(
1202
- 'orderby' => 'id',
1203
- 'order' => 'DESC',
1204
- 'hide_empty' => false,
1205
- 'number' => $number,
1206
- 'fields' => 'all',
1207
- 'pad_counts' => false,
1208
- 'offset' => $pre_load->category
1209
- ));
1210
-
 
 
 
 
1211
  if(count($categories) > 0){
1212
  foreach ($categories as $key => $category) {
1213
  if($mobile_theme){
1214
- array_push($urls, array("url" => get_term_link($category->slug, "category"), "user-agent" => "mobile"));
1215
  $number--;
1216
  }
1217
 
1218
- array_push($urls, array("url" => get_term_link($category->slug, "category"), "user-agent" => "desktop"));
1219
  $number--;
1220
 
1221
  $pre_load->category = $pre_load->category + 1;
@@ -1226,6 +1254,45 @@ GNU General Public License for more details.
1226
  }
1227
  }
1228
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1229
 
1230
  if(count($urls) > 0){
1231
  foreach ($urls as $key => $arr) {
@@ -1284,7 +1351,7 @@ GNU General Public License for more details.
1284
  }
1285
 
1286
  public function wpfc_remote_get($url, $user_agent){
1287
- $response = wp_remote_get($url, array('timeout' => 10, 'headers' => array("cache-control" => array("no-store, no-cache, must-revalidate", "post-check=0, pre-check=0"),'user-agent' => $user_agent)));
1288
 
1289
  if (!$response || is_wp_error($response)){
1290
  echo $response->get_error_message()." - ";
@@ -1404,7 +1471,7 @@ GNU General Public License for more details.
1404
  public function rm_folder_recursively($dir, $i = 1) {
1405
  $files = @scandir($dir);
1406
  foreach((array)$files as $file) {
1407
- if($i > 50){
1408
  return true;
1409
  }else{
1410
  $i++;
@@ -1625,6 +1692,11 @@ GNU General Public License for more details.
1625
  }else{
1626
  $cdnurl = $cdn->cdnurl;
1627
  }
 
 
 
 
 
1628
  }else{
1629
  $cdnurl = $cdn->cdnurl;
1630
  }
@@ -1638,7 +1710,7 @@ GNU General Public License for more details.
1638
  if($cdn->keywords){
1639
  $cdn->keywords = str_replace(",", "|", $cdn->keywords);
1640
 
1641
- if(!preg_match("/".$cdn->keywords."/i", $matches[0])){
1642
  continue;
1643
  }
1644
  }
@@ -1646,9 +1718,9 @@ GNU General Public License for more details.
1646
  if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){
1647
  $matches[0] = preg_replace("/(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "", $matches[0]);
1648
  $matches[0] = preg_replace("/".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
1649
- }else if(preg_match("/".preg_quote($cdn->originurl, "/")."/", $matches[2])){
1650
  $matches[0] = preg_replace("/(http(s?)\:)?\/\/(www\.)?".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
1651
- }else if(preg_match("/^(\/?)(wp-includes|wp-content)/", $matches[2])){
1652
  $matches[0] = preg_replace("/(\/?)(wp-includes|wp-content)/i", $cdnurl."/"."$2", $matches[0]);
1653
  }else if(preg_match("/[\"\']https?\:\\\\\/\\\\\/[^\"\']+[\"\']/i", $matches[0])){
1654
  if(preg_match("/^(logo|url)$/i", $matches[1])){
@@ -1716,14 +1788,13 @@ GNU General Public License for more details.
1716
 
1717
  public function get_mobile_browsers(){
1718
  $mobile_browsers = array(
1719
- 'Vivaldi',
1720
  '\bCrMo\b|CriOS|Android.*Chrome\/[.0-9]*\s(Mobile)?',
1721
  '\bDolfin\b',
1722
  'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+',
1723
  'Skyfire',
1724
  'Mobile\sSafari\/[.0-9]*\sEdge',
1725
  'IEMobile|MSIEMobile', // |Trident/[.0-9]+
1726
- 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile',
1727
  'bolt',
1728
  'teashark',
1729
  'Blazer',
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.8.7.0
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
152
  add_action('wp_ajax_wpfc_cdn_template_ajax_request', array($this, 'wpfc_cdn_template_ajax_request_callback'));
153
  add_action('plugins_loaded', array($this, 'wpfc_load_plugin_textdomain'));
154
  add_action('wp_loaded', array($this, "load_admin_toolbar"));
155
+ add_action('wp_loaded', array($this, "load_column"));
156
 
157
  $this->admin();
158
  }
600
  }
601
  }
602
 
603
+ public function load_column(){
604
+ include_once plugin_dir_path(__FILE__)."inc/column.php";
605
+
606
+ $column = new WpFastestCacheColumn();
607
+ $column->add();
608
+ }
609
+
610
  public function load_admin_toolbar(){
611
  if(!defined('WPFC_HIDE_TOOLBAR') || (defined('WPFC_HIDE_TOOLBAR') && !WPFC_HIDE_TOOLBAR)){
612
  $show = false;
746
  delete_option("WpFastestCacheCSSSIZE");
747
  delete_option("WpFastestCacheJS");
748
  delete_option("WpFastestCacheJSSIZE");
749
+ delete_option("wpfc_server_location");
750
 
751
  foreach ((array)_get_cron_array() as $cron_key => $cron_value) {
752
  foreach ( (array) $cron_value as $hook => $events ) {
883
  // to clear cache of homepage
884
  $this->deleteHomePageCache();
885
 
886
+ // to clear cache of cats and tags which contains the post (only first page)
887
+ global $wpdb;
888
+ $terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
889
 
890
+ foreach ($terms as $term_key => $term_val){
891
+ $term = get_term($term_val["term_taxonomy_id"]);
 
 
 
 
 
 
892
 
893
+ if(preg_match("/cat|tag/", $term->taxonomy)){
894
+ $url = get_term_link($term->term_id, $term->taxonomy);
 
895
 
896
+ if(preg_match("/^http/", $url)){
897
+ $path = preg_replace("/https?\:\/\/[^\/]+/i", "", $url);
898
+ $path = trim($path, "/");
899
 
900
+ @unlink($this->getWpContentDir()."/cache/all/".$path."/index.html");
901
+ @unlink($this->getWpContentDir()."/cache/wpfc-mobile-cache/".$path."/index.html");
902
+ }
903
  }
904
  }
905
  }
1146
  // 'suppress_filters' => true
1147
  // ), ARRAY_A);
1148
  global $wpdb;
1149
+ $recent_posts = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS ".$wpdb->prefix."posts.ID FROM ".$wpdb->prefix."posts WHERE 1=1 AND (".$wpdb->prefix."posts.post_type = 'post' OR ".$wpdb->prefix."posts.post_type = 'product') AND ((".$wpdb->prefix."posts.post_status = 'publish')) ORDER BY ".$wpdb->prefix."posts.ID DESC LIMIT ".$pre_load->post.", ".$number, ARRAY_A);
1150
 
1151
 
1152
  if(count($recent_posts) > 0){
1166
  }
1167
  }
1168
 
1169
+ // ATTACHMENT
1170
+ if($number > 0 && isset($pre_load->attachment) && $pre_load->attachment > -1){
1171
+ global $wpdb;
1172
+ $recent_attachments = $wpdb->get_results("SELECT SQL_CALC_FOUND_ROWS ".$wpdb->prefix."posts.ID FROM ".$wpdb->prefix."posts WHERE 1=1 AND (".$wpdb->prefix."posts.post_type = 'attachment') ORDER BY ".$wpdb->prefix."posts.ID DESC LIMIT ".$pre_load->attachment.", ".$number, ARRAY_A);
1173
+
1174
+ if(count($recent_attachments) > 0){
1175
+ foreach ($recent_attachments as $key => $attachment) {
1176
+ if($mobile_theme){
1177
+ array_push($urls, array("url" => get_permalink($attachment["ID"]), "user-agent" => "mobile"));
1178
+ $number--;
1179
+ }
1180
+
1181
+ array_push($urls, array("url" => get_permalink($attachment["ID"]), "user-agent" => "desktop"));
1182
+ $number--;
1183
+
1184
+ $pre_load->attachment = $pre_load->attachment + 1;
1185
+ }
1186
+ }else{
1187
+ $pre_load->attachment = -1;
1188
+ }
1189
+ }
1190
 
1191
  // PAGE
1192
  if($number > 0 && $pre_load->page > -1){
1222
 
1223
  // CATEGORY
1224
  if($number > 0 && $pre_load->category > -1){
1225
+ // $categories = get_terms(array(
1226
+ // 'taxonomy' => array('category', 'product_cat'),
1227
+ // 'orderby' => 'id',
1228
+ // 'order' => 'DESC',
1229
+ // 'hide_empty' => false,
1230
+ // 'number' => $number,
1231
+ // 'fields' => 'all',
1232
+ // 'pad_counts' => false,
1233
+ // 'offset' => $pre_load->category
1234
+ // ));
1235
+
1236
+ global $wpdb;
1237
+ $categories = $wpdb->get_results("SELECT t.*, tt.* FROM ".$wpdb->prefix."terms AS t INNER JOIN ".$wpdb->prefix."term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('category', 'product_cat') ORDER BY t.term_id ASC LIMIT ".$pre_load->category.", ".$number, ARRAY_A);
1238
+
1239
  if(count($categories) > 0){
1240
  foreach ($categories as $key => $category) {
1241
  if($mobile_theme){
1242
+ array_push($urls, array("url" => get_term_link($category["slug"], $category["taxonomy"]), "user-agent" => "mobile"));
1243
  $number--;
1244
  }
1245
 
1246
+ array_push($urls, array("url" => get_term_link($category["slug"], $category["taxonomy"]), "user-agent" => "desktop"));
1247
  $number--;
1248
 
1249
  $pre_load->category = $pre_load->category + 1;
1254
  }
1255
  }
1256
 
1257
+ // TAG
1258
+ if($number > 0 && isset($pre_load->tag) && $pre_load->tag > -1){
1259
+ // $tags = get_terms(array(
1260
+ // 'taxonomy' => array('post_tag', 'product_tag'),
1261
+ // 'orderby' => 'id',
1262
+ // 'order' => 'DESC',
1263
+ // 'hide_empty' => false,
1264
+ // 'number' => $number,
1265
+ // 'fields' => 'all',
1266
+ // 'pad_counts' => false,
1267
+ // 'offset' => $pre_load->tag
1268
+ // ));
1269
+
1270
+ global $wpdb;
1271
+ $tags = $wpdb->get_results("SELECT t.*, tt.* FROM ".$wpdb->prefix."terms AS t INNER JOIN ".$wpdb->prefix."term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag', 'product_tag') ORDER BY t.term_id ASC LIMIT ".$pre_load->tag.", ".$number, ARRAY_A);
1272
+
1273
+
1274
+ if(count($tags) > 0){
1275
+ foreach ($tags as $key => $tag) {
1276
+ if($mobile_theme){
1277
+ array_push($urls, array("url" => get_term_link($tag["slug"], $tag["taxonomy"]), "user-agent" => "mobile"));
1278
+ $number--;
1279
+ }
1280
+
1281
+ array_push($urls, array("url" => get_term_link($tag["slug"], $tag["taxonomy"]), "user-agent" => "desktop"));
1282
+ $number--;
1283
+
1284
+ $pre_load->tag = $pre_load->tag + 1;
1285
+
1286
+ }
1287
+ }else{
1288
+ $pre_load->tag = -1;
1289
+ }
1290
+ }
1291
+
1292
+
1293
+
1294
+
1295
+
1296
 
1297
  if(count($urls) > 0){
1298
  foreach ($urls as $key => $arr) {
1351
  }
1352
 
1353
  public function wpfc_remote_get($url, $user_agent){
1354
+ $response = wp_remote_get($url, array('timeout' => 10, 'sslverify' => false, 'headers' => array("cache-control" => array("no-store, no-cache, must-revalidate", "post-check=0, pre-check=0"),'user-agent' => $user_agent)));
1355
 
1356
  if (!$response || is_wp_error($response)){
1357
  echo $response->get_error_message()." - ";
1471
  public function rm_folder_recursively($dir, $i = 1) {
1472
  $files = @scandir($dir);
1473
  foreach((array)$files as $file) {
1474
+ if($i > 50 && !preg_match("/wp-fastest-cache-premium/i", $dir)){
1475
  return true;
1476
  }else{
1477
  $i++;
1692
  }else{
1693
  $cdnurl = $cdn->cdnurl;
1694
  }
1695
+
1696
+ //to add www. if exists
1697
+ if(preg_match("/\/\/www\./", $matches[0])){
1698
+ $cdnurl = preg_replace("/(\/\/i\d\.wp\.com\/)(www\.)?/", "$1www.", $cdnurl);
1699
+ }
1700
  }else{
1701
  $cdnurl = $cdn->cdnurl;
1702
  }
1710
  if($cdn->keywords){
1711
  $cdn->keywords = str_replace(",", "|", $cdn->keywords);
1712
 
1713
+ if(!preg_match("/".preg_quote($cdn->keywords, "/")."/i", $matches[0])){
1714
  continue;
1715
  }
1716
  }
1718
  if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){
1719
  $matches[0] = preg_replace("/(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "", $matches[0]);
1720
  $matches[0] = preg_replace("/".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
1721
+ }else if(isset($matches[2]) && preg_match("/".preg_quote($cdn->originurl, "/")."/", $matches[2])){
1722
  $matches[0] = preg_replace("/(http(s?)\:)?\/\/(www\.)?".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
1723
+ }else if(isset($matches[2]) && preg_match("/^(\/?)(wp-includes|wp-content)/", $matches[2])){
1724
  $matches[0] = preg_replace("/(\/?)(wp-includes|wp-content)/i", $cdnurl."/"."$2", $matches[0]);
1725
  }else if(preg_match("/[\"\']https?\:\\\\\/\\\\\/[^\"\']+[\"\']/i", $matches[0])){
1726
  if(preg_match("/^(logo|url)$/i", $matches[1])){
1788
 
1789
  public function get_mobile_browsers(){
1790
  $mobile_browsers = array(
 
1791
  '\bCrMo\b|CriOS|Android.*Chrome\/[.0-9]*\s(Mobile)?',
1792
  '\bDolfin\b',
1793
  'Opera.*Mini|Opera.*Mobi|Android.*Opera|Mobile.*OPR\/[0-9.]+|Coast\/[0-9.]+',
1794
  'Skyfire',
1795
  'Mobile\sSafari\/[.0-9]*\sEdge',
1796
  'IEMobile|MSIEMobile', // |Trident/[.0-9]+
1797
+ 'fennec|firefox.*maemo|(Mobile|Tablet).*Firefox|Firefox.*Mobile|FxiOS',
1798
  'bolt',
1799
  'teashark',
1800
  'Blazer',