WP Fastest Cache - Version 0.9.0.9

Version Description

  • [FEATURE] to add wizard allows you to show the clear cache button which exists on the admin toolbar based on user roles [Details]
  • to fix the replace problem when the cdn-url starts with a number
  • to fix the little issue on the cloudflare integration
Download this release

Release Info

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

Code changes from version 0.9.0.8 to 0.9.0.9

inc/admin-toolbar.php CHANGED
@@ -106,6 +106,15 @@
106
  'parent'=> 'wpfc-toolbar-parent',
107
  'meta' => array("class" => "wpfc-toolbar-child")
108
  ));
 
 
 
 
 
 
 
 
 
109
  }
110
  }
111
  }
106
  'parent'=> 'wpfc-toolbar-parent',
107
  'meta' => array("class" => "wpfc-toolbar-child")
108
  ));
109
+ }else{
110
+ if(isset($_GET["page"]) && $_GET["page"] == "wpfastestcacheoptions"){
111
+ $wp_admin_bar->add_menu( array(
112
+ 'id' => 'wpfc-toolbar-parent-settings',
113
+ 'title' => __("Settings", "wp-fastest-cache"),
114
+ 'parent'=> 'wpfc-toolbar-parent',
115
+ 'meta' => array("class" => "wpfc-toolbar-child")
116
+ ));
117
+ }
118
  }
119
  }
120
  }
inc/admin.php CHANGED
@@ -2104,6 +2104,7 @@
2104
  </div>
2105
 
2106
  <?php include_once(WPFC_MAIN_PATH."templates/permission_error.html"); ?>
 
2107
 
2108
  <?php
2109
  if(isset($this->options->wpFastestCacheStatus)){
2104
  </div>
2105
 
2106
  <?php include_once(WPFC_MAIN_PATH."templates/permission_error.html"); ?>
2107
+ <?php include_once(WPFC_MAIN_PATH."templates/toolbar_settings.php"); ?>
2108
 
2109
  <?php
2110
  if(isset($this->options->wpFastestCacheStatus)){
inc/cdn.php CHANGED
@@ -40,6 +40,7 @@
40
  public static function cloudflare_disable_rocket_loader($email = false, $key = false, $zoneid = false){
41
  if($email && $key && $zoneid){
42
  $header = array("method" => "PATCH",
 
43
  'headers' => array(
44
  "X-Auth-Email" => $email,
45
  "X-Auth-Key" => $key,
@@ -72,6 +73,7 @@
72
  public static function cloudflare_set_browser_caching($email = false, $key = false, $zoneid = false){
73
  if($email && $key && $zoneid){
74
  $header = array("method" => "PATCH",
 
75
  'headers' => array(
76
  "X-Auth-Email" => $email,
77
  "X-Auth-Key" => $key,
@@ -83,7 +85,7 @@
83
  $response = wp_remote_request('https://api.cloudflare.com/client/v4/zones/'.$zoneid.'/settings/browser_cache_ttl', $header);
84
 
85
  if(!$response || is_wp_error($response)){
86
- return array("success" => false, "error_message" => "Unable to disable rocket loader option");
87
  }else{
88
  $body = json_decode(wp_remote_retrieve_body($response));
89
 
@@ -103,6 +105,7 @@
103
  public static function cloudflare_disable_minify($email = false, $key = false, $zoneid = false){
104
  if($email && $key && $zoneid){
105
  $header = array("method" => "PATCH",
 
106
  'headers' => array(
107
  "X-Auth-Email" => $email,
108
  "X-Auth-Key" => $key,
40
  public static function cloudflare_disable_rocket_loader($email = false, $key = false, $zoneid = false){
41
  if($email && $key && $zoneid){
42
  $header = array("method" => "PATCH",
43
+ 'timeout' => 10,
44
  'headers' => array(
45
  "X-Auth-Email" => $email,
46
  "X-Auth-Key" => $key,
73
  public static function cloudflare_set_browser_caching($email = false, $key = false, $zoneid = false){
74
  if($email && $key && $zoneid){
75
  $header = array("method" => "PATCH",
76
+ 'timeout' => 10,
77
  'headers' => array(
78
  "X-Auth-Email" => $email,
79
  "X-Auth-Key" => $key,
85
  $response = wp_remote_request('https://api.cloudflare.com/client/v4/zones/'.$zoneid.'/settings/browser_cache_ttl', $header);
86
 
87
  if(!$response || is_wp_error($response)){
88
+ return array("success" => false, "error_message" => "Unable to set the browser caching option");
89
  }else{
90
  $body = json_decode(wp_remote_retrieve_body($response));
91
 
105
  public static function cloudflare_disable_minify($email = false, $key = false, $zoneid = false){
106
  if($email && $key && $zoneid){
107
  $header = array("method" => "PATCH",
108
+ 'timeout' => 10,
109
  'headers' => array(
110
  "X-Auth-Email" => $email,
111
  "X-Auth-Key" => $key,
js/toolbar.js CHANGED
@@ -1,57 +1,122 @@
1
- window.addEventListener('load', function(){
2
- jQuery(document).ready(function(){
 
 
 
 
 
 
 
 
 
3
  jQuery("body").append('<div id="revert-loader-toolbar"></div>');
4
 
5
  jQuery("#wp-admin-bar-wpfc-toolbar-parent-default li").click(function(e){
6
- if(typeof ajaxurl != "undefined" || typeof wpfc_ajaxurl != "undefined"){
7
- var ajax_url = (typeof ajaxurl != "undefined") ? ajaxurl : wpfc_ajaxurl;
8
- var id = (typeof e.target.id != "undefined" && e.target.id) ? e.target.id : jQuery(e.target).parent("li").attr("id");
9
- var action = "";
10
-
11
- if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache"){
12
- action = "wpfc_delete_cache";
13
- }else if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache-and-minified"){
14
- action = "wpfc_delete_cache_and_minified";
15
- }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-this-page"){
16
- action = "wpfc_delete_current_page_cache";
17
- }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-allsites"){
18
- action = "wpfc_clear_cache_of_allsites";
19
- }
 
 
 
20
 
21
- var data_json = {"action": action, "path" : window.location.pathname};
 
 
 
 
 
22
 
23
- if(typeof wpfc_nonce != "undefined" && wpfc_nonce){
24
- data_json.nonce = wpfc_nonce;
25
- }
 
 
 
 
 
 
 
26
 
27
- jQuery("#revert-loader-toolbar").show();
28
- jQuery.ajax({
29
- type: 'GET',
30
- url: ajax_url,
31
- data : data_json,
32
- dataType : "json",
33
- cache: false,
34
- success: function(data){
35
- if(data[1] == "error"){
36
- if(typeof data[2] != "undefined" && data[2] == "alert"){
37
- alert(data[0]);
38
- }else{
39
- Wpfc_New_Dialog.dialog("wpfc-modal-permission", {close: "default"});
40
- Wpfc_New_Dialog.show_button("close");
 
 
41
  }
42
- }
 
 
 
43
 
44
- if(typeof WpFcCacheStatics != "undefined"){
45
- WpFcCacheStatics.update();
46
- }else{
47
  jQuery("#revert-loader-toolbar").hide();
48
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
- });
51
- }else{
52
- alert("AjaxURL has NOT been defined");
 
 
 
 
53
  }
54
  });
 
 
 
 
 
 
55
  });
56
  });
57
 
1
+ var WPFC_TOOLBAR = {
2
+ ajax_url: false,
3
+ init: function(){
4
+ var self = this;
5
+
6
+ if(typeof ajaxurl != "undefined" || typeof wpfc_ajaxurl != "undefined"){
7
+ self.ajax_url = (typeof ajaxurl != "undefined") ? ajaxurl : wpfc_ajaxurl;
8
+ }else{
9
+ alert("AjaxURL has NOT been defined");
10
+ }
11
+
12
  jQuery("body").append('<div id="revert-loader-toolbar"></div>');
13
 
14
  jQuery("#wp-admin-bar-wpfc-toolbar-parent-default li").click(function(e){
15
+ var id = (typeof e.target.id != "undefined" && e.target.id) ? e.target.id : jQuery(e.target).parent("li").attr("id");
16
+ var action = "";
17
+
18
+ if(id == "wp-admin-bar-wpfc-toolbar-parent-settings"){
19
+ if(jQuery("div[id^='wpfc-modal-toolbarsettings-']").length === 0){
20
+ self.open_settings();
21
+ }
22
+ }else{
23
+ if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache"){
24
+ action = "wpfc_delete_cache";
25
+ }else if(id == "wp-admin-bar-wpfc-toolbar-parent-delete-cache-and-minified"){
26
+ action = "wpfc_delete_cache_and_minified";
27
+ }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-this-page"){
28
+ action = "wpfc_delete_current_page_cache";
29
+ }else if(id == "wp-admin-bar-wpfc-toolbar-parent-clear-cache-of-allsites"){
30
+ action = "wpfc_clear_cache_of_allsites";
31
+ }
32
 
33
+ WPFC_TOOLBAR.send({"action": action, "path" : window.location.pathname});
34
+ }
35
+ });
36
+ },
37
+ open_settings: function(){
38
+ var self = this;
39
 
40
+ jQuery("#revert-loader-toolbar").show();
41
+ jQuery.ajax({
42
+ type: 'GET',
43
+ url: self.ajax_url,
44
+ data : {"action": "wpfc_toolbar_get_settings", "path" : window.location.pathname},
45
+ dataType : "json",
46
+ cache: false,
47
+ success: function(data){
48
+ if(data.success){
49
+ var data_json = {"action": "wpfc_toolbar_save_settings", "path" : window.location.pathname, "roles" : {}};
50
 
51
+ Wpfc_New_Dialog.dialog("wpfc-modal-toolbarsettings", {
52
+ close: function(){
53
+ Wpfc_New_Dialog.clone.remove();
54
+ },
55
+ finish: function(){
56
+ jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']:checked").each(function(i, e){
57
+ data_json.roles[jQuery(e).attr("name")] = 1;
58
+ });
59
+
60
+ WPFC_TOOLBAR.send(data_json);
61
+
62
+ Wpfc_New_Dialog.clone.remove();
63
+ }}, function(dialog){
64
+ jQuery("#" + Wpfc_New_Dialog.id).find("input[type='checkbox']").each(function(i, e){
65
+ if(typeof data.roles[jQuery(e).attr("name")] != "undefined"){
66
+ jQuery(e).attr('checked', true);
67
  }
68
+ });
69
+
70
+ Wpfc_New_Dialog.show_button("close");
71
+ Wpfc_New_Dialog.show_button("finish");
72
 
73
+ setTimeout(function(){
 
 
74
  jQuery("#revert-loader-toolbar").hide();
75
+ }, 500);
76
+ });
77
+ }else{
78
+ alert("Toolbar Settings Error!")
79
+ }
80
+ }
81
+ });
82
+ },
83
+ send: function(data_json){
84
+ var self = this;
85
+
86
+ if(typeof wpfc_nonce != "undefined" && wpfc_nonce){
87
+ data_json.nonce = wpfc_nonce;
88
+ }
89
+
90
+ jQuery("#revert-loader-toolbar").show();
91
+ jQuery.ajax({
92
+ type: 'GET',
93
+ url: self.ajax_url,
94
+ data : data_json,
95
+ dataType : "json",
96
+ cache: false,
97
+ success: function(data){
98
+ if(data[1] == "error"){
99
+ if(typeof data[2] != "undefined" && data[2] == "alert"){
100
+ alert(data[0]);
101
+ }else{
102
+ Wpfc_New_Dialog.dialog("wpfc-modal-permission", {close: "default"});
103
+ Wpfc_New_Dialog.show_button("close");
104
  }
105
+ }
106
+
107
+ if(typeof WpFcCacheStatics != "undefined"){
108
+ WpFcCacheStatics.update();
109
+ }else{
110
+ jQuery("#revert-loader-toolbar").hide();
111
+ }
112
  }
113
  });
114
+ }
115
+ };
116
+
117
+ window.addEventListener('load', function(){
118
+ jQuery(document).ready(function(){
119
+ WPFC_TOOLBAR.init();
120
  });
121
  });
122
 
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.4
7
- Stable tag: 0.9.0.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,11 @@ The free version is enough to speed up your site but in the premium version ther
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
127
  = 0.9.0.8 =
128
  * to exclude PDF files from caching
129
  * to add Modified Time into htaccess
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.9
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.9 =
128
+ * <strong>[FEATURE]</strong> to add wizard allows you to show the clear cache button which exists on the admin toolbar based on user roles [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-link-on-the-toolbar/">Details</a>]
129
+ * to fix the replace problem when the cdn-url starts with a number
130
+ * to fix the little issue on the cloudflare integration
131
+
132
  = 0.9.0.8 =
133
  * to exclude PDF files from caching
134
  * to add Modified Time into htaccess
templates/toolbar_settings.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style type="text/css">
2
+ div[id^="wpfc-modal-toolbarsettings"] .wiz-input-cont{
3
+ margin-top: 0 !important;
4
+ margin-bottom: 10px !important;
5
+ float: left !important;
6
+ width: 108px !important;
7
+ }
8
+ .wiz-input-cont label{
9
+ margin-right: 0 !important;
10
+ }
11
+ </style>
12
+ <div template-id="wpfc-modal-toolbarsettings" style="display:none;top: 10.5px; left: 226px; position: absolute; padding: 6px; height: auto; width: 560px; z-index: 9995;">
13
+ <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;">
14
+ </div>
15
+ <div style="z-index: 600; border-radius: 3px;">
16
+ <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;">
17
+ <table width="100%" height="100%">
18
+ <tbody>
19
+ <tr>
20
+ <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;"><?php _e('Toolbar Settings', 'wp-fastest-cache'); ?></td>
21
+ <td width="20" align="center" style="vertical-align: middle;"></td>
22
+ <td width="20" align="center" style="vertical-align: middle; font-family: Arial,Helvetica,sans-serif; color: rgb(170, 170, 170); cursor: default;">
23
+ <div title="Close Window" class="close-wiz"></div>
24
+ </td>
25
+ </tr>
26
+ </tbody>
27
+ </table>
28
+ </div>
29
+ <div class="window-content-wrapper" style="padding: 15px;">
30
+ <div class="window-content" style="z-index: 1000; height: auto; position: relative; display: inline-block; width: 100%;">
31
+ <div class="wpfc-cdn-pages-container">
32
+ <div class="wiz-cont" style="">
33
+ <h1>Authorities</h1>
34
+ <p style="margin-bottom: 24px;">This feature allows you to show the clear cache button which exists on the admin toolbar based on user roles. <a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-link-on-the-toolbar/"><img src="<?php echo plugins_url("wp-fastest-cache/images/info.png"); ?>" /></a></p>
35
+
36
+ <?php
37
+ global $wp_roles;
38
+
39
+ if(!isset($wp_roles)){
40
+ $wp_roles = new WP_Roles();
41
+ }
42
+
43
+ $wpfc_role_names = $wp_roles->get_names();
44
+
45
+ foreach ($wpfc_role_names as $key => $value){
46
+ if($key == "administrator"){
47
+ continue;
48
+ }
49
+
50
+ $wpfc_toolbar_element_id = "wpfc_toolbar_".$key;
51
+ ?>
52
+
53
+ <div class="wiz-input-cont" style="padding-right: 12px;margin-right: 10px;width: auto !important;">
54
+ <label class="mc-input-label" style="margin-right: 5px;"><input type="checkbox" id="<?php echo $wpfc_toolbar_element_id; ?>" name="<?php echo $wpfc_toolbar_element_id; ?>"></label>
55
+ <label for="<?php echo $wpfc_toolbar_element_id; ?>"><?php _e($value); ?></label>
56
+ </div>
57
+ <?php
58
+ }
59
+ ?>
60
+ </div>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ <div class="window-buttons-wrapper" style="padding: 0px; display: inline-block; width: 100%; border-top: 1px solid rgb(255, 255, 255); background: none repeat scroll 0px 0px rgb(222, 222, 222); z-index: 999; position: relative; text-align: right; border-radius: 0px 0px 3px 3px;">
65
+ <div style="padding: 12px; height: 23px;">
66
+
67
+ <button class="wpfc-dialog-buttons" type="button" action="close">
68
+ <span><?php _e("Cancel", "wp-fastest-cache"); ?></span>
69
+ </button>
70
+ <button class="wpfc-dialog-buttons buttons-green" type="button" action="finish">
71
+ <span><?php _e("Save", "wp-fastest-cache"); ?></span>
72
+ </button>
73
+
74
+ </div>
75
+ </div>
76
+ </div>
77
+ </div>
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.8
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -102,6 +102,9 @@ GNU General Public License for more details.
102
 
103
  add_action('wp_ajax_wpfc_clear_cache_of_allsites', array($this, "wpfc_clear_cache_of_allsites_callback"));
104
 
 
 
 
105
 
106
  add_action( 'wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
107
  add_action( 'wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
@@ -671,16 +674,14 @@ GNU General Public License for more details.
671
  $user = wp_get_current_user();
672
  $allowed_roles = array('administrator');
673
 
674
- $constants = get_defined_constants();
675
- if(is_array($constants)){
676
- foreach ($constants as $key => $value) {
677
- if(preg_match("/^WPFC_TOOLBAR_FOR_(.+)/", $key, $role)){
678
- if($value){
679
- array_push($allowed_roles, strtolower($role[1]));
680
- }
681
- }
682
  }
683
  }
 
684
 
685
  if(array_intersect($allowed_roles, $user->roles)){
686
  include_once plugin_dir_path(__FILE__)."inc/admin-toolbar.php";
@@ -694,7 +695,6 @@ GNU General Public License for more details.
694
  $toolbar = new WpFastestCacheAdminToolbar($is_multi);
695
  $toolbar->add();
696
  }
697
-
698
  }
699
  }
700
 
@@ -735,6 +735,49 @@ GNU General Public License for more details.
735
  $this->deleteCache(true);
736
  }
737
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
738
  public function wpfc_clear_cache_of_allsites_callback(){
739
  include_once('inc/cdn.php');
740
  CdnWPFC::cloudflare_clear_cache();
@@ -1906,7 +1949,7 @@ GNU General Public License for more details.
1906
  // $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3$4".$cdnurl, $matches[0]);
1907
  // }
1908
 
1909
- $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3".$cdnurl, $matches[0]);
1910
 
1911
 
1912
  }else if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $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.9
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
102
 
103
  add_action('wp_ajax_wpfc_clear_cache_of_allsites', array($this, "wpfc_clear_cache_of_allsites_callback"));
104
 
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'));
674
  $user = wp_get_current_user();
675
  $allowed_roles = array('administrator');
676
 
677
+ $wpfc_role_status = get_option("WpFastestCacheToolbarSettings");
678
+ if(is_array($wpfc_role_status) && !empty($wpfc_role_status)){
679
+ foreach ($wpfc_role_status as $key => $value){
680
+ $key = str_replace("wpfc_toolbar_", "", $key);
681
+ array_push($allowed_roles, strtolower($key));
 
 
 
682
  }
683
  }
684
+
685
 
686
  if(array_intersect($allowed_roles, $user->roles)){
687
  include_once plugin_dir_path(__FILE__)."inc/admin-toolbar.php";
695
  $toolbar = new WpFastestCacheAdminToolbar($is_multi);
696
  $toolbar->add();
697
  }
 
698
  }
699
  }
700
 
735
  $this->deleteCache(true);
736
  }
737
 
738
+ public function wpfc_toolbar_get_settings_callback(){
739
+ if(current_user_can('manage_options')){
740
+ $result = array("success" => true, "roles" => false);
741
+
742
+ $wpfc_role_status = get_option("WpFastestCacheToolbarSettings");
743
+ if(is_array($wpfc_role_status) && !empty($wpfc_role_status)){
744
+ $result["roles"] = $wpfc_role_status;
745
+ }
746
+
747
+ die(json_encode($result));
748
+ }else{
749
+ wp_die("Must be admin");
750
+ }
751
+ }
752
+
753
+ public function wpfc_toolbar_save_settings_callback(){
754
+ if(current_user_can('manage_options')){
755
+ if(is_array($_GET["roles"]) && !empty($_GET["roles"])){
756
+ $roles_arr = array();
757
+
758
+ foreach($_GET["roles"] as $key => $value){
759
+ $value = esc_html(esc_sql($value));
760
+ $key = esc_html(esc_sql($key));
761
+
762
+ $roles_arr[$key] = $value;
763
+ }
764
+
765
+ if(get_option("WpFastestCacheToolbarSettings") === false){
766
+ add_option("WpFastestCacheToolbarSettings", $roles_arr, 1, "no");
767
+ }else{
768
+ update_option("WpFastestCacheToolbarSettings", $roles_arr);
769
+ }
770
+ }else{
771
+ delete_option("WpFastestCacheToolbarSettings");
772
+ }
773
+
774
+
775
+ die(json_encode(array("Saved","success")));
776
+ }else{
777
+ wp_die("Must be admin");
778
+ }
779
+ }
780
+
781
  public function wpfc_clear_cache_of_allsites_callback(){
782
  include_once('inc/cdn.php');
783
  CdnWPFC::cloudflare_clear_cache();
1949
  // $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", "$1$2$3$4".$cdnurl, $matches[0]);
1950
  // }
1951
 
1952
+ $matches[0] = preg_replace("/(quot\;|\s)(https?\:)?(\\\\\/\\\\\/|\/\/)(www\.)?".$cdn->originurl."/i", '${1}${2}${3}'.$cdnurl, $matches[0]);
1953
 
1954
 
1955
  }else if(preg_match("/\{\"concatemoji\"\:\"[^\"]+\"\}/i", $matches[0])){