WP Fastest Cache - Version 0.9.0.4

Version Description

  • to fix PHP Fatal error: Call to a member function lazy_load() on null in cache.php on line 798
  • to clear sitemap cache after updating or publishing post
  • to clear cache of the static posts page
  • to replace urls on data-siteorigin-parallax attribute with cdn-url
  • to fix the problem abour "Mobile" option
  • [FEATURE] Clear cache after theme or plugin update [Details]
Download this release

Release Info

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

Code changes from version 0.9.0.3 to 0.9.0.4

Files changed (4) hide show
  1. inc/cache.php +15 -2
  2. inc/nonce-timeout.php +0 -50
  3. readme.txt +10 -2
  4. wpFastestCache.php +78 -46
inc/cache.php CHANGED
@@ -140,6 +140,18 @@
140
  if(preg_match("/\.{2,}/", $this->cacheFilePath)){
141
  $this->cacheFilePath = false;
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
 
145
  public function remove_url_paramters(){
@@ -777,7 +789,7 @@
777
  $content = str_replace("<!--WPFC_FOOTER_START-->", "", $content);
778
 
779
 
780
- if(isset($this->options->wpFastestCacheLazyLoad)){
781
  $execute_lazy_load = true;
782
 
783
  // to disable Lazy Load if the page is amp
@@ -876,7 +888,8 @@
876
  $content = preg_replace_callback("/(jsFileLocation)\s*\:[\"\']([^\"\']+)[\"\']/i", array($this, 'cdn_replace_urls'), $content);
877
 
878
  // <form data-product_variations="[{&quot;src&quot;:&quot;//domain.com\/img.jpg&quot;}]">
879
- $content = preg_replace_callback("/data-product_variations\=[\"\'][^\"\']+[\"\']/i", array($this, 'cdn_replace_urls'), $content);
 
880
 
881
  // <object data="https://site.com/source.swf" type="application/x-shockwave-flash"></object>
882
  $content = preg_replace_callback("/<object[^\>]+(data)\s{0,2}\=[\'\"]([^\'\"]+)[\'\"][^\>]+>/i", array($this, 'cdn_replace_urls'), $content);
140
  if(preg_match("/\.{2,}/", $this->cacheFilePath)){
141
  $this->cacheFilePath = false;
142
  }
143
+
144
+ if($this->isMobile()){
145
+ if(isset($this->options->wpFastestCacheMobile)){
146
+ if(!class_exists("WpFcMobileCache")){
147
+ $this->cacheFilePath = false;
148
+ }else{
149
+ if(!isset($this->options->wpFastestCacheMobileTheme)){
150
+ $this->cacheFilePath = false;
151
+ }
152
+ }
153
+ }
154
+ }
155
  }
156
 
157
  public function remove_url_paramters(){
789
  $content = str_replace("<!--WPFC_FOOTER_START-->", "", $content);
790
 
791
 
792
+ if(isset($this->options->wpFastestCacheLazyLoad) && class_exists("WpFastestCachePowerfulHtml")){
793
  $execute_lazy_load = true;
794
 
795
  // to disable Lazy Load if the page is amp
888
  $content = preg_replace_callback("/(jsFileLocation)\s*\:[\"\']([^\"\']+)[\"\']/i", array($this, 'cdn_replace_urls'), $content);
889
 
890
  // <form data-product_variations="[{&quot;src&quot;:&quot;//domain.com\/img.jpg&quot;}]">
891
+ // <div data-siteorigin-parallax="{&quot;backgroundUrl&quot;:&quot;https:\/\/domain.com\/wp-content\/TOR.jpg&quot;,&quot;backgroundSize&quot;:[830,467],&quot;}" data-stretch-type="full">
892
+ $content = preg_replace_callback("/(data-product_variations|data-siteorigin-parallax)\=[\"\'][^\"\']+[\"\']/i", array($this, 'cdn_replace_urls'), $content);
893
 
894
  // <object data="https://site.com/source.swf" type="application/x-shockwave-flash"></object>
895
  $content = preg_replace_callback("/<object[^\>]+(data)\s{0,2}\=[\'\"]([^\'\"]+)[\'\"][^\>]+>/i", array($this, 'cdn_replace_urls'), $content);
inc/nonce-timeout.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
- class WPFC_NONCE_TIMEOUT{
3
- private $file_path = "";
4
- private $file_name = "nonce_datas.txt";
5
- private $prev_nonce = false;
6
- private $current_nonce = false;
7
-
8
- public function __construct($cache_path){
9
- $this->file_path = $cache_path;
10
- $this->set_current_nonce();
11
- $this->set_prev_nonce();
12
- }
13
-
14
- public function verify_nonce(){
15
- $verified = false;
16
-
17
- if($this->prev_nonce){
18
- if(wp_verify_nonce($this->prev_nonce, 'wpfc')){
19
- $verified = true;
20
- }else{
21
- $this->write();
22
- }
23
- }else{
24
- $verified = true;
25
-
26
- $this->write();
27
- }
28
-
29
- return $verified;
30
- }
31
-
32
- public function write(){
33
- if(is_dir($this->file_path)){
34
- @file_put_contents($this->file_path."/".$this->file_name, $this->current_nonce);
35
- }
36
- }
37
-
38
- public function set_current_nonce(){
39
- $this->current_nonce = wp_create_nonce("wpfc");
40
- }
41
-
42
- public function set_prev_nonce(){
43
- if(file_exists($this->file_path."/".$this->file_name)){
44
- if($data = @file_get_contents($this->file_path."/".$this->file_name)){
45
- $this->prev_nonce = $data;
46
- }
47
- }
48
- }
49
- }
50
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: emrevona
3
  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.3
7
- Stable tag: 0.9.0.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,14 @@ The free version is enough to speed up your site but in the premium version ther
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
 
 
127
  = 0.9.0.3 =
128
  * [FEATURE] Compatible with Multiple Domain Mapping on single site
129
  * [BETA FEATURE] to create cache after publishing new post or updating a post [<a target="_blank" href="https://www.wpfastestcache.com/features/automatic-cache/">Details</a>]
3
  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.4
7
+ Stable tag: 0.9.0.4
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.0.4 =
128
+ * to fix PHP Fatal error: Call to a member function lazy_load() on null in cache.php on line 798
129
+ * to clear sitemap cache after updating or publishing post
130
+ * to clear cache of the static posts page
131
+ * to replace urls on data-siteorigin-parallax attribute with cdn-url
132
+ * to fix the problem abour "Mobile" option
133
+ * [FEATURE] Clear cache after theme or plugin update [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-after-theme-or-plugin-update/">Details</a>]
134
+
135
  = 0.9.0.3 =
136
  * [FEATURE] Compatible with Multiple Domain Mapping on single site
137
  * [BETA FEATURE] to create cache after publishing new post or updating a post [<a target="_blank" href="https://www.wpfastestcache.com/features/automatic-cache/">Details</a>]
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.0.3
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -114,8 +114,13 @@ GNU General Public License for more details.
114
  add_action( 'profile_update', array($this, 'modify_htaccess_for_new_user'), 10, 1);
115
  add_action( 'edit_terms', array($this, 'delete_cache_of_term'), 10, 1);
116
 
117
- // to check nonce is timeout or not
118
- //add_action('init', array($this, "nonce_timeout"));
 
 
 
 
 
119
 
120
  // to clear cache after new Woocommerce orders
121
  add_action('woocommerce_checkout_order_processed', array($this, 'clear_cache_after_woocommerce_checkout_order_processed'), 1, 1);
@@ -304,6 +309,22 @@ GNU General Public License for more details.
304
  }
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  public function action_links($actions){
308
  $actions['powered_settings'] = sprintf(__( '<a href="%s">Settings</a>', 'wp-fastest-cache'), esc_url( admin_url( 'admin.php?page=wpfastestcacheoptions')));
309
  return array_reverse($actions);
@@ -364,36 +385,6 @@ GNU General Public License for more details.
364
  $this->singleDeleteCache(false, $id);
365
  }
366
 
367
- public function nonce_timeout(){
368
- if(!is_user_logged_in()){
369
- $run = false;
370
- $list = array(
371
- "caldera-forms/caldera-core.php",
372
- "contact-form-7/wp-contact-form-7.php",
373
- "js_composer/js_composer.php",
374
- "kk-star-ratings/index.php",
375
- "ninja-forms/ninja-forms.php",
376
- "yet-another-stars-rating/yet-another-stars-rating.php"
377
- );
378
-
379
- foreach ($list as $key => $value) {
380
- if($this->isPluginActive($value)){
381
- $run = true;
382
- }
383
- }
384
-
385
- if($run){
386
- include_once('inc/nonce-timeout.php');
387
-
388
- $wpfc_nonce = new WPFC_NONCE_TIMEOUT(WPFC_WP_CONTENT_DIR."/cache/all");
389
-
390
- if(!$wpfc_nonce->verify_nonce()){
391
- $this->deleteCache();
392
- }
393
- }
394
- }
395
- }
396
-
397
  public function clear_cache_after_woocommerce_checkout_order_processed($order_id = false){
398
  if(function_exists("wc_get_order")){
399
  if($order_id){
@@ -836,6 +827,12 @@ GNU General Public License for more details.
836
  $my_home_url = trim($my_home_url, "/");
837
 
838
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$my_home_url."/$1", $path);
 
 
 
 
 
 
839
  }
840
 
841
  if($this->isPluginActive('multiple-domain-mapping-on-single-site/multidomainmapping.php')){
@@ -1078,6 +1075,9 @@ GNU General Public License for more details.
1078
  // to clear cache of author page
1079
  $this->delete_author_page_cache($post_id);
1080
 
 
 
 
1081
  // to clear cache of cats and tags which contains the post (only first page)
1082
  global $wpdb;
1083
  $terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
@@ -1091,16 +1091,35 @@ GNU General Public License for more details.
1091
  }
1092
  }
1093
 
1094
- public function delete_multiple_domain_mapping_cache(){
 
 
 
 
 
 
 
 
 
1095
  //https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/
1096
  if($this->isPluginActive("multiple-domain-mapping-on-single-site/multidomainmapping.php")){
1097
  $multiple_arr = get_option('falke_mdm_mappings');
1098
 
1099
  if(isset($multiple_arr) && isset($multiple_arr["mappings"]) && isset($multiple_arr["mappings"][0])){
1100
  foreach($multiple_arr["mappings"] as $mapping_key => $mapping_value){
1101
- $mapping_domain_path = preg_replace("/(\/cache\/[^\/]+\/all)/", "/cache/".$mapping_value["domain"]."/all", $this->getWpContentDir("/cache/all/index.html"));
 
 
 
 
 
 
 
 
 
1102
 
1103
- @unlink($mapping_domain_path);
 
1104
  }
1105
  }
1106
  }
@@ -1208,6 +1227,24 @@ GNU General Public License for more details.
1208
  $this->rm_folder_recursively($this->getWpContentDir("/cache/all/page"));
1209
  $this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/page"));
1210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
 
1212
  if($log){
1213
  if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
@@ -1262,7 +1299,7 @@ GNU General Public License for more details.
1262
  //to clear widget cache path
1263
  $this->deleteWidgetCache();
1264
 
1265
- $this->delete_multiple_domain_mapping_cache();
1266
 
1267
  if(is_dir($cache_path)){
1268
  if(@rename($cache_path, $this->getWpContentDir("/cache/tmpWpfc/").time())){
@@ -1791,7 +1828,7 @@ GNU General Public License for more details.
1791
 
1792
  $cdn->file_types = str_replace(",", "|", $cdn->file_types);
1793
 
1794
- if(preg_match("/\.(".$cdn->file_types.")[\"\'\?\)\s]/i", $matches[0])){
1795
  //nothing
1796
  }else{
1797
  if(preg_match("/js/", $cdn->file_types)){
@@ -1811,14 +1848,9 @@ GNU General Public License for more details.
1811
  }
1812
  }
1813
 
1814
- if(preg_match("/data-product_variations\=[\"\'][^\"\']+[\"\']/i", $matches[0])){
1815
- $cdn->originurl = preg_quote($cdn->originurl, "/");
1816
- $cdn->originurl = str_replace("\/", "\\\\\/", $cdn->originurl);
1817
-
1818
- if(preg_match("/".$cdn->originurl."/", $matches[0])){
1819
- $matches[0] = preg_replace("/(quot\;|\s)(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "$1", $matches[0]);
1820
- $matches[0] = preg_replace("/".$cdn->originurl."/i", $cdnurl, $matches[0]);
1821
- }
1822
  }else if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){
1823
  $matches[0] = preg_replace("/(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "", $matches[0]);
1824
  $matches[0] = preg_replace("/".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);
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.0.4
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
114
  add_action( 'profile_update', array($this, 'modify_htaccess_for_new_user'), 10, 1);
115
  add_action( 'edit_terms', array($this, 'delete_cache_of_term'), 10, 1);
116
 
117
+ if(defined("WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE") && WPFC_CLEAR_CACHE_AFTER_PLUGIN_UPDATE){
118
+ add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_plugin'), 10, 2);
119
+ }
120
+
121
+ if(defined("WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE") && WPFC_CLEAR_CACHE_AFTER_THEME_UPDATE){
122
+ add_action('upgrader_process_complete', array($this, 'clear_cache_after_update_theme'), 10, 2);
123
+ }
124
 
125
  // to clear cache after new Woocommerce orders
126
  add_action('woocommerce_checkout_order_processed', array($this, 'clear_cache_after_woocommerce_checkout_order_processed'), 1, 1);
309
  }
310
  }
311
 
312
+ public function clear_cache_after_update_plugin($upgrader_object, $options){
313
+ if($options['action'] == 'update'){
314
+ if($options['type'] == 'plugin' && isset($options['plugins'])){
315
+ $this->deleteCache();
316
+ }
317
+ }
318
+ }
319
+
320
+ public function clear_cache_after_update_theme($upgrader_object, $options){
321
+ if($options['action'] == 'update'){
322
+ if($options['type'] == 'theme' && isset($options['themes'])){
323
+ $this->deleteCache();
324
+ }
325
+ }
326
+ }
327
+
328
  public function action_links($actions){
329
  $actions['powered_settings'] = sprintf(__( '<a href="%s">Settings</a>', 'wp-fastest-cache'), esc_url( admin_url( 'admin.php?page=wpfastestcacheoptions')));
330
  return array_reverse($actions);
385
  $this->singleDeleteCache(false, $id);
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  public function clear_cache_after_woocommerce_checkout_order_processed($order_id = false){
389
  if(function_exists("wc_get_order")){
390
  if($order_id){
827
  $my_home_url = trim($my_home_url, "/");
828
 
829
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$my_home_url."/$1", $path);
830
+ }else if(($language_negotiation_type == 1) && $this->isPluginActive('sitepress-multilingual-cms/sitepress.php')){
831
+ $my_current_lang = apply_filters('wpml_current_language', NULL);
832
+
833
+ if($my_current_lang){
834
+ $path = preg_replace("/\/cache\/wpfc-widget-cache\/(.+)/", "/cache/wpfc-widget-cache/".$my_current_lang."-"."$1", $path);
835
+ }
836
  }
837
 
838
  if($this->isPluginActive('multiple-domain-mapping-on-single-site/multidomainmapping.php')){
1075
  // to clear cache of author page
1076
  $this->delete_author_page_cache($post_id);
1077
 
1078
+ // to clear sitemap cache
1079
+ $this->delete_sitemap_cache();
1080
+
1081
  // to clear cache of cats and tags which contains the post (only first page)
1082
  global $wpdb;
1083
  $terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
1091
  }
1092
  }
1093
 
1094
+ public function delete_sitemap_cache(){
1095
+ //to clear sitemap.xml and sitemap-(.+).xml
1096
+ $files = array_merge(glob($this->getWpContentDir("/cache/all/")."sitemap*.xml"), glob($this->getWpContentDir("/cache/wpfc-mobile-cache/")."sitemap*.xml"));
1097
+
1098
+ foreach((array)$files as $file){
1099
+ $this->rm_folder_recursively($file);
1100
+ }
1101
+ }
1102
+
1103
+ public function delete_multiple_domain_mapping_cache($minified = false){
1104
  //https://wordpress.org/plugins/multiple-domain-mapping-on-single-site/
1105
  if($this->isPluginActive("multiple-domain-mapping-on-single-site/multidomainmapping.php")){
1106
  $multiple_arr = get_option('falke_mdm_mappings');
1107
 
1108
  if(isset($multiple_arr) && isset($multiple_arr["mappings"]) && isset($multiple_arr["mappings"][0])){
1109
  foreach($multiple_arr["mappings"] as $mapping_key => $mapping_value){
1110
+ if($minified){
1111
+ $mapping_domain_path = preg_replace("/(\/cache\/[^\/]+\/all\/)/", "/cache/".$mapping_value["domain"]."/", $this->getWpContentDir("/cache/all/"));
1112
+
1113
+ if(is_dir($mapping_domain_path)){
1114
+ if(@rename($mapping_domain_path, $this->getWpContentDir("/cache/tmpWpfc/").$mapping_value["domain"]."_".time())){
1115
+
1116
+ }
1117
+ }
1118
+ }else{
1119
+ $mapping_domain_path = preg_replace("/(\/cache\/[^\/]+\/all)/", "/cache/".$mapping_value["domain"]."/all", $this->getWpContentDir("/cache/all/index.html"));
1120
 
1121
+ @unlink($mapping_domain_path);
1122
+ }
1123
  }
1124
  }
1125
  }
1227
  $this->rm_folder_recursively($this->getWpContentDir("/cache/all/page"));
1228
  $this->rm_folder_recursively($this->getWpContentDir("/cache/wpfc-mobile-cache/page"));
1229
 
1230
+ // options-reading.php - static posts page
1231
+ if($page_for_posts_id = get_option('page_for_posts')){
1232
+ $page_for_posts_permalink = urldecode(get_permalink($page_for_posts_id));
1233
+
1234
+ $page_for_posts_permalink = rtrim($page_for_posts_permalink, "/");
1235
+ $page_for_posts_permalink = preg_replace("/__trashed$/", "", $page_for_posts_permalink);
1236
+ //for /%postname%/%post_id% : sample-url__trashed/57595
1237
+ $page_for_posts_permalink = preg_replace("/__trashed\/(\d+)$/", "/$1", $page_for_posts_permalink);
1238
+
1239
+ if(preg_match("/https?:\/\/[^\/]+\/(.+)/", $page_for_posts_permalink, $out)){
1240
+ $page_for_posts_path = $this->getWpContentDir("/cache/all/").$out[1];
1241
+ $page_for_posts_mobile_path = $this->getWpContentDir("/cache/wpfc-mobile-cache/").$out[1];
1242
+
1243
+ $this->rm_folder_recursively($page_for_posts_path);
1244
+ $this->rm_folder_recursively($page_for_posts_mobile_path);
1245
+ }
1246
+ }
1247
+
1248
 
1249
  if($log){
1250
  if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
1299
  //to clear widget cache path
1300
  $this->deleteWidgetCache();
1301
 
1302
+ $this->delete_multiple_domain_mapping_cache($minified);
1303
 
1304
  if(is_dir($cache_path)){
1305
  if(@rename($cache_path, $this->getWpContentDir("/cache/tmpWpfc/").time())){
1828
 
1829
  $cdn->file_types = str_replace(",", "|", $cdn->file_types);
1830
 
1831
+ if(preg_match("/\.(".$cdn->file_types.")(\"|\'|\?|\)|\s|\&quot\;)/i", $matches[0])){
1832
  //nothing
1833
  }else{
1834
  if(preg_match("/js/", $cdn->file_types)){
1848
  }
1849
  }
1850
 
1851
+ if(preg_match("/(data-product_variations|data-siteorigin-parallax)\=[\"\'][^\"\']+[\"\']/i", $matches[0])){
1852
+ $cdnurl = preg_replace("/(https?\:)?(\/\/)(www\.)?/", "", $cdnurl);
1853
+ $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3$4".$cdnurl, $matches[0]);
 
 
 
 
 
1854
  }else if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){
1855
  $matches[0] = preg_replace("/(http(s?)\:)?".preg_quote("\/\/", "/")."(www\.)?/i", "", $matches[0]);
1856
  $matches[0] = preg_replace("/".preg_quote($cdn->originurl, "/")."/i", $cdnurl, $matches[0]);