LiteSpeed Cache - Version 2.4

Version Description

  • Jul 2 2018 =
  • [NEW FEATURE] Image Optimization Added lossless optimization.
  • [NEW FEATURE] Image Optimization Added Request Orignal Images ON/OFF.
  • [NEW FEATURE] Image Optimization Added Request WebP ON/OFF. (@JMCA2)
  • [IMPROVEMENT] Image Optimization Improved optimization tools to archive maximum compression and score.
  • [IMPROVEMENT] Image Optimization Improved speed of image pull.
  • [IMPROVEMENT] Image Optimization Automatically recover credit after pulled.
  • [REFACTOR] Config Separated configure const class.
  • [BUGFIX] Report Report can be sent successfully with emoji now. (@music47ell)
  • [IAPI] New Europe Image Optimization server (EU3/EU4).
  • [IAPI] New America Image Optimization server (US3/US4/US5/US6).
  • [IAPI] New Asian Image Optimization server (AS3).
  • [IAPI] Refactored optimization process.
  • [IAPI] Increased credit limit.
  • [IAPI] Removed request interval limit.
  • [IAPI] IAPI v2.4.
  • We strongly recommended that you re-optimize your image library to get a better compression result.
Download this release

Release Info

Developer LiteSpeedTech
Plugin Icon 128x128 LiteSpeed Cache
Version 2.4
Comparing to
See all releases

Code changes from version 2.3.1 to 2.4

admin/litespeed-cache-admin-rules.class.php CHANGED
@@ -663,7 +663,7 @@ class LiteSpeed_Cache_Admin_Rules
663
}
664
665
// webp support
666
- $id = LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ;
667
if ( ! empty( $cfg[ $id ] ) ) {
668
$new_rules[] = self::MARKER_WEBP . self::MARKER_START ;
669
$new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp"' ;
663
}
664
665
// webp support
666
+ $id = LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ;
667
if ( ! empty( $cfg[ $id ] ) ) {
668
$new_rules[] = self::MARKER_WEBP . self::MARKER_START ;
669
$new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp"' ;
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -671,11 +671,13 @@ class LiteSpeed_Cache_Admin_Settings
671
$ids = array(
672
LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
673
LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
674
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF,
675
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET,
676
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY,
677
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF,
678
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS,
679
) ;
680
foreach ( $ids as $id ) {
681
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
@@ -1013,7 +1015,7 @@ class LiteSpeed_Cache_Admin_Settings
1013
LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
1014
LiteSpeed_Cache_Config::OPID_CACHE_RES,
1015
LiteSpeed_Cache_Config::OPID_CACHE_BROWSER,
1016
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP,
1017
) ;
1018
foreach ( $ids as $id ) {
1019
$new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
671
$ids = array(
672
LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
673
LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
674
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_AUTO,
675
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON,
676
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI,
677
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP,
678
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS,
679
+ LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF,
680
+ LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET,
681
) ;
682
foreach ( $ids as $id ) {
683
$this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
1015
LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
1016
LiteSpeed_Cache_Config::OPID_CACHE_RES,
1017
LiteSpeed_Cache_Config::OPID_CACHE_BROWSER,
1018
+ LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE,
1019
) ;
1020
foreach ( $ids as $id ) {
1021
$new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
admin/tpl/image_optimization.php CHANGED
@@ -236,7 +236,7 @@ LiteSpeed_Cache_GUI::show_promo() ;
236
237
<br />
238
239
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_ORI ) ; ?>" class="litespeed-btn-danger">
240
<?php echo __( 'Undo Optimization', 'litespeed-cache' ) ; ?>
241
</a>
242
<span class="litespeed-desc">
@@ -245,7 +245,7 @@ LiteSpeed_Cache_GUI::show_promo() ;
245
246
<br />
247
248
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_OPTM ) ; ?>" class="litespeed-btn-warning">
249
<?php echo __( 'Re-do Optimization', 'litespeed-cache' ) ; ?>
250
</a>
251
<span class="litespeed-desc">
236
237
<br />
238
239
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_ORI ) ; ?>" class="litespeed-btn-warning">
240
<?php echo __( 'Undo Optimization', 'litespeed-cache' ) ; ?>
241
</a>
242
<span class="litespeed-desc">
245
246
<br />
247
248
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_OPTM ) ; ?>" class="litespeed-btn-success">
249
<?php echo __( 'Re-do Optimization', 'litespeed-cache' ) ; ?>
250
</a>
251
<span class="litespeed-desc">
admin/tpl/inc/disabled_all.php CHANGED
File without changes
admin/tpl/setting/settings_cdn.php CHANGED
@@ -32,6 +32,7 @@ if ( ! $cdn_mapping ) {
32
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN ) ; ?>
33
<div class="litespeed-desc">
34
<?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ) ; ?>
35
</div>
36
</td>
37
</tr>
32
<?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN ) ; ?>
33
<div class="litespeed-desc">
34
<?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ) ; ?>
35
+ <?php echo sprintf( __( 'If using Cloudflare, leave this setting %s and use Cloudflare API setting below.', 'litespeed-cache' ), '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?>
36
</div>
37
</td>
38
</tr>
admin/tpl/setting/settings_inc.media_webp.php CHANGED
@@ -5,7 +5,7 @@ if ( ! defined( 'WPINC' ) ) die ;
5
<tr>
6
<th><?php echo __( 'Image WebP Replacement', 'litespeed-cache' ) ; ?></th>
7
<td>
8
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ) ; ?>
9
<div class="litespeed-desc">
10
<?php echo sprintf( __( 'Significantly improve load time by replacing images with their optimized %s versions.', 'litespeed-cache' ), '.webp' ) ; ?>
11
<br /><font class="litespeed-warning">
5
<tr>
6
<th><?php echo __( 'Image WebP Replacement', 'litespeed-cache' ) ; ?></th>
7
<td>
8
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ) ; ?>
9
<div class="litespeed-desc">
10
<?php echo sprintf( __( 'Significantly improve load time by replacing images with their optimized %s versions.', 'litespeed-cache' ), '.webp' ) ; ?>
11
<br /><font class="litespeed-warning">
admin/tpl/setting/settings_media.php CHANGED
@@ -65,56 +65,53 @@ if ( ! defined( 'WPINC' ) ) die ;
65
</td>
66
</tr>
67
68
- <tr>
69
- <th><?php echo __( 'Disable Optimization Pull', 'litespeed-cache' ) ; ?></th>
70
<td>
71
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF ) ; ?>
72
<div class="litespeed-desc">
73
- <?php echo sprintf( __( 'Set this option to %s to disable the cron job responsible for fetching optimized images from LiteSpeed\'s Image Server.', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ) ) ; ?>
74
</div>
75
</td>
76
</tr>
77
78
- <?php
79
- if ( ! is_multisite() ) :
80
- // webp
81
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ;
82
-
83
- endif ;
84
- ?>
85
86
<tr>
87
- <th><?php echo __( 'WebP Attribute To Replace', 'litespeed-cache' ) ; ?></th>
88
<td>
89
- <?php $id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ; ?>
90
- <?php $this->build_textarea2( $id, 40 ) ; ?>
91
- <?php $this->recommended( $id, true ) ; ?>
92
<div class="litespeed-desc">
93
- <?php echo __( 'Specify which element attributes will be replaced with WebP.', 'litespeed-cache' ) ; ?>
94
- <?php echo __( 'Only attributes listed here will be replaced.', 'litespeed-cache' ) ; ?>
95
- <br /><?php echo sprintf( __( 'Use the format %1$s or %2$s (element is optional).', 'litespeed-cache' ), '<code>element.attribute</code>', '<code>.attribute</code>' ) ; ?>
96
- <?php echo __('One per line.', 'litespeed-cache'); ?>
97
</div>
98
</td>
99
</tr>
100
101
<tr>
102
- <th><?php echo __( 'WebP For Extra srcset', 'litespeed-cache' ) ; ?></th>
103
<td>
104
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET ) ; ?>
105
<div class="litespeed-desc">
106
- <?php echo sprintf( __( 'Enable replacement of WebP in %s elements that were generated outside of WordPress logic.', 'litespeed-cache' ), '<code>srcset</code>' ) ; ?>
107
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#webp_for_extra_srcset" target="_blank"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
108
</div>
109
</td>
110
</tr>
111
112
<tr>
113
- <th><?php echo __( 'Only Request WebP', 'litespeed-cache' ) ; ?></th>
114
<td>
115
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ) ; ?>
116
<div class="litespeed-desc">
117
- <?php echo __( 'Prevent images from being replaced with optimized versions when optimizing. WebP versions will still be generated.', 'litespeed-cache' ) ; ?>
118
</div>
119
</td>
120
</tr>
@@ -122,7 +119,7 @@ if ( ! defined( 'WPINC' ) ) die ;
122
<tr>
123
<th><?php echo __( 'Preserve EXIF data', 'litespeed-cache' ) ; ?></th>
124
<td>
125
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF ) ; ?>
126
<div class="litespeed-desc">
127
<?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ) ; ?>
128
<?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ) ; ?>
@@ -130,13 +127,36 @@ if ( ! defined( 'WPINC' ) ) die ;
130
</td>
131
</tr>
132
133
- <tr class="litespeed-hide">
134
- <th><?php echo __( 'WebP Lossless Compression', 'litespeed-cache' ) ; ?></th>
135
<td>
136
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS ) ; ?>
137
<div class="litespeed-desc">
138
- <?php echo __( 'Generate WebP images using lossless compression.', 'litespeed-cache' ) ; ?>
139
- <?php echo __( 'This can improve quality at the cost of larger images.', 'litespeed-cache' ) ; ?>
140
</div>
141
</td>
142
</tr>
65
</td>
66
</tr>
67
68
+ <tr class="litespeed-hide">
69
+ <th><?php echo __( 'Optimize New Images', 'litespeed-cache' ) ; ?></th>
70
<td>
71
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_AUTO ) ; ?>
72
<div class="litespeed-desc">
73
+ <?php echo __( 'Automatically request optimization for newly-uploaded images.', 'litespeed-cache' ) ; ?>
74
</div>
75
</td>
76
</tr>
77
78
+ <tr>
79
+ <th><?php echo __( 'Optimization Cron', 'litespeed-cache' ) ; ?></th>
80
+ <td>
81
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON ) ; ?>
82
+ <div class="litespeed-desc">
83
+ <?php echo __( 'Disabling this will stop the cron job responsible for fetching optimized images from LiteSpeed\'s Image Server.', 'litespeed-cache' ) ; ?>
84
+ </div>
85
+ </td>
86
+ </tr>
87
88
<tr>
89
+ <th><?php echo __( 'Optimize Original Images', 'litespeed-cache' ) ; ?></th>
90
<td>
91
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ; ?>
92
<div class="litespeed-desc">
93
+ <?php echo __( 'Optimize images and save backups of the originals in the same folder.', 'litespeed-cache' ) ; ?>
94
</div>
95
</td>
96
</tr>
97
98
<tr>
99
+ <th><?php echo __( 'Optimize WebP Versions', 'litespeed-cache' ) ; ?></th>
100
<td>
101
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ; ?>
102
<div class="litespeed-desc">
103
+ <?php echo __( 'Request WebP versions of original images when doing optimization.', 'litespeed-cache' ) ; ?>
104
</div>
105
</td>
106
</tr>
107
108
<tr>
109
+ <th><?php echo __( 'Optimize Losslessly', 'litespeed-cache' ) ; ?></th>
110
<td>
111
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS ) ; ?>
112
<div class="litespeed-desc">
113
+ <?php echo __( 'Optimize images using lossless compression.', 'litespeed-cache' ) ; ?>
114
+ <?php echo __( 'This can improve quality but may result in larger images than lossy compression will.', 'litespeed-cache' ) ; ?>
115
</div>
116
</td>
117
</tr>
119
<tr>
120
<th><?php echo __( 'Preserve EXIF data', 'litespeed-cache' ) ; ?></th>
121
<td>
122
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF ) ; ?>
123
<div class="litespeed-desc">
124
<?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ) ; ?>
125
<?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ) ; ?>
127
</td>
128
</tr>
129
130
+ <?php
131
+ if ( ! is_multisite() ) :
132
+ // webp
133
+ require LSCWP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ;
134
+
135
+ endif ;
136
+ ?>
137
+
138
+ <tr>
139
+ <th><?php echo __( 'WebP Attribute To Replace', 'litespeed-cache' ) ; ?></th>
140
<td>
141
+ <?php $id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ; ?>
142
+ <?php $this->build_textarea2( $id, 40 ) ; ?>
143
+ <?php $this->recommended( $id, true ) ; ?>
144
<div class="litespeed-desc">
145
+ <?php echo __( 'Specify which element attributes will be replaced with WebP.', 'litespeed-cache' ) ; ?>
146
+ <?php echo __( 'Only attributes listed here will be replaced.', 'litespeed-cache' ) ; ?>
147
+ <br /><?php echo sprintf( __( 'Use the format %1$s or %2$s (element is optional).', 'litespeed-cache' ), '<code>element.attribute</code>', '<code>.attribute</code>' ) ; ?>
148
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
149
+ </div>
150
+ </td>
151
+ </tr>
152
+
153
+ <tr>
154
+ <th><?php echo __( 'WebP For Extra srcset', 'litespeed-cache' ) ; ?></th>
155
+ <td>
156
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET ) ; ?>
157
+ <div class="litespeed-desc">
158
+ <?php echo sprintf( __( 'Enable replacement of WebP in %s elements that were generated outside of WordPress logic.', 'litespeed-cache' ), '<code>srcset</code>' ) ; ?>
159
+ <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#webp_for_extra_srcset" target="_blank"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
160
</div>
161
</td>
162
</tr>
admin/tpl/settings.php CHANGED
@@ -99,9 +99,6 @@ else {
99
$adv_mode = get_option( LiteSpeed_Cache_Config::ITEM_SETTING_MODE ) ;
100
}
101
102
- $class_basic = $adv_mode ? '' : ' litespeed-setting-curr' ;
103
- $class_advanced = ! $adv_mode ? '' : ' litespeed-setting-curr' ;
104
-
105
$hide_tabs = array() ;
106
$_hide_in_basic_mode = '' ;
107
@@ -129,10 +126,6 @@ if ( ! $adv_mode ) {
129
<span class="litespeed-desc">
130
v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
131
</span>
132
- <span class="litespeed-desc">
133
- <a href="admin.php?page=lscache-settings&mode=basic" class="litespeed-setting-basic <?php echo $class_basic ; ?>"><?php echo __( 'Basic View', 'litespeed-cache' ) ; ?></a>
134
- <a href="admin.php?page=lscache-settings&mode=advanced" class="litespeed-setting-advanced <?php echo $class_advanced ; ?>"><?php echo __( 'Advanced View', 'litespeed-cache' ) ; ?></a>
135
- </span>
136
<hr class="wp-header-end">
137
</div>
138
<div class="litespeed-wrap">
@@ -153,6 +146,11 @@ if ( ! $adv_mode ) {
153
$i ++ ;
154
}
155
?>
156
</h2>
157
<div class="litespeed-body">
158
<form method="post" action="options.php" id="litespeed_form_options" class="litespeed-relative">
99
$adv_mode = get_option( LiteSpeed_Cache_Config::ITEM_SETTING_MODE ) ;
100
}
101
102
$hide_tabs = array() ;
103
$_hide_in_basic_mode = '' ;
104
126
<span class="litespeed-desc">
127
v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
128
</span>
129
<hr class="wp-header-end">
130
</div>
131
<div class="litespeed-wrap">
146
$i ++ ;
147
}
148
?>
149
+ <?php if ( $adv_mode ) : ?>
150
+ <a href="admin.php?page=lscache-settings&mode=basic" class="litespeed-tab litespeed-advanced-tab-hide litespeed-right"><?php echo __( 'Hide Advanced Options', 'litespeed-cache' ) ; ?></a>
151
+ <?php else : ?>
152
+ <a href="admin.php?page=lscache-settings&mode=advanced" class="litespeed-tab litespeed-advanced-tab-show litespeed-right"><?php echo __( 'Show Advanced Options', 'litespeed-cache' ) ; ?></a>
153
+ <?php endif ; ?>
154
</h2>
155
<div class="litespeed-body">
156
<form method="post" action="options.php" id="litespeed_form_options" class="litespeed-relative">
cli/litespeed-cache-cli-admin.class.php CHANGED
@@ -11,70 +11,14 @@ class LiteSpeed_Cache_Cli_Admin
11
12
public function __construct()
13
{
14
- self::$checkboxes = array(
15
- LiteSpeed_Cache_Config::OPID_CACHE_PRIV,
16
- LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER,
17
- LiteSpeed_Cache_Config::OPID_CACHE_REST,
18
- LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN,
19
- LiteSpeed_Cache_Config::OPID_CACHE_MOBILE,
20
- LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE,
21
- LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
22
- LiteSpeed_Cache_Config::OPID_CACHE_RES,
23
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT,
24
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND,
25
-
26
- LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE,
27
- LiteSpeed_Cache_Config::OPID_ESI_ENABLE,
28
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR,
29
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM,
30
- LiteSpeed_Cache_Config::CRWL_POSTS,
31
- LiteSpeed_Cache_Config::CRWL_PAGES,
32
- LiteSpeed_Cache_Config::CRWL_CATS,
33
- LiteSpeed_Cache_Config::CRWL_TAGS,
34
- LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE,
35
- LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL,
36
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
37
- LiteSpeed_Cache_Config::OPID_HEARTBEAT,
38
- LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
39
- LiteSpeed_Cache_Config::OPID_COLLAPS_QS,
40
- LiteSpeed_Cache_Config::OPID_LOG_FILTERS,
41
-
42
- LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
43
- LiteSpeed_Cache_Config::OPID_CSS_INLINE_MINIFY,
44
- LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
45
- LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY,
46
- LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
47
- LiteSpeed_Cache_Config::OPID_JS_MINIFY,
48
- LiteSpeed_Cache_Config::OPID_JS_INLINE_MINIFY,
49
- LiteSpeed_Cache_Config::OPID_JS_COMBINE,
50
- LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY,
51
- LiteSpeed_Cache_Config::OPID_JS_HTTP2,
52
- LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
53
- LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
54
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
55
- LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
56
- LiteSpeed_Cache_Config::OPT_OPTM_CCSS_GEN,
57
- LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC,
58
- LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE,
59
- LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
60
- LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
61
- LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
62
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC,
63
- LiteSpeed_Cache_Config::OPID_OPTM_RM_COMMENT,
64
-
65
- LiteSpeed_Cache_Config::OPID_CDN,
66
- LiteSpeed_Cache_Config::OPID_CDN_QUIC,
67
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE,
68
-
69
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
70
- LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
71
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF,
72
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP,
73
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET,
74
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY,
75
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF,
76
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS,
77
- ) ;
78
self::$purges = array(
79
'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
80
'purge_' . LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
@@ -131,62 +75,7 @@ class LiteSpeed_Cache_Cli_Admin
131
$options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
132
}
133
//fall through
134
- case LiteSpeed_Cache_Config::OPID_CACHE_PRIV:
135
- case LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER:
136
- case LiteSpeed_Cache_Config::OPID_CACHE_REST:
137
- case LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN:
138
- case LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE:
139
- case LiteSpeed_Cache_Config::OPID_CACHE_FAVICON:
140
- case LiteSpeed_Cache_Config::OPID_CACHE_RES:
141
- case LiteSpeed_Cache_Config::OPID_CACHE_OBJECT:
142
- case LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND:
143
-
144
- case LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE:
145
- case LiteSpeed_Cache_Config::OPID_ESI_ENABLE:
146
- case LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR:
147
- case LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM:
148
- case LiteSpeed_Cache_Config::CRWL_POSTS:
149
- case LiteSpeed_Cache_Config::CRWL_PAGES:
150
- case LiteSpeed_Cache_Config::CRWL_CATS:
151
- case LiteSpeed_Cache_Config::CRWL_TAGS:
152
- case LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE:
153
- case LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL:
154
- case LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL:
155
- case LiteSpeed_Cache_Config::OPID_HEARTBEAT:
156
- case LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE:
157
- case LiteSpeed_Cache_Config::OPID_COLLAPS_QS:
158
- case LiteSpeed_Cache_Config::OPID_LOG_FILTERS:
159
-
160
- case LiteSpeed_Cache_Config::OPID_CSS_MINIFY:
161
- case LiteSpeed_Cache_Config::OPID_CSS_COMBINE:
162
- case LiteSpeed_Cache_Config::OPID_JS_MINIFY:
163
- case LiteSpeed_Cache_Config::OPID_JS_COMBINE:
164
- case LiteSpeed_Cache_Config::OPID_HTML_MINIFY:
165
- case LiteSpeed_Cache_Config::OPID_OPTM_QS_RM:
166
- case LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM:
167
- case LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC:
168
- case LiteSpeed_Cache_Config::OPT_OPTM_CCSS_GEN:
169
- case LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC:
170
- case LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE:
171
- case LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER:
172
- case LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM:
173
- case LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY:
174
- case LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC:
175
- case LiteSpeed_Cache_Config::OPID_OPTM_RM_COMMENT:
176
-
177
- case LiteSpeed_Cache_Config::OPID_CDN:
178
- case LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE:
179
-
180
- case LiteSpeed_Cache_Config::OPID_ADV_INSTANT_CLICK:
181
-
182
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY:
183
- case LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY:
184
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF:
185
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP:
186
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET:
187
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY:
188
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF:
189
- case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS:
190
//checkbox
191
if ( $val === 'true' ) {
192
$options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
11
12
public function __construct()
13
{
14
+ // Build on/off options
15
+ self::$checkboxes = array() ;
16
+ foreach ( LiteSpeed_Cache_Config::get_instance()->get_default_options() as $k => $v ) {
17
+ if ( is_bool( $v ) ) {
18
+ self::$checkboxes[] = $k ;
19
+ }
20
+ }
21
+
22
self::$purges = array(
23
'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
24
'purge_' . LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
75
$options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
76
}
77
//fall through
78
+ case in_array( $key, self::$checkboxes ) :
79
//checkbox
80
if ( $val === 'true' ) {
81
$options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
css/litespeed.css CHANGED
@@ -26,6 +26,10 @@
26
display: inline-block;
27
}
28
29
.litespeed-success {
30
color: #73b38d!important;
31
}
@@ -76,6 +80,11 @@
76
position: relative ;
77
}
78
79
.litespeed-h3{
80
font-family: "Open Sans", Arial, sans-serif;
81
line-height: 18px;
@@ -113,6 +122,52 @@ h3 .litespeed-learn-more {
113
margin-left: 30px;
114
}
115
116
/********************************* logo *******************************/
117
@font-face {
118
font-family: 'litespeedfont';
26
display: inline-block;
27
}
28
29
+ .litespeed-default {
30
+ color: #a7a7a7!important;
31
+ }
32
+
33
.litespeed-success {
34
color: #73b38d!important;
35
}
80
position: relative ;
81
}
82
83
+ .litespeed-wrap .litespeed-right,
84
+ .litespeed-right {
85
+ float: right ;
86
+ }
87
+
88
.litespeed-h3{
89
font-family: "Open Sans", Arial, sans-serif;
90
line-height: 18px;
122
margin-left: 30px;
123
}
124
125
+ /*show advanced options tab*/
126
+
127
+ .litespeed-header .litespeed-advanced-tab-show {
128
+ background: #00CC99;
129
+ color: #DDF8F1 !important;
130
+ font-weight: 600;
131
+ border-right: 1px solid #00A37A;
132
+ border-left: 1px solid #00A37A;
133
+ border-top: 1px solid #00A37A;
134
+ }
135
+
136
+ .litespeed-header .litespeed-advanced-tab-show:hover,
137
+ .litespeed-header .litespeed-advanced-tab-show:focus,
138
+ .litespeed-header .litespeed-advanced-tab-show:focus:active {
139
+ background: #00A37A;
140
+ color: #FFFFFF !important;
141
+ font-weight: 600;
142
+ border-right: 1px solid #00A37A;
143
+ border-left: 1px solid #00A37A;
144
+ border-top: 1px solid #00A37A;
145
+ border-bottom: 1px solid #00A37A;
146
+ }
147
+
148
+ /*hide advanced options tab*/
149
+
150
+ .litespeed-header .litespeed-advanced-tab-hide {
151
+ background: #99CCCC;
152
+ color: #FDFDFD !important;
153
+ font-weight: 600;
154
+ border-left: 1px solid #7AA3A3;
155
+ border-top: 1px solid #7AA3A3;
156
+ border-right: 1px solid #7AA3A3;
157
+ }
158
+
159
+ .litespeed-header .litespeed-advanced-tab-hide:hover,
160
+ .litespeed-header .litespeed-advanced-tab-hide:focus,
161
+ .litespeed-header .litespeed-advanced-tab-hide:focus:active {
162
+ background: #7AA3A3;
163
+ color: #FFFFFF !important;
164
+ font-weight: 600;
165
+ border-right: 1px solid #7AA3A3;
166
+ border-left: 1px solid #7AA3A3;
167
+ border-top: 1px solid #7AA3A3;
168
+ border-bottom: 1px solid #7AA3A3;
169
+ }
170
+
171
/********************************* logo *******************************/
172
@font-face {
173
font-family: 'litespeedfont';
inc/config.class.php CHANGED
@@ -10,215 +10,10 @@
10
* @subpackage LiteSpeed_Cache/inc
11
* @author LiteSpeed Technologies <info@litespeedtech.com>
12
*/
13
- class LiteSpeed_Cache_Config
14
{
15
private static $_instance ;
16
17
- const OPTION_NAME = 'litespeed-cache-conf' ;
18
- const VARY_GROUP = 'litespeed-cache-vary-group' ;
19
- const EXCLUDE_OPTIMIZATION_ROLES = 'litespeed-cache-exclude-optimization-roles' ;
20
- const EXCLUDE_CACHE_ROLES = 'litespeed-cache-exclude-cache-roles' ;
21
- const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
22
- const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
23
- const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
24
- const ITEM_IMG_OPTM_NEED_PULL = 'litespeed-media-need-pull' ;
25
- const ITEM_ENV_REF = 'litespeed-env-ref' ;
26
- const ITEM_CACHE_DROP_QS = 'litespeed-cache-drop_qs' ;
27
- const ITEM_CDN_MAPPING = 'litespeed-cache-cdn_mapping' ;
28
- const ITEM_DNS_PREFETCH = 'litespeed-cache-dns_prefetch' ;
29
- const ITEM_CLOUDFLARE_STATUS = 'litespeed-cache-cloudflare_status' ;
30
- const ITEM_LOG_IGNORE_FILTERS = 'litespeed-log_ignore_filters' ;
31
- const ITEM_LOG_IGNORE_PART_FILTERS = 'litespeed-log_ignore_part_filters' ;
32
- const ITEM_OBJECT_GLOBAL_GROUPS = 'litespeed-object_global_groups' ;
33
- const ITEM_OBJECT_NON_PERSISTENT_GROUPS = 'litespeed-object_non_persistent_groups' ;
34
- const ITEM_CRWL_AS_UIDS = 'litespeed-crawler-as-uids' ;
35
- const ITEM_ADV_PURGE_ALL_HOOKS = 'litespeed-adv-purge_all_hooks' ;
36
- const ITEM_CDN_ORI_DIR = 'litespeed-cdn-ori_dir' ;
37
- const ITEM_MEDIA_WEBP_ATTRIBUTE = 'litespeed-media-webp_attribute' ;
38
- const ITEM_FORCE_CACHE_URI = 'litespeed-forced_cache_uri' ;
39
- const ITEM_CACHE_URI_PRIV = 'litespeed-cache_uri_priv' ;
40
- const ITEM_OPTM_EXCLUDES = 'litespeed-optm_excludes' ;
41
- const ITEM_EXCLUDES_URI = 'litespeed-excludes_uri' ;
42
-
43
- const ITEM_SETTING_MODE = 'litespeed-setting-mode' ;
44
- const ITEM_CRAWLER_HASH = 'litespeed-crawler-hash' ;
45
- const ITEM_GUIDE = 'litespeed-guide' ; // Array of each guidance tag as key, step as val
46
-
47
- // Server variables
48
- const ENV_CRAWLER_USLEEP = 'CRAWLER_USLEEP' ;
49
- const ENV_CRAWLER_LOAD_LIMIT = 'CRAWLER_LOAD_LIMIT' ;
50
- const ENV_CRAWLER_LOAD_LIMIT_ENFORCE = 'CRAWLER_LOAD_LIMIT_ENFORCE' ;
51
-
52
- // const ITEM_FAVICON = 'litespeed-cache-favicon' ;
53
-
54
- const ITEM_CDN_MAPPING_URL = 'url' ;
55
- const ITEM_CDN_MAPPING_INC_IMG = 'inc_img' ;
56
- const ITEM_CDN_MAPPING_INC_CSS = 'inc_css' ;
57
- const ITEM_CDN_MAPPING_INC_JS = 'inc_js' ;
58
- const ITEM_CDN_MAPPING_FILETYPE = 'filetype' ;
59
-
60
- const VAL_OFF = 0 ;
61
- const VAL_ON = 1 ;
62
- const VAL_ON2 = 2 ;
63
-
64
- const LOG_LEVEL_NONE = 0 ;
65
- const LOG_LEVEL_ERROR = 1 ;
66
- const LOG_LEVEL_NOTICE = 2 ;
67
- const LOG_LEVEL_INFO = 3 ;
68
- const LOG_LEVEL_DEBUG = 4 ;
69
- const OPID_VERSION = 'version' ;
70
- const OPID_ENABLED_RADIO = 'radio_select' ;
71
-
72
- const OPID_CACHE_PRIV = 'cache_priv' ;
73
- const OPID_CACHE_COMMENTER = 'cache_commenter' ;
74
- const OPID_CACHE_REST = 'cache_rest' ;
75
- const OPID_CACHE_PAGE_LOGIN = 'cache_page_login' ;
76
- const OPID_CACHE_FAVICON = 'cache_favicon' ;
77
- const OPID_CACHE_RES = 'cache_resources' ;
78
- const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
79
- const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
80
- const OPID_CACHE_OBJECT = 'cache_object' ;
81
- const OPID_CACHE_OBJECT_KIND = 'cache_object_kind' ;
82
- const OPID_CACHE_OBJECT_HOST = 'cache_object_host' ;
83
- const OPID_CACHE_OBJECT_PORT = 'cache_object_port' ;
84
- const OPID_CACHE_OBJECT_LIFE = 'cache_object_life' ;
85
- const OPID_CACHE_OBJECT_PERSISTENT = 'cache_object_persistent' ;
86
- const OPID_CACHE_OBJECT_ADMIN = 'cache_object_admin' ;
87
- const OPID_CACHE_OBJECT_TRANSIENTS = 'cache_object_transients' ;
88
- const OPID_CACHE_OBJECT_DB_ID = 'cache_object_db_id' ;
89
- const OPID_CACHE_OBJECT_USER = 'cache_object_user' ;
90
- const OPID_CACHE_OBJECT_PSWD = 'cache_object_pswd' ;
91
- const OPID_CACHE_BROWSER = 'cache_browser' ;
92
- const OPID_CACHE_BROWSER_TTL = 'cache_browser_ttl' ;
93
-
94
- const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
95
- const OPID_TIMED_URLS = 'timed_urls' ;
96
- const OPID_TIMED_URLS_TIME = 'timed_urls_time' ;
97
-
98
- const OPID_LOGIN_COOKIE = 'login_cookie' ;
99
- const OPID_CHECK_ADVANCEDCACHE = 'check_advancedcache' ;
100
- const OPID_USE_HTTP_FOR_HTTPS_VARY = 'use_http_for_https_vary' ;
101
- // do NOT set default options for these three, it is used for admin.
102
- const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
103
- const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
104
- const OPID_DEBUG_DISABLE_ALL = 'debug_disable_all' ;
105
- const OPID_DEBUG = 'debug' ;
106
- const OPID_ADMIN_IPS = 'admin_ips' ;
107
- const OPID_DEBUG_LEVEL = 'debug_level' ;
108
- const OPID_LOG_FILE_SIZE = 'log_file_size' ;
109
- const OPID_HEARTBEAT = 'heartbeat' ;
110
- const OPID_DEBUG_COOKIE = 'debug_cookie' ;
111
- const OPID_COLLAPS_QS = 'collaps_qs' ;
112
- const OPID_LOG_FILTERS = 'log_filters' ;
113
-
114
- const OPID_PUBLIC_TTL = 'public_ttl' ;
115
- const OPID_PRIVATE_TTL = 'private_ttl' ;
116
- const OPID_FRONT_PAGE_TTL = 'front_page_ttl' ;
117
- const OPID_FEED_TTL = 'feed_ttl' ;
118
- const OPID_403_TTL = '403_ttl' ;
119
- const OPID_404_TTL = '404_ttl' ;
120
- const OPID_500_TTL = '500_ttl' ;
121
- const OPID_PURGE_BY_POST = 'purge_by_post' ;
122
- const OPID_ESI_ENABLE = 'esi_enabled' ;
123
- const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
124
- const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
125
- const PURGE_ALL_PAGES = '-' ;
126
- const PURGE_FRONT_PAGE = 'F' ;
127
- const PURGE_HOME_PAGE = 'H' ;
128
- const PURGE_PAGES = 'PGS' ;
129
- const PURGE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
130
- const PURGE_AUTHOR = 'A' ;
131
- const PURGE_YEAR = 'Y' ;
132
- const PURGE_MONTH = 'M' ;
133
- const PURGE_DATE = 'D' ;
134
- const PURGE_TERM = 'T' ; // include category|tag|tax
135
- const PURGE_POST_TYPE = 'PT' ;
136
-
137
- const OPID_EXCLUDES_QS = 'excludes_qs' ;
138
- const OPID_EXCLUDES_CAT = 'excludes_cat' ;
139
- const OPID_EXCLUDES_TAG = 'excludes_tag' ;
140
-
141
- // const OPID_ADV_FAVICON = 'adv_favicon' ;
142
- const OPID_ADV_INSTANT_CLICK = 'instant_click' ;
143
-
144
- const OPID_CSS_MINIFY = 'css_minify' ;
145
- const OPID_CSS_INLINE_MINIFY = 'css_inline_minify' ;
146
- const OPID_CSS_COMBINE = 'css_combine' ;
147
- const OPID_CSS_COMBINED_PRIORITY = 'css_combined_priority' ;
148
- const OPID_CSS_HTTP2 = 'css_http2' ;
149
- const OPID_CSS_EXCLUDES = 'css_exclude' ;
150
- const OPID_JS_MINIFY = 'js_minify' ;
151
- const OPID_JS_INLINE_MINIFY = 'js_inline_minify' ;
152
- const OPID_JS_COMBINE = 'js_combine' ;
153
- const OPID_JS_COMBINED_PRIORITY = 'js_combined_priority' ;
154
- const OPID_JS_HTTP2 = 'js_http2' ;
155
- const OPID_JS_EXCLUDES = 'js_exclude' ;
156
- const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
157
- const OPID_HTML_MINIFY = 'html_minify' ;
158
- const OPID_OPTM_QS_RM = 'optm_qs_rm' ;
159
- const OPID_OPTM_GGFONTS_RM = 'optm_ggfonts_rm' ;
160
- const OPID_OPTM_CSS_ASYNC = 'optm_css_async' ;
161
- const OPT_OPTM_CCSS_GEN = 'optm_ccss_gen' ;
162
- const OPT_OPTM_CCSS_ASYNC = 'optm_ccss_async' ;
163
- const OPT_OPTM_CSS_ASYNC_INLINE = 'optm_css_async_inline' ;
164
- const OPID_OPTM_JS_DEFER = 'optm_js_defer' ;
165
- const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
166
- const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
167
- const OPID_OPTM_GGFONTS_ASYNC = 'optm_ggfonts_async' ;
168
- const OPID_OPTM_MAX_SIZE = 'optm_max_size' ;
169
- const OPID_OPTM_RM_COMMENT = 'optm_rm_comment' ;
170
-
171
- const OPID_CDN = 'cdn' ;
172
- const OPID_CDN_ORI = 'cdn_ori' ;
173
- const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
174
- const OPID_CDN_REMOTE_JQUERY = 'cdn_remote_jquery' ;
175
- const OPID_CDN_QUIC = 'cdn_quic' ;
176
- const OPID_CDN_QUIC_EMAIL = 'cdn_quic_email' ;
177
- const OPID_CDN_QUIC_KEY = 'cdn_quic_key' ;
178
- const OPID_CDN_QUIC_SITE = 'cdn_quic_site' ;
179
- const OPID_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
180
- const OPID_CDN_CLOUDFLARE_EMAIL = 'cdn_cloudflare_email' ;
181
- const OPID_CDN_CLOUDFLARE_KEY = 'cdn_cloudflare_key' ;
182
- const OPID_CDN_CLOUDFLARE_NAME = 'cdn_cloudflare_name' ;
183
- const OPID_CDN_CLOUDFLARE_ZONE = 'cdn_cloudflare_zone' ;
184
-
185
- const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
186
- const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
187
- const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
188
- const OPID_MEDIA_IMG_OPTM_CRON_OFF = 'media_img_optm_cron_off' ;
189
- const OPID_MEDIA_IMG_WEBP = 'media_img_webp' ;
190
- const OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET = 'media_img_webp_replace_srcset' ;
191
- const OPID_MEDIA_IMG_WEBP_ONLY = 'media_img_webp_only' ;
192
- const OPID_MEDIA_IMG_EXIF = 'media_img_exif' ;
193
- const OPID_MEDIA_IMG_WEBP_LOSSLESS = 'media_img_webp_lossless' ;
194
-
195
- const HASH = 'hash' ;
196
-
197
- const NETWORK_OPID_ENABLED = 'network_enabled' ;
198
- const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
199
-
200
- const CRWL_POSTS = 'crawler_include_posts' ;
201
- const CRWL_PAGES = 'crawler_include_pages' ;
202
- const CRWL_CATS = 'crawler_include_cats' ;
203
- const CRWL_TAGS = 'crawler_include_tags' ;
204
- const CRWL_EXCLUDES_CPT = 'crawler_excludes_cpt' ;
205
- const CRWL_ORDER_LINKS = 'crawler_order_links' ;
206
- const CRWL_USLEEP = 'crawler_usleep' ;
207
- const CRWL_RUN_DURATION = 'crawler_run_duration' ;
208
- const CRWL_RUN_INTERVAL = 'crawler_run_interval' ;
209
- const CRWL_CRAWL_INTERVAL = 'crawler_crawl_interval' ;
210
- const CRWL_THREADS = 'crawler_threads' ;
211
- const CRWL_LOAD_LIMIT = 'crawler_load_limit' ;
212
- const CRWL_DOMAIN_IP = 'crawler_domain_ip' ;
213
- const CRWL_CUSTOM_SITEMAP = 'crawler_custom_sitemap' ;
214
-
215
- const CRWL_CRON_ACTIVE = 'crawler_cron_active' ;
216
-
217
- const CRWL_DATE_DESC = 'date_desc' ;
218
- const CRWL_DATE_ASC = 'date_asc' ;
219
- const CRWL_ALPHA_DESC = 'alpha_desc' ;
220
- const CRWL_ALPHA_ASC = 'alpha_asc' ;
221
-
222
protected $options ;
223
protected $vary_groups ;
224
protected $exclude_optimization_roles ;
@@ -269,41 +64,6 @@ class LiteSpeed_Cache_Config
269
270
}
271
272
- /**
273
- * Get the items in wp_options that need for backup
274
- *
275
- * @since 2.2.1
276
- * @access public
277
- */
278
- public function stored_items()
279
- {
280
- return array(
281
- self::OPTION_NAME,
282
- self::VARY_GROUP,
283
- self::EXCLUDE_OPTIMIZATION_ROLES,
284
- self::EXCLUDE_CACHE_ROLES,
285
- self::ITEM_OPTM_CSS,
286
- self::ITEM_OPTM_JS_DEFER_EXC,
287
- self::ITEM_MEDIA_LAZY_IMG_EXC,
288
- self::ITEM_IMG_OPTM_NEED_PULL,
289
- self::ITEM_ENV_REF,
290
- self::ITEM_CACHE_DROP_QS,
291
- self::ITEM_CDN_MAPPING,
292
- self::ITEM_DNS_PREFETCH,
293
- self::ITEM_CLOUDFLARE_STATUS,
294
- self::ITEM_LOG_IGNORE_FILTERS,
295
- self::ITEM_LOG_IGNORE_PART_FILTERS,
296
- self::ITEM_OBJECT_GLOBAL_GROUPS,
297
- self::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
298
- self::ITEM_CRWL_AS_UIDS,
299
- self::ITEM_ADV_PURGE_ALL_HOOKS,
300
- self::ITEM_FORCE_CACHE_URI,
301
- self::ITEM_CACHE_URI_PRIV,
302
- self::ITEM_OPTM_EXCLUDES,
303
- self::ITEM_EXCLUDES_URI,
304
- ) ;
305
- }
306
-
307
/**
308
* Define `LSCACHE_ADV_CACHE` based on options setting
309
*
@@ -588,220 +348,6 @@ class LiteSpeed_Cache_Config
588
return in_array( $flag, $this->purge_options ) ;
589
}
590
591
- /**
592
- * Gets the default single site options
593
- *
594
- * @since 1.0.0
595
- * @access public
596
- * @param bool $include_thirdparty Whether to include the thirdparty options.
597
- * @return array An array of the default options.
598
- */
599
- public function get_default_options($include_thirdparty = true)
600
- {
601
- $default_purge_options = array(
602
- self::PURGE_FRONT_PAGE,
603
- self::PURGE_HOME_PAGE,
604
- self::PURGE_PAGES,
605
- self::PURGE_PAGES_WITH_RECENT_POSTS,
606
- self::PURGE_AUTHOR,
607
- self::PURGE_MONTH,
608
- self::PURGE_TERM,
609
- self::PURGE_POST_TYPE,
610
- ) ;
611
- sort($default_purge_options) ;
612
-
613
- //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
614
- if ( is_multisite() ) {
615
- $default_radio = 2 ;
616
- }
617
- else {
618
- $default_radio = 1 ;
619
- }
620
-
621
- $default_options = array(
622
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
623
- self::OPID_ENABLED_RADIO => $default_radio,
624
- self::OPID_PURGE_ON_UPGRADE => true,
625
- self::OPID_CACHE_PRIV => true,
626
- self::OPID_CACHE_COMMENTER => true,
627
- self::OPID_CACHE_REST => true,
628
- self::OPID_CACHE_PAGE_LOGIN => true,
629
- self::OPID_TIMED_URLS => '',
630
- self::OPID_TIMED_URLS_TIME => '',
631
- self::OPID_CACHE_FAVICON => true,
632
- self::OPID_CACHE_RES => true,
633
- self::OPID_CACHE_MOBILE => false,
634
- self::ID_MOBILEVIEW_LIST => false,
635
- self::OPID_CACHE_OBJECT => false,
636
- self::OPID_CACHE_OBJECT_KIND => false,
637
- self::OPID_CACHE_OBJECT_HOST => 'localhost',
638
- self::OPID_CACHE_OBJECT_PORT => '11211',
639
- self::OPID_CACHE_OBJECT_LIFE => '360',
640
- self::OPID_CACHE_OBJECT_PERSISTENT => true,
641
- self::OPID_CACHE_OBJECT_ADMIN => true,
642
- self::OPID_CACHE_OBJECT_TRANSIENTS => true,
643
- self::OPID_CACHE_OBJECT_DB_ID => 0,
644
- self::OPID_CACHE_OBJECT_USER => '',
645
- self::OPID_CACHE_OBJECT_PSWD => '',
646
- self::OPID_CACHE_BROWSER => false,
647
- self::OPID_CACHE_BROWSER_TTL => 2592000,
648
-
649
- self::OPID_LOGIN_COOKIE => '',
650
- self::OPID_CHECK_ADVANCEDCACHE => true,
651
- self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
652
- self::OPID_DEBUG_DISABLE_ALL => false,
653
- self::OPID_DEBUG => self::LOG_LEVEL_NONE,
654
- self::OPID_ADMIN_IPS => '127.0.0.1',
655
- self::OPID_DEBUG_LEVEL => false,
656
- self::OPID_LOG_FILE_SIZE => 3,
657
- self::OPID_HEARTBEAT => true,
658
- self::OPID_DEBUG_COOKIE => false,
659
- self::OPID_COLLAPS_QS => false,
660
- self::OPID_LOG_FILTERS => false,
661
- self::OPID_PUBLIC_TTL => 604800,
662
- self::OPID_PRIVATE_TTL => 1800,
663
- self::OPID_FRONT_PAGE_TTL => 604800,
664
- self::OPID_FEED_TTL => 0,
665
- self::OPID_403_TTL => 3600,
666
- self::OPID_404_TTL => 3600,
667
- self::OPID_500_TTL => 3600,
668
- self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
669
- self::OPID_EXCLUDES_QS => '',
670
- self::OPID_EXCLUDES_CAT => '',
671
- self::OPID_EXCLUDES_TAG => '',
672
-
673
- // self::OPID_ADV_FAVICON => false,
674
- self::OPID_ADV_INSTANT_CLICK => false,
675
-
676
- self::OPID_CSS_MINIFY => false,
677
- self::OPID_CSS_INLINE_MINIFY => false,
678
- self::OPID_CSS_COMBINE => false,
679
- self::OPID_CSS_COMBINED_PRIORITY => false,
680
- self::OPID_CSS_HTTP2 => false,
681
- self::OPID_CSS_EXCLUDES => '',
682
- self::OPID_JS_MINIFY => false,
683
- self::OPID_JS_INLINE_MINIFY => false,
684
- self::OPID_JS_COMBINE => false,
685
- self::OPID_JS_COMBINED_PRIORITY => false,
686
- self::OPID_JS_HTTP2 => false,
687
- self::OPID_JS_EXCLUDES => '',
688
- self::OPID_OPTIMIZE_TTL => 604800,
689
- self::OPID_HTML_MINIFY => false,
690
- self::OPID_OPTM_QS_RM => false,
691
- self::OPID_OPTM_GGFONTS_RM => false,
692
- self::OPID_OPTM_CSS_ASYNC => false,
693
- self::OPT_OPTM_CCSS_GEN => true,
694
- self::OPT_OPTM_CCSS_ASYNC => true,
695
- self::OPT_OPTM_CSS_ASYNC_INLINE => true,
696
- self::OPID_OPTM_JS_DEFER => false,
697
- self::OPID_OPTM_EMOJI_RM => false,
698
- self::OPID_OPTM_EXC_JQUERY => true,
699
- self::OPID_OPTM_GGFONTS_ASYNC => false,
700
- self::OPID_OPTM_MAX_SIZE => 1.2,
701
- self::OPID_OPTM_RM_COMMENT => false,
702
-
703
- self::OPID_CDN => false,
704
- self::OPID_CDN_ORI => '',
705
- self::OPID_CDN_EXCLUDE => '',
706
- self::OPID_CDN_REMOTE_JQUERY => false,
707
- self::OPID_CDN_QUIC => false,
708
- self::OPID_CDN_QUIC_EMAIL => '',
709
- self::OPID_CDN_QUIC_KEY => '',
710
- self::OPID_CDN_QUIC_SITE => '',
711
- self::OPID_CDN_CLOUDFLARE => false,
712
- self::OPID_CDN_CLOUDFLARE_EMAIL => '',
713
- self::OPID_CDN_CLOUDFLARE_KEY => '',
714
- self::OPID_CDN_CLOUDFLARE_NAME => '',
715
- self::OPID_CDN_CLOUDFLARE_ZONE => '',
716
-
717
- self::OPID_MEDIA_IMG_LAZY => false,
718
- self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
719
- self::OPID_MEDIA_IFRAME_LAZY => false,
720
- self::OPID_MEDIA_IMG_OPTM_CRON_OFF => false,
721
- self::OPID_MEDIA_IMG_WEBP => false,
722
- self::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET => false,
723
- self::OPID_MEDIA_IMG_WEBP_ONLY => false,
724
- self::OPID_MEDIA_IMG_EXIF => false,
725
- self::OPID_MEDIA_IMG_WEBP_LOSSLESS => false,
726
-
727
- self::HASH => '',
728
-
729
- self::ID_NOCACHE_COOKIES => '',
730
- self::ID_NOCACHE_USERAGENTS => '',
731
- self::CRWL_POSTS => true,
732
- self::CRWL_PAGES => true,
733
- self::CRWL_CATS => true,
734
- self::CRWL_TAGS => true,
735
- self::CRWL_EXCLUDES_CPT => '',
736
- self::CRWL_ORDER_LINKS => self::CRWL_DATE_DESC,
737
- self::CRWL_USLEEP => 500,
738
- self::CRWL_RUN_DURATION => 400,
739
- self::CRWL_RUN_INTERVAL => 600,
740
- self::CRWL_CRAWL_INTERVAL => 302400,
741
- self::CRWL_THREADS => 3,
742
- self::CRWL_LOAD_LIMIT => 1,
743
- self::CRWL_DOMAIN_IP => '',
744
- self::CRWL_CUSTOM_SITEMAP => '',
745
- self::CRWL_CRON_ACTIVE => false,
746
- ) ;
747
-
748
- if ( LSWCP_ESI_SUPPORT ) {
749
- $default_options[self::OPID_ESI_ENABLE] = false ;
750
- $default_options[self::OPID_ESI_CACHE_ADMBAR] = true ;
751
- $default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
752
- }
753
-
754
- if ( ! $include_thirdparty ) {
755
- return $default_options ;
756
- }
757
-
758
- $tp_options = $this->get_thirdparty_options($default_options) ;
759
- if ( ! isset($tp_options) || ! is_array($tp_options) ) {
760
- return $default_options ;
761
- }
762
- return array_merge($default_options, $tp_options) ;
763
- }
764
-
765
- /**
766
- * Gets the default network options
767
- *
768
- * @since 1.0.11
769
- * @access protected
770
- * @return array An array of the default options.
771
- */
772
- protected function get_default_site_options()
773
- {
774
- $default_site_options = array(
775
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
776
- self::NETWORK_OPID_ENABLED => false,
777
- self::NETWORK_OPID_USE_PRIMARY => false,
778
- self::OPID_PURGE_ON_UPGRADE => true,
779
- self::OPID_CACHE_FAVICON => true,
780
- self::OPID_CACHE_RES => true,
781
- self::OPID_CACHE_MOBILE => 0, // todo: why not false
782
- self::ID_MOBILEVIEW_LIST => false,
783
- self::OPID_CACHE_OBJECT => false,
784
- self::OPID_CACHE_OBJECT_KIND => false,
785
- self::OPID_CACHE_OBJECT_HOST => 'localhost',
786
- self::OPID_CACHE_OBJECT_PORT => '11211',
787
- self::OPID_CACHE_OBJECT_LIFE => '360',
788
- self::OPID_CACHE_OBJECT_PERSISTENT => true,
789
- self::OPID_CACHE_OBJECT_ADMIN => true,
790
- self::OPID_CACHE_OBJECT_TRANSIENTS => true,
791
- self::OPID_CACHE_OBJECT_DB_ID => 0,
792
- self::OPID_CACHE_OBJECT_USER => '',
793
- self::OPID_CACHE_OBJECT_PSWD => '',
794
- self::OPID_CACHE_BROWSER => false,
795
- self::OPID_CACHE_BROWSER_TTL => 2592000,
796
- self::OPID_LOGIN_COOKIE => '',
797
- self::OPID_CHECK_ADVANCEDCACHE => true,
798
- self::ID_NOCACHE_COOKIES => '',
799
- self::ID_NOCACHE_USERAGENTS => '',
800
- self::OPID_MEDIA_IMG_WEBP => false,
801
- ) ;
802
- return $default_site_options ;
803
- }
804
-
805
/**
806
* Get item val
807
*
@@ -822,41 +368,6 @@ class LiteSpeed_Cache_Config
822
return $val ;
823
}
824
825
- /**
826
- * Get default item val
827
- *
828
- * @since 1.8
829
- * @access public
830
- */
831
- public function default_item( $k )
832
- {
833
- switch ( $k ) {
834
- case self::ITEM_OBJECT_GLOBAL_GROUPS :
835
- return "users\nuserlogins\nusermeta\nuser_meta\nsite-transient\nsite-options\nsite-lookup\nblog-lookup\nblog-details\nrss\nglobal-posts\nblog-id-cache" ;
836
-
837
- case self::ITEM_OBJECT_NON_PERSISTENT_GROUPS :
838
- return "comment\ncounts\nplugins" ;
839
-
840
- case self::ITEM_ADV_PURGE_ALL_HOOKS :
841
- return "switch_theme\nwp_create_nav_menu\nwp_update_nav_menu\nwp_delete_nav_menu\ncreate_term\nedit_terms\ndelete_term\nadd_link\nedit_link\ndelete_link" ;
842
-
843
- case self::ITEM_CDN_ORI_DIR :
844
- return LSCWP_CONTENT_FOLDER . "\nwp-includes\n/min/" ;
845
-
846
- case self::ITEM_MEDIA_WEBP_ATTRIBUTE :
847
- return "img.src\n" .
848
- "div.data-thumb\n" .
849
- "img.data-src\n" .
850
- "div.data-large_image\n" .
851
- "img.retina_logo_url" ;
852
-
853
- default :
854
- break ;
855
- }
856
-
857
- return false ;
858
- }
859
-
860
/**
861
* Get the plugin's site wide options.
862
*
@@ -883,26 +394,6 @@ class LiteSpeed_Cache_Config
883
return $default_site_options ;
884
}
885
886
- /**
887
- * Gets the third party options.
888
- * Will also strip the options that are actually normal options.
889
- *
890
- * @access public
891
- * @since 1.0.9
892
- * @param array $options Optional. The default options to compare against.
893
- * @return mixed boolean on failure, array of keys on success.
894
- */
895
- public function get_thirdparty_options($options = null)
896
- {
897
- $tp_options = apply_filters('litespeed_cache_get_options', array()) ;
898
- if ( empty($tp_options) ) {
899
- return false ;
900
- }
901
- if ( ! isset($options) ) {
902
- $options = $this->get_default_options(false) ;
903
- }
904
- return array_diff_key($tp_options, $options) ;
905
- }
906
907
/**
908
* Helper function to convert the options to replicate the input format.
10
* @subpackage LiteSpeed_Cache/inc
11
* @author LiteSpeed Technologies <info@litespeedtech.com>
12
*/
13
+ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
14
{
15
private static $_instance ;
16
17
protected $options ;
18
protected $vary_groups ;
19
protected $exclude_optimization_roles ;
64
65
}
66
67
/**
68
* Define `LSCACHE_ADV_CACHE` based on options setting
69
*
348
return in_array( $flag, $this->purge_options ) ;
349
}
350
351
/**
352
* Get item val
353
*
368
return $val ;
369
}
370
371
/**
372
* Get the plugin's site wide options.
373
*
394
return $default_site_options ;
395
}
396
397
398
/**
399
* Helper function to convert the options to replicate the input format.
inc/const.cls.php ADDED
@@ -0,0 +1,527 @@
1
+ <?php
2
+ /**
3
+ * The core consts for config
4
+ *
5
+ * @since 2.4
6
+ * @package LiteSpeed_Cache
7
+ * @subpackage LiteSpeed_Cache/inc
8
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
9
+ */
10
+ class LiteSpeed_Cache_Const
11
+ {
12
+ const OPTION_NAME = 'litespeed-cache-conf' ;
13
+ const VARY_GROUP = 'litespeed-cache-vary-group' ;
14
+ const EXCLUDE_OPTIMIZATION_ROLES = 'litespeed-cache-exclude-optimization-roles' ;
15
+ const EXCLUDE_CACHE_ROLES = 'litespeed-cache-exclude-cache-roles' ;
16
+ const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
17
+ const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
18
+ const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
19
+ const ITEM_IMG_OPTM_NEED_PULL = 'litespeed-media-need-pull' ;
20
+ const ITEM_ENV_REF = 'litespeed-env-ref' ;
21
+ const ITEM_CACHE_DROP_QS = 'litespeed-cache-drop_qs' ;
22
+ const ITEM_CDN_MAPPING = 'litespeed-cache-cdn_mapping' ;
23
+ const ITEM_DNS_PREFETCH = 'litespeed-cache-dns_prefetch' ;
24
+ const ITEM_CLOUDFLARE_STATUS = 'litespeed-cache-cloudflare_status' ;
25
+ const ITEM_LOG_IGNORE_FILTERS = 'litespeed-log_ignore_filters' ;
26
+ const ITEM_LOG_IGNORE_PART_FILTERS = 'litespeed-log_ignore_part_filters' ;
27
+ const ITEM_OBJECT_GLOBAL_GROUPS = 'litespeed-object_global_groups' ;
28
+ const ITEM_OBJECT_NON_PERSISTENT_GROUPS = 'litespeed-object_non_persistent_groups' ;
29
+ const ITEM_CRWL_AS_UIDS = 'litespeed-crawler-as-uids' ;
30
+ const ITEM_ADV_PURGE_ALL_HOOKS = 'litespeed-adv-purge_all_hooks' ;
31
+ const ITEM_CDN_ORI_DIR = 'litespeed-cdn-ori_dir' ;
32
+ const ITEM_MEDIA_WEBP_ATTRIBUTE = 'litespeed-media-webp_attribute' ;
33
+ const ITEM_FORCE_CACHE_URI = 'litespeed-forced_cache_uri' ;
34
+ const ITEM_CACHE_URI_PRIV = 'litespeed-cache_uri_priv' ;
35
+ const ITEM_OPTM_EXCLUDES = 'litespeed-optm_excludes' ;
36
+ const ITEM_EXCLUDES_URI = 'litespeed-excludes_uri' ;
37
+
38
+ const ITEM_SETTING_MODE = 'litespeed-setting-mode' ;
39
+ const ITEM_CRAWLER_HASH = 'litespeed-crawler-hash' ;
40
+ const ITEM_GUIDE = 'litespeed-guide' ; // Array of each guidance tag as key, step as val
41
+
42
+ // Server variables
43
+ const ENV_CRAWLER_USLEEP = 'CRAWLER_USLEEP' ;
44
+ const ENV_CRAWLER_LOAD_LIMIT = 'CRAWLER_LOAD_LIMIT' ;
45
+ const ENV_CRAWLER_LOAD_LIMIT_ENFORCE = 'CRAWLER_LOAD_LIMIT_ENFORCE' ;
46
+
47
+ // const ITEM_FAVICON = 'litespeed-cache-favicon' ;
48
+
49
+ const ITEM_CDN_MAPPING_URL = 'url' ;
50
+ const ITEM_CDN_MAPPING_INC_IMG = 'inc_img' ;
51
+ const ITEM_CDN_MAPPING_INC_CSS = 'inc_css' ;
52
+ const ITEM_CDN_MAPPING_INC_JS = 'inc_js' ;
53
+ const ITEM_CDN_MAPPING_FILETYPE = 'filetype' ;
54
+
55
+ const VAL_OFF = 0 ;
56
+ const VAL_ON = 1 ;
57
+ const VAL_ON2 = 2 ;
58
+
59
+ const LOG_LEVEL_NONE = 0 ;
60
+ const LOG_LEVEL_ERROR = 1 ;
61
+ const LOG_LEVEL_NOTICE = 2 ;
62
+ const LOG_LEVEL_INFO = 3 ;
63
+ const LOG_LEVEL_DEBUG = 4 ;
64
+ const OPID_VERSION = 'version' ;
65
+ const OPID_ENABLED_RADIO = 'radio_select' ;
66
+
67
+ const OPID_CACHE_PRIV = 'cache_priv' ;
68
+ const OPID_CACHE_COMMENTER = 'cache_commenter' ;
69
+ const OPID_CACHE_REST = 'cache_rest' ;
70
+ const OPID_CACHE_PAGE_LOGIN = 'cache_page_login' ;
71
+ const OPID_CACHE_FAVICON = 'cache_favicon' ;
72
+ const OPID_CACHE_RES = 'cache_resources' ;
73
+ const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
74
+ const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
75
+ const OPID_CACHE_OBJECT = 'cache_object' ;
76
+ const OPID_CACHE_OBJECT_KIND = 'cache_object_kind' ;
77
+ const OPID_CACHE_OBJECT_HOST = 'cache_object_host' ;
78
+ const OPID_CACHE_OBJECT_PORT = 'cache_object_port' ;
79
+ const OPID_CACHE_OBJECT_LIFE = 'cache_object_life' ;
80
+ const OPID_CACHE_OBJECT_PERSISTENT = 'cache_object_persistent' ;
81
+ const OPID_CACHE_OBJECT_ADMIN = 'cache_object_admin' ;
82
+ const OPID_CACHE_OBJECT_TRANSIENTS = 'cache_object_transients' ;
83
+ const OPID_CACHE_OBJECT_DB_ID = 'cache_object_db_id' ;
84
+ const OPID_CACHE_OBJECT_USER = 'cache_object_user' ;
85
+ const OPID_CACHE_OBJECT_PSWD = 'cache_object_pswd' ;
86
+ const OPID_CACHE_BROWSER = 'cache_browser' ;
87
+ const OPID_CACHE_BROWSER_TTL = 'cache_browser_ttl' ;
88
+
89
+ const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
90
+ const OPID_TIMED_URLS = 'timed_urls' ;
91
+ const OPID_TIMED_URLS_TIME = 'timed_urls_time' ;
92
+
93
+ const OPID_LOGIN_COOKIE = 'login_cookie' ;
94
+ const OPID_CHECK_ADVANCEDCACHE = 'check_advancedcache' ;
95
+ const OPID_USE_HTTP_FOR_HTTPS_VARY = 'use_http_for_https_vary' ;
96
+ // do NOT set default options for these three, it is used for admin.
97
+ const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
98
+ const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
99
+ const OPID_DEBUG_DISABLE_ALL = 'debug_disable_all' ;
100
+ const OPID_DEBUG = 'debug' ;
101
+ const OPID_ADMIN_IPS = 'admin_ips' ;
102
+ const OPID_DEBUG_LEVEL = 'debug_level' ;
103
+ const OPID_LOG_FILE_SIZE = 'log_file_size' ;
104
+ const OPID_HEARTBEAT = 'heartbeat' ;
105
+ const OPID_DEBUG_COOKIE = 'debug_cookie' ;
106
+ const OPID_COLLAPS_QS = 'collaps_qs' ;
107
+ const OPID_LOG_FILTERS = 'log_filters' ;
108
+
109
+ const OPID_PUBLIC_TTL = 'public_ttl' ;
110
+ const OPID_PRIVATE_TTL = 'private_ttl' ;
111
+ const OPID_FRONT_PAGE_TTL = 'front_page_ttl' ;
112
+ const OPID_FEED_TTL = 'feed_ttl' ;
113
+ const OPID_403_TTL = '403_ttl' ;
114
+ const OPID_404_TTL = '404_ttl' ;
115
+ const OPID_500_TTL = '500_ttl' ;
116
+ const OPID_PURGE_BY_POST = 'purge_by_post' ;
117
+ const OPID_ESI_ENABLE = 'esi_enabled' ;
118
+ const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
119
+ const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
120
+ const PURGE_ALL_PAGES = '-' ;
121
+ const PURGE_FRONT_PAGE = 'F' ;
122
+ const PURGE_HOME_PAGE = 'H' ;
123
+ const PURGE_PAGES = 'PGS' ;
124
+ const PURGE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
125
+ const PURGE_AUTHOR = 'A' ;
126
+ const PURGE_YEAR = 'Y' ;
127
+ const PURGE_MONTH = 'M' ;
128
+ const PURGE_DATE = 'D' ;
129
+ const PURGE_TERM = 'T' ; // include category|tag|tax
130
+ const PURGE_POST_TYPE = 'PT' ;
131
+
132
+ const OPID_EXCLUDES_QS = 'excludes_qs' ;
133
+ const OPID_EXCLUDES_CAT = 'excludes_cat' ;
134
+ const OPID_EXCLUDES_TAG = 'excludes_tag' ;
135
+
136
+ // const OPID_ADV_FAVICON = 'adv_favicon' ;
137
+ const OPID_ADV_INSTANT_CLICK = 'instant_click' ;
138
+
139
+ const OPID_CSS_MINIFY = 'css_minify' ;
140
+ const OPID_CSS_INLINE_MINIFY = 'css_inline_minify' ;
141
+ const OPID_CSS_COMBINE = 'css_combine' ;
142
+ const OPID_CSS_COMBINED_PRIORITY = 'css_combined_priority' ;
143
+ const OPID_CSS_HTTP2 = 'css_http2' ;
144
+ const OPID_CSS_EXCLUDES = 'css_exclude' ;
145
+ const OPID_JS_MINIFY = 'js_minify' ;
146
+ const OPID_JS_INLINE_MINIFY = 'js_inline_minify' ;
147
+ const OPID_JS_COMBINE = 'js_combine' ;
148
+ const OPID_JS_COMBINED_PRIORITY = 'js_combined_priority' ;
149
+ const OPID_JS_HTTP2 = 'js_http2' ;
150
+ const OPID_JS_EXCLUDES = 'js_exclude' ;
151
+ const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
152
+ const OPID_HTML_MINIFY = 'html_minify' ;
153
+ const OPID_OPTM_QS_RM = 'optm_qs_rm' ;
154
+ const OPID_OPTM_GGFONTS_RM = 'optm_ggfonts_rm' ;
155
+ const OPID_OPTM_CSS_ASYNC = 'optm_css_async' ;
156
+ const OPT_OPTM_CCSS_GEN = 'optm_ccss_gen' ;
157
+ const OPT_OPTM_CCSS_ASYNC = 'optm_ccss_async' ;
158
+ const OPT_OPTM_CSS_ASYNC_INLINE = 'optm_css_async_inline' ;
159
+ const OPID_OPTM_JS_DEFER = 'optm_js_defer' ;
160
+ const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
161
+ const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
162
+ const OPID_OPTM_GGFONTS_ASYNC = 'optm_ggfonts_async' ;
163
+ const OPID_OPTM_MAX_SIZE = 'optm_max_size' ;
164
+ const OPID_OPTM_RM_COMMENT = 'optm_rm_comment' ;
165
+
166
+ const OPID_CDN = 'cdn' ;
167
+ const OPID_CDN_ORI = 'cdn_ori' ;
168
+ const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
169
+ const OPID_CDN_REMOTE_JQUERY = 'cdn_remote_jquery' ;
170
+ const OPID_CDN_QUIC = 'cdn_quic' ;
171
+ const OPID_CDN_QUIC_EMAIL = 'cdn_quic_email' ;
172
+ const OPID_CDN_QUIC_KEY = 'cdn_quic_key' ;
173
+ const OPID_CDN_QUIC_SITE = 'cdn_quic_site' ;
174
+ const OPID_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
175
+ const OPID_CDN_CLOUDFLARE_EMAIL = 'cdn_cloudflare_email' ;
176
+ const OPID_CDN_CLOUDFLARE_KEY = 'cdn_cloudflare_key' ;
177
+ const OPID_CDN_CLOUDFLARE_NAME = 'cdn_cloudflare_name' ;
178
+ const OPID_CDN_CLOUDFLARE_ZONE = 'cdn_cloudflare_zone' ;
179
+
180
+ const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
181
+ const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
182
+ const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
183
+ const OPT_MEDIA_OPTM_AUTO = 'media_optm_auto' ;
184
+ const OPT_MEDIA_OPTM_CRON = 'media_optm_cron' ;
185
+ const OPT_MEDIA_OPTM_ORI = 'media_optm_ori' ;
186
+ const OPT_MEDIA_OPTM_WEBP = 'media_optm_webp' ;
187
+ const OPT_MEDIA_OPTM_LOSSLESS = 'media_optm_lossless' ;
188
+ const OPT_MEDIA_OPTM_EXIF = 'media_optm_exif' ;
189
+ const OPT_MEDIA_WEBP_REPLACE = 'media_webp_replace' ;
190
+ const OPT_MEDIA_WEBP_REPLACE_SRCSET = 'media_webp_replace_srcset' ;
191
+
192
+ const HASH = 'hash' ;
193
+
194
+ const NETWORK_OPID_ENABLED = 'network_enabled' ;
195
+ const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
196
+
197
+ const CRWL_POSTS = 'crawler_include_posts' ;
198
+ const CRWL_PAGES = 'crawler_include_pages' ;
199
+ const CRWL_CATS = 'crawler_include_cats' ;
200
+ const CRWL_TAGS = 'crawler_include_tags' ;
201
+ const CRWL_EXCLUDES_CPT = 'crawler_excludes_cpt' ;
202
+ const CRWL_ORDER_LINKS = 'crawler_order_links' ;
203
+ const CRWL_USLEEP = 'crawler_usleep' ;
204
+ const CRWL_RUN_DURATION = 'crawler_run_duration' ;
205
+ const CRWL_RUN_INTERVAL = 'crawler_run_interval' ;
206
+ const CRWL_CRAWL_INTERVAL = 'crawler_crawl_interval' ;
207
+ const CRWL_THREADS = 'crawler_threads' ;
208
+ const CRWL_LOAD_LIMIT = 'crawler_load_limit' ;
209
+ const CRWL_DOMAIN_IP = 'crawler_domain_ip' ;
210
+ const CRWL_CUSTOM_SITEMAP = 'crawler_custom_sitemap' ;
211
+
212
+ const CRWL_CRON_ACTIVE = 'crawler_cron_active' ;
213
+
214
+ const CRWL_DATE_DESC = 'date_desc' ;
215
+ const CRWL_DATE_ASC = 'date_asc' ;
216
+ const CRWL_ALPHA_DESC = 'alpha_desc' ;
217
+ const CRWL_ALPHA_ASC = 'alpha_asc' ;
218
+
219
+ /**
220
+ * Get the items in wp_options that need for backup
221
+ *
222
+ * @since 2.2.1
223
+ * @access public
224
+ */
225
+ public function stored_items()
226
+ {
227
+ return array(
228
+ self::OPTION_NAME,
229
+ self::VARY_GROUP,
230
+ self::EXCLUDE_OPTIMIZATION_ROLES,
231
+ self::EXCLUDE_CACHE_ROLES,
232
+ self::ITEM_OPTM_CSS,
233
+ self::ITEM_OPTM_JS_DEFER_EXC,
234
+ self::ITEM_MEDIA_LAZY_IMG_EXC,
235
+ self::ITEM_IMG_OPTM_NEED_PULL,
236
+ self::ITEM_ENV_REF,
237
+ self::ITEM_CACHE_DROP_QS,
238
+ self::ITEM_CDN_MAPPING,
239
+ self::ITEM_DNS_PREFETCH,
240
+ self::ITEM_CLOUDFLARE_STATUS,
241
+ self::ITEM_LOG_IGNORE_FILTERS,
242
+ self::ITEM_LOG_IGNORE_PART_FILTERS,
243
+ self::ITEM_OBJECT_GLOBAL_GROUPS,
244
+ self::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
245
+ self::ITEM_CRWL_AS_UIDS,
246
+ self::ITEM_ADV_PURGE_ALL_HOOKS,
247
+ self::ITEM_FORCE_CACHE_URI,
248
+ self::ITEM_CACHE_URI_PRIV,
249
+ self::ITEM_OPTM_EXCLUDES,
250
+ self::ITEM_EXCLUDES_URI,
251
+ ) ;
252
+ }
253
+
254
+ /**
255
+ * Get default item val
256
+ *
257
+ * @since 1.8
258
+ * @access public
259
+ */
260
+ public function default_item( $k )
261
+ {
262
+ switch ( $k ) {
263
+ case self::ITEM_OBJECT_GLOBAL_GROUPS :
264
+ return "users\nuserlogins\nusermeta\nuser_meta\nsite-transient\nsite-options\nsite-lookup\nblog-lookup\nblog-details\nrss\nglobal-posts\nblog-id-cache" ;
265
+
266
+ case self::ITEM_OBJECT_NON_PERSISTENT_GROUPS :
267
+ return "comment\ncounts\nplugins" ;
268
+
269
+ case self::ITEM_ADV_PURGE_ALL_HOOKS :
270
+ return "switch_theme\nwp_create_nav_menu\nwp_update_nav_menu\nwp_delete_nav_menu\ncreate_term\nedit_terms\ndelete_term\nadd_link\nedit_link\ndelete_link" ;
271
+
272
+ case self::ITEM_CDN_ORI_DIR :
273
+ return LSCWP_CONTENT_FOLDER . "\nwp-includes\n/min/" ;
274
+
275
+ case self::ITEM_MEDIA_WEBP_ATTRIBUTE :
276
+ return "img.src\n" .
277
+ "div.data-thumb\n" .
278
+ "img.data-src\n" .
279
+ "div.data-large_image\n" .
280
+ "img.retina_logo_url" ;
281
+
282
+ default :
283
+ break ;
284
+ }
285
+
286
+ return false ;
287
+ }
288
+
289
+ /**
290
+ * Gets the default network options
291
+ *
292
+ * @since 1.0.11
293
+ * @access protected
294
+ * @return array An array of the default options.
295
+ */
296
+ protected function get_default_site_options()
297
+ {
298
+ $default_site_options = array(
299
+ self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
300
+ self::NETWORK_OPID_ENABLED => false,
301
+ self::NETWORK_OPID_USE_PRIMARY => false,
302
+ self::OPID_PURGE_ON_UPGRADE => true,
303
+ self::OPID_CACHE_FAVICON => true,
304
+ self::OPID_CACHE_RES => true,
305
+ self::OPID_CACHE_MOBILE => 0, // todo: why not false
306
+ self::ID_MOBILEVIEW_LIST => false,
307
+ self::OPID_CACHE_OBJECT => false,
308
+ self::OPID_CACHE_OBJECT_KIND => false,
309
+ self::OPID_CACHE_OBJECT_HOST => 'localhost',
310
+ self::OPID_CACHE_OBJECT_PORT => '11211',
311
+ self::OPID_CACHE_OBJECT_LIFE => '360',
312
+ self::OPID_CACHE_OBJECT_PERSISTENT => true,
313
+ self::OPID_CACHE_OBJECT_ADMIN => true,
314
+ self::OPID_CACHE_OBJECT_TRANSIENTS => true,
315
+ self::OPID_CACHE_OBJECT_DB_ID => 0,
316
+ self::OPID_CACHE_OBJECT_USER => '',
317
+ self::OPID_CACHE_OBJECT_PSWD => '',
318
+ self::OPID_CACHE_BROWSER => false,
319
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
320
+ self::OPID_LOGIN_COOKIE => '',
321
+ self::OPID_CHECK_ADVANCEDCACHE => true,
322
+ self::ID_NOCACHE_COOKIES => '',
323
+ self::ID_NOCACHE_USERAGENTS => '',
324
+ self::OPT_MEDIA_WEBP_REPLACE => false,
325
+ ) ;
326
+ return $default_site_options ;
327
+ }
328
+
329
+ /**
330
+ * Gets the default single site options
331
+ *
332
+ * @since 1.0.0
333
+ * @access public
334
+ * @param bool $include_thirdparty Whether to include the thirdparty options.
335
+ * @return array An array of the default options.
336
+ */
337
+ public function get_default_options($include_thirdparty = true)
338
+ {
339
+ $default_purge_options = array(
340
+ self::PURGE_FRONT_PAGE,
341
+ self::PURGE_HOME_PAGE,
342
+ self::PURGE_PAGES,
343
+ self::PURGE_PAGES_WITH_RECENT_POSTS,
344
+ self::PURGE_AUTHOR,
345
+ self::PURGE_MONTH,
346
+ self::PURGE_TERM,
347
+ self::PURGE_POST_TYPE,
348
+ ) ;
349
+ sort($default_purge_options) ;
350
+
351
+ //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
352
+ if ( is_multisite() ) {
353
+ $default_radio = 2 ;
354
+ }
355
+ else {
356
+ $default_radio = 1 ;
357
+ }
358
+
359
+ $default_options = array(
360
+ self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
361
+ self::OPID_ENABLED_RADIO => $default_radio,
362
+ self::OPID_PURGE_ON_UPGRADE => true,
363
+ self::OPID_CACHE_PRIV => true,
364
+ self::OPID_CACHE_COMMENTER => true,
365
+ self::OPID_CACHE_REST => true,
366
+ self::OPID_CACHE_PAGE_LOGIN => true,
367
+ self::OPID_TIMED_URLS => '',
368
+ self::OPID_TIMED_URLS_TIME => '',
369
+ self::OPID_CACHE_FAVICON => true,
370
+ self::OPID_CACHE_RES => true,
371
+ self::OPID_CACHE_MOBILE => false,
372
+ self::ID_MOBILEVIEW_LIST => false,
373
+ self::OPID_CACHE_OBJECT => false,
374
+ self::OPID_CACHE_OBJECT_KIND => false,
375
+ self::OPID_CACHE_OBJECT_HOST => 'localhost',
376
+ self::OPID_CACHE_OBJECT_PORT => '11211',
377
+ self::OPID_CACHE_OBJECT_LIFE => '360',
378
+ self::OPID_CACHE_OBJECT_PERSISTENT => true,
379
+ self::OPID_CACHE_OBJECT_ADMIN => true,
380
+ self::OPID_CACHE_OBJECT_TRANSIENTS => true,
381
+ self::OPID_CACHE_OBJECT_DB_ID => 0,
382
+ self::OPID_CACHE_OBJECT_USER => '',
383
+ self::OPID_CACHE_OBJECT_PSWD => '',
384
+ self::OPID_CACHE_BROWSER => false,
385
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
386
+
387
+ self::OPID_LOGIN_COOKIE => '',
388
+ self::OPID_CHECK_ADVANCEDCACHE => true,
389
+ self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
390
+ self::OPID_DEBUG_DISABLE_ALL => false,
391
+ self::OPID_DEBUG => self::LOG_LEVEL_NONE,
392
+ self::OPID_ADMIN_IPS => '127.0.0.1',
393
+ self::OPID_DEBUG_LEVEL => false,
394
+ self::OPID_LOG_FILE_SIZE => 3,
395
+ self::OPID_HEARTBEAT => true,
396
+ self::OPID_DEBUG_COOKIE => false,
397
+ self::OPID_COLLAPS_QS => false,
398
+ self::OPID_LOG_FILTERS => false,
399
+ self::OPID_PUBLIC_TTL => 604800,
400
+ self::OPID_PRIVATE_TTL => 1800,
401
+ self::OPID_FRONT_PAGE_TTL => 604800,
402
+ self::OPID_FEED_TTL => 0,
403
+ self::OPID_403_TTL => 3600,
404
+ self::OPID_404_TTL => 3600,
405
+ self::OPID_500_TTL => 3600,
406
+ self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
407
+ self::OPID_EXCLUDES_QS => '',
408
+ self::OPID_EXCLUDES_CAT => '',
409
+ self::OPID_EXCLUDES_TAG => '',
410
+
411
+ // self::OPID_ADV_FAVICON => false,
412
+ self::OPID_ADV_INSTANT_CLICK => false,
413
+
414
+ self::OPID_CSS_MINIFY => false,
415
+ self::OPID_CSS_INLINE_MINIFY => false,
416
+ self::OPID_CSS_COMBINE => false,
417
+ self::OPID_CSS_COMBINED_PRIORITY => false,
418
+ self::OPID_CSS_HTTP2 => false,
419
+ self::OPID_CSS_EXCLUDES => '',
420
+ self::OPID_JS_MINIFY => false,
421
+ self::OPID_JS_INLINE_MINIFY => false,
422
+ self::OPID_JS_COMBINE => false,
423
+ self::OPID_JS_COMBINED_PRIORITY => false,
424
+ self::OPID_JS_HTTP2 => false,
425
+ self::OPID_JS_EXCLUDES => '',
426
+ self::OPID_OPTIMIZE_TTL => 604800,
427
+ self::OPID_HTML_MINIFY => false,
428
+ self::OPID_OPTM_QS_RM => false,
429
+ self::OPID_OPTM_GGFONTS_RM => false,
430
+ self::OPID_OPTM_CSS_ASYNC => false,
431
+ self::OPT_OPTM_CCSS_GEN => true,
432
+ self::OPT_OPTM_CCSS_ASYNC => true,
433
+ self::OPT_OPTM_CSS_ASYNC_INLINE => true,
434
+ self::OPID_OPTM_JS_DEFER => false,
435
+ self::OPID_OPTM_EMOJI_RM => false,
436
+ self::OPID_OPTM_EXC_JQUERY => true,
437
+ self::OPID_OPTM_GGFONTS_ASYNC => false,
438
+ self::OPID_OPTM_MAX_SIZE => 1.2,
439
+ self::OPID_OPTM_RM_COMMENT => false,
440
+
441
+ self::OPID_CDN => false,
442
+ self::OPID_CDN_ORI => '',
443
+ self::OPID_CDN_EXCLUDE => '',
444
+ self::OPID_CDN_REMOTE_JQUERY => false,
445
+ self::OPID_CDN_QUIC => false,
446
+ self::OPID_CDN_QUIC_EMAIL => '',
447
+ self::OPID_CDN_QUIC_KEY => '',
448
+ self::OPID_CDN_QUIC_SITE => '',
449
+ self::OPID_CDN_CLOUDFLARE => false,
450
+ self::OPID_CDN_CLOUDFLARE_EMAIL => '',
451
+ self::OPID_CDN_CLOUDFLARE_KEY => '',
452
+ self::OPID_CDN_CLOUDFLARE_NAME => '',
453
+ self::OPID_CDN_CLOUDFLARE_ZONE => '',
454
+
455
+ self::OPID_MEDIA_IMG_LAZY => false,
456
+ self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
457
+ self::OPID_MEDIA_IFRAME_LAZY => false,
458
+ self::OPT_MEDIA_OPTM_AUTO => false,
459
+ self::OPT_MEDIA_OPTM_CRON => true,
460
+ self::OPT_MEDIA_OPTM_ORI => true,
461
+ self::OPT_MEDIA_OPTM_WEBP => false,
462
+ self::OPT_MEDIA_OPTM_LOSSLESS => false,
463
+ self::OPT_MEDIA_OPTM_EXIF => false,
464
+ self::OPT_MEDIA_WEBP_REPLACE => false,
465
+ self::OPT_MEDIA_WEBP_REPLACE_SRCSET => false,
466
+
467
+ self::HASH => '',
468
+
469
+ self::ID_NOCACHE_COOKIES => '',
470
+ self::ID_NOCACHE_USERAGENTS => '',
471
+ self::CRWL_POSTS => true,
472
+ self::CRWL_PAGES => true,
473
+ self::CRWL_CATS => true,
474
+ self::CRWL_TAGS => true,
475
+ self::CRWL_EXCLUDES_CPT => '',
476
+ self::CRWL_ORDER_LINKS => self::CRWL_DATE_DESC,
477
+ self::CRWL_USLEEP => 500,
478
+ self::CRWL_RUN_DURATION => 400,
479
+ self::CRWL_RUN_INTERVAL => 600,
480
+ self::CRWL_CRAWL_INTERVAL => 302400,
481
+ self::CRWL_THREADS => 3,
482
+ self::CRWL_LOAD_LIMIT => 1,
483
+ self::CRWL_DOMAIN_IP => '',
484
+ self::CRWL_CUSTOM_SITEMAP => '',
485
+ self::CRWL_CRON_ACTIVE => false,
486
+ ) ;
487
+
488
+ if ( LSWCP_ESI_SUPPORT ) {
489
+ $default_options[self::OPID_ESI_ENABLE] = false ;
490
+ $default_options[self::OPID_ESI_CACHE_ADMBAR] = true ;
491
+ $default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
492
+ }
493
+
494
+ if ( ! $include_thirdparty ) {
495
+ return $default_options ;
496
+ }
497
+
498
+ $tp_options = $this->get_thirdparty_options($default_options) ;
499
+ if ( ! isset($tp_options) || ! is_array($tp_options) ) {
500
+ return $default_options ;
501
+ }
502
+ return array_merge($default_options, $tp_options) ;
503
+ }
504
+
505
+
506
+ /**
507
+ * Gets the third party options.
508
+ * Will also strip the options that are actually normal options.
509
+ *
510
+ * @access public
511
+ * @since 1.0.9
512
+ * @param array $options Optional. The default options to compare against.
513
+ * @return mixed boolean on failure, array of keys on success.
514
+ */
515
+ public function get_thirdparty_options($options = null)
516
+ {
517
+ $tp_options = apply_filters('litespeed_cache_get_options', array()) ;
518
+ if ( empty($tp_options) ) {
519
+ return false ;
520
+ }
521
+ if ( ! isset($options) ) {
522
+ $options = $this->get_default_options(false) ;
523
+ }
524
+ return array_diff_key($tp_options, $options) ;
525
+ }
526
+
527
+ }
inc/crawler.class.php CHANGED
@@ -488,7 +488,7 @@ class LiteSpeed_Cache_Crawler
488
$roles = $roles ? explode( "\n", $roles ) : array() ;
489
490
// WebP on/off
491
- $webp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ) ;
492
493
if ( $count_only ) {
494
$count = count( $roles ) + 1 ;
488
$roles = $roles ? explode( "\n", $roles ) : array() ;
489
490
// WebP on/off
491
+ $webp = LiteSpeed_Cache_Media::webp_enabled() ;
492
493
if ( $count_only ) {
494
$count = count( $roles ) + 1 ;
inc/img_optm.class.php CHANGED
@@ -609,10 +609,11 @@ class LiteSpeed_Cache_Img_Optm
609
private function _push_img_in_queue_to_iapi()
610
{
611
$data = array(
612
- 'list' => $this->_img_in_queue,
613
- 'webp_only' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ),
614
- 'keep_exif' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF ),
615
- 'webp_lossless' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS ),
616
) ;
617
618
// Push to LiteSpeed IAPI server
@@ -747,7 +748,7 @@ class LiteSpeed_Cache_Img_Optm
747
* @since 1.6
748
* @access private
749
*/
750
- private function _pull_optimized_img()
751
{
752
if ( $this->cron_running() ) {
753
LiteSpeed_Cache_Log::debug( '[Img_Optm] fetch cron is running' ) ;
@@ -762,10 +763,13 @@ class LiteSpeed_Cache_Img_Optm
762
WHERE a.root_id = 0 AND a.optm_status = %s ORDER BY a.id LIMIT 1" ;
763
$_q = $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_SIZE, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ) ;
764
765
- $webp_only = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ) ;
766
767
- // pull 10 images each time
768
- for ( $i=0 ; $i < 10 ; $i++ ) {
769
$row_img = $wpdb->get_row( $_q ) ;
770
if ( ! $row_img ) {
771
// No image
@@ -797,71 +801,25 @@ class LiteSpeed_Cache_Img_Optm
797
'src_md5' => $row_img->src_md5,
798
) ;
799
$json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG, $data, $server, true ) ;
800
- if ( empty( $json[ 'webp' ] ) ) {
801
LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: ', $json ) ;
802
return ;
803
}
804
805
$local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $row_img->src ;
806
807
- /**
808
- * Use wp orignal get func to avoid allow_url_open off issue
809
- * @since 1.6.5
810
- */
811
- // Fetch webp image
812
- $response = wp_remote_get( $json[ 'webp' ], array( 'timeout' => 15 ) ) ;
813
- if ( is_wp_error( $response ) ) {
814
- $error_message = $response->get_error_message() ;
815
- LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
816
- return ;
817
- }
818
-
819
- file_put_contents( $local_file . '.webp', $response[ 'body' ] ) ;
820
-
821
- if ( ! file_exists( $local_file . '.webp' ) ) {
822
- return ;
823
- }
824
-
825
- // Unknown issue
826
- if ( md5_file( $local_file . '.webp' ) !== $json[ 'webp_md5' ] ) {
827
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img WebP: file md5 dismatch, server md5: ' . $json[ 'webp_md5' ] ) ;
828
-
829
- // update status to failed
830
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
831
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
832
- // Update child images
833
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE root_id = %d " ;
834
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
835
-
836
- // Notify server to update status
837
- LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server, true ) ;
838
-
839
- return ;// exit from running pull process
840
- }
841
-
842
- $ori_size = $row_img->src_filesize ?: filesize( $local_file ) ;
843
-
844
- // log webp file saved size summary
845
- $webp_size = filesize( $local_file . '.webp' ) ;
846
- $webp_saved = $ori_size - $webp_size ;
847
- if ( $webp_saved > 0 ) {
848
- $optm_info[ 'webp_total' ] += $ori_size ;
849
- $optm_info[ 'webp_saved' ] += $webp_saved ;
850
- }
851
- else {
852
- $webp_saved = 0 ;
853
- }
854
-
855
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
856
-
857
- // Fetch optimized image itself
858
$target_size = 0 ;
859
$target_saved = 0 ;
860
- if ( ! $webp_only && ! empty( $json[ 'target_file' ] ) ) {
861
-
862
- // Fetch failed, unkown issue, return
863
- // NOTE: if this failed more than 5 times, next time fetching webp will touch err limit on server side, whole image will be failed
864
- $response = wp_remote_get( $json[ 'target_file' ], array( 'timeout' => 15 ) ) ;
865
if ( is_wp_error( $response ) ) {
866
$error_message = $response->get_error_message() ;
867
LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
@@ -869,9 +827,9 @@ class LiteSpeed_Cache_Img_Optm
869
}
870
871
file_put_contents( $local_file . '.tmp', $response[ 'body' ] ) ;
872
- // Unknown issue
873
- if ( md5_file( $local_file . '.tmp' ) !== $json[ 'target_md5' ] ) {
874
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img iteself: file md5 dismatch, server md5: ' . $json[ 'target_md5' ] ) ;
875
876
// update status to failed
877
$q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
@@ -886,17 +844,6 @@ class LiteSpeed_Cache_Img_Optm
886
return ; // exit from running pull process
887
}
888
889
- // log webp file saved size summary
890
- $target_size = filesize( $local_file . '.tmp' ) ;
891
- $target_saved = $ori_size - $target_size ;
892
- if ( $target_saved > 0 ) {
893
- $optm_info[ 'ori_total' ] += $ori_size ;
894
- $optm_info[ 'ori_saved' ] += $target_saved ;
895
- }
896
- else {
897
- $target_saved = 0 ;
898
- }
899
-
900
// Backup ori img
901
$extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
902
$bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
@@ -906,6 +853,49 @@ class LiteSpeed_Cache_Img_Optm
906
rename( $local_file . '.tmp', $local_file ) ;
907
908
LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img: ' . $local_file ) ;
909
}
910
911
LiteSpeed_Cache_Log::debug2( '[Img_Optm] Update _table_img_optm record [id] ' . $row_img->id ) ;
@@ -914,7 +904,7 @@ class LiteSpeed_Cache_Img_Optm
914
$q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, target_saved = %d, webp_filesize = %d, webp_saved = %d WHERE id = %d " ;
915
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $target_saved, $webp_size, $webp_saved, $row_img->id ) ) ) ;
916
917
- // Update child images
918
$q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, target_saved = %d, webp_filesize = %d, webp_saved = %d WHERE root_id = %d " ;
919
$child_count = $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $target_saved, $webp_size, $webp_saved, $row_img->id ) ) ) ;
920
@@ -975,6 +965,9 @@ class LiteSpeed_Cache_Img_Optm
975
$wpdb->query( $wpdb->prepare( $q, $pids_data_to_insert ) ) ;
976
}
977
}
978
}
979
980
// Update guidance
@@ -1358,6 +1351,9 @@ class LiteSpeed_Cache_Img_Optm
1358
private function _update_credit( $credit )
1359
{
1360
$summary = get_option( self::DB_IMG_OPTM_SUMMARY, array() ) ;
1361
$summary[ 'credit' ] = $credit ;
1362
1363
update_option( self::DB_IMG_OPTM_SUMMARY, $summary ) ;
@@ -1640,6 +1636,8 @@ class LiteSpeed_Cache_Img_Optm
1640
}
1641
1642
LiteSpeed_Cache_Log::debug( '[Img_Optm] batch switched images total: ' . $i ) ;
1643
1644
}
1645
609
private function _push_img_in_queue_to_iapi()
610
{
611
$data = array(
612
+ 'list' => $this->_img_in_queue,
613
+ 'optm_ori' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ? 1 : 0,
614
+ 'optm_webp' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ? 1 : 0,
615
+ 'optm_lossless' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS ) ? 1 : 0,
616
+ 'keep_exif' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF ) ? 1 : 0,
617
) ;
618
619
// Push to LiteSpeed IAPI server
748
* @since 1.6
749
* @access private
750
*/
751
+ private function _pull_optimized_img( $manual = false )
752
{
753
if ( $this->cron_running() ) {
754
LiteSpeed_Cache_Log::debug( '[Img_Optm] fetch cron is running' ) ;
763
WHERE a.root_id = 0 AND a.optm_status = %s ORDER BY a.id LIMIT 1" ;
764
$_q = $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_SIZE, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ) ;
765
766
+ $optm_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ;
767
+ $optm_webp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ;
768
769
+ // pull 1min images each time
770
+ $end_time = time() + ( $manual ? 120 : 60 ) ;
771
+
772
+ while ( time() < $end_time ) {
773
$row_img = $wpdb->get_row( $_q ) ;
774
if ( ! $row_img ) {
775
// No image
801
'src_md5' => $row_img->src_md5,
802
) ;
803
$json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG, $data, $server, true ) ;
804
+
805
+ // Check if data interrupt or not
806
+ if ( empty( $json[ 'ok' ] ) ) {
807
LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: ', $json ) ;
808
return ;
809
}
810
811
$local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $row_img->src ;
812
813
+ // Save ori optm image
814
$target_size = 0 ;
815
$target_saved = 0 ;
816
+ if ( ! empty( $json[ 'ori' ] ) ) {
817
+ /**
818
+ * Use wp orignal get func to avoid allow_url_open off issue
819
+ * @since 1.6.5
820
+ */
821
+ // Fetch
822
+ $response = wp_remote_get( $json[ 'ori' ], array( 'timeout' => 15 ) ) ;
823
if ( is_wp_error( $response ) ) {
824
$error_message = $response->get_error_message() ;
825
LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
827
}
828
829
file_put_contents( $local_file . '.tmp', $response[ 'body' ] ) ;
830
+
831
+ if ( ! file_exists( $local_file . '.tmp' ) || md5_file( $local_file . '.tmp' ) !== $json[ 'ori_md5' ] ) {
832
+ LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: file md5 dismatch, server md5: ' . $json[ 'ori_md5' ] ) ;
833
834
// update status to failed
835
$q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
844
return ; // exit from running pull process
845
}
846
847
// Backup ori img
848
$extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
849
$bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
853
rename( $local_file . '.tmp', $local_file ) ;
854
855
LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img: ' . $local_file ) ;
856
+
857
+ $optm_info[ 'ori_total' ] += $json[ 'src_size' ] ;
858
+ $optm_info[ 'ori_saved' ] += $json[ 'ori_reduced' ] ;
859
+ $target_size = filesize( $local_file ) ;
860
+ $target_saved = $json[ 'ori_reduced' ] ;
861
+ }
862
+
863
+ // Save webp image
864
+ $webp_size = 0 ;
865
+ $webp_saved = 0 ;
866
+ if ( ! empty( $json[ 'webp' ] ) ) {
867
+ // Fetch
868
+ $response = wp_remote_get( $json[ 'webp' ], array( 'timeout' => 15 ) ) ;
869
+ if ( is_wp_error( $response ) ) {
870
+ $error_message = $response->get_error_message() ;
871
+ LiteSpeed_Cache_Log::debug( 'IAPI failed to pull webp image: ' . $error_message ) ;
872
+ return ;
873
+ }
874
+
875
+ file_put_contents( $local_file . '.webp', $response[ 'body' ] ) ;
876
+
877
+ if ( ! file_exists( $local_file . '.webp' ) || md5_file( $local_file . '.webp' ) !== $json[ 'webp_md5' ] ) {
878
+ LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized webp img: file md5 dismatch, server md5: ' . $json[ 'webp_md5' ] ) ;
879
+
880
+ // update status to failed
881
+ $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
882
+ $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
883
+ // Update child images
884
+ $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE root_id = %d " ;
885
+ $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
886
+
887
+ // Notify server to update status
888
+ LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server, true ) ;
889
+
890
+ return ; // exit from running pull process
891
+ }
892
+
893
+ LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
894
+
895
+ $optm_info[ 'webp_total' ] += $json[ 'src_size' ] ;
896
+ $optm_info[ 'webp_saved' ] += $json[ 'webp_reduced' ] ;
897
+ $webp_size = filesize( $local_file . '.webp' ) ;
898
+ $webp_saved = $json[ 'webp_reduced' ] ;
899
}
900
901
LiteSpeed_Cache_Log::debug2( '[Img_Optm] Update _table_img_optm record [id] ' . $row_img->id ) ;
904
$q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, target_saved = %d, webp_filesize = %d, webp_saved = %d WHERE id = %d " ;
905
$wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $target_saved, $webp_size, $webp_saved, $row_img->id ) ) ) ;
906
907
+ // Update child images ( same md5 files )
908
$q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, target_saved = %d, webp_filesize = %d, webp_saved = %d WHERE root_id = %d " ;
909
$child_count = $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $target_saved, $webp_size, $webp_saved, $row_img->id ) ) ) ;
910
965
$wpdb->query( $wpdb->prepare( $q, $pids_data_to_insert ) ) ;
966
}
967
}
968
+
969
+ // Recover credit
970
+ $this->_update_credit( '++' ) ;
971
}
972
973
// Update guidance
1351
private function _update_credit( $credit )
1352
{
1353
$summary = get_option( self::DB_IMG_OPTM_SUMMARY, array() ) ;
1354
+ if ( $credit === '++' ) {
1355
+ $credit = $summary[ 'credit' ] + 1 ;
1356
+ }
1357
$summary[ 'credit' ] = $credit ;
1358
1359
update_option( self::DB_IMG_OPTM_SUMMARY, $summary ) ;
1636
}
1637
1638
LiteSpeed_Cache_Log::debug( '[Img_Optm] batch switched images total: ' . $i ) ;
1639
+ $msg = __( 'Switched images successfully.', 'litespeed-cache' ) ;
1640
+ LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
1641
1642
}
1643
inc/litespeed-cache.class.php CHANGED
@@ -19,7 +19,7 @@ class LiteSpeed_Cache
19
private static $_instance ;
20
21
const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '2.3.1' ;
23
24
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
19
private static $_instance ;
20
21
const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '2.4' ;
23
24
const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
inc/litespeed.autoload.php CHANGED
@@ -30,6 +30,7 @@ if ( !function_exists('_litespeed_autoload') ) {
30
'LiteSpeed_Cache_CDN_Quiccloud' => 'inc/cdn/quiccloud.class.php',
31
'LiteSpeed_Cache_Config' => 'inc/config.class.php',
32
'LiteSpeed_Cache_Control' => 'inc/control.class.php',
33
'LiteSpeed_Cache_Crawler' => 'inc/crawler.class.php',
34
'LiteSpeed_Cache_Crawler_Sitemap' => 'inc/crawler-sitemap.class.php',
35
'LiteSpeed_Cache_CSS' => 'inc/css.cls.php',
30
'LiteSpeed_Cache_CDN_Quiccloud' => 'inc/cdn/quiccloud.class.php',
31
'LiteSpeed_Cache_Config' => 'inc/config.class.php',
32
'LiteSpeed_Cache_Control' => 'inc/control.class.php',
33
+ 'LiteSpeed_Cache_Const' => 'inc/const.cls.php',
34
'LiteSpeed_Cache_Crawler' => 'inc/crawler.class.php',
35
'LiteSpeed_Cache_Crawler_Sitemap' => 'inc/crawler-sitemap.class.php',
36
'LiteSpeed_Cache_CSS' => 'inc/css.cls.php',
inc/media.class.php CHANGED
@@ -36,7 +36,7 @@ class LiteSpeed_Cache_Media
36
if ( $this->can_media() ) {
37
$this->_static_request_check() ;
38
39
- $this->cfg_img_webp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ) ;
40
41
// Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
42
if ( $this->cfg_img_webp ) {
@@ -78,6 +78,17 @@ class LiteSpeed_Cache_Media
78
return true ;
79
}
80
81
/**
82
* Register admin menu
83
*
@@ -556,7 +567,7 @@ class LiteSpeed_Cache_Media
556
557
// parse srcset
558
// todo: should apply this to cdn too
559
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_REPLACE_SRCSET ) ) {
560
$this->content = LiteSpeed_Cache_Utility::srcset_replace( $this->content, array( $this, 'replace_webp' ) ) ;
561
}
562
36
if ( $this->can_media() ) {
37
$this->_static_request_check() ;
38
39
+ $this->cfg_img_webp = self::webp_enabled() ;
40
41
// Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
42
if ( $this->cfg_img_webp ) {
78
return true ;
79
}
80
81
+ /**
82
+ * Check if enabled webp or not
83
+ *
84
+ * @since 2.4
85
+ * @access public
86
+ */
87
+ public static function webp_enabled()
88
+ {
89
+ return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ) ;
90
+ }
91
+
92
/**
93
* Register admin menu
94
*
567
568
// parse srcset
569
// todo: should apply this to cdn too
570
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET ) ) {
571
$this->content = LiteSpeed_Cache_Utility::srcset_replace( $this->content, array( $this, 'replace_webp' ) ) ;
572
}
573
inc/task.class.php CHANGED
@@ -39,7 +39,7 @@ class LiteSpeed_Cache_Task
39
}
40
41
// Register img optimization fetch ( always fetch immediately )
42
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF ) && LiteSpeed_Cache_Img_Optm::check_need_pull() ) {
43
self::schedule_filter_imgoptm() ;
44
45
add_action( self::CRON_ACTION_HOOK_IMGOPTM, 'LiteSpeed_Cache_Img_Optm::pull_optimized_img' ) ;
39
}
40
41
// Register img optimization fetch ( always fetch immediately )
42
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON ) && LiteSpeed_Cache_Img_Optm::check_need_pull() ) {
43
self::schedule_filter_imgoptm() ;
44
45
add_action( self::CRON_ACTION_HOOK_IMGOPTM, 'LiteSpeed_Cache_Img_Optm::pull_optimized_img' ) ;
includes/litespeed-cache-config.class.php CHANGED
@@ -10,215 +10,10 @@
10
* @subpackage LiteSpeed_Cache/inc
11
* @author LiteSpeed Technologies <info@litespeedtech.com>
12
*/
13
- class LiteSpeed_Cache_Config
14
{
15
private static $_instance ;
16
17
- const OPTION_NAME = 'litespeed-cache-conf' ;
18
- const VARY_GROUP = 'litespeed-cache-vary-group' ;
19
- const EXCLUDE_OPTIMIZATION_ROLES = 'litespeed-cache-exclude-optimization-roles' ;
20
- const EXCLUDE_CACHE_ROLES = 'litespeed-cache-exclude-cache-roles' ;
21
- const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
22
- const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
23
- const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
24
- const ITEM_IMG_OPTM_NEED_PULL = 'litespeed-media-need-pull' ;
25
- const ITEM_ENV_REF = 'litespeed-env-ref' ;
26
- const ITEM_CACHE_DROP_QS = 'litespeed-cache-drop_qs' ;
27
- const ITEM_CDN_MAPPING = 'litespeed-cache-cdn_mapping' ;
28
- const ITEM_DNS_PREFETCH = 'litespeed-cache-dns_prefetch' ;
29
- const ITEM_CLOUDFLARE_STATUS = 'litespeed-cache-cloudflare_status' ;
30
- const ITEM_LOG_IGNORE_FILTERS = 'litespeed-log_ignore_filters' ;
31
- const ITEM_LOG_IGNORE_PART_FILTERS = 'litespeed-log_ignore_part_filters' ;
32
- const ITEM_OBJECT_GLOBAL_GROUPS = 'litespeed-object_global_groups' ;
33
- const ITEM_OBJECT_NON_PERSISTENT_GROUPS = 'litespeed-object_non_persistent_groups' ;
34
- const ITEM_CRWL_AS_UIDS = 'litespeed-crawler-as-uids' ;
35
- const ITEM_ADV_PURGE_ALL_HOOKS = 'litespeed-adv-purge_all_hooks' ;
36
- const ITEM_CDN_ORI_DIR = 'litespeed-cdn-ori_dir' ;
37
- const ITEM_MEDIA_WEBP_ATTRIBUTE = 'litespeed-media-webp_attribute' ;
38
- const ITEM_FORCE_CACHE_URI = 'litespeed-forced_cache_uri' ;
39
- const ITEM_CACHE_URI_PRIV = 'litespeed-cache_uri_priv' ;
40
- const ITEM_OPTM_EXCLUDES = 'litespeed-optm_excludes' ;
41
- const ITEM_EXCLUDES_URI = 'litespeed-excludes_uri' ;
42
-
43
- const ITEM_SETTING_MODE = 'litespeed-setting-mode' ;
44
- const ITEM_CRAWLER_HASH = 'litespeed-crawler-hash' ;