WP Fastest Cache - Version 0.9.0.6

Version Description

  • [FEATURE] to add WP-CLI command for clearing minified sources [Details]
  • to fix Warning: parse_url() expects parameter 1 to be string, object given in preload.php on line 458
  • [FEATURE] Compatible with Multiple Domain
  • [FEATURE] to add Clear Cache of All Sites button [Details]
Download this release

Release Info

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

Code changes from version 0.9.0.5 to 0.9.0.6

Files changed (7) hide show
  1. inc/admin-toolbar.php +23 -1
  2. inc/admin.php +4 -4
  3. inc/cli.php +32 -11
  4. inc/preload.php +4 -0
  5. js/toolbar.js +2 -0
  6. readme.txt +7 -1
  7. wpFastestCache.php +37 -2
inc/admin-toolbar.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
  class WpFastestCacheAdminToolbar{
3
- public function __construct(){}
 
 
 
 
4
 
5
  public function add(){
6
  if(is_admin()){
@@ -62,6 +66,15 @@
62
  'parent'=> 'wpfc-toolbar-parent',
63
  'meta' => array("class" => "wpfc-toolbar-child")
64
  ));
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  public function wpfc_tweaked_toolbar_on_admin_panel() {
@@ -85,6 +98,15 @@
85
  'parent'=> 'wpfc-toolbar-parent',
86
  'meta' => array("class" => "wpfc-toolbar-child")
87
  ));
 
 
 
 
 
 
 
 
 
88
  }
89
  }
90
  ?>
1
  <?php
2
  class WpFastestCacheAdminToolbar{
3
+ private $is_multi = false;
4
+
5
+ public function __construct($is_multi){
6
+ $this->is_multi = $is_multi;
7
+ }
8
 
9
  public function add(){
10
  if(is_admin()){
66
  'parent'=> 'wpfc-toolbar-parent',
67
  'meta' => array("class" => "wpfc-toolbar-child")
68
  ));
69
+
70
+ if($this->is_multi){
71
+ $wp_admin_bar->add_menu( array(
72
+ 'id' => 'wpfc-toolbar-parent-clear-cache-of-allsites',
73
+ 'title' => __("Clear Cache of All Sites", "wp-fastest-cache"),
74
+ 'parent'=> 'wpfc-toolbar-parent',
75
+ 'meta' => array("class" => "wpfc-toolbar-child")
76
+ ));
77
+ }
78
  }
79
 
80
  public function wpfc_tweaked_toolbar_on_admin_panel() {
98
  'parent'=> 'wpfc-toolbar-parent',
99
  'meta' => array("class" => "wpfc-toolbar-child")
100
  ));
101
+
102
+ if($this->is_multi){
103
+ $wp_admin_bar->add_menu( array(
104
+ 'id' => 'wpfc-toolbar-parent-clear-cache-of-allsites',
105
+ 'title' => __("Clear Cache of All Sites", "wp-fastest-cache"),
106
+ 'parent'=> 'wpfc-toolbar-parent',
107
+ 'meta' => array("class" => "wpfc-toolbar-child")
108
+ ));
109
+ }
110
  }
111
  }
112
  ?>
inc/admin.php CHANGED
@@ -1656,16 +1656,16 @@
1656
  </div>
1657
  <div class="wpfc-premium-step-footer">
1658
  <?php
1659
- if(in_array(get_bloginfo('language'), array("tr-TR", "tr", "it-IT", "nl", "fr-FR", "ja", "de-AT", "en-CA", "en-GB"))){
 
 
 
1660
  $premium_buy_link = "https://www.wpfastestcache.com/#buy";
1661
  $premium_price = "$49.99";
1662
 
1663
  if(in_array(get_bloginfo('language'), array("tr-TR", "tr"))){
1664
  $premium_price = "150TL";
1665
  }
1666
- }else{
1667
- $premium_price = "$49.99";
1668
- $premium_buy_link = "https://api.wpfastestcache.net/paypal/buypremium/";
1669
  }
1670
 
1671
  ?>
1656
  </div>
1657
  <div class="wpfc-premium-step-footer">
1658
  <?php
1659
+ if(in_array(get_bloginfo('language'), array("en-US"))){
1660
+ $premium_price = "$49.99";
1661
+ $premium_buy_link = "https://api.wpfastestcache.net/paypal/buypremium/";
1662
+ }else{
1663
  $premium_buy_link = "https://www.wpfastestcache.com/#buy";
1664
  $premium_price = "$49.99";
1665
 
1666
  if(in_array(get_bloginfo('language'), array("tr-TR", "tr"))){
1667
  $premium_price = "150TL";
1668
  }
 
 
 
1669
  }
1670
 
1671
  ?>
inc/cli.php CHANGED
@@ -20,6 +20,7 @@ class wpfcCLI extends \WP_CLI_Command
20
  *
21
  * ## EXAMPLES
22
  * wp fastest-cache clear all
 
23
  *
24
  *
25
  * @subcommand clear
@@ -29,23 +30,43 @@ class wpfcCLI extends \WP_CLI_Command
29
  *
30
  * @return void
31
  */
32
- public function clear($args, $args_assoc){
33
- if(isset($args[0]) && $args[0] == "all"){
34
- if(isset($GLOBALS['wp_fastest_cache'])){
35
- if(method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')){
36
-
37
- WP_CLI::line("Clearing the ALL cache...");
38
- $GLOBALS['wp_fastest_cache']->deleteCache();
39
- WP_CLI::success("The cache has been cleared!");
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  }else{
42
- WP_CLI::error("deleteCache() does not exist!");
43
  }
44
  }else{
45
- WP_CLI::error("GLOBALS['wp_fastest_cache'] has not been defined!");
46
  }
47
  }else{
48
- WP_CLI::error("The cache has been cleared!");
49
  }
50
  }
51
  }
20
  *
21
  * ## EXAMPLES
22
  * wp fastest-cache clear all
23
+ * wp fastest-cache clear all and minified
24
  *
25
  *
26
  * @subcommand clear
30
  *
31
  * @return void
32
  */
33
+ public function wrong_usage(){
34
+ $message = array("*************************************************************************",
35
+ "* Wrong usage! *",
36
+ "* Please read: https://www.wpfastestcache.com/features/wp-cli-commands/ *",
37
+ "*************************************************************************");
38
+ WP_CLI::error_multi_line($message);
39
+ }
 
40
 
41
+ public function clear($args, $args_assoc){
42
+ if(isset($GLOBALS['wp_fastest_cache'])){
43
+ if(method_exists($GLOBALS['wp_fastest_cache'], 'deleteCache')){
44
+ if(isset($args[0])){
45
+ if($args[0] == "all"){
46
+ if(isset($args[1]) && isset($args[2])){
47
+ if($args[1] == "and" && $args[2] == "minified"){
48
+ WP_CLI::line("Clearing the ALL cache...");
49
+ $GLOBALS['wp_fastest_cache']->deleteCache(true);
50
+ WP_CLI::success("The cache has been cleared!");
51
+ }else{
52
+ self::wrong_usage();
53
+ }
54
+ }else{
55
+ WP_CLI::line("Clearing the ALL cache...");
56
+ $GLOBALS['wp_fastest_cache']->deleteCache();
57
+ WP_CLI::success("The cache has been cleared!");
58
+ }
59
+ }else{
60
+ self::wrong_usage();
61
+ }
62
  }else{
63
+ self::wrong_usage();
64
  }
65
  }else{
66
+ WP_CLI::error("deleteCache() does not exist!");
67
  }
68
  }else{
69
+ WP_CLI::error("GLOBALS['wp_fastest_cache'] has not been defined!");
70
  }
71
  }
72
  }
inc/preload.php CHANGED
@@ -455,6 +455,10 @@
455
  }
456
 
457
  public static function is_excluded($url){
 
 
 
 
458
  $request_url = parse_url($url, PHP_URL_PATH);
459
  $request_url = urldecode(trim($request_url, "/"));
460
 
455
  }
456
 
457
  public static function is_excluded($url){
458
+ if(!is_string($url)){
459
+ return false;
460
+ }
461
+
462
  $request_url = parse_url($url, PHP_URL_PATH);
463
  $request_url = urldecode(trim($request_url, "/"));
464
 
js/toolbar.js CHANGED
@@ -14,6 +14,8 @@ window.addEventListener('load', function(){
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
  }
18
 
19
  var data_json = {"action": action, "path" : window.location.pathname};
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};
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.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -124,6 +124,12 @@ The free version is enough to speed up your site but in the premium version ther
124
 
125
  == Changelog ==
126
 
 
 
 
 
 
 
127
  = 0.9.0.5 =
128
  * to fix replacing urls on the json source with cdn url
129
  * to fix clearing cache on sites using Polylang plugin
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.6
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.6 =
128
+ * <strong>[FEATURE]</strong> to add WP-CLI command for clearing minified sources [<a target="_blank" href="https://www.wpfastestcache.com/features/wp-cli-commands/">Details</a>]
129
+ * to fix Warning: parse_url() expects parameter 1 to be string, object given in preload.php on line 458
130
+ * <strong>[FEATURE]</strong> Compatible with <a target="_blank" href="https://wordpress.org/plugins/multiple-domain/">Multiple Domain</a>
131
+ * <strong>[FEATURE]</strong> to add Clear Cache of All Sites button [<a target="_blank" href="https://www.wpfastestcache.com/features/clear-cache-of-all-sites/">Details</a>]
132
+
133
  = 0.9.0.5 =
134
  * to fix replacing urls on the json source with cdn url
135
  * to fix clearing cache on sites using Polylang plugin
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.5
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
@@ -99,6 +99,10 @@ GNU General Public License for more details.
99
  add_action('wp_ajax_wpfc_delete_cache', array($this, "deleteCacheToolbar"));
100
  add_action('wp_ajax_wpfc_delete_cache_and_minified', array($this, "deleteCssAndJsCacheToolbar"));
101
  add_action('wp_ajax_wpfc_delete_current_page_cache', array($this, "delete_current_page_cache"));
 
 
 
 
102
  add_action( 'wp_ajax_wpfc_save_timeout_pages', array($this, 'wpfc_save_timeout_pages_callback'));
103
  add_action( 'wp_ajax_wpfc_save_exclude_pages', array($this, 'wpfc_save_exclude_pages_callback'));
104
  add_action( 'wp_ajax_wpfc_cdn_options', array($this, 'wpfc_cdn_options_ajax_request_callback'));
@@ -677,7 +681,13 @@ GNU General Public License for more details.
677
  if(array_intersect($allowed_roles, $user->roles)){
678
  include_once plugin_dir_path(__FILE__)."inc/admin-toolbar.php";
679
 
680
- $toolbar = new WpFastestCacheAdminToolbar();
 
 
 
 
 
 
681
  $toolbar->add();
682
  }
683
 
@@ -721,6 +731,27 @@ GNU General Public License for more details.
721
  $this->deleteCache(true);
722
  }
723
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
  public function delete_current_page_cache(){
725
  if(!wp_verify_nonce($_GET["nonce"], "wpfc")){
726
  die(json_encode(array("Security Error!", "error", "alert")));
@@ -843,6 +874,10 @@ GNU General Public License for more details.
843
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
844
  }
845
 
 
 
 
 
846
  if(is_multisite()){
847
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
848
  }
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.6
7
  Author: Emre Vona
8
  Author URI: http://tr.linkedin.com/in/emrevona
9
  Text Domain: wp-fastest-cache
99
  add_action('wp_ajax_wpfc_delete_cache', array($this, "deleteCacheToolbar"));
100
  add_action('wp_ajax_wpfc_delete_cache_and_minified', array($this, "deleteCssAndJsCacheToolbar"));
101
  add_action('wp_ajax_wpfc_delete_current_page_cache', array($this, "delete_current_page_cache"));
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'));
108
  add_action( 'wp_ajax_wpfc_cdn_options', array($this, 'wpfc_cdn_options_ajax_request_callback'));
681
  if(array_intersect($allowed_roles, $user->roles)){
682
  include_once plugin_dir_path(__FILE__)."inc/admin-toolbar.php";
683
 
684
+ if(preg_match("/\/cache\/all/", $this->getWpContentDir("/cache/all"))){
685
+ $is_multi = false;
686
+ }else{
687
+ $is_multi = true;
688
+ }
689
+
690
+ $toolbar = new WpFastestCacheAdminToolbar($is_multi);
691
  $toolbar->add();
692
  }
693
 
731
  $this->deleteCache(true);
732
  }
733
 
734
+ public function wpfc_clear_cache_of_allsites_callback(){
735
+ include_once('inc/cdn.php');
736
+ CdnWPFC::cloudflare_clear_cache();
737
+
738
+ $path = $this->getWpContentDir("/cache/*");
739
+
740
+ $files = glob($this->getWpContentDir("/cache/*"));
741
+
742
+ if(!is_dir($this->getWpContentDir("/cache/tmpWpfc"))){
743
+ if(@mkdir($this->getWpContentDir("/cache/tmpWpfc"), 0755, true)){
744
+ //tmpWpfc has been created
745
+ }
746
+ }
747
+
748
+ foreach ((array)$files as $file){
749
+ @rename($file, $this->getWpContentDir("/cache/tmpWpfc/").basename($file)."-".time());
750
+ }
751
+
752
+ die(json_encode(array("The cache of page has been cleared","success")));
753
+ }
754
+
755
  public function delete_current_page_cache(){
756
  if(!wp_verify_nonce($_GET["nonce"], "wpfc")){
757
  die(json_encode(array("Security Error!", "error", "alert")));
874
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
875
  }
876
 
877
+ if($this->isPluginActive('multiple-domain/multiple-domain.php')){
878
+ $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
879
+ }
880
+
881
  if(is_multisite()){
882
  $path = preg_replace("/\/cache\/(all|wpfc-minified|wpfc-widget-cache|wpfc-mobile-cache)/", "/cache/".$_SERVER['HTTP_HOST']."/$1", $path);
883
  }