Version Description
- to exclude the admins cookies for the cache automatically
- to clear the cache of category and tag after update
- refactoring of insertWebp()
- to exclude /cart automatically for eCommerce Shopping Cart by WP EasyCart
- to exclude /cart and /checkout automatically for Easy Digital Downloads
- to exclude /sitemap_index.xml automatically for Yoast SEO
- to decode path if it is not utf-8
- to fix problem on activation and deactivation
- to clear widget cache after publishing a new post
Download this release
Release Info
Developer | emrevona |
Plugin | WP Fastest Cache |
Version | 0.8.7.2 |
Comparing to | |
See all releases |
Code changes from version 0.8.7.1 to 0.8.7.2
- css/style.css +18 -0
- inc/admin.php +21 -14
- inc/cache.php +42 -5
- js/lang/ru.js +9 -1
- readme.txt +12 -1
- wpFastestCache.php +144 -56
css/style.css
CHANGED
@@ -539,4 +539,22 @@ span.deleteicon span.cleared {
|
|
539 |
position: relative;
|
540 |
width: 97%;
|
541 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
/* input[type=checkbox]:checked:before { color: #e14d43;} */
|
539 |
position: relative;
|
540 |
width: 97%;
|
541 |
}
|
542 |
+
.error-wpfc{
|
543 |
+
border-color: #D8000C !important;
|
544 |
+
color: #D8000C !important;
|
545 |
+
background: #FFBABA url("") no-repeat 10px !important;
|
546 |
+
}
|
547 |
+
.success-wpfc, .error-wpfc{
|
548 |
+
background-position: 10px center !important;
|
549 |
+
padding-bottom: 5px !important;
|
550 |
+
padding-top: 5px !important;
|
551 |
+
}
|
552 |
+
.success-wpfc{
|
553 |
+
border-color: #4F8A10 !important;
|
554 |
+
color: #4F8A10 !important;
|
555 |
+
background: #DFF2BF url("../images/success.png") no-repeat 10px !important;
|
556 |
+
}
|
557 |
+
.success-wpfc p, .error-wpfc p{
|
558 |
+
padding: 2px 2px 2px 0px !important;
|
559 |
+
}
|
560 |
/* input[type=checkbox]:checked:before { color: #e14d43;} */
|
inc/admin.php
CHANGED
@@ -392,12 +392,29 @@
|
|
392 |
}else{
|
393 |
$webp = false;
|
394 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
|
396 |
if($webp){
|
397 |
if(ABSPATH == "//"){
|
398 |
-
$RewriteCond = "RewriteCond %{DOCUMENT_ROOT}
|
399 |
}else{
|
400 |
-
$RewriteCond = "RewriteCond %{DOCUMENT_ROOT}
|
401 |
$RewriteCond = $RewriteCond."RewriteCond ".ABSPATH."$1.webp -f"."\n";
|
402 |
}
|
403 |
|
@@ -408,14 +425,10 @@
|
|
408 |
"RewriteCond %{HTTP_ACCEPT} image/webp"."\n".
|
409 |
"RewriteCond %{REQUEST_URI} \.(jpe?g|png)"."\n".
|
410 |
$RewriteCond.
|
411 |
-
"RewriteRule ^(.*) \"
|
412 |
"</IfModule>"."\n".
|
413 |
"<IfModule mod_headers.c>"."\n".
|
414 |
"Header append Vary Accept env=REDIRECT_accept"."\n".
|
415 |
-
"Header set Expires \"max-age=2592000, public\""."\n".
|
416 |
-
"Header unset ETag"."\n".
|
417 |
-
"Header set Connection keep-alive"."\n".
|
418 |
-
"FileETag None"."\n".
|
419 |
"</IfModule>"."\n".
|
420 |
"AddType image/webp .webp"."\n".
|
421 |
"# END WEBPWpFastestCache"."\n";
|
@@ -592,6 +605,7 @@
|
|
592 |
$this->ruleForWpContent()."\n".
|
593 |
$this->prefixRedirect().
|
594 |
$this->excludeRules()."\n".
|
|
|
595 |
$this->http_condition_rule()."\n".
|
596 |
"RewriteCond %{HTTP_USER_AGENT} !(".$this->get_excluded_useragent().")"."\n".
|
597 |
"RewriteCond %{REQUEST_METHOD} !POST"."\n".
|
@@ -2036,13 +2050,6 @@
|
|
2036 |
<h3>Having Issues?</h3>
|
2037 |
<ul>
|
2038 |
<li><label>You can create a ticket</label> <a target="_blank" href="http://wordpress.org/support/plugin/wp-fastest-cache"><label>WordPress support forum</label></a></li>
|
2039 |
-
<?php
|
2040 |
-
if(isset($this->options->wpFastestCacheLanguage) && $this->options->wpFastestCacheLanguage == "tr"){
|
2041 |
-
?>
|
2042 |
-
<li><label>R10 Üzerinden Sorabilirsiniz</label> <a target="_blank" href="http://www.r10.net/wordpress/1096868-wp-fastest-cache-wp-en-hizli-ve-en-basit-cache-sistemi.html"><label>R10.net destek başlığı</label></a></li>
|
2043 |
-
<?php
|
2044 |
-
}
|
2045 |
-
?>
|
2046 |
</ul>
|
2047 |
<?php } ?>
|
2048 |
</div>
|
392 |
}else{
|
393 |
$webp = false;
|
394 |
}
|
395 |
+
|
396 |
+
$basename = "$1.webp";
|
397 |
+
|
398 |
+
// this part for sub-directory installation
|
399 |
+
// site_url() and home_url() must be the same
|
400 |
+
if(preg_match("/https?\:\/\/[^\/]+\/(.+)/", site_url(), $siteurl_base_name)){
|
401 |
+
if(preg_match("/https?\:\/\/[^\/]+\/(.+)/", home_url(), $homeurl_base_name)){
|
402 |
+
$homeurl_base_name[1] = trim($homeurl_base_name[1], "/");
|
403 |
+
$siteurl_base_name[1] = trim($siteurl_base_name[1], "/");
|
404 |
+
|
405 |
+
if($homeurl_base_name[1] == $siteurl_base_name[1]){
|
406 |
+
if(preg_match("/".preg_quote($homeurl_base_name[1], "/")."$/", trim(ABSPATH, "/"))){
|
407 |
+
$basename = $homeurl_base_name[1]."/".$basename;
|
408 |
+
}
|
409 |
+
}
|
410 |
+
}
|
411 |
+
}
|
412 |
|
413 |
if($webp){
|
414 |
if(ABSPATH == "//"){
|
415 |
+
$RewriteCond = "RewriteCond %{DOCUMENT_ROOT}/".$basename." -f"."\n";
|
416 |
}else{
|
417 |
+
$RewriteCond = "RewriteCond %{DOCUMENT_ROOT}/".$basename." -f [or]"."\n";
|
418 |
$RewriteCond = $RewriteCond."RewriteCond ".ABSPATH."$1.webp -f"."\n";
|
419 |
}
|
420 |
|
425 |
"RewriteCond %{HTTP_ACCEPT} image/webp"."\n".
|
426 |
"RewriteCond %{REQUEST_URI} \.(jpe?g|png)"."\n".
|
427 |
$RewriteCond.
|
428 |
+
"RewriteRule ^(.*) \"/".$basename."\" [L]"."\n".
|
429 |
"</IfModule>"."\n".
|
430 |
"<IfModule mod_headers.c>"."\n".
|
431 |
"Header append Vary Accept env=REDIRECT_accept"."\n".
|
|
|
|
|
|
|
|
|
432 |
"</IfModule>"."\n".
|
433 |
"AddType image/webp .webp"."\n".
|
434 |
"# END WEBPWpFastestCache"."\n";
|
605 |
$this->ruleForWpContent()."\n".
|
606 |
$this->prefixRedirect().
|
607 |
$this->excludeRules()."\n".
|
608 |
+
$this->excludeAdminCookie()."\n".
|
609 |
$this->http_condition_rule()."\n".
|
610 |
"RewriteCond %{HTTP_USER_AGENT} !(".$this->get_excluded_useragent().")"."\n".
|
611 |
"RewriteCond %{REQUEST_METHOD} !POST"."\n".
|
2050 |
<h3>Having Issues?</h3>
|
2051 |
<ul>
|
2052 |
<li><label>You can create a ticket</label> <a target="_blank" href="http://wordpress.org/support/plugin/wp-fastest-cache"><label>WordPress support forum</label></a></li>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2053 |
</ul>
|
2054 |
<?php } ?>
|
2055 |
</div>
|
inc/cache.php
CHANGED
@@ -110,6 +110,11 @@
|
|
110 |
}
|
111 |
}
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
public function set_cdn(){
|
@@ -154,8 +159,8 @@
|
|
154 |
public function createCache(){
|
155 |
if(isset($this->options->wpFastestCacheStatus)){
|
156 |
|
|
|
157 |
if(isset($this->options->wpFastestCacheLoggedInUser) && $this->options->wpFastestCacheLoggedInUser == "on"){
|
158 |
-
// to check logged-in user
|
159 |
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
|
160 |
if(preg_match("/wordpress_logged_in/i", $cookie_key)){
|
161 |
ob_start(array($this, "cdn_rewrite"));
|
@@ -165,6 +170,20 @@
|
|
165 |
}
|
166 |
}
|
167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
168 |
// to check comment author
|
169 |
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
|
170 |
if(preg_match("/comment_author_/i", $cookie_key)){
|
@@ -308,6 +327,7 @@
|
|
308 |
$list = array(
|
309 |
"\/wp\-comments\-post\.php",
|
310 |
"\/sitemap\.xml",
|
|
|
311 |
"\/wp\-login\.php",
|
312 |
"\/robots\.txt",
|
313 |
"\/wp\-cron\.php",
|
@@ -342,6 +362,14 @@
|
|
342 |
array_push($list, "\/cart", "\/checkout", "\/receipt", "\/confirmation", "\/wc-api\/");
|
343 |
}
|
344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
if(preg_match("/".implode("|", $list)."/i", $_SERVER["REQUEST_URI"])){
|
346 |
return true;
|
347 |
}
|
@@ -568,8 +596,19 @@
|
|
568 |
|
569 |
|
570 |
if(isset($this->options->wpFastestCacheLazyLoad)){
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
if(!class_exists("WpFastestCacheLazyLoad")){
|
574 |
include_once $this->get_premium_path("lazy-load.php");
|
575 |
}
|
@@ -696,8 +735,6 @@
|
|
696 |
}
|
697 |
}
|
698 |
|
699 |
-
$cachFilePath = urldecode($cachFilePath);
|
700 |
-
|
701 |
if($create){
|
702 |
if (!is_user_logged_in() && !$this->isCommenter()){
|
703 |
if(!is_dir($cachFilePath)){
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
+
|
114 |
+
// to decode path if it is not utf-8
|
115 |
+
if($this->cacheFilePath){
|
116 |
+
$this->cacheFilePath = urldecode($this->cacheFilePath);
|
117 |
+
}
|
118 |
}
|
119 |
|
120 |
public function set_cdn(){
|
159 |
public function createCache(){
|
160 |
if(isset($this->options->wpFastestCacheStatus)){
|
161 |
|
162 |
+
// to check logged-in user
|
163 |
if(isset($this->options->wpFastestCacheLoggedInUser) && $this->options->wpFastestCacheLoggedInUser == "on"){
|
|
|
164 |
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
|
165 |
if(preg_match("/wordpress_logged_in/i", $cookie_key)){
|
166 |
ob_start(array($this, "cdn_rewrite"));
|
170 |
}
|
171 |
}
|
172 |
|
173 |
+
// to exclude admin users
|
174 |
+
$users_groups = get_users(array("role" => "administrator", "fields" => array("user_login")));
|
175 |
+
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
|
176 |
+
if(preg_match("/wordpress_logged_in/i", $cookie_key)){
|
177 |
+
foreach ($users_groups as $user_key => $user_value) {
|
178 |
+
if(preg_match("/^".preg_quote($user_value->user_login, "/")."/", $cookie_value)){
|
179 |
+
ob_start(array($this, "cdn_rewrite"));
|
180 |
+
|
181 |
+
return 0;
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
|
187 |
// to check comment author
|
188 |
foreach ((array)$_COOKIE as $cookie_key => $cookie_value){
|
189 |
if(preg_match("/comment_author_/i", $cookie_key)){
|
327 |
$list = array(
|
328 |
"\/wp\-comments\-post\.php",
|
329 |
"\/sitemap\.xml",
|
330 |
+
"\/sitemap_index\.xml",
|
331 |
"\/wp\-login\.php",
|
332 |
"\/robots\.txt",
|
333 |
"\/wp\-cron\.php",
|
362 |
array_push($list, "\/cart", "\/checkout", "\/receipt", "\/confirmation", "\/wc-api\/");
|
363 |
}
|
364 |
|
365 |
+
if($this->isPluginActive('wp-easycart/wpeasycart.php')){
|
366 |
+
array_push($list, "\/cart");
|
367 |
+
}
|
368 |
+
|
369 |
+
if($this->isPluginActive('easy-digital-downloads/easy-digital-downloads.php')){
|
370 |
+
array_push($list, "\/cart", "\/checkout");
|
371 |
+
}
|
372 |
+
|
373 |
if(preg_match("/".implode("|", $list)."/i", $_SERVER["REQUEST_URI"])){
|
374 |
return true;
|
375 |
}
|
596 |
|
597 |
|
598 |
if(isset($this->options->wpFastestCacheLazyLoad)){
|
599 |
+
$execute_lazy_load = true;
|
600 |
+
|
601 |
+
// to disable Lazy Load if the page is amp
|
602 |
+
if(preg_match("/<html[^\>]+amp[^\>]*>/i", $content)){
|
603 |
+
$execute_lazy_load = false;
|
604 |
+
}
|
605 |
+
|
606 |
+
// to disable for Ajax Load More on the pages
|
607 |
+
if($this->isPluginActive('ajax-load-more/ajax-load-more.php') && preg_match("/\/page\/\d+\//", $_SERVER["REQUEST_URI"])){
|
608 |
+
$execute_lazy_load = false;
|
609 |
+
}
|
610 |
+
|
611 |
+
if($execute_lazy_load){
|
612 |
if(!class_exists("WpFastestCacheLazyLoad")){
|
613 |
include_once $this->get_premium_path("lazy-load.php");
|
614 |
}
|
735 |
}
|
736 |
}
|
737 |
|
|
|
|
|
738 |
if($create){
|
739 |
if (!is_user_logged_in() && !$this->isCommenter()){
|
740 |
if(!is_dir($cachFilePath)){
|
js/lang/ru.js
CHANGED
@@ -139,7 +139,7 @@ window.wpfc.dictionary = {
|
|
139 |
"Optimize All" : "Оптимизировать все",
|
140 |
"CDN Settings" : "Настройки CDN",
|
141 |
"Render Blocking Js" : "Блокирующий JS",
|
142 |
-
"Remove render-blocking JavaScript" : "
|
143 |
"Only available in Premium version" : "Доступно только в премиум-версии",
|
144 |
"Update Post" : "Обновление записи",
|
145 |
"Clear cache files when a post or page is updated" : "Очищать кэш при обновлении записи или страницы",
|
@@ -156,4 +156,12 @@ window.wpfc.dictionary = {
|
|
156 |
"Home Page" : "Домашняя страница",
|
157 |
"Starts With" : "Начинается с",
|
158 |
"Is Equal To" : "Соответствует",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
};
|
139 |
"Optimize All" : "Оптимизировать все",
|
140 |
"CDN Settings" : "Настройки CDN",
|
141 |
"Render Blocking Js" : "Блокирующий JS",
|
142 |
+
"Remove render-blocking JavaScript" : "Удаляет код JavaScript, препятствующий отображению",
|
143 |
"Only available in Premium version" : "Доступно только в премиум-версии",
|
144 |
"Update Post" : "Обновление записи",
|
145 |
"Clear cache files when a post or page is updated" : "Очищать кэш при обновлении записи или страницы",
|
156 |
"Home Page" : "Домашняя страница",
|
157 |
"Starts With" : "Начинается с",
|
158 |
"Is Equal To" : "Соответствует",
|
159 |
+
"Widget Cache" : "Кэш виджетов",
|
160 |
+
"Reduce the number of SQL queries" : "Сокращает число SQL-запросов",
|
161 |
+
"Google Fonts" : "Шрифты Google",
|
162 |
+
"Load Google Fonts asynchronously" : "Асинхронная загрузка шрифтов Google",
|
163 |
+
"Cache Statistics" : "Статистика кэша",
|
164 |
+
"Exclude Cookies" : "Исключить куки",
|
165 |
+
"Database Cleanup" : "Очистка базы данных",
|
166 |
+
"" : "",
|
167 |
};
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: http://profiles.wordpress.org/emrevona/
|
|
4 |
Tags: cache, performance, wp-cache, total cache, super cache
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 4.8
|
7 |
-
Stable tag: 0.8.7.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -101,6 +101,17 @@ Wpfc does not support Wordpress Multisite yet.
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
= 0.8.7.1 =
|
105 |
* to fix image error on Structured Data Testing Tool when cdn is used
|
106 |
* to optimize the panel of wp fastest cache
|
4 |
Tags: cache, performance, wp-cache, total cache, super cache
|
5 |
Requires at least: 3.3
|
6 |
Tested up to: 4.8
|
7 |
+
Stable tag: 0.8.7.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= 0.8.7.2 =
|
105 |
+
* to exclude the admins cookies for the cache automatically
|
106 |
+
* to clear the cache of category and tag after update
|
107 |
+
* refactoring of insertWebp()
|
108 |
+
* to exclude /cart automatically for eCommerce Shopping Cart by WP EasyCart
|
109 |
+
* to exclude /cart and /checkout automatically for Easy Digital Downloads
|
110 |
+
* to exclude /sitemap_index.xml automatically for Yoast SEO
|
111 |
+
* to decode path if it is not utf-8
|
112 |
+
* to fix problem on activation and deactivation
|
113 |
+
* to clear widget cache after publishing a new post
|
114 |
+
|
115 |
= 0.8.7.1 =
|
116 |
* to fix image error on Structured Data Testing Tool when cdn is used
|
117 |
* to optimize the panel of wp fastest cache
|
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.8.7.
|
7 |
Author: Emre Vona
|
8 |
Author URI: http://tr.linkedin.com/in/emrevona
|
9 |
Text Domain: wp-fastest-cache
|
@@ -47,6 +47,40 @@ GNU General Public License for more details.
|
|
47 |
}
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
class WpFastestCache{
|
51 |
private $systemMessage = "";
|
52 |
private $options = array();
|
@@ -84,6 +118,13 @@ GNU General Public License for more details.
|
|
84 |
|
85 |
add_action( 'rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
// to check nonce is timeout or not
|
88 |
//add_action('init', array($this, "nonce_timeout"));
|
89 |
|
@@ -121,8 +162,6 @@ GNU General Public License for more details.
|
|
121 |
|
122 |
$this->checkCronTime();
|
123 |
|
124 |
-
register_activation_hook( __FILE__, array('WpFastestCache', 'activate'));
|
125 |
-
register_deactivation_hook( __FILE__, array('WpFastestCache', 'deactivate'));
|
126 |
register_uninstall_hook( __FILE__, array('WpFastestCache', 'uninstall'));
|
127 |
|
128 |
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
|
@@ -200,9 +239,13 @@ GNU General Public License for more details.
|
|
200 |
public function nonce_timeout(){
|
201 |
if(!is_user_logged_in()){
|
202 |
$run = false;
|
203 |
-
$list = array(
|
|
|
|
|
|
|
204 |
"kk-star-ratings/index.php",
|
205 |
-
"
|
|
|
206 |
);
|
207 |
|
208 |
foreach ($list as $key => $value) {
|
@@ -267,8 +310,8 @@ GNU General Public License for more details.
|
|
267 |
$statics["all_warnings"] = $statics["all_warnings"] + $wpdb->query( $element );
|
268 |
|
269 |
$element = "SELECT * FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;";
|
270 |
-
$statics["transient_options"] = $wpdb->query( $element );
|
271 |
-
$statics["all_warnings"] = $statics["all_warnings"] + $
|
272 |
|
273 |
die(json_encode($statics));
|
274 |
}
|
@@ -732,38 +775,8 @@ GNU General Public License for more details.
|
|
732 |
$wpfc->createCache();
|
733 |
}
|
734 |
|
735 |
-
public function activate(){
|
736 |
-
if($options = get_option("WpFastestCache")){
|
737 |
-
$post = json_decode($options, true);
|
738 |
-
|
739 |
-
include_once('inc/admin.php');
|
740 |
-
$wpfc = new WpFastestCacheAdmin();
|
741 |
-
$wpfc->modifyHtaccess($post);
|
742 |
-
}
|
743 |
-
}
|
744 |
-
|
745 |
-
public function deactivate(){
|
746 |
-
$wpfc = new WpFastestCache();
|
747 |
-
$path = ABSPATH;
|
748 |
-
|
749 |
-
if($wpfc->is_subdirectory_install()){
|
750 |
-
$path = $wpfc->getABSPATH();
|
751 |
-
}
|
752 |
-
|
753 |
-
if(is_file($path.".htaccess") && is_writable($path.".htaccess")){
|
754 |
-
$htaccess = file_get_contents($path.".htaccess");
|
755 |
-
$htaccess = preg_replace("/#\s?BEGIN\s?WpFastestCache.*?#\s?END\s?WpFastestCache/s", "", $htaccess);
|
756 |
-
$htaccess = preg_replace("/#\s?BEGIN\s?GzipWpFastestCache.*?#\s?END\s?GzipWpFastestCache/s", "", $htaccess);
|
757 |
-
$htaccess = preg_replace("/#\s?BEGIN\s?LBCWpFastestCache.*?#\s?END\s?LBCWpFastestCache/s", "", $htaccess);
|
758 |
-
@file_put_contents($path.".htaccess", $htaccess);
|
759 |
-
}
|
760 |
-
|
761 |
-
$wpfc->deleteCache();
|
762 |
-
}
|
763 |
-
|
764 |
public function uninstall(){
|
765 |
-
|
766 |
-
$wpfc->deactivate();
|
767 |
|
768 |
// wp_clear_scheduled_hook("wp_fastest_cache");
|
769 |
// wp_clear_scheduled_hook("wp_fastest_cache_regular");
|
@@ -822,6 +835,22 @@ GNU General Public License for more details.
|
|
822 |
// }
|
823 |
// }
|
824 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
825 |
public function on_all_status_transitions($new_status, $old_status, $post) {
|
826 |
if ( ! wp_is_post_revision($post->ID) ){
|
827 |
if(isset($this->options->wpFastestCacheNewPost) && isset($this->options->wpFastestCacheStatus)){
|
@@ -831,8 +860,12 @@ GNU General Public License for more details.
|
|
831 |
$this->deleteCache();
|
832 |
}else if($this->options->wpFastestCacheNewPost_type == "homepage"){
|
833 |
$this->deleteHomePageCache();
|
|
|
834 |
//to clear category cache and tag cache
|
835 |
$this->singleDeleteCache(false, $post->ID);
|
|
|
|
|
|
|
836 |
}
|
837 |
}else{
|
838 |
$this->deleteCache();
|
@@ -919,19 +952,23 @@ GNU General Public License for more details.
|
|
919 |
$terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
|
920 |
|
921 |
foreach ($terms as $term_key => $term_val){
|
922 |
-
$
|
|
|
|
|
|
|
923 |
|
924 |
-
|
925 |
-
|
926 |
|
927 |
-
|
928 |
-
|
929 |
-
$path = trim($path, "/");
|
930 |
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
|
|
|
|
935 |
}
|
936 |
}
|
937 |
}
|
@@ -980,7 +1017,6 @@ GNU General Public License for more details.
|
|
980 |
|
981 |
$cache_path = $this->getWpContentDir()."/cache/all";
|
982 |
$minified_cache_path = $this->getWpContentDir()."/cache/wpfc-minified";
|
983 |
-
$widget_cache_path = $this->getWpContentDir()."/cache/wpfc-widget-cache";
|
984 |
|
985 |
if(class_exists("WpFcMobileCache")){
|
986 |
$wpfc_mobile = new WpFcMobileCache();
|
@@ -999,11 +1035,7 @@ GNU General Public License for more details.
|
|
999 |
}
|
1000 |
|
1001 |
//to clear widget cache path
|
1002 |
-
|
1003 |
-
if(@rename($widget_cache_path, $this->getWpContentDir()."/cache/tmpWpfc/w".time())){
|
1004 |
-
//DONE
|
1005 |
-
}
|
1006 |
-
}
|
1007 |
|
1008 |
if(is_dir($cache_path)){
|
1009 |
if(@rename($cache_path, $this->getWpContentDir()."/cache/tmpWpfc/".time())){
|
@@ -1378,7 +1410,9 @@ GNU General Public License for more details.
|
|
1378 |
}
|
1379 |
}
|
1380 |
|
1381 |
-
|
|
|
|
|
1382 |
}
|
1383 |
|
1384 |
public function wpfc_remote_get($url, $user_agent){
|
@@ -1446,6 +1480,57 @@ GNU General Public License for more details.
|
|
1446 |
}
|
1447 |
}
|
1448 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1449 |
public function excludeRules(){
|
1450 |
$htaccess_page_rules = "";
|
1451 |
$htaccess_page_useragent = "";
|
@@ -1458,6 +1543,9 @@ GNU General Public License for more details.
|
|
1458 |
foreach ($rules_std as $key => $value) {
|
1459 |
$value->type = isset($value->type) ? $value->type : "page";
|
1460 |
|
|
|
|
|
|
|
1461 |
if($value->type == "page"){
|
1462 |
if($value->prefix == "startwith"){
|
1463 |
$htaccess_page_rules = $htaccess_page_rules."RewriteCond %{REQUEST_URI} !^/".$value->content." [NC]\n";
|
@@ -1524,7 +1612,7 @@ GNU General Public License for more details.
|
|
1524 |
return true;
|
1525 |
}
|
1526 |
|
1527 |
-
|
1528 |
if(strlen(site_url()) > strlen(home_url())){
|
1529 |
return true;
|
1530 |
}
|
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.8.7.2
|
7 |
Author: Emre Vona
|
8 |
Author URI: http://tr.linkedin.com/in/emrevona
|
9 |
Text Domain: wp-fastest-cache
|
47 |
}
|
48 |
}
|
49 |
|
50 |
+
function wpfastestcache_activate(){
|
51 |
+
if($options = get_option("WpFastestCache")){
|
52 |
+
$post = json_decode($options, true);
|
53 |
+
|
54 |
+
include_once('inc/admin.php');
|
55 |
+
$wpfc = new WpFastestCacheAdmin();
|
56 |
+
$wpfc->modifyHtaccess($post);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
|
60 |
+
function wpfastestcache_deactivate(){
|
61 |
+
$wpfc = new WpFastestCache();
|
62 |
+
|
63 |
+
$path = ABSPATH;
|
64 |
+
|
65 |
+
if($wpfc->is_subdirectory_install()){
|
66 |
+
$path = $wpfc->getABSPATH();
|
67 |
+
}
|
68 |
+
|
69 |
+
if(is_file($path.".htaccess") && is_writable($path.".htaccess")){
|
70 |
+
$htaccess = file_get_contents($path.".htaccess");
|
71 |
+
$htaccess = preg_replace("/#\s?BEGIN\s?WpFastestCache.*?#\s?END\s?WpFastestCache/s", "", $htaccess);
|
72 |
+
$htaccess = preg_replace("/#\s?BEGIN\s?GzipWpFastestCache.*?#\s?END\s?GzipWpFastestCache/s", "", $htaccess);
|
73 |
+
$htaccess = preg_replace("/#\s?BEGIN\s?LBCWpFastestCache.*?#\s?END\s?LBCWpFastestCache/s", "", $htaccess);
|
74 |
+
$htaccess = preg_replace("/#\s?BEGIN\s?WEBPWpFastestCache.*?#\s?END\s?WEBPWpFastestCache/s", "", $htaccess);
|
75 |
+
@file_put_contents($path.".htaccess", $htaccess);
|
76 |
+
}
|
77 |
+
|
78 |
+
$wpfc->deleteCache();
|
79 |
+
}
|
80 |
+
|
81 |
+
register_activation_hook( __FILE__, "wpfastestcache_activate");
|
82 |
+
register_deactivation_hook( __FILE__, "wpfastestcache_deactivate");
|
83 |
+
|
84 |
class WpFastestCache{
|
85 |
private $systemMessage = "";
|
86 |
private $options = array();
|
118 |
|
119 |
add_action( 'rate_post', array($this, 'wp_postratings_clear_fastest_cache'), 10, 2);
|
120 |
|
121 |
+
|
122 |
+
add_action('user_register', array($this, 'modify_htaccess_for_new_user'), 10, 1);
|
123 |
+
add_action('profile_update', array($this, 'modify_htaccess_for_new_user'), 10, 1);
|
124 |
+
|
125 |
+
|
126 |
+
add_action('edit_terms', array($this, 'delete_cache_of_term'), 10, 1);
|
127 |
+
|
128 |
// to check nonce is timeout or not
|
129 |
//add_action('init', array($this, "nonce_timeout"));
|
130 |
|
162 |
|
163 |
$this->checkCronTime();
|
164 |
|
|
|
|
|
165 |
register_uninstall_hook( __FILE__, array('WpFastestCache', 'uninstall'));
|
166 |
|
167 |
if($this->isPluginActive("wp-fastest-cache-premium/wpFastestCachePremium.php")){
|
239 |
public function nonce_timeout(){
|
240 |
if(!is_user_logged_in()){
|
241 |
$run = false;
|
242 |
+
$list = array(
|
243 |
+
"caldera-forms/caldera-core.php",
|
244 |
+
"contact-form-7/wp-contact-form-7.php",
|
245 |
+
"js_composer/js_composer.php",
|
246 |
"kk-star-ratings/index.php",
|
247 |
+
"ninja-forms/ninja-forms.php",
|
248 |
+
"yet-another-stars-rating/yet-another-stars-rating.php"
|
249 |
);
|
250 |
|
251 |
foreach ($list as $key => $value) {
|
310 |
$statics["all_warnings"] = $statics["all_warnings"] + $wpdb->query( $element );
|
311 |
|
312 |
$element = "SELECT * FROM `$wpdb->options` WHERE option_name LIKE '%\_transient\_%' ;";
|
313 |
+
$statics["transient_options"] = $wpdb->query( $element ) > 20 ? $wpdb->query( $element ) : 0;
|
314 |
+
$statics["all_warnings"] = $statics["all_warnings"] + $statics["transient_options"];
|
315 |
|
316 |
die(json_encode($statics));
|
317 |
}
|
775 |
$wpfc->createCache();
|
776 |
}
|
777 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
778 |
public function uninstall(){
|
779 |
+
wpfastestcache_deactivate();
|
|
|
780 |
|
781 |
// wp_clear_scheduled_hook("wp_fastest_cache");
|
782 |
// wp_clear_scheduled_hook("wp_fastest_cache_regular");
|
835 |
// }
|
836 |
// }
|
837 |
|
838 |
+
public function deleteWidgetCache(){
|
839 |
+
$widget_cache_path = $this->getWpContentDir()."/cache/wpfc-widget-cache";
|
840 |
+
|
841 |
+
if(is_dir($widget_cache_path)){
|
842 |
+
if(!is_dir($this->getWpContentDir()."/cache/tmpWpfc")){
|
843 |
+
if(@mkdir($this->getWpContentDir()."/cache/tmpWpfc", 0755, true)){
|
844 |
+
//tmpWpfc has been created
|
845 |
+
}
|
846 |
+
}
|
847 |
+
|
848 |
+
if(@rename($widget_cache_path, $this->getWpContentDir()."/cache/tmpWpfc/w".time())){
|
849 |
+
//DONE
|
850 |
+
}
|
851 |
+
}
|
852 |
+
}
|
853 |
+
|
854 |
public function on_all_status_transitions($new_status, $old_status, $post) {
|
855 |
if ( ! wp_is_post_revision($post->ID) ){
|
856 |
if(isset($this->options->wpFastestCacheNewPost) && isset($this->options->wpFastestCacheStatus)){
|
860 |
$this->deleteCache();
|
861 |
}else if($this->options->wpFastestCacheNewPost_type == "homepage"){
|
862 |
$this->deleteHomePageCache();
|
863 |
+
|
864 |
//to clear category cache and tag cache
|
865 |
$this->singleDeleteCache(false, $post->ID);
|
866 |
+
|
867 |
+
//to clear widget cache
|
868 |
+
$this->deleteWidgetCache();
|
869 |
}
|
870 |
}else{
|
871 |
$this->deleteCache();
|
952 |
$terms = $wpdb->get_results("SELECT * FROM `".$wpdb->prefix."term_relationships` WHERE `object_id`=".$post_id, ARRAY_A);
|
953 |
|
954 |
foreach ($terms as $term_key => $term_val){
|
955 |
+
$this->delete_cache_of_term($term_val["term_taxonomy_id"]);
|
956 |
+
}
|
957 |
+
}
|
958 |
+
}
|
959 |
|
960 |
+
public function delete_cache_of_term($term_id){
|
961 |
+
$term = get_term($term_id);
|
962 |
|
963 |
+
if(preg_match("/cat|tag/", $term->taxonomy)){
|
964 |
+
$url = get_term_link($term->term_id, $term->taxonomy);
|
|
|
965 |
|
966 |
+
if(preg_match("/^http/", $url)){
|
967 |
+
$path = preg_replace("/https?\:\/\/[^\/]+/i", "", $url);
|
968 |
+
$path = trim($path, "/");
|
969 |
+
|
970 |
+
@unlink($this->getWpContentDir()."/cache/all/".$path."/index.html");
|
971 |
+
@unlink($this->getWpContentDir()."/cache/wpfc-mobile-cache/".$path."/index.html");
|
972 |
}
|
973 |
}
|
974 |
}
|
1017 |
|
1018 |
$cache_path = $this->getWpContentDir()."/cache/all";
|
1019 |
$minified_cache_path = $this->getWpContentDir()."/cache/wpfc-minified";
|
|
|
1020 |
|
1021 |
if(class_exists("WpFcMobileCache")){
|
1022 |
$wpfc_mobile = new WpFcMobileCache();
|
1035 |
}
|
1036 |
|
1037 |
//to clear widget cache path
|
1038 |
+
$this->deleteWidgetCache();
|
|
|
|
|
|
|
|
|
1039 |
|
1040 |
if(is_dir($cache_path)){
|
1041 |
if(@rename($cache_path, $this->getWpContentDir()."/cache/tmpWpfc/".time())){
|
1410 |
}
|
1411 |
}
|
1412 |
|
1413 |
+
if(isset($_GET) && isset($_GET["type"]) && $_GET["type"] == "preload"){
|
1414 |
+
die();
|
1415 |
+
}
|
1416 |
}
|
1417 |
|
1418 |
public function wpfc_remote_get($url, $user_agent){
|
1480 |
}
|
1481 |
}
|
1482 |
|
1483 |
+
public function modify_htaccess_for_new_user($user_id){
|
1484 |
+
$path = ABSPATH;
|
1485 |
+
|
1486 |
+
if($this->is_subdirectory_install()){
|
1487 |
+
$path = $this->getABSPATH();
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
$htaccess = @file_get_contents($path.".htaccess");
|
1491 |
+
|
1492 |
+
if(preg_match("/\#\s?Start_WPFC_Exclude_Admin_Cookie/", $htaccess)){
|
1493 |
+
$rules = $this->excludeAdminCookie();
|
1494 |
+
|
1495 |
+
$htaccess = preg_replace("/\#\s?Start_WPFC_Exclude_Admin_Cookie[^\#]*\#\s?End_WPFC_Exclude_Admin_Cookie\s+/", $rules, $htaccess);
|
1496 |
+
}
|
1497 |
+
|
1498 |
+
@file_put_contents($path.".htaccess", $htaccess);
|
1499 |
+
}
|
1500 |
+
|
1501 |
+
public function excludeAdminCookie(){
|
1502 |
+
$rules = "";
|
1503 |
+
$users_groups = array_chunk(get_users(array("role" => "administrator", "fields" => array("user_login"))), 5);
|
1504 |
+
|
1505 |
+
foreach ($users_groups as $group_key => $group) {
|
1506 |
+
$tmp_users = "";
|
1507 |
+
$tmp_rule = "";
|
1508 |
+
|
1509 |
+
foreach ($group as $key => $value) {
|
1510 |
+
if($tmp_users){
|
1511 |
+
$tmp_users = $tmp_users."|".sanitize_user(wp_unslash($value->user_login), true);
|
1512 |
+
}else{
|
1513 |
+
$tmp_users = sanitize_user(wp_unslash($value->user_login), true);
|
1514 |
+
}
|
1515 |
+
|
1516 |
+
// to replace spaces with \s
|
1517 |
+
$tmp_users = preg_replace("/\s/", "\s", $tmp_users);
|
1518 |
+
|
1519 |
+
if(!next($group)){
|
1520 |
+
$tmp_rule = "RewriteCond %{HTTP:Cookie} !wordpress_logged_in_[^\=]+\=".$tmp_users;
|
1521 |
+
}
|
1522 |
+
}
|
1523 |
+
|
1524 |
+
if($rules){
|
1525 |
+
$rules = $rules."\n".$tmp_rule;
|
1526 |
+
}else{
|
1527 |
+
$rules = $tmp_rule;
|
1528 |
+
}
|
1529 |
+
}
|
1530 |
+
|
1531 |
+
return "# Start_WPFC_Exclude_Admin_Cookie\n".$rules."\n# End_WPFC_Exclude_Admin_Cookie\n";
|
1532 |
+
}
|
1533 |
+
|
1534 |
public function excludeRules(){
|
1535 |
$htaccess_page_rules = "";
|
1536 |
$htaccess_page_useragent = "";
|
1543 |
foreach ($rules_std as $key => $value) {
|
1544 |
$value->type = isset($value->type) ? $value->type : "page";
|
1545 |
|
1546 |
+
// escape the chars
|
1547 |
+
$value->content = str_replace("?", "\?", $value->content);
|
1548 |
+
|
1549 |
if($value->type == "page"){
|
1550 |
if($value->prefix == "startwith"){
|
1551 |
$htaccess_page_rules = $htaccess_page_rules."RewriteCond %{REQUEST_URI} !^/".$value->content." [NC]\n";
|
1612 |
return true;
|
1613 |
}
|
1614 |
|
1615 |
+
public function is_subdirectory_install(){
|
1616 |
if(strlen(site_url()) > strlen(home_url())){
|
1617 |
return true;
|
1618 |
}
|