WP Fastest Cache - Version 0.9.9

Version Description

  • to clear cache when regular price of woocommorce is updated
  • refactoring of Automatic Cache
Download this release

Release Info

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

Code changes from version 0.9.8 to 0.9.9

Files changed (4) hide show
  1. inc/cdn.php +7 -1
  2. inc/single-preload.php +76 -32
  3. readme.txt +5 -1
  4. wpFastestCache.php +13 -1
inc/cdn.php CHANGED
@@ -161,7 +161,13 @@
161
  }
162
 
163
 
164
- $hostname = preg_replace("/^(https?\:\/\/)?(www\d*\.)?/", "", $_SERVER["HTTP_HOST"]);
 
 
 
 
 
 
165
 
166
  if(function_exists("idn_to_utf8")){
167
  $hostname = idn_to_utf8($hostname);
161
  }
162
 
163
 
164
+ if(substr_count($_SERVER["HTTP_HOST"], ".") == 1){
165
+ // to exclude if the url is like https://www1.co
166
+ $hostname = preg_replace("/^(https?\:\/\/)/", "", $_SERVER["HTTP_HOST"]);
167
+ }else{
168
+ $hostname = preg_replace("/^(https?\:\/\/)?(www\d*\.)?/", "", $_SERVER["HTTP_HOST"]);
169
+ }
170
+
171
 
172
  if(function_exists("idn_to_utf8")){
173
  $hostname = idn_to_utf8($hostname);
inc/single-preload.php CHANGED
@@ -45,7 +45,7 @@
45
  </p>
46
 
47
  <p id="wpfc-single-preload-process" style="display: none;">
48
- <label>Status: <span id="wpfc-single-preload-status-runnig">Running...</span><span id="wpfc-single-preload-status-completed" style="display: none; color: #33CD32; font-weight: bold;">Completed</span></label><br>
49
  <label>Total: <span id="wpfc-single-preload-total-number"><?php echo count(self::$urls); ?></span></label><br>
50
  <label>Cached: <span id="wpfc-single-preload-cached-number">0</span></label><br>
51
  <label>Errors: <span id="wpfc-single-preload-error-number">0</span></label>
@@ -226,30 +226,82 @@
226
 
227
  WpfcSinglePreload.change_status();
228
  },
229
- create_cache: function(url, user_agent){
230
- var self = this;
231
- jQuery("#wpfc-single-preload").show();
232
-
233
- jQuery.ajax({
234
- type: 'GET',
235
- url: ajaxurl,
236
- data: {"action": "wpfc_preload_single", "url": url, "user_agent": user_agent},
237
- dataType: "html",
238
- timeout: 10000,
239
- cache: false,
240
- success: function(data){
241
- if(data == "true"){
242
- WpfcSinglePreload.increase_cached();
243
  }else{
244
- self.error_message = data;
245
- WpfcSinglePreload.increase_error();
246
  }
247
- },
248
- error: function(error){
249
- self.error_message = error.statusText;
250
- WpfcSinglePreload.increase_error();
251
  }
252
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  }
254
  };
255
 
@@ -261,16 +313,8 @@
261
 
262
  if(jQuery("#message").find("a").attr("href")){
263
  WpfcSinglePreload.init();
264
-
265
- <?php
266
- foreach (self::$urls as $key => $value) {
267
- ?>
268
- setTimeout(function(){
269
- WpfcSinglePreload.create_cache("<?php echo $value["url"]; ?>", "<?php echo $value["user-agent"]; ?>");
270
- }, <?php echo $key*500;?>);
271
- <?php
272
- }
273
- ?>
274
  }
275
  });
276
  </script>
45
  </p>
46
 
47
  <p id="wpfc-single-preload-process" style="display: none;">
48
+ <label>Status: <span id="wpfc-single-preload-status-runnig">Running</span><span id="wpfc-single-preload-status-completed" style="display: none; color: #33CD32; font-weight: bold;">Completed</span></label><br>
49
  <label>Total: <span id="wpfc-single-preload-total-number"><?php echo count(self::$urls); ?></span></label><br>
50
  <label>Cached: <span id="wpfc-single-preload-cached-number">0</span></label><br>
51
  <label>Errors: <span id="wpfc-single-preload-error-number">0</span></label>
226
 
227
  WpfcSinglePreload.change_status();
228
  },
229
+ running_animation: function(){
230
+ let label = jQuery("#wpfc-single-preload-status-runnig");
231
+ let text = label.text();
232
+ let dot = 0;
233
+
234
+ label.text(text + ".");
235
+
236
+ self.interval = setInterval(function(){
237
+ text = label.text();
238
+ dot = text.match(/\./g);
239
+
240
+ if(dot){
241
+ if(dot.length < 3){
242
+ label.text(text + ".");
243
  }else{
244
+ label.text(text.replace(/\.+$/, ""));
 
245
  }
246
+ }else{
247
+ label.text(text + ".");
 
 
248
  }
249
+ }, 300);
250
+ },
251
+ create_cache: function(list){
252
+ var action = function(url, user_agent, list){
253
+ var self = this;
254
+ jQuery("#wpfc-single-preload").show();
255
+
256
+ jQuery.ajax({
257
+ type: 'GET',
258
+ url: ajaxurl,
259
+ data: {"action": "wpfc_preload_single", "url": url, "user_agent": user_agent},
260
+ dataType: "html",
261
+ timeout: 10000,
262
+ cache: false,
263
+ success: function(data){
264
+ if(data == "true"){
265
+ WpfcSinglePreload.increase_cached();
266
+ }else{
267
+ self.error_message = data;
268
+ WpfcSinglePreload.increase_error();
269
+ }
270
+
271
+ if(typeof list == "object"){
272
+ WpfcSinglePreload.create_cache(list);
273
+ }
274
+ },
275
+ error: function(error){
276
+ self.error_message = error.statusText;
277
+ WpfcSinglePreload.increase_error();
278
+
279
+ if(typeof list == "object"){
280
+ WpfcSinglePreload.create_cache(list);
281
+ }
282
+ }
283
+ });
284
+
285
+ };
286
+
287
+ let number_to_used = 3;
288
+ let sliced = list.slice(0, number_to_used);
289
+
290
+ list.splice(0, number_to_used);
291
+
292
+ jQuery.each(sliced, function( index, value ) {
293
+ console.log( value["url"] );
294
+
295
+ if(index == (number_to_used-1)){
296
+ setTimeout(function(){
297
+ action(value["url"], value["user-agent"], list);
298
+ }, 500);
299
+ }else{
300
+ setTimeout(function(){
301
+ action(value["url"], value["user-agent"], false);
302
+ }, 500);
303
+ }
304
+ });
305
  }
306
  };
307
 
313
 
314
  if(jQuery("#message").find("a").attr("href")){
315
  WpfcSinglePreload.init();
316
+ WpfcSinglePreload.running_animation();
317
+ WpfcSinglePreload.create_cache(<?php echo json_encode(self::$urls); ?>);
 
 
 
 
 
 
 
 
318
  }
319
  });
320
  </script>
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.9
7
- Stable tag: 0.9.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -125,6 +125,10 @@ The free version is enough to speed up your site but in the premium version ther
125
 
126
  == Changelog ==
127
 
 
 
 
 
128
  = 0.9.8 =
129
  * to clear cache after updating Elementor Website Builder plugin
130
  * to clear cache after theme or plugin update by custom settings [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-after-theme-or-plugin-update/">Details</a>]
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.9
7
+ Stable tag: 0.9.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
125
 
126
  == Changelog ==
127
 
128
+ = 0.9.9 =
129
+ * to clear cache when regular price of woocommorce is updated
130
+ * refactoring of Automatic Cache
131
+
132
  = 0.9.8 =
133
  * to clear cache after updating Elementor Website Builder plugin
134
  * to clear cache after theme or plugin update by custom settings [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-after-theme-or-plugin-update/">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.8
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -86,6 +86,7 @@ GNU General Public License for more details.
86
  private $options = array();
87
  public $noscript = "";
88
  public $content_url = "";
 
89
 
90
  public function __construct(){
91
  $this->set_content_url();
@@ -247,6 +248,9 @@ GNU General Public License for more details.
247
  $this->options = $this->getOptions();
248
 
249
  add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3 );
 
 
 
250
 
251
  $this->commentHooks();
252
 
@@ -1065,7 +1069,15 @@ GNU General Public License for more details.
1065
  }
1066
  }
1067
 
 
 
 
 
 
 
1068
  public function on_all_status_transitions($new_status, $old_status, $post){
 
 
1069
  if(!wp_is_post_revision($post->ID)){
1070
  if(isset($post->post_type)){
1071
  if($post->post_type == "nf_sub"){
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.9
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
86
  private $options = array();
87
  public $noscript = "";
88
  public $content_url = "";
89
+ public $deleted_before = false;
90
 
91
  public function __construct(){
92
  $this->set_content_url();
248
  $this->options = $this->getOptions();
249
 
250
  add_action('transition_post_status', array($this, 'on_all_status_transitions'), 10, 3 );
251
+
252
+ // when the regular price is updated, the "transition_post_status" action cannot catch it
253
+ add_action('woocommerce_update_product', array($this, 'clear_cache_after_woocommerce_update_product'), 10, 1);
254
 
255
  $this->commentHooks();
256
 
1069
  }
1070
  }
1071
 
1072
+ public function clear_cache_after_woocommerce_update_product($product_id){
1073
+ if(!$this->deleted_before){
1074
+ $this->singleDeleteCache(false, $product_id);
1075
+ }
1076
+ }
1077
+
1078
  public function on_all_status_transitions($new_status, $old_status, $post){
1079
+ $this->deleted_before = true;
1080
+
1081
  if(!wp_is_post_revision($post->ID)){
1082
  if(isset($post->post_type)){
1083
  if($post->post_type == "nf_sub"){