WP Fastest Cache - Version 0.9.0.3

Version Description

  • [FEATURE] Compatible with Multiple Domain Mapping on single site
  • [BETA FEATURE] to create cache after publishing new post or updating a post [Details]
  • to fix clearing search (/?s=) result cache
  • to add settings link on the plugin list
  • [FEATURE] Compatible with Polylang with one different subdomain or domain per language
  • to exclude url which ends with slash if the permalink does not end with slush
  • to exclude images for cdn if the url contains brizy_media=
Download this release

Release Info

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

Code changes from version 0.9.0.2 to 0.9.0.3

inc/admin-toolbar.php CHANGED
@@ -27,7 +27,10 @@
27
 
28
  public function print_my_inline_script() {
29
  ?>
30
- <script type="text/javascript">var wpfc_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";</script>
 
 
 
31
  <?php
32
  }
33
 
27
 
28
  public function print_my_inline_script() {
29
  ?>
30
+ <script type="text/javascript">
31
+ var wpfc_ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
32
+ var wpfc_nonce = "<?php echo wp_create_nonce("wpfc"); ?>";
33
+ </script>
34
  <?php
35
  }
36
 
inc/admin.php CHANGED
@@ -727,7 +727,7 @@
727
  if($this->is_trailing_slash()){
728
  $trailing_slash_rule = "RewriteCond %{REQUEST_URI} \/$"."\n";
729
  }else{
730
- //toDo
731
  }
732
 
733
  $data = "# BEGIN WpFastestCache"."\n".
@@ -933,8 +933,10 @@
933
  }else{
934
  $translation_file_name = $this->options->wpFastestCacheLanguage;
935
 
936
- if($translation_file_name == "es"){
937
- $translation_file_name = "es_ES";
 
 
938
  }
939
 
940
  if(file_exists(WPFC_MAIN_PATH. "languages/wp-fastest-cache-".$translation_file_name.".po")){
@@ -1366,7 +1368,7 @@
1366
  <div class="inputCon">
1367
  <input type="hidden" value="<?php echo $wpFastestCacheLazyLoad_placeholder; ?>" id="wpFastestCacheLazyLoad_placeholder" name="wpFastestCacheLazyLoad_placeholder">
1368
  <input type="hidden" value="<?php echo $wpFastestCacheLazyLoad_keywords; ?>" id="wpFastestCacheLazyLoad_keywords" name="wpFastestCacheLazyLoad_keywords">
1369
- <input type="hidden" value="<?php echo $wpFastestCacheLazyLoad_exclude_full_size_img; ?>" id="wpFastestCacheLazyLoad_exclude_full_size_img" name="wpFastestCacheLazyLoad_exclude_full_size_img">
1370
 
1371
  <input type="checkbox" <?php echo $wpFastestCacheLazyLoad; ?> id="wpFastestCacheLazyLoad" name="wpFastestCacheLazyLoad"><label for="wpFastestCacheLazyLoad"><?php _e("Load images and iframes when they enter the browsers viewport", "wp-fastest-cache"); ?></label>
1372
  </div>
@@ -1719,9 +1721,13 @@
1719
  </div>
1720
  <div class="wpfc-premium-step-footer">
1721
  <?php
1722
- if(in_array(get_bloginfo('language'), array("tr-TR", "tr"))){
1723
- $premium_price = "150TL";
1724
  $premium_buy_link = "https://www.wpfastestcache.com/#buy";
 
 
 
 
 
1725
  }else{
1726
  $premium_price = "$49.99";
1727
  $premium_buy_link = "https://api.wpfastestcache.net/paypal/buypremium/";
727
  if($this->is_trailing_slash()){
728
  $trailing_slash_rule = "RewriteCond %{REQUEST_URI} \/$"."\n";
729
  }else{
730
+ $trailing_slash_rule = "RewriteCond %{REQUEST_URI} ![^\/]+\/$"."\n";
731
  }
732
 
733
  $data = "# BEGIN WpFastestCache"."\n".
933
  }else{
934
  $translation_file_name = $this->options->wpFastestCacheLanguage;
935
 
936
+ if(preg_match("/^(de|es|fr|it|tr)$/", $translation_file_name)){
937
+ $translation_file_name = $translation_file_name."_".strtoupper($translation_file_name);
938
+ }else if($translation_file_name == "sv"){
939
+ $translation_file_name = "sv_SE";
940
  }
941
 
942
  if(file_exists(WPFC_MAIN_PATH. "languages/wp-fastest-cache-".$translation_file_name.".po")){
1368
  <div class="inputCon">
1369
  <input type="hidden" value="<?php echo $wpFastestCacheLazyLoad_placeholder; ?>" id="wpFastestCacheLazyLoad_placeholder" name="wpFastestCacheLazyLoad_placeholder">
1370
  <input type="hidden" value="<?php echo $wpFastestCacheLazyLoad_keywords; ?>" id="wpFastestCacheLazyLoad_keywords" name="wpFastestCacheLazyLoad_keywords">
1371
+ <input style="display: none;" type="checkbox" <?php echo $wpFastestCacheLazyLoad_exclude_full_size_img; ?> id="wpFastestCacheLazyLoad_exclude_full_size_img" name="wpFastestCacheLazyLoad_exclude_full_size_img">
1372
 
1373
  <input type="checkbox" <?php echo $wpFastestCacheLazyLoad; ?> id="wpFastestCacheLazyLoad" name="wpFastestCacheLazyLoad"><label for="wpFastestCacheLazyLoad"><?php _e("Load images and iframes when they enter the browsers viewport", "wp-fastest-cache"); ?></label>
1374
  </div>
1721
  </div>
1722
  <div class="wpfc-premium-step-footer">
1723
  <?php
1724
+ if(in_array(get_bloginfo('language'), array("tr-TR", "tr", "it-IT", "nl", "fr-FR", "ja", "de-AT", "en-CA", "en-GB"))){
 
1725
  $premium_buy_link = "https://www.wpfastestcache.com/#buy";
1726
+ $premium_price = "$49.99";
1727
+
1728
+ if(in_array(get_bloginfo('language'), array("tr-TR", "tr"))){
1729
+ $premium_price = "150TL";
1730
+ }
1731
  }else{
1732
  $premium_price = "$49.99";
1733
  $premium_buy_link = "https://api.wpfastestcache.net/paypal/buypremium/";
inc/cache.php CHANGED
@@ -79,30 +79,32 @@
79
  }
80
 
81
  public function set_cache_file_path(){
 
82
 
83
  if($this->isMobile() && isset($this->options->wpFastestCacheMobile)){
84
  if(class_exists("WpFcMobileCache") && isset($this->options->wpFastestCacheMobileTheme)){
85
- $wpfc_mobile = new WpFcMobileCache();
86
- $this->cacheFilePath = $this->getWpContentDir("/cache/wpfc-mobile-cache").$_SERVER["REQUEST_URI"];
87
- }
88
- }else{
89
- if($this->isPluginActive('gtranslate/gtranslate.php')){
90
- if(isset($_SERVER["HTTP_X_GT_LANG"])){
91
- $this->cacheFilePath = $this->getWpContentDir("/cache/all/").$_SERVER["HTTP_X_GT_LANG"].$_SERVER["REQUEST_URI"];
92
- }else if(isset($_SERVER["REDIRECT_URL"]) && $_SERVER["REDIRECT_URL"] != "/index.php"){
93
- $this->cacheFilePath = $this->getWpContentDir("/cache/all/").$_SERVER["REDIRECT_URL"];
94
- }else if(isset($_SERVER["REQUEST_URI"])){
95
- $this->cacheFilePath = $this->getWpContentDir("/cache/all/").$_SERVER["REQUEST_URI"];
96
- }
97
- }else{
98
- $this->cacheFilePath = $this->getWpContentDir("/cache/all/").$_SERVER["REQUEST_URI"];
99
  }
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
 
104
  $this->cacheFilePath = $this->cacheFilePath ? rtrim($this->cacheFilePath, "/")."/" : "";
105
- $this->cacheFilePath = str_replace("/cache/all//", "/cache/all/", $this->cacheFilePath);
106
 
107
 
108
  if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pages
@@ -292,6 +294,13 @@
292
  return 0;
293
  }
294
 
 
 
 
 
 
 
 
295
  if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST"){
296
  return 0;
297
  }
@@ -324,13 +333,6 @@
324
  return 0;
325
  }
326
 
327
- //different domain names may be used for different languages
328
- if($this->isPluginActive('polylang/polylang.php')){
329
- if(!preg_match("/".preg_quote(str_replace("www.", "", $_SERVER["HTTP_HOST"]), "/")."/i", get_option("home"))){
330
- return 0;
331
- }
332
- }
333
-
334
  if($this->exclude_page()){
335
  //echo "<!-- Wp Fastest Cache: Exclude Page -->"."\n";
336
  return 0;
79
  }
80
 
81
  public function set_cache_file_path(){
82
+ $type = "all";
83
 
84
  if($this->isMobile() && isset($this->options->wpFastestCacheMobile)){
85
  if(class_exists("WpFcMobileCache") && isset($this->options->wpFastestCacheMobileTheme)){
86
+ $type = "wpfc-mobile-cache";
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  }
88
  }
89
 
90
+ if($this->isPluginActive('gtranslate/gtranslate.php')){
91
+ if(isset($_SERVER["HTTP_X_GT_LANG"])){
92
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["HTTP_X_GT_LANG"].$_SERVER["REQUEST_URI"];
93
+ }else if(isset($_SERVER["REDIRECT_URL"]) && $_SERVER["REDIRECT_URL"] != "/index.php"){
94
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["REDIRECT_URL"];
95
+ }else if(isset($_SERVER["REQUEST_URI"])){
96
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["REQUEST_URI"];
97
+ }
98
+ }else{
99
+ $this->cacheFilePath = $this->getWpContentDir("/cache/".$type."/").$_SERVER["REQUEST_URI"];
100
+
101
+ // for /?s=
102
+ $this->cacheFilePath = preg_replace("/(\/\?s\=)/", "$1/", $this->cacheFilePath);
103
+ }
104
 
105
 
106
  $this->cacheFilePath = $this->cacheFilePath ? rtrim($this->cacheFilePath, "/")."/" : "";
107
+ $this->cacheFilePath = preg_replace("/\/cache\/(all|wpfc-mobile-cache)\/\//", "/cache/$1/", $this->cacheFilePath);
108
 
109
 
110
  if(strlen($_SERVER["REQUEST_URI"]) > 1){ // for the sub-pages
294
  return 0;
295
  }
296
 
297
+ // to check permalink if it does not end with slash
298
+ if(isset($_SERVER['REQUEST_URI']) && preg_match("/[^\/]+\/$/", $_SERVER['REQUEST_URI'])){
299
+ if(!preg_match("/\/$/", get_option('permalink_structure'))){
300
+ return 0;
301
+ }
302
+ }
303
+
304
  if(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "POST"){
305
  return 0;
306
  }
333
  return 0;
334
  }
335
 
 
 
 
 
 
 
 
336
  if($this->exclude_page()){
337
  //echo "<!-- Wp Fastest Cache: Exclude Page -->"."\n";
338
  return 0;
inc/single-preload.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class SinglePreloadWPFC{
3
+ public static $id = 0;
4
+ public static $urls = array();
5
+
6
+ public static function init(){
7
+ SinglePreloadWPFC::set_id();
8
+ SinglePreloadWPFC::set_urls();
9
+ SinglePreloadWPFC::set_urls_with_terms();
10
+ }
11
+
12
+ public static function set_id(){
13
+ if(isset($_GET["post"]) && $_GET["post"]){
14
+ static::$id = esc_sql($_GET["post"]);
15
+
16
+ if(get_post_status(static::$id) != "publish"){
17
+ static::$id = 0;
18
+ }
19
+ }
20
+ }
21
+
22
+ public static function create_cache(){
23
+ $res = $GLOBALS["wp_fastest_cache"]->wpfc_remote_get($_GET["url"], $_GET["user_agent"]);
24
+
25
+ if($res){
26
+ die("true");
27
+ }
28
+ }
29
+
30
+ public static function is_mobile_active(){
31
+ if(isset($GLOBALS["wp_fastest_cache_options"]->wpFastestCacheMobile) && isset($GLOBALS["wp_fastest_cache_options"]->wpFastestCacheMobileTheme)){
32
+ return true;
33
+ }else{
34
+ return false;
35
+ }
36
+ }
37
+
38
+ public static function set_term_urls($term_taxonomy_id){
39
+ $term = get_term_by("term_taxonomy_id", $term_taxonomy_id);
40
+
41
+ if($term && !is_wp_error($term)){
42
+ $url = get_term_link($term->term_id, $term->taxonomy);
43
+
44
+ array_push(static::$urls, array("url" => $url, "user-agent" => "WP Fastest Cache Preload Bot"));
45
+
46
+ if(self::is_mobile_active()){
47
+ array_push(static::$urls, array("url" => $url, "user-agent" => "WP Fastest Cache Preload iPhone Mobile Bot"));
48
+ }
49
+
50
+ if($term->parent > 0){
51
+ $parent = get_term_by("id", $term->parent, $term->taxonomy);
52
+
53
+ static::set_term_urls($parent->term_taxonomy_id);
54
+ }
55
+ }
56
+ }
57
+
58
+ public static function set_urls_with_terms(){
59
+ global $wpdb;
60
+ $terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".static::$id, ARRAY_A);
61
+
62
+ foreach ($terms as $term_key => $term_val){
63
+ static::set_term_urls($term_val["term_taxonomy_id"]);
64
+ }
65
+ }
66
+
67
+ public static function set_urls(){
68
+ if(static::$id){
69
+ $permalink = get_permalink(static::$id);
70
+
71
+ array_push(static::$urls, array("url" => $permalink, "user-agent" => "WP Fastest Cache Preload Bot"));
72
+
73
+ if(self::is_mobile_active()){
74
+ array_push(static::$urls, array("url" => $permalink, "user-agent" => "WP Fastest Cache Preload iPhone Mobile Bot"));
75
+ }
76
+ }
77
+ }
78
+
79
+ public static function put_inline_js(){
80
+ $screen = get_current_screen();
81
+
82
+ if($screen->parent_base == "edit" && $screen->base == "post"){
83
+ ?>
84
+ <div id="wpfc-single-preload" class="notice notice-info is-dismissible" style="display: none;">
85
+ <p id="wpfc-single-preload-info"><?php _e('Cache is generated for this content', 'wp-fastest-cache');?><label style="display: none;" id="wpfc-single-preload-error">0</label><label id="wpfc-single-preload-process" style="padding-left: 5px;"><span>0</span>/<span><?php echo count(static::$urls); ?></span></label></p>
86
+
87
+ <script type="text/javascript">
88
+ var WpfcSinglePreload = {
89
+ error_message: "",
90
+ init: function(){},
91
+ change_status: function(){
92
+ var type = "";
93
+ var cached_number = parseInt(jQuery("#wpfc-single-preload-process span").first().text());
94
+ var total = parseInt(jQuery("#wpfc-single-preload-process span").last().text());
95
+ var error_number = parseInt(jQuery("#wpfc-single-preload-error").text());
96
+
97
+ if(cached_number == total){
98
+ type = "success";
99
+ }
100
+
101
+ if((error_number + cached_number) == total){
102
+ if(error_number > cached_number){
103
+ type = "error";
104
+ }else{
105
+ type = "success";
106
+ }
107
+ }
108
+
109
+ if(type){
110
+ var class_name = jQuery("#wpfc-single-preload").attr("class");
111
+ class_name = class_name.replace("notice-info", "notice-" + type);
112
+ jQuery("#wpfc-single-preload").attr("class", class_name);
113
+
114
+ if(type == "success"){
115
+ jQuery("#wpfc-single-preload p").text("<?php _e('Cache has been generated for this content successfully', 'wp-fastest-cache');?>");
116
+ }else{
117
+ if(this.error_message){
118
+ this.error_message = "<?php _e('Cache has NOT been generated for this content successfully', 'wp-fastest-cache');?>" + "<br>" + "<?php _e('Reason:', 'wp-fastest-cache');?>" + " " + this.error_message;
119
+ jQuery("#wpfc-single-preload p").html(this.error_message);
120
+ }
121
+ }
122
+ }
123
+ },
124
+ increase_error: function(){
125
+ var error_number = jQuery("#wpfc-single-preload-error").text();
126
+ error_number = parseInt(error_number) + 1;
127
+ jQuery("#wpfc-single-preload-error").text(error_number);
128
+
129
+ this.change_status();
130
+ },
131
+ create_cache: function(url, user_agent){
132
+ var self = this;
133
+ jQuery("#wpfc-single-preload").show();
134
+
135
+ jQuery.ajax({
136
+ type: 'GET',
137
+ url: ajaxurl,
138
+ data: {"action": "wpfc_preload_single", "url": url, "user_agent": user_agent},
139
+ dataType: "html",
140
+ timeout: 10000,
141
+ cache: false,
142
+ success: function(data){
143
+ if(data == "true"){
144
+ var number = jQuery("#wpfc-single-preload-process span").first().text();
145
+ number = parseInt(number) + 1;
146
+
147
+ jQuery("#wpfc-single-preload-process span").first().text(number);
148
+ }else{
149
+ self.error_message = data;
150
+ WpfcSinglePreload.increase_error();
151
+ }
152
+
153
+ self.change_status();
154
+ },
155
+ error: function(error){
156
+ self.error_message = error.statusText;
157
+ WpfcSinglePreload.increase_error();
158
+ }
159
+ });
160
+ }
161
+ };
162
+
163
+
164
+ jQuery(document).ready(function(){
165
+ if(jQuery("#message").find("a").attr("href")){
166
+ WpfcSinglePreload.init();
167
+
168
+ <?php
169
+ foreach (self::$urls as $key => $value) {
170
+ ?>
171
+ setTimeout(function(){
172
+ WpfcSinglePreload.create_cache("<?php echo $value["url"]; ?>", "<?php echo $value["user-agent"]; ?>");
173
+ }, <?php echo $key*500;?>);
174
+ <?php
175
+ }
176
+ ?>
177
+ }
178
+ });
179
+ </script>
180
+ </div>
181
+ <?php
182
+ }
183
+ }
184
+ }
185
+ ?>
js/toolbar.js CHANGED
@@ -16,11 +16,17 @@ window.addEventListener('load', function(){
16
  action = "wpfc_delete_current_page_cache";
17
  }
18
 
 
 
 
 
 
 
19
  jQuery("#revert-loader-toolbar").show();
20
  jQuery.ajax({
21
  type: 'GET',
22
  url: ajax_url,
23
- data : {"action": action, "path" : window.location.pathname},
24
  dataType : "json",
25
  cache: false,
26
  success: function(data){
16
  action = "wpfc_delete_current_page_cache";
17
  }
18
 
19
+ var data_json = {"action": action, "path" : window.location.pathname};
20
+
21
+ if(typeof wpfc_nonce != "undefined" && wpfc_nonce){
22
+ data_json.nonce = wpfc_nonce;
23
+ }
24
+
25
  jQuery("#revert-loader-toolbar").show();
26
  jQuery.ajax({
27
  type: 'GET',
28
  url: ajax_url,
29
+ data : data_json,
30
  dataType : "json",
31
  cache: false,
32
  success: function(data){
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.3
7
- Stable tag: 0.9.0.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,15 @@ The free version is enough to speed up your site but in the premium version ther
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
 
 
 
127
  = 0.9.0.2 =
128
  * <strong>[FEATURE]</strong> to add Spanish (Argentina) language
129
  * to add WPFC_TOOLBAR_FOR_SHOP_MANAGER [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-link-at-the-toolbar/">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.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
 
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>]
130
+ * to fix clearing search (/?s=) result cache
131
+ * to add settings link on the plugin list
132
+ * [FEATURE] Compatible with Polylang with one different subdomain or domain per language
133
+ * to exclude url which ends with slash if the permalink does not end with slush
134
+ * to exclude images for cdn if the url contains brizy_media=
135
+
136
  = 0.9.0.2 =
137
  * <strong>[FEATURE]</strong> to add Spanish (Argentina) language
138
  * to add WPFC_TOOLBAR_FOR_SHOP_MANAGER [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-link-at-the-toolbar/">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.2
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -130,6 +130,14 @@ GNU General Public License for more details.
130
  add_action("wpfc_clear_all_cache", array($this, 'deleteCache'), 10, 1);
131
  add_action("wpfc_clear_post_cache_by_id", array($this, 'singleDeleteCache'), 10, 2);
132
 
 
 
 
 
 
 
 
 
133
 
134
 
135
  // to clear cache after ajax request by other plugins
@@ -155,6 +163,7 @@ GNU General Public License for more details.
155
  $this->rm_folder_recursively($this->getWpContentDir("/cache/tmpWpfc"));
156
  }
157
 
 
158
  if($this->isPluginActive('wp-polls/wp-polls.php')){
159
  //for WP-Polls
160
  require_once "inc/wp-polls.php";
@@ -295,6 +304,23 @@ GNU General Public License for more details.
295
  }
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
  public function notify($message = array()){
300
  if(isset($message[0]) && $message[0]){
@@ -317,6 +343,16 @@ GNU General Public License for more details.
317
  }
318
  }
319
 
 
 
 
 
 
 
 
 
 
 
320
  if (!defined('WPFC_WP_CONTENT_URL')) {
321
  define("WPFC_WP_CONTENT_URL", $content_url);
322
  }
@@ -633,24 +669,18 @@ GNU General Public License for more details.
633
 
634
  public function load_admin_toolbar(){
635
  if(!defined('WPFC_HIDE_TOOLBAR') || (defined('WPFC_HIDE_TOOLBAR') && !WPFC_HIDE_TOOLBAR)){
636
- $show = false;
637
-
638
  $user = wp_get_current_user();
639
  $allowed_roles = array('administrator');
640
 
641
- // Author
642
- if(defined('WPFC_TOOLBAR_FOR_AUTHOR') && WPFC_TOOLBAR_FOR_AUTHOR){
643
- array_push($allowed_roles, "author");
644
- }
645
-
646
- // Editor
647
- if(defined('WPFC_TOOLBAR_FOR_EDITOR') && WPFC_TOOLBAR_FOR_EDITOR){
648
- array_push($allowed_roles, "editor");
649
- }
650
-
651
- // Shop Manager
652
- if(defined('WPFC_TOOLBAR_FOR_SHOP_MANAGER') && WPFC_TOOLBAR_FOR_SHOP_MANAGER){
653
- array_push($allowed_roles, "shop_manager");
654
  }
655
 
656
  if(array_intersect($allowed_roles, $user->roles)){
@@ -701,6 +731,10 @@ GNU General Public License for more details.
701
  }
702
 
703
  public function delete_current_page_cache(){
 
 
 
 
704
  include_once('inc/cdn.php');
705
  CdnWPFC::cloudflare_clear_cache();
706
 
@@ -734,6 +768,8 @@ GNU General Public License for more details.
734
  }
735
  }
736
 
 
 
737
  die(json_encode(array("The cache of page has been cleared","success")));
738
  }else{
739
  die(json_encode(array("Path has NOT been defined", "error", "alert")));
@@ -802,6 +838,14 @@ GNU General Public License for more details.
802
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$my_home_url."/$1", $path);
803
  }
804
 
 
 
 
 
 
 
 
 
805
  if(is_multisite()){
806
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
807
  }
@@ -876,6 +920,10 @@ GNU General Public License for more details.
876
  }
877
 
878
  if($new_status == "publish" && $old_status == "publish"){
 
 
 
 
879
  if(isset($this->options->wpFastestCacheUpdatePost) && isset($this->options->wpFastestCacheStatus)){
880
 
881
  if($this->options->wpFastestCacheUpdatePost_type == "post"){
@@ -1038,6 +1086,23 @@ GNU General Public License for more details.
1038
  $this->delete_cache_of_term($term_val["term_taxonomy_id"]);
1039
  }
1040
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1041
  }
1042
  }
1043
 
@@ -1197,6 +1262,8 @@ GNU General Public License for more details.
1197
  //to clear widget cache path
1198
  $this->deleteWidgetCache();
1199
 
 
 
1200
  if(is_dir($cache_path)){
1201
  if(@rename($cache_path, $this->getWpContentDir("/cache/tmpWpfc/").time())){
1202
  delete_option("WpFastestCacheHTML");
@@ -1690,6 +1757,11 @@ GNU General Public License for more details.
1690
  return $matches[0];
1691
  }
1692
 
 
 
 
 
 
1693
  //https://cdn.shortpixel.ai/client/q_glossy,ret_img,w_736/http://wpfc.com/stories.png
1694
  if(preg_match("/cdn\.shortpixel\.ai\/client/i", $matches[0])){
1695
  return $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.3
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
130
  add_action("wpfc_clear_all_cache", array($this, 'deleteCache'), 10, 1);
131
  add_action("wpfc_clear_post_cache_by_id", array($this, 'singleDeleteCache'), 10, 2);
132
 
133
+ // to create cache for single content
134
+ if(defined("WPFC_AUTOMATIC_CACHE") && WPFC_AUTOMATIC_CACHE){
135
+ add_action('admin_notices', array( $this, 'single_preload_inline_js'));
136
+ add_action('wp_ajax_wpfc_preload_single', array($this, "wpfc_preload_single_callback"));
137
+ }
138
+
139
+ // to add settings link
140
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'action_links'));
141
 
142
 
143
  // to clear cache after ajax request by other plugins
163
  $this->rm_folder_recursively($this->getWpContentDir("/cache/tmpWpfc"));
164
  }
165
 
166
+
167
  if($this->isPluginActive('wp-polls/wp-polls.php')){
168
  //for WP-Polls
169
  require_once "inc/wp-polls.php";
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);
310
+ }
311
+
312
+ public function wpfc_preload_single_callback(){
313
+ include_once('inc/single-preload.php');
314
+ SinglePreloadWPFC::create_cache();
315
+ }
316
+
317
+
318
+ public function single_preload_inline_js(){
319
+ include_once('inc/single-preload.php');
320
+ SinglePreloadWPFC::init();
321
+ SinglePreloadWPFC::put_inline_js();
322
+ }
323
+
324
 
325
  public function notify($message = array()){
326
  if(isset($message[0]) && $message[0]){
343
  }
344
  }
345
 
346
+ // to change content url if a different url is used for other langs
347
+ if($this->isPluginActive('polylang/polylang.php')){
348
+ $url = parse_url($content_url);
349
+
350
+ if($url["host"] != $_SERVER['HTTP_HOST']){
351
+ $protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
352
+ $content_url = $protocol.$_SERVER['HTTP_HOST'].$url['path'];
353
+ }
354
+ }
355
+
356
  if (!defined('WPFC_WP_CONTENT_URL')) {
357
  define("WPFC_WP_CONTENT_URL", $content_url);
358
  }
669
 
670
  public function load_admin_toolbar(){
671
  if(!defined('WPFC_HIDE_TOOLBAR') || (defined('WPFC_HIDE_TOOLBAR') && !WPFC_HIDE_TOOLBAR)){
 
 
672
  $user = wp_get_current_user();
673
  $allowed_roles = array('administrator');
674
 
675
+ $constants = get_defined_constants();
676
+ if(is_array($constants)){
677
+ foreach ($constants as $key => $value) {
678
+ if(preg_match("/^WPFC_TOOLBAR_FOR_(.+)/", $key, $role)){
679
+ if($value){
680
+ array_push($allowed_roles, strtolower($role[1]));
681
+ }
682
+ }
683
+ }
 
 
 
 
684
  }
685
 
686
  if(array_intersect($allowed_roles, $user->roles)){
731
  }
732
 
733
  public function delete_current_page_cache(){
734
+ if(!wp_verify_nonce($_GET["nonce"], "wpfc")){
735
+ die(json_encode(array("Security Error!", "error", "alert")));
736
+ }
737
+
738
  include_once('inc/cdn.php');
739
  CdnWPFC::cloudflare_clear_cache();
740
 
768
  }
769
  }
770
 
771
+ $this->delete_multiple_domain_mapping_cache();
772
+
773
  die(json_encode(array("The cache of page has been cleared","success")));
774
  }else{
775
  die(json_encode(array("Path has NOT been defined", "error", "alert")));
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')){
842
+ $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
843
+ }
844
+
845
+ if($this->isPluginActive('polylang/polylang.php')){
846
+ $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
847
+ }
848
+
849
  if(is_multisite()){
850
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
851
  }
920
  }
921
 
922
  if($new_status == "publish" && $old_status == "publish"){
923
+
924
+
925
+
926
+
927
  if(isset($this->options->wpFastestCacheUpdatePost) && isset($this->options->wpFastestCacheStatus)){
928
 
929
  if($this->options->wpFastestCacheUpdatePost_type == "post"){
1086
  $this->delete_cache_of_term($term_val["term_taxonomy_id"]);
1087
  }
1088
  }
1089
+
1090
+ $this->delete_multiple_domain_mapping_cache();
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
  }
1107
  }
1108
 
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())){
1269
  delete_option("WpFastestCacheHTML");
1757
  return $matches[0];
1758
  }
1759
 
1760
+ //https://site.com?brizy_media=AttachmentName.jpg&brizy_crop=CropSizes&brizy_post=TheCurrentPost
1761
+ if(preg_match("/brizy_media\=/i", $matches[0])){
1762
+ return $matches[0];
1763
+ }
1764
+
1765
  //https://cdn.shortpixel.ai/client/q_glossy,ret_img,w_736/http://wpfc.com/stories.png
1766
  if(preg_match("/cdn\.shortpixel\.ai\/client/i", $matches[0])){
1767
  return $matches[0];