WP Fastest Cache - Version 0.9.5

Version Description

  • to prevent generating cache when DONOTCACHEPAGE is defined as true for Divi theme
  • to add nonce security system for cdn saving
Download this release

Release Info

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

Code changes from version 0.9.4 to 0.9.5

inc/admin.php CHANGED
@@ -921,8 +921,8 @@
921
 
922
  $htaccess = preg_replace("/\n+/","\n", $htaccess);
923
 
924
- echo "<noscript id='wpfc-htaccess-data'>".$htaccess."</noscript>";
925
- echo "<noscript id='wpfc-htaccess-path-data'>".$path.".htaccess"."</noscript>";
926
  ?>
927
  <script type="text/javascript">
928
  jQuery(document).ready(function(){
@@ -1031,8 +1031,8 @@
1031
  }else if((isset($_POST["wpFastestCachePage"])) && ("wpfc-".$_POST["wpFastestCachePage"] == $value["id"])){
1032
  $checked = ' checked="checked" ';
1033
  }
1034
- echo '<input '.$checked.' type="radio" id="'.$value["id"].'" name="tabGroup1" style="display:none;">'."\n";
1035
- echo '<label for="'.$value["id"].'">'.$value["title"].'</label>'."\n";
1036
  }
1037
  ?>
1038
  <br>
@@ -2011,7 +2011,8 @@
2011
 
2012
  WpfcCDN.init({"id" : jQuery(e.currentTarget).attr("wpfc-cdn-name"),
2013
  "template_main_url" : "<?php echo plugins_url('wp-fastest-cache/templates/cdn'); ?>",
2014
- "values" : data
 
2015
  });
2016
 
2017
 
921
 
922
  $htaccess = preg_replace("/\n+/","\n", $htaccess);
923
 
924
+ echo "<noscript id='wpfc-htaccess-data'>".esc_html($htaccess)."</noscript>";
925
+ echo "<noscript id='wpfc-htaccess-path-data'>".esc_html($path).".htaccess"."</noscript>";
926
  ?>
927
  <script type="text/javascript">
928
  jQuery(document).ready(function(){
1031
  }else if((isset($_POST["wpFastestCachePage"])) && ("wpfc-".$_POST["wpFastestCachePage"] == $value["id"])){
1032
  $checked = ' checked="checked" ';
1033
  }
1034
+ echo '<input '.esc_html($checked).' type="radio" id="'.esc_html($value["id"]).'" name="tabGroup1" style="display:none;">'."\n";
1035
+ echo '<label for="'.esc_html($value["id"]).'">'.esc_html($value["title"]).'</label>'."\n";
1036
  }
1037
  ?>
1038
  <br>
2011
 
2012
  WpfcCDN.init({"id" : jQuery(e.currentTarget).attr("wpfc-cdn-name"),
2013
  "template_main_url" : "<?php echo plugins_url('wp-fastest-cache/templates/cdn'); ?>",
2014
+ "values" : data,
2015
+ "nonce" : "<?php echo wp_create_nonce("cdn-nonce"); ?>"
2016
  });
2017
 
2018
 
inc/cache.php CHANGED
@@ -687,6 +687,12 @@
687
  }
688
  }
689
 
 
 
 
 
 
 
690
  if($this->exclude_page($buffer)){
691
  $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
692
  return $buffer;
687
  }
688
  }
689
 
690
+ // for Divi Theme
691
+ if(defined('DONOTCACHEPAGE') && (get_template() == "Divi")){
692
+ return $buffer."<!-- DONOTCACHEPAGE is defined as TRUE -->";
693
+ }
694
+
695
+
696
  if($this->exclude_page($buffer)){
697
  $buffer = preg_replace('/<\!--WPFC_PAGE_TYPE_[a-z]+-->/i', '', $buffer);
698
  return $buffer;
inc/cdn.php CHANGED
@@ -281,8 +281,8 @@
281
  //admin OR author OR editor
282
  if(current_user_can('manage_options') || current_user_can('delete_published_posts') || current_user_can('edit_published_posts')){
283
  if(isset($_GET["url"]) && isset($_GET["origin_url"])){
284
- $email = $_GET["url"];
285
- $key = $_GET["origin_url"];
286
  }
287
 
288
  $zone = CdnWPFC::cloudflare_get_zone_id($email, $key);
@@ -559,12 +559,15 @@
559
  }
560
 
561
  public static function save_cdn_integration(){
562
- if(current_user_can('manage_options')){
563
- if(isset($_POST) && isset($_POST["values"])){
564
- foreach ($_POST["values"] as $val_key => &$val_value) {
565
- $val_value = sanitize_text_field($val_value);
 
 
566
  }
567
  }
 
568
 
569
  if($data = get_option("WpFastestCacheCDN")){
570
  $cdn_exist = false;
@@ -572,32 +575,32 @@
572
 
573
  if(is_array($arr)){
574
  foreach ($arr as $cdn_key => &$cdn_value) {
575
- if($cdn_value->id == $_POST["values"]["id"]){
576
- $cdn_value = $_POST["values"];
577
  $cdn_exist = true;
578
  }
579
  }
580
 
581
  if(!$cdn_exist){
582
- array_push($arr, $_POST["values"]);
583
  }
584
 
585
  update_option("WpFastestCacheCDN", json_encode($arr));
586
  }else{
587
  $tmp_arr = array();
588
 
589
- if($arr->id == $_POST["values"]["id"]){
590
- array_push($tmp_arr, $_POST["values"]);
591
  }else{
592
  array_push($tmp_arr, $arr);
593
- array_push($tmp_arr, $_POST["values"]);
594
  }
595
 
596
  update_option("WpFastestCacheCDN", json_encode($tmp_arr));
597
  }
598
  }else{
599
  $arr = array();
600
- array_push($arr, $_POST["values"]);
601
 
602
  add_option("WpFastestCacheCDN", json_encode($arr), null, "yes");
603
  }
281
  //admin OR author OR editor
282
  if(current_user_can('manage_options') || current_user_can('delete_published_posts') || current_user_can('edit_published_posts')){
283
  if(isset($_GET["url"]) && isset($_GET["origin_url"])){
284
+ $email = sanitize_text_field($_GET["url"]);
285
+ $key = sanitize_text_field($_GET["origin_url"]);
286
  }
287
 
288
  $zone = CdnWPFC::cloudflare_get_zone_id($email, $key);
559
  }
560
 
561
  public static function save_cdn_integration(){
562
+ if(current_user_can('manage_options') && wp_verify_nonce($_POST["nonce"], "cdn-nonce")){
563
+ $values = array();
564
+
565
+ if(isset($_POST) && isset($values)){
566
+ foreach ($_POST["values"] as $val_key => $val_value) {
567
+ $values[$val_key] = sanitize_text_field($val_value);
568
  }
569
  }
570
+
571
 
572
  if($data = get_option("WpFastestCacheCDN")){
573
  $cdn_exist = false;
575
 
576
  if(is_array($arr)){
577
  foreach ($arr as $cdn_key => &$cdn_value) {
578
+ if($cdn_value->id == $values["id"]){
579
+ $cdn_value = $values;
580
  $cdn_exist = true;
581
  }
582
  }
583
 
584
  if(!$cdn_exist){
585
+ array_push($arr, $values);
586
  }
587
 
588
  update_option("WpFastestCacheCDN", json_encode($arr));
589
  }else{
590
  $tmp_arr = array();
591
 
592
+ if($arr->id == $values["id"]){
593
+ array_push($tmp_arr, $values);
594
  }else{
595
  array_push($tmp_arr, $arr);
596
+ array_push($tmp_arr, $values);
597
  }
598
 
599
  update_option("WpFastestCacheCDN", json_encode($tmp_arr));
600
  }
601
  }else{
602
  $arr = array();
603
+ array_push($arr, $values);
604
 
605
  add_option("WpFastestCacheCDN", json_encode($arr), null, "yes");
606
  }
inc/preload.php CHANGED
@@ -143,7 +143,7 @@
143
 
144
  foreach ($total as $key => $value) {
145
  $pre_load->$key = $pre_load->$key == -1 ? $value : $pre_load->$key;
146
- echo $key.": ".$pre_load->$key."/".$value."<br>";
147
  }
148
  }
149
 
@@ -487,7 +487,7 @@
487
 
488
 
489
 
490
- echo $status." ".$arr["url"]." (".$arr["user-agent"].")<br>";
491
  }
492
  echo "<br>";
493
  echo count($urls)." page have been cached";
143
 
144
  foreach ($total as $key => $value) {
145
  $pre_load->$key = $pre_load->$key == -1 ? $value : $pre_load->$key;
146
+ echo esc_html($key).": ".esc_html($pre_load->$key)."/".esc_html($value)."<br>";
147
  }
148
  }
149
 
487
 
488
 
489
 
490
+ echo $status." ".esc_html($arr["url"])." (".esc_html($arr["user-agent"]).")<br>";
491
  }
492
  echo "<br>";
493
  echo count($urls)." page have been cached";
inc/single-preload.php CHANGED
@@ -101,9 +101,9 @@
101
  $res = array("success" => true);
102
 
103
  if(get_option("WpFastestCache_autocache")){
104
- update_option("WpFastestCache_autocache", $_POST["is_enable"]);
105
  }else{
106
- add_option("WpFastestCache_autocache", $_POST["is_enable"], null, "yes");
107
  }
108
 
109
  wp_send_json($res);
@@ -114,7 +114,8 @@
114
 
115
  public static function set_id(){
116
  if(isset($_GET["post"]) && $_GET["post"]){
117
- static::$id = esc_sql($_GET["post"]);
 
118
 
119
  if(get_post_status(static::$id) != "publish"){
120
  static::$id = 0;
101
  $res = array("success" => true);
102
 
103
  if(get_option("WpFastestCache_autocache")){
104
+ update_option("WpFastestCache_autocache", sanitize_text_field($_POST["is_enable"]));
105
  }else{
106
+ add_option("WpFastestCache_autocache", sanitize_text_field($_POST["is_enable"]), null, "yes");
107
  }
108
 
109
  wp_send_json($res);
114
 
115
  public static function set_id(){
116
  if(isset($_GET["post"]) && $_GET["post"]){
117
+
118
+ static::$id = (int) $_GET["post"];
119
 
120
  if(get_post_status(static::$id) != "publish"){
121
  static::$id = 0;
js/cdn/cdn.js CHANGED
@@ -1,6 +1,7 @@
1
  var WpfcCDN = {
2
  values: {"name" : "", "cdnurl" : "", "originurl" : "", "file_types" : "", "keywords" : "", "excludekeywords" : ""},
3
  id : "",
 
4
  template_url : "",
5
  content : "",
6
  interval : false,
@@ -21,7 +22,9 @@ var WpfcCDN = {
21
  },
22
  set_params: function(obj){
23
  this.id = obj.id;
 
24
  this.template_url = obj.template_main_url + "/" + this.id + ".php";
 
25
  if(obj.values){
26
  this.values = obj.values;
27
  }
@@ -249,7 +252,7 @@ var WpfcCDN = {
249
  type: 'POST',
250
  dataType: "json",
251
  url: ajaxurl,
252
- data : {"action": "wpfc_save_cdn_integration", "values" : self.values, "file_types" : self.values.file_types, "keywords" : self.values.keywords, "excludekeywords" : self.values.excludekeywords},
253
  success: function(res){
254
  jQuery("div[wpfc-cdn-name='" + self.id + "']").find("div.meta").addClass("isConnected");
255
 
1
  var WpfcCDN = {
2
  values: {"name" : "", "cdnurl" : "", "originurl" : "", "file_types" : "", "keywords" : "", "excludekeywords" : ""},
3
  id : "",
4
+ nonce: "",
5
  template_url : "",
6
  content : "",
7
  interval : false,
22
  },
23
  set_params: function(obj){
24
  this.id = obj.id;
25
+ this.nonce = obj.nonce;
26
  this.template_url = obj.template_main_url + "/" + this.id + ".php";
27
+
28
  if(obj.values){
29
  this.values = obj.values;
30
  }
252
  type: 'POST',
253
  dataType: "json",
254
  url: ajaxurl,
255
+ data : {"action": "wpfc_save_cdn_integration", "nonce" : self.nonce, "values" : self.values, "file_types" : self.values.file_types, "keywords" : self.values.keywords, "excludekeywords" : self.values.excludekeywords},
256
  success: function(res){
257
  jQuery("div[wpfc-cdn-name='" + self.id + "']").find("div.meta").addClass("isConnected");
258
 
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.8
7
- Stable tag: 0.9.4
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.4 =
129
  * to make compatible the Auto Cache feature with the Disable Gutenberg plugin
130
  * refactoring of rewrite rule of HTTP_USER_AGENT
4
  Tags: cache, caching, performance, wp-cache, total cache, super cache, cdn
5
  Requires at least: 3.3
6
  Tested up to: 5.8
7
+ Stable tag: 0.9.5
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.5 =
129
+ * to prevent generating cache when DONOTCACHEPAGE is defined as true for Divi theme
130
+ * to add nonce security system for cdn saving
131
+
132
  = 0.9.4 =
133
  * to make compatible the Auto Cache feature with the Disable Gutenberg plugin
134
  * refactoring of rewrite rule of HTTP_USER_AGENT
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.4
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -810,8 +810,8 @@ GNU General Public License for more details.
810
  }
811
 
812
  $path_arr = array(
813
- "cachepath" => $_POST["cachepath"],
814
- "optimizedpath" => $_POST["optimizedpath"]
815
  );
816
 
817
  if(get_option("WpFastestCachePathSettings") === false){
@@ -1152,7 +1152,7 @@ GNU General Public License for more details.
1152
  // Yet Another Stars Rating
1153
  if($_POST["action"] == "yasr_send_visitor_rating"){
1154
  $to_clear_parents = false;
1155
- $post_id = $_POST["post_id"];
1156
  }
1157
 
1158
  // All In One Schema.org Rich Snippets
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.5
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
810
  }
811
 
812
  $path_arr = array(
813
+ "cachepath" => sanitize_text_field($_POST["cachepath"]),
814
+ "optimizedpath" => sanitize_text_field($_POST["optimizedpath"])
815
  );
816
 
817
  if(get_option("WpFastestCachePathSettings") === false){
1152
  // Yet Another Stars Rating
1153
  if($_POST["action"] == "yasr_send_visitor_rating"){
1154
  $to_clear_parents = false;
1155
+ $post_id = sanitize_text_field($_POST["post_id"]);
1156
  }
1157
 
1158
  // All In One Schema.org Rich Snippets