WP Fastest Cache - Version 0.9.4

Version Description

  • to make compatible the Auto Cache feature with the Disable Gutenberg plugin
  • refactoring of rewrite rule of HTTP_USER_AGENT
  • to check that resources have been successfully optimized
Download this release

Release Info

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

Code changes from version 0.9.3 to 0.9.4

css/style.css CHANGED
@@ -229,11 +229,11 @@ form.delete-line{
229
  float: left;
230
  }
231
  form.delete-line .left{
232
- width: 25%;
233
  float: left;
234
  }
235
  form.delete-line .right{
236
- width: 75%;
237
  float: left;
238
  }
239
 
@@ -244,7 +244,7 @@ form.delete-line .left .submit{
244
  }
245
  form.delete-line .left .submit input{
246
  height: 65px;
247
- width: 165px;
248
  white-space: pre-line !important;
249
  }
250
  td div.revert:before{
229
  float: left;
230
  }
231
  form.delete-line .left{
232
+ width: 20%;
233
  float: left;
234
  }
235
  form.delete-line .right{
236
+ width: 80%;
237
  float: left;
238
  }
239
 
244
  }
245
  form.delete-line .left .submit input{
246
  height: 65px;
247
+ width: 130px;
248
  white-space: pre-line !important;
249
  }
250
  td div.revert:before{
inc/admin.php CHANGED
@@ -727,7 +727,7 @@
727
  }
728
 
729
  if(isset($_POST["wpFastestCacheMobile"]) && $_POST["wpFastestCacheMobile"] == "on"){
730
- $mobile = "RewriteCond %{HTTP_USER_AGENT} !^.*(".$this->getMobileUserAgents().").*$ [NC]"."\n";
731
 
732
  if(isset($_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'])){
733
  $mobile = $mobile."RewriteCond %{HTTP_CLOUDFRONT_IS_MOBILE_VIEWER} false [NC]"."\n";
@@ -1465,6 +1465,9 @@
1465
  <div class="exclude_section_clear" style=" margin-left: 3%; width: 95%; margin-bottom: 20px; margin-top: 0;"><div></div></div>
1466
 
1467
  <h2 id="delete-cache-h2" style="padding-left:20px;padding-bottom:10px;"><?php _e("Delete Cache", "wp-fastest-cache"); ?></h2>
 
 
 
1468
  <form method="post" name="wp_manager" class="delete-line" action="options.php">
1469
  <?php settings_fields( 'wpfc-group' ); ?>
1470
  <input type="hidden" value="deleteCache" name="wpFastestCachePage">
727
  }
728
 
729
  if(isset($_POST["wpFastestCacheMobile"]) && $_POST["wpFastestCacheMobile"] == "on"){
730
+ $mobile = "RewriteCond %{HTTP_USER_AGENT} !^.*".$this->getMobileUserAgents().".*$ [NC]"."\n";
731
 
732
  if(isset($_SERVER['HTTP_CLOUDFRONT_IS_MOBILE_VIEWER'])){
733
  $mobile = $mobile."RewriteCond %{HTTP_CLOUDFRONT_IS_MOBILE_VIEWER} false [NC]"."\n";
1465
  <div class="exclude_section_clear" style=" margin-left: 3%; width: 95%; margin-bottom: 20px; margin-top: 0;"><div></div></div>
1466
 
1467
  <h2 id="delete-cache-h2" style="padding-left:20px;padding-bottom:10px;"><?php _e("Delete Cache", "wp-fastest-cache"); ?></h2>
1468
+
1469
+ <?php //include_once(WPFC_MAIN_PATH."templates/cache_path.php"); ?>
1470
+
1471
  <form method="post" name="wp_manager" class="delete-line" action="options.php">
1472
  <?php settings_fields( 'wpfc-group' ); ?>
1473
  <input type="hidden" value="deleteCache" name="wpFastestCachePage">
inc/cache.php CHANGED
@@ -847,6 +847,14 @@
847
 
848
  $content = $this->fix_pre_tag($content, $buffer);
849
 
 
 
 
 
 
 
 
 
850
  if($this->cacheFilePath){
851
  if($this->is_html()){
852
  $this->createFolder($this->cacheFilePath, $content);
847
 
848
  $content = $this->fix_pre_tag($content, $buffer);
849
 
850
+ if(preg_match("/<link[^\>]+href\s*\=\s*[\'\"][^\"\']+\.\.[\"\'][^\>]+>/", $content)){
851
+ /*
852
+ to check that resources have been successfully optimized
853
+ <link rel='stylesheet' href='//site.com/wp-content/cache/wpfc-minified/895p0t5d/..' media='all' />
854
+ */
855
+ return $buffer."<!-- Cache has NOT been created due to optimized resource -->";
856
+ }
857
+
858
  if($this->cacheFilePath){
859
  if($this->is_html()){
860
  $this->createFolder($this->cacheFilePath, $content);
js/dialog_new.js CHANGED
@@ -5,11 +5,53 @@ var Wpfc_New_Dialog = {
5
  clone: "",
6
  current_page_number: 1,
7
  total_page_number: 0,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  dialog: function(id, buttons, callback){
9
  var self = this;
10
  self.clone = jQuery("div[template-id='" + id + "']").clone();
11
 
12
  self.total_page_number = self.clone.find("div[wpfc-page]").length;
 
 
13
 
14
  self.template_id = id;
15
  self.id = id + "-" + new Date().getTime();
@@ -107,8 +149,8 @@ var Wpfc_New_Dialog = {
107
  this.clone.find("button[action='" + index + "']").hide();
108
  },
109
  show_page: function(number){
110
- this.clone.find("div[wpfc-page]").hide();
111
- this.clone.find("div[wpfc-page='" + number + "']").show();
112
  this.current_page_number = number;
113
  },
114
  update_ids_for_label: function(){
5
  clone: "",
6
  current_page_number: 1,
7
  total_page_number: 0,
8
+ interval : false,
9
+ enable_button: function(button_type){
10
+ clearInterval(this.interval);
11
+
12
+ let self = this;
13
+ let modal = jQuery("#" + self.id);
14
+ let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
15
+
16
+ button.attr("disabled", false);
17
+ button.text(button.text().replace(/\.+$/, ""));
18
+ },
19
+ disable_button: function(button_type){
20
+ let self = this;
21
+ let modal = jQuery("#" + self.id);
22
+ let button = modal.find(".wpfc-dialog-buttons[action='" + button_type + "']");
23
+ let text = button.text();
24
+ let dot = 0;
25
+
26
+ button.attr("disabled", true);
27
+
28
+ button.text(text + ".");
29
+
30
+ self.interval = setInterval(function(){
31
+ text = button.text();
32
+ dot = text.match(/\./g);
33
+
34
+ console.log(dot);
35
+ console.log(button);
36
+
37
+ if(dot){
38
+ if(dot.length < 3){
39
+ button.text(text + ".");
40
+ }else{
41
+ button.text(text.replace(/\.+$/, ""));
42
+ }
43
+ }else{
44
+ button.text(text + ".");
45
+ }
46
+ }, 300);
47
+ },
48
  dialog: function(id, buttons, callback){
49
  var self = this;
50
  self.clone = jQuery("div[template-id='" + id + "']").clone();
51
 
52
  self.total_page_number = self.clone.find("div[wpfc-page]").length;
53
+ self.total_page_number = self.total_page_number > 0 ? self.total_page_number : self.clone.find("div[wpfc-cdn-page]").length;
54
+
55
 
56
  self.template_id = id;
57
  self.id = id + "-" + new Date().getTime();
149
  this.clone.find("button[action='" + index + "']").hide();
150
  },
151
  show_page: function(number){
152
+ this.clone.find("div[wpfc-page], div[wpfc-cdn-page]").hide();
153
+ this.clone.find("div[wpfc-page='" + number + "'], div[wpfc-cdn-page='" + number + "']").show();
154
  this.current_page_number = number;
155
  },
156
  update_ids_for_label: function(){
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.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -125,6 +125,11 @@ The free version is enough to speed up your site but in the premium version ther
125
 
126
  == Changelog ==
127
 
 
 
 
 
 
128
  = 0.9.3 =
129
  * to prevent removing "/" for exclude rules
130
  * <strong>[FEATURE]</strong> to add "pause" feature for cdn [<a target="_blank" href="https://www.wpfastestcache.com/features/temporarily-disable-cdn/">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.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
 
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
131
+ * to check that resources have been successfully optimized
132
+
133
  = 0.9.3 =
134
  * to prevent removing "/" for exclude rules
135
  * <strong>[FEATURE]</strong> to add "pause" feature for cdn [<a target="_blank" href="https://www.wpfastestcache.com/features/temporarily-disable-cdn/">Details</a>]
templates/cache_path.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div template-id="wpfc-modal-cachepath" style="display:none;top: 10.5px; left: 226px; position: absolute; padding: 6px; height: auto; width: 560px; z-index: 9995;">
2
+ <div style="height: 100%; width: 100%; background: none repeat scroll 0% 0% rgb(0, 0, 0); position: absolute; top: 0px; left: 0px; z-index: -1; opacity: 0.5; border-radius: 8px;">
3
+ </div>
4
+ <div style="z-index: 600; border-radius: 3px;">
5
+ <div style="font-family:Verdana,Geneva,Arial,Helvetica,sans-serif;font-size:12px;background: none repeat scroll 0px 0px rgb(255, 161, 0); z-index: 1000; position: relative; padding: 2px; border-bottom: 1px solid rgb(194, 122, 0); height: 35px; border-radius: 3px 3px 0px 0px;">
6
+ <table width="100%" height="100%">
7
+ <tbody>
8
+ <tr>
9
+ <td valign="middle" style="vertical-align: middle; font-weight: bold; color: rgb(255, 255, 255); text-shadow: 0px 1px 1px rgba(0, 0, 0, 0.5); padding-left: 10px; font-size: 13px; cursor: move;">Cache Path Customization</td>
10
+ <td width="20" align="center" style="vertical-align: middle;"></td>
11
+ <td width="20" align="center" style="vertical-align: middle; font-family: Arial,Helvetica,sans-serif; color: rgb(170, 170, 170); cursor: default;">
12
+ <div title="Close Window" class="close-wiz"></div>
13
+ </td>
14
+ </tr>
15
+ </tbody>
16
+ </table>
17
+ </div>
18
+ <div class="window-content-wrapper" style="padding: 15px;">
19
+ <div class="window-content" style="z-index: 1000; height: auto; position: relative; display: inline-block; width: 100%;">
20
+ <div class="wpfc-cdn-pages-container">
21
+ <?php
22
+ $wpfc_cache_path = get_option("WpFastestCachePathSettings");
23
+
24
+ if(!is_array($wpfc_cache_path)){
25
+ $wpfc_cache_path = array(
26
+ "cachepath" => "cache",
27
+ "optimizedpath" => "wpfc-minified"
28
+ );
29
+ }
30
+ ?>
31
+ <div wpfc-cdn-page="1" class="wiz-cont">
32
+ <h1>Cache Folder</h1>
33
+ <p>Hi!, You can specify a custom location for the <strong>cache path</strong> via this part. Please choose a folder and continue...</p>
34
+ <div class="wiz-input-cont" style="text-align:center;">
35
+ <label class="mc-input-label" style="margin-right: 5px;">
36
+ <select disabled style="width:30%;" name="wpcontentpath">
37
+ <option value="wp-content">wp-content</option>
38
+ </select>
39
+ <select style="width:65%;" name="cachepath">
40
+ <?php
41
+ echo '<option value="cache">cache</option>';
42
+
43
+ foreach(glob($this->getWpContentDir()."/*", GLOB_ONLYDIR) as $f_key => $f_value){
44
+ if(basename($f_value) == "cache"){
45
+ continue;
46
+ }
47
+
48
+ if($wpfc_cache_path["cachepath"] == basename($f_value)){
49
+ echo '<option selected="" value="'.basename($f_value).'">'.basename($f_value).'</option>';
50
+ }else{
51
+ echo '<option value="'.basename($f_value).'">'.basename($f_value).'</option>';
52
+ }
53
+
54
+ }
55
+
56
+ ?>
57
+ </select>
58
+ </label>
59
+ </div>
60
+ <p class="wpfc-bottom-note" style="margin-bottom:-10px;"><a target="_blank" href="https://www.maxcdn.com/one/tutorial/implementing-cdn-on-wordpress-with-wp-fastest-cache/">Note: Please read How to Integrate StackPath into WP Fastest Cache</a></p>
61
+ </div>
62
+
63
+ <div wpfc-cdn-page="2" class="wiz-cont" style="display:none">
64
+ <h1>Optimized Sources Folder</h1>
65
+ <p>You can specify a custom location path for the <strong>optimized JS/CSS sources</strong> via this part.</p>
66
+ <div class="wiz-input-cont" style="text-align:center;">
67
+ <label class="mc-input-label" style="margin-right: 5px;">
68
+ <select disabled name="disabled-cachepath" style="width:65%;"></select>
69
+ <input type="text" name="optimizedpath" style="width: 30%;" value="<?php echo $wpfc_cache_path["optimizedpath"]; ?>">
70
+ </label>
71
+ </div>
72
+ <p class="wpfc-bottom-note" style="margin-bottom:-10px;"><a target="_blank" href="https://www.maxcdn.com/one/tutorial/implementing-cdn-on-wordpress-with-wp-fastest-cache/">Note: Please read How to Integrate StackPath into WP Fastest Cache</a></p>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ </div>
77
+ <?php include WPFC_MAIN_PATH."templates/buttons.html"; ?>
78
+ </div>
79
+ </div>
80
+
81
+ <script type="text/javascript">
82
+ var WPFC_CACHE_PATH = {
83
+ ajax_url: false,
84
+ init: function(){
85
+ jQuery("form.delete-line div.questionCon.right").click(function(){
86
+ Wpfc_New_Dialog.dialog("wpfc-modal-cachepath", {
87
+ close: function(){
88
+
89
+ },
90
+ next: "default",
91
+ back: "default",
92
+ finish: function(){
93
+ let wpfc_dialog = jQuery("#" + Wpfc_New_Dialog.id);
94
+ let cachepath = wpfc_dialog.find("select[name='cachepath']").val();
95
+ let optimizedpath = wpfc_dialog.find("input[name='optimizedpath']").val();
96
+
97
+ Wpfc_New_Dialog.disable_button("finish");
98
+
99
+ jQuery.ajax({
100
+ type: 'POST',
101
+ url: ajaxurl,
102
+ data: {"action" : "wpfc_cache_path_save_settings", "cachepath" : cachepath, "optimizedpath" : optimizedpath},
103
+ dataType: "json",
104
+ cache: false,
105
+ success: function(data){
106
+ jQuery("div[template-id='wpfc-modal-cachepath']").find("select[name='cachepath'] option[value='" + cachepath + "']").attr("selected", true);
107
+ jQuery("div[template-id='wpfc-modal-cachepath']").find("input[name='optimizedpath']").val(optimizedpath);
108
+
109
+ Wpfc_New_Dialog.enable_button("finish");
110
+ Wpfc_New_Dialog.clone.remove();
111
+ },
112
+ error: function(error){
113
+ alert("unknown error");
114
+ }
115
+ });
116
+
117
+ console.log(cachepath, optimizedpath, wpcontent);
118
+
119
+ }
120
+ }, function(dialog){
121
+ var wpfc_dialog = jQuery("#" + Wpfc_New_Dialog.id);
122
+ var wpcontent = wpfc_dialog.find("select[name='wpcontentpath']").val();
123
+
124
+ wpfc_dialog.find("select[name='disabled-cachepath']").append("<option>" + (wpfc_dialog.find("select[name='cachepath']").val() == "cache" ? wpcontent + "/cache" : wpcontent + "/" + wpfc_dialog.find("select[name='cachepath']").val() + "/cache") + "</option>");
125
+
126
+ wpfc_dialog.find("select[name='cachepath']").change(function(e){
127
+ wpfc_dialog.find("select[name='disabled-cachepath']").find("option").remove();
128
+ wpfc_dialog.find("select[name='disabled-cachepath']").append("<option>" + (this.value == "cache" ? wpcontent + "/cache" : wpcontent + "/" + this.value + "/cache") + "</option>");
129
+ });
130
+
131
+ wpfc_dialog.find("input[name='optimizedpath']").keypress(function(event){
132
+ var keyChar = String.fromCharCode(event.which || event.keyCode);
133
+
134
+ if(!keyChar.match(/[A-Za-z0-9]/)){
135
+ return false;
136
+ }
137
+ });
138
+
139
+ Wpfc_New_Dialog.show_page(1);
140
+ Wpfc_New_Dialog.show_button("next");
141
+ });
142
+ });
143
+ }
144
+ };
145
+
146
+ window.addEventListener('load', function(){
147
+ jQuery(document).ready(function(){
148
+ WPFC_CACHE_PATH.init();
149
+ });
150
+ });
151
+ </script>
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.3
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -105,6 +105,7 @@ GNU General Public License for more details.
105
  add_action('wp_ajax_wpfc_toolbar_save_settings', array($this, "wpfc_toolbar_save_settings_callback"));
106
  add_action('wp_ajax_wpfc_toolbar_get_settings', array($this, "wpfc_toolbar_get_settings_callback"));
107
 
 
108
 
109
  add_action( 'wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
110
  add_action( 'wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
@@ -161,7 +162,7 @@ GNU General Public License for more details.
161
 
162
 
163
 
164
- if($this->isPluginActive('classic-editor/classic-editor.php')){
165
  // to create cache for single content
166
  add_action("add_meta_boxes", array($this, "add_meta_box"), 10, 2);
167
  add_action('admin_notices', array($this, 'single_preload_inline_js'));
@@ -802,6 +803,29 @@ GNU General Public License for more details.
802
  }
803
  }
804
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
805
  public function wpfc_toolbar_save_settings_callback(){
806
  if(current_user_can('manage_options')){
807
  if(is_array($_GET["roles"]) && !empty($_GET["roles"])){
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
105
  add_action('wp_ajax_wpfc_toolbar_save_settings', array($this, "wpfc_toolbar_save_settings_callback"));
106
  add_action('wp_ajax_wpfc_toolbar_get_settings', array($this, "wpfc_toolbar_get_settings_callback"));
107
 
108
+ //add_action('wp_ajax_wpfc_cache_path_save_settings', array($this, "wpfc_cache_path_save_settings_callback"));
109
 
110
  add_action( 'wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
111
  add_action( 'wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
162
 
163
 
164
 
165
+ if($this->isPluginActive('classic-editor/classic-editor.php') || $this->isPluginActive('disable-gutenberg/disable-gutenberg.php')){
166
  // to create cache for single content
167
  add_action("add_meta_boxes", array($this, "add_meta_box"), 10, 2);
168
  add_action('admin_notices', array($this, 'single_preload_inline_js'));
803
  }
804
  }
805
 
806
+ public function wpfc_cache_path_save_settings_callback(){
807
+ if(current_user_can('manage_options')){
808
+ foreach($_POST as $key => &$value){
809
+ $value = esc_html(esc_sql($value));
810
+ }
811
+
812
+ $path_arr = array(
813
+ "cachepath" => $_POST["cachepath"],
814
+ "optimizedpath" => $_POST["optimizedpath"]
815
+ );
816
+
817
+ if(get_option("WpFastestCachePathSettings") === false){
818
+ add_option("WpFastestCachePathSettings", $path_arr, 1, "no");
819
+ }else{
820
+ update_option("WpFastestCachePathSettings", $path_arr);
821
+ }
822
+
823
+ die(json_encode(array("success" => true)));
824
+ }else{
825
+ wp_die("Must be admin");
826
+ }
827
+ }
828
+
829
  public function wpfc_toolbar_save_settings_callback(){
830
  if(current_user_can('manage_options')){
831
  if(is_array($_GET["roles"]) && !empty($_GET["roles"])){