Version Description
- October 6 2017 =
- [BUGFIX] Improved optimizer table creating process in certain database charset to avoid css/js minify/combination failure.
Download this release
Release Info
Developer | LiteSpeedTech |
Plugin | LiteSpeed Cache |
Version | 1.3.1.1 |
Comparing to | |
See all releases |
Code changes from version 1.2.3.1 to 1.3.1.1
- admin/img/icons/purge-front.svg +0 -32
- admin/litespeed-cache-admin-display.class.php +8 -59
- admin/litespeed-cache-admin-optimize.class.php +1 -1
- admin/litespeed-cache-admin-rules.class.php +162 -185
- admin/litespeed-cache-admin-settings.class.php +538 -579
- admin/litespeed-cache-admin.class.php +2 -2
- admin/tpl/crawler.php +5 -5
- admin/tpl/edit_htaccess.php +1 -1
- admin/tpl/info_faqs.php +1 -1
- admin/tpl/manage.php +1 -1
- admin/tpl/manage_purge.php +1 -1
- admin/tpl/network_settings.php +1 -1
- admin/tpl/network_settings_cache.php +1 -0
- admin/tpl/network_settings_excludes.php +8 -4
- admin/tpl/settings.php +2 -3
- admin/tpl/settings_advanced.php +1 -1
- admin/tpl/settings_cache.php +22 -0
- admin/tpl/settings_debug.php +1 -12
- admin/tpl/settings_excludes.php +107 -102
- admin/tpl/settings_inc.cache_browser.php +19 -0
- admin/tpl/settings_inc.cache_favicon.php +4 -0
- admin/tpl/settings_inc.cache_mobile.php +22 -30
- admin/tpl/settings_inc.cache_resources.php +4 -0
- admin/tpl/settings_inc.exclude_cookies.php +23 -19
- admin/tpl/settings_inc.exclude_useragent.php +20 -20
- admin/tpl/settings_inc.purge_on_upgrade.php +1 -1
- admin/tpl/settings_optimize.php +64 -0
- cli/litespeed-cache-cli-admin.class.php +12 -2
- cli/litespeed-cache-cli-purge.class.php +1 -2
- {admin/css → css}/fonts/litespeedfont.eot +0 -0
- {admin/css → css}/fonts/litespeedfont.svg +0 -0
- {admin/css → css}/fonts/litespeedfont.ttf +0 -0
- {admin/css → css}/fonts/litespeedfont.woff +0 -0
- {admin/css → css}/litespeed.css +13 -2
- {admin/img → img}/Litespeed.icon.svg +0 -0
- {admin/img → img}/icons/all.svg +0 -0
- {admin/img → img}/icons/all_transients.svg +0 -0
- {admin/img → img}/icons/auto_draft.svg +0 -0
- {admin/img → img}/icons/cross_icon.svg +0 -0
- {admin/img → img}/icons/db.svg +0 -0
- {admin/img → img}/icons/empty-cache.svg +0 -0
- {admin/img → img}/icons/expired_transient.svg +0 -0
- {admin/img → img}/icons/optimize_tables.svg +0 -0
- {admin/img → img}/icons/purge-403.svg +0 -0
- {admin/img → img}/icons/purge-404.svg +0 -0
- {admin/img → img}/icons/purge-500.svg +0 -0
- {admin/img → img}/icons/purge-all.svg +0 -0
- {admin/img → img}/icons/purge-cssjs.svg +0 -0
- img/icons/purge-front.svg +31 -0
- {admin/img → img}/icons/purge-pages.svg +0 -0
- {admin/img → img}/icons/revision.svg +0 -0
- {admin/img → img}/icons/spam_comment.svg +0 -0
- {admin/img → img}/icons/success_icon.svg +0 -0
- {admin/img → img}/icons/trackback-pingback.svg +0 -0
- {admin/img → img}/icons/trash_comment.svg +0 -0
- {admin/img → img}/icons/trash_post.svg +0 -0
- inc/data.class.php +177 -0
- includes/litespeed-cache-activation.class.php +47 -57
- includes/litespeed-cache-api.class.php +43 -2
- includes/litespeed-cache-cdn.class.php +15 -3
- includes/litespeed-cache-config.class.php +156 -125
- includes/litespeed-cache-control.class.php +64 -65
- includes/litespeed-cache-crawler-sitemap.class.php +6 -7
- includes/litespeed-cache-crawler.class.php +7 -7
- includes/litespeed-cache-esi.class.php +24 -15
- includes/litespeed-cache-gui.class.php +116 -0
- includes/litespeed-cache-log.class.php +7 -7
- includes/litespeed-cache-optimize.class.php +383 -58
- includes/litespeed-cache-purge.class.php +20 -1
- includes/litespeed-cache-router.class.php +9 -73
- includes/litespeed-cache-task.class.php +20 -20
- includes/litespeed-cache-utility.class.php +193 -9
- includes/litespeed-cache-vary.class.php +8 -4
- includes/litespeed-cache.class.php +84 -34
- includes/litespeed.autoload.php +3 -0
- js/css_async.js +4 -0
- {admin/js → js}/litespeed-cache-admin.js +5 -0
- languages/litespeed-cache.pot +235 -151
- lib/litespeed-php-compatibility.func.php +11 -11
- lib/litespeed/litespeed-string.class.php +70 -0
- litespeed-cache.php +19 -10
- readme.txt +68 -11
- thirdparty/lscwp-3rd-nextgengallery.cls.php +1 -1
- thirdparty/lscwp-3rd-woocommerce.cls.php +2 -2
- thirdparty/lscwp-3rd-yith-wishlist.cls.php +1 -1
admin/img/icons/purge-front.svg
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?xml version="1.0" encoding="utf-8"?>
|
2 |
-
<!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
-
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4 |
-
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5 |
-
width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
|
6 |
-
<g>
|
7 |
-
<path fill="#6699CC" d="M63.657,12.237c-0.046-0.116-0.109-0.227-0.205-0.318L52.954,1.835c-0.028-0.027-0.065-0.039-0.097-0.062
|
8 |
-
c-0.06-0.043-0.115-0.089-0.186-0.117c-0.068-0.027-0.143-0.034-0.215-0.043c-0.037-0.005-0.07-0.022-0.109-0.022H52.33h-0.001
|
9 |
-
H14.114c-1.577,0-2.86,1.283-2.86,2.859v66.923c0,1.577,1.283,2.859,2.86,2.859h46.773c1.575,0,2.858-1.282,2.858-2.859V12.608
|
10 |
-
C63.746,12.474,63.711,12.351,63.657,12.237z M53.223,4.52l7.51,7.213h-7.395c-0.064,0-0.115-0.052-0.115-0.118V4.52z
|
11 |
-
M61.996,71.373c0,0.611-0.498,1.109-1.109,1.109H14.114c-0.612,0-1.11-0.498-1.11-1.109V4.45c0-0.612,0.498-1.109,1.11-1.109
|
12 |
-
h37.359v8.274c0,1.03,0.836,1.868,1.864,1.868h8.658L61.996,71.373L61.996,71.373z"/>
|
13 |
-
<path fill="#6699CC" d="M45.43,44.486c-6.656,0-12.072,5.416-12.072,12.072S38.773,68.63,45.43,68.63
|
14 |
-
c6.655,0,12.071-5.415,12.071-12.071S52.085,44.486,45.43,44.486z M45.43,66.881c-5.691,0-10.322-4.63-10.322-10.32
|
15 |
-
c0-5.691,4.63-10.322,10.322-10.322c5.69,0,10.321,4.631,10.321,10.322C55.751,62.251,51.12,66.881,45.43,66.881z"/>
|
16 |
-
<path fill="#6699CC" d="M51.299,50.689c-0.342-0.342-0.896-0.342-1.238,0L45.43,55.32l-4.631-4.631
|
17 |
-
c-0.342-0.342-0.896-0.342-1.238,0c-0.34,0.342-0.34,0.896,0,1.237l4.631,4.632l-4.631,4.631c-0.34,0.342-0.34,0.896,0,1.237
|
18 |
-
c0.172,0.171,0.396,0.257,0.619,0.257s0.448-0.086,0.619-0.257l4.631-4.631l4.631,4.631c0.172,0.171,0.396,0.257,0.619,0.257
|
19 |
-
s0.448-0.086,0.619-0.257c0.342-0.342,0.342-0.896,0-1.237l-4.631-4.631l4.631-4.632C51.641,51.586,51.641,51.031,51.299,50.689z"
|
20 |
-
/>
|
21 |
-
<path fill="#6699CC" d="M19.826,18.879c0,0.483,0.392,0.875,0.875,0.875h33.598c0.483,0,0.875-0.392,0.875-0.875
|
22 |
-
s-0.392-0.875-0.875-0.875H20.701C20.218,18.004,19.826,18.396,19.826,18.879z"/>
|
23 |
-
<path fill="#6699CC" d="M20.701,29.511h33.598c0.483,0,0.875-0.392,0.875-0.875c0-0.483-0.392-0.875-0.875-0.875H20.701
|
24 |
-
c-0.483,0-0.875,0.392-0.875,0.875C19.826,29.119,20.218,29.511,20.701,29.511z"/>
|
25 |
-
<path fill="#6699CC" d="M20.701,39.27h33.598c0.483,0,0.875-0.393,0.875-0.875c0-0.483-0.392-0.875-0.875-0.875H20.701
|
26 |
-
c-0.483,0-0.875,0.392-0.875,0.875C19.826,38.877,20.218,39.27,20.701,39.27z"/>
|
27 |
-
<path fill="#6699CC" d="M30.125,47.275h-9.423c-0.483,0-0.875,0.393-0.875,0.875c0,0.483,0.392,0.875,0.875,0.875h9.423
|
28 |
-
c0.483,0,0.875-0.392,0.875-0.875C31,47.668,30.608,47.275,30.125,47.275z"/>
|
29 |
-
<path fill="#6699CC" d="M27.75,57.034h-7.049c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875h7.049
|
30 |
-
c0.483,0,0.875-0.392,0.875-0.875S28.233,57.034,27.75,57.034z"/>
|
31 |
-
</g>
|
32 |
-
</svg>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/litespeed-cache-admin-display.class.php
CHANGED
@@ -65,7 +65,7 @@ class LiteSpeed_Cache_Admin_Display
|
|
65 |
$manage = 'manage_options' ;
|
66 |
}
|
67 |
if ( current_user_can($manage) ) {
|
68 |
-
if (
|
69 |
add_action('wp_before_admin_bar_render', array($this, 'add_quick_purge')) ;
|
70 |
}
|
71 |
add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this cos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
|
@@ -97,7 +97,7 @@ class LiteSpeed_Cache_Admin_Display
|
|
97 |
// Admin footer
|
98 |
add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
|
99 |
|
100 |
-
if(
|
101 |
// Help tab
|
102 |
$this->add_help_tabs() ;
|
103 |
|
@@ -185,7 +185,7 @@ class LiteSpeed_Cache_Admin_Display
|
|
185 |
*/
|
186 |
public function enqueue_style()
|
187 |
{
|
188 |
-
wp_enqueue_style(LiteSpeed_Cache::PLUGIN_NAME,
|
189 |
}
|
190 |
|
191 |
/**
|
@@ -196,15 +196,15 @@ class LiteSpeed_Cache_Admin_Display
|
|
196 |
*/
|
197 |
public function enqueue_scripts()
|
198 |
{
|
199 |
-
wp_register_script(LiteSpeed_Cache::PLUGIN_NAME,
|
200 |
|
201 |
if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
|
202 |
-
$ajax_url_dismiss_whm =
|
203 |
wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_whm' => $ajax_url_dismiss_whm)) ;
|
204 |
}
|
205 |
|
206 |
if ( LiteSpeed_Cache_Router::has_msg_ruleconflict() ) {
|
207 |
-
$ajax_url =
|
208 |
wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_ruleconflict' => $ajax_url)) ;
|
209 |
}
|
210 |
|
@@ -278,7 +278,7 @@ class LiteSpeed_Cache_Admin_Display
|
|
278 |
public function add_quick_purge()
|
279 |
{
|
280 |
global $wp_admin_bar ;
|
281 |
-
$url =
|
282 |
|
283 |
$wp_admin_bar->add_node(array(
|
284 |
'id' => 'lscache-quick-purge',
|
@@ -288,57 +288,6 @@ class LiteSpeed_Cache_Admin_Display
|
|
288 |
)) ;
|
289 |
}
|
290 |
|
291 |
-
/**
|
292 |
-
* Builds an admin url with an action and a nonce.
|
293 |
-
*
|
294 |
-
* Assumes user capabilities are already checked.
|
295 |
-
*
|
296 |
-
* @access public
|
297 |
-
* @param string $action The LSCWP_CTRL action to do in the url.
|
298 |
-
* @param string $ajax_action AJAX call's action
|
299 |
-
* @param string $append_str The appending string to url
|
300 |
-
* @return string The built url.
|
301 |
-
*/
|
302 |
-
public static function build_url($action, $ajax_action = false, $append_str = false)
|
303 |
-
{
|
304 |
-
global $pagenow ;
|
305 |
-
$prefix = '?' ;
|
306 |
-
|
307 |
-
if ( $ajax_action === false ) {
|
308 |
-
$params = $_GET ;
|
309 |
-
|
310 |
-
if ( ! empty($params) ) {
|
311 |
-
if ( isset($params['LSCWP_CTRL']) ) {
|
312 |
-
unset($params['LSCWP_CTRL']) ;
|
313 |
-
}
|
314 |
-
if ( isset($params['_wpnonce']) ) {
|
315 |
-
unset($params['_wpnonce']) ;
|
316 |
-
}
|
317 |
-
if ( ! empty($params) ) {
|
318 |
-
$prefix .= http_build_query($params) . '&' ;
|
319 |
-
}
|
320 |
-
}
|
321 |
-
$combined = $pagenow . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
|
322 |
-
}
|
323 |
-
else {
|
324 |
-
$combined = 'admin-ajax.php?action=' . $ajax_action . '&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
|
325 |
-
}
|
326 |
-
|
327 |
-
if ( is_network_admin() ) {
|
328 |
-
$prenonce = network_admin_url($combined) ;
|
329 |
-
}
|
330 |
-
else {
|
331 |
-
$prenonce = admin_url($combined) ;
|
332 |
-
}
|
333 |
-
$url = wp_nonce_url($prenonce, $action, LiteSpeed_Cache::NONCE_NAME) ;
|
334 |
-
|
335 |
-
if ( $append_str ) {
|
336 |
-
$url .= '&' . $append_str ;
|
337 |
-
}
|
338 |
-
|
339 |
-
return $url ;
|
340 |
-
}
|
341 |
-
|
342 |
/**
|
343 |
* Change the admin footer text on LiteSpeed Cache admin pages.
|
344 |
*
|
@@ -408,7 +357,7 @@ class LiteSpeed_Cache_Admin_Display
|
|
408 |
*/
|
409 |
public function check_license()
|
410 |
{
|
411 |
-
if ( !
|
412 |
self::add_error(LiteSpeed_Cache_Admin_Error::E_SERVER) ;
|
413 |
self::display_messages() ;
|
414 |
}
|
65 |
$manage = 'manage_options' ;
|
66 |
}
|
67 |
if ( current_user_can($manage) ) {
|
68 |
+
if ( defined( 'LITESPEED_ON' ) ) {
|
69 |
add_action('wp_before_admin_bar_render', array($this, 'add_quick_purge')) ;
|
70 |
}
|
71 |
add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this cos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
|
97 |
// Admin footer
|
98 |
add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
|
99 |
|
100 |
+
if( defined( 'LITESPEED_ON' ) ) {
|
101 |
// Help tab
|
102 |
$this->add_help_tabs() ;
|
103 |
|
185 |
*/
|
186 |
public function enqueue_style()
|
187 |
{
|
188 |
+
wp_enqueue_style(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all') ;
|
189 |
}
|
190 |
|
191 |
/**
|
196 |
*/
|
197 |
public function enqueue_scripts()
|
198 |
{
|
199 |
+
wp_register_script(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false) ;
|
200 |
|
201 |
if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
|
202 |
+
$ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DISMISS_WHM, LiteSpeed_Cache::ACTION_DISMISS_WHM) ;
|
203 |
wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_whm' => $ajax_url_dismiss_whm)) ;
|
204 |
}
|
205 |
|
206 |
if ( LiteSpeed_Cache_Router::has_msg_ruleconflict() ) {
|
207 |
+
$ajax_url = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT, LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT) ;
|
208 |
wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', array('ajax_url_dismiss_ruleconflict' => $ajax_url)) ;
|
209 |
}
|
210 |
|
278 |
public function add_quick_purge()
|
279 |
{
|
280 |
global $wp_admin_bar ;
|
281 |
+
$url = LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_PURGE_ALL) ;
|
282 |
|
283 |
$wp_admin_bar->add_node(array(
|
284 |
'id' => 'lscache-quick-purge',
|
288 |
)) ;
|
289 |
}
|
290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
/**
|
292 |
* Change the admin footer text on LiteSpeed Cache admin pages.
|
293 |
*
|
357 |
*/
|
358 |
public function check_license()
|
359 |
{
|
360 |
+
if ( ! defined( 'LITESPEED_ALLOWED' ) ) {
|
361 |
self::add_error(LiteSpeed_Cache_Admin_Error::E_SERVER) ;
|
362 |
self::display_messages() ;
|
363 |
}
|
admin/litespeed-cache-admin-optimize.class.php
CHANGED
@@ -25,7 +25,7 @@ class LiteSpeed_Cache_Admin_Optimize
|
|
25 |
*/
|
26 |
public static function generate_url( $type )
|
27 |
{
|
28 |
-
$url =
|
29 |
return $url ;
|
30 |
}
|
31 |
|
25 |
*/
|
26 |
public static function generate_url( $type )
|
27 |
{
|
28 |
+
$url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DB_OPTIMIZE, false, self::TYPE . '=' . $type ) ;
|
29 |
return $url ;
|
30 |
}
|
31 |
|
admin/litespeed-cache-admin-rules.class.php
CHANGED
@@ -24,8 +24,6 @@ class LiteSpeed_Cache_Admin_Rules
|
|
24 |
private $theme_htaccess_readable = false ;
|
25 |
private $theme_htaccess_writable = false ;
|
26 |
|
27 |
-
private static $RW_LOOKUP ;
|
28 |
-
const RW_LOOKUP_PUBLIC = "CacheLookup Public on" ;
|
29 |
const RW_LOOKUP_BOTH = "CacheLookup on" ;
|
30 |
const RW_PRIV_BYPASS_POST_PURGE = "RewriteRule .* - [E=Cache-Control:no-autoflush]" ;
|
31 |
const RW_OPTM_NO_VARY = "RewriteRule min/\w+\.(css|js) - [E=cache-control:no-vary]" ;
|
@@ -42,6 +40,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
42 |
const MARKER_NOCACHE_USER_AGENTS = '### marker NOCACHE USER AGENTS' ;
|
43 |
const MARKER_CACHE_RESOURCE = '### marker CACHE RESOURCE' ;
|
44 |
const MARKER_FAVICON = '### marker FAVICON' ;
|
|
|
45 |
const MARKER_MINIFY = '### marker MINIFY' ;
|
46 |
const MARKER_START = ' start ###' ;
|
47 |
const MARKER_END = ' end ###' ;
|
@@ -67,13 +66,13 @@ class LiteSpeed_Cache_Admin_Rules
|
|
67 |
if ( is_writable($test_permissions) ) {
|
68 |
$this->frontend_htaccess_writable = true ;
|
69 |
}
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
self
|
75 |
-
|
76 |
-
|
77 |
|
78 |
// backend .htaccess privilege
|
79 |
if ( $this->frontend_htaccess === $this->backend_htaccess ) {
|
@@ -399,7 +398,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
399 |
*/
|
400 |
public function get_rewrite_rule_mobile_agents()
|
401 |
{
|
402 |
-
$rules = $this->
|
403 |
if( ! isset($rules[0]) ) {
|
404 |
LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, self::MARKER_MOBILE) ;
|
405 |
return false ;
|
@@ -426,7 +425,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
426 |
*/
|
427 |
public function get_rewrite_rule_login_cookie($kind = 'frontend')
|
428 |
{
|
429 |
-
$rule = $this->
|
430 |
if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
|
431 |
return false ;
|
432 |
}
|
@@ -440,7 +439,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
440 |
* @param string $kind Frontend or backend .htaccess file
|
441 |
* @return mixed Rules
|
442 |
*/
|
443 |
-
private function
|
444 |
{
|
445 |
clearstatcache() ;
|
446 |
$path = $this->htaccess_path($kind) ;
|
@@ -470,164 +469,68 @@ class LiteSpeed_Cache_Admin_Rules
|
|
470 |
}
|
471 |
|
472 |
/**
|
473 |
-
*
|
474 |
*
|
475 |
-
* @since
|
476 |
-
* @access
|
477 |
-
* @
|
478 |
-
* @param array $input The input
|
479 |
-
* @param array $errors Errors array to add error messages to.
|
480 |
-
* @return mixed False if there is an error, diff array otherwise.
|
481 |
*/
|
482 |
-
|
483 |
{
|
484 |
-
$
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
489 |
) ;
|
490 |
-
$
|
491 |
-
|
492 |
-
foreach ($opts as $opt) {
|
493 |
-
$input[$opt] = LiteSpeed_Cache_Admin_Settings::parse_onoff( $input, $opt ) ;
|
494 |
-
if ( $input[$opt] || $options[$opt] != $input[$opt] ) {
|
495 |
-
$diff[$opt] = $input[$opt] ;
|
496 |
-
}
|
497 |
-
}
|
498 |
-
|
499 |
-
// check mobile agents
|
500 |
-
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
|
501 |
-
if ( $input[LiteSpeed_Cache_Config::OPID_CACHE_MOBILE] ) {
|
502 |
-
$list = $input[$id] ;
|
503 |
-
if ( empty($list) || $this->check_rewrite($list) === false ) {
|
504 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array($id, empty($list) ? 'EMPTY' : esc_html($list))
|
505 |
-
) ;
|
506 |
-
$has_error = true ;
|
507 |
-
}
|
508 |
-
$diff[$id] = $list ;
|
509 |
-
}
|
510 |
-
elseif ( isset($diff[LiteSpeed_Cache_Config::OPID_CACHE_MOBILE]) ) {
|
511 |
-
$diff[$id] = false ;
|
512 |
-
}
|
513 |
-
|
514 |
-
$id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
|
515 |
-
if ( isset($input[$id]) && $input[$id] ) {
|
516 |
-
$cookie_list = preg_replace("/[\r\n]+/", '|', $input[$id]) ;
|
517 |
-
}
|
518 |
-
else {
|
519 |
-
$cookie_list = '' ;
|
520 |
-
}
|
521 |
-
|
522 |
-
if ( empty($cookie_list) || $this->check_rewrite($cookie_list) ) {
|
523 |
-
$diff[$id] = $cookie_list ;
|
524 |
-
}
|
525 |
-
else {
|
526 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array($id, esc_html($cookie_list))) ;
|
527 |
-
$has_error = true ;
|
528 |
-
}
|
529 |
-
|
530 |
-
$id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
|
531 |
-
if ( isset($input[$id]) && $this->check_rewrite($input[$id]) ) {
|
532 |
-
$diff[$id] = $input[$id] ;
|
533 |
-
}
|
534 |
-
else {
|
535 |
-
$err_args = array($id) ;
|
536 |
-
if ( ! isset($input[$id]) || empty($input[$id]) ) {
|
537 |
-
$err_args[] = 'EMPTY' ;
|
538 |
-
}
|
539 |
-
else {
|
540 |
-
$err_args[] = esc_html($input[$id]) ;
|
541 |
-
}
|
542 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, $err_args) ;
|
543 |
-
$has_error = true ;
|
544 |
-
}
|
545 |
-
|
546 |
-
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
|
547 |
-
$aExceptions = array('-', '_') ;
|
548 |
-
if ( isset($input[$id]) ) {
|
549 |
-
if ( $input[$id] === '' || (ctype_alnum(str_replace($aExceptions, '', $input[$id])) && $this->check_rewrite($input[$id])) ) {
|
550 |
-
$diff[$id] = $input[$id] ;
|
551 |
-
}
|
552 |
-
else {
|
553 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_LC, esc_html($input[$id])) ;
|
554 |
-
$has_error = true ;
|
555 |
-
}
|
556 |
-
}
|
557 |
-
|
558 |
-
if ( $has_error ) {
|
559 |
-
return false ;
|
560 |
-
}
|
561 |
-
return $diff ;
|
562 |
}
|
563 |
|
564 |
/**
|
565 |
-
*
|
566 |
*
|
567 |
-
*
|
568 |
-
* Starts with |
|
569 |
-
* Ends with |
|
570 |
-
* Double |
|
571 |
-
* Unescaped space
|
572 |
-
* Invalid character (NOT \w, -, \, |, \s, /, ., +, *, (, ))
|
573 |
-
*
|
574 |
-
* @since 1.0.9
|
575 |
* @access private
|
576 |
-
* @param
|
577 |
-
* @return
|
578 |
*/
|
579 |
-
private function
|
580 |
{
|
581 |
-
$escaped = str_replace('@', '\@', $rule) ;
|
582 |
-
return @preg_match('@' . $escaped . '@', null) !== false ;//todo: improve to try catch
|
583 |
-
}
|
584 |
-
|
585 |
-
/**
|
586 |
-
* Validate common rewrite rules configured by the admin.
|
587 |
-
*
|
588 |
-
* @since 1.0.4
|
589 |
-
* @access public
|
590 |
-
* @param array $diff The rules that need to be set.
|
591 |
-
* @param array $errors Returns error messages added if failed.
|
592 |
-
* @return mixed Returns updated options array on success, false otherwise.
|
593 |
-
*/
|
594 |
-
public function validate_common_rewrites($diff, &$errors)
|
595 |
-
{
|
596 |
-
if ( ! self::readable() ) {
|
597 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_HTA_R) ;
|
598 |
-
return false ;
|
599 |
-
}
|
600 |
-
|
601 |
-
if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
|
602 |
-
if ( ! self::readable('backend') ) {
|
603 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_HTA_R) ;
|
604 |
-
return false ;
|
605 |
-
}
|
606 |
-
}
|
607 |
-
|
608 |
-
// check login cookie
|
609 |
-
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
|
610 |
-
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
|
611 |
-
if ( $diff[$id] ) {
|
612 |
-
$diff[$id] .= ',wp-postpass_' . COOKIEHASH ;
|
613 |
-
}
|
614 |
-
else {
|
615 |
-
$diff[$id] = 'wp-postpass_' . COOKIEHASH ;
|
616 |
-
}
|
617 |
-
|
618 |
-
$tp_cookies = apply_filters('litespeed_cache_api_vary', array()) ;
|
619 |
-
if ( ! empty($tp_cookies) && is_array($tp_cookies) ) {
|
620 |
-
$diff[$id] .= ',' . implode(',', $tp_cookies) ;
|
621 |
-
}
|
622 |
-
}
|
623 |
-
|
624 |
$new_rules = array() ;
|
625 |
$new_rules_backend = array() ;
|
|
|
626 |
// mobile agents
|
627 |
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
|
628 |
-
if (
|
629 |
$new_rules[] = self::MARKER_MOBILE . self::MARKER_START ;
|
630 |
-
$new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $
|
631 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=ismobile]' ;
|
632 |
$new_rules[] = self::MARKER_MOBILE . self::MARKER_END ;
|
633 |
$new_rules[] = '' ;
|
@@ -635,9 +538,9 @@ class LiteSpeed_Cache_Admin_Rules
|
|
635 |
|
636 |
// nocache cookie
|
637 |
$id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
|
638 |
-
if (
|
639 |
$new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_START ;
|
640 |
-
$new_rules[] = 'RewriteCond %{HTTP_COOKIE} ' . $
|
641 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
|
642 |
$new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_END ;
|
643 |
$new_rules[] = '' ;
|
@@ -645,9 +548,9 @@ class LiteSpeed_Cache_Admin_Rules
|
|
645 |
|
646 |
// nocache user agents
|
647 |
$id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
|
648 |
-
if (
|
649 |
$new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_START ;
|
650 |
-
$new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $
|
651 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
|
652 |
$new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_END ;
|
653 |
$new_rules[] = '' ;
|
@@ -655,18 +558,31 @@ class LiteSpeed_Cache_Admin_Rules
|
|
655 |
|
656 |
// caching php resource
|
657 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_RES ;
|
658 |
-
if (
|
659 |
$new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_START ;
|
660 |
$new_rules[] = $new_rules_backend[] = 'RewriteRule ' . LSWCP_CONTENT_FOLDER . self::RW_PATTERN_RES . ' - [E=cache-control:max-age=3600]' ;
|
661 |
$new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_END ;
|
662 |
$new_rules[] = $new_rules_backend[] = '' ;
|
663 |
}
|
664 |
|
665 |
-
// login cookie
|
666 |
-
// frontend and backend
|
667 |
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
|
668 |
-
if (
|
669 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
|
671 |
$env = '"' . $env . '"' ;
|
672 |
}
|
@@ -679,27 +595,25 @@ class LiteSpeed_Cache_Admin_Rules
|
|
679 |
// favicon
|
680 |
// frontend and backend
|
681 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON ;
|
682 |
-
if (
|
683 |
$new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_START ;
|
684 |
$new_rules[] = $new_rules_backend[] = 'RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]' ;
|
685 |
$new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_END ;
|
686 |
$new_rules[] = '' ;
|
687 |
}
|
688 |
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
$
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_HTA_W) ;
|
698 |
-
$errors[] = $this->rewrite_codes_msg( $this->backend_htaccess, $new_rules ) ;
|
699 |
-
return false ;
|
700 |
-
}
|
701 |
}
|
702 |
-
|
|
|
|
|
703 |
}
|
704 |
|
705 |
/**
|
@@ -714,7 +628,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
714 |
{
|
715 |
return sprintf( __( '<p>Please add/replace the following codes into the beginning of %1$s:</p> %2$s' , 'litespeed-cache' ),
|
716 |
$file,
|
717 |
-
'<textarea style="width:100%;" rows="10" readonly>' . htmlspecialchars( $this->
|
718 |
) ;
|
719 |
}
|
720 |
|
@@ -725,14 +639,14 @@ class LiteSpeed_Cache_Admin_Rules
|
|
725 |
* @param array $rules
|
726 |
* @return array final rules data for htaccess
|
727 |
*/
|
728 |
-
private function
|
729 |
{
|
730 |
$marker = self::MARKER ;
|
731 |
$start_marker = "# BEGIN {$marker}" ;
|
732 |
$end_marker = "# END {$marker}" ;
|
733 |
$new_file_data = implode( "\n", array_merge(
|
734 |
array( $start_marker ),
|
735 |
-
$this->
|
736 |
array( $end_marker )
|
737 |
) ) ;
|
738 |
|
@@ -746,13 +660,13 @@ class LiteSpeed_Cache_Admin_Rules
|
|
746 |
* @param array $rules
|
747 |
* @return array wrapped rules with module info
|
748 |
*/
|
749 |
-
private function
|
750 |
{
|
751 |
if ( $rules !== false ) {
|
752 |
$rules = array_merge(
|
753 |
array(self::LS_MODULE_DONOTEDIT),
|
754 |
array(self::LS_MODULE_START),
|
755 |
-
|
756 |
array(''),
|
757 |
$rules,
|
758 |
array(self::LS_MODULE_END),
|
@@ -776,7 +690,71 @@ class LiteSpeed_Cache_Admin_Rules
|
|
776 |
return false ;
|
777 |
}
|
778 |
|
779 |
-
return Litespeed_File::insert_with_markers( $this->htaccess_path($kind), $this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
780 |
}
|
781 |
|
782 |
/**
|
@@ -788,7 +766,6 @@ class LiteSpeed_Cache_Admin_Rules
|
|
788 |
public function clear_rules( $clear_all = false )
|
789 |
{
|
790 |
$keep_wrapper = $clear_all === true ? false : array() ;
|
791 |
-
$this->deprecated_clear_rules() ;
|
792 |
$this->insert_wrapper( $keep_wrapper ) ;
|
793 |
if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
|
794 |
$this->insert_wrapper( $keep_wrapper, 'backend' ) ;
|
@@ -867,7 +844,7 @@ class LiteSpeed_Cache_Admin_Rules
|
|
867 |
*/
|
868 |
public static function get_instance()
|
869 |
{
|
870 |
-
if ( ! isset(self::$_instance) ) {
|
871 |
self::$_instance = new self() ;
|
872 |
}
|
873 |
|
24 |
private $theme_htaccess_readable = false ;
|
25 |
private $theme_htaccess_writable = false ;
|
26 |
|
|
|
|
|
27 |
const RW_LOOKUP_BOTH = "CacheLookup on" ;
|
28 |
const RW_PRIV_BYPASS_POST_PURGE = "RewriteRule .* - [E=Cache-Control:no-autoflush]" ;
|
29 |
const RW_OPTM_NO_VARY = "RewriteRule min/\w+\.(css|js) - [E=cache-control:no-vary]" ;
|
40 |
const MARKER_NOCACHE_USER_AGENTS = '### marker NOCACHE USER AGENTS' ;
|
41 |
const MARKER_CACHE_RESOURCE = '### marker CACHE RESOURCE' ;
|
42 |
const MARKER_FAVICON = '### marker FAVICON' ;
|
43 |
+
const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE' ;
|
44 |
const MARKER_MINIFY = '### marker MINIFY' ;
|
45 |
const MARKER_START = ' start ###' ;
|
46 |
const MARKER_END = ' end ###' ;
|
66 |
if ( is_writable($test_permissions) ) {
|
67 |
$this->frontend_htaccess_writable = true ;
|
68 |
}
|
69 |
+
|
70 |
+
self::$LS_MODULE_REWRITE_ON = array(
|
71 |
+
'RewriteEngine on',
|
72 |
+
self::RW_LOOKUP_BOTH,
|
73 |
+
self::RW_PRIV_BYPASS_POST_PURGE,
|
74 |
+
self::RW_OPTM_NO_VARY,
|
75 |
+
) ;
|
76 |
|
77 |
// backend .htaccess privilege
|
78 |
if ( $this->frontend_htaccess === $this->backend_htaccess ) {
|
398 |
*/
|
399 |
public function get_rewrite_rule_mobile_agents()
|
400 |
{
|
401 |
+
$rules = $this->_get_rule_by(self::MARKER_MOBILE) ;
|
402 |
if( ! isset($rules[0]) ) {
|
403 |
LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, self::MARKER_MOBILE) ;
|
404 |
return false ;
|
425 |
*/
|
426 |
public function get_rewrite_rule_login_cookie($kind = 'frontend')
|
427 |
{
|
428 |
+
$rule = $this->_get_rule_by(self::MARKER_LOGIN_COOKIE, $kind) ;
|
429 |
if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
|
430 |
return false ;
|
431 |
}
|
439 |
* @param string $kind Frontend or backend .htaccess file
|
440 |
* @return mixed Rules
|
441 |
*/
|
442 |
+
private function _get_rule_by($cond, $kind = 'frontend')
|
443 |
{
|
444 |
clearstatcache() ;
|
445 |
$path = $this->htaccess_path($kind) ;
|
469 |
}
|
470 |
|
471 |
/**
|
472 |
+
* Generate browser cache rules
|
473 |
*
|
474 |
+
* @since 1.3
|
475 |
+
* @access private
|
476 |
+
* @return array Rules set
|
|
|
|
|
|
|
477 |
*/
|
478 |
+
private function _browser_cache_rules()
|
479 |
{
|
480 |
+
$rules = array(
|
481 |
+
'<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
|
482 |
+
'<IfModule mod_expires.c>',
|
483 |
+
'ExpiresActive on',
|
484 |
+
'ExpiresByType application/pdf A2592000',
|
485 |
+
'ExpiresByType image/x-icon A2592000',
|
486 |
+
'ExpiresByType image/vnd.microsoft.icon A2592000',
|
487 |
+
'ExpiresByType image/svg+xml A2592000',
|
488 |
+
'',
|
489 |
+
'ExpiresByType image/jpg A2592000',
|
490 |
+
'ExpiresByType image/jpeg A2592000',
|
491 |
+
'ExpiresByType image/png A2592000',
|
492 |
+
'ExpiresByType image/gif A2592000',
|
493 |
+
'ExpiresByType image/webp A2592000',
|
494 |
+
'',
|
495 |
+
'ExpiresByType video/ogg A2592000',
|
496 |
+
'ExpiresByType audio/ogg A2592000',
|
497 |
+
'ExpiresByType video/mp4 A2592000',
|
498 |
+
'ExpiresByType video/webm A2592000',
|
499 |
+
'',
|
500 |
+
'ExpiresByType text/css A2592000',
|
501 |
+
'ExpiresByType text/javascript A2592000',
|
502 |
+
'ExpiresByType application/javascript A2592000',
|
503 |
+
'ExpiresByType application/x-javascript A2592000',
|
504 |
+
'',
|
505 |
+
'ExpiresByType application/x-font-ttf A2592000',
|
506 |
+
'ExpiresByType application/font-woff A2592000',
|
507 |
+
'ExpiresByType application/font-woff2 A2592000',
|
508 |
+
'ExpiresByType application/vnd.ms-fontobject A2592000',
|
509 |
+
'',
|
510 |
+
'</IfModule>',
|
511 |
+
'</FilesMatch>',
|
512 |
) ;
|
513 |
+
return $rules ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
}
|
515 |
|
516 |
/**
|
517 |
+
* Generate rewrite rules based on settings
|
518 |
*
|
519 |
+
* @since 1.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
520 |
* @access private
|
521 |
+
* @param array $cfg The settings to be used for rewrite rule
|
522 |
+
* @return array Rules array
|
523 |
*/
|
524 |
+
private function _generate_rules( $cfg )
|
525 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
526 |
$new_rules = array() ;
|
527 |
$new_rules_backend = array() ;
|
528 |
+
|
529 |
// mobile agents
|
530 |
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
|
531 |
+
if ( ! empty( $cfg[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) && ! empty( $cfg[ $id ] ) ) {
|
532 |
$new_rules[] = self::MARKER_MOBILE . self::MARKER_START ;
|
533 |
+
$new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] . ' [NC]' ;
|
534 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=ismobile]' ;
|
535 |
$new_rules[] = self::MARKER_MOBILE . self::MARKER_END ;
|
536 |
$new_rules[] = '' ;
|
538 |
|
539 |
// nocache cookie
|
540 |
$id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
|
541 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
542 |
$new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_START ;
|
543 |
+
$new_rules[] = 'RewriteCond %{HTTP_COOKIE} ' . $cfg[ $id ] ;
|
544 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
|
545 |
$new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_END ;
|
546 |
$new_rules[] = '' ;
|
548 |
|
549 |
// nocache user agents
|
550 |
$id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
|
551 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
552 |
$new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_START ;
|
553 |
+
$new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] ;
|
554 |
$new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
|
555 |
$new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_END ;
|
556 |
$new_rules[] = '' ;
|
558 |
|
559 |
// caching php resource
|
560 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_RES ;
|
561 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
562 |
$new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_START ;
|
563 |
$new_rules[] = $new_rules_backend[] = 'RewriteRule ' . LSWCP_CONTENT_FOLDER . self::RW_PATTERN_RES . ' - [E=cache-control:max-age=3600]' ;
|
564 |
$new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_END ;
|
565 |
$new_rules[] = $new_rules_backend[] = '' ;
|
566 |
}
|
567 |
|
568 |
+
// check login cookie
|
|
|
569 |
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
|
570 |
+
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
|
571 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
572 |
+
$cfg[ $id ] .= ',wp-postpass_' . COOKIEHASH ;
|
573 |
+
}
|
574 |
+
else {
|
575 |
+
$cfg[ $id ] = 'wp-postpass_' . COOKIEHASH ;
|
576 |
+
}
|
577 |
+
|
578 |
+
$tp_cookies = apply_filters( 'litespeed_cache_api_vary', array() ) ;
|
579 |
+
if ( ! empty( $tp_cookies ) && is_array( $tp_cookies ) ) {
|
580 |
+
$cfg[ $id ] .= ',' . implode( ',', $tp_cookies ) ;
|
581 |
+
}
|
582 |
+
}
|
583 |
+
// frontend and backend
|
584 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
585 |
+
$env = 'Cache-Vary:' . $cfg[ $id ] ;
|
586 |
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
|
587 |
$env = '"' . $env . '"' ;
|
588 |
}
|
595 |
// favicon
|
596 |
// frontend and backend
|
597 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON ;
|
598 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
599 |
$new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_START ;
|
600 |
$new_rules[] = $new_rules_backend[] = 'RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]' ;
|
601 |
$new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_END ;
|
602 |
$new_rules[] = '' ;
|
603 |
}
|
604 |
|
605 |
+
// Browser cache
|
606 |
+
$id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ;
|
607 |
+
if ( ! empty( $cfg[ $id ] ) ) {
|
608 |
+
$new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_START ;
|
609 |
+
$new_rules = array_merge( $new_rules, $this->_browser_cache_rules() ) ;
|
610 |
+
$new_rules_backend = array_merge( $new_rules_backend, $this->_browser_cache_rules() ) ;
|
611 |
+
$new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_END ;
|
612 |
+
$new_rules[] = '' ;
|
|
|
|
|
|
|
|
|
613 |
}
|
614 |
+
|
615 |
+
return array( $new_rules, $new_rules_backend ) ;
|
616 |
+
|
617 |
}
|
618 |
|
619 |
/**
|
628 |
{
|
629 |
return sprintf( __( '<p>Please add/replace the following codes into the beginning of %1$s:</p> %2$s' , 'litespeed-cache' ),
|
630 |
$file,
|
631 |
+
'<textarea style="width:100%;" rows="10" readonly>' . htmlspecialchars( $this->_wrap_rules_with_marker( $rules ) ) . '</textarea>'
|
632 |
) ;
|
633 |
}
|
634 |
|
639 |
* @param array $rules
|
640 |
* @return array final rules data for htaccess
|
641 |
*/
|
642 |
+
private function _wrap_rules_with_marker( $rules )
|
643 |
{
|
644 |
$marker = self::MARKER ;
|
645 |
$start_marker = "# BEGIN {$marker}" ;
|
646 |
$end_marker = "# END {$marker}" ;
|
647 |
$new_file_data = implode( "\n", array_merge(
|
648 |
array( $start_marker ),
|
649 |
+
$this->_wrap_rules($rules),
|
650 |
array( $end_marker )
|
651 |
) ) ;
|
652 |
|
660 |
* @param array $rules
|
661 |
* @return array wrapped rules with module info
|
662 |
*/
|
663 |
+
private function _wrap_rules( $rules )
|
664 |
{
|
665 |
if ( $rules !== false ) {
|
666 |
$rules = array_merge(
|
667 |
array(self::LS_MODULE_DONOTEDIT),
|
668 |
array(self::LS_MODULE_START),
|
669 |
+
self::$LS_MODULE_REWRITE_ON,
|
670 |
array(''),
|
671 |
$rules,
|
672 |
array(self::LS_MODULE_END),
|
690 |
return false ;
|
691 |
}
|
692 |
|
693 |
+
return Litespeed_File::insert_with_markers( $this->htaccess_path($kind), $this->_wrap_rules( $rules ), self::MARKER, true ) ;
|
694 |
+
}
|
695 |
+
|
696 |
+
/**
|
697 |
+
* Update rewrite rules based on setting
|
698 |
+
*
|
699 |
+
* @since 1.3
|
700 |
+
* @access public
|
701 |
+
* @param array $cfg The rules that need to be set.
|
702 |
+
*/
|
703 |
+
public function update( $cfg )
|
704 |
+
{
|
705 |
+
if ( ! LiteSpeed_Cache_Admin_Rules::readable() ) {
|
706 |
+
return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
|
707 |
+
}
|
708 |
+
|
709 |
+
if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
|
710 |
+
if ( ! LiteSpeed_Cache_Admin_Rules::readable( 'backend' ) ) {
|
711 |
+
return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
|
712 |
+
}
|
713 |
+
}
|
714 |
+
|
715 |
+
list( $frontend_rules, $backend_rules ) = $this->_generate_rules( $cfg ) ;
|
716 |
+
// Check frontend content
|
717 |
+
if ( $this->_wrap_rules( $frontend_rules ) != $this->extract_rules() ) {
|
718 |
+
// Need to update frontend htaccess
|
719 |
+
if ( ! $this->insert_wrapper( $frontend_rules ) ) {
|
720 |
+
$manual_guide_codes = $this->rewrite_codes_msg( $this->frontend_htaccess, $frontend_rules ) ;
|
721 |
+
return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
|
722 |
+
}
|
723 |
+
}
|
724 |
+
|
725 |
+
if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
|
726 |
+
// Check backend content
|
727 |
+
if ( $this->_wrap_rules( $backend_rules ) != $this->extract_rules( 'backend' ) ) {
|
728 |
+
// Need to update backend htaccess
|
729 |
+
if ( ! $this->insert_wrapper( $backend_rules, 'backend' ) ) {
|
730 |
+
$manual_guide_codes = $this->rewrite_codes_msg( $this->backend_htaccess, $backend_rules ) ;
|
731 |
+
return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
|
732 |
+
}
|
733 |
+
}
|
734 |
+
}
|
735 |
+
|
736 |
+
return true ;
|
737 |
+
}
|
738 |
+
|
739 |
+
/**
|
740 |
+
* Get existing rewrite rules
|
741 |
+
*
|
742 |
+
* @since 1.3
|
743 |
+
* @access public
|
744 |
+
* @param string $kind Frontend or backend .htaccess file
|
745 |
+
* @return bool|array False if failed to read, rules array otherwise
|
746 |
+
*/
|
747 |
+
public function extract_rules( $kind = 'frontend' )
|
748 |
+
{
|
749 |
+
clearstatcache() ;
|
750 |
+
$path = $this->htaccess_path( $kind ) ;
|
751 |
+
if ( ! self::readable( $kind ) ) {
|
752 |
+
return false ;
|
753 |
+
}
|
754 |
+
|
755 |
+
$rules = Litespeed_File::extract_from_markers( $path, self::MARKER ) ;
|
756 |
+
|
757 |
+
return $rules ;
|
758 |
}
|
759 |
|
760 |
/**
|
766 |
public function clear_rules( $clear_all = false )
|
767 |
{
|
768 |
$keep_wrapper = $clear_all === true ? false : array() ;
|
|
|
769 |
$this->insert_wrapper( $keep_wrapper ) ;
|
770 |
if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
|
771 |
$this->insert_wrapper( $keep_wrapper, 'backend' ) ;
|
844 |
*/
|
845 |
public static function get_instance()
|
846 |
{
|
847 |
+
if ( ! isset( self::$_instance ) ) {
|
848 |
self::$_instance = new self() ;
|
849 |
}
|
850 |
|
admin/litespeed-cache-admin-settings.class.php
CHANGED
@@ -12,223 +12,268 @@ class LiteSpeed_Cache_Admin_Settings
|
|
12 |
{
|
13 |
private static $_instance ;
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
*
|
19 |
-
* @since 1.0.12
|
20 |
-
* @access public
|
21 |
-
* @param array $input Input array
|
22 |
-
* @param string $id Option ID
|
23 |
-
* @param number $min Minimum number
|
24 |
-
* @param number $max Maximum number
|
25 |
-
* @return bool True if valid, false otherwise.
|
26 |
-
*/
|
27 |
-
public function validate_ttl( $input, $id, $min = false, $max = 2147483647)
|
28 |
-
{
|
29 |
-
if ( ! isset( $input[ $id ]) ) {
|
30 |
-
return false ;
|
31 |
-
}
|
32 |
|
33 |
-
|
34 |
|
35 |
-
|
36 |
-
$sval = strval( $val) ;
|
37 |
-
|
38 |
-
if( $min && $ival < $min ) {
|
39 |
-
return false ;
|
40 |
-
}
|
41 |
-
|
42 |
-
return ctype_digit( $sval) && $ival >= 0 && $ival < $max ;
|
43 |
-
}
|
44 |
|
45 |
/**
|
46 |
-
*
|
47 |
-
* This will only hook if there was a problem when saving the widget.
|
48 |
*
|
49 |
-
* @since
|
50 |
-
* @access
|
51 |
-
* @param string $location The location string.
|
52 |
-
* @return string the updated location string.
|
53 |
*/
|
54 |
-
|
55 |
{
|
56 |
-
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
-
*
|
61 |
-
* Validate the LiteSpeed Cache settings on edit widget save.
|
62 |
*
|
63 |
-
*
|
|
|
|
|
64 |
* @access public
|
65 |
-
* @param array $
|
66 |
-
* @
|
67 |
-
* @param array $old_instance The original settings.
|
68 |
-
* @param WP_Widget $widget The widget
|
69 |
-
* @return mixed Updated settings on success, false on error.
|
70 |
*/
|
71 |
-
public
|
72 |
{
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
76 |
-
$current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
|
77 |
-
$input = $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
|
78 |
-
$esistr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
|
79 |
-
$ttlstr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
-
|
87 |
-
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
92 |
}
|
93 |
|
94 |
-
if ( empty( $
|
95 |
-
|
|
|
|
|
96 |
}
|
97 |
-
$instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
|
98 |
-
$instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
|
99 |
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
}
|
103 |
-
|
104 |
-
|
|
|
|
|
105 |
}
|
106 |
|
107 |
-
|
108 |
-
|
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
-
* Validates the
|
113 |
*
|
114 |
* @since 1.0.12
|
115 |
* @access private
|
116 |
-
* @param array $input The input options.
|
117 |
-
* @param array $options The current options.
|
118 |
-
* @param array $errors The errors list.
|
119 |
*/
|
120 |
-
private function
|
121 |
{
|
122 |
-
$
|
123 |
-
$
|
124 |
-
|
125 |
-
//
|
126 |
-
$
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
if( $
|
134 |
-
|
135 |
-
|
136 |
-
else{
|
137 |
-
if ( is_multisite() ) {
|
138 |
-
$enabled = $options[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED] ;
|
139 |
}
|
140 |
-
else{
|
141 |
-
$
|
142 |
}
|
143 |
}
|
144 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
|
|
|
|
|
|
|
|
153 |
}
|
154 |
-
|
155 |
LiteSpeed_Cache_Purge::purge_all() ;
|
156 |
}
|
157 |
-
elseif ( $options[LiteSpeed_Cache_Config::OPID_CACHE_FAVICON] ) {
|
158 |
-
$options[LiteSpeed_Cache_Config::OPID_CACHE_FAVICON] = false ;
|
159 |
-
}
|
160 |
-
$input[ $id ] = 'changed' ;
|
161 |
-
}
|
162 |
-
else {
|
163 |
-
$input[ $id ] = $enabled ;
|
164 |
}
|
165 |
|
166 |
-
$id = LiteSpeed_Cache_Config::
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
$options[ $id ] = $input[ $id ] ;
|
172 |
}
|
173 |
|
174 |
-
$id = LiteSpeed_Cache_Config::
|
175 |
-
|
176 |
-
$errors[] = sprintf( $num_err, __( 'Default Private Cache', 'litespeed-cache' ), 60, 3600 ) ;
|
177 |
-
}
|
178 |
-
else {
|
179 |
-
$options[ $id ] = $input[ $id ] ;
|
180 |
-
}
|
181 |
|
182 |
-
$id = LiteSpeed_Cache_Config::
|
183 |
-
|
184 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
186 |
else {
|
187 |
-
|
|
|
188 |
}
|
189 |
|
190 |
-
$
|
191 |
-
|
192 |
-
|
193 |
-
}
|
194 |
-
elseif ( $input[ $id ] < 30 ) {
|
195 |
-
$options[ $id ] = 0 ;
|
196 |
-
}
|
197 |
-
else {
|
198 |
-
$options[ $id ] = intval( $input[ $id ]) ;
|
199 |
}
|
200 |
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
elseif ( $input[ $id ] < 30 ) {
|
206 |
-
$options[ $id ] = 0 ;
|
207 |
-
}
|
208 |
-
else {
|
209 |
-
$options[ $id ] = intval( $input[ $id ]) ;
|
210 |
-
}
|
211 |
|
212 |
-
|
213 |
-
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
-
|
217 |
-
|
|
|
|
|
|
|
218 |
}
|
219 |
else {
|
220 |
-
|
221 |
}
|
222 |
|
223 |
-
|
224 |
-
if (
|
225 |
-
|
226 |
-
}
|
227 |
-
elseif ( $input[ $id ] < 30 ) {
|
228 |
-
$options[ $id ] = 0 ;
|
229 |
}
|
230 |
-
|
231 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
}
|
233 |
|
234 |
}
|
@@ -238,25 +283,27 @@ class LiteSpeed_Cache_Admin_Settings
|
|
238 |
*
|
239 |
* @since 1.1.6
|
240 |
* @access private
|
241 |
-
* @param array $input The input options.
|
242 |
-
* @param array $options The current options.
|
243 |
-
* @param array $errors The errors list.
|
244 |
*/
|
245 |
-
private function
|
246 |
{
|
247 |
-
$
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
|
256 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ;
|
257 |
-
$
|
258 |
-
if( ! $
|
259 |
-
LiteSpeed_Cache_Purge::add(LiteSpeed_Cache_Tag::TYPE_LOGIN) ;
|
|
|
|
|
|
|
|
|
|
|
260 |
}
|
261 |
}
|
262 |
|
@@ -265,14 +312,11 @@ class LiteSpeed_Cache_Admin_Settings
|
|
265 |
*
|
266 |
* @since 1.0.12
|
267 |
* @access private
|
268 |
-
* @param array $input The input options.
|
269 |
-
* @param array $options The current options.
|
270 |
-
* @param array $errors The errors list.
|
271 |
*/
|
272 |
-
private function
|
273 |
{
|
274 |
$id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
|
275 |
-
$
|
276 |
|
277 |
// get auto purge rules options
|
278 |
$pvals = array(
|
@@ -289,39 +333,27 @@ class LiteSpeed_Cache_Admin_Settings
|
|
289 |
LiteSpeed_Cache_Config::PURGE_POST_TYPE,
|
290 |
) ;
|
291 |
$input_purge_options = array() ;
|
292 |
-
foreach ( $pvals as $
|
293 |
-
$input_name = 'purge_' . $
|
294 |
-
if ( self::parse_onoff( $
|
295 |
-
$input_purge_options[] = $
|
296 |
}
|
297 |
}
|
298 |
sort( $input_purge_options ) ;
|
299 |
$purge_by_post = implode( '.', $input_purge_options ) ;
|
300 |
-
if ( $purge_by_post !== $
|
301 |
-
$
|
302 |
}
|
303 |
|
304 |
// Filter scheduled purge URLs
|
305 |
$id = LiteSpeed_Cache_Config::OPID_TIMED_URLS ;
|
306 |
-
$
|
307 |
-
|
308 |
-
if ( ! empty( $input[ $id ] ) ) {
|
309 |
-
$list = array() ;
|
310 |
-
foreach ( explode( "\n", $input[ $id ] ) as $val ) {
|
311 |
-
$val = LiteSpeed_Cache_Utility::make_relative( $val ) ;
|
312 |
-
if ( $val ) {
|
313 |
-
$list[] = $val ;
|
314 |
-
}
|
315 |
-
}
|
316 |
-
if ( $list ) {
|
317 |
-
$options[ $id ] = implode( "\n", $list ) ;
|
318 |
-
}
|
319 |
-
}
|
320 |
}
|
321 |
|
322 |
// Schduled Purge Time
|
323 |
$id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ;
|
324 |
-
$
|
325 |
}
|
326 |
|
327 |
/**
|
@@ -329,61 +361,62 @@ class LiteSpeed_Cache_Admin_Settings
|
|
329 |
*
|
330 |
* @since 1.0.12
|
331 |
* @access private
|
332 |
-
* @param array $input The input options.
|
333 |
-
* @param array $options The current options.
|
334 |
-
* @param array $errors The errors list.
|
335 |
*/
|
336 |
-
private function
|
337 |
{
|
338 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ;
|
339 |
-
if ( isset( $
|
340 |
-
$
|
341 |
-
|
|
|
|
|
|
|
|
|
342 |
}
|
343 |
|
344 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT ;
|
345 |
-
$
|
346 |
-
if ( isset( $
|
347 |
$cat_ids = array() ;
|
348 |
-
$cats = explode("\n", $
|
349 |
-
foreach ( $cats as $cat) {
|
350 |
-
$cat_name = trim( $cat) ;
|
351 |
if ( $cat_name == '' ) {
|
352 |
continue ;
|
353 |
}
|
354 |
-
$cat_id = get_cat_ID( $cat_name) ;
|
355 |
if ( $cat_id == 0 ) {
|
356 |
-
$
|
357 |
}
|
358 |
else {
|
359 |
$cat_ids[] = $cat_id ;
|
360 |
}
|
361 |
}
|
362 |
-
if ( ! empty( $cat_ids) ) {
|
363 |
-
$
|
364 |
}
|
365 |
}
|
366 |
|
367 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG ;
|
368 |
-
$
|
369 |
-
if ( isset( $
|
370 |
$tag_ids = array() ;
|
371 |
-
$tags = explode("\n", $
|
372 |
-
foreach ( $tags as $tag) {
|
373 |
-
$tag_name = trim( $tag) ;
|
374 |
if ( $tag_name == '' ) {
|
375 |
continue ;
|
376 |
}
|
377 |
-
$term = get_term_by('name', $tag_name, 'post_tag') ;
|
378 |
if ( $term == 0 ) {
|
379 |
-
$
|
380 |
}
|
381 |
else {
|
382 |
$tag_ids[] = $term->term_id ;
|
383 |
}
|
384 |
}
|
385 |
-
if ( ! empty( $tag_ids) ) {
|
386 |
-
$
|
387 |
}
|
388 |
}
|
389 |
}
|
@@ -394,51 +427,46 @@ class LiteSpeed_Cache_Admin_Settings
|
|
394 |
* @since 1.2.2
|
395 |
* @access private
|
396 |
*/
|
397 |
-
private function
|
398 |
{
|
399 |
$ids = array(
|
400 |
LiteSpeed_Cache_Config::OPID_CDN,
|
401 |
LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
|
402 |
LiteSpeed_Cache_Config::OPID_CDN_INC_CSS,
|
403 |
LiteSpeed_Cache_Config::OPID_CDN_INC_JS,
|
404 |
-
);
|
405 |
foreach ( $ids as $id ) {
|
406 |
-
$
|
407 |
}
|
408 |
|
409 |
$id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
|
410 |
-
$
|
411 |
-
if ( $
|
412 |
-
$tmp = parse_url( $
|
413 |
if ( ! empty( $tmp[ 'scheme' ] ) ) {
|
414 |
-
$
|
415 |
}
|
416 |
}
|
417 |
|
418 |
$id = LiteSpeed_Cache_Config::OPID_CDN_URL ;
|
419 |
-
$
|
420 |
|
421 |
$ids = array(
|
422 |
LiteSpeed_Cache_Config::OPID_CDN_FILETYPE,
|
423 |
LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE,
|
424 |
) ;
|
425 |
foreach ( $ids as $id ) {
|
426 |
-
$
|
427 |
-
$options[ $id ] = array_map( 'trim', $options[ $id ] ) ;
|
428 |
-
$options[ $id ] = array_unique( $options[ $id ] ) ;
|
429 |
-
$options[ $id ] = array_filter( $options[ $id ] ) ;
|
430 |
-
$options[ $id ] = implode( "\n", $options[ $id ] ) ;
|
431 |
}
|
432 |
}
|
433 |
|
434 |
-
|
435 |
/**
|
436 |
* Validates the optimize settings.
|
437 |
*
|
438 |
* @since 1.2.2
|
439 |
* @access private
|
440 |
*/
|
441 |
-
private function
|
442 |
{
|
443 |
$ids = array(
|
444 |
LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
|
@@ -448,9 +476,14 @@ class LiteSpeed_Cache_Admin_Settings
|
|
448 |
LiteSpeed_Cache_Config::OPID_JS_COMBINE,
|
449 |
LiteSpeed_Cache_Config::OPID_JS_HTTP2,
|
450 |
LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
|
|
|
|
|
|
|
|
|
|
|
451 |
) ;
|
452 |
foreach ( $ids as $id ) {
|
453 |
-
$
|
454 |
}
|
455 |
|
456 |
$ids = array(
|
@@ -458,55 +491,17 @@ class LiteSpeed_Cache_Admin_Settings
|
|
458 |
LiteSpeed_Cache_Config::OPID_JS_EXCLUDES,
|
459 |
) ;
|
460 |
foreach ( $ids as $id ) {
|
461 |
-
$
|
462 |
-
$options[ $id ] = array_map( 'LiteSpeed_Cache_Utility::url2uri', $options[ $id ] ) ;
|
463 |
-
$options[ $id ] = array_unique( $options[ $id ] ) ;
|
464 |
-
$options[ $id ] = array_filter( $options[ $id ] ) ;
|
465 |
-
$options[ $id ] = implode( "\n", $options[ $id ] ) ;
|
466 |
}
|
467 |
|
468 |
$id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ;
|
469 |
-
if ( ! $this->
|
470 |
-
$
|
471 |
-
}
|
472 |
-
$options[ $id ] = $input[ $id ] ;
|
473 |
-
|
474 |
-
}
|
475 |
-
|
476 |
-
/**
|
477 |
-
* Validates the single site specific settings.
|
478 |
-
*
|
479 |
-
* @since 1.0.12
|
480 |
-
* @access private
|
481 |
-
* @param array $input The input options.
|
482 |
-
* @param array $options The current options.
|
483 |
-
* @param array $errors The errors list.
|
484 |
-
*/
|
485 |
-
private function validate_singlesite( $input, &$options, &$errors)
|
486 |
-
{
|
487 |
-
$rules = LiteSpeed_Cache_Admin_Rules::get_instance() ;
|
488 |
-
|
489 |
-
$id = LiteSpeed_Cache_Config::OPID_ENABLED ;
|
490 |
-
if ( $input[ $id ] !== 'changed' ) {
|
491 |
-
$diff = $rules->check_input_for_rewrite( $options, $input, $errors) ;
|
492 |
-
}
|
493 |
-
elseif ( $options[ $id ] ) {
|
494 |
-
$reset = LiteSpeed_Cache_Config::get_rule_reset_options() ;
|
495 |
-
$added_and_changed = $rules->check_input_for_rewrite( $reset, $input, $errors) ;
|
496 |
-
// Merge to include the newly disabled options
|
497 |
-
$diff = array_merge( $reset, $added_and_changed) ;
|
498 |
-
}
|
499 |
-
else {
|
500 |
-
$rules->clear_rules() ;
|
501 |
-
$diff = $rules->check_input_for_rewrite( $options, $input, $errors) ;
|
502 |
}
|
|
|
503 |
|
504 |
-
|
505 |
-
|
506 |
-
}
|
507 |
-
|
508 |
-
$id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
|
509 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
510 |
}
|
511 |
|
512 |
/**
|
@@ -514,104 +509,62 @@ class LiteSpeed_Cache_Admin_Settings
|
|
514 |
*
|
515 |
* @since 1.0.12
|
516 |
* @access private
|
517 |
-
* @param array $input The input options.
|
518 |
-
* @param array $options The current options.
|
519 |
-
* @param array $errors The errors list.
|
520 |
*/
|
521 |
-
private function
|
522 |
{
|
523 |
-
$num_err = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_NUMERIC) ;
|
524 |
-
|
525 |
$id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS ;
|
526 |
-
if ( isset( $
|
527 |
-
$admin_ips = array_map('trim', explode("\n", trim( $
|
528 |
-
$admin_ips = array_filter( $admin_ips) ;
|
529 |
$has_err = false ;
|
530 |
if ( $admin_ips ) {
|
531 |
-
foreach ( $admin_ips as $ip) {
|
532 |
-
if ( ! WP_Http::is_ip_address( $ip) ) {
|
533 |
-
$has_err = true ;
|
534 |
-
break ;
|
535 |
-
}
|
536 |
-
}
|
537 |
-
}
|
538 |
-
$admin_ips = implode("\n", $admin_ips) ;
|
539 |
-
|
540 |
-
if ( $has_err ) {
|
541 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_ADMIN_IP_INV) ;
|
542 |
-
}
|
543 |
-
elseif ( $admin_ips != $options[ $id ] ) {
|
544 |
-
$options[ $id ] = $admin_ips ;
|
545 |
-
}
|
546 |
-
}
|
547 |
-
|
548 |
-
$id = LiteSpeed_Cache_Config::OPID_TEST_IPS ;
|
549 |
-
if ( isset( $input[ $id ]) ) {
|
550 |
-
// this feature has not implemented yet
|
551 |
-
$test_ips = array_map('trim', explode("\n", trim( $input[ $id ]))) ;
|
552 |
-
$test_ips = array_filter( $test_ips) ;
|
553 |
-
$has_err = false ;
|
554 |
-
if ( $test_ips ) {
|
555 |
-
foreach ( $test_ips as $ip) {
|
556 |
-
if ( ! WP_Http::is_ip_address( $ip) ) {
|
557 |
$has_err = true ;
|
558 |
break ;
|
559 |
}
|
560 |
}
|
561 |
}
|
562 |
-
$
|
563 |
|
564 |
if ( $has_err ) {
|
565 |
-
$
|
566 |
}
|
567 |
-
|
568 |
-
$
|
569 |
}
|
570 |
}
|
571 |
|
572 |
$id = LiteSpeed_Cache_Config::OPID_DEBUG ;
|
573 |
-
$
|
574 |
-
if ( $debug_level != $options[ $id ] ){
|
575 |
-
$options[ $id ] = $debug_level ;
|
576 |
-
}
|
577 |
-
|
578 |
-
$id = LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL ;
|
579 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
580 |
|
581 |
$id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ;
|
582 |
-
if ( ! $this->
|
583 |
-
$
|
584 |
}
|
585 |
else {
|
586 |
-
$
|
587 |
}
|
588 |
|
589 |
-
$
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
$id = LiteSpeed_Cache_Config::OPID_LOG_FILTERS ;
|
599 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
600 |
-
|
601 |
-
$id = LiteSpeed_Cache_Config::OPID_LOG_IGNORE_FILTERS ;
|
602 |
-
if ( isset( $input[ $id ] ) ) {
|
603 |
-
$items = array_map( 'trim', explode( "\n", trim( $input[ $id ] ) ) ) ;
|
604 |
-
$items = implode( "\n", array_filter( $items ) ) ;
|
605 |
-
$options[ $id ] = $items ;
|
606 |
}
|
607 |
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
|
|
|
|
613 |
}
|
614 |
-
|
615 |
}
|
616 |
|
617 |
/**
|
@@ -619,116 +572,152 @@ class LiteSpeed_Cache_Admin_Settings
|
|
619 |
*
|
620 |
* @since 1.0.12
|
621 |
* @access private
|
622 |
-
* @param array $input The input options.
|
623 |
-
* @param array $options The current options.
|
624 |
-
* @param array $errors The errors list.
|
625 |
*/
|
626 |
-
private function
|
627 |
{
|
628 |
-
$
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
638 |
-
|
639 |
-
$id = LiteSpeed_Cache_Config::CRWL_TAGS ;
|
640 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
641 |
|
642 |
$id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
|
643 |
-
if ( isset( $
|
644 |
-
$arr = array_map('trim', explode("\n", $
|
645 |
-
$arr = array_filter( $arr) ;
|
646 |
-
$ori = array_diff(get_post_types( '', 'names' ), array('post', 'page')) ;
|
647 |
-
$
|
648 |
}
|
649 |
|
650 |
$id = LiteSpeed_Cache_Config::CRWL_ORDER_LINKS ;
|
651 |
-
if( ! isset( $
|
652 |
LiteSpeed_Cache_Config::CRWL_DATE_DESC,
|
653 |
LiteSpeed_Cache_Config::CRWL_DATE_ASC,
|
654 |
LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
|
655 |
LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
|
656 |
-
)
|
657 |
-
|
|
|
658 |
}
|
659 |
-
$
|
660 |
|
661 |
-
$
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
667 |
}
|
668 |
|
669 |
-
|
670 |
-
|
671 |
-
|
|
|
|
|
|
|
|
|
672 |
}
|
673 |
else {
|
674 |
-
$
|
675 |
}
|
676 |
|
677 |
-
$id = LiteSpeed_Cache_Config::
|
678 |
-
if ( ! $this->
|
679 |
-
$
|
680 |
}
|
681 |
else {
|
682 |
-
$
|
683 |
}
|
684 |
|
685 |
-
|
686 |
-
|
687 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
688 |
}
|
689 |
else {
|
690 |
-
$
|
691 |
}
|
692 |
|
693 |
-
|
694 |
-
|
695 |
-
|
|
|
|
|
696 |
}
|
697 |
else {
|
698 |
-
$
|
699 |
}
|
700 |
|
701 |
-
|
702 |
-
$
|
703 |
-
|
704 |
-
|
705 |
-
if ( ! empty( $input[ $id ]) && ! WP_Http::is_ip_address( $input[ $id ]) ) {
|
706 |
-
$errors[] = LiteSpeed_Cache_Admin_Display::get_error(LiteSpeed_Cache_Admin_Error::E_SETTING_SITE_IP, $input[ $id ]) ;
|
707 |
}
|
708 |
else {
|
709 |
-
$
|
710 |
}
|
711 |
|
712 |
-
|
713 |
-
|
714 |
-
|
|
|
715 |
}
|
716 |
else {
|
717 |
-
$
|
718 |
}
|
719 |
|
720 |
-
|
721 |
-
|
722 |
-
/**
|
723 |
-
* Validates the custom sitemap settings.
|
724 |
-
*
|
725 |
-
* @since 1.1.1
|
726 |
-
* @access private
|
727 |
-
* @param string $url The sitemap url
|
728 |
-
*/
|
729 |
-
private function validate_custom_sitemap( $url)
|
730 |
-
{
|
731 |
-
return LiteSpeed_Cache_Crawler::get_instance()->parse_custom_sitemap( $url, false) ;
|
732 |
}
|
733 |
|
734 |
/**
|
@@ -736,24 +725,23 @@ class LiteSpeed_Cache_Admin_Settings
|
|
736 |
*
|
737 |
* @since 1.0.12
|
738 |
* @access private
|
739 |
-
* @param array $input The input options.
|
740 |
-
* @param array $options The current options.
|
741 |
*/
|
742 |
-
private function
|
743 |
{
|
744 |
$tp_default_options = LiteSpeed_Cache_Config::get_instance()->get_thirdparty_options() ;
|
745 |
-
if ( empty( $tp_default_options) ) {
|
746 |
-
return
|
747 |
}
|
748 |
-
|
749 |
-
|
750 |
-
|
|
|
751 |
}
|
752 |
-
|
753 |
-
|
754 |
-
|
|
|
755 |
}
|
756 |
-
return $options ;
|
757 |
}
|
758 |
|
759 |
/**
|
@@ -761,185 +749,156 @@ class LiteSpeed_Cache_Admin_Settings
|
|
761 |
*
|
762 |
* @since 1.1.3
|
763 |
* @access private
|
764 |
-
* @param array $input The input options.
|
765 |
-
* @param array $options The current options.
|
766 |
-
* @param array $errors The errors list.
|
767 |
*/
|
768 |
-
private function
|
769 |
{
|
770 |
-
$
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
|
779 |
// Save vary group settings
|
780 |
$vary_groups = $_POST[ LiteSpeed_Cache_Config::VARY_GROUP ] ;
|
781 |
$vary_groups = array_map( 'trim', $vary_groups ) ;
|
782 |
$vary_groups = array_filter( $vary_groups ) ;
|
783 |
update_option( LiteSpeed_Cache_Config::VARY_GROUP, $vary_groups ) ;
|
784 |
-
|
785 |
}
|
786 |
|
787 |
/**
|
788 |
-
*
|
789 |
-
*
|
790 |
-
*
|
791 |
-
* NOTE: Anytime that validate_plugin_settings is called, `convert_options_to_input` must be done first if not from option page
|
792 |
*
|
793 |
-
* @since 1.
|
794 |
* @access public
|
795 |
-
* @param
|
796 |
-
*
|
797 |
-
* @return array The updated configuration options.
|
798 |
*/
|
799 |
-
public function
|
800 |
{
|
801 |
-
|
802 |
-
|
803 |
-
$errors = array() ;
|
804 |
-
|
805 |
-
if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
|
806 |
-
add_settings_error(LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, __('\'Use primary site settings\' set by Network Administrator.', 'litespeed-cache')) ;
|
807 |
|
808 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
809 |
}
|
|
|
|
|
|
|
|
|
810 |
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
$this->validate_purge( $input, $options, $errors) ;
|
816 |
-
|
817 |
-
$this->validate_exclude( $input, $options, $errors) ;
|
818 |
-
|
819 |
-
$this->validate_optimize( $input, $options, $errors) ;
|
820 |
-
|
821 |
-
$this->validate_cdn( $input, $options, $errors) ;
|
822 |
|
823 |
-
$
|
|
|
824 |
|
825 |
-
if (
|
826 |
-
|
|
|
827 |
}
|
828 |
|
829 |
-
if (
|
830 |
-
$
|
831 |
}
|
|
|
|
|
832 |
|
833 |
-
if (
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
$new_enabled = $options[LiteSpeed_Cache_Config::OPID_ENABLED] ;
|
840 |
-
$new_esi_enabled = $options[LiteSpeed_Cache_Config::OPID_ESI_ENABLE] ;
|
841 |
-
|
842 |
-
if ( $orig_enabled !== $new_enabled || $orig_esi_enabled !== $new_esi_enabled ) {
|
843 |
-
LiteSpeed_Cache_Purge::purge_all() ;
|
844 |
-
}
|
845 |
}
|
846 |
|
847 |
-
|
848 |
-
|
|
|
849 |
|
850 |
-
|
851 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
852 |
|
853 |
-
$
|
854 |
-
if ( LiteSpeed_Cache_Router::is_cli() ) {
|
855 |
-
$id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
|
856 |
-
$cron_val = $options[ $id ] ;
|
857 |
-
// assign crawler_cron_active to $options if exists in $input separately for CLI
|
858 |
-
// This has to be specified cos crawler cron activation is not set in admin setting page
|
859 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
860 |
-
if ( $cron_val != $options[ $id ] ) {
|
861 |
-
$cron_changed = true ;
|
862 |
-
}
|
863 |
-
}
|
864 |
|
865 |
-
|
866 |
-
|
867 |
-
|
|
|
|
|
|
|
868 |
}
|
869 |
|
870 |
-
|
871 |
|
872 |
-
return $
|
873 |
}
|
874 |
|
875 |
/**
|
876 |
-
*
|
877 |
*
|
878 |
-
* @since 1.0.
|
879 |
-
* @access
|
|
|
|
|
|
|
|
|
|
|
880 |
*/
|
881 |
-
|
882 |
{
|
883 |
-
|
884 |
-
|
885 |
-
$errors = array() ;
|
886 |
-
|
887 |
-
$id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
|
888 |
-
$network_enabled = self::parse_onoff( $input, $id ) ;
|
889 |
-
if ( $options[ $id ] != $network_enabled ) {
|
890 |
-
$options[ $id ] = $network_enabled ;
|
891 |
-
if ( $network_enabled ) {
|
892 |
-
$ret = LiteSpeed_Cache_Config::wp_cache_var_setter(true) ;
|
893 |
-
if ( $ret !== true ) {
|
894 |
-
$errors[] = $ret ;
|
895 |
-
}
|
896 |
-
}
|
897 |
-
else {
|
898 |
-
LiteSpeed_Cache_Purge::purge_all() ;
|
899 |
-
}
|
900 |
-
$input[ $id ] = 'changed' ;
|
901 |
-
$reset = LiteSpeed_Cache_Config::get_rule_reset_options() ;
|
902 |
-
}
|
903 |
-
|
904 |
-
$id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
|
905 |
-
$orig_primary = $options[ $id ] ;
|
906 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
907 |
-
if ( $orig_primary != $options[ $id ] ) {
|
908 |
-
LiteSpeed_Cache_Purge::purge_all() ;
|
909 |
}
|
910 |
|
911 |
-
$
|
912 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
913 |
-
|
914 |
-
$id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
|
915 |
-
$options[ $id ] = self::parse_onoff( $input, $id ) ;
|
916 |
|
917 |
-
$
|
|
|
918 |
|
919 |
-
if
|
920 |
-
|
921 |
-
}
|
922 |
-
elseif ( $network_enabled ) {
|
923 |
-
$added_and_changed = $rules->check_input_for_rewrite( $reset, $input, $errors) ;
|
924 |
-
// Merge to include the newly disabled options
|
925 |
-
$diff = array_merge( $reset, $added_and_changed) ;
|
926 |
-
}
|
927 |
-
else {
|
928 |
-
$rules->validate_common_rewrites( $reset, $errors) ;
|
929 |
-
$diff = $rules->check_input_for_rewrite( $options, $input, $errors) ;
|
930 |
}
|
931 |
|
932 |
-
if (
|
933 |
-
$
|
934 |
}
|
935 |
|
936 |
-
|
937 |
-
LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_RED, $errors) ;
|
938 |
-
return ;
|
939 |
-
}
|
940 |
-
LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __('File saved.', 'litespeed-cache')) ;
|
941 |
-
update_site_option(LiteSpeed_Cache_Config::OPTION_NAME, $options) ;
|
942 |
-
return $options ;
|
943 |
}
|
944 |
|
945 |
/**
|
@@ -964,11 +923,11 @@ class LiteSpeed_Cache_Admin_Settings
|
|
964 |
* @param int $val The checkbox value
|
965 |
* @return bool Filtered value
|
966 |
*/
|
967 |
-
public static function is_checked( $val)
|
968 |
{
|
969 |
-
$val = intval( $val) ;
|
970 |
|
971 |
-
if( $val === LiteSpeed_Cache_Config::VAL_ON ){
|
972 |
return true ;
|
973 |
}
|
974 |
|
@@ -983,15 +942,15 @@ class LiteSpeed_Cache_Admin_Settings
|
|
983 |
* @param int $val The radio value
|
984 |
* @return int Filtered value
|
985 |
*/
|
986 |
-
public static function is_checked_radio( $val)
|
987 |
{
|
988 |
-
$val = intval( $val) ;
|
989 |
|
990 |
-
if( $val === LiteSpeed_Cache_Config::VAL_ON ){
|
991 |
return LiteSpeed_Cache_Config::VAL_ON ;
|
992 |
}
|
993 |
|
994 |
-
if( $val === LiteSpeed_Cache_Config::VAL_ON2 ){
|
995 |
return LiteSpeed_Cache_Config::VAL_ON2 ;
|
996 |
}
|
997 |
|
@@ -1007,7 +966,7 @@ class LiteSpeed_Cache_Admin_Settings
|
|
1007 |
*/
|
1008 |
public static function get_instance()
|
1009 |
{
|
1010 |
-
if ( ! isset(self::$_instance) ) {
|
1011 |
self::$_instance = new self() ;
|
1012 |
}
|
1013 |
|
12 |
{
|
13 |
private static $_instance ;
|
14 |
|
15 |
+
private $_input ;
|
16 |
+
private $_options ;
|
17 |
+
private $_err ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
private $_err_msg_numeric ;
|
20 |
|
21 |
+
private $_max_int = 2147483647 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
/**
|
24 |
+
* Init
|
|
|
25 |
*
|
26 |
+
* @since 1.3
|
27 |
+
* @access private
|
|
|
|
|
28 |
*/
|
29 |
+
private function __construct()
|
30 |
{
|
31 |
+
$this->_err_msg_numeric = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_NUMERIC ) ;
|
32 |
}
|
33 |
|
34 |
/**
|
35 |
+
* Callback function that will validate any changes made in the settings page.
|
|
|
36 |
*
|
37 |
+
* NOTE: Anytime that validate_plugin_settings is called, `convert_options_to_input` must be done first if not from option page
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
* @access public
|
41 |
+
* @param array $input The configuration selected by the admin when clicking save.
|
42 |
+
* @return array The updated configuration options.
|
|
|
|
|
|
|
43 |
*/
|
44 |
+
public function validate_plugin_settings( $input )
|
45 |
{
|
46 |
+
LiteSpeed_Cache_Log::debug( 'Settings: validate_plugin_settings called' ) ;
|
47 |
+
$this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
|
48 |
+
|
49 |
+
if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
|
50 |
+
add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, __( '\'Use primary site settings\' set by Network Administrator.', 'litespeed-cache' ) ) ;
|
51 |
+
|
52 |
+
return $this->_options ;
|
53 |
}
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
$this->_input = $input ;
|
56 |
+
|
57 |
+
$this->_validate_general() ;
|
58 |
+
|
59 |
+
$this->_validate_cache() ;
|
60 |
+
|
61 |
+
$this->_validate_purge() ;
|
62 |
+
|
63 |
+
$this->_validate_exclude() ;
|
64 |
+
|
65 |
+
$this->_validate_optimize() ;
|
66 |
+
|
67 |
+
$this->_validate_cdn() ;
|
68 |
+
|
69 |
+
$this->_validate_debug() ;
|
70 |
+
|
71 |
+
$this->_validate_crawler() ; // Network setup doesn't run validate_plugin_settings
|
72 |
+
|
73 |
+
if ( ! is_multisite() ) {
|
74 |
+
$this->_validate_singlesite() ;
|
75 |
}
|
76 |
|
77 |
+
if ( LSWCP_ESI_SUPPORT ) {
|
78 |
+
$orig_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
|
79 |
|
80 |
+
$this->_validate_esi() ;
|
81 |
+
|
82 |
+
$new_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
|
83 |
+
|
84 |
+
if ( $orig_esi_enabled !== $new_esi_enabled ) {
|
85 |
+
LiteSpeed_Cache_Purge::purge_all() ;
|
86 |
+
}
|
87 |
}
|
88 |
|
89 |
+
if ( ! empty( $this->_err ) ) {
|
90 |
+
add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, implode( '<br />', $this->_err ) ) ;
|
91 |
+
|
92 |
+
return $this->_options ;
|
93 |
}
|
|
|
|
|
94 |
|
95 |
+
$cron_changed = false ;
|
96 |
+
if ( defined( 'LITESPEED_CLI' ) ) {
|
97 |
+
$id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
|
98 |
+
$cron_val = $this->_options[ $id ] ;
|
99 |
+
// assign crawler_cron_active to $this->_options if exists in $this->_input separately for CLI
|
100 |
+
// This has to be specified cos crawler cron activation is not set in admin setting page
|
101 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
102 |
+
if ( $cron_val != $this->_options[ $id ] ) {
|
103 |
+
$cron_changed = true ;
|
104 |
+
}
|
105 |
}
|
106 |
+
|
107 |
+
// check if need to enable crawler cron
|
108 |
+
if ( defined( 'LITESPEED_ON_CHANGED' ) || $cron_changed ) {
|
109 |
+
LiteSpeed_Cache_Task::update( $this->_options ) ;
|
110 |
}
|
111 |
|
112 |
+
$this->_validate_thirdparty( ) ;
|
113 |
+
|
114 |
+
return $this->_options ;
|
115 |
}
|
116 |
|
117 |
/**
|
118 |
+
* Validates the single site specific settings.
|
119 |
*
|
120 |
* @since 1.0.12
|
121 |
* @access private
|
|
|
|
|
|
|
122 |
*/
|
123 |
+
private function _validate_singlesite()
|
124 |
{
|
125 |
+
$id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
|
126 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
127 |
+
|
128 |
+
// Parse rewrite rule settings
|
129 |
+
$new_options = $this->_validate_rewrite_settings() ;
|
130 |
+
$this->_options = array_merge( $this->_options, $new_options ) ;
|
131 |
+
|
132 |
+
// Try to update rewrite rules
|
133 |
+
if ( ! defined( 'LITESPEED_NEW_OFF' ) ) {
|
134 |
+
// Only update needs to get error, for clear rules, can ignore for now
|
135 |
+
$res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $this->_options ) ;
|
136 |
+
if ( $res !== true ) {
|
137 |
+
if ( ! is_array( $res ) ) {
|
138 |
+
$this->_err[] = $res ;
|
|
|
|
|
|
|
139 |
}
|
140 |
+
else {
|
141 |
+
$this->_err = array_merge( $this->_err, $res ) ;
|
142 |
}
|
143 |
}
|
144 |
}
|
145 |
+
else {
|
146 |
+
LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules() ;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Parses any changes made by the network admin on the network settings.
|
152 |
+
*
|
153 |
+
* @since 1.0.4
|
154 |
+
* @access public
|
155 |
+
*/
|
156 |
+
public function validate_network_settings()
|
157 |
+
{
|
158 |
+
$input = array_map( 'LiteSpeed_Cache_Admin::cleanup_text', $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ;
|
159 |
+
$this->_input = $input ;
|
160 |
|
161 |
+
$options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
|
162 |
+
|
163 |
+
$id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
|
164 |
+
$network_enabled = self::parse_onoff( $this->_input, $id ) ;
|
165 |
+
if ( $options[ $id ] != $network_enabled ) {
|
166 |
+
$options[ $id ] = $network_enabled ;
|
167 |
+
if ( $network_enabled ) {
|
168 |
+
$ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
|
169 |
+
if ( $ret !== true ) {
|
170 |
+
$this->_err[] = $ret ;
|
171 |
+
}
|
172 |
}
|
173 |
+
else {
|
174 |
LiteSpeed_Cache_Purge::purge_all() ;
|
175 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
|
178 |
+
$id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
|
179 |
+
$orig_primary = $options[ $id ] ;
|
180 |
+
$options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
181 |
+
if ( $orig_primary != $options[ $id ] ) {
|
182 |
+
LiteSpeed_Cache_Purge::purge_all() ;
|
|
|
183 |
}
|
184 |
|
185 |
+
$id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
|
186 |
+
$options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
|
|
|
|
|
|
|
|
|
|
187 |
|
188 |
+
$id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
|
189 |
+
$options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
190 |
+
|
191 |
+
// Parse rewrite settings from input
|
192 |
+
$new_options = $this->_validate_rewrite_settings() ;
|
193 |
+
$options = array_merge( $options, $new_options ) ;
|
194 |
+
|
195 |
+
// Update htaccess
|
196 |
+
if ( $network_enabled ) {
|
197 |
+
$res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options ) ;
|
198 |
+
if ( $res !== true ) {
|
199 |
+
if ( ! is_array( $res ) ) {
|
200 |
+
$this->_err[] = $res ;
|
201 |
+
}
|
202 |
+
else {
|
203 |
+
$this->_err = array_merge( $this->_err, $res ) ;
|
204 |
+
}
|
205 |
+
}
|
206 |
}
|
207 |
else {
|
208 |
+
// Need to set cachePublicOn in case subblogs turn on cache manually
|
209 |
+
LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
|
210 |
}
|
211 |
|
212 |
+
if ( ! empty( $this->_err ) ) {
|
213 |
+
LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $this->_err ) ;
|
214 |
+
return ;
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
}
|
216 |
|
217 |
+
LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __( 'Site options saved.', 'litespeed-cache' ) ) ;
|
218 |
+
update_site_option( LiteSpeed_Cache_Config::OPTION_NAME, $options ) ;
|
219 |
+
return $options ;
|
220 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
|
222 |
+
/**
|
223 |
+
* Validates the general settings.
|
224 |
+
*
|
225 |
+
* @since 1.0.12
|
226 |
+
* @access private
|
227 |
+
*/
|
228 |
+
private function _validate_general()
|
229 |
+
{
|
230 |
+
// Cache enabled setting
|
231 |
+
$id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO ;
|
232 |
+
$this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
|
233 |
+
|
234 |
+
$enabled = $this->_options[ $id ] ;
|
235 |
+
// Use network setting
|
236 |
+
if( $enabled === LiteSpeed_Cache_Config::VAL_ON2 ) {
|
237 |
+
$enabled = is_multisite() ? defined( 'LITESPEED_NETWORK_ON' ) : true ; // Default to true
|
238 |
}
|
239 |
+
|
240 |
+
// Purge when disabled
|
241 |
+
if ( ! $enabled ) {
|
242 |
+
LiteSpeed_Cache_Purge::purge_all() ;
|
243 |
+
! defined( 'LITESPEED_NEW_OFF' ) && define( 'LITESPEED_NEW_OFF', true ) ; // Latest status is off
|
244 |
}
|
245 |
else {
|
246 |
+
! defined( 'LITESPEED_NEW_ON' ) && define( 'LITESPEED_NEW_ON', true ) ; // Latest status is on
|
247 |
}
|
248 |
|
249 |
+
// Status changed
|
250 |
+
if ( defined( 'LITESPEED_ON' ) xor $enabled ) {
|
251 |
+
define( 'LITESPEED_ON_CHANGED', true ) ;
|
|
|
|
|
|
|
252 |
}
|
253 |
+
|
254 |
+
// TTL check
|
255 |
+
$ids = array(
|
256 |
+
LiteSpeed_Cache_Config::OPID_PUBLIC_TTL => array( __( 'Default Public Cache', 'litespeed-cache' ), 30, $this->_max_int ),
|
257 |
+
LiteSpeed_Cache_Config::OPID_PRIVATE_TTL => array( __( 'Default Private Cache', 'litespeed-cache' ), 60, 3600 ),
|
258 |
+
LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL => array( __( 'Default Front Page', 'litespeed-cache' ), 30, $this->_max_int ),
|
259 |
+
LiteSpeed_Cache_Config::OPID_FEED_TTL => array( __( 'Feed', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
|
260 |
+
LiteSpeed_Cache_Config::OPID_404_TTL => array( __( '404', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
|
261 |
+
LiteSpeed_Cache_Config::OPID_403_TTL => array( __( '403', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
|
262 |
+
LiteSpeed_Cache_Config::OPID_500_TTL => array( __( '500', 'litespeed-cache' ), 0, $this->_max_int, 30 ),
|
263 |
+
) ;
|
264 |
+
foreach ( $ids as $id => $v ) {
|
265 |
+
list( $desc, $min, $max ) = $v ;
|
266 |
+
if ( ! $this->_check_ttl( $this->_input, $id, $min, $max ) ) {
|
267 |
+
$this->_err[] = sprintf( $this->_err_msg_numeric, $desc, $min, $max ) ;
|
268 |
+
}
|
269 |
+
else {
|
270 |
+
if ( ! empty( $v[ 3 ] ) && $this->_input[ $id ] < $v[ 3 ] ) {
|
271 |
+
$this->_options[ $id ] = 0 ;
|
272 |
+
}
|
273 |
+
else {
|
274 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
275 |
+
}
|
276 |
+
}
|
277 |
}
|
278 |
|
279 |
}
|
283 |
*
|
284 |
* @since 1.1.6
|
285 |
* @access private
|
|
|
|
|
|
|
286 |
*/
|
287 |
+
private function _validate_cache()
|
288 |
{
|
289 |
+
$ids = array(
|
290 |
+
LiteSpeed_Cache_Config::OPID_CACHE_PRIV,
|
291 |
+
LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER,
|
292 |
+
LiteSpeed_Cache_Config::OPID_CACHE_REST,
|
293 |
+
);
|
294 |
+
foreach ( $ids as $id ) {
|
295 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
296 |
+
}
|
297 |
|
298 |
$id = LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ;
|
299 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
300 |
+
if( ! $this->_options[ $id ] ) {
|
301 |
+
LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_LOGIN ) ;
|
302 |
+
}
|
303 |
+
|
304 |
+
$id = LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ;
|
305 |
+
if ( isset( $this->_input[ $id ]) ) {
|
306 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
|
307 |
}
|
308 |
}
|
309 |
|
312 |
*
|
313 |
* @since 1.0.12
|
314 |
* @access private
|
|
|
|
|
|
|
315 |
*/
|
316 |
+
private function _validate_purge()
|
317 |
{
|
318 |
$id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
|
319 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
320 |
|
321 |
// get auto purge rules options
|
322 |
$pvals = array(
|
333 |
LiteSpeed_Cache_Config::PURGE_POST_TYPE,
|
334 |
) ;
|
335 |
$input_purge_options = array() ;
|
336 |
+
foreach ( $pvals as $v) {
|
337 |
+
$input_name = 'purge_' . $v ;
|
338 |
+
if ( self::parse_onoff( $this->_input, $input_name ) ) {
|
339 |
+
$input_purge_options[] = $v ;
|
340 |
}
|
341 |
}
|
342 |
sort( $input_purge_options ) ;
|
343 |
$purge_by_post = implode( '.', $input_purge_options ) ;
|
344 |
+
if ( $purge_by_post !== $this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] ) {
|
345 |
+
$this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] = $purge_by_post ;
|
346 |
}
|
347 |
|
348 |
// Filter scheduled purge URLs
|
349 |
$id = LiteSpeed_Cache_Config::OPID_TIMED_URLS ;
|
350 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
351 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
// Schduled Purge Time
|
355 |
$id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ;
|
356 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
357 |
}
|
358 |
|
359 |
/**
|
361 |
*
|
362 |
* @since 1.0.12
|
363 |
* @access private
|
|
|
|
|
|
|
364 |
*/
|
365 |
+
private function _validate_exclude()
|
366 |
{
|
367 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ;
|
368 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
369 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
|
370 |
+
}
|
371 |
+
|
372 |
+
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ;
|
373 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
374 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
|
375 |
}
|
376 |
|
377 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT ;
|
378 |
+
$this->_options[ $id ] = '' ;
|
379 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
380 |
$cat_ids = array() ;
|
381 |
+
$cats = explode( "\n", $this->_input[ $id ] ) ;
|
382 |
+
foreach ( $cats as $cat ) {
|
383 |
+
$cat_name = trim( $cat ) ;
|
384 |
if ( $cat_name == '' ) {
|
385 |
continue ;
|
386 |
}
|
387 |
+
$cat_id = get_cat_ID( $cat_name ) ;
|
388 |
if ( $cat_id == 0 ) {
|
389 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_CAT, $cat_name ) ;
|
390 |
}
|
391 |
else {
|
392 |
$cat_ids[] = $cat_id ;
|
393 |
}
|
394 |
}
|
395 |
+
if ( ! empty( $cat_ids ) ) {
|
396 |
+
$this->_options[ $id ] = implode( ',', $cat_ids ) ;
|
397 |
}
|
398 |
}
|
399 |
|
400 |
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG ;
|
401 |
+
$this->_options[ $id ] = '' ;
|
402 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
403 |
$tag_ids = array() ;
|
404 |
+
$tags = explode( "\n", $this->_input[ $id ] ) ;
|
405 |
+
foreach ( $tags as $tag ) {
|
406 |
+
$tag_name = trim( $tag ) ;
|
407 |
if ( $tag_name == '' ) {
|
408 |
continue ;
|
409 |
}
|
410 |
+
$term = get_term_by( 'name', $tag_name, 'post_tag' ) ;
|
411 |
if ( $term == 0 ) {
|
412 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_TAG, $tag_name ) ;
|
413 |
}
|
414 |
else {
|
415 |
$tag_ids[] = $term->term_id ;
|
416 |
}
|
417 |
}
|
418 |
+
if ( ! empty( $tag_ids ) ) {
|
419 |
+
$this->_options[ $id ] = implode( ',', $tag_ids ) ;
|
420 |
}
|
421 |
}
|
422 |
}
|
427 |
* @since 1.2.2
|
428 |
* @access private
|
429 |
*/
|
430 |
+
private function _validate_cdn()
|
431 |
{
|
432 |
$ids = array(
|
433 |
LiteSpeed_Cache_Config::OPID_CDN,
|
434 |
LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
|
435 |
LiteSpeed_Cache_Config::OPID_CDN_INC_CSS,
|
436 |
LiteSpeed_Cache_Config::OPID_CDN_INC_JS,
|
437 |
+
) ;
|
438 |
foreach ( $ids as $id ) {
|
439 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
440 |
}
|
441 |
|
442 |
$id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
|
443 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
444 |
+
if ( $this->_options[ $id ] ) {
|
445 |
+
$tmp = parse_url( $this->_options[ $id ] ) ;
|
446 |
if ( ! empty( $tmp[ 'scheme' ] ) ) {
|
447 |
+
$this->_options[ $id ] = str_replace( $tmp[ 'scheme' ] . ':', '', $this->_options[ $id ] ) ;
|
448 |
}
|
449 |
}
|
450 |
|
451 |
$id = LiteSpeed_Cache_Config::OPID_CDN_URL ;
|
452 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
453 |
|
454 |
$ids = array(
|
455 |
LiteSpeed_Cache_Config::OPID_CDN_FILETYPE,
|
456 |
LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE,
|
457 |
) ;
|
458 |
foreach ( $ids as $id ) {
|
459 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
|
|
|
|
|
|
|
|
|
460 |
}
|
461 |
}
|
462 |
|
|
|
463 |
/**
|
464 |
* Validates the optimize settings.
|
465 |
*
|
466 |
* @since 1.2.2
|
467 |
* @access private
|
468 |
*/
|
469 |
+
private function _validate_optimize()
|
470 |
{
|
471 |
$ids = array(
|
472 |
LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
|
476 |
LiteSpeed_Cache_Config::OPID_JS_COMBINE,
|
477 |
LiteSpeed_Cache_Config::OPID_JS_HTTP2,
|
478 |
LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
|
479 |
+
LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
|
480 |
+
LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
|
481 |
+
LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
|
482 |
+
LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
|
483 |
+
LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
|
484 |
) ;
|
485 |
foreach ( $ids as $id ) {
|
486 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
487 |
}
|
488 |
|
489 |
$ids = array(
|
491 |
LiteSpeed_Cache_Config::OPID_JS_EXCLUDES,
|
492 |
) ;
|
493 |
foreach ( $ids as $id ) {
|
494 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'uri' ) ;
|
|
|
|
|
|
|
|
|
495 |
}
|
496 |
|
497 |
$id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ;
|
498 |
+
if ( ! $this->_check_ttl( $this->_input, $id, 3600 ) ) {
|
499 |
+
$this->_input[ $id ] = 3600 ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
}
|
501 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
502 |
|
503 |
+
// Update critical css
|
504 |
+
update_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, $this->_input[ LiteSpeed_Cache_Config::ITEM_OPTM_CSS ] ) ;
|
|
|
|
|
|
|
|
|
505 |
}
|
506 |
|
507 |
/**
|
509 |
*
|
510 |
* @since 1.0.12
|
511 |
* @access private
|
|
|
|
|
|
|
512 |
*/
|
513 |
+
private function _validate_debug()
|
514 |
{
|
|
|
|
|
515 |
$id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS ;
|
516 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
517 |
+
$admin_ips = array_map( 'trim', explode( "\n", trim( $this->_input[ $id ] ) ) ) ;
|
518 |
+
$admin_ips = array_filter( $admin_ips ) ;
|
519 |
$has_err = false ;
|
520 |
if ( $admin_ips ) {
|
521 |
+
foreach ( $admin_ips as $ip ) {
|
522 |
+
if ( ! WP_Http::is_ip_address( $ip ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
$has_err = true ;
|
524 |
break ;
|
525 |
}
|
526 |
}
|
527 |
}
|
528 |
+
$admin_ips = implode( "\n", $admin_ips ) ;
|
529 |
|
530 |
if ( $has_err ) {
|
531 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_ADMIN_IP_INV ) ;
|
532 |
}
|
533 |
+
else {
|
534 |
+
$this->_options[ $id ] = $admin_ips ;
|
535 |
}
|
536 |
}
|
537 |
|
538 |
$id = LiteSpeed_Cache_Config::OPID_DEBUG ;
|
539 |
+
$this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
|
541 |
$id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ;
|
542 |
+
if ( ! $this->_check_ttl( $this->_input, $id, 3, 3000 ) ) {
|
543 |
+
$this->_err[] = sprintf( $this->_err_msg_numeric, __( 'Log File Size Limit', 'litespeed-cache' ), 3, 3000 ) ;
|
544 |
}
|
545 |
else {
|
546 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
547 |
}
|
548 |
|
549 |
+
$ids = array(
|
550 |
+
LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
|
551 |
+
LiteSpeed_Cache_Config::OPID_HEARTBEAT,
|
552 |
+
LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
|
553 |
+
LiteSpeed_Cache_Config::OPID_COLLAPS_QS,
|
554 |
+
LiteSpeed_Cache_Config::OPID_LOG_FILTERS,
|
555 |
+
) ;
|
556 |
+
foreach ( $ids as $id ) {
|
557 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
558 |
}
|
559 |
|
560 |
+
// Filters ignored
|
561 |
+
$ids = array(
|
562 |
+
LiteSpeed_Cache_Config::OPID_LOG_IGNORE_FILTERS,
|
563 |
+
LiteSpeed_Cache_Config::OPID_LOG_IGNORE_PART_FILTERS,
|
564 |
+
) ;
|
565 |
+
foreach ( $ids as $id ) {
|
566 |
+
$this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
|
567 |
}
|
|
|
568 |
}
|
569 |
|
570 |
/**
|
572 |
*
|
573 |
* @since 1.0.12
|
574 |
* @access private
|
|
|
|
|
|
|
575 |
*/
|
576 |
+
private function _validate_crawler()
|
577 |
{
|
578 |
+
$ids = array(
|
579 |
+
LiteSpeed_Cache_Config::CRWL_POSTS,
|
580 |
+
LiteSpeed_Cache_Config::CRWL_PAGES,
|
581 |
+
LiteSpeed_Cache_Config::CRWL_CATS,
|
582 |
+
LiteSpeed_Cache_Config::CRWL_TAGS,
|
583 |
+
) ;
|
584 |
+
foreach ( $ids as $id ) {
|
585 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
586 |
+
}
|
|
|
|
|
|
|
|
|
587 |
|
588 |
$id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
|
589 |
+
if ( isset( $this->_input[ $id ] ) ) {
|
590 |
+
$arr = array_map( 'trim', explode( "\n", $this->_input[ $id ] ) ) ;
|
591 |
+
$arr = array_filter( $arr ) ;
|
592 |
+
$ori = array_diff( get_post_types( '', 'names' ), array( 'post', 'page' ) ) ;
|
593 |
+
$this->_options[ $id ] = implode( "\n", array_intersect( $arr, $ori ) ) ;
|
594 |
}
|
595 |
|
596 |
$id = LiteSpeed_Cache_Config::CRWL_ORDER_LINKS ;
|
597 |
+
if( ! isset( $this->_input[ $id ] ) || ! in_array( $this->_input[ $id ], array(
|
598 |
LiteSpeed_Cache_Config::CRWL_DATE_DESC,
|
599 |
LiteSpeed_Cache_Config::CRWL_DATE_ASC,
|
600 |
LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
|
601 |
LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
|
602 |
+
) )
|
603 |
+
) {
|
604 |
+
$this->_input[ $id ] = LiteSpeed_Cache_Config::CRWL_DATE_DESC ;
|
605 |
}
|
606 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
607 |
|
608 |
+
$ids = array(
|
609 |
+
LiteSpeed_Cache_Config::CRWL_USLEEP => array( __( 'Delay', 'litespeed-cache' ), 0, 30000 ),
|
610 |
+
LiteSpeed_Cache_Config::CRWL_RUN_DURATION => array( __( 'Run Duration', 'litespeed-cache' ), 0, $this->_max_int ),
|
611 |
+
LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL => array( __( 'Cron Interval', 'litespeed-cache' ), 60, $this->_max_int ),
|
612 |
+
LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL => array( __( 'Whole Interval', 'litespeed-cache' ), 0, $this->_max_int ),
|
613 |
+
LiteSpeed_Cache_Config::CRWL_THREADS => array( __( 'Threads', 'litespeed-cache' ), 1, 16 ),
|
614 |
+
) ;
|
615 |
+
foreach ( $ids as $id => $v ) {
|
616 |
+
list( $desc, $min, $max ) = $v ;
|
617 |
+
if ( ! $this->_check_ttl( $this->_input, $id, $min, $max ) ) {
|
618 |
+
$this->_err[] = sprintf( $this->_err_msg_numeric, $desc, $min, $max ) ;
|
619 |
+
}
|
620 |
+
else {
|
621 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
622 |
+
}
|
623 |
}
|
624 |
|
625 |
+
|
626 |
+
$id = LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ;
|
627 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
628 |
+
|
629 |
+
$id = LiteSpeed_Cache_Config::CRWL_DOMAIN_IP ;
|
630 |
+
if ( ! empty( $this->_input[ $id ] ) && ! WP_Http::is_ip_address( $this->_input[ $id ] ) ) {
|
631 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_SITE_IP, $this->_input[ $id ] ) ;
|
632 |
}
|
633 |
else {
|
634 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
635 |
}
|
636 |
|
637 |
+
$id = LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ;
|
638 |
+
if ( ! empty( $this->_input[ $id ] ) && ( $err = $this->_validate_custom_sitemap( $this->_input[ $id ] ) ) !== true ) {
|
639 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( $err, $this->_input[ $id ] ) ;
|
640 |
}
|
641 |
else {
|
642 |
+
$this->_options[ $id ] = $this->_input[ $id ] ;
|
643 |
}
|
644 |
|
645 |
+
}
|
646 |
+
|
647 |
+
/**
|
648 |
+
* Validates the custom sitemap settings.
|
649 |
+
*
|
650 |
+
* @since 1.1.1
|
651 |
+
* @access private
|
652 |
+
* @param string $url The sitemap url
|
653 |
+
*/
|
654 |
+
private function _validate_custom_sitemap( $url )
|
655 |
+
{
|
656 |
+
return LiteSpeed_Cache_Crawler::get_instance()->parse_custom_sitemap( $url, false ) ;
|
657 |
+
}
|
658 |
+
|
659 |
+
/**
|
660 |
+
* Validates settings related to rewrite rules
|
661 |
+
*
|
662 |
+
* @since 1.3
|
663 |
+
* @access private
|
664 |
+
* @return array New options related to rewrite rule
|
665 |
+
*/
|
666 |
+
private function _validate_rewrite_settings()
|
667 |
+
{
|
668 |
+
$new_options = array() ;
|
669 |
+
|
670 |
+
$ids = array(
|
671 |
+
LiteSpeed_Cache_Config::OPID_CACHE_MOBILE,
|
672 |
+
LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
|
673 |
+
LiteSpeed_Cache_Config::OPID_CACHE_RES,
|
674 |
+
LiteSpeed_Cache_Config::OPID_CACHE_BROWSER,
|
675 |
+
) ;
|
676 |
+
foreach ( $ids as $id ) {
|
677 |
+
$new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
678 |
+
}
|
679 |
+
|
680 |
+
// check mobile agents
|
681 |
+
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
|
682 |
+
if ( ! $this->_input[ $id ] && $new_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
|
683 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, 'EMPTY' ) ) ;
|
684 |
+
}
|
685 |
+
elseif ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
|
686 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
|
687 |
}
|
688 |
else {
|
689 |
+
$new_options[ $id ] = $this->_input[ $id ] ;
|
690 |
}
|
691 |
|
692 |
+
// No cache cookie settings
|
693 |
+
$id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
|
694 |
+
$this->_input[ $id ] = preg_replace( "/[\r\n]+/", '|', $this->_input[ $id ] ) ;
|
695 |
+
if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
|
696 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
|
697 |
}
|
698 |
else {
|
699 |
+
$new_options[ $id ] = $this->_input[ $id ] ;
|
700 |
}
|
701 |
|
702 |
+
// No cache user agent settings
|
703 |
+
$id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
|
704 |
+
if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
|
705 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
|
|
|
|
|
706 |
}
|
707 |
else {
|
708 |
+
$new_options[ $id ] = $this->_input[ $id ] ;
|
709 |
}
|
710 |
|
711 |
+
// Login cookie
|
712 |
+
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
|
713 |
+
if ( $this->_input[ $id ] && preg_match( '#[^\w\-]#', $this->_input[ $id ] ) ) {
|
714 |
+
$this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_LC, esc_html( $this->_input[ $id ] ) ) ;
|
715 |
}
|
716 |
else {
|
717 |
+
$new_options[ $id ] = $this->_input[ $id ] ;
|
718 |
}
|
719 |
|
720 |
+
return $new_options ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
721 |
}
|
722 |
|
723 |
/**
|
725 |
*
|
726 |
* @since 1.0.12
|
727 |
* @access private
|
|
|
|
|
728 |
*/
|
729 |
+
private function _validate_thirdparty()
|
730 |
{
|
731 |
$tp_default_options = LiteSpeed_Cache_Config::get_instance()->get_thirdparty_options() ;
|
732 |
+
if ( empty( $tp_default_options ) ) {
|
733 |
+
return ;
|
734 |
}
|
735 |
+
|
736 |
+
$tp_input = array_intersect_key( $this->_input, $tp_default_options ) ;
|
737 |
+
if ( empty( $tp_input ) ) {
|
738 |
+
return ;
|
739 |
}
|
740 |
+
|
741 |
+
$tp_options = apply_filters( 'litespeed_cache_save_options', array_intersect_key( $this->_options, $tp_default_options ), $tp_input ) ;
|
742 |
+
if ( ! empty( $tp_options ) && is_array( $tp_options ) ) {
|
743 |
+
$this->_options = array_merge( $this->_options, $tp_options ) ;
|
744 |
}
|
|
|
745 |
}
|
746 |
|
747 |
/**
|
749 |
*
|
750 |
* @since 1.1.3
|
751 |
* @access private
|
|
|
|
|
|
|
752 |
*/
|
753 |
+
private function _validate_esi()
|
754 |
{
|
755 |
+
$ids = array(
|
756 |
+
LiteSpeed_Cache_Config::OPID_ESI_ENABLE,
|
757 |
+
LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR,
|
758 |
+
LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM,
|
759 |
+
) ;
|
760 |
+
foreach ( $ids as $id ) {
|
761 |
+
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
|
762 |
+
}
|
763 |
|
764 |
// Save vary group settings
|
765 |
$vary_groups = $_POST[ LiteSpeed_Cache_Config::VARY_GROUP ] ;
|
766 |
$vary_groups = array_map( 'trim', $vary_groups ) ;
|
767 |
$vary_groups = array_filter( $vary_groups ) ;
|
768 |
update_option( LiteSpeed_Cache_Config::VARY_GROUP, $vary_groups ) ;
|
|
|
769 |
}
|
770 |
|
771 |
/**
|
772 |
+
* Hooked to the wp_redirect filter.
|
773 |
+
* This will only hook if there was a problem when saving the widget.
|
|
|
|
|
774 |
*
|
775 |
+
* @since 1.1.3
|
776 |
* @access public
|
777 |
+
* @param string $location The location string.
|
778 |
+
* @return string the updated location string.
|
|
|
779 |
*/
|
780 |
+
public static function widget_save_err( $location )
|
781 |
{
|
782 |
+
return str_replace( '?message=0', '?error=0', $location ) ;
|
783 |
+
}
|
|
|
|
|
|
|
|
|
784 |
|
785 |
+
/**
|
786 |
+
* Hooked to the widget_update_callback filter.
|
787 |
+
* Validate the LiteSpeed Cache settings on edit widget save.
|
788 |
+
*
|
789 |
+
* @since 1.1.3
|
790 |
+
* @access public
|
791 |
+
* @param array $instance The new settings.
|
792 |
+
* @param array $new_instance
|
793 |
+
* @param array $old_instance The original settings.
|
794 |
+
* @param WP_Widget $widget The widget
|
795 |
+
* @return mixed Updated settings on success, false on error.
|
796 |
+
*/
|
797 |
+
public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget )
|
798 |
+
{
|
799 |
+
if ( empty( $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
|
800 |
+
return $instance ;
|
801 |
}
|
802 |
+
$current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
|
803 |
+
$input = $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
|
804 |
+
$esistr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
|
805 |
+
$ttlstr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
|
806 |
|
807 |
+
if ( ! is_numeric( $ttlstr ) || ! is_numeric( $esistr ) ) {
|
808 |
+
add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
|
809 |
+
return false ;
|
810 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
811 |
|
812 |
+
$esi = self::is_checked_radio( $esistr ) ;
|
813 |
+
$ttl = intval( $ttlstr ) ;
|
814 |
|
815 |
+
if ( $ttl != 0 && $ttl < 30 ) {
|
816 |
+
add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
|
817 |
+
return false ; // invalid ttl.
|
818 |
}
|
819 |
|
820 |
+
if ( empty( $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
|
821 |
+
$instance[ LiteSpeed_Cache_Config::OPTION_NAME ] = array() ;
|
822 |
}
|
823 |
+
$instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
|
824 |
+
$instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
|
825 |
|
826 |
+
if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
|
827 |
+
LiteSpeed_Cache_Purge::purge_all() ;
|
828 |
+
}
|
829 |
+
elseif ( $ttl != 0 && $ttl != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) {
|
830 |
+
LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget->id ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
}
|
832 |
|
833 |
+
LiteSpeed_Cache_Purge::purge_all() ;
|
834 |
+
return $instance ;
|
835 |
+
}
|
836 |
|
837 |
+
/**
|
838 |
+
* Parse rewrite input to check for possible issues (e.g. unescaped spaces).
|
839 |
+
*
|
840 |
+
* Issues tracked:
|
841 |
+
* Starts with |
|
842 |
+
* Ends with |
|
843 |
+
* Double |
|
844 |
+
* Unescaped space
|
845 |
+
* Invalid character (NOT \w, -, \, |, \s, /, ., +, *, (, ))
|
846 |
+
*
|
847 |
+
* @since 1.0.9
|
848 |
+
* @access private
|
849 |
+
* @param String $rule Input rewrite rule.
|
850 |
+
* @return bool True for valid rules, false otherwise.
|
851 |
+
*/
|
852 |
+
private function _syntax_checker( $rule )
|
853 |
+
{
|
854 |
+
$escaped = str_replace( '@', '\@', $rule ) ;
|
855 |
|
856 |
+
$success = true ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
|
858 |
+
set_error_handler( 'litespeed_exception_handler' ) ;
|
859 |
+
|
860 |
+
try {
|
861 |
+
preg_match( '@' . $escaped . '@', null ) ;
|
862 |
+
} catch ( ErrorException $e ) {
|
863 |
+
$success = false ;
|
864 |
}
|
865 |
|
866 |
+
restore_error_handler() ;
|
867 |
|
868 |
+
return $success ;
|
869 |
}
|
870 |
|
871 |
/**
|
872 |
+
* Helper function to validate TTL settings. Will check if it's set, is an integer, and is greater than 0 and less than INT_MAX.
|
873 |
*
|
874 |
+
* @since 1.0.12
|
875 |
+
* @access private
|
876 |
+
* @param array $input Input array
|
877 |
+
* @param string $id Option ID
|
878 |
+
* @param number $min Minimum number
|
879 |
+
* @param number $max Maximum number
|
880 |
+
* @return bool True if valid, false otherwise.
|
881 |
*/
|
882 |
+
private function _check_ttl( $input, $id, $min = false, $max = null )
|
883 |
{
|
884 |
+
if ( ! isset( $input[ $id ] ) ) {
|
885 |
+
return false ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
}
|
887 |
|
888 |
+
$val = $input[ $id ] ;
|
|
|
|
|
|
|
|
|
889 |
|
890 |
+
$ival = intval( $val ) ;
|
891 |
+
$sval = strval( $val ) ;
|
892 |
|
893 |
+
if( $min && $ival < $min ) {
|
894 |
+
return false ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
895 |
}
|
896 |
|
897 |
+
if ( $max === null ) {
|
898 |
+
$max = $this->_max_int ;
|
899 |
}
|
900 |
|
901 |
+
return ctype_digit( $sval ) && $ival >= 0 && $ival < $max ;
|
|
|
|
|
|
|
|
|
|
|
|
|
902 |
}
|
903 |
|
904 |
/**
|
923 |
* @param int $val The checkbox value
|
924 |
* @return bool Filtered value
|
925 |
*/
|
926 |
+
public static function is_checked( $val )
|
927 |
{
|
928 |
+
$val = intval( $val ) ;
|
929 |
|
930 |
+
if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
|
931 |
return true ;
|
932 |
}
|
933 |
|
942 |
* @param int $val The radio value
|
943 |
* @return int Filtered value
|
944 |
*/
|
945 |
+
public static function is_checked_radio( $val )
|
946 |
{
|
947 |
+
$val = intval( $val ) ;
|
948 |
|
949 |
+
if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
|
950 |
return LiteSpeed_Cache_Config::VAL_ON ;
|
951 |
}
|
952 |
|
953 |
+
if( $val === LiteSpeed_Cache_Config::VAL_ON2 ) {
|
954 |
return LiteSpeed_Cache_Config::VAL_ON2 ;
|
955 |
}
|
956 |
|
966 |
*/
|
967 |
public static function get_instance()
|
968 |
{
|
969 |
+
if ( ! isset( self::$_instance ) ) {
|
970 |
self::$_instance = new self() ;
|
971 |
}
|
972 |
|
admin/litespeed-cache-admin.class.php
CHANGED
@@ -38,7 +38,7 @@ class LiteSpeed_Cache_Admin
|
|
38 |
// add link to plugin list page
|
39 |
add_filter( 'plugin_action_links_' . LSWCP_BASENAME, array( $this->display, 'add_plugin_links' ) ) ;
|
40 |
|
41 |
-
if (
|
42 |
// register purge_all actions
|
43 |
$purge_all_events = array(
|
44 |
'switch_theme',
|
@@ -96,7 +96,7 @@ class LiteSpeed_Cache_Admin
|
|
96 |
}
|
97 |
|
98 |
// step out if plugin is not enabled
|
99 |
-
if ( !
|
100 |
return ;
|
101 |
}
|
102 |
|
38 |
// add link to plugin list page
|
39 |
add_filter( 'plugin_action_links_' . LSWCP_BASENAME, array( $this->display, 'add_plugin_links' ) ) ;
|
40 |
|
41 |
+
if ( defined( 'LITESPEED_ON' ) ) {
|
42 |
// register purge_all actions
|
43 |
$purge_all_events = array(
|
44 |
'switch_theme',
|
96 |
}
|
97 |
|
98 |
// step out if plugin is not enabled
|
99 |
+
if ( ! defined( 'LITESPEED_ON' ) ) {
|
100 |
return ;
|
101 |
}
|
102 |
|
admin/tpl/crawler.php
CHANGED
@@ -20,7 +20,7 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
|
|
20 |
<div class="litespeed-wrap">
|
21 |
<div class="litespeed-body">
|
22 |
<h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
|
23 |
-
<a href="<?php echo
|
24 |
<?php echo __('Generate Crawler File', 'litespeed-cache') ; ?>
|
25 |
</a>
|
26 |
|
@@ -128,7 +128,7 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
|
|
128 |
<td>
|
129 |
<div class="litespeed-switch-drag">
|
130 |
<input type="checkbox" name="litespeed_crawler_cron_enable" id="litespeed_crawler_cron_enable" value="1"
|
131 |
-
data-url="<?php echo
|
132 |
<?php if( $_options[LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE] && LiteSpeed_Cache_Router::can_crawl() ) echo "checked"; ?>
|
133 |
<?php echo $disabled ; ?>
|
134 |
/>
|
@@ -140,9 +140,9 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
|
|
140 |
</td>
|
141 |
<td>
|
142 |
<?php
|
143 |
-
echo " <a href='" .
|
144 |
|
145 |
-
$href = LiteSpeed_Cache_Router::can_crawl() ?
|
146 |
echo " <a href='$href' id='litespeed_manual_trigger' target='litespeedHiddenIframe' class='litespeed-btn-success litespeed-btn-xs' $disabled>" . __('Manually run', 'litespeed-cache') . "</a>" ;
|
147 |
?>
|
148 |
<?php if ( $meta && $meta->last_start_time ): ?>
|
@@ -189,7 +189,7 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
|
|
189 |
<div class="litespeed-shell-header">
|
190 |
<div class="litespeed-shell-header-bg"></div>
|
191 |
<div class="litespeed-shell-header-icon-container">
|
192 |
-
<img id="litespeed-shell-icon" src="<?php echo
|
193 |
</div>
|
194 |
</div>
|
195 |
<ul class="litespeed-shell-body">
|
20 |
<div class="litespeed-wrap">
|
21 |
<div class="litespeed-body">
|
22 |
<h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
|
23 |
+
<a href="<?php echo LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE) ; ?>" class="litespeed-btn-success">
|
24 |
<?php echo __('Generate Crawler File', 'litespeed-cache') ; ?>
|
25 |
</a>
|
26 |
|
128 |
<td>
|
129 |
<div class="litespeed-switch-drag">
|
130 |
<input type="checkbox" name="litespeed_crawler_cron_enable" id="litespeed_crawler_cron_enable" value="1"
|
131 |
+
data-url="<?php echo LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE, 'cron_enable') ; ?>"
|
132 |
<?php if( $_options[LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE] && LiteSpeed_Cache_Router::can_crawl() ) echo "checked"; ?>
|
133 |
<?php echo $disabled ; ?>
|
134 |
/>
|
140 |
</td>
|
141 |
<td>
|
142 |
<?php
|
143 |
+
echo " <a href='" . LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS) . "' class='litespeed-btn-warning litespeed-btn-xs'>" . __('Reset position', 'litespeed-cache') . "</a>" ;
|
144 |
|
145 |
+
$href = LiteSpeed_Cache_Router::can_crawl() ? LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DO_CRAWL) : 'javascript:;' ;
|
146 |
echo " <a href='$href' id='litespeed_manual_trigger' target='litespeedHiddenIframe' class='litespeed-btn-success litespeed-btn-xs' $disabled>" . __('Manually run', 'litespeed-cache') . "</a>" ;
|
147 |
?>
|
148 |
<?php if ( $meta && $meta->last_start_time ): ?>
|
189 |
<div class="litespeed-shell-header">
|
190 |
<div class="litespeed-shell-header-bg"></div>
|
191 |
<div class="litespeed-shell-header-icon-container">
|
192 |
+
<img id="litespeed-shell-icon" src="<?php echo LSWCP_PLUGIN_URL . 'img/Litespeed.icon.svg' ; ?>" />
|
193 |
</div>
|
194 |
</div>
|
195 |
<ul class="litespeed-shell-body">
|
admin/tpl/edit_htaccess.php
CHANGED
@@ -5,7 +5,7 @@ $readonly = LiteSpeed_Cache_Admin_Rules::writable() ? '' : 'readonly';
|
|
5 |
$content = LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_read();
|
6 |
|
7 |
// Check if there is `ExpiresDefault` in .htaccess
|
8 |
-
if (
|
9 |
$htaccess_con = Litespeed_File::read( LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ) ;
|
10 |
if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
|
11 |
$is_dismissed = get_option( self::DISMISS_MSG ) ;
|
5 |
$content = LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_read();
|
6 |
|
7 |
// Check if there is `ExpiresDefault` in .htaccess
|
8 |
+
if ( defined( 'LITESPEED_ON' ) ) {
|
9 |
$htaccess_con = Litespeed_File::read( LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ) ;
|
10 |
if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
|
11 |
$is_dismissed = get_option( self::DISMISS_MSG ) ;
|
admin/tpl/info_faqs.php
CHANGED
@@ -90,7 +90,7 @@ if (!defined('WPINC')) die;
|
|
90 |
</li>
|
91 |
<li><?php echo sprintf(__('Replace the ajax query in %1$s with %2$s', 'litespeed-cache'),
|
92 |
'<code>wp-content/plugins/wp-postviews/postviews-cache.js</code>',
|
93 |
-
'<textarea class="litespeed-textarea" rows="11" readonly>jQuery.ajax({
|
94 |
type:"GET",
|
95 |
url:viewsCacheL10n.admin_ajax_url,
|
96 |
data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
|
90 |
</li>
|
91 |
<li><?php echo sprintf(__('Replace the ajax query in %1$s with %2$s', 'litespeed-cache'),
|
92 |
'<code>wp-content/plugins/wp-postviews/postviews-cache.js</code>',
|
93 |
+
'<br /><textarea class="litespeed-textarea" rows="11" readonly>jQuery.ajax({
|
94 |
type:"GET",
|
95 |
url:viewsCacheL10n.admin_ajax_url,
|
96 |
data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
|
admin/tpl/manage.php
CHANGED
@@ -37,7 +37,7 @@ $menu_list = array(
|
|
37 |
?>
|
38 |
</h2>
|
39 |
|
40 |
-
<?php if ( !
|
41 |
<div class="litespeed-callout-warning">
|
42 |
<h4><?php echo __('WARNING: LiteSpeed cache is disabled. The functionalities here can not work.', 'litespeed-cache'); ?></h4>
|
43 |
</div>
|
37 |
?>
|
38 |
</h2>
|
39 |
|
40 |
+
<?php if ( ! defined( 'LITESPEED_ON' ) ) : ?>
|
41 |
<div class="litespeed-callout-warning">
|
42 |
<h4><?php echo __('WARNING: LiteSpeed cache is disabled. The functionalities here can not work.', 'litespeed-cache'); ?></h4>
|
43 |
</div>
|
admin/tpl/manage_purge.php
CHANGED
@@ -79,7 +79,7 @@ if ( ! is_multisite() || is_network_admin() ) {
|
|
79 |
<?php foreach ( $_panels as $val ): ?>
|
80 |
|
81 |
<a class="litespeed-panel"
|
82 |
-
href="<?php echo
|
83 |
<?php if ( ! empty( $val[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $val[ 'cfm' ] . '"' ; ?>
|
84 |
>
|
85 |
<section class="litespeed-panel-wrapper-icon">
|
79 |
<?php foreach ( $_panels as $val ): ?>
|
80 |
|
81 |
<a class="litespeed-panel"
|
82 |
+
href="<?php echo LiteSpeed_Cache_Utility::build_url( $val[ 'tag' ], false, ! empty( $val[ 'append_url' ] ) ? $val[ 'append_url' ] : false ) ; ?>"
|
83 |
<?php if ( ! empty( $val[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $val[ 'cfm' ] . '"' ; ?>
|
84 |
>
|
85 |
<section class="litespeed-panel-wrapper-icon">
|
admin/tpl/network_settings.php
CHANGED
@@ -34,7 +34,7 @@ $_options = LiteSpeed_Cache_Config::get_instance()->get_site_options();
|
|
34 |
?>
|
35 |
</h2>
|
36 |
<div class="litespeed-body">
|
37 |
-
<form method="post" action="admin.php?page=lscache-settings" id="
|
38 |
<?php
|
39 |
$this->form_action(LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK);
|
40 |
|
34 |
?>
|
35 |
</h2>
|
36 |
<div class="litespeed-body">
|
37 |
+
<form method="post" action="admin.php?page=lscache-settings" id="litespeed_form_options" class="litespeed-relative">
|
38 |
<?php
|
39 |
$this->form_action(LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK);
|
40 |
|
admin/tpl/network_settings_cache.php
CHANGED
@@ -13,6 +13,7 @@ if ( ! defined( 'WPINC' ) ) die ;
|
|
13 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_favicon.php' ; ?>
|
14 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_resources.php' ; ?>
|
15 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_mobile.php' ; ?>
|
|
|
16 |
|
17 |
</tbody></table>
|
18 |
|
13 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_favicon.php' ; ?>
|
14 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_resources.php' ; ?>
|
15 |
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_mobile.php' ; ?>
|
16 |
+
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.cache_browser.php' ; ?>
|
17 |
|
18 |
</tbody></table>
|
19 |
|
admin/tpl/network_settings_excludes.php
CHANGED
@@ -4,8 +4,12 @@ if (!defined('WPINC')) die;
|
|
4 |
?>
|
5 |
<h3 class="litespeed-title"><?php echo __('Network Do Not Cache Rules', 'litespeed-cache'); ?></h3>
|
6 |
|
7 |
-
|
8 |
-
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_useragent.php'; ?>
|
9 |
|
10 |
-
<!--
|
11 |
-
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.
|
|
|
|
|
|
|
|
|
|
4 |
?>
|
5 |
<h3 class="litespeed-title"><?php echo __('Network Do Not Cache Rules', 'litespeed-cache'); ?></h3>
|
6 |
|
7 |
+
<table><tbody>
|
|
|
8 |
|
9 |
+
<!-- User Agent List -->
|
10 |
+
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_useragent.php'; ?>
|
11 |
+
|
12 |
+
<!-- Cookie List -->
|
13 |
+
<?php require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_cookies.php'; ?>
|
14 |
+
|
15 |
+
</tbody></table>
|
admin/tpl/settings.php
CHANGED
@@ -26,7 +26,6 @@ if ($this->show_compatibility_tab()){
|
|
26 |
|
27 |
$menu_list['crawler'] = __('Crawler', 'litespeed-cache') ;
|
28 |
|
29 |
-
|
30 |
global $_options ;
|
31 |
$_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
|
32 |
|
@@ -107,7 +106,7 @@ else {
|
|
107 |
?>
|
108 |
</h2>
|
109 |
<div class="litespeed-body">
|
110 |
-
<form method="post" action="options.php" id="litespeed_form_options">
|
111 |
<!--input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_SAVE_SETTINGS ; ?>" /-->
|
112 |
|
113 |
<?php if ($this->get_disable_all()): ?>
|
@@ -136,7 +135,7 @@ else {
|
|
136 |
|
137 |
echo "<div class='litespeed-top20'></div>" ;
|
138 |
|
139 |
-
if ($this->get_disable_all()) {
|
140 |
submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-primary', 'litespeed-submit', true, array('disabled' => true)) ;
|
141 |
}
|
142 |
else {
|
26 |
|
27 |
$menu_list['crawler'] = __('Crawler', 'litespeed-cache') ;
|
28 |
|
|
|
29 |
global $_options ;
|
30 |
$_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
|
31 |
|
106 |
?>
|
107 |
</h2>
|
108 |
<div class="litespeed-body">
|
109 |
+
<form method="post" action="options.php" id="litespeed_form_options" class="litespeed-relative">
|
110 |
<!--input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_SAVE_SETTINGS ; ?>" /-->
|
111 |
|
112 |
<?php if ($this->get_disable_all()): ?>
|
135 |
|
136 |
echo "<div class='litespeed-top20'></div>" ;
|
137 |
|
138 |
+
if ( $this->get_disable_all() ) {
|
139 |
submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-primary', 'litespeed-submit', true, array('disabled' => true)) ;
|
140 |
}
|
141 |
else {
|
admin/tpl/settings_advanced.php
CHANGED
@@ -55,7 +55,7 @@ if ( $cookie_rule && substr($cookie_rule, 0, 11) !== 'Cache-Vary:' ){
|
|
55 |
}
|
56 |
|
57 |
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
|
58 |
-
if (
|
59 |
|
60 |
if (!$cookie_rule){
|
61 |
echo '<div class="litespeed-callout-danger">'
|
55 |
}
|
56 |
|
57 |
$id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE;
|
58 |
+
if ( defined( 'LITESPEED_ON' ) && $_options[$id] ){
|
59 |
|
60 |
if (!$cookie_rule){
|
61 |
echo '<div class="litespeed-callout-danger">'
|
admin/tpl/settings_cache.php
CHANGED
@@ -52,5 +52,27 @@ if ( ! defined( 'WPINC' ) ) die ;
|
|
52 |
endif ;
|
53 |
?>
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
</tbody></table>
|
56 |
|
52 |
endif ;
|
53 |
?>
|
54 |
|
55 |
+
<tr>
|
56 |
+
<th><?php echo __( 'Private Cached URIs', 'litespeed-cache' ) ; ?></th>
|
57 |
+
<td>
|
58 |
+
<?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV); ?>
|
59 |
+
<div class="litespeed-desc">
|
60 |
+
<?php echo __('URI Paths containing these strings will NOT be cached as public.', 'litespeed-cache'); ?>
|
61 |
+
<?php echo __('The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache'); ?>
|
62 |
+
<br />
|
63 |
+
<i>
|
64 |
+
<?php echo sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ; ?>
|
65 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
66 |
+
</i>
|
67 |
+
</div>
|
68 |
+
</td>
|
69 |
+
</tr>
|
70 |
+
|
71 |
+
<?php
|
72 |
+
if ( ! is_multisite() ) :
|
73 |
+
require LSWCP_DIR . 'admin/tpl/settings_inc.cache_browser.php' ;
|
74 |
+
endif ;
|
75 |
+
?>
|
76 |
+
|
77 |
</tbody></table>
|
78 |
|
admin/tpl/settings_debug.php
CHANGED
@@ -32,7 +32,7 @@ if ( ! defined( 'WPINC' ) ) die ;
|
|
32 |
<?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ) ; ?>
|
33 |
<?php echo __( 'This should be set to off once everything is working to prevent filling the disk.', 'litespeed-cache' ) ; ?>
|
34 |
<?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ) ; ?>
|
35 |
-
<?php echo __( 'The logs will be outputted to
|
36 |
</div>
|
37 |
</td>
|
38 |
</tr>
|
@@ -144,14 +144,3 @@ if ( ! defined( 'WPINC' ) ) die ;
|
|
144 |
</tr>
|
145 |
|
146 |
</tbody></table>
|
147 |
-
|
148 |
-
<?php
|
149 |
-
|
150 |
-
/* Maybe add this feature later
|
151 |
-
$id = LiteSpeed_Cache_Config::OPID_TEST_IPS;
|
152 |
-
$input_test_ips = $this->input_field_text($id, $options[$id], '', 'regular-text');
|
153 |
-
$buf .= $this->display_config_row('Test IPs', $input_test_ips,
|
154 |
-
'Enable LiteSpeed Cache only for specified IPs. (Space or comma separated.)
|
155 |
-
* Allows testing on a live site. If empty, cache will be served to everyone.');
|
156 |
-
*
|
157 |
-
*/
|
32 |
<?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ) ; ?>
|
33 |
<?php echo __( 'This should be set to off once everything is working to prevent filling the disk.', 'litespeed-cache' ) ; ?>
|
34 |
<?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ) ; ?>
|
35 |
+
<?php echo sprintf( __( 'The logs will be outputted to %s.', 'litespeed-cache' ), '<code>wp-content/debug.log</code>' ) ; ?>
|
36 |
</div>
|
37 |
</td>
|
38 |
</tr>
|
144 |
</tr>
|
145 |
|
146 |
</tbody></table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
admin/tpl/settings_excludes.php
CHANGED
@@ -1,111 +1,116 @@
|
|
1 |
<?php
|
2 |
-
if (!defined('WPINC')) die;
|
3 |
-
|
4 |
?>
|
|
|
5 |
|
6 |
-
|
7 |
-
<
|
8 |
-
<
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
'http://www.example.com/blog/excludethis.php', '/blog/excludethis.php'); ?></li>
|
23 |
-
</ol>
|
24 |
-
</div>
|
25 |
-
<div class="litespeed-desc">
|
26 |
-
<i>
|
27 |
-
<?php echo __('SYNTAX: URLs must start with a \'/\' to be correctly matched.', 'litespeed-cache'); ?><br />
|
28 |
-
<?php echo __('To do an exact match, add \'$\' to the end of the URL. One URL per line.', 'litespeed-cache'); ?>
|
29 |
-
</i>
|
30 |
-
</div>
|
31 |
-
<?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_URI); ?>
|
32 |
|
33 |
-
|
34 |
-
<
|
35 |
-
<
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
<
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
</ol>
|
46 |
-
</div>
|
47 |
-
<div class="litespeed-desc">
|
48 |
-
<i>
|
49 |
-
<?php echo __('SYNTAX: One category id per line.', 'litespeed-cache'); ?>
|
50 |
-
</i>
|
51 |
-
</div>
|
52 |
-
<?php
|
53 |
-
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
|
54 |
-
$excludes_buf = '';
|
55 |
-
$cat_ids = $_options[$id];
|
56 |
-
if ($cat_ids != '') {
|
57 |
-
$id_list = explode(',', $cat_ids);
|
58 |
-
$excludes_buf = implode("\n", array_map('get_cat_name', $id_list));
|
59 |
-
}
|
60 |
-
$this->build_textarea($id, $excludes_buf);
|
61 |
-
?>
|
62 |
|
63 |
-
|
64 |
-
<
|
65 |
-
<
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
<
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
</
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
if (!empty($tag_names)) {
|
94 |
-
$excludes_buf = implode("\n", $tag_names);
|
95 |
-
}
|
96 |
-
}
|
97 |
-
$this->build_textarea($id, $excludes_buf);
|
98 |
-
?>
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
-
|
107 |
-
|
108 |
|
109 |
-
|
110 |
-
|
111 |
|
|
1 |
<?php
|
2 |
+
if ( ! defined( 'WPINC' ) ) die ;
|
|
|
3 |
?>
|
4 |
+
<h3 class="litespeed-title"><?php echo __( 'Do Not Cache Settings', 'litespeed-cache' ) ; ?></h3>
|
5 |
|
6 |
+
<table><tbody>
|
7 |
+
<tr>
|
8 |
+
<th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
|
9 |
+
<td>
|
10 |
+
<?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_URI); ?>
|
11 |
+
<div class="litespeed-desc">
|
12 |
+
<?php echo __('Paths containing these strings will not be cached.', 'litespeed-cache'); ?>
|
13 |
+
<?php echo __('The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache'); ?>
|
14 |
+
<br />
|
15 |
+
<i>
|
16 |
+
<?php echo sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ; ?>
|
17 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
18 |
+
</i>
|
19 |
+
</div>
|
20 |
+
</td>
|
21 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
<tr>
|
24 |
+
<th><?php echo __( 'Do Not Cache Query Strings', 'litespeed-cache' ) ; ?></th>
|
25 |
+
<td>
|
26 |
+
<?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_QS); ?>
|
27 |
+
<div class="litespeed-desc">
|
28 |
+
<?php echo __('Query string containing these parameters will not be cached.', 'litespeed-cache'); ?>
|
29 |
+
<i>
|
30 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
31 |
+
</i>
|
32 |
+
</div>
|
33 |
+
</td>
|
34 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
+
<tr>
|
37 |
+
<th><?php echo __( 'Do Not Cache Categories', 'litespeed-cache' ) ; ?></th>
|
38 |
+
<td>
|
39 |
+
<?php
|
40 |
+
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
|
41 |
+
$excludes_buf = '';
|
42 |
+
$cat_ids = $_options[$id];
|
43 |
+
if ($cat_ids != '') {
|
44 |
+
$id_list = explode(',', $cat_ids);
|
45 |
+
$excludes_buf = implode("\n", array_map('get_cat_name', $id_list));
|
46 |
+
}
|
47 |
+
$this->build_textarea($id, $excludes_buf);
|
48 |
+
?>
|
49 |
+
<div class="litespeed-desc">
|
50 |
+
<b><?php echo __('All categories are cached by default.', 'litespeed-cache'); ?></b>
|
51 |
+
<?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'categories', 'litespeed-cache') ) ; ?>
|
52 |
+
<i>
|
53 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
54 |
+
</i>
|
55 |
+
</div>
|
56 |
+
<div class="litespeed-callout-warning">
|
57 |
+
<h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
|
58 |
+
<ol>
|
59 |
+
<li><?php echo __('If the Category ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
|
60 |
+
<li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
|
61 |
+
'<code>http://www.example.com/category/category-id/</code>', '<code>category-id</code>'); ?></li>
|
62 |
+
</ol>
|
63 |
+
</div>
|
64 |
+
</td>
|
65 |
+
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
67 |
+
<tr>
|
68 |
+
<th><?php echo __( 'Do Not Cache Tags', 'litespeed-cache' ) ; ?></th>
|
69 |
+
<td>
|
70 |
+
<?php
|
71 |
+
$id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
|
72 |
+
$excludes_buf = '';
|
73 |
+
$ids = $_options[$id];
|
74 |
+
if ($ids != '') {
|
75 |
+
$id_list = explode(',', $ids);
|
76 |
+
$tags_list = array_map('get_tag', $id_list);
|
77 |
+
$tag_names = array();
|
78 |
+
foreach ($tags_list as $tag) {
|
79 |
+
$tag_names[] = $tag->name;
|
80 |
+
}
|
81 |
+
if (!empty($tag_names)) {
|
82 |
+
$excludes_buf = implode("\n", $tag_names);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
$this->build_textarea($id, $excludes_buf);
|
86 |
+
?>
|
87 |
+
<div class="litespeed-desc">
|
88 |
+
<b><?php echo __('All tags are cached by default.', 'litespeed-cache'); ?></b>
|
89 |
+
<?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'tags', 'litespeed-cache') ) ; ?>
|
90 |
+
<i>
|
91 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
92 |
+
</i>
|
93 |
+
</div>
|
94 |
+
<div class="litespeed-callout-warning">
|
95 |
+
<h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
|
96 |
+
<ol>
|
97 |
+
<li><?php echo __('If the Tag ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
|
98 |
+
<li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
|
99 |
+
'<code>http://www.example.com/tag/category/tag-id/</code>', '<code>tag-id</code>'); ?></li>
|
100 |
+
</ol>
|
101 |
+
</div>
|
102 |
+
</td>
|
103 |
+
</tr>
|
104 |
+
|
105 |
+
<?php
|
106 |
+
if ( ! is_multisite() ) :
|
107 |
+
// Cookie
|
108 |
+
require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_cookies.php' ;
|
109 |
|
110 |
+
// User Agent
|
111 |
+
require LSWCP_DIR . 'admin/tpl/settings_inc.exclude_useragent.php' ;
|
112 |
|
113 |
+
endif ;
|
114 |
+
?>
|
115 |
|
116 |
+
</tbody></table>
|
admin/tpl/settings_inc.cache_browser.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'WPINC' ) ) die ;
|
3 |
+
|
4 |
+
?>
|
5 |
+
<tr>
|
6 |
+
<th><?php echo __( 'Browser Cache', 'litespeed-cache' ) ; ?></th>
|
7 |
+
<td>
|
8 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ) ; ?>
|
9 |
+
<div class="litespeed-desc">
|
10 |
+
<?php echo __( 'Browser caching stores static files locally in the user\'s browser. Turn on this setting to reduce repeated requests for static files.', 'litespeed-cache' ) ; ?>
|
11 |
+
<i class="litespeed-warning">
|
12 |
+
<?php echo __('NOTE:', 'litespeed-cache'); ?>
|
13 |
+
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
|
14 |
+
</i>
|
15 |
+
<p><?php echo sprintf( __( 'You can turn on browser caching in server admin too. <a %s>Learn more about LiteSpeed browser cache setting</a>.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:browser_cache" target="_blank"' ) ; ?></p>
|
16 |
+
</div>
|
17 |
+
</td>
|
18 |
+
</tr>
|
19 |
+
|
admin/tpl/settings_inc.cache_favicon.php
CHANGED
@@ -10,6 +10,10 @@ $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
|
|
10 |
<div class="litespeed-desc">
|
11 |
<?php echo __('favicon.ico is requested on most pages.', 'litespeed-cache'); ?>
|
12 |
<?php echo __('Caching this resource may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
|
|
|
|
|
|
|
|
|
13 |
</div>
|
14 |
</td>
|
15 |
</tr>
|
10 |
<div class="litespeed-desc">
|
11 |
<?php echo __('favicon.ico is requested on most pages.', 'litespeed-cache'); ?>
|
12 |
<?php echo __('Caching this resource may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
|
13 |
+
<i class="litespeed-warning">
|
14 |
+
<?php echo __('NOTE:', 'litespeed-cache'); ?>
|
15 |
+
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
|
16 |
+
</i>
|
17 |
</div>
|
18 |
</td>
|
19 |
</tr>
|
admin/tpl/settings_inc.cache_mobile.php
CHANGED
@@ -14,6 +14,10 @@ if (!defined('WPINC')) die;
|
|
14 |
<div class="litespeed-desc">
|
15 |
<?php echo __('When enabled, mobile views will be cached separately.', 'litespeed-cache'); ?>
|
16 |
<?php echo __('A site built with responsive design does not need to check this.', 'litespeed-cache'); ?>
|
|
|
|
|
|
|
|
|
17 |
</div>
|
18 |
</td>
|
19 |
</tr>
|
@@ -22,56 +26,44 @@ if (!defined('WPINC')) die;
|
|
22 |
<th><?php echo __('List of Mobile User Agents', 'litespeed-cache'); ?></th>
|
23 |
<td>
|
24 |
<?php
|
25 |
-
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST;
|
26 |
-
$wp_default_mobile = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi';
|
27 |
-
$cache_enable_id = is_network_admin() ? LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED : LiteSpeed_Cache_Config::OPID_ENABLED;
|
28 |
-
$mobile_agents = '';
|
29 |
-
$input_value = $wp_default_mobile;
|
30 |
|
31 |
// if set, use value as input value
|
32 |
-
if ( $_options[
|
33 |
-
|
34 |
-
$input_value = $_options[$id];
|
35 |
|
36 |
// if enabled, check the setting in file
|
37 |
-
if (
|
38 |
|
39 |
-
$
|
40 |
-
$this->display_messages();
|
41 |
-
if ( $mobile_agents ){
|
42 |
-
$input_value = $mobile_agents;
|
43 |
-
}
|
44 |
|
45 |
-
|
|
|
46 |
echo '<div class="litespeed-callout-danger">'
|
47 |
-
. __('Htaccess did not match configuration option.', 'litespeed-cache')
|
48 |
-
. ' ' . __('Please re-enter the mobile view setting.', 'litespeed-cache')
|
49 |
-
. ' ' . sprintf(__('List in WordPress database is: %s', 'litespeed-cache'), '<b>' . $_options[$id] . '</b>')
|
50 |
-
. '</div>';
|
51 |
}
|
52 |
}
|
53 |
}
|
54 |
|
55 |
-
$this->build_input($id, 'litespeed-input-long', false,
|
56 |
?>
|
57 |
|
58 |
<input type="hidden" name="<?php echo LiteSpeed_Cache_Config::OPTION_NAME; ?>[<?php echo $id; ?>__default]"
|
59 |
id="litespeed-mobileview-rules-default"
|
60 |
-
value="<?php echo esc_textarea(
|
61 |
/>
|
62 |
|
63 |
<div class="litespeed-desc">
|
64 |
-
<strong><?php echo __('NOTICE:', 'litespeed-cache'); ?></strong>
|
65 |
-
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?><br />
|
66 |
-
|
67 |
<i>
|
68 |
-
|
69 |
-
echo sprintf(__('
|
70 |
-
. ' ' . sprintf(__('Any spaces should be escaped with a backslash before the space, %s', 'litespeed-cache'), "'\\ '.")
|
71 |
-
. '<br />'
|
72 |
-
. sprintf(__('The default list WordPress uses is %s', 'litespeed-cache'), "<b>$wp_default_mobile</b>");
|
73 |
-
?>
|
74 |
</i>
|
|
|
|
|
|
|
75 |
</div>
|
76 |
</td>
|
77 |
</tr>
|
14 |
<div class="litespeed-desc">
|
15 |
<?php echo __('When enabled, mobile views will be cached separately.', 'litespeed-cache'); ?>
|
16 |
<?php echo __('A site built with responsive design does not need to check this.', 'litespeed-cache'); ?>
|
17 |
+
<i class="litespeed-warning">
|
18 |
+
<?php echo __( 'NOTE:', 'litespeed-cache' ) ; ?>
|
19 |
+
<?php echo __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ; ?>
|
20 |
+
</i>
|
21 |
</div>
|
22 |
</td>
|
23 |
</tr>
|
26 |
<th><?php echo __('List of Mobile User Agents', 'litespeed-cache'); ?></th>
|
27 |
<td>
|
28 |
<?php
|
29 |
+
$id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
|
30 |
+
$wp_default_mobile = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
|
|
|
|
|
|
|
31 |
|
32 |
// if set, use value as input value
|
33 |
+
if ( $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
|
|
|
|
|
34 |
|
35 |
// if enabled, check the setting in file
|
36 |
+
if ( defined( 'LITESPEED_ON' ) ) {
|
37 |
|
38 |
+
$this->display_messages() ;
|
|
|
|
|
|
|
|
|
39 |
|
40 |
+
$mobile_agents = LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_mobile_agents() ;
|
41 |
+
if ( $mobile_agents !== $_options[ $id ] ) {
|
42 |
echo '<div class="litespeed-callout-danger">'
|
43 |
+
. __( 'Htaccess did not match configuration option.', 'litespeed-cache' )
|
44 |
+
. ' ' . __( 'Please re-enter the mobile view setting.', 'litespeed-cache' )
|
45 |
+
. ' ' . sprintf( __( 'List in WordPress database is: %s', 'litespeed-cache' ), '<b>' . $_options[ $id ] . '</b>' )
|
46 |
+
. '</div>' ;
|
47 |
}
|
48 |
}
|
49 |
}
|
50 |
|
51 |
+
$this->build_input( $id, 'litespeed-input-long', false, ! $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ], 'litespeed-mobileview-rules' ) ;
|
52 |
?>
|
53 |
|
54 |
<input type="hidden" name="<?php echo LiteSpeed_Cache_Config::OPTION_NAME; ?>[<?php echo $id; ?>__default]"
|
55 |
id="litespeed-mobileview-rules-default"
|
56 |
+
value="<?php echo esc_textarea( $wp_default_mobile ) ; ?>"
|
57 |
/>
|
58 |
|
59 |
<div class="litespeed-desc">
|
|
|
|
|
|
|
60 |
<i>
|
61 |
+
<?php echo sprintf( __( 'SYNTAX: Each entry should be separated with a bar, %s.', 'litespeed-cache'), "<code>|</code>" ) ; ?>
|
62 |
+
<?php echo sprintf( __( 'Any spaces should be escaped with a backslash before the space, %s.', 'litespeed-cache' ), "<code>\\</code>" ) ; ?>
|
|
|
|
|
|
|
|
|
63 |
</i>
|
64 |
+
<p>
|
65 |
+
<?php echo sprintf( __( 'The default list WordPress uses is %s', 'litespeed-cache' ), "<code>$wp_default_mobile</code>" ) ; ?>
|
66 |
+
</p>
|
67 |
</div>
|
68 |
</td>
|
69 |
</tr>
|
admin/tpl/settings_inc.cache_resources.php
CHANGED
@@ -11,6 +11,10 @@ $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
|
|
11 |
<div class="litespeed-desc">
|
12 |
<?php echo __('Some themes and plugins add resources via a PHP request.', 'litespeed-cache'); ?>
|
13 |
<?php echo __('Caching these pages may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
|
|
|
|
|
|
|
|
|
14 |
</div>
|
15 |
</td>
|
16 |
</tr>
|
11 |
<div class="litespeed-desc">
|
12 |
<?php echo __('Some themes and plugins add resources via a PHP request.', 'litespeed-cache'); ?>
|
13 |
<?php echo __('Caching these pages may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
|
14 |
+
<i class="litespeed-warning">
|
15 |
+
<?php echo __('NOTE:', 'litespeed-cache'); ?>
|
16 |
+
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
|
17 |
+
</i>
|
18 |
</div>
|
19 |
</td>
|
20 |
</tr>
|
admin/tpl/settings_inc.exclude_cookies.php
CHANGED
@@ -1,23 +1,27 @@
|
|
1 |
-
<!-- build_setting_exclude_cookies -->
|
2 |
-
<h3 class="litespeed-title"><?php echo __('Cookie List', 'litespeed-cache'); ?></h3>
|
3 |
-
<p><?php echo __('To prevent cookies from being cached, enter it in the text area below.', 'litespeed-cache'); ?></p>
|
4 |
-
<div class="litespeed-callout-warning">
|
5 |
-
<h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
|
6 |
-
<ol>
|
7 |
-
<li><?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?></li>
|
8 |
-
</ol>
|
9 |
-
</div>
|
10 |
-
<div class="litespeed-desc">
|
11 |
-
<i>
|
12 |
-
<?php echo __('SYNTAX: Cookies should be listed one per line.', 'litespeed-cache'); ?>
|
13 |
-
<?php echo sprintf(__('Spaces should have a backslash in front of them, %s', 'litespeed-cache'), "'\ '."); ?>
|
14 |
-
</i>
|
15 |
-
</div>
|
16 |
-
|
17 |
<?php
|
|
|
|
|
18 |
|
19 |
-
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
$file_writable = LiteSpeed_Cache_Admin_Rules::writable();
|
22 |
|
23 |
-
$this->build_textarea($id, str_replace('|', "\n", $_options[$id]));//, !$file_writable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<?php
|
2 |
+
if ( ! defined( 'WPINC' ) ) die ;
|
3 |
+
?>
|
4 |
|
5 |
+
<tr>
|
6 |
+
<th><?php echo __( 'Do Not Cache Cookies', 'litespeed-cache' ) ; ?></th>
|
7 |
+
<td>
|
8 |
+
<?php
|
9 |
+
$id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
|
10 |
|
11 |
+
$file_writable = LiteSpeed_Cache_Admin_Rules::writable();
|
12 |
|
13 |
+
$this->build_textarea($id, str_replace('|', "\n", $_options[$id]));//, !$file_writable
|
14 |
+
?>
|
15 |
+
<div class="litespeed-desc">
|
16 |
+
<?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'cookies', 'litespeed-cache') ) ; ?>
|
17 |
+
<i>
|
18 |
+
<?php echo sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), '<code>\ </code>'); ?>
|
19 |
+
<?php echo __('One per line.', 'litespeed-cache'); ?>
|
20 |
+
</i>
|
21 |
+
<i class="litespeed-warning">
|
22 |
+
<?php echo __('NOTE:', 'litespeed-cache'); ?>
|
23 |
+
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
|
24 |
+
</i>
|
25 |
+
</div>
|
26 |
+
</td>
|
27 |
+
</tr>
|
admin/tpl/settings_inc.exclude_useragent.php
CHANGED
@@ -3,24 +3,24 @@ if (!defined('WPINC')) die;
|
|
3 |
|
4 |
?>
|
5 |
|
6 |
-
|
7 |
-
<
|
8 |
-
<
|
9 |
-
|
10 |
-
|
11 |
-
<ol>
|
12 |
-
<li><?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?></li>
|
13 |
-
</ol>
|
14 |
-
</div>
|
15 |
-
<div class="litespeed-desc">
|
16 |
-
<i>
|
17 |
-
<?php echo sprintf(__('SYNTAX: Separate each user agent with a bar, <font style="font-style:normal">%s</font>.', 'litespeed-cache'), "'|'"); ?>
|
18 |
-
<?php echo sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), "'\'"); ?>
|
19 |
-
</i>
|
20 |
-
</div>
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
?>
|
5 |
|
6 |
+
<tr>
|
7 |
+
<th><?php echo __( 'Do Not Cache User Agents', 'litespeed-cache' ) ; ?></th>
|
8 |
+
<td>
|
9 |
+
<?php
|
10 |
+
$file_writable = LiteSpeed_Cache_Admin_Rules::writable();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
+
$this->build_input(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS, 'litespeed-input-long');//, !$file_writable
|
13 |
+
?>
|
14 |
+
<div class="litespeed-desc">
|
15 |
+
<?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'user agents', 'litespeed-cache') ) ; ?>
|
16 |
+
<i>
|
17 |
+
<?php echo sprintf( __( 'SYNTAX: Separate each user agent with a bar, %s.', 'litespeed-cache' ), '<code>|</code>' ) ; ?>
|
18 |
+
<?php echo sprintf( __( 'Spaces should have a backslash in front of them, %s.', 'litespeed-cache' ), '<code>\</code>' ) ; ?>
|
19 |
+
</i>
|
20 |
+
<i class="litespeed-warning">
|
21 |
+
<?php echo __('NOTE:', 'litespeed-cache'); ?>
|
22 |
+
<?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
|
23 |
+
</i>
|
24 |
+
</div>
|
25 |
+
</td>
|
26 |
+
</tr>
|
admin/tpl/settings_inc.purge_on_upgrade.php
CHANGED
@@ -4,7 +4,7 @@ if (!defined('WPINC')) die;
|
|
4 |
?>
|
5 |
<!-- build_setting_purge_on_upgrade -->
|
6 |
<tr>
|
7 |
-
<th><?php echo __('Purge All
|
8 |
<td>
|
9 |
<?php $this->build_switch(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE); ?>
|
10 |
<div class="litespeed-desc">
|
4 |
?>
|
5 |
<!-- build_setting_purge_on_upgrade -->
|
6 |
<tr>
|
7 |
+
<th><?php echo __('Purge All On Upgrade', 'litespeed-cache'); ?></th>
|
8 |
<td>
|
9 |
<?php $this->build_switch(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE); ?>
|
10 |
<div class="litespeed-desc">
|
admin/tpl/settings_optimize.php
CHANGED
@@ -115,4 +115,68 @@ if ( ! defined( 'WPINC' ) ) die ;
|
|
115 |
</td>
|
116 |
</tr>
|
117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
</tbody></table>
|
115 |
</td>
|
116 |
</tr>
|
117 |
|
118 |
+
<tr>
|
119 |
+
<th><?php echo __( 'Remove Query Strings', 'litespeed-cache' ) ; ?></th>
|
120 |
+
<td>
|
121 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ; ?>
|
122 |
+
<div class="litespeed-desc">
|
123 |
+
<?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
|
124 |
+
<?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
|
125 |
+
</div>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
|
129 |
+
<tr>
|
130 |
+
<th><?php echo __( 'Remove Google Fonts', 'litespeed-cache' ) ; ?></th>
|
131 |
+
<td>
|
132 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ; ?>
|
133 |
+
<div class="litespeed-desc">
|
134 |
+
<?php echo __( 'Prevent google fonts from loading on all your pages.', 'litespeed-cache' ) ; ?>
|
135 |
+
</div>
|
136 |
+
</td>
|
137 |
+
</tr>
|
138 |
+
|
139 |
+
<tr>
|
140 |
+
<th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
|
141 |
+
<td>
|
142 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ; ?>
|
143 |
+
<div class="litespeed-desc">
|
144 |
+
<?php echo __( 'Optimize CSS delivery. This will load Google Fonts asynchronously too.', 'litespeed-cache' ) ; ?>
|
145 |
+
<?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
|
146 |
+
</div>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
|
150 |
+
<tr>
|
151 |
+
<th><?php echo __( 'Critical CSS Rules', 'litespeed-cache' ) ; ?></th>
|
152 |
+
<td>
|
153 |
+
<?php $this->build_textarea( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, get_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ) ; ?>
|
154 |
+
<div class="litespeed-desc">
|
155 |
+
<?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
|
156 |
+
</div>
|
157 |
+
</td>
|
158 |
+
</tr>
|
159 |
+
|
160 |
+
<tr>
|
161 |
+
<th><?php echo __( 'Load JS Deferred', 'litespeed-cache' ) ; ?></th>
|
162 |
+
<td>
|
163 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ; ?>
|
164 |
+
<div class="litespeed-desc">
|
165 |
+
<?php echo __( 'Doing so can help reduce resource contention and improve performance.', 'litespeed-cache' ) ; ?>
|
166 |
+
<?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
|
167 |
+
</div>
|
168 |
+
</td>
|
169 |
+
</tr>
|
170 |
+
|
171 |
+
<tr>
|
172 |
+
<th><?php echo __( 'Remove WordPress Emoji', 'litespeed-cache' ) ; ?></th>
|
173 |
+
<td>
|
174 |
+
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ; ?>
|
175 |
+
<div class="litespeed-desc">
|
176 |
+
<?php echo __( 'Enable this setting to stop loading emoji from wordpress.org. The visitor\'s browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
|
177 |
+
<?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
|
178 |
+
</div>
|
179 |
+
</td>
|
180 |
+
</tr>
|
181 |
+
|
182 |
</tbody></table>
|
cli/litespeed-cache-cli-admin.class.php
CHANGED
@@ -42,6 +42,11 @@ class LiteSpeed_Cache_Cli_Admin
|
|
42 |
LiteSpeed_Cache_Config::OPID_JS_COMBINE,
|
43 |
LiteSpeed_Cache_Config::OPID_JS_HTTP2,
|
44 |
LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
LiteSpeed_Cache_Config::OPID_CDN,
|
47 |
LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
|
@@ -100,8 +105,8 @@ class LiteSpeed_Cache_Cli_Admin
|
|
100 |
|
101 |
case LiteSpeed_Cache_Config::OPID_CACHE_MOBILE:
|
102 |
// set list then do checkbox
|
103 |
-
if ( $val === 'true' ) {
|
104 |
-
$options[LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
|
105 |
}
|
106 |
//fall through
|
107 |
case LiteSpeed_Cache_Config::OPID_CACHE_PRIV:
|
@@ -131,6 +136,11 @@ class LiteSpeed_Cache_Cli_Admin
|
|
131 |
case LiteSpeed_Cache_Config::OPID_JS_MINIFY:
|
132 |
case LiteSpeed_Cache_Config::OPID_JS_COMBINE:
|
133 |
case LiteSpeed_Cache_Config::OPID_HTML_MINIFY:
|
|
|
|
|
|
|
|
|
|
|
134 |
|
135 |
case LiteSpeed_Cache_Config::OPID_CDN:
|
136 |
case LiteSpeed_Cache_Config::OPID_CDN_INC_IMG:
|
42 |
LiteSpeed_Cache_Config::OPID_JS_COMBINE,
|
43 |
LiteSpeed_Cache_Config::OPID_JS_HTTP2,
|
44 |
LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
|
45 |
+
LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
|
46 |
+
LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
|
47 |
+
LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
|
48 |
+
LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
|
49 |
+
LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
|
50 |
|
51 |
LiteSpeed_Cache_Config::OPID_CDN,
|
52 |
LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
|
105 |
|
106 |
case LiteSpeed_Cache_Config::OPID_CACHE_MOBILE:
|
107 |
// set list then do checkbox
|
108 |
+
if ( $val === 'true' && empty( $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] ) ) {
|
109 |
+
$options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
|
110 |
}
|
111 |
//fall through
|
112 |
case LiteSpeed_Cache_Config::OPID_CACHE_PRIV:
|
136 |
case LiteSpeed_Cache_Config::OPID_JS_MINIFY:
|
137 |
case LiteSpeed_Cache_Config::OPID_JS_COMBINE:
|
138 |
case LiteSpeed_Cache_Config::OPID_HTML_MINIFY:
|
139 |
+
case LiteSpeed_Cache_Config::OPID_OPTM_QS_RM:
|
140 |
+
case LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM:
|
141 |
+
case LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC:
|
142 |
+
case LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER:
|
143 |
+
case LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM:
|
144 |
|
145 |
case LiteSpeed_Cache_Config::OPID_CDN:
|
146 |
case LiteSpeed_Cache_Config::OPID_CDN_INC_IMG:
|
cli/litespeed-cache-cli-purge.class.php
CHANGED
@@ -172,8 +172,7 @@ class LiteSpeed_Cache_Cli_Purge
|
|
172 |
}
|
173 |
}
|
174 |
else {
|
175 |
-
$
|
176 |
-
$deconstructed_site = wp_parse_url($site_url) ;
|
177 |
if ( $deconstructed['host'] !== $deconstructed_site['host'] ) {
|
178 |
WP_CLI::error('Single site url passed in is invalid.') ;
|
179 |
return ;
|
172 |
}
|
173 |
}
|
174 |
else {
|
175 |
+
$deconstructed_site = wp_parse_url( get_home_url() ) ;
|
|
|
176 |
if ( $deconstructed['host'] !== $deconstructed_site['host'] ) {
|
177 |
WP_CLI::error('Single site url passed in is invalid.') ;
|
178 |
return ;
|
{admin/css → css}/fonts/litespeedfont.eot
RENAMED
File without changes
|
{admin/css → css}/fonts/litespeedfont.svg
RENAMED
File without changes
|
{admin/css → css}/fonts/litespeedfont.ttf
RENAMED
File without changes
|
{admin/css → css}/fonts/litespeedfont.woff
RENAMED
File without changes
|
{admin/css → css}/litespeed.css
RENAMED
@@ -18,7 +18,7 @@
|
|
18 |
}
|
19 |
|
20 |
.litespeed-warning {
|
21 |
-
color: #
|
22 |
}
|
23 |
|
24 |
.litespeed-danger {
|
@@ -110,6 +110,8 @@
|
|
110 |
color: #998c85 ;
|
111 |
background-color: #dde9f5;
|
112 |
border-radius: 3px;
|
|
|
|
|
113 |
}
|
114 |
|
115 |
.litespeed-body ul{
|
@@ -121,6 +123,10 @@
|
|
121 |
line-height: 16px;
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
124 |
.litespeed-body p {
|
125 |
margin: 1em ;
|
126 |
}
|
@@ -746,7 +752,7 @@ ul.litespeed-shell-body {
|
|
746 |
border-left-width: 5px;
|
747 |
color: #538ac6;
|
748 |
margin: 13px 0;
|
749 |
-
background: #
|
750 |
}
|
751 |
|
752 |
[class*="litespeed-callout-"] h4 {
|
@@ -1118,6 +1124,11 @@ ul.litespeed-shell-body {
|
|
1118 |
border-radius: 3px;
|
1119 |
}
|
1120 |
|
|
|
|
|
|
|
|
|
|
|
1121 |
|
1122 |
.litespeed-body input,.litespeed-body textarea {
|
1123 |
border: 1px solid #6699cc;
|
18 |
}
|
19 |
|
20 |
.litespeed-warning {
|
21 |
+
color: #e59544!important;
|
22 |
}
|
23 |
|
24 |
.litespeed-danger {
|
110 |
color: #998c85 ;
|
111 |
background-color: #dde9f5;
|
112 |
border-radius: 3px;
|
113 |
+
font-size: 11px;
|
114 |
+
font-style: normal;
|
115 |
}
|
116 |
|
117 |
.litespeed-body ul{
|
123 |
line-height: 16px;
|
124 |
}
|
125 |
|
126 |
+
.litespeed-body .litespeed-desc i {
|
127 |
+
font-size: 12px;
|
128 |
+
}
|
129 |
+
|
130 |
.litespeed-body p {
|
131 |
margin: 1em ;
|
132 |
}
|
752 |
border-left-width: 5px;
|
753 |
color: #538ac6;
|
754 |
margin: 13px 0;
|
755 |
+
background: #f2f9ff;
|
756 |
}
|
757 |
|
758 |
[class*="litespeed-callout-"] h4 {
|
1124 |
border-radius: 3px;
|
1125 |
}
|
1126 |
|
1127 |
+
.litespeed-float-submit {
|
1128 |
+
position: absolute;
|
1129 |
+
right: 10px;
|
1130 |
+
top: 10px;
|
1131 |
+
}
|
1132 |
|
1133 |
.litespeed-body input,.litespeed-body textarea {
|
1134 |
border: 1px solid #6699cc;
|
{admin/img → img}/Litespeed.icon.svg
RENAMED
File without changes
|
{admin/img → img}/icons/all.svg
RENAMED
File without changes
|
{admin/img → img}/icons/all_transients.svg
RENAMED
File without changes
|
{admin/img → img}/icons/auto_draft.svg
RENAMED
File without changes
|
{admin/img → img}/icons/cross_icon.svg
RENAMED
File without changes
|
{admin/img → img}/icons/db.svg
RENAMED
File without changes
|
{admin/img → img}/icons/empty-cache.svg
RENAMED
File without changes
|
{admin/img → img}/icons/expired_transient.svg
RENAMED
File without changes
|
{admin/img → img}/icons/optimize_tables.svg
RENAMED
File without changes
|
{admin/img → img}/icons/purge-403.svg
RENAMED
File without changes
|
{admin/img → img}/icons/purge-404.svg
RENAMED
File without changes
|
{admin/img → img}/icons/purge-500.svg
RENAMED
File without changes
|
{admin/img → img}/icons/purge-all.svg
RENAMED
File without changes
|
{admin/img → img}/icons/purge-cssjs.svg
RENAMED
File without changes
|
img/icons/purge-front.svg
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 16.0.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
5 |
+
width="75px" height="75px" viewBox="0 0 75 75" enable-background="new 0 0 75 75" xml:space="preserve">
|
6 |
+
<g>
|
7 |
+
<path fill="#21A0DF" d="M63.657,12.237c-0.045-0.116-0.109-0.227-0.205-0.318L52.954,1.835c-0.028-0.027-0.065-0.039-0.097-0.062
|
8 |
+
c-0.059-0.043-0.115-0.089-0.185-0.117c-0.069-0.027-0.142-0.034-0.215-0.043c-0.037-0.005-0.071-0.022-0.11-0.022H52.33h-0.001
|
9 |
+
H14.114c-1.577,0-2.86,1.283-2.86,2.859v66.923c0,1.577,1.283,2.859,2.86,2.859h46.772c1.576,0,2.859-1.282,2.859-2.859V12.608
|
10 |
+
C63.746,12.474,63.711,12.351,63.657,12.237z M53.223,4.52l7.51,7.213h-7.395c-0.064,0-0.115-0.052-0.115-0.118V4.52z
|
11 |
+
M61.996,71.373c0,0.611-0.498,1.109-1.109,1.109H14.114c-0.612,0-1.11-0.498-1.11-1.109V4.45c0-0.612,0.498-1.109,1.11-1.109
|
12 |
+
h37.358v8.274c0,1.03,0.837,1.868,1.865,1.868h8.658V71.373z"/>
|
13 |
+
<path fill="#21A0DF" d="M45.429,44.487c-6.656,0-12.071,5.416-12.071,12.072s5.415,12.071,12.071,12.071
|
14 |
+
s12.072-5.415,12.072-12.071S52.085,44.487,45.429,44.487z M45.429,66.881c-5.691,0-10.321-4.63-10.321-10.321
|
15 |
+
s4.63-10.322,10.321-10.322s10.322,4.631,10.322,10.322S51.12,66.881,45.429,66.881z"/>
|
16 |
+
<path fill="#21A0DF" d="M51.299,50.689c-0.342-0.342-0.896-0.342-1.238,0L45.43,55.32l-4.631-4.631
|
17 |
+
c-0.342-0.342-0.896-0.342-1.238,0c-0.341,0.342-0.341,0.896,0,1.238l4.631,4.631l-4.631,4.631c-0.341,0.342-0.341,0.896,0,1.238
|
18 |
+
c0.171,0.171,0.396,0.256,0.619,0.256s0.448-0.085,0.619-0.256l4.631-4.631l4.631,4.631c0.171,0.171,0.396,0.256,0.619,0.256
|
19 |
+
s0.448-0.085,0.619-0.256c0.341-0.342,0.341-0.896,0-1.238l-4.631-4.631l4.631-4.631C51.64,51.586,51.64,51.031,51.299,50.689z"/>
|
20 |
+
<path fill="#21A0DF" d="M19.826,18.879c0,0.483,0.392,0.875,0.875,0.875h33.598c0.483,0,0.875-0.392,0.875-0.875
|
21 |
+
s-0.392-0.875-0.875-0.875H20.701C20.218,18.004,19.826,18.396,19.826,18.879z"/>
|
22 |
+
<path fill="#21A0DF" d="M20.701,29.511h33.598c0.483,0,0.875-0.392,0.875-0.875s-0.392-0.875-0.875-0.875H20.701
|
23 |
+
c-0.483,0-0.875,0.392-0.875,0.875S20.218,29.511,20.701,29.511z"/>
|
24 |
+
<path fill="#21A0DF" d="M20.701,39.269h33.598c0.483,0,0.875-0.392,0.875-0.875s-0.392-0.875-0.875-0.875H20.701
|
25 |
+
c-0.483,0-0.875,0.392-0.875,0.875S20.218,39.269,20.701,39.269z"/>
|
26 |
+
<path fill="#21A0DF" d="M30.125,47.276h-9.423c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875h9.423
|
27 |
+
c0.483,0,0.875-0.392,0.875-0.875S30.608,47.276,30.125,47.276z"/>
|
28 |
+
<path fill="#21A0DF" d="M27.75,57.034h-7.049c-0.483,0-0.875,0.392-0.875,0.875s0.392,0.875,0.875,0.875h7.049
|
29 |
+
c0.483,0,0.875-0.392,0.875-0.875S28.233,57.034,27.75,57.034z"/>
|
30 |
+
</g>
|
31 |
+
</svg>
|
{admin/img → img}/icons/purge-pages.svg
RENAMED
File without changes
|
{admin/img → img}/icons/revision.svg
RENAMED
File without changes
|
{admin/img → img}/icons/spam_comment.svg
RENAMED
File without changes
|
{admin/img → img}/icons/success_icon.svg
RENAMED
File without changes
|
{admin/img → img}/icons/trackback-pingback.svg
RENAMED
File without changes
|
{admin/img → img}/icons/trash_comment.svg
RENAMED
File without changes
|
{admin/img → img}/icons/trash_post.svg
RENAMED
File without changes
|
inc/data.class.php
ADDED
@@ -0,0 +1,177 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The class to store and manage litespeed db data.
|
5 |
+
*
|
6 |
+
* @since 1.3.1
|
7 |
+
* @package LiteSpeed_Cache
|
8 |
+
* @subpackage LiteSpeed_Cache/includes
|
9 |
+
* @author LiteSpeed Technologies <info@litespeedtech.com>
|
10 |
+
*/
|
11 |
+
|
12 |
+
class LiteSpeed_Cache_Data
|
13 |
+
{
|
14 |
+
private static $_instance ;
|
15 |
+
|
16 |
+
const TB_OPTIMIZER = 'litespeed_optimizer' ;
|
17 |
+
|
18 |
+
private $_charset_collate ;
|
19 |
+
private $_tb_optm ;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Init
|
23 |
+
*
|
24 |
+
* @since 1.3.1
|
25 |
+
* @access private
|
26 |
+
*/
|
27 |
+
private function __construct()
|
28 |
+
{
|
29 |
+
LiteSpeed_Cache_Log::debug2( 'Data init' ) ;
|
30 |
+
global $wpdb ;
|
31 |
+
|
32 |
+
$this->_charset_collate = $wpdb->get_charset_collate() ;
|
33 |
+
|
34 |
+
$this->_tb_optm = $wpdb->base_prefix . self::TB_OPTIMIZER ;
|
35 |
+
|
36 |
+
$this->_optm_sync() ;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* save optimizer src to db
|
41 |
+
*
|
42 |
+
* @since 1.3.1
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public static function optm_save_src( $filename, $src )
|
46 |
+
{
|
47 |
+
$instance = self::get_instance() ;
|
48 |
+
return $instance->_optm_save_src( $filename, $src ) ;
|
49 |
+
}
|
50 |
+
private function _optm_save_src( $filename, $src )
|
51 |
+
{
|
52 |
+
global $wpdb ;
|
53 |
+
|
54 |
+
$src = serialize( $src ) ;
|
55 |
+
$f = array(
|
56 |
+
'hash_name' => $filename,
|
57 |
+
'src' => $src,
|
58 |
+
'dateline' => time(),
|
59 |
+
'refer' => ! empty( $SERVER[ 'SCRIPT_URI' ] ) ? $SERVER[ 'SCRIPT_URI' ] : '',
|
60 |
+
) ;
|
61 |
+
|
62 |
+
$res = $wpdb->replace( $this->_tb_optm, $f ) ;
|
63 |
+
|
64 |
+
return $res ;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Get src set from hash in optimizer
|
69 |
+
*
|
70 |
+
* @since 1.3.1
|
71 |
+
* @access public
|
72 |
+
*/
|
73 |
+
public static function optm_hash2src( $filename )
|
74 |
+
{
|
75 |
+
$instance = self::get_instance() ;
|
76 |
+
return $instance->_optm_hash2src( $filename ) ;
|
77 |
+
}
|
78 |
+
private function _optm_hash2src( $filename )
|
79 |
+
{
|
80 |
+
global $wpdb ;
|
81 |
+
|
82 |
+
$s = $wpdb->prepare( 'SELECT src FROM `' . $this->_tb_optm . '` WHERE `hash_name` = %s', $filename ) ;
|
83 |
+
|
84 |
+
$res = $wpdb->get_var( $s ) ;
|
85 |
+
|
86 |
+
LiteSpeed_Cache_Log::debug2( 'Data: Loaded hash2src ' . $res ) ;
|
87 |
+
|
88 |
+
$res = unserialize( $res ) ;
|
89 |
+
|
90 |
+
return $res ;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Create optimizer table
|
95 |
+
*
|
96 |
+
* @since 1.3.1
|
97 |
+
* @access private
|
98 |
+
*/
|
99 |
+
private function _optm_sync()
|
100 |
+
{
|
101 |
+
if ( defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
|
102 |
+
return ;
|
103 |
+
}
|
104 |
+
define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
|
105 |
+
|
106 |
+
// if ( get_option( $this->_tb_optm ) ) {
|
107 |
+
// return ;
|
108 |
+
// }
|
109 |
+
|
110 |
+
global $wpdb ;
|
111 |
+
|
112 |
+
LiteSpeed_Cache_Log::debug2( 'Data: Checking optm table' ) ;
|
113 |
+
|
114 |
+
// Check if table exists first
|
115 |
+
$res = $wpdb->get_var( "SHOW TABLES LIKE '$this->_tb_optm'" ) ;
|
116 |
+
if ( $res ) {
|
117 |
+
LiteSpeed_Cache_Log::debug2( 'Data: Existed' ) ;
|
118 |
+
|
119 |
+
return ;
|
120 |
+
}
|
121 |
+
|
122 |
+
LiteSpeed_Cache_Log::debug( 'Data: Creating optm table' ) ;
|
123 |
+
|
124 |
+
$s = sprintf(
|
125 |
+
'CREATE TABLE IF NOT EXISTS `%1$s` (
|
126 |
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
127 |
+
`hash_name` varchar(60) NOT NULL COMMENT "hash.filetype",
|
128 |
+
`src` text NOT NULL COMMENT "full url array set",
|
129 |
+
`dateline` int(11) NOT NULL,
|
130 |
+
`refer` varchar(255) NOT NULL COMMENT "The container page url",
|
131 |
+
PRIMARY KEY (`id`),
|
132 |
+
UNIQUE KEY `hash_name` (`hash_name`),
|
133 |
+
KEY `dateline` (`dateline`)
|
134 |
+
) %2$s;',
|
135 |
+
$this->_tb_optm,
|
136 |
+
$this->_charset_collate
|
137 |
+
) ;
|
138 |
+
|
139 |
+
$wpdb->query( $s ) ;
|
140 |
+
|
141 |
+
// Move data from wp_options to here
|
142 |
+
$hashes = get_option( 'litespeed-cache-optimized' ) ;
|
143 |
+
if ( $hashes ) {
|
144 |
+
foreach ( $hashes as $k => $v ) {
|
145 |
+
$f = array(
|
146 |
+
'hash_name' => $k,
|
147 |
+
'src' => serialize( $v ),
|
148 |
+
'dateline' => time(),
|
149 |
+
'refer' => '',
|
150 |
+
) ;
|
151 |
+
$wpdb->replace( $this->_tb_optm, $f ) ;
|
152 |
+
}
|
153 |
+
}
|
154 |
+
delete_option( 'litespeed-cache-optimized' ) ;
|
155 |
+
|
156 |
+
// Record tb version
|
157 |
+
update_option( $this->_tb_optm, LiteSpeed_Cache::PLUGIN_VERSION ) ;
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Get the current instance object.
|
163 |
+
*
|
164 |
+
* @since 1.3.1
|
165 |
+
* @access public
|
166 |
+
* @return Current class instance.
|
167 |
+
*/
|
168 |
+
public static function get_instance()
|
169 |
+
{
|
170 |
+
if ( ! isset( self::$_instance ) ) {
|
171 |
+
self::$_instance = new self() ;
|
172 |
+
}
|
173 |
+
|
174 |
+
return self::$_instance ;
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
includes/litespeed-cache-activation.class.php
CHANGED
@@ -23,25 +23,24 @@ class LiteSpeed_Cache_Activation
|
|
23 |
public static function register_activation()
|
24 |
{
|
25 |
$count = 0 ;
|
26 |
-
|
27 |
-
|
28 |
-
}
|
29 |
self::try_copy_advanced_cache() ;
|
30 |
-
LiteSpeed_Cache_Config::wp_cache_var_setter(true) ;
|
31 |
|
32 |
if ( is_multisite() ) {
|
33 |
$count = self::get_network_count() ;
|
34 |
if ( $count !== false ) {
|
35 |
-
$count = intval($count) + 1 ;
|
36 |
-
set_site_transient(self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS) ;
|
37 |
}
|
38 |
}
|
39 |
-
do_action('litespeed_cache_api_load_thirdparty') ;
|
40 |
-
LiteSpeed_Cache_Config::get_instance()->plugin_activation($count) ;
|
41 |
LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
|
42 |
|
43 |
-
if (defined('LSCWP_PLUGIN_NAME')) {
|
44 |
-
set_transient(LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL) ;
|
45 |
}
|
46 |
|
47 |
// Register crawler cron task
|
@@ -72,20 +71,20 @@ class LiteSpeed_Cache_Activation
|
|
72 |
* @param array $args Arguments to pass into get_sites/wp_get_sites.
|
73 |
* @return array The array of blog ids.
|
74 |
*/
|
75 |
-
public static function get_network_ids($args = array())
|
76 |
{
|
77 |
global $wp_version ;
|
78 |
-
if ( version_compare($wp_version, '4.6', '<') ) {
|
79 |
-
$blogs = wp_get_sites($args) ;
|
80 |
-
if ( !empty($blogs) ) {
|
81 |
foreach ( $blogs as $key => $blog ) {
|
82 |
-
$blogs[$key] = $blog['blog_id'] ;
|
83 |
}
|
84 |
}
|
85 |
}
|
86 |
else {
|
87 |
-
$args['fields'] = 'ids' ;
|
88 |
-
$blogs = get_sites($args) ;
|
89 |
}
|
90 |
return $blogs ;
|
91 |
}
|
@@ -99,26 +98,27 @@ class LiteSpeed_Cache_Activation
|
|
99 |
*/
|
100 |
private static function get_network_count()
|
101 |
{
|
102 |
-
$count = get_site_transient(self::NETWORK_TRANSIENT_COUNT) ;
|
103 |
if ( $count !== false ) {
|
104 |
-
return intval($count) ;
|
105 |
}
|
106 |
// need to update
|
107 |
$default = array() ;
|
108 |
$count = 0 ;
|
109 |
|
110 |
-
$sites = self::get_network_ids(array('deleted' => 0)) ;
|
111 |
-
if ( empty($sites) ) {
|
112 |
return false ;
|
113 |
}
|
114 |
|
115 |
foreach ( $sites as $site ) {
|
116 |
-
$
|
117 |
-
|
|
|
118 |
$count++ ;
|
119 |
}
|
120 |
}
|
121 |
-
if ( is_plugin_active_for_network(LSWCP_BASENAME) ) {
|
122 |
$count++ ;
|
123 |
}
|
124 |
return $count ;
|
@@ -141,11 +141,11 @@ class LiteSpeed_Cache_Activation
|
|
141 |
if ( $count !== 1 ) {
|
142 |
// Not deactivating the last one.
|
143 |
$count-- ;
|
144 |
-
set_site_transient(self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS) ;
|
145 |
return false ;
|
146 |
}
|
147 |
|
148 |
-
delete_site_transient(self::NETWORK_TRANSIENT_COUNT) ;
|
149 |
return true ;
|
150 |
}
|
151 |
|
@@ -160,27 +160,17 @@ class LiteSpeed_Cache_Activation
|
|
160 |
public static function register_deactivation()
|
161 |
{
|
162 |
LiteSpeed_Cache_Task::clear() ;
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
LiteSpeed_Cache_Purge::purge_all() ;
|
167 |
|
168 |
if ( is_multisite() ) {
|
169 |
-
|
170 |
-
|
171 |
-
if (
|
172 |
-
|
173 |
-
|
174 |
-
update_site_option(LiteSpeed_Cache_Config::OPTION_NAME, $opt_str) ;
|
175 |
-
}
|
176 |
-
}
|
177 |
-
if ( !self::is_deactivate_last() ) {
|
178 |
-
if ( is_network_admin()
|
179 |
-
&& isset($opt_str)
|
180 |
-
&& $options[LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED] ) {
|
181 |
-
$reset = LiteSpeed_Cache_Config::get_rule_reset_options() ;
|
182 |
-
$errors = array() ;
|
183 |
-
LiteSpeed_Cache_Admin_Rules::get_instance()->validate_common_rewrites($reset, $errors) ;
|
184 |
}
|
185 |
return ;
|
186 |
}
|
@@ -188,22 +178,24 @@ class LiteSpeed_Cache_Activation
|
|
188 |
|
189 |
$adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
|
190 |
// this file can be generated by other cache plugin like w3tc, we only delete our own file
|
191 |
-
if ( file_exists($adv_cache_path) && is_writable($adv_cache_path) ) {
|
192 |
-
if ( strpos(file_get_contents($adv_cache_path), 'LSCACHE_ADV_CACHE') !== false ) {
|
193 |
-
unlink($adv_cache_path) ;
|
194 |
}
|
195 |
else {
|
196 |
-
error_log('Keep advanced-cache.php as it belongs to other plugins') ;
|
197 |
}
|
198 |
}
|
199 |
else {
|
200 |
-
error_log('Failed to remove advanced-cache.php, file does not exist or is not writable!') ;
|
201 |
}
|
202 |
|
203 |
-
if ( !LiteSpeed_Cache_Config::wp_cache_var_setter(false) ) {
|
204 |
error_log('In wp-config.php: WP_CACHE could not be set to false during deactivation!') ;
|
205 |
}
|
|
|
206 |
LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules( true ) ;
|
|
|
207 |
// delete in case it's not deleted prior to deactivation.
|
208 |
self::dismiss_whm() ;
|
209 |
}
|
@@ -218,15 +210,13 @@ class LiteSpeed_Cache_Activation
|
|
218 |
public static function try_copy_advanced_cache()
|
219 |
{
|
220 |
$adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
|
221 |
-
if (file_exists($adv_cache_path)
|
222 |
-
&& (filesize($adv_cache_path) !== 0
|
223 |
-
|| !is_writable($adv_cache_path)) ) {
|
224 |
return false ;
|
225 |
}
|
226 |
|
227 |
-
copy(LSWCP_DIR . 'includes/advanced-cache.php', $adv_cache_path) ;
|
228 |
-
include($adv_cache_path) ;
|
229 |
-
$ret = defined('LSCACHE_ADV_CACHE') ;
|
230 |
return $ret ;
|
231 |
}
|
232 |
|
@@ -238,7 +228,7 @@ class LiteSpeed_Cache_Activation
|
|
238 |
*/
|
239 |
public static function dismiss_whm()
|
240 |
{
|
241 |
-
delete_transient(LiteSpeed_Cache::WHM_TRANSIENT) ;
|
242 |
}
|
243 |
|
244 |
|
23 |
public static function register_activation()
|
24 |
{
|
25 |
$count = 0 ;
|
26 |
+
! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
|
27 |
+
|
|
|
28 |
self::try_copy_advanced_cache() ;
|
29 |
+
LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
|
30 |
|
31 |
if ( is_multisite() ) {
|
32 |
$count = self::get_network_count() ;
|
33 |
if ( $count !== false ) {
|
34 |
+
$count = intval( $count ) + 1 ;
|
35 |
+
set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
|
36 |
}
|
37 |
}
|
38 |
+
do_action( 'litespeed_cache_api_load_thirdparty' ) ;
|
39 |
+
LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
|
40 |
LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
|
41 |
|
42 |
+
if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
|
43 |
+
set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
|
44 |
}
|
45 |
|
46 |
// Register crawler cron task
|
71 |
* @param array $args Arguments to pass into get_sites/wp_get_sites.
|
72 |
* @return array The array of blog ids.
|
73 |
*/
|
74 |
+
public static function get_network_ids( $args = array() )
|
75 |
{
|
76 |
global $wp_version ;
|
77 |
+
if ( version_compare( $wp_version, '4.6', '<' ) ) {
|
78 |
+
$blogs = wp_get_sites( $args ) ;
|
79 |
+
if ( ! empty( $blogs ) ) {
|
80 |
foreach ( $blogs as $key => $blog ) {
|
81 |
+
$blogs[ $key ] = $blog[ 'blog_id' ] ;
|
82 |
}
|
83 |
}
|
84 |
}
|
85 |
else {
|
86 |
+
$args[ 'fields' ] = 'ids' ;
|
87 |
+
$blogs = get_sites( $args ) ;
|
88 |
}
|
89 |
return $blogs ;
|
90 |
}
|
98 |
*/
|
99 |
private static function get_network_count()
|
100 |
{
|
101 |
+
$count = get_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
|
102 |
if ( $count !== false ) {
|
103 |
+
return intval( $count ) ;
|
104 |
}
|
105 |
// need to update
|
106 |
$default = array() ;
|
107 |
$count = 0 ;
|
108 |
|
109 |
+
$sites = self::get_network_ids( array( 'deleted' => 0 ) ) ;
|
110 |
+
if ( empty( $sites ) ) {
|
111 |
return false ;
|
112 |
}
|
113 |
|
114 |
foreach ( $sites as $site ) {
|
115 |
+
$bid = is_object( $site ) && property_exists( $site, 'blog_id' ) ? $site->blog_id : $site ;
|
116 |
+
$plugins = get_blog_option( $bid , 'active_plugins', $default ) ;
|
117 |
+
if ( in_array( LSWCP_BASENAME, $plugins, true ) ) {
|
118 |
$count++ ;
|
119 |
}
|
120 |
}
|
121 |
+
if ( is_plugin_active_for_network( LSWCP_BASENAME ) ) {
|
122 |
$count++ ;
|
123 |
}
|
124 |
return $count ;
|
141 |
if ( $count !== 1 ) {
|
142 |
// Not deactivating the last one.
|
143 |
$count-- ;
|
144 |
+
set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
|
145 |
return false ;
|
146 |
}
|
147 |
|
148 |
+
delete_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
|
149 |
return true ;
|
150 |
}
|
151 |
|
160 |
public static function register_deactivation()
|
161 |
{
|
162 |
LiteSpeed_Cache_Task::clear() ;
|
163 |
+
|
164 |
+
! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Deactivate_' . get_current_blog_id() ) ;
|
165 |
+
|
166 |
LiteSpeed_Cache_Purge::purge_all() ;
|
167 |
|
168 |
if ( is_multisite() ) {
|
169 |
+
|
170 |
+
if ( ! self::is_deactivate_last() ) {
|
171 |
+
if ( is_network_admin() ) {
|
172 |
+
// Still other activated subsite left, set .htaccess with only CacheLookUp
|
173 |
+
LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
return ;
|
176 |
}
|
178 |
|
179 |
$adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
|
180 |
// this file can be generated by other cache plugin like w3tc, we only delete our own file
|
181 |
+
if ( file_exists( $adv_cache_path ) && is_writable( $adv_cache_path ) ) {
|
182 |
+
if ( strpos( file_get_contents( $adv_cache_path ), 'LSCACHE_ADV_CACHE' ) !== false ) {
|
183 |
+
unlink( $adv_cache_path ) ;
|
184 |
}
|
185 |
else {
|
186 |
+
error_log(' Keep advanced-cache.php as it belongs to other plugins' ) ;
|
187 |
}
|
188 |
}
|
189 |
else {
|
190 |
+
error_log( 'Failed to remove advanced-cache.php, file does not exist or is not writable!' ) ;
|
191 |
}
|
192 |
|
193 |
+
if ( ! LiteSpeed_Cache_Config::wp_cache_var_setter( false ) ) {
|
194 |
error_log('In wp-config.php: WP_CACHE could not be set to false during deactivation!') ;
|
195 |
}
|
196 |
+
|
197 |
LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules( true ) ;
|
198 |
+
|
199 |
// delete in case it's not deleted prior to deactivation.
|
200 |
self::dismiss_whm() ;
|
201 |
}
|
210 |
public static function try_copy_advanced_cache()
|
211 |
{
|
212 |
$adv_cache_path = LSWCP_CONTENT_DIR . '/advanced-cache.php' ;
|
213 |
+
if ( file_exists( $adv_cache_path ) && ( filesize( $adv_cache_path ) !== 0 || ! is_writable( $adv_cache_path ) ) ) {
|
|
|
|
|
214 |
return false ;
|
215 |
}
|
216 |
|
217 |
+
copy( LSWCP_DIR . 'includes/advanced-cache.php', $adv_cache_path ) ;
|
218 |
+
include( $adv_cache_path ) ;
|
219 |
+
$ret = defined( 'LSCACHE_ADV_CACHE' ) ;
|
220 |
return $ret ;
|
221 |
}
|
222 |
|
228 |
*/
|
229 |
public static function dismiss_whm()
|
230 |
{
|
231 |
+
delete_transient( LiteSpeed_Cache::WHM_TRANSIENT ) ;
|
232 |
}
|
233 |
|
234 |
|
includes/litespeed-cache-api.class.php
CHANGED
@@ -10,6 +10,8 @@
|
|
10 |
*/
|
11 |
class LiteSpeed_Cache_API
|
12 |
{
|
|
|
|
|
13 |
const TYPE_FEED = LiteSpeed_Cache_Tag::TYPE_FEED ;
|
14 |
const TYPE_FRONTPAGE = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
|
15 |
const TYPE_HOME = LiteSpeed_Cache_Tag::TYPE_HOME ;
|
@@ -34,6 +36,17 @@ class LiteSpeed_Cache_API
|
|
34 |
const VAL_ON = LiteSpeed_Cache_Config::VAL_ON ;
|
35 |
const VAL_ON2 = LiteSpeed_Cache_Config::VAL_ON2 ;
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
/**
|
38 |
* Set mobile
|
39 |
*
|
@@ -155,6 +168,18 @@ class LiteSpeed_Cache_API
|
|
155 |
LiteSpeed_Cache_Purge::purge_all() ;
|
156 |
}
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
/**
|
159 |
* Add purge tags
|
160 |
*
|
@@ -220,6 +245,8 @@ class LiteSpeed_Cache_API
|
|
220 |
/**
|
221 |
* Hook vary appending to vary
|
222 |
*
|
|
|
|
|
223 |
* @since 1.1.3
|
224 |
* @access public
|
225 |
*/
|
@@ -334,9 +361,12 @@ class LiteSpeed_Cache_API
|
|
334 |
* @access public
|
335 |
* @param string $control Cache control tag
|
336 |
*/
|
337 |
-
public static function esi_url($block_id, $wrapper, $params = array(), $control = '
|
338 |
{
|
339 |
-
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
/**
|
@@ -361,6 +391,17 @@ class LiteSpeed_Cache_API
|
|
361 |
return LiteSpeed_Cache_Router::esi_enabled() ;
|
362 |
}
|
363 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
364 |
/**
|
365 |
* Get cfg setting value
|
366 |
*
|
10 |
*/
|
11 |
class LiteSpeed_Cache_API
|
12 |
{
|
13 |
+
const VERSION = LiteSpeed_Cache::PLUGIN_VERSION ;
|
14 |
+
|
15 |
const TYPE_FEED = LiteSpeed_Cache_Tag::TYPE_FEED ;
|
16 |
const TYPE_FRONTPAGE = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
|
17 |
const TYPE_HOME = LiteSpeed_Cache_Tag::TYPE_HOME ;
|
36 |
const VAL_ON = LiteSpeed_Cache_Config::VAL_ON ;
|
37 |
const VAL_ON2 = LiteSpeed_Cache_Config::VAL_ON2 ;
|
38 |
|
39 |
+
/**
|
40 |
+
* Compare version
|
41 |
+
*
|
42 |
+
* @since 1.3
|
43 |
+
* @access public
|
44 |
+
*/
|
45 |
+
public static function v( $v )
|
46 |
+
{
|
47 |
+
return version_compare( self::VERSION, $v, '>=' ) ;
|
48 |
+
}
|
49 |
+
|
50 |
/**
|
51 |
* Set mobile
|
52 |
*
|
168 |
LiteSpeed_Cache_Purge::purge_all() ;
|
169 |
}
|
170 |
|
171 |
+
/**
|
172 |
+
* Purge single action
|
173 |
+
*
|
174 |
+
* @since 1.3
|
175 |
+
* @access public
|
176 |
+
* @param int $pid The ID of a post
|
177 |
+
*/
|
178 |
+
public static function purge_post( $pid )
|
179 |
+
{
|
180 |
+
LiteSpeed_Cache_Purge::purge_post( $pid ) ;
|
181 |
+
}
|
182 |
+
|
183 |
/**
|
184 |
* Add purge tags
|
185 |
*
|
245 |
/**
|
246 |
* Hook vary appending to vary
|
247 |
*
|
248 |
+
* NOTE: This will add vary to rewrite rule
|
249 |
+
*
|
250 |
* @since 1.1.3
|
251 |
* @access public
|
252 |
*/
|
361 |
* @access public
|
362 |
* @param string $control Cache control tag
|
363 |
*/
|
364 |
+
public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false )
|
365 |
{
|
366 |
+
if ( $control === 'default' ) {
|
367 |
+
$control = 'private,no-vary' ;
|
368 |
+
}
|
369 |
+
return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence ) ;
|
370 |
}
|
371 |
|
372 |
/**
|
391 |
return LiteSpeed_Cache_Router::esi_enabled() ;
|
392 |
}
|
393 |
|
394 |
+
/**
|
395 |
+
* Get cache enable setting value
|
396 |
+
*
|
397 |
+
* @since 1.3
|
398 |
+
* @access public
|
399 |
+
*/
|
400 |
+
public static function cache_enabled()
|
401 |
+
{
|
402 |
+
return defined( 'LITESPEED_ON' ) ;
|
403 |
+
}
|
404 |
+
|
405 |
/**
|
406 |
* Get cfg setting value
|
407 |
*
|
includes/litespeed-cache-cdn.class.php
CHANGED
@@ -332,15 +332,20 @@ class LiteSpeed_Cache_CDN
|
|
332 |
*/
|
333 |
public function rewrite( $url )
|
334 |
{
|
|
|
335 |
$url_parsed = parse_url( $url ) ;
|
336 |
|
337 |
// Only images under wp-cotnent/wp-includes can be replaced
|
338 |
if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
|
339 |
-
|
|
|
|
|
|
|
340 |
}
|
341 |
|
342 |
// Check if is external url
|
343 |
if ( ! empty( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
|
|
|
344 |
return false ;
|
345 |
}
|
346 |
|
@@ -353,15 +358,22 @@ class LiteSpeed_Cache_CDN
|
|
353 |
}
|
354 |
}
|
355 |
|
356 |
-
// Fill
|
357 |
if ( empty( $url_parsed[ 'host' ] ) ) {
|
358 |
-
$url =
|
|
|
|
|
|
|
359 |
}
|
360 |
|
361 |
$scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
|
|
|
|
|
|
|
362 |
|
363 |
// Now lets replace CDN url
|
364 |
$url = str_replace( $scheme . $this->cfg_url_ori, $this->cfg_cdn_url, $url ) ;
|
|
|
365 |
|
366 |
return $url ;
|
367 |
}
|
332 |
*/
|
333 |
public function rewrite( $url )
|
334 |
{
|
335 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: try rewriting ' . $url ) ;
|
336 |
$url_parsed = parse_url( $url ) ;
|
337 |
|
338 |
// Only images under wp-cotnent/wp-includes can be replaced
|
339 |
if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
|
340 |
+
if ( defined( 'UPLOADS' ) && stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
|
341 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match ' ) ;
|
342 |
+
return false ;
|
343 |
+
}
|
344 |
}
|
345 |
|
346 |
// Check if is external url
|
347 |
if ( ! empty( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
|
348 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: host not internal' ) ;
|
349 |
return false ;
|
350 |
}
|
351 |
|
358 |
}
|
359 |
}
|
360 |
|
361 |
+
// Fill full url before replacement
|
362 |
if ( empty( $url_parsed[ 'host' ] ) ) {
|
363 |
+
$url = LiteSpeed_Cache_Utility::uri2url( $url ) ;
|
364 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: fill before rewritten: ' . $url ) ;
|
365 |
+
|
366 |
+
$url_parsed = parse_url( $url ) ;
|
367 |
}
|
368 |
|
369 |
$scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
|
370 |
+
if ( $scheme ) {
|
371 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: scheme from url: ' . $scheme ) ;
|
372 |
+
}
|
373 |
|
374 |
// Now lets replace CDN url
|
375 |
$url = str_replace( $scheme . $this->cfg_url_ori, $this->cfg_cdn_url, $url ) ;
|
376 |
+
LiteSpeed_Cache_Log::debug2( 'CDN: after rewritten: ' . $url ) ;
|
377 |
|
378 |
return $url ;
|
379 |
}
|
includes/litespeed-cache-config.class.php
CHANGED
@@ -15,6 +15,7 @@ class LiteSpeed_Cache_Config
|
|
15 |
|
16 |
const OPTION_NAME = 'litespeed-cache-conf' ;
|
17 |
const VARY_GROUP = 'litespeed-cache-vary-group' ;
|
|
|
18 |
const VAL_OFF = 0 ;
|
19 |
const VAL_ON = 1 ;
|
20 |
const VAL_ON2 = 2 ;
|
@@ -25,7 +26,6 @@ class LiteSpeed_Cache_Config
|
|
25 |
const LOG_LEVEL_INFO = 3 ;
|
26 |
const LOG_LEVEL_DEBUG = 4 ;
|
27 |
const OPID_VERSION = 'version' ;
|
28 |
-
const OPID_ENABLED = 'enabled' ;
|
29 |
const OPID_ENABLED_RADIO = 'radio_select' ;
|
30 |
|
31 |
const OPID_CACHE_PRIV = 'cache_priv' ;
|
@@ -36,6 +36,8 @@ class LiteSpeed_Cache_Config
|
|
36 |
const OPID_CACHE_RES = 'cache_resources' ;
|
37 |
const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
|
38 |
const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
|
|
|
|
|
39 |
|
40 |
const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
|
41 |
const OPID_TIMED_URLS = 'timed_urls' ;
|
@@ -65,7 +67,6 @@ class LiteSpeed_Cache_Config
|
|
65 |
const OPID_404_TTL = '404_ttl' ;
|
66 |
const OPID_500_TTL = '500_ttl' ;
|
67 |
const OPID_PURGE_BY_POST = 'purge_by_post' ;
|
68 |
-
const OPID_TEST_IPS = 'test_ips' ;
|
69 |
const OPID_ESI_ENABLE = 'esi_enabled' ;
|
70 |
const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
|
71 |
const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
|
@@ -81,6 +82,7 @@ class LiteSpeed_Cache_Config
|
|
81 |
const PURGE_TERM = 'T' ; // include category|tag|tax
|
82 |
const PURGE_POST_TYPE = 'PT' ;
|
83 |
const OPID_EXCLUDES_URI = 'excludes_uri' ;
|
|
|
84 |
const OPID_EXCLUDES_CAT = 'excludes_cat' ;
|
85 |
const OPID_EXCLUDES_TAG = 'excludes_tag' ;
|
86 |
|
@@ -94,6 +96,11 @@ class LiteSpeed_Cache_Config
|
|
94 |
const OPID_JS_EXCLUDES = 'js_exclude' ;
|
95 |
const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
|
96 |
const OPID_HTML_MINIFY = 'html_minify' ;
|
|
|
|
|
|
|
|
|
|
|
97 |
|
98 |
const OPID_CDN = 'cdn' ;
|
99 |
const OPID_CDN_ORI = 'cdn_ori' ;
|
@@ -104,6 +111,8 @@ class LiteSpeed_Cache_Config
|
|
104 |
const OPID_CDN_FILETYPE = 'cdn_filetype' ;
|
105 |
const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
|
106 |
|
|
|
|
|
107 |
const NETWORK_OPID_ENABLED = 'network_enabled' ;
|
108 |
const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
|
109 |
|
@@ -147,20 +156,34 @@ class LiteSpeed_Cache_Config
|
|
147 |
else {
|
148 |
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
|
149 |
}
|
|
|
150 |
$this->options = $options ;
|
151 |
$this->purge_options = explode('.', $options[ self::OPID_PURGE_BY_POST ] ) ;
|
152 |
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
}
|
156 |
|
157 |
// Vary group settings
|
158 |
-
$this->vary_groups = (array)get_option( self::VARY_GROUP ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
/**
|
162 |
-
* For multisite installations, the single site options need to be updated
|
163 |
-
* with the network wide options.
|
164 |
*
|
165 |
* @since 1.0.13
|
166 |
* @access private
|
@@ -168,38 +191,51 @@ class LiteSpeed_Cache_Config
|
|
168 |
*/
|
169 |
private function construct_multisite_options()
|
170 |
{
|
171 |
-
$site_options = get_site_option(self::OPTION_NAME) ;
|
172 |
|
173 |
-
if ( ! function_exists('is_plugin_active_for_network') ) {
|
174 |
require_once(ABSPATH . '/wp-admin/includes/plugin.php') ;
|
175 |
}
|
176 |
|
177 |
-
$options = get_option(self::OPTION_NAME, $this->get_default_options()) ;
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
|
|
182 |
}
|
183 |
return $options ;
|
184 |
}
|
185 |
|
186 |
-
|
|
|
|
|
187 |
// save temparary cron setting
|
188 |
-
$CRWL_CRON_ACTIVE = $options[self::CRWL_CRON_ACTIVE] ;
|
189 |
|
190 |
-
|
|
|
191 |
|
192 |
// crawler cron activation is separated
|
193 |
-
$options[self::CRWL_CRON_ACTIVE] = $CRWL_CRON_ACTIVE ;
|
194 |
}
|
195 |
|
196 |
-
|
197 |
-
if ($options[self::OPID_ENABLED_RADIO]
|
198 |
-
|
|
|
|
|
|
|
|
|
199 |
}
|
|
|
|
|
200 |
unset( $site_options[ self::NETWORK_OPID_ENABLED ] ) ;
|
201 |
unset( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ;
|
|
|
|
|
202 |
$options = array_merge( $options, $site_options ) ;
|
|
|
203 |
return $options ;
|
204 |
}
|
205 |
|
@@ -252,6 +288,40 @@ class LiteSpeed_Cache_Config
|
|
252 |
return update_option( self::OPTION_NAME, $this->options ) ;
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
/**
|
256 |
* Check if one user role is in vary group settings
|
257 |
*
|
@@ -322,17 +392,14 @@ class LiteSpeed_Cache_Config
|
|
322 |
|
323 |
//For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
|
324 |
if ( is_multisite() ) {
|
325 |
-
$default_enabled = false ;
|
326 |
$default_radio = 2 ;
|
327 |
}
|
328 |
else {
|
329 |
-
$default_enabled = true ;
|
330 |
$default_radio = 1 ;
|
331 |
}
|
332 |
|
333 |
$default_options = array(
|
334 |
self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
|
335 |
-
self::OPID_ENABLED => $default_enabled,
|
336 |
self::OPID_ENABLED_RADIO => $default_radio,
|
337 |
self::OPID_PURGE_ON_UPGRADE => true,
|
338 |
self::OPID_CACHE_PRIV => true,
|
@@ -345,6 +412,9 @@ class LiteSpeed_Cache_Config
|
|
345 |
self::OPID_CACHE_RES => true,
|
346 |
self::OPID_CACHE_MOBILE => false,
|
347 |
self::ID_MOBILEVIEW_LIST => false,
|
|
|
|
|
|
|
348 |
self::OPID_LOGIN_COOKIE => '',
|
349 |
self::OPID_CHECK_ADVANCEDCACHE => true,
|
350 |
self::OPID_DEBUG => self::LOG_LEVEL_NONE,
|
@@ -357,7 +427,6 @@ class LiteSpeed_Cache_Config
|
|
357 |
self::OPID_LOG_FILTERS => false,
|
358 |
self::OPID_LOG_IGNORE_FILTERS => "gettext\ngettext_with_context\nget_the_terms\nget_term",
|
359 |
self::OPID_LOG_IGNORE_PART_FILTERS => "i18n\nlocale\nsettings\noption",
|
360 |
-
self::OPID_TEST_IPS => '',
|
361 |
self::OPID_PUBLIC_TTL => 604800,
|
362 |
self::OPID_PRIVATE_TTL => 1800,
|
363 |
self::OPID_FRONT_PAGE_TTL => 604800,
|
@@ -367,6 +436,7 @@ class LiteSpeed_Cache_Config
|
|
367 |
self::OPID_500_TTL => 3600,
|
368 |
self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
|
369 |
self::OPID_EXCLUDES_URI => '',
|
|
|
370 |
self::OPID_EXCLUDES_CAT => '',
|
371 |
self::OPID_EXCLUDES_TAG => '',
|
372 |
|
@@ -380,6 +450,11 @@ class LiteSpeed_Cache_Config
|
|
380 |
self::OPID_JS_EXCLUDES => '',
|
381 |
self::OPID_OPTIMIZE_TTL => 604800,
|
382 |
self::OPID_HTML_MINIFY => false,
|
|
|
|
|
|
|
|
|
|
|
383 |
|
384 |
self::OPID_CDN => false,
|
385 |
self::OPID_CDN_ORI => '',
|
@@ -390,6 +465,8 @@ class LiteSpeed_Cache_Config
|
|
390 |
self::OPID_CDN_FILETYPE => ".aac\n.css\n.eot\n.gif\n.jpeg\n.js\n.jpg\n.less\n.mp3\n.mp4\n.ogg\n.otf\n.pdf\n.png\n.svg\n.ttf\n.woff",
|
391 |
self::OPID_CDN_EXCLUDE => '',
|
392 |
|
|
|
|
|
393 |
self::ID_NOCACHE_COOKIES => '',
|
394 |
self::ID_NOCACHE_USERAGENTS => '',
|
395 |
self::CRWL_POSTS => true,
|
@@ -415,10 +492,6 @@ class LiteSpeed_Cache_Config
|
|
415 |
$default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
|
416 |
}
|
417 |
|
418 |
-
if ( is_multisite() ) {
|
419 |
-
$default_options[self::NETWORK_OPID_ENABLED] = false ;
|
420 |
-
}
|
421 |
-
|
422 |
if ( ! $include_thirdparty ) {
|
423 |
return $default_options ;
|
424 |
}
|
@@ -448,6 +521,7 @@ class LiteSpeed_Cache_Config
|
|
448 |
self::OPID_CACHE_RES => true,
|
449 |
self::OPID_CACHE_MOBILE => 0, // todo: why not false
|
450 |
self::ID_MOBILEVIEW_LIST => false,
|
|
|
451 |
self::OPID_LOGIN_COOKIE => '',
|
452 |
self::OPID_CHECK_ADVANCEDCACHE => true,
|
453 |
self::ID_NOCACHE_COOKIES => '',
|
@@ -456,28 +530,6 @@ class LiteSpeed_Cache_Config
|
|
456 |
return $default_site_options ;
|
457 |
}
|
458 |
|
459 |
-
/**
|
460 |
-
* When the .htaccess files need to be reset, use this array to denote
|
461 |
-
* everything off.
|
462 |
-
*
|
463 |
-
* @since 1.0.12
|
464 |
-
* @access public
|
465 |
-
* @return array The list of options to reset.
|
466 |
-
*/
|
467 |
-
public static function get_rule_reset_options()
|
468 |
-
{
|
469 |
-
$reset = array(
|
470 |
-
LiteSpeed_Cache_Config::OPID_CACHE_MOBILE => false,
|
471 |
-
LiteSpeed_Cache_Config::OPID_CACHE_FAVICON => false,
|
472 |
-
LiteSpeed_Cache_Config::OPID_CACHE_RES => false,
|
473 |
-
LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST => false,
|
474 |
-
LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES => '',
|
475 |
-
LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS => '',
|
476 |
-
LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE => ''
|
477 |
-
) ;
|
478 |
-
return $reset ;
|
479 |
-
}
|
480 |
-
|
481 |
/**
|
482 |
* Get the plugin's site wide options.
|
483 |
*
|
@@ -492,15 +544,15 @@ class LiteSpeed_Cache_Config
|
|
492 |
if ( ! is_multisite() ) {
|
493 |
return null ;
|
494 |
}
|
495 |
-
$site_options = get_site_option(self::OPTION_NAME) ;
|
496 |
-
|
497 |
-
|
498 |
-
}
|
499 |
-
elseif ( isset($site_options) && is_string($site_options) ) {
|
500 |
return $site_options ;
|
501 |
}
|
|
|
502 |
$default_site_options = $this->get_default_site_options() ;
|
503 |
-
add_site_option(self::OPTION_NAME, $default_site_options) ;
|
|
|
504 |
return $default_site_options ;
|
505 |
}
|
506 |
|
@@ -586,9 +638,6 @@ class LiteSpeed_Cache_Config
|
|
586 |
}
|
587 |
$options[self::OPID_VERSION] = LiteSpeed_Cache::PLUGIN_VERSION ;
|
588 |
|
589 |
-
if ( $options[self::OPID_CACHE_MOBILE] === false ) {
|
590 |
-
$options[self::ID_MOBILEVIEW_LIST] = false ;
|
591 |
-
}
|
592 |
return $options ;
|
593 |
}
|
594 |
|
@@ -604,16 +653,16 @@ class LiteSpeed_Cache_Config
|
|
604 |
{
|
605 |
$default_options = $this->get_default_options() ;
|
606 |
|
607 |
-
if ( $this->options[self::OPID_VERSION] == $default_options[self::OPID_VERSION] && count($default_options) == count($this->options) ) {
|
608 |
return ;
|
609 |
}
|
610 |
|
611 |
-
$this->options = self::option_diff($default_options, $this->options) ;
|
612 |
|
613 |
$res = $this->update_options() ;
|
614 |
define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
|
615 |
LiteSpeed_Cache_Purge::purge_all() ;
|
616 |
-
LiteSpeed_Cache_Log::debug("plugin_upgrade option changed = $res\n") ;
|
617 |
}
|
618 |
|
619 |
/**
|
@@ -627,15 +676,15 @@ class LiteSpeed_Cache_Config
|
|
627 |
$default_options = $this->get_default_site_options() ;
|
628 |
$options = $this->get_site_options() ;
|
629 |
|
630 |
-
if ( $options[self::OPID_VERSION] == $default_options[self::OPID_VERSION] && count($default_options) == count($options) ) {
|
631 |
return ;
|
632 |
}
|
633 |
|
634 |
-
$options = self::option_diff($default_options, $options) ;
|
635 |
|
636 |
-
$res = update_site_option(self::OPTION_NAME, $options) ;
|
637 |
|
638 |
-
LiteSpeed_Cache_Log::debug("plugin_upgrade option changed = $res\n") ;
|
639 |
}
|
640 |
|
641 |
/**
|
@@ -652,44 +701,47 @@ class LiteSpeed_Cache_Config
|
|
652 |
public static function wp_cache_var_setter( $enable )
|
653 |
{
|
654 |
if ( $enable ) {
|
655 |
-
if ( defined('WP_CACHE') && WP_CACHE ) {
|
656 |
return true ;
|
657 |
}
|
658 |
}
|
659 |
-
elseif ( ! defined('WP_CACHE') || (defined('WP_CACHE') && ! WP_CACHE) ) {
|
660 |
return true ;
|
661 |
}
|
|
|
662 |
$file = ABSPATH . 'wp-config.php' ;
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
|
|
667 |
return LiteSpeed_Cache_Admin_Error::E_CONF_WRITE ;
|
668 |
}
|
669 |
}
|
670 |
-
|
|
|
671 |
|
672 |
if ( $enable ) {
|
673 |
$count = 0 ;
|
674 |
|
675 |
-
$new_file_content = preg_replace('/[\/]*define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', true);", $file_content, -1, $count) ;
|
676 |
if ( $count == 0 ) {
|
677 |
-
$new_file_content = preg_replace('/(\$table_prefix)/', "define('WP_CACHE', true);\n$1", $file_content) ;
|
678 |
if ( $count == 0 ) {
|
679 |
-
$new_file_content = preg_replace('/(\<\?php)/', "$1\ndefine('WP_CACHE', true);", $file_content, -1, $count) ;
|
680 |
}
|
681 |
|
682 |
if ( $count == 0 ) {
|
683 |
-
error_log('wp-config file did not find a place to insert define.') ;
|
684 |
return LiteSpeed_Cache_Admin_Error::E_CONF_FIND ;
|
685 |
}
|
686 |
}
|
687 |
}
|
688 |
else {
|
689 |
-
$new_file_content = preg_replace('/define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', false);", $file_content) ;
|
690 |
}
|
691 |
|
692 |
-
file_put_contents($file, $new_file_content) ;
|
693 |
return true ;
|
694 |
}
|
695 |
|
@@ -700,74 +752,53 @@ class LiteSpeed_Cache_Config
|
|
700 |
* @access public
|
701 |
* @param int $count The count of blogs active in multisite.
|
702 |
*/
|
703 |
-
public function plugin_activation($count)
|
704 |
{
|
705 |
$errors = array() ;
|
706 |
-
|
707 |
-
$
|
708 |
-
|
709 |
if ( LiteSpeed_Cache_Log::get_enabled() ) {
|
710 |
-
LiteSpeed_Cache_Log::push("plugin_activation update option = ".var_export($res, true)) ;
|
711 |
}
|
|
|
712 |
if ( is_multisite() ) {
|
|
|
713 |
if ( ! is_network_admin() ) {
|
714 |
if ( $count === 1 ) {
|
715 |
-
|
|
|
716 |
}
|
717 |
return ;
|
718 |
}
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
update_site_option(self::OPTION_NAME, $options) ;
|
723 |
}
|
724 |
-
|
|
|
|
|
|
|
725 |
return ;
|
726 |
}
|
|
|
727 |
}
|
728 |
-
elseif ( $res == false &&
|
729 |
return ;
|
730 |
}
|
731 |
else {
|
732 |
$options = $this->get_options() ;
|
733 |
}
|
734 |
|
735 |
-
$
|
736 |
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
|
|
741 |
}
|
742 |
|
743 |
-
if ( ! empty($errors) ) {
|
744 |
-
exit(implode("\n", $errors)) ;
|
745 |
-
}
|
746 |
-
|
747 |
-
}
|
748 |
-
|
749 |
-
/**
|
750 |
-
* Checks if caching is allowed via server variable.
|
751 |
-
*
|
752 |
-
* @since 1.0.0
|
753 |
-
* @access public
|
754 |
-
* @return boolean True if allowed, false otherwise.
|
755 |
-
*/
|
756 |
-
public function is_caching_allowed()
|
757 |
-
{
|
758 |
-
//lsws
|
759 |
-
if ( isset( $_SERVER['X-LSCACHE'] ) && $_SERVER['X-LSCACHE'] ) {
|
760 |
-
return true ;
|
761 |
-
}
|
762 |
-
// web adc
|
763 |
-
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_ADC' ) {
|
764 |
-
return true ;
|
765 |
-
}
|
766 |
-
// cli call
|
767 |
-
if ( PHP_SAPI == 'cli' ) {
|
768 |
-
return true ;
|
769 |
-
}
|
770 |
-
return false ;
|
771 |
}
|
772 |
|
773 |
/**
|
@@ -779,7 +810,7 @@ class LiteSpeed_Cache_Config
|
|
779 |
*/
|
780 |
public static function get_instance()
|
781 |
{
|
782 |
-
if ( ! isset(self::$_instance) ) {
|
783 |
self::$_instance = new self() ;
|
784 |
}
|
785 |
|
15 |
|
16 |
const OPTION_NAME = 'litespeed-cache-conf' ;
|
17 |
const VARY_GROUP = 'litespeed-cache-vary-group' ;
|
18 |
+
const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
|
19 |
const VAL_OFF = 0 ;
|
20 |
const VAL_ON = 1 ;
|
21 |
const VAL_ON2 = 2 ;
|
26 |
const LOG_LEVEL_INFO = 3 ;
|
27 |
const LOG_LEVEL_DEBUG = 4 ;
|
28 |
const OPID_VERSION = 'version' ;
|
|
|
29 |
const OPID_ENABLED_RADIO = 'radio_select' ;
|
30 |
|
31 |
const OPID_CACHE_PRIV = 'cache_priv' ;
|
36 |
const OPID_CACHE_RES = 'cache_resources' ;
|
37 |
const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
|
38 |
const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
|
39 |
+
const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
|
40 |
+
const OPID_CACHE_BROWSER = 'cache_browser' ;
|
41 |
|
42 |
const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
|
43 |
const OPID_TIMED_URLS = 'timed_urls' ;
|
67 |
const OPID_404_TTL = '404_ttl' ;
|
68 |
const OPID_500_TTL = '500_ttl' ;
|
69 |
const OPID_PURGE_BY_POST = 'purge_by_post' ;
|
|
|
70 |
const OPID_ESI_ENABLE = 'esi_enabled' ;
|
71 |
const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
|
72 |
const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
|
82 |
const PURGE_TERM = 'T' ; // include category|tag|tax
|
83 |
const PURGE_POST_TYPE = 'PT' ;
|
84 |
const OPID_EXCLUDES_URI = 'excludes_uri' ;
|
85 |
+
const OPID_EXCLUDES_QS = 'excludes_qs' ;
|
86 |
const OPID_EXCLUDES_CAT = 'excludes_cat' ;
|
87 |
const OPID_EXCLUDES_TAG = 'excludes_tag' ;
|
88 |
|
96 |
const OPID_JS_EXCLUDES = 'js_exclude' ;
|
97 |
const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
|
98 |
const OPID_HTML_MINIFY = 'html_minify' ;
|
99 |
+
const OPID_OPTM_QS_RM = 'optm_qs_rm' ;
|
100 |
+
const OPID_OPTM_GGFONTS_RM = 'optm_ggfonts_rm' ;
|
101 |
+
const OPID_OPTM_CSS_ASYNC = 'optm_css_async' ;
|
102 |
+
const OPID_OPTM_JS_DEFER = 'optm_js_defer' ;
|
103 |
+
const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
|
104 |
|
105 |
const OPID_CDN = 'cdn' ;
|
106 |
const OPID_CDN_ORI = 'cdn_ori' ;
|
111 |
const OPID_CDN_FILETYPE = 'cdn_filetype' ;
|
112 |
const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
|
113 |
|
114 |
+
const HASH = 'hash' ;
|
115 |
+
|
116 |
const NETWORK_OPID_ENABLED = 'network_enabled' ;
|
117 |
const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
|
118 |
|
156 |
else {
|
157 |
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
|
158 |
}
|
159 |
+
|
160 |
$this->options = $options ;
|
161 |
$this->purge_options = explode('.', $options[ self::OPID_PURGE_BY_POST ] ) ;
|
162 |
|
163 |
+
// Init global const cache on set
|
164 |
+
if ( $this->options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON
|
165 |
+
// || ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) && $this->options[ LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ] ) todo: need to check when primary is off and network is on, if can manage
|
166 |
+
) {
|
167 |
+
defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
|
168 |
+
}
|
169 |
+
|
170 |
+
// Check advanced_cache set
|
171 |
+
if ( isset( $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] ) && $this->options[ self::OPID_CHECK_ADVANCEDCACHE ] === false && ! defined( 'LSCACHE_ADV_CACHE' ) ) {
|
172 |
+
define( 'LSCACHE_ADV_CACHE', true ) ;
|
173 |
}
|
174 |
|
175 |
// Vary group settings
|
176 |
+
$this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
|
177 |
+
|
178 |
+
// Set security key if not initialized yet
|
179 |
+
if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
|
180 |
+
$this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
|
181 |
+
}
|
182 |
+
|
183 |
}
|
184 |
|
185 |
/**
|
186 |
+
* For multisite installations, the single site options need to be updated with the network wide options.
|
|
|
187 |
*
|
188 |
* @since 1.0.13
|
189 |
* @access private
|
191 |
*/
|
192 |
private function construct_multisite_options()
|
193 |
{
|
194 |
+
$site_options = get_site_option( self::OPTION_NAME ) ;
|
195 |
|
196 |
+
if ( ! function_exists('is_plugin_active_for_network') ) { // todo: check if needed
|
197 |
require_once(ABSPATH . '/wp-admin/includes/plugin.php') ;
|
198 |
}
|
199 |
|
200 |
+
$options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
|
201 |
|
202 |
+
// If don't have site options
|
203 |
+
if ( ! $site_options || ! is_array( $site_options ) || ! is_plugin_active_for_network( 'litespeed-cache/litespeed-cache.php' ) ) {
|
204 |
+
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 ) { // Default to cache on
|
205 |
+
defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
|
206 |
}
|
207 |
return $options ;
|
208 |
}
|
209 |
|
210 |
+
// If network set to use primary setting
|
211 |
+
if ( ! empty ( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ) {
|
212 |
+
|
213 |
// save temparary cron setting
|
214 |
+
$CRWL_CRON_ACTIVE = $options[ self::CRWL_CRON_ACTIVE ] ;
|
215 |
|
216 |
+
// Get the primary site settings
|
217 |
+
$options = get_blog_option( BLOG_ID_CURRENT_SITE, LiteSpeed_Cache_Config::OPTION_NAME, array() ) ;
|
218 |
|
219 |
// crawler cron activation is separated
|
220 |
+
$options[ self::CRWL_CRON_ACTIVE ] = $CRWL_CRON_ACTIVE ;
|
221 |
}
|
222 |
|
223 |
+
// If use network setting
|
224 |
+
if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 && $site_options[ self::NETWORK_OPID_ENABLED ] ) {
|
225 |
+
defined( 'LITESPEED_ALLOWED' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
|
226 |
+
}
|
227 |
+
// Set network eanble to on
|
228 |
+
if ( $site_options[ self::NETWORK_OPID_ENABLED ] ) {
|
229 |
+
! defined( 'LITESPEED_NETWORK_ON' ) && define( 'LITESPEED_NETWORK_ON', true ) ;
|
230 |
}
|
231 |
+
|
232 |
+
// These two are not for single blog options
|
233 |
unset( $site_options[ self::NETWORK_OPID_ENABLED ] ) ;
|
234 |
unset( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ;
|
235 |
+
|
236 |
+
// Append site options to single blog options
|
237 |
$options = array_merge( $options, $site_options ) ;
|
238 |
+
|
239 |
return $options ;
|
240 |
}
|
241 |
|
288 |
return update_option( self::OPTION_NAME, $this->options ) ;
|
289 |
}
|
290 |
|
291 |
+
/**
|
292 |
+
* Save frontend url to private cached uri/no cache uri
|
293 |
+
*
|
294 |
+
* @since 1.3
|
295 |
+
* @access public
|
296 |
+
*/
|
297 |
+
public static function frontend_save()
|
298 |
+
{
|
299 |
+
if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
|
300 |
+
exit( 'no referer' ) ;
|
301 |
+
}
|
302 |
+
|
303 |
+
if ( empty( $_GET[ 'type' ] ) ) {
|
304 |
+
exit( 'no type' ) ;
|
305 |
+
}
|
306 |
+
|
307 |
+
$id = $_GET[ 'type' ] == 'nocache' ? self::OPID_EXCLUDES_URI : self::OPID_CACHE_URI_PRIV ;
|
308 |
+
$instance = self::get_instance() ;
|
309 |
+
$list = $instance->get_option( $id ) ;
|
310 |
+
|
311 |
+
$list = explode( "\n", $list ) ;
|
312 |
+
$list[] = $_SERVER[ 'HTTP_REFERER' ] ;
|
313 |
+
$list = array_map( 'LiteSpeed_Cache_Utility::make_relative', $list ) ;// Remove domain
|
314 |
+
$list = array_unique( $list ) ;
|
315 |
+
$list = array_filter( $list ) ;
|
316 |
+
$list = implode( "\n", $list ) ;
|
317 |
+
|
318 |
+
$instance->update_options( array( $id => $list ) ) ;
|
319 |
+
|
320 |
+
// Purge this page & redirect
|
321 |
+
LiteSpeed_Cache_Purge::frontend_purge() ;
|
322 |
+
exit() ;
|
323 |
+
}
|
324 |
+
|
325 |
/**
|
326 |
* Check if one user role is in vary group settings
|
327 |
*
|
392 |
|
393 |
//For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
|
394 |
if ( is_multisite() ) {
|
|
|
395 |
$default_radio = 2 ;
|
396 |
}
|
397 |
else {
|
|
|
398 |
$default_radio = 1 ;
|
399 |
}
|
400 |
|
401 |
$default_options = array(
|
402 |
self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
|
|
|
403 |
self::OPID_ENABLED_RADIO => $default_radio,
|
404 |
self::OPID_PURGE_ON_UPGRADE => true,
|
405 |
self::OPID_CACHE_PRIV => true,
|
412 |
self::OPID_CACHE_RES => true,
|
413 |
self::OPID_CACHE_MOBILE => false,
|
414 |
self::ID_MOBILEVIEW_LIST => false,
|
415 |
+
self::OPID_CACHE_URI_PRIV => '',
|
416 |
+
self::OPID_CACHE_BROWSER => false,
|
417 |
+
|
418 |
self::OPID_LOGIN_COOKIE => '',
|
419 |
self::OPID_CHECK_ADVANCEDCACHE => true,
|
420 |
self::OPID_DEBUG => self::LOG_LEVEL_NONE,
|
427 |
self::OPID_LOG_FILTERS => false,
|
428 |
self::OPID_LOG_IGNORE_FILTERS => "gettext\ngettext_with_context\nget_the_terms\nget_term",
|
429 |
self::OPID_LOG_IGNORE_PART_FILTERS => "i18n\nlocale\nsettings\noption",
|
|
|
430 |
self::OPID_PUBLIC_TTL => 604800,
|
431 |
self::OPID_PRIVATE_TTL => 1800,
|
432 |
self::OPID_FRONT_PAGE_TTL => 604800,
|
436 |
self::OPID_500_TTL => 3600,
|
437 |
self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
|
438 |
self::OPID_EXCLUDES_URI => '',
|
439 |
+
self::OPID_EXCLUDES_QS => '',
|
440 |
self::OPID_EXCLUDES_CAT => '',
|
441 |
self::OPID_EXCLUDES_TAG => '',
|
442 |
|
450 |
self::OPID_JS_EXCLUDES => '',
|
451 |
self::OPID_OPTIMIZE_TTL => 604800,
|
452 |
self::OPID_HTML_MINIFY => false,
|
453 |
+
self::OPID_OPTM_QS_RM => false,
|
454 |
+
self::OPID_OPTM_GGFONTS_RM => false,
|
455 |
+
self::OPID_OPTM_CSS_ASYNC => false,
|
456 |
+
self::OPID_OPTM_JS_DEFER => false,
|
457 |
+
self::OPID_OPTM_EMOJI_RM => false,
|
458 |
|
459 |
self::OPID_CDN => false,
|
460 |
self::OPID_CDN_ORI => '',
|
465 |
self::OPID_CDN_FILETYPE => ".aac\n.css\n.eot\n.gif\n.jpeg\n.js\n.jpg\n.less\n.mp3\n.mp4\n.ogg\n.otf\n.pdf\n.png\n.svg\n.ttf\n.woff",
|
466 |
self::OPID_CDN_EXCLUDE => '',
|
467 |
|
468 |
+
self::HASH => '',
|
469 |
+
|
470 |
self::ID_NOCACHE_COOKIES => '',
|
471 |
self::ID_NOCACHE_USERAGENTS => '',
|
472 |
self::CRWL_POSTS => true,
|
492 |
$default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
|
493 |
}
|
494 |
|
|
|
|
|
|
|
|
|
495 |
if ( ! $include_thirdparty ) {
|
496 |
return $default_options ;
|
497 |
}
|
521 |
self::OPID_CACHE_RES => true,
|
522 |
self::OPID_CACHE_MOBILE => 0, // todo: why not false
|
523 |
self::ID_MOBILEVIEW_LIST => false,
|
524 |
+
self::OPID_CACHE_BROWSER => false,
|
525 |
self::OPID_LOGIN_COOKIE => '',
|
526 |
self::OPID_CHECK_ADVANCEDCACHE => true,
|
527 |
self::ID_NOCACHE_COOKIES => '',
|
530 |
return $default_site_options ;
|
531 |
}
|
532 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
533 |
/**
|
534 |
* Get the plugin's site wide options.
|
535 |
*
|
544 |
if ( ! is_multisite() ) {
|
545 |
return null ;
|
546 |
}
|
547 |
+
$site_options = get_site_option( self::OPTION_NAME ) ;
|
548 |
+
|
549 |
+
if ( isset( $site_options ) && is_array( $site_options ) ) {
|
|
|
|
|
550 |
return $site_options ;
|
551 |
}
|
552 |
+
|
553 |
$default_site_options = $this->get_default_site_options() ;
|
554 |
+
add_site_option( self::OPTION_NAME, $default_site_options ) ;
|
555 |
+
|
556 |
return $default_site_options ;
|
557 |
}
|
558 |
|
638 |
}
|
639 |
$options[self::OPID_VERSION] = LiteSpeed_Cache::PLUGIN_VERSION ;
|
640 |
|
|
|
|
|
|
|
641 |
return $options ;
|
642 |
}
|
643 |
|
653 |
{
|
654 |
$default_options = $this->get_default_options() ;
|
655 |
|
656 |
+
if ( $this->options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] && count( $default_options ) == count( $this->options ) ) {
|
657 |
return ;
|
658 |
}
|
659 |
|
660 |
+
$this->options = self::option_diff( $default_options, $this->options ) ;
|
661 |
|
662 |
$res = $this->update_options() ;
|
663 |
define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
|
664 |
LiteSpeed_Cache_Purge::purge_all() ;
|
665 |
+
LiteSpeed_Cache_Log::debug( "plugin_upgrade option changed = $res\n" ) ;
|
666 |
}
|
667 |
|
668 |
/**
|
676 |
$default_options = $this->get_default_site_options() ;
|
677 |
$options = $this->get_site_options() ;
|
678 |
|
679 |
+
if ( $options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] && count( $default_options ) == count( $options ) ) {
|
680 |
return ;
|
681 |
}
|
682 |
|
683 |
+
$options = self::option_diff( $default_options, $options ) ;
|
684 |
|
685 |
+
$res = update_site_option( self::OPTION_NAME, $options ) ;
|
686 |
|
687 |
+
LiteSpeed_Cache_Log::debug( "plugin_upgrade option changed = $res\n" ) ;
|
688 |
}
|
689 |
|
690 |
/**
|
701 |
public static function wp_cache_var_setter( $enable )
|
702 |
{
|
703 |
if ( $enable ) {
|
704 |
+
if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
|
705 |
return true ;
|
706 |
}
|
707 |
}
|
708 |
+
elseif ( ! defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && ! WP_CACHE ) ) {
|
709 |
return true ;
|
710 |
}
|
711 |
+
|
712 |
$file = ABSPATH . 'wp-config.php' ;
|
713 |
+
|
714 |
+
if ( ! is_writeable( $file ) ) {
|
715 |
+
$file = dirname( ABSPATH ) . '/wp-config.php' ; // todo: is the path correct?
|
716 |
+
if ( ! is_writeable( $file ) ) {
|
717 |
+
error_log( 'wp-config file not writable for \'WP_CACHE\'' ) ;
|
718 |
return LiteSpeed_Cache_Admin_Error::E_CONF_WRITE ;
|
719 |
}
|
720 |
}
|
721 |
+
|
722 |
+
$file_content = file_get_contents( $file ) ;
|
723 |
|
724 |
if ( $enable ) {
|
725 |
$count = 0 ;
|
726 |
|
727 |
+
$new_file_content = preg_replace( '/[\/]*define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', true);", $file_content, -1, $count ) ;
|
728 |
if ( $count == 0 ) {
|
729 |
+
$new_file_content = preg_replace( '/(\$table_prefix)/', "define('WP_CACHE', true);\n$1", $file_content ) ;
|
730 |
if ( $count == 0 ) {
|
731 |
+
$new_file_content = preg_replace( '/(\<\?php)/', "$1\ndefine('WP_CACHE', true);", $file_content, -1, $count ) ;
|
732 |
}
|
733 |
|
734 |
if ( $count == 0 ) {
|
735 |
+
error_log( 'wp-config file did not find a place to insert define.' ) ;
|
736 |
return LiteSpeed_Cache_Admin_Error::E_CONF_FIND ;
|
737 |
}
|
738 |
}
|
739 |
}
|
740 |
else {
|
741 |
+
$new_file_content = preg_replace( '/define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', false);", $file_content ) ;
|
742 |
}
|
743 |
|
744 |
+
file_put_contents( $file, $new_file_content ) ;
|
745 |
return true ;
|
746 |
}
|
747 |
|
752 |
* @access public
|
753 |
* @param int $count The count of blogs active in multisite.
|
754 |
*/
|
755 |
+
public function plugin_activation( $count )
|
756 |
{
|
757 |
$errors = array() ;
|
758 |
+
|
759 |
+
$res = add_option( self::OPTION_NAME, $this->get_default_options() ) ;
|
760 |
+
|
761 |
if ( LiteSpeed_Cache_Log::get_enabled() ) {
|
762 |
+
LiteSpeed_Cache_Log::push( "plugin_activation update option = " . var_export( $res, true ) ) ;
|
763 |
}
|
764 |
+
|
765 |
if ( is_multisite() ) {
|
766 |
+
|
767 |
if ( ! is_network_admin() ) {
|
768 |
if ( $count === 1 ) {
|
769 |
+
// Only itself is activated, set .htaccess with only CacheLookUp
|
770 |
+
LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
|
771 |
}
|
772 |
return ;
|
773 |
}
|
774 |
+
else {
|
775 |
+
// Network admin should make a wapper to avoid subblogs cache not work
|
776 |
+
LiteSpeed_Cache_Admin_Rules::get_instance()->insert_wrapper() ;
|
|
|
777 |
}
|
778 |
+
|
779 |
+
$options = $this->get_site_options() ;
|
780 |
+
|
781 |
+
if ( $res == true || $options[ self::NETWORK_OPID_ENABLED ] == false ) {
|
782 |
return ;
|
783 |
}
|
784 |
+
|
785 |
}
|
786 |
+
elseif ( $res == false && ! defined( 'LITESPEED_ON' ) ) {// todo: why do this
|
787 |
return ;
|
788 |
}
|
789 |
else {
|
790 |
$options = $this->get_options() ;
|
791 |
}
|
792 |
|
793 |
+
$res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options ) ;
|
794 |
|
795 |
+
if ( $res !== true ) {
|
796 |
+
if ( ! is_array( $res ) ) {
|
797 |
+
exit( $res ) ;
|
798 |
+
}
|
799 |
+
exit( implode( "\n", $res ) ) ;
|
800 |
}
|
801 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
802 |
}
|
803 |
|
804 |
/**
|
810 |
*/
|
811 |
public static function get_instance()
|
812 |
{
|
813 |
+
if ( ! isset( self::$_instance ) ) {
|
814 |
self::$_instance = new self() ;
|
815 |
}
|
816 |
|
includes/litespeed-cache-control.class.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
*/
|
10 |
class LiteSpeed_Cache_Control
|
11 |
{
|
12 |
-
|
13 |
|
14 |
const BM_CACHEABLE = 1 ;
|
15 |
const BM_PRIVATE = 2 ;
|
@@ -311,10 +311,10 @@ class LiteSpeed_Cache_Control
|
|
311 |
*/
|
312 |
public static function check_redirect( $location, $status )
|
313 |
{
|
314 |
-
if (
|
315 |
-
LiteSpeed_Cache_Log::debug( "301 from " . $_SERVER['SCRIPT_URI'] ) ;
|
316 |
LiteSpeed_Cache_Log::debug( "301 to $location" ) ;
|
317 |
-
if ( $_SERVER['SCRIPT_URI'] == $location ) {
|
318 |
self::set_nocache( '301 to same url' ) ;
|
319 |
}
|
320 |
}
|
@@ -380,6 +380,8 @@ class LiteSpeed_Cache_Control
|
|
380 |
return ;
|
381 |
}
|
382 |
|
|
|
|
|
383 |
// Apply 3rd party filter
|
384 |
// Parse ESI block id
|
385 |
$esi_id = false ;
|
@@ -404,7 +406,7 @@ class LiteSpeed_Cache_Control
|
|
404 |
}
|
405 |
|
406 |
// Check litespeed setting to set cacheable status
|
407 |
-
if ( !
|
408 |
self::set_nocache() ;
|
409 |
return ;
|
410 |
}
|
@@ -445,51 +447,72 @@ class LiteSpeed_Cache_Control
|
|
445 |
* @access private
|
446 |
* @return boolean True if cacheable, false otherwise.
|
447 |
*/
|
448 |
-
private
|
449 |
{
|
450 |
// logged_in users already excluded, no hook added
|
451 |
|
452 |
-
if( ! empty($_REQUEST[LiteSpeed_Cache::ACTION_KEY]) ) {
|
453 |
-
return
|
454 |
}
|
455 |
|
456 |
if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
|
457 |
-
return
|
458 |
}
|
459 |
|
460 |
-
if ( is_feed() && LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_FEED_TTL) == 0 ) {
|
461 |
-
return
|
462 |
}
|
463 |
|
464 |
if ( is_trackback() ) {
|
465 |
-
return
|
466 |
}
|
467 |
|
468 |
-
if ( is_404() && LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_404_TTL) == 0 ) {
|
469 |
-
return
|
470 |
}
|
471 |
|
472 |
if ( is_search() ) {
|
473 |
-
return
|
474 |
}
|
475 |
|
476 |
// if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
|
477 |
-
// return
|
478 |
// }
|
479 |
|
480 |
-
|
481 |
-
|
482 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
}
|
484 |
|
485 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
|
486 |
if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
|
487 |
-
return
|
488 |
}
|
489 |
|
490 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
|
491 |
if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
|
492 |
-
return
|
493 |
}
|
494 |
|
495 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
|
@@ -498,7 +521,7 @@ class LiteSpeed_Cache_Control
|
|
498 |
|
499 |
foreach( $_COOKIE as $key=>$val) {
|
500 |
if ( in_array($key, $exclude_list) ) {
|
501 |
-
return
|
502 |
}
|
503 |
}
|
504 |
}
|
@@ -508,7 +531,7 @@ class LiteSpeed_Cache_Control
|
|
508 |
$pattern = '/' . $excludes . '/' ;
|
509 |
$nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
|
510 |
if ( $nummatches ) {
|
511 |
-
return
|
512 |
}
|
513 |
}
|
514 |
|
@@ -523,50 +546,26 @@ class LiteSpeed_Cache_Control
|
|
523 |
* @param string $reason An explanation for why the page is not cacheable.
|
524 |
* @return boolean Return false.
|
525 |
*/
|
526 |
-
private
|
527 |
{
|
528 |
LiteSpeed_Cache_Log::debug('X Cache_control off - ' . $reason) ;
|
529 |
return false ;
|
530 |
}
|
531 |
|
532 |
/**
|
533 |
-
* Check
|
534 |
*
|
535 |
-
* @since
|
536 |
* @access private
|
537 |
-
* @param
|
538 |
-
* @return boolean
|
539 |
*/
|
540 |
-
private
|
541 |
{
|
542 |
-
$
|
543 |
-
|
544 |
-
if (is_multisite()) {
|
545 |
-
$blog_details = get_blog_details(get_current_blog_id());
|
546 |
-
$blog_path = $blog_details->path;
|
547 |
-
$blog_path_len = strlen($blog_path);
|
548 |
-
if (($uri_len >= $blog_path_len)
|
549 |
-
&& (strncmp($uri, $blog_path, $blog_path_len) == 0)) {
|
550 |
-
$uri = substr($uri, $blog_path_len - 1);
|
551 |
-
$uri_len = strlen( $uri ) ;
|
552 |
-
}
|
553 |
-
}
|
554 |
-
foreach( $excludes_list as $excludes_rule ){
|
555 |
-
$rule_len = strlen( $excludes_rule );
|
556 |
-
if (($excludes_rule[$rule_len - 1] == '$')) {
|
557 |
-
if ($uri_len != (--$rule_len)) {
|
558 |
-
continue;
|
559 |
-
}
|
560 |
-
}
|
561 |
-
elseif ( $uri_len < $rule_len ) {
|
562 |
-
continue;
|
563 |
-
}
|
564 |
-
|
565 |
-
if ( strncmp( $uri, $excludes_rule, $rule_len ) == 0 ){
|
566 |
-
return true ;
|
567 |
-
}
|
568 |
}
|
569 |
-
return false;
|
570 |
}
|
571 |
|
572 |
/**
|
@@ -596,16 +595,16 @@ class LiteSpeed_Cache_Control
|
|
596 |
/**
|
597 |
* Get the current instance object.
|
598 |
*
|
599 |
-
* @since 1.
|
600 |
* @access public
|
601 |
* @return Current class instance.
|
602 |
*/
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
}
|
9 |
*/
|
10 |
class LiteSpeed_Cache_Control
|
11 |
{
|
12 |
+
private static $_instance ;
|
13 |
|
14 |
const BM_CACHEABLE = 1 ;
|
15 |
const BM_PRIVATE = 2 ;
|
311 |
*/
|
312 |
public static function check_redirect( $location, $status )
|
313 |
{
|
314 |
+
if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
|
315 |
+
LiteSpeed_Cache_Log::debug( "301 from " . $_SERVER[ 'SCRIPT_URI' ] ) ;
|
316 |
LiteSpeed_Cache_Log::debug( "301 to $location" ) ;
|
317 |
+
if ( parse_url( $_SERVER[ 'SCRIPT_URI' ], PHP_URL_PATH ) == parse_url( $location, PHP_URL_PATH ) ) {
|
318 |
self::set_nocache( '301 to same url' ) ;
|
319 |
}
|
320 |
}
|
380 |
return ;
|
381 |
}
|
382 |
|
383 |
+
$instance = self::get_instance() ;
|
384 |
+
|
385 |
// Apply 3rd party filter
|
386 |
// Parse ESI block id
|
387 |
$esi_id = false ;
|
406 |
}
|
407 |
|
408 |
// Check litespeed setting to set cacheable status
|
409 |
+
if ( ! $instance->_setting_cacheable() ) {
|
410 |
self::set_nocache() ;
|
411 |
return ;
|
412 |
}
|
447 |
* @access private
|
448 |
* @return boolean True if cacheable, false otherwise.
|
449 |
*/
|
450 |
+
private function _setting_cacheable()
|
451 |
{
|
452 |
// logged_in users already excluded, no hook added
|
453 |
|
454 |
+
if( ! empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
|
455 |
+
return $this->_no_cache_for( 'Query String Action' ) ;
|
456 |
}
|
457 |
|
458 |
if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
|
459 |
+
return $this->_no_cache_for('not GET method:' . $_SERVER["REQUEST_METHOD"]) ;
|
460 |
}
|
461 |
|
462 |
+
if ( is_feed() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FEED_TTL ) == 0 ) {
|
463 |
+
return $this->_no_cache_for('feed') ;
|
464 |
}
|
465 |
|
466 |
if ( is_trackback() ) {
|
467 |
+
return $this->_no_cache_for('trackback') ;
|
468 |
}
|
469 |
|
470 |
+
if ( is_404() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_404_TTL ) == 0 ) {
|
471 |
+
return $this->_no_cache_for('404 pages') ;
|
472 |
}
|
473 |
|
474 |
if ( is_search() ) {
|
475 |
+
return $this->_no_cache_for('search') ;
|
476 |
}
|
477 |
|
478 |
// if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
|
479 |
+
// return $this->_no_cache_for('no theme used') ;
|
480 |
// }
|
481 |
|
482 |
+
// Check private cache URI setting
|
483 |
+
$excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_URI_PRIV ) ;
|
484 |
+
if ( ! empty( $excludes ) ) {
|
485 |
+
$uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
|
486 |
+
$result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
|
487 |
+
if ( $result ) {
|
488 |
+
self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
// Check if URI is excluded from cache
|
493 |
+
$excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_URI ) ;
|
494 |
+
if ( ! empty( $excludes ) ) {
|
495 |
+
$uri = esc_url( $_SERVER[ 'REQUEST_URI' ] ) ;
|
496 |
+
$result = LiteSpeed_Cache_Utility::str_hit_array( $uri, explode( "\n", $excludes ) ) ;
|
497 |
+
if ( $result ) {
|
498 |
+
return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
|
499 |
+
}
|
500 |
+
}
|
501 |
+
|
502 |
+
// Check QS excluded setting
|
503 |
+
$excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
|
504 |
+
if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
|
505 |
+
return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
|
506 |
}
|
507 |
|
508 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
|
509 |
if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
|
510 |
+
return $this->_no_cache_for('Admin configured Category Do not cache.') ;
|
511 |
}
|
512 |
|
513 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
|
514 |
if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
|
515 |
+
return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
|
516 |
}
|
517 |
|
518 |
$excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
|
521 |
|
522 |
foreach( $_COOKIE as $key=>$val) {
|
523 |
if ( in_array($key, $exclude_list) ) {
|
524 |
+
return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
|
525 |
}
|
526 |
}
|
527 |
}
|
531 |
$pattern = '/' . $excludes . '/' ;
|
532 |
$nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
|
533 |
if ( $nummatches ) {
|
534 |
+
return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
|
535 |
}
|
536 |
}
|
537 |
|
546 |
* @param string $reason An explanation for why the page is not cacheable.
|
547 |
* @return boolean Return false.
|
548 |
*/
|
549 |
+
private function _no_cache_for( $reason )
|
550 |
{
|
551 |
LiteSpeed_Cache_Log::debug('X Cache_control off - ' . $reason) ;
|
552 |
return false ;
|
553 |
}
|
554 |
|
555 |
/**
|
556 |
+
* Check if current request has qs excluded setting
|
557 |
*
|
558 |
+
* @since 1.3
|
559 |
* @access private
|
560 |
+
* @param array $excludes QS excludes setting
|
561 |
+
* @return boolean|string False if not excluded, otherwise the hit qs list
|
562 |
*/
|
563 |
+
private function _is_qs_excluded( $excludes )
|
564 |
{
|
565 |
+
if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
|
566 |
+
return implode( ',', $intersect ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
}
|
568 |
+
return false ;
|
569 |
}
|
570 |
|
571 |
/**
|
595 |
/**
|
596 |
* Get the current instance object.
|
597 |
*
|
598 |
+
* @since 1.3
|
599 |
* @access public
|
600 |
* @return Current class instance.
|
601 |
*/
|
602 |
+
public static function get_instance()
|
603 |
+
{
|
604 |
+
if ( ! isset( self::$_instance ) ) {
|
605 |
+
self::$_instance = new self() ;
|
606 |
+
}
|
607 |
+
|
608 |
+
return self::$_instance ;
|
609 |
+
}
|
610 |
}
|
includes/litespeed-cache-crawler-sitemap.class.php
CHANGED
@@ -12,7 +12,7 @@
|
|
12 |
class LiteSpeed_Cache_Crawler_Sitemap
|
13 |
{
|
14 |
private static $_instance ;
|
15 |
-
private $
|
16 |
|
17 |
protected $_urls = array() ;
|
18 |
|
@@ -25,11 +25,10 @@ class LiteSpeed_Cache_Crawler_Sitemap
|
|
25 |
private function __construct()
|
26 |
{
|
27 |
if ( is_multisite() ) {
|
28 |
-
$
|
29 |
-
$this->site_url = get_site_url($blog_id) ;
|
30 |
}
|
31 |
else{
|
32 |
-
$this->
|
33 |
}
|
34 |
}
|
35 |
|
@@ -102,7 +101,7 @@ class LiteSpeed_Cache_Crawler_Sitemap
|
|
102 |
$results = $wpdb->get_results($query) ;
|
103 |
|
104 |
foreach ( $results as $result ){
|
105 |
-
$slug = str_replace($this->
|
106 |
if ( ! in_array($slug, $blacklist) ) {
|
107 |
$this->_urls[] = $slug ;
|
108 |
}
|
@@ -114,7 +113,7 @@ class LiteSpeed_Cache_Crawler_Sitemap
|
|
114 |
$cats = get_terms("category", array("hide_empty"=>true, "hierarchical"=>false)) ;
|
115 |
if ( $cats && is_array($cats) && count($cats) > 0 ) {
|
116 |
foreach ( $cats as $cat ) {
|
117 |
-
$slug = str_replace($this->
|
118 |
if ( ! in_array($slug, $blacklist) ){
|
119 |
$this->_urls[] = $slug ;//var_dump($slug);exit;//todo: check permalink
|
120 |
}
|
@@ -127,7 +126,7 @@ class LiteSpeed_Cache_Crawler_Sitemap
|
|
127 |
$tags = get_terms("post_tag", array("hide_empty"=>true, "hierarchical"=>false)) ;
|
128 |
if ( $tags && is_array($tags) && count($tags) > 0 ) {
|
129 |
foreach ( $tags as $tag ) {
|
130 |
-
$slug = str_replace($this->
|
131 |
if ( ! in_array($slug, $blacklist) ) {
|
132 |
$this->_urls[] = $slug ;
|
133 |
}
|
12 |
class LiteSpeed_Cache_Crawler_Sitemap
|
13 |
{
|
14 |
private static $_instance ;
|
15 |
+
private $home_url ;// Used to simplify urls
|
16 |
|
17 |
protected $_urls = array() ;
|
18 |
|
25 |
private function __construct()
|
26 |
{
|
27 |
if ( is_multisite() ) {
|
28 |
+
$this->home_url = get_home_url( get_current_blog_id() ) ;
|
|
|
29 |
}
|
30 |
else{
|
31 |
+
$this->home_url = get_home_url() ;
|
32 |
}
|
33 |
}
|
34 |
|
101 |
$results = $wpdb->get_results($query) ;
|
102 |
|
103 |
foreach ( $results as $result ){
|
104 |
+
$slug = str_replace($this->home_url, '', get_permalink($result->ID)) ;
|
105 |
if ( ! in_array($slug, $blacklist) ) {
|
106 |
$this->_urls[] = $slug ;
|
107 |
}
|
113 |
$cats = get_terms("category", array("hide_empty"=>true, "hierarchical"=>false)) ;
|
114 |
if ( $cats && is_array($cats) && count($cats) > 0 ) {
|
115 |
foreach ( $cats as $cat ) {
|
116 |
+
$slug = str_replace($this->home_url, '', get_category_link($cat->term_id)) ;
|
117 |
if ( ! in_array($slug, $blacklist) ){
|
118 |
$this->_urls[] = $slug ;//var_dump($slug);exit;//todo: check permalink
|
119 |
}
|
126 |
$tags = get_terms("post_tag", array("hide_empty"=>true, "hierarchical"=>false)) ;
|
127 |
if ( $tags && is_array($tags) && count($tags) > 0 ) {
|
128 |
foreach ( $tags as $tag ) {
|
129 |
+
$slug = str_replace($this->home_url, '', get_tag_link($tag->term_id)) ;
|
130 |
if ( ! in_array($slug, $blacklist) ) {
|
131 |
$this->_urls[] = $slug ;
|
132 |
}
|
includes/litespeed-cache-crawler.class.php
CHANGED
@@ -14,7 +14,7 @@ class LiteSpeed_Cache_Crawler
|
|
14 |
private static $_instance;
|
15 |
private $_sitemap_file ;
|
16 |
private $_blacklist_file ;
|
17 |
-
private $
|
18 |
const CRWL_BLACKLIST = 'crawler_blacklist' ;
|
19 |
|
20 |
/**
|
@@ -29,11 +29,11 @@ class LiteSpeed_Cache_Crawler
|
|
29 |
if ( is_multisite() ) {
|
30 |
$blogID = get_current_blog_id() ;
|
31 |
$this->_sitemap_file = $sitemapPath . '/crawlermap-' . $blogID . '.data' ;
|
32 |
-
$this->
|
33 |
}
|
34 |
else{
|
35 |
$this->_sitemap_file = $sitemapPath . '/crawlermap.data' ;
|
36 |
-
$this->
|
37 |
}
|
38 |
$this->_blacklist_file = $this->_sitemap_file . '.blacklist' ;
|
39 |
|
@@ -53,7 +53,7 @@ class LiteSpeed_Cache_Crawler
|
|
53 |
return false ;
|
54 |
}
|
55 |
$metaUrl = implode('/', array_slice(explode('/', $this->_sitemap_file . '.meta'), -5)) ;
|
56 |
-
return $this->
|
57 |
}
|
58 |
|
59 |
/**
|
@@ -261,10 +261,10 @@ class LiteSpeed_Cache_Crawler
|
|
261 |
if ( $sitemap = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ) ) {
|
262 |
$sitemap_urls = $this->parse_custom_sitemap( $sitemap ) ;
|
263 |
$urls = array() ;
|
264 |
-
$offset = strlen( $this->
|
265 |
if ( is_array( $sitemap_urls ) && ! empty( $sitemap_urls ) ) {
|
266 |
foreach ( $sitemap_urls as $val ) {
|
267 |
-
if ( stripos( $val, $this->
|
268 |
$urls[] = substr( $val, $offset ) ;
|
269 |
}
|
270 |
}
|
@@ -381,7 +381,7 @@ class LiteSpeed_Cache_Crawler
|
|
381 |
}
|
382 |
$this->_generate_sitemap() ;
|
383 |
}
|
384 |
-
$crawler->set_base_url($this->
|
385 |
$crawler->set_run_duration($options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION]) ;
|
386 |
$crawler->set_run_delay($options[LiteSpeed_Cache_Config::CRWL_USLEEP]) ;
|
387 |
$crawler->set_threads_limit($options[LiteSpeed_Cache_Config::CRWL_THREADS]) ;
|
14 |
private static $_instance;
|
15 |
private $_sitemap_file ;
|
16 |
private $_blacklist_file ;
|
17 |
+
private $_home_url ;
|
18 |
const CRWL_BLACKLIST = 'crawler_blacklist' ;
|
19 |
|
20 |
/**
|
29 |
if ( is_multisite() ) {
|
30 |
$blogID = get_current_blog_id() ;
|
31 |
$this->_sitemap_file = $sitemapPath . '/crawlermap-' . $blogID . '.data' ;
|
32 |
+
$this->_home_url = get_home_url( $blogID ) ;
|
33 |
}
|
34 |
else{
|
35 |
$this->_sitemap_file = $sitemapPath . '/crawlermap.data' ;
|
36 |
+
$this->_home_url = get_home_url() ;
|
37 |
}
|
38 |
$this->_blacklist_file = $this->_sitemap_file . '.blacklist' ;
|
39 |
|
53 |
return false ;
|
54 |
}
|
55 |
$metaUrl = implode('/', array_slice(explode('/', $this->_sitemap_file . '.meta'), -5)) ;
|
56 |
+
return $this->_home_url . '/' . $metaUrl ;
|
57 |
}
|
58 |
|
59 |
/**
|
261 |
if ( $sitemap = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ) ) {
|
262 |
$sitemap_urls = $this->parse_custom_sitemap( $sitemap ) ;
|
263 |
$urls = array() ;
|
264 |
+
$offset = strlen( $this->_home_url ) ;
|
265 |
if ( is_array( $sitemap_urls ) && ! empty( $sitemap_urls ) ) {
|
266 |
foreach ( $sitemap_urls as $val ) {
|
267 |
+
if ( stripos( $val, $this->_home_url ) === 0 ) {
|
268 |
$urls[] = substr( $val, $offset ) ;
|
269 |
}
|
270 |
}
|
381 |
}
|
382 |
$this->_generate_sitemap() ;
|
383 |
}
|
384 |
+
$crawler->set_base_url($this->_home_url) ;
|
385 |
$crawler->set_run_duration($options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION]) ;
|
386 |
$crawler->set_run_delay($options[LiteSpeed_Cache_Config::CRWL_USLEEP]) ;
|
387 |
$crawler->set_threads_limit($options[LiteSpeed_Cache_Config::CRWL_THREADS]) ;
|
includes/litespeed-cache-esi.class.php
CHANGED
@@ -161,23 +161,27 @@ class LiteSpeed_Cache_ESI
|
|
161 |
*
|
162 |
* The block_id parameter should contain alphanumeric and '-_' only.
|
163 |
*
|
164 |
-
* If echo is false *HAS_ESI WILL NOT BE SET TO TRUE*!
|
165 |
-
*
|
166 |
* @since 1.1.3
|
167 |
* @access private
|
168 |
* @param string $block_id The id to use to display the correct esi block.
|
169 |
* @param string $wrapper The wrapper for the esi comments.
|
170 |
* @param array $params The esi parameters.
|
171 |
* @param string $control The cache control attribute if any.
|
172 |
-
* @param
|
173 |
-
* @return
|
174 |
*/
|
175 |
-
public static function sub_esi_block($block_id, $wrapper, $params = array(), $control = 'private,no-vary', $
|
176 |
{
|
177 |
if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
|
178 |
return false ;
|
179 |
}
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
$params = apply_filters('litespeed_cache_sub_esi_params-' . $block_id, $params) ;
|
182 |
$control = apply_filters('litespeed_cache_sub_esi_control-' . $block_id, $control) ;
|
183 |
if ( !is_array($params) || !is_string($control) ) {
|
@@ -190,19 +194,20 @@ class LiteSpeed_Cache_ESI
|
|
190 |
}
|
191 |
|
192 |
$url = trailingslashit( wp_make_link_relative( home_url() ) ) . '?' . self::QS_ACTION . '=' . self::POSTTYPE . '&' . self::QS_PARAMS . '=' . urlencode(base64_encode(serialize($params))) ;
|
193 |
-
$output = "
|
194 |
if ( ! empty( $control ) ) {
|
195 |
$output .= " cache-control='$control'" ;
|
196 |
}
|
197 |
-
$output .= "
|
|
|
|
|
|
|
|
|
198 |
|
199 |
LiteSpeed_Cache_Log::debug( "ESI block ID:$block_id; $wrapper; $control" ) ;
|
200 |
|
201 |
-
if ( $echo == false ) {
|
202 |
-
return $output ;
|
203 |
-
}
|
204 |
-
echo $output ;
|
205 |
self::set_has_esi() ;
|
|
|
206 |
}
|
207 |
|
208 |
/**
|
@@ -252,6 +257,10 @@ class LiteSpeed_Cache_ESI
|
|
252 |
LiteSpeed_Cache_Log::push( $logInfo ) ;
|
253 |
}
|
254 |
|
|
|
|
|
|
|
|
|
255 |
$orig = $_SERVER[ 'REQUEST_URI' ] ;
|
256 |
$_SERVER[ 'REQUEST_URI' ] = !empty( $_SERVER[ 'ESI_REFERER' ] ) ? $_SERVER[ 'ESI_REFERER' ] : false ;
|
257 |
|
@@ -394,7 +403,7 @@ class LiteSpeed_Cache_ESI
|
|
394 |
self::PARAM_ARGS => $args
|
395 |
) ;
|
396 |
|
397 |
-
self::sub_esi_block( 'widget', 'widget ' . $name, $params, $esi_private . 'no-vary' ) ;
|
398 |
return false ;
|
399 |
}
|
400 |
|
@@ -414,7 +423,7 @@ class LiteSpeed_Cache_ESI
|
|
414 |
return ;
|
415 |
}
|
416 |
|
417 |
-
self::sub_esi_block('admin-bar', 'adminbar') ;
|
418 |
}
|
419 |
|
420 |
/**
|
@@ -459,7 +468,7 @@ class LiteSpeed_Cache_ESI
|
|
459 |
self::PARAM_ARGS => $esi_args,
|
460 |
) ;
|
461 |
|
462 |
-
self::sub_esi_block('comment-form', 'comment form', $params) ;
|
463 |
ob_start() ;
|
464 |
add_action('comment_form_after', array($this, 'comment_form_sub_clean')) ;
|
465 |
return $unused ;
|
161 |
*
|
162 |
* The block_id parameter should contain alphanumeric and '-_' only.
|
163 |
*
|
|
|
|
|
164 |
* @since 1.1.3
|
165 |
* @access private
|
166 |
* @param string $block_id The id to use to display the correct esi block.
|
167 |
* @param string $wrapper The wrapper for the esi comments.
|
168 |
* @param array $params The esi parameters.
|
169 |
* @param string $control The cache control attribute if any.
|
170 |
+
* @param bool $silence If generate wrapper comment or not
|
171 |
+
* @return bool|string False on error, the output otherwise.
|
172 |
*/
|
173 |
+
public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false )
|
174 |
{
|
175 |
if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
|
176 |
return false ;
|
177 |
}
|
178 |
+
|
179 |
+
$params[ self::PARAM_BLOCK_ID ] = $block_id ;
|
180 |
+
if ( $silence ) {
|
181 |
+
// Don't add comment to esi block ( orignal for nonce used in tag property data-nonce='esi_block' )
|
182 |
+
$params[ '_ls_silence' ] = true ;
|
183 |
+
}
|
184 |
+
|
185 |
$params = apply_filters('litespeed_cache_sub_esi_params-' . $block_id, $params) ;
|
186 |
$control = apply_filters('litespeed_cache_sub_esi_control-' . $block_id, $control) ;
|
187 |
if ( !is_array($params) || !is_string($control) ) {
|
194 |
}
|
195 |
|
196 |
$url = trailingslashit( wp_make_link_relative( home_url() ) ) . '?' . self::QS_ACTION . '=' . self::POSTTYPE . '&' . self::QS_PARAMS . '=' . urlencode(base64_encode(serialize($params))) ;
|
197 |
+
$output = "<esi:include src='$url'" ;
|
198 |
if ( ! empty( $control ) ) {
|
199 |
$output .= " cache-control='$control'" ;
|
200 |
}
|
201 |
+
$output .= " />" ;
|
202 |
+
|
203 |
+
if ( ! $silence ) {
|
204 |
+
$output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
|
205 |
+
}
|
206 |
|
207 |
LiteSpeed_Cache_Log::debug( "ESI block ID:$block_id; $wrapper; $control" ) ;
|
208 |
|
|
|
|
|
|
|
|
|
209 |
self::set_has_esi() ;
|
210 |
+
return $output ;
|
211 |
}
|
212 |
|
213 |
/**
|
257 |
LiteSpeed_Cache_Log::push( $logInfo ) ;
|
258 |
}
|
259 |
|
260 |
+
if ( ! empty( $params[ '_ls_silence' ] ) ) {
|
261 |
+
define( 'LSCACHE_ESI_SILENCE', true ) ;
|
262 |
+
}
|
263 |
+
|
264 |
$orig = $_SERVER[ 'REQUEST_URI' ] ;
|
265 |
$_SERVER[ 'REQUEST_URI' ] = !empty( $_SERVER[ 'ESI_REFERER' ] ) ? $_SERVER[ 'ESI_REFERER' ] : false ;
|
266 |
|
403 |
self::PARAM_ARGS => $args
|
404 |
) ;
|
405 |
|
406 |
+
echo self::sub_esi_block( 'widget', 'widget ' . $name, $params, $esi_private . 'no-vary' ) ;
|
407 |
return false ;
|
408 |
}
|
409 |
|
423 |
return ;
|
424 |
}
|
425 |
|
426 |
+
echo self::sub_esi_block('admin-bar', 'adminbar') ;
|
427 |
}
|
428 |
|
429 |
/**
|
468 |
self::PARAM_ARGS => $esi_args,
|
469 |
) ;
|
470 |
|
471 |
+
echo self::sub_esi_block('comment-form', 'comment form', $params) ;
|
472 |
ob_start() ;
|
473 |
add_action('comment_form_after', array($this, 'comment_form_sub_clean')) ;
|
474 |
return $unused ;
|
includes/litespeed-cache-gui.class.php
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The frontend GUI class.
|
5 |
+
*
|
6 |
+
* @since 1.3
|
7 |
+
* @package LiteSpeed_Cache
|
8 |
+
* @subpackage LiteSpeed_Cache/includes
|
9 |
+
* @author LiteSpeed Technologies <info@litespeedtech.com>
|
10 |
+
*/
|
11 |
+
|
12 |
+
class LiteSpeed_Cache_GUI
|
13 |
+
{
|
14 |
+
private static $_instance ;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Init
|
18 |
+
*
|
19 |
+
* @since 1.3
|
20 |
+
* @access private
|
21 |
+
*/
|
22 |
+
private function __construct()
|
23 |
+
{
|
24 |
+
if ( ! is_admin() && is_admin_bar_showing() && current_user_can( 'manage_options' ) ) {
|
25 |
+
LiteSpeed_Cache_Log::debug( 'GUI init' ) ;
|
26 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'frontend_enqueue_style' ) ) ;
|
27 |
+
add_action( 'admin_bar_menu', array( $this, 'frontend_shortcut' ), 95 ) ;
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Load frontend menu shortcut
|
33 |
+
*
|
34 |
+
* @since 1.3
|
35 |
+
* @access private
|
36 |
+
*/
|
37 |
+
public function frontend_enqueue_style()
|
38 |
+
{
|
39 |
+
wp_enqueue_style( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all' ) ;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Load frontend menu shortcut
|
44 |
+
*
|
45 |
+
* @since 1.3
|
46 |
+
* @access private
|
47 |
+
*/
|
48 |
+
public function frontend_shortcut()
|
49 |
+
{
|
50 |
+
|
51 |
+
global $wp_admin_bar ;
|
52 |
+
$wp_admin_bar->add_menu( array(
|
53 |
+
'id' => 'litespeed-menu',
|
54 |
+
'title' => '<span class="ab-icon"></span>',
|
55 |
+
'href' => get_admin_url( null, 'admin.php?page=lscache-settings' ),
|
56 |
+
'meta' => array( 'tabindex' => 0, 'class' => 'litespeed-top-toolbar' ),
|
57 |
+
) ) ;
|
58 |
+
|
59 |
+
$wp_admin_bar->add_menu( array(
|
60 |
+
'parent' => 'litespeed-menu',
|
61 |
+
'id' => 'litespeed-purge-single',
|
62 |
+
'title' => __( 'Purge this page', 'litespeed-cache' ),
|
63 |
+
'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_PURGE, false, false, true ),
|
64 |
+
'meta' => array( 'tabindex' => '0' ),
|
65 |
+
) );
|
66 |
+
|
67 |
+
$wp_admin_bar->add_menu( array(
|
68 |
+
'parent' => 'litespeed-menu',
|
69 |
+
'id' => 'litespeed-single-action',
|
70 |
+
'title' => __( 'Mark this page as ', 'litespeed-cache' ),
|
71 |
+
'meta' => array( 'tabindex' => '0' ),
|
72 |
+
) );
|
73 |
+
|
74 |
+
$wp_admin_bar->add_menu( array(
|
75 |
+
'parent' => 'litespeed-single-action',
|
76 |
+
'id' => 'litespeed-single-noncache',
|
77 |
+
'title' => __( 'Non cacheable', 'litespeed-cache' ),
|
78 |
+
'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nocache', true ),
|
79 |
+
) );
|
80 |
+
|
81 |
+
$wp_admin_bar->add_menu( array(
|
82 |
+
'parent' => 'litespeed-single-action',
|
83 |
+
'id' => 'litespeed-single-private',
|
84 |
+
'title' => __( 'Private cache', 'litespeed-cache' ),
|
85 |
+
'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=private', true ),
|
86 |
+
) );
|
87 |
+
|
88 |
+
$wp_admin_bar->add_menu( array(
|
89 |
+
'parent' => 'litespeed-single-action',
|
90 |
+
'id' => 'litespeed-single-more',
|
91 |
+
'title' => __( 'More settings', 'litespeed-cache' ),
|
92 |
+
'href' => get_admin_url( null, 'admin.php?page=lscache-settings#excludes' ),
|
93 |
+
) );
|
94 |
+
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* Get the current instance object.
|
100 |
+
*
|
101 |
+
* @since 1.3
|
102 |
+
* @access public
|
103 |
+
* @return Current class instance.
|
104 |
+
*/
|
105 |
+
public static function get_instance()
|
106 |
+
{
|
107 |
+
if ( ! isset( self::$_instance ) ) {
|
108 |
+
self::$_instance = new self() ;
|
109 |
+
}
|
110 |
+
|
111 |
+
return self::$_instance ;
|
112 |
+
}
|
113 |
+
|
114 |
+
}
|
115 |
+
|
116 |
+
|
includes/litespeed-cache-log.class.php
CHANGED
@@ -134,6 +134,11 @@ class LiteSpeed_Cache_Log
|
|
134 |
*/
|
135 |
private static function format_message( $msg )
|
136 |
{
|
|
|
|
|
|
|
|
|
|
|
137 |
if ( ! isset( self::$_prefix ) ) {
|
138 |
// address
|
139 |
if ( PHP_SAPI == 'cli' ) {
|
@@ -148,14 +153,9 @@ class LiteSpeed_Cache_Log
|
|
148 |
else {
|
149 |
$addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ] ;
|
150 |
}
|
|
|
151 |
// Generate a unique string per request
|
152 |
-
|
153 |
-
$_random_list = '0123456789abcdefghijklmnopqrstuvwxyz' ;
|
154 |
-
$max = strlen( $_random_list ) - 1 ;
|
155 |
-
for( $i = 0 ; $i < 3 ; $i++ ) {
|
156 |
-
$unique .= $_random_list[ mt_rand( 0, $max ) ] ;
|
157 |
-
}
|
158 |
-
self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, $unique ) ;
|
159 |
}
|
160 |
list( $usec, $sec ) = explode(' ', microtime() ) ;
|
161 |
return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n" ;
|
134 |
*/
|
135 |
private static function format_message( $msg )
|
136 |
{
|
137 |
+
// If call here without calling get_enabled() first, improve compatibility
|
138 |
+
if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
|
139 |
+
return $msg . "\n" ;
|
140 |
+
}
|
141 |
+
|
142 |
if ( ! isset( self::$_prefix ) ) {
|
143 |
// address
|
144 |
if ( PHP_SAPI == 'cli' ) {
|
153 |
else {
|
154 |
$addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ] ;
|
155 |
}
|
156 |
+
|
157 |
// Generate a unique string per request
|
158 |
+
self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, Litespeed_String::rrand( 3 ) ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
list( $usec, $sec ) = explode(' ', microtime() ) ;
|
161 |
return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n" ;
|
includes/litespeed-cache-optimize.class.php
CHANGED
@@ -13,8 +13,8 @@ class LiteSpeed_Cache_Optimize
|
|
13 |
{
|
14 |
private static $_instance ;
|
15 |
|
16 |
-
const OPTION_OPTIMIZED = 'litespeed-cache-optimized' ;
|
17 |
const DIR_MIN = '/min' ;
|
|
|
18 |
|
19 |
private $content ;
|
20 |
private $http2_headers = array() ;
|
@@ -26,6 +26,14 @@ class LiteSpeed_Cache_Optimize
|
|
26 |
private $cfg_js_minify ;
|
27 |
private $cfg_js_combine ;
|
28 |
private $cfg_html_minify ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
private $minify_cache ;
|
31 |
private $minify_minify ;
|
@@ -49,8 +57,62 @@ class LiteSpeed_Cache_Optimize
|
|
49 |
$this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
|
50 |
$this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
|
51 |
$this->cfg_html_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
/**
|
@@ -60,8 +122,26 @@ class LiteSpeed_Cache_Optimize
|
|
60 |
* @access private
|
61 |
* @return string The static file content
|
62 |
*/
|
63 |
-
private function
|
64 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
// If not turn on min files
|
66 |
if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
|
67 |
return ;
|
@@ -103,6 +183,47 @@ class LiteSpeed_Cache_Optimize
|
|
103 |
exit ;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
/**
|
107 |
* Run optimize process
|
108 |
* NOTE: As this is after cache finalized, can NOT set any cache control anymore
|
@@ -113,8 +234,12 @@ class LiteSpeed_Cache_Optimize
|
|
113 |
*/
|
114 |
public static function run( $content )
|
115 |
{
|
116 |
-
if (
|
117 |
-
|
|
|
|
|
|
|
|
|
118 |
return $content ;
|
119 |
}
|
120 |
|
@@ -135,30 +260,69 @@ class LiteSpeed_Cache_Optimize
|
|
135 |
*/
|
136 |
private function _optimize()
|
137 |
{
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
|
|
|
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css ) {
|
143 |
-
list( $src_list, $html_list ) = $this->_parse_css() ;
|
144 |
|
145 |
if ( $src_list ) {
|
146 |
-
|
|
|
147 |
|
148 |
// IF combine
|
149 |
if ( $this->cfg_css_combine ) {
|
150 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
-
$html_head .= implode( '', $ignored_html ) . "<link data-minified='1' rel='stylesheet' href='$url' />" ;
|
153 |
// Move all css to top
|
154 |
$this->content = str_replace( $html_list, '', $this->content ) ;
|
155 |
|
156 |
// Add to HTTP2
|
157 |
-
|
|
|
|
|
158 |
|
159 |
}
|
160 |
// Only minify
|
161 |
elseif ( $this->cfg_css_minify ) {
|
|
|
162 |
$this->_src_queue_handler( $src_queue_list, $html_list ) ;
|
163 |
}
|
164 |
// Only HTTP2 push
|
@@ -170,11 +334,29 @@ class LiteSpeed_Cache_Optimize
|
|
170 |
}
|
171 |
}
|
172 |
|
173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
174 |
list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
|
|
|
|
|
|
|
|
|
175 |
|
176 |
if ( $src_list ) {
|
177 |
-
list( $ignored_html, $src_queue_list ) = $this->_analyse_links( $src_list, $html_list, 'js' ) ;
|
178 |
|
179 |
// IF combine
|
180 |
if ( $this->cfg_js_combine ) {
|
@@ -183,12 +365,12 @@ class LiteSpeed_Cache_Optimize
|
|
183 |
$head_ignored_html = array() ;
|
184 |
$foot_js = array() ;
|
185 |
$foot_ignored_html = array() ;
|
186 |
-
foreach ( $src_queue_list as $src ) {
|
187 |
if ( in_array( $src, $head_src_list ) ) {
|
188 |
-
$head_js[] = $src ;
|
189 |
}
|
190 |
else {
|
191 |
-
$foot_js[] = $src ;
|
192 |
}
|
193 |
}
|
194 |
foreach ( $ignored_html as $src => $html ) {
|
@@ -200,44 +382,81 @@ class LiteSpeed_Cache_Optimize
|
|
200 |
}
|
201 |
}
|
202 |
|
203 |
-
$
|
204 |
-
if ( $
|
205 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
-
$html_head .= implode( '', $head_ignored_html ) . $
|
208 |
|
209 |
-
$
|
210 |
-
if ( $
|
211 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
-
$html_foot .= implode( '', $foot_ignored_html ) . $
|
214 |
|
215 |
// Will move all js to top/bottom
|
216 |
$this->content = str_replace( $html_list, '', $this->content ) ;
|
217 |
|
218 |
-
// Add to HTTP2
|
219 |
-
$this->append_http2( $url, 'js' ) ;
|
220 |
-
|
221 |
}
|
222 |
// Only minify
|
223 |
elseif ( $this->cfg_js_minify ) {
|
|
|
224 |
$this->_src_queue_handler( $src_queue_list, $html_list, 'js' ) ;
|
225 |
}
|
226 |
// Only HTTP2 push
|
227 |
else {
|
228 |
foreach ( $src_queue_list as $val ) {
|
229 |
-
$this->append_http2( $val ) ;
|
230 |
}
|
231 |
}
|
232 |
}
|
233 |
}
|
234 |
|
235 |
-
if
|
236 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
}
|
238 |
|
239 |
-
|
240 |
-
|
|
|
|
|
241 |
}
|
242 |
|
243 |
// HTML minify
|
@@ -263,6 +482,44 @@ class LiteSpeed_Cache_Optimize
|
|
263 |
if ( $this->http2_headers ) {
|
264 |
@header( 'Link: ' . implode( ',', $this->http2_headers ), false ) ;
|
265 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
|
268 |
/**
|
@@ -273,17 +530,33 @@ class LiteSpeed_Cache_Optimize
|
|
273 |
*/
|
274 |
private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
|
275 |
{
|
|
|
|
|
|
|
276 |
$tag = $file_type === 'css' ? 'link' : 'script' ;
|
277 |
foreach ( $src_queue_list as $key => $src ) {
|
278 |
$url = $this->_build_hash_url( $src, $file_type ) ;
|
279 |
-
$
|
280 |
-
$
|
281 |
|
282 |
-
$
|
283 |
|
284 |
// Add to HTTP2
|
285 |
$this->append_http2( $url, $file_type ) ;
|
286 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
287 |
}
|
288 |
|
289 |
/**
|
@@ -291,7 +564,7 @@ class LiteSpeed_Cache_Optimize
|
|
291 |
*
|
292 |
* @since 1.2.2
|
293 |
* @access private
|
294 |
-
* @return array Array(Ignored raw html, src needed to be handled list)
|
295 |
*/
|
296 |
private function _analyse_links( $src_list, $html_list, $file_type = 'css' )
|
297 |
{
|
@@ -307,6 +580,7 @@ class LiteSpeed_Cache_Optimize
|
|
307 |
|
308 |
$ignored_html = array() ;
|
309 |
$src_queue_list = array() ;
|
|
|
310 |
|
311 |
// Analyse links
|
312 |
foreach ( $src_list as $key => $src ) {
|
@@ -324,16 +598,17 @@ class LiteSpeed_Cache_Optimize
|
|
324 |
|
325 |
// Check if is external URL
|
326 |
$url_parsed = parse_url( $src ) ;
|
327 |
-
if ( ! $this->_is_file_url( $src ) ) {
|
328 |
$ignored_html[ $src ] = $html_list[ $key ] ;
|
329 |
LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist ' ) ;
|
330 |
continue ;
|
331 |
}
|
332 |
|
333 |
$src_queue_list[ $key ] = $src ;
|
|
|
334 |
}
|
335 |
|
336 |
-
return array( $ignored_html, $src_queue_list ) ;
|
337 |
}
|
338 |
|
339 |
/**
|
@@ -384,7 +659,7 @@ class LiteSpeed_Cache_Optimize
|
|
384 |
return false ;
|
385 |
}
|
386 |
|
387 |
-
return $file_path ;
|
388 |
}
|
389 |
|
390 |
/**
|
@@ -397,12 +672,11 @@ class LiteSpeed_Cache_Optimize
|
|
397 |
private function _minify( $filename )
|
398 |
{
|
399 |
// Search filename in db for src URLs
|
400 |
-
$
|
401 |
-
if ( ! $
|
402 |
return false;
|
403 |
}
|
404 |
|
405 |
-
$urls = $hashes[ $filename ] ;
|
406 |
$file_type = substr( $filename, strrpos( $filename, '.' ) + 1 ) ;
|
407 |
|
408 |
// Parse real file path
|
@@ -412,7 +686,7 @@ class LiteSpeed_Cache_Optimize
|
|
412 |
if ( ! $real_file ) {
|
413 |
continue ;
|
414 |
}
|
415 |
-
$real_files[] = $real_file ;
|
416 |
}
|
417 |
|
418 |
if ( ! $real_files ) {
|
@@ -457,28 +731,22 @@ class LiteSpeed_Cache_Optimize
|
|
457 |
$filename = $short ;
|
458 |
|
459 |
// Need to check conflicts
|
460 |
-
$hashes = get_option( self::OPTION_OPTIMIZED ) ;
|
461 |
-
if ( ! is_array( $hashes ) ) {
|
462 |
-
$hashes = array() ;
|
463 |
-
}
|
464 |
// If short hash exists
|
465 |
-
if ( $
|
466 |
// If conflicts
|
467 |
-
if ( $
|
468 |
-
|
469 |
-
update_option( self::OPTION_OPTIMIZED, $hashes ) ;
|
470 |
$filename = $hash ;
|
471 |
}
|
472 |
}
|
473 |
else {
|
474 |
// Short hash is safe now
|
475 |
-
|
476 |
-
update_option( self::OPTION_OPTIMIZED, $hashes ) ;
|
477 |
}
|
478 |
|
479 |
$file_to_save = self::DIR_MIN . '/' . $filename . '.' . $file_type ;
|
480 |
|
481 |
-
return
|
482 |
}
|
483 |
|
484 |
/**
|
@@ -524,14 +792,16 @@ class LiteSpeed_Cache_Optimize
|
|
524 |
}
|
525 |
|
526 |
/**
|
527 |
-
* Parse css src
|
528 |
*
|
529 |
* @since 1.2.2
|
530 |
* @access private
|
531 |
* @return array All the src & related raw html list
|
532 |
*/
|
533 |
-
private function
|
534 |
{
|
|
|
|
|
535 |
$src_list = array() ;
|
536 |
$html_list = array() ;
|
537 |
|
@@ -558,6 +828,14 @@ class LiteSpeed_Cache_Optimize
|
|
558 |
continue ;
|
559 |
}
|
560 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
561 |
$src_list[] = $attrs[ 'href' ] ;
|
562 |
$html_list[] = $match[ 0 ] ;
|
563 |
}
|
@@ -565,6 +843,53 @@ class LiteSpeed_Cache_Optimize
|
|
565 |
return array( $src_list, $html_list ) ;
|
566 |
}
|
567 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
568 |
/**
|
569 |
* Parse attributes from string
|
570 |
*
|
13 |
{
|
14 |
private static $_instance ;
|
15 |
|
|
|
16 |
const DIR_MIN = '/min' ;
|
17 |
+
const CSS_ASYNC_LIB = '/min/css_async.js' ;
|
18 |
|
19 |
private $content ;
|
20 |
private $http2_headers = array() ;
|
26 |
private $cfg_js_minify ;
|
27 |
private $cfg_js_combine ;
|
28 |
private $cfg_html_minify ;
|
29 |
+
private $cfg_css_async ;
|
30 |
+
private $cfg_js_defer ;
|
31 |
+
private $cfg_qs_rm ;
|
32 |
+
|
33 |
+
|
34 |
+
private $html_foot = '' ; // The html info append to <body>
|
35 |
+
private $html_head = '' ; // The html info prepend to <body>
|
36 |
+
private $css_to_be_removed = array() ;
|
37 |
|
38 |
private $minify_cache ;
|
39 |
private $minify_minify ;
|
57 |
$this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
|
58 |
$this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
|
59 |
$this->cfg_html_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ;
|
60 |
+
$this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
|
61 |
+
$this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
|
62 |
+
$this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
|
63 |
+
|
64 |
+
$this->_static_request_check() ;
|
65 |
+
|
66 |
+
if ( ! $this->_can_optm() ) {
|
67 |
+
return ;
|
68 |
+
}
|
69 |
+
|
70 |
+
// To remove emoji from WP
|
71 |
+
if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
|
72 |
+
add_action( 'init', array( $this, 'emoji_rm' ) ) ;
|
73 |
+
}
|
74 |
+
|
75 |
+
if ( $this->cfg_qs_rm ) {
|
76 |
+
add_filter( 'style_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
|
77 |
+
add_filter( 'script_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
|
78 |
+
}
|
79 |
+
|
80 |
+
// Check if there is any critical css rules setting
|
81 |
+
if ( $this->cfg_css_async ) {
|
82 |
+
add_action( 'wp_head', array( $this, 'prepend_critical_css' ), 1 ) ;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Remove emoji from WP
|
88 |
+
*
|
89 |
+
* @since 1.4
|
90 |
+
* @access public
|
91 |
+
*/
|
92 |
+
public function emoji_rm()
|
93 |
+
{
|
94 |
+
remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
|
95 |
+
remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
|
96 |
+
remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
|
97 |
+
remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
|
98 |
+
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Output critical css
|
102 |
+
*
|
103 |
+
* @since 1.3
|
104 |
+
* @access public
|
105 |
+
* @return string The static file content
|
106 |
+
*/
|
107 |
+
public function prepend_critical_css()
|
108 |
+
{
|
109 |
+
|
110 |
+
$rules = get_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ;
|
111 |
+
if ( ! $rules ) {
|
112 |
+
return ;
|
113 |
+
}
|
114 |
+
|
115 |
+
echo '<style id="litespeed-optm-css-rules">' . $rules . '</style>' ;
|
116 |
}
|
117 |
|
118 |
/**
|
122 |
* @access private
|
123 |
* @return string The static file content
|
124 |
*/
|
125 |
+
private function _static_request_check()
|
126 |
{
|
127 |
+
// This request is for js/css_async.js
|
128 |
+
if ( $this->cfg_css_async && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
|
129 |
+
LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
|
130 |
+
|
131 |
+
LiteSpeed_Cache_Control::set_cacheable() ;
|
132 |
+
LiteSpeed_Cache_Control::set_no_vary() ;
|
133 |
+
LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
|
134 |
+
LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_CSS_ASYNC' ) ;
|
135 |
+
|
136 |
+
$file = LSWCP_DIR . 'js/css_async.js' ;
|
137 |
+
|
138 |
+
header( 'Content-Length: ' . filesize( $file ) ) ;
|
139 |
+
header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
|
140 |
+
|
141 |
+
echo file_get_contents( $file ) ;
|
142 |
+
exit ;
|
143 |
+
}
|
144 |
+
|
145 |
// If not turn on min files
|
146 |
if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
|
147 |
return ;
|
183 |
exit ;
|
184 |
}
|
185 |
|
186 |
+
/**
|
187 |
+
* Remove QS
|
188 |
+
*
|
189 |
+
* @since 1.3
|
190 |
+
* @access public
|
191 |
+
*/
|
192 |
+
public function remove_query_strings( $src )
|
193 |
+
{
|
194 |
+
if ( strpos( $src, 'ver=' ) !== false ) {
|
195 |
+
$src = preg_replace( '#[&\?]+(ver=([\w\-\.]+))#i', '', $src ) ;
|
196 |
+
}
|
197 |
+
return $src ;
|
198 |
+
}
|
199 |
+
|
200 |
+
/**
|
201 |
+
* Check if can run optimize
|
202 |
+
*
|
203 |
+
* @since 1.3
|
204 |
+
* @access private
|
205 |
+
*/
|
206 |
+
private function _can_optm()
|
207 |
+
{
|
208 |
+
if ( is_admin() ) {
|
209 |
+
return false ;
|
210 |
+
}
|
211 |
+
|
212 |
+
if ( is_feed() ) {
|
213 |
+
return false ;
|
214 |
+
}
|
215 |
+
|
216 |
+
if ( is_preview() ) {
|
217 |
+
return false ;
|
218 |
+
}
|
219 |
+
|
220 |
+
if ( LiteSpeed_Cache_Router::is_ajax() ) {
|
221 |
+
return false ;
|
222 |
+
}
|
223 |
+
|
224 |
+
return true ;
|
225 |
+
}
|
226 |
+
|
227 |
/**
|
228 |
* Run optimize process
|
229 |
* NOTE: As this is after cache finalized, can NOT set any cache control anymore
|
234 |
*/
|
235 |
public static function run( $content )
|
236 |
{
|
237 |
+
if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again
|
238 |
+
return $content ;
|
239 |
+
}
|
240 |
+
|
241 |
+
if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
|
242 |
+
LiteSpeed_Cache_Log::debug( 'Optimizer bypass: Not frontend HTML type' ) ;
|
243 |
return $content ;
|
244 |
}
|
245 |
|
260 |
*/
|
261 |
private function _optimize()
|
262 |
{
|
263 |
+
if ( ! $this->_can_optm() ) {
|
264 |
+
LiteSpeed_Cache_Log::debug( 'Optimizer bypass: admin/feed/preview' ) ;
|
265 |
+
return ;
|
266 |
+
}
|
267 |
+
|
268 |
+
do_action( 'litespeed_optm' ) ;
|
269 |
|
270 |
+
// Parse css from content
|
271 |
+
$ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
|
272 |
+
if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async ) {
|
273 |
+
// To remove google fonts
|
274 |
+
if ( $ggfonts_rm ) {
|
275 |
+
$this->css_to_be_removed[] = 'fonts.googleapis.com' ;
|
276 |
+
}
|
277 |
+
list( $src_list, $html_list ) = $this->_handle_css() ;
|
278 |
+
}
|
279 |
+
|
280 |
+
// css optimizer
|
281 |
if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css ) {
|
|
|
282 |
|
283 |
if ( $src_list ) {
|
284 |
+
// Analyze local file
|
285 |
+
list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list ) ;
|
286 |
|
287 |
// IF combine
|
288 |
if ( $this->cfg_css_combine ) {
|
289 |
+
$urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
|
290 |
+
|
291 |
+
$snippet = '' ;
|
292 |
+
foreach ( $urls as $url ) {
|
293 |
+
$snippet .= "<link data-minified='1' rel='stylesheet' href='$url' />" ;
|
294 |
+
}
|
295 |
+
|
296 |
+
// Handle css async load
|
297 |
+
if ( $this->cfg_css_async ) {
|
298 |
+
// Only ignored html snippet needs async
|
299 |
+
list( $noscript, $ignored_html_async ) = $this->_async_css_list( $ignored_html ) ;
|
300 |
+
|
301 |
+
$noscript .= $snippet ;
|
302 |
+
$snippet = '' ;
|
303 |
+
foreach ( $urls as $url ) {
|
304 |
+
$snippet .= "<link rel='preload' data-preload='1' data-minified='1' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
|
305 |
+
}
|
306 |
+
|
307 |
+
$this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
|
308 |
+
$this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
|
309 |
+
}
|
310 |
+
else {
|
311 |
+
$this->html_head .= implode( '', $ignored_html ) . $snippet ;
|
312 |
+
}
|
313 |
|
|
|
314 |
// Move all css to top
|
315 |
$this->content = str_replace( $html_list, '', $this->content ) ;
|
316 |
|
317 |
// Add to HTTP2
|
318 |
+
foreach ( $urls as $url ) {
|
319 |
+
$this->append_http2( $url ) ;
|
320 |
+
}
|
321 |
|
322 |
}
|
323 |
// Only minify
|
324 |
elseif ( $this->cfg_css_minify ) {
|
325 |
+
// will handle async css load inside
|
326 |
$this->_src_queue_handler( $src_queue_list, $html_list ) ;
|
327 |
}
|
328 |
// Only HTTP2 push
|
334 |
}
|
335 |
}
|
336 |
|
337 |
+
// Handle css lazy load if not handled async loaded yet
|
338 |
+
if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
|
339 |
+
// async html
|
340 |
+
list( $noscript, $html_list_async ) = $this->_async_css_list( $html_list ) ;
|
341 |
+
|
342 |
+
// add noscript
|
343 |
+
$this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
|
344 |
+
|
345 |
+
// Replace async css
|
346 |
+
$this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
|
347 |
+
|
348 |
+
}
|
349 |
+
|
350 |
+
// Parse js from buffer as needed
|
351 |
+
if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
|
352 |
list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
|
353 |
+
}
|
354 |
+
|
355 |
+
// js optimizer
|
356 |
+
if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js ) {
|
357 |
|
358 |
if ( $src_list ) {
|
359 |
+
list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list, 'js' ) ;
|
360 |
|
361 |
// IF combine
|
362 |
if ( $this->cfg_js_combine ) {
|
365 |
$head_ignored_html = array() ;
|
366 |
$foot_js = array() ;
|
367 |
$foot_ignored_html = array() ;
|
368 |
+
foreach ( $src_queue_list as $k => $src ) {
|
369 |
if ( in_array( $src, $head_src_list ) ) {
|
370 |
+
$head_js[ $k ] = $src ;
|
371 |
}
|
372 |
else {
|
373 |
+
$foot_js[ $k ] = $src ;
|
374 |
}
|
375 |
}
|
376 |
foreach ( $ignored_html as $src => $html ) {
|
382 |
}
|
383 |
}
|
384 |
|
385 |
+
$snippet = '' ;
|
386 |
+
if ( $head_js ) {
|
387 |
+
$urls = $this->_limit_size_build_hash_url( $head_js, $file_size_list, 'js' ) ;
|
388 |
+
foreach ( $urls as $url ) {
|
389 |
+
$snippet .= "<script data-minified='1' src='$url' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
|
390 |
+
|
391 |
+
// Add to HTTP2
|
392 |
+
$this->append_http2( $url, 'js' ) ;
|
393 |
+
}
|
394 |
+
}
|
395 |
+
if ( $this->cfg_js_defer ) {
|
396 |
+
$head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
|
397 |
}
|
398 |
+
$this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
|
399 |
|
400 |
+
$snippet = '' ;
|
401 |
+
if ( $foot_js ) {
|
402 |
+
$urls = $this->_limit_size_build_hash_url( $foot_js, $file_size_list, 'js' ) ;
|
403 |
+
foreach ( $urls as $url ) {
|
404 |
+
$snippet .= "<script data-minified='1' src='$url' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
|
405 |
+
|
406 |
+
// Add to HTTP2
|
407 |
+
$this->append_http2( $url, 'js' ) ;
|
408 |
+
}
|
409 |
+
}
|
410 |
+
if ( $this->cfg_js_defer ) {
|
411 |
+
$foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
|
412 |
}
|
413 |
+
$this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
|
414 |
|
415 |
// Will move all js to top/bottom
|
416 |
$this->content = str_replace( $html_list, '', $this->content ) ;
|
417 |
|
|
|
|
|
|
|
418 |
}
|
419 |
// Only minify
|
420 |
elseif ( $this->cfg_js_minify ) {
|
421 |
+
// Will handle js defer inside
|
422 |
$this->_src_queue_handler( $src_queue_list, $html_list, 'js' ) ;
|
423 |
}
|
424 |
// Only HTTP2 push
|
425 |
else {
|
426 |
foreach ( $src_queue_list as $val ) {
|
427 |
+
$this->append_http2( $val, 'js' ) ;
|
428 |
}
|
429 |
}
|
430 |
}
|
431 |
}
|
432 |
|
433 |
+
// Handle js defer if not handled defer yet
|
434 |
+
if ( $this->cfg_js_defer && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
|
435 |
+
// defer html
|
436 |
+
$html_list2 = $this->_js_defer( $html_list ) ;
|
437 |
+
|
438 |
+
// Replace async js
|
439 |
+
$this->content = str_replace( $html_list, $html_list2, $this->content ) ;
|
440 |
+
}
|
441 |
+
|
442 |
+
|
443 |
+
// Append async compatibility lib to head
|
444 |
+
if ( $this->cfg_css_async ) {
|
445 |
+
$css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
|
446 |
+
$this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;
|
447 |
+
$this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
|
448 |
+
}
|
449 |
+
|
450 |
+
// Replace html head part
|
451 |
+
$this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
|
452 |
+
if ( $this->html_head ) {
|
453 |
+
$this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
|
454 |
}
|
455 |
|
456 |
+
// Replace html foot part
|
457 |
+
$this->html_foot = apply_filters( 'litespeed_optm_html_foot', $this->html_foot ) ;
|
458 |
+
if ( $this->html_foot ) {
|
459 |
+
$this->content = str_replace( '</body>', $this->html_foot . '</body>' , $this->content ) ;
|
460 |
}
|
461 |
|
462 |
// HTML minify
|
482 |
if ( $this->http2_headers ) {
|
483 |
@header( 'Link: ' . implode( ',', $this->http2_headers ), false ) ;
|
484 |
}
|
485 |
+
|
486 |
+
}
|
487 |
+
|
488 |
+
/**
|
489 |
+
* Limit combined filesize when build hash url
|
490 |
+
*
|
491 |
+
* @since 1.3
|
492 |
+
* @access private
|
493 |
+
*/
|
494 |
+
private function _limit_size_build_hash_url( $src_queue_list, $file_size_list, $file_type = 'css' )
|
495 |
+
{
|
496 |
+
$total = 0 ;
|
497 |
+
$i = 0 ;
|
498 |
+
$src_arr = array() ;
|
499 |
+
foreach ( $src_queue_list as $k => $v ) {
|
500 |
+
|
501 |
+
empty( $src_arr[ $i ] ) && $src_arr[ $i ] = array() ;
|
502 |
+
|
503 |
+
$src_arr[ $i ][] = $v ;
|
504 |
+
|
505 |
+
$total += $file_size_list[ $k ] ;
|
506 |
+
|
507 |
+
if ( $total > 1000000 ) { // If larger than 1M, separate them
|
508 |
+
$total = 0;
|
509 |
+
$i ++ ;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
if ( count( $src_arr ) > 1 ) {
|
513 |
+
LiteSpeed_Cache_Log::debug( 'Optimizer: separate ' . $file_type . ' to ' . count( $src_arr ) ) ;
|
514 |
+
}
|
515 |
+
|
516 |
+
// group build
|
517 |
+
$hashed_arr = array() ;
|
518 |
+
foreach ( $src_arr as $v ) {
|
519 |
+
$hashed_arr[] = $this->_build_hash_url( $v, $file_type ) ;
|
520 |
+
}
|
521 |
+
|
522 |
+
return $hashed_arr ;
|
523 |
}
|
524 |
|
525 |
/**
|
530 |
*/
|
531 |
private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
|
532 |
{
|
533 |
+
$noscript = '' ;
|
534 |
+
$html_list_ori = $html_list ;
|
535 |
+
|
536 |
$tag = $file_type === 'css' ? 'link' : 'script' ;
|
537 |
foreach ( $src_queue_list as $key => $src ) {
|
538 |
$url = $this->_build_hash_url( $src, $file_type ) ;
|
539 |
+
$snippet = str_replace( $src, $url, $html_list[ $key ] ) ;
|
540 |
+
$snippet = str_replace( "<$tag ", "<$tag data-minified='1' ", $snippet ) ;
|
541 |
|
542 |
+
$html_list[ $key ] = $snippet ;
|
543 |
|
544 |
// Add to HTTP2
|
545 |
$this->append_http2( $url, $file_type ) ;
|
546 |
}
|
547 |
+
|
548 |
+
// Handle css async load
|
549 |
+
if ( $file_type === 'css' && $this->cfg_css_async ) {
|
550 |
+
list( $noscript, $html_list ) = $this->_async_css_list( $html_list ) ;
|
551 |
+
$this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
|
552 |
+
}
|
553 |
+
|
554 |
+
// Handle js defer
|
555 |
+
if ( $file_type === 'js' && $this->cfg_js_defer ) {
|
556 |
+
$html_list = $this->_js_defer( $html_list ) ;
|
557 |
+
}
|
558 |
+
|
559 |
+
$this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
|
560 |
}
|
561 |
|
562 |
/**
|
564 |
*
|
565 |
* @since 1.2.2
|
566 |
* @access private
|
567 |
+
* @return array Array(Ignored raw html, src needed to be handled list, filesize for param 2nd )
|
568 |
*/
|
569 |
private function _analyse_links( $src_list, $html_list, $file_type = 'css' )
|
570 |
{
|
580 |
|
581 |
$ignored_html = array() ;
|
582 |
$src_queue_list = array() ;
|
583 |
+
$file_size_list = array() ;
|
584 |
|
585 |
// Analyse links
|
586 |
foreach ( $src_list as $key => $src ) {
|
598 |
|
599 |
// Check if is external URL
|
600 |
$url_parsed = parse_url( $src ) ;
|
601 |
+
if ( ! $file_info = $this->_is_file_url( $src ) ) {
|
602 |
$ignored_html[ $src ] = $html_list[ $key ] ;
|
603 |
LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist ' ) ;
|
604 |
continue ;
|
605 |
}
|
606 |
|
607 |
$src_queue_list[ $key ] = $src ;
|
608 |
+
$file_size_list[ $key ] = $file_info[ 1 ] ;
|
609 |
}
|
610 |
|
611 |
+
return array( $ignored_html, $src_queue_list, $file_size_list ) ;
|
612 |
}
|
613 |
|
614 |
/**
|
659 |
return false ;
|
660 |
}
|
661 |
|
662 |
+
return array( $file_path, filesize( $file_path ) ) ;
|
663 |
}
|
664 |
|
665 |
/**
|
672 |
private function _minify( $filename )
|
673 |
{
|
674 |
// Search filename in db for src URLs
|
675 |
+
$urls = LiteSpeed_Cache_Data::optm_hash2src( $filename ) ;
|
676 |
+
if ( ! $urls || ! is_array( $urls ) ) {
|
677 |
return false;
|
678 |
}
|
679 |
|
|
|
680 |
$file_type = substr( $filename, strrpos( $filename, '.' ) + 1 ) ;
|
681 |
|
682 |
// Parse real file path
|
686 |
if ( ! $real_file ) {
|
687 |
continue ;
|
688 |
}
|
689 |
+
$real_files[] = $real_file[ 0 ] ;
|
690 |
}
|
691 |
|
692 |
if ( ! $real_files ) {
|
731 |
$filename = $short ;
|
732 |
|
733 |
// Need to check conflicts
|
|
|
|
|
|
|
|
|
734 |
// If short hash exists
|
735 |
+
if ( $urls = LiteSpeed_Cache_Data::optm_hash2src( $short . '.' . $file_type ) ) {
|
736 |
// If conflicts
|
737 |
+
if ( $urls !== $src ) {
|
738 |
+
LiteSpeed_Cache_Data::optm_save_src( $hash . '.' . $file_type, $src ) ;
|
|
|
739 |
$filename = $hash ;
|
740 |
}
|
741 |
}
|
742 |
else {
|
743 |
// Short hash is safe now
|
744 |
+
LiteSpeed_Cache_Data::optm_save_src( $short . '.' . $file_type, $src ) ;
|
|
|
745 |
}
|
746 |
|
747 |
$file_to_save = self::DIR_MIN . '/' . $filename . '.' . $file_type ;
|
748 |
|
749 |
+
return LiteSpeed_Cache_Utility::get_permalink_url( $file_to_save ) ;
|
750 |
}
|
751 |
|
752 |
/**
|
792 |
}
|
793 |
|
794 |
/**
|
795 |
+
* Parse css src and remove to-be-removed css
|
796 |
*
|
797 |
* @since 1.2.2
|
798 |
* @access private
|
799 |
* @return array All the src & related raw html list
|
800 |
*/
|
801 |
+
private function _handle_css()
|
802 |
{
|
803 |
+
$this->css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', $this->css_to_be_removed ) ;
|
804 |
+
|
805 |
$src_list = array() ;
|
806 |
$html_list = array() ;
|
807 |
|
828 |
continue ;
|
829 |
}
|
830 |
|
831 |
+
// Check if need to remove this css
|
832 |
+
if ( $this->css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $this->css_to_be_removed ) ) {
|
833 |
+
LiteSpeed_Cache_Log::debug( 'Optm: rm css snippet ' . $attrs[ 'href' ] ) ;
|
834 |
+
// Delete this css snippet from orig html
|
835 |
+
$this->content = str_replace( $match[ 0 ], '', $this->content ) ;
|
836 |
+
continue ;
|
837 |
+
}
|
838 |
+
|
839 |
$src_list[] = $attrs[ 'href' ] ;
|
840 |
$html_list[] = $match[ 0 ] ;
|
841 |
}
|
843 |
return array( $src_list, $html_list ) ;
|
844 |
}
|
845 |
|
846 |
+
/**
|
847 |
+
* Replace css to async loaded css
|
848 |
+
*
|
849 |
+
* @since 1.3
|
850 |
+
* @access private
|
851 |
+
* @param array $html_list Orignal css array
|
852 |
+
* @return array array( (string)noscript, (array)css_async_list )
|
853 |
+
*/
|
854 |
+
private function _async_css_list( $html_list )
|
855 |
+
{
|
856 |
+
$noscript = '' ;
|
857 |
+
foreach ( $html_list as $k => $ori ) {
|
858 |
+
// Append to noscript content
|
859 |
+
$noscript .= $ori ;
|
860 |
+
// async replacement
|
861 |
+
$v = str_replace( 'stylesheet', 'preload', $ori ) ;
|
862 |
+
$v = str_replace( '<link', "<link data-preload='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
|
863 |
+
$html_list[ $k ] = $v ;
|
864 |
+
}
|
865 |
+
return array( $noscript, $html_list ) ;
|
866 |
+
}
|
867 |
+
|
868 |
+
/**
|
869 |
+
* Add defer to js
|
870 |
+
*
|
871 |
+
* @since 1.3
|
872 |
+
* @access private
|
873 |
+
*/
|
874 |
+
private function _js_defer( $html_list )
|
875 |
+
{
|
876 |
+
foreach ( $html_list as $k => $v ) {
|
877 |
+
if ( strpos( $v, 'async' ) !== false ) {
|
878 |
+
continue ;
|
879 |
+
}
|
880 |
+
if ( strpos( $v, 'defer' ) !== false ) {
|
881 |
+
continue ;
|
882 |
+
}
|
883 |
+
if ( strpos( $v, 'data-defer' ) !== false ) {
|
884 |
+
continue ;
|
885 |
+
}
|
886 |
+
|
887 |
+
$html_list[ $k ] = str_replace( '></script>', ' defer></script>', $v ) ;
|
888 |
+
}
|
889 |
+
|
890 |
+
return $html_list ;
|
891 |
+
}
|
892 |
+
|
893 |
/**
|
894 |
* Parse attributes from string
|
895 |
*
|
includes/litespeed-cache-purge.class.php
CHANGED
@@ -268,7 +268,7 @@ class LiteSpeed_Cache_Purge
|
|
268 |
* @param string $value A url to purge.
|
269 |
* @param string $key Unused.
|
270 |
*/
|
271 |
-
public function purgeby_url_cb( $value, $key )
|
272 |
{
|
273 |
$val = trim( $value ) ;
|
274 |
if ( empty( $val ) ) {
|
@@ -339,6 +339,25 @@ class LiteSpeed_Cache_Purge
|
|
339 |
$_GET[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] = $sel ;
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
/**
|
343 |
* Purge a post on update.
|
344 |
*
|
268 |
* @param string $value A url to purge.
|
269 |
* @param string $key Unused.
|
270 |
*/
|
271 |
+
public function purgeby_url_cb( $value, $key = false )
|
272 |
{
|
273 |
$val = trim( $value ) ;
|
274 |
if ( empty( $val ) ) {
|
339 |
$_GET[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] = $sel ;
|
340 |
}
|
341 |
|
342 |
+
/**
|
343 |
+
* Purge frontend url
|
344 |
+
*
|
345 |
+
* @since 1.3
|
346 |
+
* @access public
|
347 |
+
*/
|
348 |
+
public static function frontend_purge()
|
349 |
+
{
|
350 |
+
if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
|
351 |
+
exit( 'no referer' ) ;
|
352 |
+
}
|
353 |
+
$instance = self::get_instance() ;
|
354 |
+
|
355 |
+
$instance->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
|
356 |
+
|
357 |
+
wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
|
358 |
+
exit() ;
|
359 |
+
}
|
360 |
+
|
361 |
/**
|
362 |
* Purge a post on update.
|
363 |
*
|
includes/litespeed-cache-router.class.php
CHANGED
@@ -13,16 +13,13 @@
|
|
13 |
class LiteSpeed_Cache_Router
|
14 |
{
|
15 |
private static $_instance ;
|
16 |
-
private static $_is_enabled ;
|
17 |
private static $_esi_enabled ;
|
18 |
private static $_is_ajax ;
|
19 |
private static $_is_logged_in ;
|
20 |
-
private static $_is_cli ;
|
21 |
private static $_can_crawl ;
|
22 |
private static $_ip ;
|
23 |
private static $_action ;
|
24 |
private static $_is_admin_ip ;
|
25 |
-
private static $_siteurl ;
|
26 |
private static $_has_whm_msg ;
|
27 |
private static $_has_msg_ruleconflict ;
|
28 |
private static $_frontend_path ;
|
@@ -51,27 +48,6 @@ class LiteSpeed_Cache_Router
|
|
51 |
return self::$_frontend_path ;
|
52 |
}
|
53 |
|
54 |
-
/**
|
55 |
-
* Check if crawler is enabled on server level
|
56 |
-
*
|
57 |
-
* @since 1.1.1
|
58 |
-
* @access public
|
59 |
-
* @return string
|
60 |
-
*/
|
61 |
-
public static function get_siteurl()
|
62 |
-
{
|
63 |
-
if ( ! isset( self::$_siteurl ) ) {
|
64 |
-
if ( is_multisite() ) {
|
65 |
-
$blogID = get_current_blog_id() ;
|
66 |
-
self::$_siteurl = get_site_url( $blogID ) ;
|
67 |
-
}
|
68 |
-
else{
|
69 |
-
self::$_siteurl = get_option( 'siteurl' ) ;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
return self::$_siteurl ;
|
73 |
-
}
|
74 |
-
|
75 |
/**
|
76 |
* Check if ESI is enabled or not
|
77 |
*
|
@@ -82,34 +58,11 @@ class LiteSpeed_Cache_Router
|
|
82 |
public static function esi_enabled()
|
83 |
{
|
84 |
if ( ! isset( self::$_esi_enabled ) ) {
|
85 |
-
self::$_esi_enabled = LSWCP_ESI_SUPPORT && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_ENABLE ) ;
|
86 |
}
|
87 |
return self::$_esi_enabled ;
|
88 |
}
|
89 |
|
90 |
-
/**
|
91 |
-
* Check if cache is enabled or not
|
92 |
-
*
|
93 |
-
* @since 1.1.5
|
94 |
-
* @access public
|
95 |
-
* @return boolean
|
96 |
-
*/
|
97 |
-
public static function cache_enabled()
|
98 |
-
{
|
99 |
-
if ( ! isset( self::$_is_enabled ) ) {
|
100 |
-
if ( ! LiteSpeed_Cache_Config::get_instance()->is_caching_allowed() ) {
|
101 |
-
self::$_is_enabled = false ;
|
102 |
-
}
|
103 |
-
elseif ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) ) {
|
104 |
-
self::$_is_enabled = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ) ;
|
105 |
-
}
|
106 |
-
else {
|
107 |
-
self::$_is_enabled = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ENABLED ) ;
|
108 |
-
}
|
109 |
-
}
|
110 |
-
return self::$_is_enabled ;
|
111 |
-
}
|
112 |
-
|
113 |
/**
|
114 |
* Check if has rule conflict notice
|
115 |
*
|
@@ -155,7 +108,7 @@ class LiteSpeed_Cache_Router
|
|
155 |
self::$_can_crawl = true ;
|
156 |
}
|
157 |
// CLI will bypass this check as crawler library can always do the 428 check
|
158 |
-
if (
|
159 |
self::$_can_crawl = true ;
|
160 |
}
|
161 |
}
|
@@ -197,21 +150,6 @@ class LiteSpeed_Cache_Router
|
|
197 |
return self::$_is_logged_in ;
|
198 |
}
|
199 |
|
200 |
-
/**
|
201 |
-
* Check if is cli usage
|
202 |
-
*
|
203 |
-
* @since 1.1.0
|
204 |
-
* @access public
|
205 |
-
* @return boolean
|
206 |
-
*/
|
207 |
-
public static function is_cli()
|
208 |
-
{
|
209 |
-
if ( ! isset( self::$_is_cli ) ) {
|
210 |
-
self::$_is_cli = defined( 'WP_CLI' ) && WP_CLI ;
|
211 |
-
}
|
212 |
-
return self::$_is_cli ;
|
213 |
-
}
|
214 |
-
|
215 |
/**
|
216 |
* Check if is ajax call
|
217 |
*
|
@@ -288,7 +226,6 @@ class LiteSpeed_Cache_Router
|
|
288 |
LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL: ' . $action ) ;
|
289 |
|
290 |
// OK, as we want to do something magic, lets check if its allowed
|
291 |
-
$_is_enabled = self::cache_enabled() ;
|
292 |
$_is_multisite = is_multisite() ;
|
293 |
$_is_network_admin = $_is_multisite && is_network_admin() ;
|
294 |
$_can_network_option = $_is_network_admin && current_user_can( 'manage_network_options' ) ;
|
@@ -315,22 +252,21 @@ class LiteSpeed_Cache_Router
|
|
315 |
case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
|
316 |
case LiteSpeed_Cache::ACTION_PURGE_ALL:
|
317 |
case LiteSpeed_Cache::ACTION_PURGE_BY:
|
318 |
-
|
319 |
-
|
|
|
320 |
self::$_action = $action ;
|
321 |
}
|
322 |
return ;
|
323 |
|
324 |
case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
|
325 |
-
if (
|
326 |
self::$_action = $action ;
|
327 |
}
|
328 |
return ;
|
329 |
|
330 |
case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
|
331 |
-
if ( $
|
332 |
-
&& ( $_can_network_option
|
333 |
-
|| ( ! $_is_multisite && $_can_option ) ) ) {
|
334 |
self::$_action = $action ;
|
335 |
}
|
336 |
return ;
|
@@ -341,7 +277,7 @@ class LiteSpeed_Cache_Router
|
|
341 |
case LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS:
|
342 |
case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
|
343 |
case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
|
344 |
-
if (
|
345 |
self::$_action = $action ;
|
346 |
}
|
347 |
return ;
|
@@ -351,7 +287,7 @@ class LiteSpeed_Cache_Router
|
|
351 |
case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
|
352 |
case LiteSpeed_Cache::ACTION_DO_CRAWL:
|
353 |
case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
|
354 |
-
if (
|
355 |
self::$_action = $action ;
|
356 |
}
|
357 |
return ;
|
13 |
class LiteSpeed_Cache_Router
|
14 |
{
|
15 |
private static $_instance ;
|
|
|
16 |
private static $_esi_enabled ;
|
17 |
private static $_is_ajax ;
|
18 |
private static $_is_logged_in ;
|
|
|
19 |
private static $_can_crawl ;
|
20 |
private static $_ip ;
|
21 |
private static $_action ;
|
22 |
private static $_is_admin_ip ;
|
|
|
23 |
private static $_has_whm_msg ;
|
24 |
private static $_has_msg_ruleconflict ;
|
25 |
private static $_frontend_path ;
|
48 |
return self::$_frontend_path ;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* Check if ESI is enabled or not
|
53 |
*
|
58 |
public static function esi_enabled()
|
59 |
{
|
60 |
if ( ! isset( self::$_esi_enabled ) ) {
|
61 |
+
self::$_esi_enabled = LSWCP_ESI_SUPPORT && defined( 'LITESPEED_ON' ) && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_ENABLE ) ;
|
62 |
}
|
63 |
return self::$_esi_enabled ;
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
/**
|
67 |
* Check if has rule conflict notice
|
68 |
*
|
108 |
self::$_can_crawl = true ;
|
109 |
}
|
110 |
// CLI will bypass this check as crawler library can always do the 428 check
|
111 |
+
if ( defined( 'LITESPEED_CLI' ) ) {
|
112 |
self::$_can_crawl = true ;
|
113 |
}
|
114 |
}
|
150 |
return self::$_is_logged_in ;
|
151 |
}
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
/**
|
154 |
* Check if is ajax call
|
155 |
*
|
226 |
LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL: ' . $action ) ;
|
227 |
|
228 |
// OK, as we want to do something magic, lets check if its allowed
|
|
|
229 |
$_is_multisite = is_multisite() ;
|
230 |
$_is_network_admin = $_is_multisite && is_network_admin() ;
|
231 |
$_can_network_option = $_is_network_admin && current_user_can( 'manage_network_options' ) ;
|
252 |
case LiteSpeed_Cache::ACTION_PURGE_ERRORS:
|
253 |
case LiteSpeed_Cache::ACTION_PURGE_ALL:
|
254 |
case LiteSpeed_Cache::ACTION_PURGE_BY:
|
255 |
+
case LiteSpeed_Cache::ACTION_FRONT_PURGE:
|
256 |
+
case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
|
257 |
+
if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
|
258 |
self::$_action = $action ;
|
259 |
}
|
260 |
return ;
|
261 |
|
262 |
case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
|
263 |
+
if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option ) ) {
|
264 |
self::$_action = $action ;
|
265 |
}
|
266 |
return ;
|
267 |
|
268 |
case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
|
269 |
+
if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
|
|
|
|
|
270 |
self::$_action = $action ;
|
271 |
}
|
272 |
return ;
|
277 |
case LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS:
|
278 |
case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
|
279 |
case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
|
280 |
+
if ( defined( 'LITESPEED_ON' ) && ( $_is_public_action || self::is_ajax() ) ) {
|
281 |
self::$_action = $action ;
|
282 |
}
|
283 |
return ;
|
287 |
case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
|
288 |
case LiteSpeed_Cache::ACTION_DO_CRAWL:
|
289 |
case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
|
290 |
+
if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
|
291 |
self::$_action = $action ;
|
292 |
}
|
293 |
return ;
|
includes/litespeed-cache-task.class.php
CHANGED
@@ -47,18 +47,26 @@ class LiteSpeed_Cache_Task
|
|
47 |
*/
|
48 |
public static function update( $options = false )
|
49 |
{
|
50 |
-
$
|
51 |
-
$
|
52 |
-
|
53 |
-
$is_active = $options[$id_task_enabled] && $options[$id_plugin_enabled] ;
|
54 |
}
|
55 |
else {
|
56 |
-
$is_active = LiteSpeed_Cache::config( $
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
}
|
58 |
|
59 |
if ( $is_active ) {
|
60 |
self::schedule_filter() ;
|
61 |
-
self::register() ;
|
62 |
}
|
63 |
else {
|
64 |
self::clear() ;
|
@@ -75,6 +83,12 @@ class LiteSpeed_Cache_Task
|
|
75 |
public static function schedule_filter()
|
76 |
{
|
77 |
add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -100,20 +114,6 @@ class LiteSpeed_Cache_Task
|
|
100 |
return $schedules ;
|
101 |
}
|
102 |
|
103 |
-
/**
|
104 |
-
* Register the cron task to WP
|
105 |
-
*
|
106 |
-
* @since 1.1.0
|
107 |
-
* @access public
|
108 |
-
*/
|
109 |
-
public static function register()
|
110 |
-
{
|
111 |
-
if( ! wp_next_scheduled( self::CRON_ACTION_HOOK ) ) {
|
112 |
-
LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
|
113 |
-
wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK ) ;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
|
117 |
/**
|
118 |
* Clear cron
|
119 |
*
|
47 |
*/
|
48 |
public static function update( $options = false )
|
49 |
{
|
50 |
+
$id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
|
51 |
+
if ( $options && isset( $options[ $id ] ) ) {
|
52 |
+
$is_active = $options[$id] ;
|
|
|
53 |
}
|
54 |
else {
|
55 |
+
$is_active = LiteSpeed_Cache::config( $id ) ;
|
56 |
+
}
|
57 |
+
|
58 |
+
// If cron setting is on, check cache status
|
59 |
+
if ( $is_active ) {
|
60 |
+
if ( defined( 'LITESPEED_NEW_OFF' ) ) {
|
61 |
+
$is_active = false ;
|
62 |
+
}
|
63 |
+
elseif ( ! defined( 'LITESPEED_ON' ) && ! defined( 'LITESPEED_NEW_ON' ) ) {
|
64 |
+
$is_active = false ;
|
65 |
+
}
|
66 |
}
|
67 |
|
68 |
if ( $is_active ) {
|
69 |
self::schedule_filter() ;
|
|
|
70 |
}
|
71 |
else {
|
72 |
self::clear() ;
|
83 |
public static function schedule_filter()
|
84 |
{
|
85 |
add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
|
86 |
+
|
87 |
+
// Schedule event here to see if it can lost again or not
|
88 |
+
if( ! wp_next_scheduled( self::CRON_ACTION_HOOK ) ) {
|
89 |
+
LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
|
90 |
+
wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK ) ;
|
91 |
+
}
|
92 |
}
|
93 |
|
94 |
/**
|
114 |
return $schedules ;
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
/**
|
118 |
* Clear cron
|
119 |
*
|
includes/litespeed-cache-utility.class.php
CHANGED
@@ -11,6 +11,48 @@
|
|
11 |
class LiteSpeed_Cache_Utility
|
12 |
{
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* Improve compatibility to PHP old versions
|
16 |
*
|
@@ -37,11 +79,32 @@ class LiteSpeed_Cache_Utility
|
|
37 |
return $host === LITESPEED_FRONTEND_HOST ;
|
38 |
}
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* Convert URL to URI
|
42 |
*
|
43 |
* @since 1.2.2
|
44 |
-
*
|
45 |
*/
|
46 |
public static function url2uri( $url )
|
47 |
{
|
@@ -53,18 +116,139 @@ class LiteSpeed_Cache_Utility
|
|
53 |
/**
|
54 |
* Make URL to be relative
|
55 |
*
|
|
|
|
|
56 |
* @param string $url
|
57 |
-
* @return string Relative URL
|
58 |
*/
|
59 |
public static function make_relative( $url )
|
60 |
{
|
61 |
-
// replace
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
if ( strpos( $url, $site_url_domain ) === 0 ) {
|
66 |
-
$url = substr( $url, strlen( $site_url_domain ) ) ;
|
67 |
}
|
68 |
return trim( $url ) ;
|
69 |
}
|
70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
class LiteSpeed_Cache_Utility
|
12 |
{
|
13 |
|
14 |
+
/**
|
15 |
+
* Get url based on permalink setting
|
16 |
+
*
|
17 |
+
* @since 1.3
|
18 |
+
* @access public
|
19 |
+
* @return string
|
20 |
+
*/
|
21 |
+
public static function get_permalink_url( $relative_url )
|
22 |
+
{
|
23 |
+
return $GLOBALS[ 'wp_rewrite' ]->using_permalinks() ? home_url( $relative_url ) : home_url() . '/?' . $relative_url ;
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Check if an array has a string
|
28 |
+
*
|
29 |
+
* Support $ exact match
|
30 |
+
*
|
31 |
+
* @since 1.3
|
32 |
+
* @access private
|
33 |
+
* @param string $needle The string to search with
|
34 |
+
* @param array $haystack
|
35 |
+
* @return bool|string False if not found, otherwise return the matched string in haystack.
|
36 |
+
*/
|
37 |
+
public static function str_hit_array( $needle, $haystack )
|
38 |
+
{
|
39 |
+
foreach( $haystack as $item ) {
|
40 |
+
// do exact match
|
41 |
+
if ( substr( $item, -1 ) === '$' ) {
|
42 |
+
if ( $needle === substr( $item, 1 ) ) {
|
43 |
+
return $item ;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
else {
|
47 |
+
if ( strpos( $needle, $item ) !== false ) {
|
48 |
+
return $item ;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return false ;
|
54 |
+
}
|
55 |
+
|
56 |
/**
|
57 |
* Improve compatibility to PHP old versions
|
58 |
*
|
79 |
return $host === LITESPEED_FRONTEND_HOST ;
|
80 |
}
|
81 |
|
82 |
+
/**
|
83 |
+
* Convert URI to URL
|
84 |
+
*
|
85 |
+
* @since 1.3
|
86 |
+
* @access public
|
87 |
+
* @param string $uri `xx/xx.html` or `/subfolder/xx/xx.html`
|
88 |
+
* @return string http://www.example.com/subfolder/xx/xx.html
|
89 |
+
*/
|
90 |
+
public static function uri2url( $uri )
|
91 |
+
{
|
92 |
+
if ( substr( $uri, 0, 1 ) === '/' ) {
|
93 |
+
self::domain_const() ;
|
94 |
+
$url = LSCWP_DOMAIN . $uri ;
|
95 |
+
}
|
96 |
+
else {
|
97 |
+
$url = home_url( '/' ) . $uri ;
|
98 |
+
}
|
99 |
+
|
100 |
+
return $url ;
|
101 |
+
}
|
102 |
+
|
103 |
/**
|
104 |
* Convert URL to URI
|
105 |
*
|
106 |
* @since 1.2.2
|
107 |
+
* @access public
|
108 |
*/
|
109 |
public static function url2uri( $url )
|
110 |
{
|
116 |
/**
|
117 |
* Make URL to be relative
|
118 |
*
|
119 |
+
* NOTE: for subfolder home_url, need to strip subfolder part (strip anything but scheme and host)
|
120 |
+
*
|
121 |
* @param string $url
|
122 |
+
* @return string Relative URL, start with /
|
123 |
*/
|
124 |
public static function make_relative( $url )
|
125 |
{
|
126 |
+
// replace home_url if the url is full url
|
127 |
+
self::domain_const() ;
|
128 |
+
if ( strpos( $url, LSCWP_DOMAIN ) === 0 ) {
|
129 |
+
$url = substr( $url, strlen( LSCWP_DOMAIN ) ) ;
|
|
|
|
|
130 |
}
|
131 |
return trim( $url ) ;
|
132 |
}
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Generate domain const
|
136 |
+
*
|
137 |
+
* This will generate http://www.example.com even there is a subfolder in home_url setting
|
138 |
+
*
|
139 |
+
* Const LSCWP_DOMAIN has NO trailing /
|
140 |
+
*
|
141 |
+
* @since 1.3
|
142 |
+
* @access public
|
143 |
+
*/
|
144 |
+
public static function domain_const()
|
145 |
+
{
|
146 |
+
if ( defined( 'LSCWP_DOMAIN' ) ) {
|
147 |
+
return ;
|
148 |
+
}
|
149 |
+
|
150 |
+
$home_url = get_home_url( is_multisite() ? get_current_blog_id() : null ) ;
|
151 |
+
|
152 |
+
self::compatibility() ;
|
153 |
+
$domain = http_build_url( $home_url, array(), HTTP_URL_STRIP_ALL ) ;
|
154 |
+
|
155 |
+
define( 'LSCWP_DOMAIN', $domain ) ;
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Array map one textarea to sanitize the url
|
160 |
+
*
|
161 |
+
* @since 1.3
|
162 |
+
* @access public
|
163 |
+
* @param string $content
|
164 |
+
* @param bool $type String handler type
|
165 |
+
* @return string
|
166 |
+
*/
|
167 |
+
public static function sanitize_lines( $content, $type = null )
|
168 |
+
{
|
169 |
+
if ( ! $content ) {
|
170 |
+
return $content ;
|
171 |
+
}
|
172 |
+
|
173 |
+
$arr = explode( "\n", $content ) ;
|
174 |
+
if ( $type === 'uri' ) {
|
175 |
+
$arr = array_map( 'LiteSpeed_Cache_Utility::url2uri', $arr ) ;
|
176 |
+
}
|
177 |
+
if ( $type === 'relative' ) {
|
178 |
+
$arr = array_map( 'LiteSpeed_Cache_Utility::make_relative', $arr ) ;// Remove domain
|
179 |
+
}
|
180 |
+
$arr = array_map( 'trim', $arr ) ;
|
181 |
+
$arr = array_unique( $arr ) ;
|
182 |
+
$arr = array_filter( $arr ) ;
|
183 |
+
return implode( "\n", $arr ) ;
|
184 |
+
}
|
185 |
+
|
186 |
+
/**
|
187 |
+
* Builds an url with an action and a nonce.
|
188 |
+
*
|
189 |
+
* Assumes user capabilities are already checked.
|
190 |
+
*
|
191 |
+
* @access public
|
192 |
+
* @param string $action The LSCWP_CTRL action to do in the url.
|
193 |
+
* @param string $ajax_action AJAX call's action
|
194 |
+
* @param string $append_str The appending string to url
|
195 |
+
* @return string The built url.
|
196 |
+
*/
|
197 |
+
public static function build_url( $action, $ajax_action = false, $append_str = false, $page = null )
|
198 |
+
{
|
199 |
+
$prefix = '?' ;
|
200 |
+
|
201 |
+
if ( $ajax_action === false ) {
|
202 |
+
if ( $page ) {
|
203 |
+
// If use admin url
|
204 |
+
if ( $page === true ) {
|
205 |
+
$page = 'admin.php' ;
|
206 |
+
}
|
207 |
+
else {
|
208 |
+
if ( strpos( $page, '?' ) !== false ) {
|
209 |
+
$prefix = '&' ;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
$combined = $page . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
|
213 |
+
}
|
214 |
+
else {
|
215 |
+
// Current page rebuild URL
|
216 |
+
$params = $_GET ;
|
217 |
+
|
218 |
+
if ( ! empty( $params ) ) {
|
219 |
+
if ( isset( $params[ 'LSCWP_CTRL' ] ) ) {
|
220 |
+
unset( $params[ 'LSCWP_CTRL' ] ) ;
|
221 |
+
}
|
222 |
+
if ( isset( $params[ '_wpnonce' ] ) ) {
|
223 |
+
unset( $params[ '_wpnonce' ] ) ;
|
224 |
+
}
|
225 |
+
if ( ! empty( $params ) ) {
|
226 |
+
$prefix .= http_build_query( $params ) . '&' ;
|
227 |
+
}
|
228 |
+
}
|
229 |
+
global $pagenow ;
|
230 |
+
$combined = $pagenow . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
|
231 |
+
}
|
232 |
+
}
|
233 |
+
else {
|
234 |
+
$combined = 'admin-ajax.php?action=' . $ajax_action . '&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
|
235 |
+
}
|
236 |
+
|
237 |
+
if ( is_network_admin() ) {
|
238 |
+
$prenonce = network_admin_url( $combined ) ;
|
239 |
+
}
|
240 |
+
else {
|
241 |
+
$prenonce = admin_url( $combined ) ;
|
242 |
+
}
|
243 |
+
$url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
|
244 |
+
|
245 |
+
if ( $append_str ) {
|
246 |
+
$url .= '&' . $append_str ;
|
247 |
+
}
|
248 |
+
|
249 |
+
return $url ;
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
|
254 |
+
|
includes/litespeed-cache-vary.class.php
CHANGED
@@ -80,9 +80,7 @@ class LiteSpeed_Cache_Vary
|
|
80 |
$db_cookie = false ;
|
81 |
if ( is_multisite() ) {
|
82 |
$options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
|
83 |
-
|
84 |
-
$db_cookie = $options[LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE] ;
|
85 |
-
}
|
86 |
}
|
87 |
else {
|
88 |
$db_cookie = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE) ;
|
@@ -278,7 +276,13 @@ class LiteSpeed_Cache_Vary
|
|
278 |
if ( ! $res ) {
|
279 |
return false ;
|
280 |
}
|
281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
}
|
283 |
|
284 |
/**
|
80 |
$db_cookie = false ;
|
81 |
if ( is_multisite() ) {
|
82 |
$options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
|
83 |
+
$db_cookie = $options[ LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ] ;
|
|
|
|
|
84 |
}
|
85 |
else {
|
86 |
$db_cookie = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE) ;
|
276 |
if ( ! $res ) {
|
277 |
return false ;
|
278 |
}
|
279 |
+
|
280 |
+
$res = implode( ';', $res ) ;
|
281 |
+
if ( LiteSpeed_Cache_Log::get_enabled() ) {
|
282 |
+
return $res ;
|
283 |
+
}
|
284 |
+
// Encrypt in production
|
285 |
+
return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
|
286 |
}
|
287 |
|
288 |
/**
|
includes/litespeed-cache.class.php
CHANGED
@@ -18,7 +18,7 @@ class LiteSpeed_Cache
|
|
18 |
private static $_instance ;
|
19 |
|
20 |
const PLUGIN_NAME = 'litespeed-cache' ;
|
21 |
-
const PLUGIN_VERSION = '1.
|
22 |
|
23 |
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
|
24 |
|
@@ -48,6 +48,9 @@ class LiteSpeed_Cache
|
|
48 |
const ACTION_DO_CRAWL = 'do-crawl' ;
|
49 |
const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
|
50 |
|
|
|
|
|
|
|
51 |
const ACTION_DB_OPTIMIZE = 'db_optimize' ;
|
52 |
|
53 |
const WHM_TRANSIENT = 'lscwp_whm_install' ;
|
@@ -68,8 +71,9 @@ class LiteSpeed_Cache
|
|
68 |
*/
|
69 |
private function __construct()
|
70 |
{
|
|
|
71 |
// Check if debug is on
|
72 |
-
if (
|
73 |
$should_debug = intval(self::config(LiteSpeed_Cache_Config::OPID_DEBUG)) ;
|
74 |
if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || ($should_debug == LiteSpeed_Cache_Config::VAL_ON2 && LiteSpeed_Cache_Router::is_admin_ip()) ) {
|
75 |
LiteSpeed_Cache_Log::set_enabled() ;
|
@@ -79,13 +83,9 @@ class LiteSpeed_Cache
|
|
79 |
include_once LSWCP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
|
80 |
}
|
81 |
|
82 |
-
if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
|
83 |
-
add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
|
84 |
-
}
|
85 |
-
|
86 |
// Register plugin activate/deactivate/uninstall hooks
|
87 |
// NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
|
88 |
-
if( is_admin() ||
|
89 |
$plugin_file = LSWCP_DIR . 'litespeed-cache.php' ;
|
90 |
register_activation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_activation' )) ;
|
91 |
register_deactivation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' )) ;
|
@@ -114,18 +114,21 @@ class LiteSpeed_Cache
|
|
114 |
*/
|
115 |
public function init()
|
116 |
{
|
|
|
|
|
|
|
|
|
117 |
if( is_admin() ) {
|
118 |
LiteSpeed_Cache_Admin::get_instance() ;
|
119 |
}
|
120 |
|
121 |
-
if ( !
|
122 |
return ;
|
123 |
}
|
124 |
|
125 |
-
define( 'LITESPEED_CACHE_ENABLED', true ) ;
|
126 |
ob_start( array( $this, 'send_headers_force' ) ) ;
|
127 |
add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
|
128 |
-
add_action( 'wp_footer', 'LiteSpeed_Cache::
|
129 |
|
130 |
// Check minify file request in the very beginning
|
131 |
LiteSpeed_Cache_Optimize::get_instance() ;
|
@@ -156,6 +159,10 @@ class LiteSpeed_Cache
|
|
156 |
if ( $action = LiteSpeed_Cache_Router::get_action() ) {
|
157 |
$this->proceed_action( $action ) ;
|
158 |
}
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
|
161 |
/**
|
@@ -238,6 +245,16 @@ class LiteSpeed_Cache
|
|
238 |
$msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
|
239 |
break;
|
240 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
case LiteSpeed_Cache::ACTION_PURGE_BY:
|
242 |
LiteSpeed_Cache_Purge::get_instance()->purge_list() ;
|
243 |
$msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
|
@@ -330,41 +347,67 @@ class LiteSpeed_Cache
|
|
330 |
}
|
331 |
|
332 |
/**
|
333 |
-
*
|
334 |
*
|
335 |
-
* @since 1.
|
336 |
* @access public
|
337 |
*/
|
338 |
-
public static function
|
339 |
{
|
340 |
-
|
341 |
-
|
342 |
-
if ( strlen( $buffer ) > 300 ) {
|
343 |
-
$buffer = substr( $buffer, 0, 300 ) ;
|
344 |
}
|
345 |
-
|
346 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
}
|
348 |
-
|
349 |
if ( defined( 'DOING_AJAX' ) ) {
|
350 |
return ;
|
351 |
}
|
|
|
352 |
if ( defined( 'DOING_CRON' ) ) {
|
353 |
return ;
|
354 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
if ( ! $is_html ) {
|
356 |
LiteSpeed_Cache_Log::debug( 'Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
|
357 |
return ;
|
358 |
}
|
359 |
|
360 |
-
if ( ! defined( '
|
361 |
-
define( '
|
362 |
}
|
363 |
}
|
364 |
|
365 |
/**
|
366 |
* For compatibility with those plugins have 'Bad' logic that forced all buffer output even it is NOT their buffer :(
|
367 |
*
|
|
|
|
|
368 |
* @since 1.1.5
|
369 |
* @access public
|
370 |
* @param string $buffer
|
@@ -372,9 +415,10 @@ class LiteSpeed_Cache
|
|
372 |
*/
|
373 |
public function send_headers_force( $buffer )
|
374 |
{
|
375 |
-
|
376 |
-
|
377 |
-
|
|
|
378 |
$buffer = LiteSpeed_Cache_CDN::run( $buffer ) ;
|
379 |
|
380 |
$buffer .= $this->send_headers( true ) ;
|
@@ -387,8 +431,7 @@ class LiteSpeed_Cache
|
|
387 |
/**
|
388 |
* Sends the headers out at the end of processing the request.
|
389 |
*
|
390 |
-
* This will send out all LiteSpeed Cache related response headers
|
391 |
-
* needed for the post.
|
392 |
*
|
393 |
* @since 1.0.5
|
394 |
* @access public
|
@@ -404,6 +447,8 @@ class LiteSpeed_Cache
|
|
404 |
return ;
|
405 |
}
|
406 |
|
|
|
|
|
407 |
// NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
|
408 |
LiteSpeed_Cache_Control::finalize() ;
|
409 |
|
@@ -422,15 +467,20 @@ class LiteSpeed_Cache
|
|
422 |
$control_header = LiteSpeed_Cache_Control::output() ;
|
423 |
|
424 |
// Init comment info
|
425 |
-
$running_info_showing = defined( '
|
|
|
|
|
|
|
|
|
|
|
426 |
$comment = '' ;
|
427 |
if ( $running_info_showing ) {
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
}
|
435 |
|
436 |
// send Control header
|
18 |
private static $_instance ;
|
19 |
|
20 |
const PLUGIN_NAME = 'litespeed-cache' ;
|
21 |
+
const PLUGIN_VERSION = '1.3.1.1' ;
|
22 |
|
23 |
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
|
24 |
|
48 |
const ACTION_DO_CRAWL = 'do-crawl' ;
|
49 |
const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
|
50 |
|
51 |
+
const ACTION_FRONT_PURGE = 'front-purge' ;
|
52 |
+
const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
|
53 |
+
|
54 |
const ACTION_DB_OPTIMIZE = 'db_optimize' ;
|
55 |
|
56 |
const WHM_TRANSIENT = 'lscwp_whm_install' ;
|
71 |
*/
|
72 |
private function __construct()
|
73 |
{
|
74 |
+
LiteSpeed_Cache_Config::get_instance() ;
|
75 |
// Check if debug is on
|
76 |
+
if ( defined( 'LITESPEED_ON' ) ) {
|
77 |
$should_debug = intval(self::config(LiteSpeed_Cache_Config::OPID_DEBUG)) ;
|
78 |
if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || ($should_debug == LiteSpeed_Cache_Config::VAL_ON2 && LiteSpeed_Cache_Router::is_admin_ip()) ) {
|
79 |
LiteSpeed_Cache_Log::set_enabled() ;
|
83 |
include_once LSWCP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
86 |
// Register plugin activate/deactivate/uninstall hooks
|
87 |
// NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
|
88 |
+
if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
|
89 |
$plugin_file = LSWCP_DIR . 'litespeed-cache.php' ;
|
90 |
register_activation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_activation' )) ;
|
91 |
register_deactivation_hook($plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' )) ;
|
114 |
*/
|
115 |
public function init()
|
116 |
{
|
117 |
+
if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
|
118 |
+
add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
|
119 |
+
}
|
120 |
+
|
121 |
if( is_admin() ) {
|
122 |
LiteSpeed_Cache_Admin::get_instance() ;
|
123 |
}
|
124 |
|
125 |
+
if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) || ! LSCACHE_ADV_CACHE ) {
|
126 |
return ;
|
127 |
}
|
128 |
|
|
|
129 |
ob_start( array( $this, 'send_headers_force' ) ) ;
|
130 |
add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
|
131 |
+
add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
|
132 |
|
133 |
// Check minify file request in the very beginning
|
134 |
LiteSpeed_Cache_Optimize::get_instance() ;
|
159 |
if ( $action = LiteSpeed_Cache_Router::get_action() ) {
|
160 |
$this->proceed_action( $action ) ;
|
161 |
}
|
162 |
+
|
163 |
+
// Load frontend GUI
|
164 |
+
LiteSpeed_Cache_GUI::get_instance() ;
|
165 |
+
|
166 |
}
|
167 |
|
168 |
/**
|
245 |
$msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
|
246 |
break;
|
247 |
|
248 |
+
case LiteSpeed_Cache::ACTION_FRONT_PURGE:
|
249 |
+
// redirect inside
|
250 |
+
LiteSpeed_Cache_Purge::frontend_purge() ;
|
251 |
+
break ;
|
252 |
+
|
253 |
+
case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
|
254 |
+
// redirect inside
|
255 |
+
LiteSpeed_Cache_Config::frontend_save() ;
|
256 |
+
break ;
|
257 |
+
|
258 |
case LiteSpeed_Cache::ACTION_PURGE_BY:
|
259 |
LiteSpeed_Cache_Purge::get_instance()->purge_list() ;
|
260 |
$msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
|
347 |
}
|
348 |
|
349 |
/**
|
350 |
+
* Mark wp_footer called
|
351 |
*
|
352 |
+
* @since 1.3
|
353 |
* @access public
|
354 |
*/
|
355 |
+
public static function footer_hook()
|
356 |
{
|
357 |
+
if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
|
358 |
+
define( 'LITESPEED_FOOTER_CALLED', true ) ;
|
|
|
|
|
359 |
}
|
360 |
+
}
|
361 |
+
|
362 |
+
/**
|
363 |
+
* Tigger coment info display hook
|
364 |
+
*
|
365 |
+
* @since 1.3
|
366 |
+
* @access private
|
367 |
+
*/
|
368 |
+
private function _check_is_html( $buffer = null )
|
369 |
+
{
|
370 |
+
if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
|
371 |
+
return ;
|
372 |
}
|
373 |
+
|
374 |
if ( defined( 'DOING_AJAX' ) ) {
|
375 |
return ;
|
376 |
}
|
377 |
+
|
378 |
if ( defined( 'DOING_CRON' ) ) {
|
379 |
return ;
|
380 |
}
|
381 |
+
|
382 |
+
if ( $buffer === null ) {
|
383 |
+
$buffer = ob_get_contents() ;
|
384 |
+
}
|
385 |
+
|
386 |
+
// double check to make sure it is a html file
|
387 |
+
if ( strlen( $buffer ) > 300 ) {
|
388 |
+
$buffer = substr( $buffer, 0, 300 ) ;
|
389 |
+
}
|
390 |
+
if ( strstr( $buffer, '<!--' ) !== false ) {
|
391 |
+
$buffer = preg_replace( '|<!--.*?-->|s', '', $buffer ) ;
|
392 |
+
}
|
393 |
+
$buffer = trim( $buffer ) ;
|
394 |
+
$is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
|
395 |
+
|
396 |
if ( ! $is_html ) {
|
397 |
LiteSpeed_Cache_Log::debug( 'Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
|
398 |
return ;
|
399 |
}
|
400 |
|
401 |
+
if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
|
402 |
+
define( 'LITESPEED_IS_HTML', true ) ;
|
403 |
}
|
404 |
}
|
405 |
|
406 |
/**
|
407 |
* For compatibility with those plugins have 'Bad' logic that forced all buffer output even it is NOT their buffer :(
|
408 |
*
|
409 |
+
* Usually this is called after send_headers() if following orignal WP process
|
410 |
+
*
|
411 |
* @since 1.1.5
|
412 |
* @access public
|
413 |
* @param string $buffer
|
415 |
*/
|
416 |
public function send_headers_force( $buffer )
|
417 |
{
|
418 |
+
$this->_check_is_html( $buffer ) ;
|
419 |
+
|
420 |
+
$buffer = LiteSpeed_Cache_Optimize::run( $buffer ) ;
|
421 |
+
|
422 |
$buffer = LiteSpeed_Cache_CDN::run( $buffer ) ;
|
423 |
|
424 |
$buffer .= $this->send_headers( true ) ;
|
431 |
/**
|
432 |
* Sends the headers out at the end of processing the request.
|
433 |
*
|
434 |
+
* This will send out all LiteSpeed Cache related response headers needed for the post.
|
|
|
435 |
*
|
436 |
* @since 1.0.5
|
437 |
* @access public
|
447 |
return ;
|
448 |
}
|
449 |
|
450 |
+
$this->_check_is_html() ;
|
451 |
+
|
452 |
// NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
|
453 |
LiteSpeed_Cache_Control::finalize() ;
|
454 |
|
467 |
$control_header = LiteSpeed_Cache_Control::output() ;
|
468 |
|
469 |
// Init comment info
|
470 |
+
$running_info_showing = defined( 'LITESPEED_IS_HTML' ) || defined( 'LSCACHE_IS_ESI' ) ;
|
471 |
+
if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
|
472 |
+
$running_info_showing = false ;
|
473 |
+
LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
|
474 |
+
}
|
475 |
+
|
476 |
$comment = '' ;
|
477 |
if ( $running_info_showing ) {
|
478 |
+
$comment .= sprintf(
|
479 |
+
'<!-- %1$s %2$s by LiteSpeed Cache on %3$s -->',
|
480 |
+
defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
|
481 |
+
LiteSpeed_Cache_Control::is_cacheable() ? 'generated' : 'uncached',
|
482 |
+
date( 'Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET )
|
483 |
+
) ;
|
484 |
}
|
485 |
|
486 |
// send Control header
|
includes/litespeed.autoload.php
CHANGED
@@ -19,6 +19,7 @@ if ( !function_exists('_litespeed_autoload') ) {
|
|
19 |
'LiteSpeed' => 'lib/litespeed/litespeed.class.php',
|
20 |
'Litespeed_Crawler' => 'lib/litespeed/litespeed-crawler.class.php',
|
21 |
'Litespeed_File' => 'lib/litespeed/litespeed-file.class.php',
|
|
|
22 |
|
23 |
'LiteSpeed_Cache' => 'includes/litespeed-cache.class.php',
|
24 |
'LiteSpeed_Cache_Activation' => 'includes/litespeed-cache-activation.class.php',
|
@@ -28,7 +29,9 @@ if ( !function_exists('_litespeed_autoload') ) {
|
|
28 |
'LiteSpeed_Cache_Control' => 'includes/litespeed-cache-control.class.php',
|
29 |
'LiteSpeed_Cache_Crawler' => 'includes/litespeed-cache-crawler.class.php',
|
30 |
'LiteSpeed_Cache_Crawler_Sitemap' => 'includes/litespeed-cache-crawler-sitemap.class.php',
|
|
|
31 |
'LiteSpeed_Cache_ESI' => 'includes/litespeed-cache-esi.class.php',
|
|
|
32 |
'LiteSpeed_Cache_Log' => 'includes/litespeed-cache-log.class.php',
|
33 |
'LiteSpeed_Cache_Optimize' => 'includes/litespeed-cache-optimize.class.php',
|
34 |
'LiteSpeed_Cache_Purge' => 'includes/litespeed-cache-purge.class.php',
|
19 |
'LiteSpeed' => 'lib/litespeed/litespeed.class.php',
|
20 |
'Litespeed_Crawler' => 'lib/litespeed/litespeed-crawler.class.php',
|
21 |
'Litespeed_File' => 'lib/litespeed/litespeed-file.class.php',
|
22 |
+
'Litespeed_String' => 'lib/litespeed/litespeed-string.class.php',
|
23 |
|
24 |
'LiteSpeed_Cache' => 'includes/litespeed-cache.class.php',
|
25 |
'LiteSpeed_Cache_Activation' => 'includes/litespeed-cache-activation.class.php',
|
29 |
'LiteSpeed_Cache_Control' => 'includes/litespeed-cache-control.class.php',
|
30 |
'LiteSpeed_Cache_Crawler' => 'includes/litespeed-cache-crawler.class.php',
|
31 |
'LiteSpeed_Cache_Crawler_Sitemap' => 'includes/litespeed-cache-crawler-sitemap.class.php',
|
32 |
+
'LiteSpeed_Cache_Data' => 'inc/data.class.php',
|
33 |
'LiteSpeed_Cache_ESI' => 'includes/litespeed-cache-esi.class.php',
|
34 |
+
'LiteSpeed_Cache_GUI' => 'includes/litespeed-cache-gui.class.php',
|
35 |
'LiteSpeed_Cache_Log' => 'includes/litespeed-cache-log.class.php',
|
36 |
'LiteSpeed_Cache_Optimize' => 'includes/litespeed-cache-optimize.class.php',
|
37 |
'LiteSpeed_Cache_Purge' => 'includes/litespeed-cache-purge.class.php',
|
js/css_async.js
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
|
2 |
+
!function(a){"use strict";var b=function(b,c,d){function e(a){return h.body?a():void setTimeout(function(){e(a)})}function f(){i.addEventListener&&i.removeEventListener("load",f),i.media=d||"all"}var g,h=a.document,i=h.createElement("link");if(c)g=c;else{var j=(h.body||h.getElementsByTagName("head")[0]).childNodes;g=j[j.length-1]}var k=h.styleSheets;i.rel="stylesheet",i.href=b,i.media="only x",e(function(){g.parentNode.insertBefore(i,c?g:g.nextSibling)});var l=function(a){for(var b=i.href,c=k.length;c--;)if(k[c].href===b)return a();setTimeout(function(){l(a)})};return i.addEventListener&&i.addEventListener("load",f),i.onloadcssdefined=l,l(f),i};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
|
3 |
+
/*! loadCSS rel=preload polyfill. [c]2017 Filament Group, Inc. MIT License */
|
4 |
+
!function(a){if(a.loadCSS){var b=loadCSS.relpreload={};if(b.support=function(){try{return a.document.createElement("link").relList.supports("preload")}catch(b){return!1}},b.poly=function(){for(var b=a.document.getElementsByTagName("link"),c=0;c<b.length;c++){var d=b[c];"preload"===d.rel&&"style"===d.getAttribute("as")&&(a.loadCSS(d.href,d,d.getAttribute("media")),d.rel=null)}},!b.support()){b.poly();var c=a.setInterval(b.poly,300);a.addEventListener&&a.addEventListener("load",function(){b.poly(),a.clearInterval(c)}),a.attachEvent&&a.attachEvent("onload",function(){a.clearInterval(c)})}}}(this);
|
{admin/js → js}/litespeed-cache-admin.js
RENAMED
@@ -175,6 +175,11 @@ var _litespeed_dots ;
|
|
175 |
if( litespeed_keycode( thiskey.charCodeAt( 0 ) ) ) $( that )[ 0 ].click() ;
|
176 |
});
|
177 |
});
|
|
|
|
|
|
|
|
|
|
|
178 |
}) ;
|
179 |
})(jQuery) ;
|
180 |
|
175 |
if( litespeed_keycode( thiskey.charCodeAt( 0 ) ) ) $( that )[ 0 ].click() ;
|
176 |
});
|
177 |
});
|
178 |
+
|
179 |
+
/** Lets copy one more submit button **/
|
180 |
+
if ( $( '#litespeed_form_options' ).length > 0 ) {
|
181 |
+
$( '#litespeed_form_options [type="submit"]' ).clone().addClass( 'litespeed-float-submit' ).prependTo( '#litespeed_form_options' ) ;
|
182 |
+
}
|
183 |
}) ;
|
184 |
})(jQuery) ;
|
185 |
|
languages/litespeed-cache.pot
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
# This file is distributed under the same license as the LiteSpeed Cache package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
-
"Project-Id-Version: LiteSpeed Cache 1.
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
|
7 |
-
"POT-Creation-Date: 2017-
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
@@ -52,15 +52,15 @@ msgstr ""
|
|
52 |
msgid "LiteSpeed Cache Purge All"
|
53 |
msgstr ""
|
54 |
|
55 |
-
#: admin/litespeed-cache-admin-display.class.php:
|
56 |
msgid "ON"
|
57 |
msgstr ""
|
58 |
|
59 |
-
#: admin/litespeed-cache-admin-display.class.php:
|
60 |
msgid "OFF"
|
61 |
msgstr ""
|
62 |
|
63 |
-
#: admin/litespeed-cache-admin-display.class.php:
|
64 |
msgid "Recommended value: %s"
|
65 |
msgstr ""
|
66 |
|
@@ -320,80 +320,80 @@ msgstr ""
|
|
320 |
msgid "Optimized all tables."
|
321 |
msgstr ""
|
322 |
|
323 |
-
#: admin/litespeed-cache-admin-rules.class.php:
|
324 |
msgid ""
|
325 |
"<p>Please add/replace the following codes into the beginning of %1$s:</p> "
|
326 |
"%2$s"
|
327 |
msgstr ""
|
328 |
|
329 |
-
#: admin/litespeed-cache-admin-rules.class.php:
|
330 |
msgid "File Saved."
|
331 |
msgstr ""
|
332 |
|
333 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
334 |
msgid "Default Public Cache"
|
335 |
msgstr ""
|
336 |
|
337 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
338 |
msgid "Default Private Cache"
|
339 |
msgstr ""
|
340 |
|
341 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
342 |
msgid "Default Front Page"
|
343 |
msgstr ""
|
344 |
|
345 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
346 |
msgid "Feed"
|
347 |
msgstr ""
|
348 |
|
349 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
350 |
msgid "404"
|
351 |
msgstr ""
|
352 |
|
353 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
354 |
msgid "403"
|
355 |
msgstr ""
|
356 |
|
357 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
358 |
msgid "500"
|
359 |
msgstr ""
|
360 |
|
361 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
362 |
#: admin/tpl/settings_debug.php:75
|
363 |
msgid "Log File Size Limit"
|
364 |
msgstr ""
|
365 |
|
366 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
367 |
#: admin/tpl/settings_crawler.php:10
|
368 |
msgid "Delay"
|
369 |
msgstr ""
|
370 |
|
371 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
372 |
#: admin/tpl/settings_crawler.php:22
|
373 |
msgid "Run Duration"
|
374 |
msgstr ""
|
375 |
|
376 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
377 |
msgid "Cron Interval"
|
378 |
msgstr ""
|
379 |
|
380 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
381 |
msgid "Whole Interval"
|
382 |
msgstr ""
|
383 |
|
384 |
-
#: admin/litespeed-cache-admin-settings.class.php:
|
385 |
#: admin/tpl/settings_crawler.php:58
|
386 |
msgid "Threads"
|
387 |
msgstr ""
|
388 |
|
389 |
-
#: admin/litespeed-cache-admin-settings.class.php:806
|
390 |
-
msgid "'Use primary site settings' set by Network Administrator."
|
391 |
-
msgstr ""
|
392 |
-
|
393 |
-
#: admin/litespeed-cache-admin-settings.class.php:940
|
394 |
-
msgid "File saved."
|
395 |
-
msgstr ""
|
396 |
-
|
397 |
#: admin/litespeed-cache-admin.class.php:203
|
398 |
msgid ""
|
399 |
"For this scenario only, the network admin may uncheck \"Check Advanced Cache"
|
@@ -471,7 +471,7 @@ msgstr ""
|
|
471 |
msgid "Crawler Cron"
|
472 |
msgstr ""
|
473 |
|
474 |
-
#: admin/tpl/crawler.php:63 admin/tpl/settings.php:
|
475 |
msgid "WARNING"
|
476 |
msgstr ""
|
477 |
|
@@ -779,10 +779,14 @@ msgid ""
|
|
779 |
"To trigger the action for a page, access the page with the query string %s"
|
780 |
msgstr ""
|
781 |
|
782 |
-
#: admin/tpl/info_common_rewrite.php:8 admin/tpl/settings_excludes.php:
|
783 |
-
#: admin/tpl/settings_excludes.php:
|
784 |
-
#: admin/tpl/settings_inc.
|
785 |
-
#: admin/tpl/settings_inc.
|
|
|
|
|
|
|
|
|
786 |
msgid "NOTE:"
|
787 |
msgstr ""
|
788 |
|
@@ -795,7 +799,6 @@ msgid "Please contact the network admin to make any changes."
|
|
795 |
msgstr ""
|
796 |
|
797 |
#: admin/tpl/info_common_rewrite.php:14 admin/tpl/settings_advanced.php:6
|
798 |
-
#: admin/tpl/settings_inc.cache_mobile.php:64
|
799 |
#: admin/tpl/settings_optimize.php:10
|
800 |
msgid "NOTICE:"
|
801 |
msgstr ""
|
@@ -1696,29 +1699,29 @@ msgstr ""
|
|
1696 |
msgid "Compatibilities"
|
1697 |
msgstr ""
|
1698 |
|
1699 |
-
#: admin/tpl/settings.php:
|
1700 |
msgid "WARNING: Third party tab input invalid."
|
1701 |
msgstr ""
|
1702 |
|
1703 |
-
#: admin/tpl/settings.php:
|
1704 |
msgid "WARNING: Third party config slug contains invalid characters."
|
1705 |
msgstr ""
|
1706 |
|
1707 |
-
#: admin/tpl/settings.php:
|
1708 |
msgid "LiteSpeed Cache Settings"
|
1709 |
msgstr ""
|
1710 |
|
1711 |
-
#: admin/tpl/settings.php:
|
1712 |
msgid "The network admin selected use primary site configs for all subsites."
|
1713 |
msgstr ""
|
1714 |
|
1715 |
-
#: admin/tpl/settings.php:
|
1716 |
msgid ""
|
1717 |
"The following options are selected, but are not editable in this settings "
|
1718 |
"page."
|
1719 |
msgstr ""
|
1720 |
|
1721 |
-
#: admin/tpl/settings.php:
|
1722 |
msgid "Save Changes"
|
1723 |
msgstr ""
|
1724 |
|
@@ -1871,6 +1874,29 @@ msgstr ""
|
|
1871 |
msgid "Disabling this option may negatively affect performance."
|
1872 |
msgstr ""
|
1873 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1874 |
#: admin/tpl/settings_cdn.php:11
|
1875 |
msgid "CDN Settings"
|
1876 |
msgstr ""
|
@@ -1884,20 +1910,20 @@ msgid "Enable Content Delivery Network use."
|
|
1884 |
msgstr ""
|
1885 |
|
1886 |
#: admin/tpl/settings_cdn.php:25
|
1887 |
-
msgid "
|
1888 |
msgstr ""
|
1889 |
|
1890 |
#: admin/tpl/settings_cdn.php:29
|
1891 |
-
msgid ""
|
1892 |
-
"Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s"
|
1893 |
msgstr ""
|
1894 |
|
1895 |
#: admin/tpl/settings_cdn.php:35
|
1896 |
-
msgid "
|
1897 |
msgstr ""
|
1898 |
|
1899 |
#: admin/tpl/settings_cdn.php:39
|
1900 |
-
msgid "
|
|
|
1901 |
msgstr ""
|
1902 |
|
1903 |
#: admin/tpl/settings_cdn.php:45
|
@@ -2161,8 +2187,7 @@ msgid ""
|
|
2161 |
msgstr ""
|
2162 |
|
2163 |
#: admin/tpl/settings_debug.php:35
|
2164 |
-
msgid ""
|
2165 |
-
"The logs will be outputted to the debug.log in the wp-content directory."
|
2166 |
msgstr ""
|
2167 |
|
2168 |
#: admin/tpl/settings_debug.php:41
|
@@ -2318,95 +2343,68 @@ msgid ""
|
|
2318 |
"etc), while all other user roles see the default public page."
|
2319 |
msgstr ""
|
2320 |
|
2321 |
-
#: admin/tpl/settings_excludes.php:
|
2322 |
-
msgid "
|
2323 |
-
msgstr ""
|
2324 |
-
|
2325 |
-
#: admin/tpl/settings_excludes.php:9
|
2326 |
-
msgid "Enter a list of urls that should not be cached."
|
2327 |
-
msgstr ""
|
2328 |
-
|
2329 |
-
#: admin/tpl/settings_excludes.php:10
|
2330 |
-
msgid "The urls will be compared to the REQUEST_URI server variable."
|
2331 |
-
msgstr ""
|
2332 |
-
|
2333 |
-
#: admin/tpl/settings_excludes.php:11
|
2334 |
-
msgid "There should only be one url per line."
|
2335 |
-
msgstr ""
|
2336 |
-
|
2337 |
-
#: admin/tpl/settings_excludes.php:16
|
2338 |
-
msgid "URLs must start with a '/' to be correctly matched."
|
2339 |
-
msgstr ""
|
2340 |
-
|
2341 |
-
#: admin/tpl/settings_excludes.php:17
|
2342 |
-
msgid "To do an exact match, add '$' to the end of the URL."
|
2343 |
-
msgstr ""
|
2344 |
-
|
2345 |
-
#: admin/tpl/settings_excludes.php:18
|
2346 |
-
msgid "Any surrounding whitespaces will be trimmed."
|
2347 |
msgstr ""
|
2348 |
|
2349 |
-
#: admin/tpl/settings_excludes.php:
|
2350 |
-
|
2351 |
-
msgid "e.g. to exclude %1$s, insert %2$s"
|
2352 |
msgstr ""
|
2353 |
|
2354 |
-
#: admin/tpl/settings_excludes.php:
|
2355 |
-
msgid "
|
2356 |
msgstr ""
|
2357 |
|
2358 |
-
#: admin/tpl/settings_excludes.php:
|
2359 |
-
msgid "
|
2360 |
msgstr ""
|
2361 |
|
2362 |
#: admin/tpl/settings_excludes.php:28
|
2363 |
-
msgid "
|
2364 |
msgstr ""
|
2365 |
|
2366 |
-
#: admin/tpl/settings_excludes.php:
|
2367 |
-
msgid "
|
2368 |
msgstr ""
|
2369 |
|
2370 |
-
#: admin/tpl/settings_excludes.php:
|
2371 |
msgid "All categories are cached by default."
|
2372 |
msgstr ""
|
2373 |
|
2374 |
-
#: admin/tpl/settings_excludes.php:
|
2375 |
-
|
2376 |
-
|
2377 |
-
"
|
|
|
|
|
|
|
|
|
2378 |
msgstr ""
|
2379 |
|
2380 |
-
#: admin/tpl/settings_excludes.php:
|
2381 |
msgid "If the Category ID is not found, the name will be removed on save."
|
2382 |
msgstr ""
|
2383 |
|
2384 |
-
#: admin/tpl/settings_excludes.php:
|
2385 |
-
msgid "
|
2386 |
msgstr ""
|
2387 |
|
2388 |
-
#: admin/tpl/settings_excludes.php:
|
2389 |
-
msgid "
|
2390 |
msgstr ""
|
2391 |
|
2392 |
-
#: admin/tpl/settings_excludes.php:
|
2393 |
msgid "All tags are cached by default."
|
2394 |
msgstr ""
|
2395 |
|
2396 |
-
#: admin/tpl/settings_excludes.php:
|
2397 |
-
msgid ""
|
2398 |
-
"To prevent tags from being cached, enter the tag in the text area below, one "
|
2399 |
-
"per line."
|
2400 |
msgstr ""
|
2401 |
|
2402 |
-
#: admin/tpl/settings_excludes.php:
|
2403 |
msgid "If the Tag ID is not found, the name will be removed on save."
|
2404 |
msgstr ""
|
2405 |
|
2406 |
-
#: admin/tpl/settings_excludes.php:79
|
2407 |
-
msgid "SYNTAX: One tag id per line."
|
2408 |
-
msgstr ""
|
2409 |
-
|
2410 |
#: admin/tpl/settings_general.php:9
|
2411 |
msgid "Enable LiteSpeed Cache"
|
2412 |
msgstr ""
|
@@ -2509,6 +2507,31 @@ msgstr ""
|
|
2509 |
msgid "If this is set to a number less than 30, 500 pages will not be cached."
|
2510 |
msgstr ""
|
2511 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2512 |
#: admin/tpl/settings_inc.cache_favicon.php:7
|
2513 |
msgid "Cache favicon.ico"
|
2514 |
msgstr ""
|
@@ -2535,37 +2558,31 @@ msgstr ""
|
|
2535 |
msgid "A site built with responsive design does not need to check this."
|
2536 |
msgstr ""
|
2537 |
|
2538 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2539 |
msgid "List of Mobile User Agents"
|
2540 |
msgstr ""
|
2541 |
|
2542 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2543 |
msgid "Htaccess did not match configuration option."
|
2544 |
msgstr ""
|
2545 |
|
2546 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2547 |
msgid "Please re-enter the mobile view setting."
|
2548 |
msgstr ""
|
2549 |
|
2550 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2551 |
msgid "List in WordPress database is: %s"
|
2552 |
msgstr ""
|
2553 |
|
2554 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2555 |
-
|
2556 |
-
#: admin/tpl/settings_inc.exclude_useragent.php:12
|
2557 |
-
msgid "This setting will edit the .htaccess file."
|
2558 |
-
msgstr ""
|
2559 |
-
|
2560 |
-
#: admin/tpl/settings_inc.cache_mobile.php:69
|
2561 |
-
msgid "SYNTAX: Each entry should be separated with a bar, %s"
|
2562 |
msgstr ""
|
2563 |
|
2564 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2565 |
-
msgid "Any spaces should be escaped with a backslash before the space, %s"
|
2566 |
msgstr ""
|
2567 |
|
2568 |
-
#: admin/tpl/settings_inc.cache_mobile.php:
|
2569 |
msgid "The default list WordPress uses is %s"
|
2570 |
msgstr ""
|
2571 |
|
@@ -2583,43 +2600,33 @@ msgid ""
|
|
2583 |
"PHP calls."
|
2584 |
msgstr ""
|
2585 |
|
2586 |
-
#: admin/tpl/settings_inc.exclude_cookies.php:
|
2587 |
-
msgid "
|
2588 |
-
msgstr ""
|
2589 |
-
|
2590 |
-
#: admin/tpl/settings_inc.exclude_cookies.php:3
|
2591 |
-
msgid "To prevent cookies from being cached, enter it in the text area below."
|
2592 |
msgstr ""
|
2593 |
|
2594 |
-
#: admin/tpl/settings_inc.exclude_cookies.php:
|
2595 |
-
msgid "
|
2596 |
msgstr ""
|
2597 |
|
2598 |
-
#: admin/tpl/settings_inc.exclude_cookies.php:
|
2599 |
-
|
|
|
2600 |
msgstr ""
|
2601 |
|
2602 |
#: admin/tpl/settings_inc.exclude_useragent.php:7
|
2603 |
-
msgid "User
|
2604 |
msgstr ""
|
2605 |
|
2606 |
-
#: admin/tpl/settings_inc.exclude_useragent.php:
|
2607 |
-
msgid ""
|
2608 |
-
"To prevent user agents from being cached, enter it in the text field below."
|
2609 |
msgstr ""
|
2610 |
|
2611 |
#: admin/tpl/settings_inc.exclude_useragent.php:17
|
2612 |
-
msgid ""
|
2613 |
-
"SYNTAX: Separate each user agent with a bar, <font style=\"font-style:normal"
|
2614 |
-
"\">%s</font>."
|
2615 |
-
msgstr ""
|
2616 |
-
|
2617 |
-
#: admin/tpl/settings_inc.exclude_useragent.php:18
|
2618 |
-
msgid "Spaces should have a backslash in front of them, %s."
|
2619 |
msgstr ""
|
2620 |
|
2621 |
#: admin/tpl/settings_inc.purge_on_upgrade.php:7
|
2622 |
-
msgid "Purge All
|
2623 |
msgstr ""
|
2624 |
|
2625 |
#: admin/tpl/settings_inc.purge_on_upgrade.php:11
|
@@ -2728,6 +2735,63 @@ msgstr ""
|
|
2728 |
msgid "Minify HTML content."
|
2729 |
msgstr ""
|
2730 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2731 |
#: admin/tpl/settings_purge.php:5
|
2732 |
msgid "Purge Settings"
|
2733 |
msgstr ""
|
@@ -2920,11 +2984,11 @@ msgstr ""
|
|
2920 |
msgid "Purged the blog!"
|
2921 |
msgstr ""
|
2922 |
|
2923 |
-
#: cli/litespeed-cache-cli-purge.class.php:
|
2924 |
msgid "Purged the url!"
|
2925 |
msgstr ""
|
2926 |
|
2927 |
-
#: cli/litespeed-cache-cli-purge.class.php:
|
2928 |
msgid "Purged the tags!"
|
2929 |
msgstr ""
|
2930 |
|
@@ -2953,6 +3017,26 @@ msgstr ""
|
|
2953 |
msgid "Reached end of sitemap file. Crawling completed."
|
2954 |
msgstr ""
|
2955 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2956 |
#: includes/litespeed-cache-purge.class.php:202
|
2957 |
msgid "Purge category %s"
|
2958 |
msgstr ""
|
@@ -2969,39 +3053,39 @@ msgstr ""
|
|
2969 |
msgid "Purge url %s"
|
2970 |
msgstr ""
|
2971 |
|
2972 |
-
#: includes/litespeed-cache-task.class.php:
|
2973 |
msgid "LiteSpeed Cache Custom Cron"
|
2974 |
msgstr ""
|
2975 |
|
2976 |
-
#: includes/litespeed-cache.class.php:
|
2977 |
msgid "Crawler blacklist is saved."
|
2978 |
msgstr ""
|
2979 |
|
2980 |
-
#: includes/litespeed-cache.class.php:
|
2981 |
msgid "Notified LiteSpeed Web Server to purge the front page."
|
2982 |
msgstr ""
|
2983 |
|
2984 |
-
#: includes/litespeed-cache.class.php:
|
2985 |
msgid "Notified LiteSpeed Web Server to purge pages."
|
2986 |
msgstr ""
|
2987 |
|
2988 |
-
#: includes/litespeed-cache.class.php:
|
2989 |
msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
|
2990 |
msgstr ""
|
2991 |
|
2992 |
-
#: includes/litespeed-cache.class.php:
|
2993 |
msgid "Notified LiteSpeed Web Server to purge error pages."
|
2994 |
msgstr ""
|
2995 |
|
2996 |
-
#: includes/litespeed-cache.class.php:
|
2997 |
msgid "Notified LiteSpeed Web Server to purge all caches."
|
2998 |
msgstr ""
|
2999 |
|
3000 |
-
#: includes/litespeed-cache.class.php:
|
3001 |
msgid "Notified LiteSpeed Web Server to purge everything."
|
3002 |
msgstr ""
|
3003 |
|
3004 |
-
#: includes/litespeed-cache.class.php:
|
3005 |
msgid "Notified LiteSpeed Web Server to purge the list."
|
3006 |
msgstr ""
|
3007 |
|
2 |
# This file is distributed under the same license as the LiteSpeed Cache package.
|
3 |
msgid ""
|
4 |
msgstr ""
|
5 |
+
"Project-Id-Version: LiteSpeed Cache 1.3.1\n"
|
6 |
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
|
7 |
+
"POT-Creation-Date: 2017-10-05 19:11:47+00:00\n"
|
8 |
"MIME-Version: 1.0\n"
|
9 |
"Content-Type: text/plain; charset=UTF-8\n"
|
10 |
"Content-Transfer-Encoding: 8bit\n"
|
52 |
msgid "LiteSpeed Cache Purge All"
|
53 |
msgstr ""
|
54 |
|
55 |
+
#: admin/litespeed-cache-admin-display.class.php:770
|
56 |
msgid "ON"
|
57 |
msgstr ""
|
58 |
|
59 |
+
#: admin/litespeed-cache-admin-display.class.php:774
|
60 |
msgid "OFF"
|
61 |
msgstr ""
|
62 |
|
63 |
+
#: admin/litespeed-cache-admin-display.class.php:807
|
64 |
msgid "Recommended value: %s"
|
65 |
msgstr ""
|
66 |
|
320 |
msgid "Optimized all tables."
|
321 |
msgstr ""
|
322 |
|
323 |
+
#: admin/litespeed-cache-admin-rules.class.php:629
|
324 |
msgid ""
|
325 |
"<p>Please add/replace the following codes into the beginning of %1$s:</p> "
|
326 |
"%2$s"
|
327 |
msgstr ""
|
328 |
|
329 |
+
#: admin/litespeed-cache-admin-rules.class.php:827
|
330 |
msgid "File Saved."
|
331 |
msgstr ""
|
332 |
|
333 |
+
#: admin/litespeed-cache-admin-settings.class.php:50
|
334 |
+
msgid "'Use primary site settings' set by Network Administrator."
|
335 |
+
msgstr ""
|
336 |
+
|
337 |
+
#: admin/litespeed-cache-admin-settings.class.php:217
|
338 |
+
msgid "Site options saved."
|
339 |
+
msgstr ""
|
340 |
+
|
341 |
+
#: admin/litespeed-cache-admin-settings.class.php:256
|
342 |
msgid "Default Public Cache"
|
343 |
msgstr ""
|
344 |
|
345 |
+
#: admin/litespeed-cache-admin-settings.class.php:257
|
346 |
msgid "Default Private Cache"
|
347 |
msgstr ""
|
348 |
|
349 |
+
#: admin/litespeed-cache-admin-settings.class.php:258
|
350 |
msgid "Default Front Page"
|
351 |
msgstr ""
|
352 |
|
353 |
+
#: admin/litespeed-cache-admin-settings.class.php:259
|
354 |
msgid "Feed"
|
355 |
msgstr ""
|
356 |
|
357 |
+
#: admin/litespeed-cache-admin-settings.class.php:260
|
358 |
msgid "404"
|
359 |
msgstr ""
|
360 |
|
361 |
+
#: admin/litespeed-cache-admin-settings.class.php:261
|
362 |
msgid "403"
|
363 |
msgstr ""
|
364 |
|
365 |
+
#: admin/litespeed-cache-admin-settings.class.php:262
|
366 |
msgid "500"
|
367 |
msgstr ""
|
368 |
|
369 |
+
#: admin/litespeed-cache-admin-settings.class.php:543
|
370 |
#: admin/tpl/settings_debug.php:75
|
371 |
msgid "Log File Size Limit"
|
372 |
msgstr ""
|
373 |
|
374 |
+
#: admin/litespeed-cache-admin-settings.class.php:609
|
375 |
#: admin/tpl/settings_crawler.php:10
|
376 |
msgid "Delay"
|
377 |
msgstr ""
|
378 |
|
379 |
+
#: admin/litespeed-cache-admin-settings.class.php:610
|
380 |
#: admin/tpl/settings_crawler.php:22
|
381 |
msgid "Run Duration"
|
382 |
msgstr ""
|
383 |
|
384 |
+
#: admin/litespeed-cache-admin-settings.class.php:611
|
385 |
msgid "Cron Interval"
|
386 |
msgstr ""
|
387 |
|
388 |
+
#: admin/litespeed-cache-admin-settings.class.php:612
|
389 |
msgid "Whole Interval"
|
390 |
msgstr ""
|
391 |
|
392 |
+
#: admin/litespeed-cache-admin-settings.class.php:613
|
393 |
#: admin/tpl/settings_crawler.php:58
|
394 |
msgid "Threads"
|
395 |
msgstr ""
|
396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
397 |
#: admin/litespeed-cache-admin.class.php:203
|
398 |
msgid ""
|
399 |
"For this scenario only, the network admin may uncheck \"Check Advanced Cache"
|
471 |
msgid "Crawler Cron"
|
472 |
msgstr ""
|
473 |
|
474 |
+
#: admin/tpl/crawler.php:63 admin/tpl/settings.php:114
|
475 |
msgid "WARNING"
|
476 |
msgstr ""
|
477 |
|
779 |
"To trigger the action for a page, access the page with the query string %s"
|
780 |
msgstr ""
|
781 |
|
782 |
+
#: admin/tpl/info_common_rewrite.php:8 admin/tpl/settings_excludes.php:57
|
783 |
+
#: admin/tpl/settings_excludes.php:95
|
784 |
+
#: admin/tpl/settings_inc.cache_browser.php:12
|
785 |
+
#: admin/tpl/settings_inc.cache_favicon.php:14
|
786 |
+
#: admin/tpl/settings_inc.cache_mobile.php:18
|
787 |
+
#: admin/tpl/settings_inc.cache_resources.php:15
|
788 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:22
|
789 |
+
#: admin/tpl/settings_inc.exclude_useragent.php:21
|
790 |
msgid "NOTE:"
|
791 |
msgstr ""
|
792 |
|
799 |
msgstr ""
|
800 |
|
801 |
#: admin/tpl/info_common_rewrite.php:14 admin/tpl/settings_advanced.php:6
|
|
|
802 |
#: admin/tpl/settings_optimize.php:10
|
803 |
msgid "NOTICE:"
|
804 |
msgstr ""
|
1699 |
msgid "Compatibilities"
|
1700 |
msgstr ""
|
1701 |
|
1702 |
+
#: admin/tpl/settings.php:64
|
1703 |
msgid "WARNING: Third party tab input invalid."
|
1704 |
msgstr ""
|
1705 |
|
1706 |
+
#: admin/tpl/settings.php:71
|
1707 |
msgid "WARNING: Third party config slug contains invalid characters."
|
1708 |
msgstr ""
|
1709 |
|
1710 |
+
#: admin/tpl/settings.php:86
|
1711 |
msgid "LiteSpeed Cache Settings"
|
1712 |
msgstr ""
|
1713 |
|
1714 |
+
#: admin/tpl/settings.php:116
|
1715 |
msgid "The network admin selected use primary site configs for all subsites."
|
1716 |
msgstr ""
|
1717 |
|
1718 |
+
#: admin/tpl/settings.php:117
|
1719 |
msgid ""
|
1720 |
"The following options are selected, but are not editable in this settings "
|
1721 |
"page."
|
1722 |
msgstr ""
|
1723 |
|
1724 |
+
#: admin/tpl/settings.php:139 admin/tpl/settings.php:142
|
1725 |
msgid "Save Changes"
|
1726 |
msgstr ""
|
1727 |
|
1874 |
msgid "Disabling this option may negatively affect performance."
|
1875 |
msgstr ""
|
1876 |
|
1877 |
+
#: admin/tpl/settings_cache.php:56
|
1878 |
+
msgid "Private Cached URIs"
|
1879 |
+
msgstr ""
|
1880 |
+
|
1881 |
+
#: admin/tpl/settings_cache.php:60
|
1882 |
+
msgid "URI Paths containing these strings will NOT be cached as public."
|
1883 |
+
msgstr ""
|
1884 |
+
|
1885 |
+
#: admin/tpl/settings_cache.php:61 admin/tpl/settings_excludes.php:13
|
1886 |
+
msgid "The URLs will be compared to the REQUEST_URI server variable."
|
1887 |
+
msgstr ""
|
1888 |
+
|
1889 |
+
#: admin/tpl/settings_cache.php:64 admin/tpl/settings_excludes.php:16
|
1890 |
+
msgid "To do an exact match, add %s to the end of the URL."
|
1891 |
+
msgstr ""
|
1892 |
+
|
1893 |
+
#: admin/tpl/settings_cache.php:65 admin/tpl/settings_excludes.php:17
|
1894 |
+
#: admin/tpl/settings_excludes.php:30 admin/tpl/settings_excludes.php:53
|
1895 |
+
#: admin/tpl/settings_excludes.php:91
|
1896 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:19
|
1897 |
+
msgid "One per line."
|
1898 |
+
msgstr ""
|
1899 |
+
|
1900 |
#: admin/tpl/settings_cdn.php:11
|
1901 |
msgid "CDN Settings"
|
1902 |
msgstr ""
|
1910 |
msgstr ""
|
1911 |
|
1912 |
#: admin/tpl/settings_cdn.php:25
|
1913 |
+
msgid "CDN URL"
|
1914 |
msgstr ""
|
1915 |
|
1916 |
#: admin/tpl/settings_cdn.php:29
|
1917 |
+
msgid "CDN URL to be used. For example, %s"
|
|
|
1918 |
msgstr ""
|
1919 |
|
1920 |
#: admin/tpl/settings_cdn.php:35
|
1921 |
+
msgid "Original URL"
|
1922 |
msgstr ""
|
1923 |
|
1924 |
#: admin/tpl/settings_cdn.php:39
|
1925 |
+
msgid ""
|
1926 |
+
"Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s"
|
1927 |
msgstr ""
|
1928 |
|
1929 |
#: admin/tpl/settings_cdn.php:45
|
2187 |
msgstr ""
|
2188 |
|
2189 |
#: admin/tpl/settings_debug.php:35
|
2190 |
+
msgid "The logs will be outputted to %s."
|
|
|
2191 |
msgstr ""
|
2192 |
|
2193 |
#: admin/tpl/settings_debug.php:41
|
2343 |
"etc), while all other user roles see the default public page."
|
2344 |
msgstr ""
|
2345 |
|
2346 |
+
#: admin/tpl/settings_excludes.php:4
|
2347 |
+
msgid "Do Not Cache Settings"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2348 |
msgstr ""
|
2349 |
|
2350 |
+
#: admin/tpl/settings_excludes.php:8
|
2351 |
+
msgid "Do Not Cache URIs"
|
|
|
2352 |
msgstr ""
|
2353 |
|
2354 |
+
#: admin/tpl/settings_excludes.php:12
|
2355 |
+
msgid "Paths containing these strings will not be cached."
|
2356 |
msgstr ""
|
2357 |
|
2358 |
+
#: admin/tpl/settings_excludes.php:24
|
2359 |
+
msgid "Do Not Cache Query Strings"
|
2360 |
msgstr ""
|
2361 |
|
2362 |
#: admin/tpl/settings_excludes.php:28
|
2363 |
+
msgid "Query string containing these parameters will not be cached."
|
2364 |
msgstr ""
|
2365 |
|
2366 |
+
#: admin/tpl/settings_excludes.php:37
|
2367 |
+
msgid "Do Not Cache Categories"
|
2368 |
msgstr ""
|
2369 |
|
2370 |
+
#: admin/tpl/settings_excludes.php:50
|
2371 |
msgid "All categories are cached by default."
|
2372 |
msgstr ""
|
2373 |
|
2374 |
+
#: admin/tpl/settings_excludes.php:51 admin/tpl/settings_excludes.php:89
|
2375 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:16
|
2376 |
+
#: admin/tpl/settings_inc.exclude_useragent.php:15
|
2377 |
+
msgid "To prevent %s from being cached, enter it here."
|
2378 |
+
msgstr ""
|
2379 |
+
|
2380 |
+
#: admin/tpl/settings_excludes.php:51
|
2381 |
+
msgid "categories"
|
2382 |
msgstr ""
|
2383 |
|
2384 |
+
#: admin/tpl/settings_excludes.php:59
|
2385 |
msgid "If the Category ID is not found, the name will be removed on save."
|
2386 |
msgstr ""
|
2387 |
|
2388 |
+
#: admin/tpl/settings_excludes.php:60 admin/tpl/settings_excludes.php:98
|
2389 |
+
msgid "To exclude %1$s, insert %2$s."
|
2390 |
msgstr ""
|
2391 |
|
2392 |
+
#: admin/tpl/settings_excludes.php:68
|
2393 |
+
msgid "Do Not Cache Tags"
|
2394 |
msgstr ""
|
2395 |
|
2396 |
+
#: admin/tpl/settings_excludes.php:88
|
2397 |
msgid "All tags are cached by default."
|
2398 |
msgstr ""
|
2399 |
|
2400 |
+
#: admin/tpl/settings_excludes.php:89
|
2401 |
+
msgid "tags"
|
|
|
|
|
2402 |
msgstr ""
|
2403 |
|
2404 |
+
#: admin/tpl/settings_excludes.php:97
|
2405 |
msgid "If the Tag ID is not found, the name will be removed on save."
|
2406 |
msgstr ""
|
2407 |
|
|
|
|
|
|
|
|
|
2408 |
#: admin/tpl/settings_general.php:9
|
2409 |
msgid "Enable LiteSpeed Cache"
|
2410 |
msgstr ""
|
2507 |
msgid "If this is set to a number less than 30, 500 pages will not be cached."
|
2508 |
msgstr ""
|
2509 |
|
2510 |
+
#: admin/tpl/settings_inc.cache_browser.php:6
|
2511 |
+
msgid "Browser Cache"
|
2512 |
+
msgstr ""
|
2513 |
+
|
2514 |
+
#: admin/tpl/settings_inc.cache_browser.php:10
|
2515 |
+
msgid ""
|
2516 |
+
"Browser caching stores static files locally in the user's browser. Turn on "
|
2517 |
+
"this setting to reduce repeated requests for static files."
|
2518 |
+
msgstr ""
|
2519 |
+
|
2520 |
+
#: admin/tpl/settings_inc.cache_browser.php:13
|
2521 |
+
#: admin/tpl/settings_inc.cache_favicon.php:15
|
2522 |
+
#: admin/tpl/settings_inc.cache_mobile.php:19
|
2523 |
+
#: admin/tpl/settings_inc.cache_resources.php:16
|
2524 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:23
|
2525 |
+
#: admin/tpl/settings_inc.exclude_useragent.php:22
|
2526 |
+
msgid "This setting will edit the .htaccess file."
|
2527 |
+
msgstr ""
|
2528 |
+
|
2529 |
+
#: admin/tpl/settings_inc.cache_browser.php:15
|
2530 |
+
msgid ""
|
2531 |
+
"You can turn on browser caching in server admin too. <a %s>Learn more about "
|
2532 |
+
"LiteSpeed browser cache setting</a>."
|
2533 |
+
msgstr ""
|
2534 |
+
|
2535 |
#: admin/tpl/settings_inc.cache_favicon.php:7
|
2536 |
msgid "Cache favicon.ico"
|
2537 |
msgstr ""
|
2558 |
msgid "A site built with responsive design does not need to check this."
|
2559 |
msgstr ""
|
2560 |
|
2561 |
+
#: admin/tpl/settings_inc.cache_mobile.php:26
|
2562 |
msgid "List of Mobile User Agents"
|
2563 |
msgstr ""
|
2564 |
|
2565 |
+
#: admin/tpl/settings_inc.cache_mobile.php:43
|
2566 |
msgid "Htaccess did not match configuration option."
|
2567 |
msgstr ""
|
2568 |
|
2569 |
+
#: admin/tpl/settings_inc.cache_mobile.php:44
|
2570 |
msgid "Please re-enter the mobile view setting."
|
2571 |
msgstr ""
|
2572 |
|
2573 |
+
#: admin/tpl/settings_inc.cache_mobile.php:45
|
2574 |
msgid "List in WordPress database is: %s"
|
2575 |
msgstr ""
|
2576 |
|
2577 |
+
#: admin/tpl/settings_inc.cache_mobile.php:61
|
2578 |
+
msgid "SYNTAX: Each entry should be separated with a bar, %s."
|
|
|
|
|
|
|
|
|
|
|
|
|
2579 |
msgstr ""
|
2580 |
|
2581 |
+
#: admin/tpl/settings_inc.cache_mobile.php:62
|
2582 |
+
msgid "Any spaces should be escaped with a backslash before the space, %s."
|
2583 |
msgstr ""
|
2584 |
|
2585 |
+
#: admin/tpl/settings_inc.cache_mobile.php:65
|
2586 |
msgid "The default list WordPress uses is %s"
|
2587 |
msgstr ""
|
2588 |
|
2600 |
"PHP calls."
|
2601 |
msgstr ""
|
2602 |
|
2603 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:6
|
2604 |
+
msgid "Do Not Cache Cookies"
|
|
|
|
|
|
|
|
|
2605 |
msgstr ""
|
2606 |
|
2607 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:16
|
2608 |
+
msgid "cookies"
|
2609 |
msgstr ""
|
2610 |
|
2611 |
+
#: admin/tpl/settings_inc.exclude_cookies.php:18
|
2612 |
+
#: admin/tpl/settings_inc.exclude_useragent.php:18
|
2613 |
+
msgid "Spaces should have a backslash in front of them, %s."
|
2614 |
msgstr ""
|
2615 |
|
2616 |
#: admin/tpl/settings_inc.exclude_useragent.php:7
|
2617 |
+
msgid "Do Not Cache User Agents"
|
2618 |
msgstr ""
|
2619 |
|
2620 |
+
#: admin/tpl/settings_inc.exclude_useragent.php:15
|
2621 |
+
msgid "user agents"
|
|
|
2622 |
msgstr ""
|
2623 |
|
2624 |
#: admin/tpl/settings_inc.exclude_useragent.php:17
|
2625 |
+
msgid "SYNTAX: Separate each user agent with a bar, %s."
|
|
|
|
|
|
|
|
|
|
|
|
|
2626 |
msgstr ""
|
2627 |
|
2628 |
#: admin/tpl/settings_inc.purge_on_upgrade.php:7
|
2629 |
+
msgid "Purge All On Upgrade"
|
2630 |
msgstr ""
|
2631 |
|
2632 |
#: admin/tpl/settings_inc.purge_on_upgrade.php:11
|
2735 |
msgid "Minify HTML content."
|
2736 |
msgstr ""
|
2737 |
|
2738 |
+
#: admin/tpl/settings_optimize.php:119
|
2739 |
+
msgid "Remove Query Strings"
|
2740 |
+
msgstr ""
|
2741 |
+
|
2742 |
+
#: admin/tpl/settings_optimize.php:123
|
2743 |
+
msgid "Remove query strings from static resources."
|
2744 |
+
msgstr ""
|
2745 |
+
|
2746 |
+
#: admin/tpl/settings_optimize.php:124 admin/tpl/settings_optimize.php:145
|
2747 |
+
#: admin/tpl/settings_optimize.php:166 admin/tpl/settings_optimize.php:177
|
2748 |
+
msgid ""
|
2749 |
+
"This can improve your speed score in services like Pingdom, GTmetrix and "
|
2750 |
+
"PageSpeed."
|
2751 |
+
msgstr ""
|
2752 |
+
|
2753 |
+
#: admin/tpl/settings_optimize.php:130
|
2754 |
+
msgid "Remove Google Fonts"
|
2755 |
+
msgstr ""
|
2756 |
+
|
2757 |
+
#: admin/tpl/settings_optimize.php:134
|
2758 |
+
msgid "Prevent google fonts from loading on all your pages."
|
2759 |
+
msgstr ""
|
2760 |
+
|
2761 |
+
#: admin/tpl/settings_optimize.php:140 admin/tpl/settings_optimize.php:155
|
2762 |
+
msgid "Load CSS Asynchronously"
|
2763 |
+
msgstr ""
|
2764 |
+
|
2765 |
+
#: admin/tpl/settings_optimize.php:144
|
2766 |
+
msgid "Optimize CSS delivery. This will load Google Fonts asynchronously too."
|
2767 |
+
msgstr ""
|
2768 |
+
|
2769 |
+
#: admin/tpl/settings_optimize.php:151
|
2770 |
+
msgid "Critical CSS Rules"
|
2771 |
+
msgstr ""
|
2772 |
+
|
2773 |
+
#: admin/tpl/settings_optimize.php:155
|
2774 |
+
msgid "Specify critical CSS rules for above-the-fold content when enabling %s."
|
2775 |
+
msgstr ""
|
2776 |
+
|
2777 |
+
#: admin/tpl/settings_optimize.php:161
|
2778 |
+
msgid "Load JS Deferred"
|
2779 |
+
msgstr ""
|
2780 |
+
|
2781 |
+
#: admin/tpl/settings_optimize.php:165
|
2782 |
+
msgid "Doing so can help reduce resource contention and improve performance."
|
2783 |
+
msgstr ""
|
2784 |
+
|
2785 |
+
#: admin/tpl/settings_optimize.php:172
|
2786 |
+
msgid "Remove WordPress Emoji"
|
2787 |
+
msgstr ""
|
2788 |
+
|
2789 |
+
#: admin/tpl/settings_optimize.php:176
|
2790 |
+
msgid ""
|
2791 |
+
"Enable this setting to stop loading emoji from wordpress.org. The visitor's "
|
2792 |
+
"browser default emoji will be displayed instead."
|
2793 |
+
msgstr ""
|
2794 |
+
|
2795 |
#: admin/tpl/settings_purge.php:5
|
2796 |
msgid "Purge Settings"
|
2797 |
msgstr ""
|
2984 |
msgid "Purged the blog!"
|
2985 |
msgstr ""
|
2986 |
|
2987 |
+
#: cli/litespeed-cache-cli-purge.class.php:186
|
2988 |
msgid "Purged the url!"
|
2989 |
msgstr ""
|
2990 |
|
2991 |
+
#: cli/litespeed-cache-cli-purge.class.php:235
|
2992 |
msgid "Purged the tags!"
|
2993 |
msgstr ""
|
2994 |
|
3017 |
msgid "Reached end of sitemap file. Crawling completed."
|
3018 |
msgstr ""
|
3019 |
|
3020 |
+
#: includes/litespeed-cache-gui.class.php:62
|
3021 |
+
msgid "Purge this page"
|
3022 |
+
msgstr ""
|
3023 |
+
|
3024 |
+
#: includes/litespeed-cache-gui.class.php:70
|
3025 |
+
msgid "Mark this page as "
|
3026 |
+
msgstr ""
|
3027 |
+
|
3028 |
+
#: includes/litespeed-cache-gui.class.php:77
|
3029 |
+
msgid "Non cacheable"
|
3030 |
+
msgstr ""
|
3031 |
+
|
3032 |
+
#: includes/litespeed-cache-gui.class.php:84
|
3033 |
+
msgid "Private cache"
|
3034 |
+
msgstr ""
|
3035 |
+
|
3036 |
+
#: includes/litespeed-cache-gui.class.php:91
|
3037 |
+
msgid "More settings"
|
3038 |
+
msgstr ""
|
3039 |
+
|
3040 |
#: includes/litespeed-cache-purge.class.php:202
|
3041 |
msgid "Purge category %s"
|
3042 |
msgstr ""
|
3053 |
msgid "Purge url %s"
|
3054 |
msgstr ""
|
3055 |
|
3056 |
+
#: includes/litespeed-cache-task.class.php:111
|
3057 |
msgid "LiteSpeed Cache Custom Cron"
|
3058 |
msgstr ""
|
3059 |
|
3060 |
+
#: includes/litespeed-cache.class.php:212
|
3061 |
msgid "Crawler blacklist is saved."
|
3062 |
msgstr ""
|
3063 |
|
3064 |
+
#: includes/litespeed-cache.class.php:217
|
3065 |
msgid "Notified LiteSpeed Web Server to purge the front page."
|
3066 |
msgstr ""
|
3067 |
|
3068 |
+
#: includes/litespeed-cache.class.php:222
|
3069 |
msgid "Notified LiteSpeed Web Server to purge pages."
|
3070 |
msgstr ""
|
3071 |
|
3072 |
+
#: includes/litespeed-cache.class.php:227
|
3073 |
msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
|
3074 |
msgstr ""
|
3075 |
|
3076 |
+
#: includes/litespeed-cache.class.php:232
|
3077 |
msgid "Notified LiteSpeed Web Server to purge error pages."
|
3078 |
msgstr ""
|
3079 |
|
3080 |
+
#: includes/litespeed-cache.class.php:238
|
3081 |
msgid "Notified LiteSpeed Web Server to purge all caches."
|
3082 |
msgstr ""
|
3083 |
|
3084 |
+
#: includes/litespeed-cache.class.php:245
|
3085 |
msgid "Notified LiteSpeed Web Server to purge everything."
|
3086 |
msgstr ""
|
3087 |
|
3088 |
+
#: includes/litespeed-cache.class.php:260
|
3089 |
msgid "Notified LiteSpeed Web Server to purge the list."
|
3090 |
msgstr ""
|
3091 |
|
lib/litespeed-php-compatibility.func.php
CHANGED
@@ -19,17 +19,17 @@ if ( ! defined('WPINC') ) {
|
|
19 |
*
|
20 |
*/
|
21 |
if ( ! function_exists('http_build_url') ) {
|
22 |
-
define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
|
23 |
-
define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
|
24 |
-
define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
|
25 |
-
define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
|
26 |
-
define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
|
27 |
-
define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
|
28 |
-
define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
|
29 |
-
define('HTTP_URL_STRIP_PATH', 128); // Strip complete path
|
30 |
-
define('HTTP_URL_STRIP_QUERY', 256); // Strip query string
|
31 |
-
define('HTTP_URL_STRIP_FRAGMENT', 512); // Strip any fragments (#identifier)
|
32 |
-
define('HTTP_URL_STRIP_ALL', 1024); // Strip anything but scheme and host
|
33 |
|
34 |
// Build an URL
|
35 |
// The parts of the second URL will be merged into the first according to the flags argument.
|
19 |
*
|
20 |
*/
|
21 |
if ( ! function_exists('http_build_url') ) {
|
22 |
+
if ( ! defined( 'HTTP_URL_REPLACE' ) ) define('HTTP_URL_REPLACE', 1); // Replace every part of the first URL when there's one of the second URL
|
23 |
+
if ( ! defined( 'HTTP_URL_JOIN_PATH' ) ) define('HTTP_URL_JOIN_PATH', 2); // Join relative paths
|
24 |
+
if ( ! defined( 'HTTP_URL_JOIN_QUERY' ) ) define('HTTP_URL_JOIN_QUERY', 4); // Join query strings
|
25 |
+
if ( ! defined( 'HTTP_URL_STRIP_USER' ) ) define('HTTP_URL_STRIP_USER', 8); // Strip any user authentication information
|
26 |
+
if ( ! defined( 'HTTP_URL_STRIP_PASS' ) ) define('HTTP_URL_STRIP_PASS', 16); // Strip any password authentication information
|
27 |
+
if ( ! defined( 'HTTP_URL_STRIP_AUTH' ) ) define('HTTP_URL_STRIP_AUTH', 32); // Strip any authentication information
|
28 |
+
if ( ! defined( 'HTTP_URL_STRIP_PORT' ) ) define('HTTP_URL_STRIP_PORT', 64); // Strip explicit port numbers
|
29 |
+
if ( ! defined( 'HTTP_URL_STRIP_PATH' ) ) define('HTTP_URL_STRIP_PATH', 128); // Strip complete path
|
30 |
+
if ( ! defined( 'HTTP_URL_STRIP_QUERY' ) ) define('HTTP_URL_STRIP_QUERY', 256); // Strip query string
|
31 |
+
if ( ! defined( 'HTTP_URL_STRIP_FRAGMENT' ) ) define('HTTP_URL_STRIP_FRAGMENT', 512); // Strip any fragments (#identifier)
|
32 |
+
if ( ! defined( 'HTTP_URL_STRIP_ALL' ) ) define('HTTP_URL_STRIP_ALL', 1024); // Strip anything but scheme and host
|
33 |
|
34 |
// Build an URL
|
35 |
// The parts of the second URL will be merged into the first according to the flags argument.
|
lib/litespeed/litespeed-string.class.php
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* LiteSpeed String Operator Library Class
|
4 |
+
*
|
5 |
+
* @since 1.3
|
6 |
+
*/
|
7 |
+
|
8 |
+
class Litespeed_String
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Generate random string
|
13 |
+
*
|
14 |
+
* @since 1.3
|
15 |
+
* @access public
|
16 |
+
* @param int $len Length of string
|
17 |
+
* @param int $type 1-Number 2-LowerChar 4-UpperChar
|
18 |
+
* @return string
|
19 |
+
*/
|
20 |
+
public static function rrand( $len, $type = 7 )
|
21 |
+
{
|
22 |
+
mt_srand( ( double ) microtime() * 1000000 ) ;
|
23 |
+
|
24 |
+
switch( $type ) {
|
25 |
+
case 0 :
|
26 |
+
$charlist = '012' ;
|
27 |
+
break ;
|
28 |
+
|
29 |
+
case 1 :
|
30 |
+
$charlist = '0123456789' ;
|
31 |
+
break ;
|
32 |
+
|
33 |
+
case 2 :
|
34 |
+
$charlist = 'abcdefghijklmnopqrstuvwxyz' ;
|
35 |
+
break ;
|
36 |
+
|
37 |
+
case 3 :
|
38 |
+
$charlist = '0123456789abcdefghijklmnopqrstuvwxyz' ;
|
39 |
+
break ;
|
40 |
+
|
41 |
+
case 4 :
|
42 |
+
$charlist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
|
43 |
+
break ;
|
44 |
+
|
45 |
+
case 5 :
|
46 |
+
$charlist = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
|
47 |
+
break ;
|
48 |
+
|
49 |
+
case 6 :
|
50 |
+
$charlist = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
|
51 |
+
break ;
|
52 |
+
|
53 |
+
case 7 :
|
54 |
+
$charlist = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
|
55 |
+
break ;
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
$str = '' ;
|
60 |
+
|
61 |
+
$max = strlen( $charlist ) - 1 ;
|
62 |
+
for( $i = 0 ; $i < $len ; $i++ ) {
|
63 |
+
$str .= $charlist[ mt_rand( 0, $max ) ] ;
|
64 |
+
}
|
65 |
+
|
66 |
+
return $str ;
|
67 |
+
}
|
68 |
+
|
69 |
+
|
70 |
+
}
|
litespeed-cache.php
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
* Plugin Name: LiteSpeed Cache
|
16 |
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
|
17 |
* Description: WordPress plugin to connect to LSCache on LiteSpeed Web Server.
|
18 |
-
* Version: 1.
|
19 |
* Author: LiteSpeed Technologies
|
20 |
* Author URI: https://www.litespeedtech.com
|
21 |
* License: GPLv3
|
@@ -50,6 +50,7 @@ if ( class_exists( 'LiteSpeed_Cache' ) || defined( 'LSWCP_DIR' ) ) {
|
|
50 |
|
51 |
define( 'LSWCP_CONTENT_DIR', dirname( get_theme_root() ) ) ;
|
52 |
define( 'LSWCP_DIR', plugin_dir_path( __FILE__ ) ) ;// Full absolute path '/usr/local/lsws/***/wp-content/plugins/litespeed-cache/'
|
|
|
53 |
define( 'LSWCP_BASENAME', plugin_basename( LSWCP_DIR . 'litespeed-cache.php' ) ) ;//LSWCP_BASENAME='litespeed-cache/litespeed-cache.php'
|
54 |
|
55 |
define( 'LSWCP_CONTENT_FOLDER', str_replace( home_url( '/' ), '', WP_CONTENT_URL ) ) ; // `wp-content`
|
@@ -61,17 +62,24 @@ if ( ! defined( 'LITESPEED_TIME_OFFSET' ) ) {
|
|
61 |
// Auto register LiteSpeed classes
|
62 |
require_once LSWCP_DIR . 'includes/litespeed.autoload.php' ;
|
63 |
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
|
|
|
69 |
if ( ! defined( 'LITESPEED_SERVER_TYPE' ) ) {
|
70 |
if ( isset( $_SERVER['HTTP_X_LSCACHE'] ) && $_SERVER['HTTP_X_LSCACHE'] ) {
|
71 |
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ADC' ) ;
|
72 |
}
|
73 |
elseif ( isset( $_SERVER['LSWS_EDITION'] ) && strncmp( $_SERVER['LSWS_EDITION'], 'Openlitespeed', 13 ) == 0 ) {
|
74 |
-
|
75 |
}
|
76 |
elseif ( isset( $_SERVER['SERVER_SOFTWARE'] ) && $_SERVER['SERVER_SOFTWARE'] == 'LiteSpeed' ) {
|
77 |
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ENT' ) ;
|
@@ -81,6 +89,11 @@ if ( ! defined( 'LITESPEED_SERVER_TYPE' ) ) {
|
|
81 |
}
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
84 |
// ESI const defination
|
85 |
if ( ! defined( 'LSWCP_ESI_SUPPORT' ) ) {
|
86 |
define( 'LSWCP_ESI_SUPPORT', LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ? true : false ) ;
|
@@ -137,11 +150,7 @@ if ( ! function_exists( 'run_litespeed_cache' ) ) {
|
|
137 |
if ( ! function_exists( 'litespeed_purge_single_post' ) ) {
|
138 |
function litespeed_purge_single_post( $id )
|
139 |
{
|
140 |
-
|
141 |
-
if ( ! in_array( get_post_status( $post_id ), array( 'publish', 'trash' ) ) ) {
|
142 |
-
return ;
|
143 |
-
}
|
144 |
-
LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_POST . $post_id ) ;
|
145 |
}
|
146 |
}
|
147 |
|
15 |
* Plugin Name: LiteSpeed Cache
|
16 |
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
|
17 |
* Description: WordPress plugin to connect to LSCache on LiteSpeed Web Server.
|
18 |
+
* Version: 1.3.1.1
|
19 |
* Author: LiteSpeed Technologies
|
20 |
* Author URI: https://www.litespeedtech.com
|
21 |
* License: GPLv3
|
50 |
|
51 |
define( 'LSWCP_CONTENT_DIR', dirname( get_theme_root() ) ) ;
|
52 |
define( 'LSWCP_DIR', plugin_dir_path( __FILE__ ) ) ;// Full absolute path '/usr/local/lsws/***/wp-content/plugins/litespeed-cache/'
|
53 |
+
define( 'LSWCP_PLUGIN_URL', plugin_dir_url(__FILE__) ) ;// Full URL path '//example.com/wp-content/plugins/litespeed-cache/'
|
54 |
define( 'LSWCP_BASENAME', plugin_basename( LSWCP_DIR . 'litespeed-cache.php' ) ) ;//LSWCP_BASENAME='litespeed-cache/litespeed-cache.php'
|
55 |
|
56 |
define( 'LSWCP_CONTENT_FOLDER', str_replace( home_url( '/' ), '', WP_CONTENT_URL ) ) ; // `wp-content`
|
62 |
// Auto register LiteSpeed classes
|
63 |
require_once LSWCP_DIR . 'includes/litespeed.autoload.php' ;
|
64 |
|
65 |
+
// Define CLI
|
66 |
+
if ( ( defined( 'WP_CLI' ) && WP_CLI ) || PHP_SAPI == 'cli' ) {
|
67 |
+
! defined( 'LITESPEED_CLI' ) && define( 'LITESPEED_CLI', true ) ;
|
68 |
+
|
69 |
+
// Register CLI cmd
|
70 |
+
if ( method_exists( 'WP_CLI', 'add_command' ) ) {
|
71 |
+
WP_CLI::add_command( 'lscache-admin', 'LiteSpeed_Cache_Cli_Admin' ) ;
|
72 |
+
WP_CLI::add_command( 'lscache-purge', 'LiteSpeed_Cache_Cli_Purge' ) ;
|
73 |
+
}
|
74 |
}
|
75 |
|
76 |
+
// Server type
|
77 |
if ( ! defined( 'LITESPEED_SERVER_TYPE' ) ) {
|
78 |
if ( isset( $_SERVER['HTTP_X_LSCACHE'] ) && $_SERVER['HTTP_X_LSCACHE'] ) {
|
79 |
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ADC' ) ;
|
80 |
}
|
81 |
elseif ( isset( $_SERVER['LSWS_EDITION'] ) && strncmp( $_SERVER['LSWS_EDITION'], 'Openlitespeed', 13 ) == 0 ) {
|
82 |
+
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_OLS' ) ;
|
83 |
}
|
84 |
elseif ( isset( $_SERVER['SERVER_SOFTWARE'] ) && $_SERVER['SERVER_SOFTWARE'] == 'LiteSpeed' ) {
|
85 |
define( 'LITESPEED_SERVER_TYPE', 'LITESPEED_SERVER_ENT' ) ;
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
// Checks if caching is allowed via server variable
|
93 |
+
if ( ! empty ( $_SERVER['X-LSCACHE'] ) || LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_ADC' || defined( 'LITESPEED_CLI' ) ) {
|
94 |
+
! defined( 'LITESPEED_ALLOWED' ) && define( 'LITESPEED_ALLOWED', true ) ;
|
95 |
+
}
|
96 |
+
|
97 |
// ESI const defination
|
98 |
if ( ! defined( 'LSWCP_ESI_SUPPORT' ) ) {
|
99 |
define( 'LSWCP_ESI_SUPPORT', LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ? true : false ) ;
|
150 |
if ( ! function_exists( 'litespeed_purge_single_post' ) ) {
|
151 |
function litespeed_purge_single_post( $id )
|
152 |
{
|
153 |
+
LiteSpeed_Cache_Purge::purge_post( $id ) ;
|
|
|
|
|
|
|
|
|
154 |
}
|
155 |
}
|
156 |
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: LiteSpeedTech
|
|
3 |
Tags: cache, wp-cache, litespeed, super cache, http2, total cache, wordfence
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.8.2
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl.html
|
9 |
|
@@ -21,7 +21,7 @@ If all of that sounds complicated, no need to worry. LiteSpeed Cache for WordPre
|
|
21 |
|
22 |
LSCWP supports WordPress Multisite and is compatible with most popular plugins, including WooCommerce, bbPress, and Yoast SEO. Scroll down for a complete list.
|
23 |
|
24 |
-
*NEW - LSCWP now includes additional optimization features, including Database Optimization, Minification and Combination of CSS and JS files, HTTP/2 push, and
|
25 |
|
26 |
Want to know more about caching in general, and LiteSpeed caching in particular? See [our Caching 101 blog series](https://blog.litespeedtech.com/tag/caching-101/).
|
27 |
|
@@ -47,11 +47,14 @@ Want to know more about caching in general, and LiteSpeed caching in particular?
|
|
47 |
|
48 |
LiteSpeed Web Server Enterprise, LiteSpeed Web ADC and OpenLiteSpeed:
|
49 |
|
50 |
-
*
|
51 |
-
*
|
52 |
-
*
|
53 |
-
*
|
54 |
-
*
|
|
|
|
|
|
|
55 |
* Automatic page caching to greatly improve site performance
|
56 |
* Automatic purge of related pages based on certain events
|
57 |
* Smart preload crawler with support for SEO-friendly sitemap
|
@@ -60,8 +63,9 @@ LiteSpeed Web Server Enterprise, LiteSpeed Web ADC and OpenLiteSpeed:
|
|
60 |
* Separate caching of desktop and mobile views
|
61 |
* Ability to schedule purge for specified URLs at specified time of day
|
62 |
* Support for HTTP/2 & HTTPS out-of-box
|
63 |
-
* Single Site and Multi Site support
|
64 |
* Support for WooCommerce and bbPress
|
|
|
65 |
* Simple API system that enables other plugins to easily integrate with cache and operate cache functionalities.
|
66 |
* No-Cache configuration by URI, Categories, Tags, Cookies, and User Agents
|
67 |
* Attractive, easy-to-understand interface
|
@@ -80,8 +84,13 @@ The vast majority of plugins and themes are compatible with LSCache. Our API is
|
|
80 |
|
81 |
If you have a plugin or theme that you would like to make compatible with LSCWP, please see the following resources:
|
82 |
|
83 |
-
* [
|
84 |
-
* [
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
= Known Compatible Plugins and Themes =
|
87 |
|
@@ -95,7 +104,7 @@ If you have a plugin or theme that you would like to make compatible with LSCWP,
|
|
95 |
* [ShortPixel](https://shortpixel.com/h/af/CXNO4OI28044/)
|
96 |
* Aelia CurrencySwitcher
|
97 |
* [Fast Velocity Minify](https://wordpress.org/plugins/fast-velocity-minify/) - Thanks Raul Peixoto!
|
98 |
-
*
|
99 |
* [Better WP Minify](https://wordpress.org/plugins/bwp-minify/)
|
100 |
* [WP Touch](https://wordpress.org/plugins/wptouch/)
|
101 |
* [Theme My Login](https://wordpress.org/plugins/theme-my-login/)
|
@@ -104,6 +113,7 @@ If you have a plugin or theme that you would like to make compatible with LSCWP,
|
|
104 |
* [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
|
105 |
* [Avada 5.1 RC1+](https://avada.theme-fusion.com/)
|
106 |
* Elegant Themes Divi 3.0.67+
|
|
|
107 |
|
108 |
= Known Uncompatible Plugins =
|
109 |
|
@@ -222,9 +232,56 @@ For more detailed information about crawler setup, please see [our blog post](ht
|
|
222 |
12. Admin Crawler Status Page
|
223 |
13. Cache Miss Example
|
224 |
14. Cache Hit Example
|
|
|
225 |
|
226 |
== Changelog ==
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
= 1.2.3.1 - September 20 2017 =
|
229 |
* [UPDATE] Improved PHP5.3 compatibility.
|
230 |
|
3 |
Tags: cache, wp-cache, litespeed, super cache, http2, total cache, wordfence
|
4 |
Requires at least: 4.0
|
5 |
Tested up to: 4.8.2
|
6 |
+
Stable tag: 1.3.1.1
|
7 |
License: GPLv3
|
8 |
License URI: http://www.gnu.org/licenses/gpl.html
|
9 |
|
21 |
|
22 |
LSCWP supports WordPress Multisite and is compatible with most popular plugins, including WooCommerce, bbPress, and Yoast SEO. Scroll down for a complete list.
|
23 |
|
24 |
+
*NEW - LSCWP now includes additional optimization features, including Database Optimization, Minification and Combination of CSS and JS files, HTTP/2 push CDN support, and Browser Cache!*
|
25 |
|
26 |
Want to know more about caching in general, and LiteSpeed caching in particular? See [our Caching 101 blog series](https://blog.litespeedtech.com/tag/caching-101/).
|
27 |
|
47 |
|
48 |
LiteSpeed Web Server Enterprise, LiteSpeed Web ADC and OpenLiteSpeed:
|
49 |
|
50 |
+
* PageSpeed score optimization
|
51 |
+
* Load CSS/JS Asynchronously
|
52 |
+
* Content Delivery Network support
|
53 |
+
* Minify CSS, JavaScript, and HTML
|
54 |
+
* Combine CSS and JavaScript
|
55 |
+
* HTTP/2 Push for CSS and JS
|
56 |
+
* Database Cleaner and Optimizer
|
57 |
+
* Browser Cache
|
58 |
* Automatic page caching to greatly improve site performance
|
59 |
* Automatic purge of related pages based on certain events
|
60 |
* Smart preload crawler with support for SEO-friendly sitemap
|
63 |
* Separate caching of desktop and mobile views
|
64 |
* Ability to schedule purge for specified URLs at specified time of day
|
65 |
* Support for HTTP/2 & HTTPS out-of-box
|
66 |
+
* Single Site and Multi Site ( Network ) support
|
67 |
* Support for WooCommerce and bbPress
|
68 |
+
* [WordPress CLI](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp#wordpress_cli)
|
69 |
* Simple API system that enables other plugins to easily integrate with cache and operate cache functionalities.
|
70 |
* No-Cache configuration by URI, Categories, Tags, Cookies, and User Agents
|
71 |
* Attractive, easy-to-understand interface
|
84 |
|
85 |
If you have a plugin or theme that you would like to make compatible with LSCWP, please see the following resources:
|
86 |
|
87 |
+
* [LSCWP API Documentation for WordPress Plugin Developers](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api)
|
88 |
+
* [LSCWP GitHub](https://github.com/litespeedtech/lscache_wp/)
|
89 |
+
* [ESI example: Use ESI for WordPress nonce with cache](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_sample)
|
90 |
+
* [ESI example: Make Caldera Form v1.5.6.1 work with cache](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_replace)
|
91 |
+
* [ESI example: Make Visual Composer's WordPress nonce work with cache](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_nonce)
|
92 |
+
|
93 |
+
If you have any API requirements, please inform us anytime in [WP Forum](https://wordpress.org/support/plugin/litespeed-cache) or [GitHub Issues](https://github.com/litespeedtech/lscache_wp/issues). We will add them ASAP.
|
94 |
|
95 |
= Known Compatible Plugins and Themes =
|
96 |
|
104 |
* [ShortPixel](https://shortpixel.com/h/af/CXNO4OI28044/)
|
105 |
* Aelia CurrencySwitcher
|
106 |
* [Fast Velocity Minify](https://wordpress.org/plugins/fast-velocity-minify/) - Thanks Raul Peixoto!
|
107 |
+
* Autoptimize
|
108 |
* [Better WP Minify](https://wordpress.org/plugins/bwp-minify/)
|
109 |
* [WP Touch](https://wordpress.org/plugins/wptouch/)
|
110 |
* [Theme My Login](https://wordpress.org/plugins/theme-my-login/)
|
113 |
* [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
|
114 |
* [Avada 5.1 RC1+](https://avada.theme-fusion.com/)
|
115 |
* Elegant Themes Divi 3.0.67+
|
116 |
+
* [Caldera Forms](https://wordpress.org/plugins/caldera-forms/) 1.5.6.2+
|
117 |
|
118 |
= Known Uncompatible Plugins =
|
119 |
|
232 |
12. Admin Crawler Status Page
|
233 |
13. Cache Miss Example
|
234 |
14. Cache Hit Example
|
235 |
+
15. Frontend Adminbar Shortcut
|
236 |
|
237 |
== Changelog ==
|
238 |
|
239 |
+
= 1.3.1.1 - October 6 2017 =
|
240 |
+
* [BUGFIX] Improved optimizer table creating process in certain database charset to avoid css/js minify/combination failure.
|
241 |
+
|
242 |
+
= 1.3.1 - October 5 2017 =
|
243 |
+
* [NEW FEATURE] Remove WP Emoji Option.
|
244 |
+
* [IMPROVEMENT] Separated optimizer data from wp_options to improve compatibility with backup plugins.
|
245 |
+
* [IMPROVEMENT] Enhanced crawler cron hook to prevent de-scheduling in some cases.
|
246 |
+
* [IMPROVEMENT] Enhanced Remove Query Strings to also remove Emoji query strings.
|
247 |
+
* [IMPROVEMENT] Enhanced HTML detection when extra spaces are present at the beginning.
|
248 |
+
* [UPDATE] Added private cache support for OLS.
|
249 |
+
* [BUGFIX] Self-redirects are no longer cached.
|
250 |
+
* [BUGFIX] Fixed css async lib warning when loading in HTTP/2 push.
|
251 |
+
|
252 |
+
= 1.3 - October 1 2017 =
|
253 |
+
* [NEW FEATURE] Added Browser Cache support.
|
254 |
+
* [NEW FEATURE] Added Remove Query Strings support.
|
255 |
+
* [NEW FEATURE] Added Remove Google Fonts support.
|
256 |
+
* [NEW FEATURE] Added Load CSS Asynchronously support.
|
257 |
+
* [NEW FEATURE] Added Load JS Deferred support.
|
258 |
+
* [NEW FEATURE] Added Critical CSS Rules support.
|
259 |
+
* [NEW FEATURE] Added Private Cached URIs support.
|
260 |
+
* [NEW FEATURE] Added Do Not Cache Query Strings support.
|
261 |
+
* [NEW FEATURE] Added frontend adminbar shortcuts ( Purge this page/Do Not Cache/Private cache ).
|
262 |
+
* [IMPROVEMENT] Do Not Cache URIs now supports full URLs.
|
263 |
+
* [IMPROVEMENT] Improved performance of Do Not Cache settings.
|
264 |
+
* [IMPROVEMENT] Encrypted vary cookie.
|
265 |
+
* [IMPROVEMENT] Enhanced HTML optimizer.
|
266 |
+
* [IMPROVEMENT] Limited combined file size to avoid heavy memory usage.
|
267 |
+
* [IMPROVEMENT] CDN supports custom upload folder for media files.
|
268 |
+
* [API] Added purge single post API.
|
269 |
+
* [API] Added version compare API.
|
270 |
+
* [API] Enhanced ESI API for third party plugins.
|
271 |
+
* [INTEGRATION] Compatibility with NextGEN Gallery v2.2.14.
|
272 |
+
* [INTEGRATION] Compatibility with Caldera Forms v1.5.6.2+.
|
273 |
+
* [BUGFIX] Fixed CDN&Minify compatibility with css url links.
|
274 |
+
* [BUGFIX] Fixed .htaccess being regenerated despite there being no changes.
|
275 |
+
* [BUGFIX] Fixed CDN path bug for subfolder WP instance.
|
276 |
+
* [BUGFIX] Fixed crawler path bug for subfolder WP instance with different site url and home url.
|
277 |
+
* [BUGFIX] Fixed a potential Optimizer generating redundant duplicated JS in HTML bug.
|
278 |
+
* [GUI] Added a more easily accessed submit button in admin settings.
|
279 |
+
* [GUI] Admin settings page cosmetic changes.
|
280 |
+
* [GUI] Reorganized GUI css/img folder structure.
|
281 |
+
* [REFACTOR] Refactored configuration init.
|
282 |
+
* [REFACTOR] Refactored admin setting save.
|
283 |
+
* [REFACTOR] Refactored .htaccess operator and rewrite rule generation.
|
284 |
+
|
285 |
= 1.2.3.1 - September 20 2017 =
|
286 |
* [UPDATE] Improved PHP5.3 compatibility.
|
287 |
|
thirdparty/lscwp-3rd-nextgengallery.cls.php
CHANGED
@@ -55,7 +55,7 @@ class LiteSpeed_Cache_ThirdParty_NextGenGallery
|
|
55 |
*/
|
56 |
public static function add_image($image)
|
57 |
{
|
58 |
-
if ( ! $image ) {
|
59 |
return ;
|
60 |
}
|
61 |
$gallery = $image->get_gallery() ;
|
55 |
*/
|
56 |
public static function add_image($image)
|
57 |
{
|
58 |
+
if ( ! $image || ! method_exists( $image, 'get_gallery' ) ) {
|
59 |
return ;
|
60 |
}
|
61 |
$gallery = $image->get_gallery() ;
|
thirdparty/lscwp-3rd-woocommerce.cls.php
CHANGED
@@ -143,7 +143,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
|
|
143 |
) ;
|
144 |
add_action('woocommerce_after_add_to_cart_form', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form') ;
|
145 |
add_action('woocommerce_after_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form', 999) ;
|
146 |
-
LiteSpeed_Cache_API::esi_url('wc-add-to-cart-form', 'WC_CART_FORM', $params) ;
|
147 |
ob_start() ;
|
148 |
}
|
149 |
|
@@ -212,7 +212,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
|
|
212 |
*/
|
213 |
public static function esi_cart_header()
|
214 |
{
|
215 |
-
LiteSpeed_Cache_API::esi_url('storefront-cart-header', 'STOREFRONT_CART_HEADER') ;
|
216 |
}
|
217 |
|
218 |
/**
|
143 |
) ;
|
144 |
add_action('woocommerce_after_add_to_cart_form', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form') ;
|
145 |
add_action('woocommerce_after_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form', 999) ;
|
146 |
+
echo LiteSpeed_Cache_API::esi_url('wc-add-to-cart-form', 'WC_CART_FORM', $params) ;
|
147 |
ob_start() ;
|
148 |
}
|
149 |
|
212 |
*/
|
213 |
public static function esi_cart_header()
|
214 |
{
|
215 |
+
echo LiteSpeed_Cache_API::esi_url('storefront-cart-header', 'STOREFRONT_CART_HEADER') ;
|
216 |
}
|
217 |
|
218 |
/**
|
thirdparty/lscwp-3rd-yith-wishlist.cls.php
CHANGED
@@ -86,7 +86,7 @@ class LiteSpeed_Cache_ThirdParty_Yith_Wishlist
|
|
86 |
$params = array(
|
87 |
self::ESI_PARAM_POSTID => $post->ID
|
88 |
) ;
|
89 |
-
LiteSpeed_Cache_API::esi_url( 'yith-wcwl-add', 'YITH ADD TO WISHLIST', $params ) ;
|
90 |
return '' ;
|
91 |
}
|
92 |
|
86 |
$params = array(
|
87 |
self::ESI_PARAM_POSTID => $post->ID
|
88 |
) ;
|
89 |
+
echo LiteSpeed_Cache_API::esi_url( 'yith-wcwl-add', 'YITH ADD TO WISHLIST', $params ) ;
|
90 |
return '' ;
|
91 |
}
|
92 |
|