LiteSpeed Cache - Version 1.6.7

Version Description

  • December 15 2017 =
  • [IAPI] Added ability to scan for new image thumbnail sizes and auto-resend image optimization requests.
  • [IAPI] Added ability to destroy all optimization data.
  • [IAPI] Updated IAPI to v1.6.7.
  • [INTEGRATION] Fixed certain 3rd party plugins calling REST without user nonce causing logged in users to be served as guest.
Download this release

Release Info

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

Code changes from version 1.5 to 1.6.7

Files changed (83) hide show
  1. admin/admin-api.class.php +214 -78
  2. admin/litespeed-cache-admin-display.class.php +62 -34
  3. admin/litespeed-cache-admin-optimize.class.php +4 -7
  4. admin/litespeed-cache-admin-report.class.php +87 -22
  5. admin/litespeed-cache-admin-rules.class.php +45 -24
  6. admin/litespeed-cache-admin-settings.class.php +36 -1
  7. admin/litespeed-cache-admin.class.php +3 -1
  8. admin/tpl/crawler.php +5 -10
  9. admin/tpl/debug_log.php +5 -0
  10. admin/tpl/edit_htaccess.php +1 -3
  11. admin/tpl/image_optimization.php +206 -0
  12. admin/tpl/inc/admin_footer.php +1 -1
  13. admin/tpl/inc/api_key.php +14 -0
  14. admin/tpl/inc/banner_promo.php +1 -1
  15. admin/tpl/info.php +0 -42
  16. admin/tpl/info/info_admin_ip.php +0 -33
  17. admin/tpl/info/info_common_rewrite.php +0 -58
  18. admin/tpl/info/info_compatibility.php +0 -57
  19. admin/tpl/info/info_config.php +0 -68
  20. admin/tpl/info/info_crawler.php +0 -67
  21. admin/tpl/info/info_faqs.php +0 -110
  22. admin/tpl/manage/manage_purge.php +4 -4
  23. admin/tpl/network_settings.php +1 -0
  24. admin/tpl/report.php +27 -27
  25. admin/tpl/setting/network_settings_media.php +10 -0
  26. admin/tpl/setting/settings_debug.php +2 -2
  27. admin/tpl/setting/settings_esi.php +0 -8
  28. admin/tpl/setting/settings_excludes.php +19 -4
  29. admin/tpl/setting/settings_general.php +1 -1
  30. admin/tpl/setting/settings_inc.cache_browser.php +12 -0
  31. admin/tpl/setting/settings_inc.media_webp.php +18 -0
  32. admin/tpl/setting/settings_media.php +50 -0
  33. admin/tpl/setting/settings_optimize.php +1 -106
  34. admin/tpl/setting/settings_tuning.php +178 -0
  35. admin/tpl/settings.php +13 -0
  36. cli/litespeed-cache-cli-admin.class.php +14 -0
  37. css/litespeed.css +131 -17
  38. img/icons/img_optm.svg +52 -0
  39. img/icons/img_optm_disabled.svg +52 -0
  40. img/icons/img_webp.svg +34 -0
  41. img/icons/img_webp_disabled.svg +34 -0
  42. inc/api.class.php +57 -2
  43. inc/cdn.class.php +36 -6
  44. inc/config.class.php +84 -4
  45. inc/control.class.php +38 -1
  46. inc/crawler.class.php +1 -1
  47. inc/gui.class.php +106 -5
  48. inc/litespeed-cache.class.php +61 -35
  49. inc/log.class.php +55 -6
  50. inc/media.class.php +1623 -28
  51. inc/optimize.class.php +148 -84
  52. inc/purge.class.php +7 -2
  53. inc/router.class.php +138 -80
  54. inc/tag.class.php +16 -0
  55. inc/task.class.php +100 -16
  56. inc/utility.class.php +194 -10
  57. inc/vary.class.php +159 -65
  58. includes/litespeed-cache-api.class.php +57 -2
  59. includes/litespeed-cache-cdn.class.php +36 -6
  60. includes/litespeed-cache-config.class.php +84 -4
  61. includes/litespeed-cache-control.class.php +38 -1
  62. includes/litespeed-cache-crawler.class.php +1 -1
  63. includes/litespeed-cache-gui.class.php +106 -5
  64. includes/litespeed-cache-log.class.php +55 -6
  65. includes/litespeed-cache-optimize.class.php +148 -84
  66. includes/litespeed-cache-purge.class.php +7 -2
  67. includes/litespeed-cache-router.class.php +138 -80
  68. includes/litespeed-cache-tag.class.php +16 -0
  69. includes/litespeed-cache-task.class.php +100 -16
  70. includes/litespeed-cache-utility.class.php +194 -10
  71. includes/litespeed-cache-vary.class.php +159 -65
  72. includes/litespeed-cache.class.php +61 -35
  73. js/lazyload.lib.js +1 -1
  74. js/lazyload.min.js +1 -1
  75. js/litespeed-cache-admin.js +0 -7
  76. languages/litespeed-cache.pot +757 -873
  77. litespeed-cache.php +1 -1
  78. readme.txt +127 -18
  79. thirdparty/lscwp-3rd-contact-form-7.cls.php +46 -0
  80. thirdparty/lscwp-3rd-login-with-ajax.cls.php +35 -0
  81. thirdparty/lscwp-3rd-woocommerce.cls.php +228 -74
  82. thirdparty/lscwp-3rd-wplister.cls.php +2 -2
  83. thirdparty/lscwp-registry-3rd.php +2 -0
admin/admin-api.class.php CHANGED
@@ -11,16 +11,24 @@ class LiteSpeed_Cache_Admin_API
11
  {
12
  private static $_instance ;
13
 
14
- private $_sapi_key ;
15
 
16
- const DB_SAPI_KEY = 'litespeed_sapi_key' ;
17
- const DB_SAPI_SERVER = 'litespeed_sapi_server' ;
18
- const DB_SAPI_KEY_HASH = 'litespeed_sapi_key_hash' ;
19
 
20
- const ACTION_REQUEST_KEY = 'request_key' ;
21
- const ACTION_REQUEST_KEY_CALLBACK = 'request_key_callback' ;
 
 
 
22
 
23
- const SAPI_ACTION_REQUEST_KEY = 'request_key' ;
 
 
 
 
 
 
24
 
25
  /**
26
  * Init
@@ -30,64 +38,75 @@ class LiteSpeed_Cache_Admin_API
30
  */
31
  private function __construct()
32
  {
33
- $this->_sapi_key = get_option( self::DB_SAPI_KEY ) ;
34
  }
35
 
36
-
37
  /**
38
- * Handle callback requests from LiteSpeed server
39
  *
40
- * @since 1.5
 
41
  * @access public
42
  */
43
- public static function sapi_callback()
44
  {
45
- if ( empty( $_GET[ 'type' ] ) ) {
46
- LiteSpeed_Cache_Log::debug( 'SAPI callback no type ' ) ;
47
- return ;
48
- }
49
- LiteSpeed_Cache_Log::debug( 'SAPI callback type: ' . $_GET[ 'type' ] ) ;
50
-
51
  $instance = self::get_instance() ;
52
 
53
- switch ( $_GET[ 'type' ] ) {
54
- case self::ACTION_REQUEST_KEY_CALLBACK :
55
- $instance->_request_key_callback() ;
 
 
 
 
 
 
 
 
 
56
  break ;
57
 
58
  default:
59
  break ;
60
  }
61
 
62
-
63
  }
64
 
65
  /**
66
- * Handle local request
67
  *
68
- * @since 1.5
69
  * @access public
70
- * @return string The msg shown in admin page
71
  */
72
- public static function sapi_proceed()
73
  {
74
- if ( empty( $_GET[ 'type' ] ) ) {
75
- return ;
 
76
  }
 
77
 
78
- LiteSpeed_Cache_Log::debug( 'SAPI proceed type: ' . $_GET[ 'type' ] ) ;
79
-
 
 
 
 
 
 
80
  $instance = self::get_instance() ;
81
 
82
- switch ( $_GET[ 'type' ] ) {
83
- case self::ACTION_REQUEST_KEY :
84
- return $instance->_request_key() ;
85
  break ;
86
 
87
  default:
88
  break ;
89
  }
90
 
 
91
  }
92
 
93
  /**
@@ -96,13 +115,87 @@ class LiteSpeed_Cache_Admin_API
96
  * @since 1.5
97
  * @access private
98
  */
99
- private function _request_key_callback()
100
  {
101
- $key_hash = get_transient( self::DB_SAPI_KEY_HASH ) ;
102
- LiteSpeed_Cache_Log::debug( 'SAPI callback request key hash: ' . $key_hash ) ;
103
  exit( $key_hash ) ;
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  /**
107
  * request key from LiteSpeed
108
  *
@@ -110,77 +203,120 @@ class LiteSpeed_Cache_Admin_API
110
  * @access private
111
  */
112
  private function _request_key()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  {
114
  $hash = Litespeed_String::rrand( 16 ) ;
115
  // store hash
116
- set_transient( self::DB_SAPI_KEY_HASH, $hash, 300 ) ;
 
 
 
 
 
 
 
 
117
 
118
- // send the request
119
- $url = 'https://wp.api.litespeedtech.com/' . self::SAPI_ACTION_REQUEST_KEY ;
120
  $param = array(
 
 
121
  'hash' => $hash,
122
- 'callback' => home_url(),
123
  ) ;
124
- $response = wp_remote_post( $url, array( 'body' => $param ) ) ;
 
 
 
 
125
 
126
  if ( is_wp_error( $response ) ) {
127
  $error_message = $response->get_error_message() ;
128
- LiteSpeed_Cache_Log::debug( 'SAPI failed to send request' ) ;
129
- return ;
130
  }
131
 
132
  // parse data from server
133
- set_error_handler( 'litespeed_exception_handler' ) ;
134
- try {
135
- $json = json_decode( $response[ 'body' ], true ) ;
 
 
136
  }
137
- catch ( ErrorException $e ) {
138
- LiteSpeed_Cache_Log::debug( 'SAPI failed to decode json: ' . $response[ 'body' ] ) ;
139
- return ;
 
 
 
 
140
  }
141
- restore_error_handler() ;
142
 
143
- if ( empty( $json[ 'auth_key' ] ) || empty( $json[ 'distribute_server' ] ) ) {
144
- LiteSpeed_Cache_Log::debug( 'SAPI failed to get key and server: ' . $response[ 'body' ] ) ;
145
- return ;
 
 
 
146
  }
147
 
148
- // store data into option locally
149
- update_option( self::DB_SAPI_KEY, $json[ 'auth_key' ] ) ;
150
- update_option( self::DB_SAPI_SERVER, $json[ 'distribute_server' ] ) ;
151
- LiteSpeed_Cache_Log::debug( 'SAPI distribute server: ' . $json[ 'distribute_server' ] ) ;
 
 
 
152
 
153
- return __( 'Generate the key from server successfully', 'litespeed-cache' ) ;
154
  }
155
 
156
  /**
157
- * Check if the get token is correct with server api key
158
  *
159
- * @since 1.5
160
- * @access public
161
- * @return bool True if correct
162
  */
163
- public static function sapi_token_check()
164
  {
165
- if ( empty( $_GET[ 'token' ] ) ) {
166
- LiteSpeed_Cache_Log::debug( 'SAPI bypassed token check' ) ;
167
- return false ;
168
- }
169
- $instance = self::get_instance() ;
170
 
171
- // don't have auth_key yet
172
- if ( ! $instance->_sapi_key ) {
173
- // use tmp hash to check
174
- $key_hash = get_transient( self::DB_SAPI_KEY_HASH ) ;
175
- $res = md5( $key_hash ) === $_GET[ 'token' ] ;
176
 
177
- LiteSpeed_Cache_Log::debug( 'SAPI token init check ' . $key_hash . ': ' . ( $res ? 'passed' : 'failed' ) ) ;
178
- return $res ;
179
  }
180
 
181
- $res = md5( $instance->_sapi_key ) === $_GET[ 'token' ] ;
182
- LiteSpeed_Cache_Log::debug( 'SAPI token check: ' . ( $res ? 'passed' : 'failed' ) ) ;
183
- return $res ;
184
  }
185
 
186
  /**
11
  {
12
  private static $_instance ;
13
 
14
+ private $_iapi_key ;
15
 
16
+ const DB_API_KEY = 'litespeed_api_key' ;
17
+ const DB_API_KEY_HASH = 'litespeed_api_key_hash' ;
 
18
 
19
+ // For each request, send a callback to confirm
20
+ const TYPE_REQUEST_CALLBACK = 'request_callback' ;
21
+ const TYPE_NOTIFY_IMG = 'notify_img' ;
22
+ const TYPE_CHECK_IMG = 'check_img' ;
23
+ const TYPE_IMG_DESTROY_CALLBACK = 'imgoptm_destroy' ;
24
 
25
+ const IAPI_ACTION_REQUEST_KEY = 'request_key' ;
26
+ const IAPI_ACTION_MEDIA_SYNC_DATA = 'media_sync_data' ;
27
+ const IAPI_ACTION_REQUEST_OPTIMIZE = 'request_optimize' ;
28
+ const IAPI_ACTION_PULL_IMG = 'client_pull' ;
29
+ const IAPI_ACTION_PULL_IMG_FAILED = 'client_pull_failed' ;
30
+ const IAPI_ACTION_REQUEST_DESTROY = 'imgoptm_destroy' ;
31
+ const IAPI_ACTION_ENV_REPORT = 'env_report' ;
32
 
33
  /**
34
  * Init
38
  */
39
  private function __construct()
40
  {
41
+ $this->_iapi_key = get_option( self::DB_API_KEY ) ?: '' ;
42
  }
43
 
 
44
  /**
45
+ * Handle aggressive callback requests from LiteSpeed image server
46
  *
47
+ * @since 1.6
48
+ * @since 1.6.7 Added destroy callback
49
  * @access public
50
  */
51
+ public static function sapi_aggressive_callback()
52
  {
 
 
 
 
 
 
53
  $instance = self::get_instance() ;
54
 
55
+ switch ( LiteSpeed_Cache_Router::verify_type() ) {
56
+ case self::TYPE_NOTIFY_IMG :
57
+ LiteSpeed_Cache_Media::get_instance()->notify_img() ;
58
+ break ;
59
+
60
+ case self::TYPE_CHECK_IMG :
61
+ $instance->validate_lsserver() ;
62
+ LiteSpeed_Cache_Media::get_instance()->check_img() ;
63
+ break ;
64
+
65
+ case self::TYPE_IMG_DESTROY_CALLBACK :
66
+ LiteSpeed_Cache_Media::get_instance()->img_optimize_destroy_callback() ;
67
  break ;
68
 
69
  default:
70
  break ;
71
  }
72
 
73
+ exit ;
74
  }
75
 
76
  /**
77
+ * Validate litespeed api server IP
78
  *
79
+ * @since 1.6.5
80
  * @access public
 
81
  */
82
+ public function validate_lsserver()
83
  {
84
+ $ip = gethostbyname( 'wp.api.litespeedtech.com' ) ;
85
+ if ( $ip != LiteSpeed_Cache_Router::get_ip() ) {
86
+ exit( 'wrong ip' ) ;
87
  }
88
+ }
89
 
90
+ /**
91
+ * Handle passive callback requests from LiteSpeed image server
92
+ *
93
+ * @since 1.6
94
+ * @access public
95
+ */
96
+ public static function sapi_passive_callback()
97
+ {
98
  $instance = self::get_instance() ;
99
 
100
+ switch ( LiteSpeed_Cache_Router::verify_type() ) {
101
+ case self::TYPE_REQUEST_CALLBACK :
102
+ $instance->_request_callback() ;
103
  break ;
104
 
105
  default:
106
  break ;
107
  }
108
 
109
+ exit ;
110
  }
111
 
112
  /**
115
  * @since 1.5
116
  * @access private
117
  */
118
+ private function _request_callback()
119
  {
120
+ $key_hash = get_option( self::DB_API_KEY_HASH ) ;
121
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback request hash: ' . $key_hash ) ;
122
  exit( $key_hash ) ;
123
  }
124
 
125
+ /**
126
+ * Check if is valid callback from litespeed passive request
127
+ *
128
+ * @since 1.5
129
+ * @access public
130
+ * @return bool True if correct
131
+ */
132
+ public static function sapi_valiate_passive_callback()
133
+ {
134
+ if ( empty( $_REQUEST[ 'hash' ] ) ) {
135
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback bypassed passive check' ) ;
136
+ return false ;
137
+ }
138
+ $instance = self::get_instance() ;
139
+
140
+ // use tmp hash to check
141
+ $key_hash = get_option( self::DB_API_KEY_HASH ) ;
142
+ $hash_check = md5( $key_hash ) === $_REQUEST[ 'hash' ] ;
143
+
144
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback hash check ' . $key_hash . ': ' . ( $hash_check ? 'passed' : 'failed' ) ) ;
145
+
146
+ return $hash_check ;
147
+ }
148
+
149
+ /**
150
+ * Check if is valid callback from litespeed aggressive request
151
+ *
152
+ * @since 1.6
153
+ * @access public
154
+ * @return bool True if correct
155
+ */
156
+ public static function sapi_validate_aggressive_callback()
157
+ {
158
+ $instance = self::get_instance() ;
159
+
160
+ // don't have auth_key yet
161
+ if ( ! $instance->_iapi_key ) {
162
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback aggressive check failed: No init key' ) ;
163
+ return false ;
164
+ }
165
+
166
+ // Once client has auth_key, each time when callback to check, need to carry on this key
167
+ if ( empty( $_REQUEST[ 'auth_key' ] ) ) {
168
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback aggressive check failed: lack of auth_key' ) ;
169
+ return false ;
170
+ }
171
+
172
+ $res = md5( $instance->_iapi_key ) === $_REQUEST[ 'auth_key' ] ;
173
+ LiteSpeed_Cache_Log::debug( 'IAPI __callback aggressive auth_key check: ' . ( $res ? 'passed' : 'failed' ) ) ;
174
+ return $res ;
175
+ }
176
+
177
+ /**
178
+ * Post data to LiteSpeed image server
179
+ *
180
+ * @since 1.6
181
+ * @access public
182
+ * @param array $data
183
+ */
184
+ public static function post( $action, $data = false, $server = false )
185
+ {
186
+ $instance = self::get_instance() ;
187
+
188
+ /**
189
+ * All requests must have api_key first
190
+ * @since 1.6.5
191
+ */
192
+ if ( ! $instance->_iapi_key ) {
193
+ $instance->_request_key() ;
194
+ }
195
+
196
+ return $instance->_post( $action, $data, $server ) ;
197
+ }
198
+
199
  /**
200
  * request key from LiteSpeed
201
  *
203
  * @access private
204
  */
205
  private function _request_key()
206
+ {
207
+ // Send request to LiteSpeed
208
+ $json = $this->_post( self::IAPI_ACTION_REQUEST_KEY, home_url() ) ;
209
+
210
+ // Check if get key&server correctly
211
+ if ( empty( $json[ 'auth_key' ] ) ) {
212
+ LiteSpeed_Cache_Log::debug( 'IAPI request key failed: ', $json ) ;
213
+ $msg = sprintf( __( 'IAPI Error %s', 'litespeed-cache' ), $json ) ;
214
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
215
+ return ;
216
+ }
217
+
218
+ // store data into option locally
219
+ update_option( self::DB_API_KEY, $json[ 'auth_key' ] ) ;
220
+ LiteSpeed_Cache_Log::debug( 'IAPI applied auth_key' ) ;
221
+
222
+ $this->_iapi_key = $json[ 'auth_key' ] ;
223
+
224
+ }
225
+
226
+ /**
227
+ * Post data to LiteSpeed image server
228
+ *
229
+ * @since 1.6
230
+ * @access private
231
+ * @param array $data
232
+ */
233
+ private function _post( $action, $data = false, $server = false )
234
  {
235
  $hash = Litespeed_String::rrand( 16 ) ;
236
  // store hash
237
+ update_option( self::DB_API_KEY_HASH, $hash ) ;
238
+
239
+ if ( $server == false ) {
240
+ $server = 'https://wp.api.litespeedtech.com' ;
241
+ }
242
+
243
+ $url = $server . '/' . $action ;
244
+
245
+ LiteSpeed_Cache_Log::debug( 'IAPI posting to : ' . $url ) ;
246
 
 
 
247
  $param = array(
248
+ 'auth_key' => $this->_iapi_key,
249
+ 'v' => LiteSpeed_Cache::PLUGIN_VERSION,
250
  'hash' => $hash,
251
+ 'data' => $data,
252
  ) ;
253
+ /**
254
+ * Extended timeout to avoid cUrl 28 timeout issue as we need callback validation
255
+ * @since 1.6.4
256
+ */
257
+ $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => 15 ) ) ;
258
 
259
  if ( is_wp_error( $response ) ) {
260
  $error_message = $response->get_error_message() ;
261
+ LiteSpeed_Cache_Log::debug( 'IAPI failed to post: ' . $error_message ) ;
262
+ return $error_message ;
263
  }
264
 
265
  // parse data from server
266
+ $json = json_decode( $response[ 'body' ], true ) ;
267
+
268
+ if ( ! is_array( $json ) ) {
269
+ LiteSpeed_Cache_Log::debug( 'IAPI failed to decode post json: ' . $response[ 'body' ] ) ;
270
+ return $response[ 'body' ] ;
271
  }
272
+
273
+ if ( ! empty( $json[ '_err' ] ) ) {
274
+ LiteSpeed_Cache_Log::debug( 'IAPI _err: ' . $json[ '_err' ] ) ;
275
+ $msg = __( 'Failed to communicate with LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_err' ] ;
276
+ $msg .= $this->_parse_link( $json ) ;
277
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
278
+ return null ;
279
  }
 
280
 
281
+ if ( ! empty( $json[ '_info' ] ) ) {
282
+ LiteSpeed_Cache_Log::debug( 'IAPI _info: ' . $json[ '_info' ] ) ;
283
+ $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_info' ] ;
284
+ $msg .= $this->_parse_link( $json ) ;
285
+ LiteSpeed_Cache_Admin_Display::info( $msg ) ;
286
+ unset( $json[ '_info' ] ) ;
287
  }
288
 
289
+ if ( ! empty( $json[ '_note' ] ) ) {
290
+ LiteSpeed_Cache_Log::debug( 'IAPI _note: ' . $json[ '_note' ] ) ;
291
+ $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_note' ] ;
292
+ $msg .= $this->_parse_link( $json ) ;
293
+ LiteSpeed_Cache_Admin_Display::note( $msg ) ;
294
+ unset( $json[ '_note' ] ) ;
295
+ }
296
 
297
+ return $json ;
298
  }
299
 
300
  /**
301
+ * Parse _links from json
302
  *
303
+ * @since 1.6.5
304
+ * @since 1.6.7 Self clean the parameter
305
+ * @access private
306
  */
307
+ private function _parse_link( &$json )
308
  {
309
+ $msg = '' ;
 
 
 
 
310
 
311
+ if ( ! empty( $json[ '_links' ] ) ) {
312
+ foreach ( $json[ '_links' ] as $v ) {
313
+ $msg .= ' ' . sprintf( '<a href="%s" class="%s" target="_blank">%s</a>', $v[ 'link' ], ! empty( $v[ 'cls' ] ) ? $v[ 'cls' ] : '', $v[ 'title' ] ) ;
314
+ }
 
315
 
316
+ unset( $json[ '_links' ] ) ;
 
317
  }
318
 
319
+ return $msg ;
 
 
320
  }
321
 
322
  /**
admin/litespeed-cache-admin-display.class.php CHANGED
@@ -145,15 +145,10 @@ class LiteSpeed_Cache_Admin_Display
145
  $this->add_submenu(__('Edit .htaccess', 'litespeed-cache'), LiteSpeed_Cache::PAGE_EDIT_HTACCESS, 'show_menu_edit_htaccess') ;
146
  }
147
 
148
- $this->add_submenu(__('Information', 'litespeed-cache'), 'lscache-info', 'show_info') ;
149
-
150
  if ( ! is_network_admin() ) {
151
- // $this->add_submenu(__('Image Optimization', 'litespeed-cache'), 'lscache-optimization', 'show_optimization') ;
152
  $this->add_submenu(__('Crawler', 'litespeed-cache'), 'lscache-crawler', 'show_crawler') ;
153
- }
154
-
155
- if ( ! is_multisite() || is_network_admin() ) {
156
- $this->add_submenu(__('Environment Report', 'litespeed-cache'), 'lscache-report', 'show_report') ;
157
  }
158
 
159
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
@@ -201,18 +196,18 @@ class LiteSpeed_Cache_Admin_Display
201
  wp_register_script( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false ) ;
202
 
203
  $localize_data = array() ;
204
- if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
205
- $ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS_WHM, LiteSpeed_Cache::ACTION_DISMISS_WHM ) ;
206
  $localize_data[ 'ajax_url_dismiss_whm' ] = $ajax_url_dismiss_whm ;
207
  }
208
 
209
- if ( LiteSpeed_Cache_Router::has_msg_ruleconflict() ) {
210
- $ajax_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT, LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT ) ;
211
  $localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
212
  }
213
 
214
- if ( LiteSpeed_Cache_Router::has_promo_msg() ) {
215
- $ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS_PROMO, LiteSpeed_Cache::ACTION_DISMISS_PROMO ) ;
216
  $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
217
  }
218
 
@@ -436,6 +431,50 @@ class LiteSpeed_Cache_Admin_Display
436
  self::add_notice(self::NOTICE_RED, $error) ;
437
  }
438
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
439
  /**
440
  * Adds a notice to display on the admin page. Multiple messages of the
441
  * same color may be added in a single call. If the list is empty, this
@@ -602,22 +641,6 @@ class LiteSpeed_Cache_Admin_Display
602
  require_once LSWCP_DIR . 'admin/tpl/debug_log.php' ;
603
  }
604
 
605
- /**
606
- * Outputs the html for the info page.
607
- *
608
- * This page includes three tabs:
609
- * - configuration
610
- * - third party plugin compatibilities
611
- * - common rewrite rules.
612
- *
613
- * @since 1.1.0
614
- * @access public
615
- */
616
- public function show_info()
617
- {
618
- require_once LSWCP_DIR . 'admin/tpl/info.php' ;
619
- }
620
-
621
  /**
622
  * Outputs a notice to the admin panel when the plugin is installed
623
  * via the WHM plugin.
@@ -760,14 +783,19 @@ class LiteSpeed_Cache_Admin_Display
760
  * @param string $title
761
  * @param bool $checked
762
  */
763
- public function build_checkbox($id, $title, $checked, $is_mini = false)
764
  {
765
  $checked = $checked ? ' checked ' : '' ;
766
- $is_mini = $is_mini ? ' litespeed-mini ' : '' ;
767
 
768
- echo "<div class='litespeed-tick $is_mini'>
769
- <label for='conf_$id'>$title</label>
770
- <input type='checkbox' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' id='conf_$id' value='1' $checked />
 
 
 
 
 
 
771
  </div>" ;
772
  }
773
 
145
  $this->add_submenu(__('Edit .htaccess', 'litespeed-cache'), LiteSpeed_Cache::PAGE_EDIT_HTACCESS, 'show_menu_edit_htaccess') ;
146
  }
147
 
 
 
148
  if ( ! is_network_admin() ) {
149
+ $this->add_submenu(__('Image Optimization', 'litespeed-cache'), 'lscache-optimization', 'show_optimization') ;
150
  $this->add_submenu(__('Crawler', 'litespeed-cache'), 'lscache-crawler', 'show_crawler') ;
151
+ $this->add_submenu(__('Report', 'litespeed-cache'), 'lscache-report', 'show_report') ;
 
 
 
152
  }
153
 
154
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
196
  wp_register_script( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false ) ;
197
 
198
  $localize_data = array() ;
199
+ if ( LiteSpeed_Cache_GUI::has_whm_msg() ) {
200
+ $ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_WHM, true ) ;
201
  $localize_data[ 'ajax_url_dismiss_whm' ] = $ajax_url_dismiss_whm ;
202
  }
203
 
204
+ if ( LiteSpeed_Cache_GUI::has_msg_ruleconflict() ) {
205
+ $ajax_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_EXPIRESDEFAULT, true ) ;
206
  $localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
207
  }
208
 
209
+ if ( LiteSpeed_Cache_GUI::has_promo_msg() ) {
210
+ $ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true ) ;
211
  $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
212
  }
213
 
431
  self::add_notice(self::NOTICE_RED, $error) ;
432
  }
433
 
434
+ /**
435
+ * Display info notice
436
+ *
437
+ * @since 1.6.5
438
+ * @access public
439
+ */
440
+ public static function info( $msg )
441
+ {
442
+ self::add_notice( self::NOTICE_BLUE, $msg ) ;
443
+ }
444
+
445
+ /**
446
+ * Display note notice
447
+ *
448
+ * @since 1.6.5
449
+ * @access public
450
+ */
451
+ public static function note( $msg )
452
+ {
453
+ self::add_notice( self::NOTICE_YELLOW, $msg ) ;
454
+ }
455
+
456
+ /**
457
+ * Display success notice
458
+ *
459
+ * @since 1.6
460
+ * @access public
461
+ */
462
+ public static function succeed( $msg )
463
+ {
464
+ self::add_notice( self::NOTICE_GREEN, $msg ) ;
465
+ }
466
+
467
+ /**
468
+ * Display error notice
469
+ *
470
+ * @since 1.6
471
+ * @access public
472
+ */
473
+ public static function error( $msg )
474
+ {
475
+ self::add_notice( self::NOTICE_RED, $msg ) ;
476
+ }
477
+
478
  /**
479
  * Adds a notice to display on the admin page. Multiple messages of the
480
  * same color may be added in a single call. If the list is empty, this
641
  require_once LSWCP_DIR . 'admin/tpl/debug_log.php' ;
642
  }
643
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
644
  /**
645
  * Outputs a notice to the admin panel when the plugin is installed
646
  * via the WHM plugin.
783
  * @param string $title
784
  * @param bool $checked
785
  */
786
+ public function build_checkbox($id, $title, $checked, $value = 1 )
787
  {
788
  $checked = $checked ? ' checked ' : '' ;
 
789
 
790
+ $label_id = str_replace( array( '[', ']' ), '_', $id ) ;
791
+
792
+ if ( $value !== 1 ) {
793
+ $label_id .= '_' . $value ;
794
+ }
795
+
796
+ echo "<div class='litespeed-tick'>
797
+ <label for='conf_$label_id'>$title</label>
798
+ <input type='checkbox' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' id='conf_$label_id' value='$value' $checked />
799
  </div>" ;
800
  }
801
 
admin/litespeed-cache-admin-optimize.class.php CHANGED
@@ -10,9 +10,6 @@
10
  */
11
  class LiteSpeed_Cache_Admin_Optimize
12
  {
13
-
14
- const TYPE = 'ls_opt_type' ;
15
-
16
  private static $_types = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients' ) ;
17
 
18
  /**
@@ -25,7 +22,7 @@ class LiteSpeed_Cache_Admin_Optimize
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
 
@@ -37,7 +34,7 @@ class LiteSpeed_Cache_Admin_Optimize
37
  */
38
  public static function run_db_clean()
39
  {
40
- if( empty( $_GET[ self::TYPE ] ) ) {
41
  return ;
42
  }
43
 
@@ -47,12 +44,12 @@ class LiteSpeed_Cache_Admin_Optimize
47
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
48
  foreach ( $blogs as $blog_id ) {
49
  switch_to_blog( $blog_id ) ;
50
- $res = self::db_clean( $_GET[ self::TYPE ] ) ;
51
  restore_current_blog() ;
52
  }
53
  }
54
  else {
55
- $res = self::db_clean( $_GET[ self::TYPE ] ) ;
56
  }
57
 
58
  return $res ;
10
  */
11
  class LiteSpeed_Cache_Admin_Optimize
12
  {
 
 
 
13
  private static $_types = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients' ) ;
14
 
15
  /**
22
  */
23
  public static function generate_url( $type )
24
  {
25
+ $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DB_OPTIMIZE, $type ) ;
26
  return $url ;
27
  }
28
 
34
  */
35
  public static function run_db_clean()
36
  {
37
+ if( ! $type = LiteSpeed_Cache_Router::verify_type() ) {
38
  return ;
39
  }
40
 
44
  $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
45
  foreach ( $blogs as $blog_id ) {
46
  switch_to_blog( $blog_id ) ;
47
+ $res = self::db_clean( $type ) ;
48
  restore_current_blog() ;
49
  }
50
  }
51
  else {
52
+ $res = self::db_clean( $type ) ;
53
  }
54
 
55
  return $res ;
admin/litespeed-cache-admin-report.class.php CHANGED
@@ -11,7 +11,88 @@
11
  */
12
  class LiteSpeed_Cache_Admin_Report
13
  {
14
- private static $_instance;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  /**
17
  * Gathers the environment details and creates the report.
@@ -53,6 +134,9 @@ class LiteSpeed_Cache_Admin_Report
53
 
54
  $extras = array(
55
  'wordpress version' => $wp_version,
 
 
 
56
  'locale' => get_locale(),
57
  'active theme' => $active_theme,
58
  'active plugins' => $active_plugins,
@@ -74,28 +158,9 @@ class LiteSpeed_Cache_Admin_Report
74
  }
75
 
76
  $report = $this->build_environment_report($_SERVER, $options, $extras, $paths) ;
77
- $this->write_environment_report($report) ;
78
  return $report ;
79
  }
80
 
81
- /**
82
- * Write the environment report to the report location.
83
- *
84
- * @since 1.0.12
85
- * @access private
86
- * @param string $content What to write to the environment report.
87
- */
88
- private function write_environment_report( $content )
89
- {
90
- $content = "<" . "?php die() ; ?" . ">\n\n" . $content ;
91
-
92
- $ret = Litespeed_File::save( LSWCP_DIR . 'environment_report.php', $content, false, false, false ) ;
93
-
94
- if ( $ret !== true && LiteSpeed_Cache_Log::get_enabled() ) {
95
- LiteSpeed_Cache_Log::push( $ret ) ;
96
- }
97
- }
98
-
99
  /**
100
  * Builds the environment report buffer with the given parameters
101
  *
@@ -119,10 +184,10 @@ class LiteSpeed_Cache_Admin_Report
119
 
120
  $buf = $this->format_report_section('Server Variables', $server_vars) ;
121
 
122
- $buf .= $this->format_report_section('LSCache Plugin Options', $options) ;
123
-
124
  $buf .= $this->format_report_section('Wordpress Specific Extras', $extras) ;
125
 
 
 
126
  if ( empty($htaccess_paths) ) {
127
  return $buf ;
128
  }
11
  */
12
  class LiteSpeed_Cache_Admin_Report
13
  {
14
+ private static $_instance ;
15
+
16
+ const TYPE_SEND_REPORT = 'send_report' ;
17
+
18
+ /**
19
+ * Handle all request actions from main cls
20
+ *
21
+ * @since 1.6.5
22
+ * @access public
23
+ */
24
+ public static function handler()
25
+ {
26
+ $instance = self::get_instance() ;
27
+
28
+ $type = LiteSpeed_Cache_Router::verify_type() ;
29
+
30
+ switch ( $type ) {
31
+
32
+ case self::TYPE_SEND_REPORT :
33
+ $instance->_post_env() ;
34
+ break ;
35
+
36
+ default:
37
+ break ;
38
+ }
39
+
40
+ LiteSpeed_Cache_Admin::redirect() ;
41
+ }
42
+
43
+ /**
44
+ * post env report number to ls center server
45
+ *
46
+ * @since 1.6.5
47
+ * @access private
48
+ */
49
+ private function _post_env()
50
+ {
51
+ $report_con = $this->generate_environment_report() ;
52
+ $data = array(
53
+ 'env' => $report_con,
54
+ ) ;
55
+
56
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_ENV_REPORT, LiteSpeed_Cache_Utility::arr2str( $data ) ) ;
57
+
58
+ if ( ! is_array( $json ) ) {
59
+ LiteSpeed_Cache_Log::debug( 'Env: Failed to post to LiteSpeed server ', $json ) ;
60
+ $msg = sprintf( __( 'Failed to push to LiteSpeed server: %s', 'litespeed-cache' ), $json ) ;
61
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
62
+ return ;
63
+ }
64
+
65
+ $data = array(
66
+ 'num' => ! empty( $json[ 'num' ] ) ? $json[ 'num' ] : '--',
67
+ 'dateline' => time(),
68
+ ) ;
69
+
70
+ update_option( LiteSpeed_Cache_Config::ITEM_ENV_REF, $data ) ;
71
+
72
+ }
73
+
74
+ /**
75
+ * Get env report number from db
76
+ *
77
+ * @since 1.6.4
78
+ * @access public
79
+ * @return array
80
+ */
81
+ public function get_env_ref()
82
+ {
83
+ $info = get_option( LiteSpeed_Cache_Config::ITEM_ENV_REF ) ;
84
+
85
+ if ( ! is_array( $info ) ) {
86
+ return array(
87
+ 'num' => '-',
88
+ 'dateline' => '-',
89
+ ) ;
90
+ }
91
+
92
+ $info[ 'dateline' ] = date( 'm/d/Y H:i:s', $info[ 'dateline' ] ) ;
93
+
94
+ return $info ;
95
+ }
96
 
97
  /**
98
  * Gathers the environment details and creates the report.
134
 
135
  $extras = array(
136
  'wordpress version' => $wp_version,
137
+ 'siteurl' => get_option( 'siteurl' ),
138
+ 'home' => get_option( 'home' ),
139
+ 'home_url' => home_url(),
140
  'locale' => get_locale(),
141
  'active theme' => $active_theme,
142
  'active plugins' => $active_plugins,
158
  }
159
 
160
  $report = $this->build_environment_report($_SERVER, $options, $extras, $paths) ;
 
161
  return $report ;
162
  }
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  /**
165
  * Builds the environment report buffer with the given parameters
166
  *
184
 
185
  $buf = $this->format_report_section('Server Variables', $server_vars) ;
186
 
 
 
187
  $buf .= $this->format_report_section('Wordpress Specific Extras', $extras) ;
188
 
189
+ $buf .= $this->format_report_section('LSCache Plugin Options', $options) ;
190
+
191
  if ( empty($htaccess_paths) ) {
192
  return $buf ;
193
  }
admin/litespeed-cache-admin-rules.class.php CHANGED
@@ -43,6 +43,7 @@ class LiteSpeed_Cache_Admin_Rules
43
  const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE' ;
44
  const MARKER_MINIFY = '### marker MINIFY' ;
45
  const MARKER_CORS = '### marker CORS' ;
 
46
  const MARKER_START = ' start ###' ;
47
  const MARKER_END = ' end ###' ;
48
 
@@ -476,37 +477,47 @@ class LiteSpeed_Cache_Admin_Rules
476
  * @access private
477
  * @return array Rules set
478
  */
479
- private function _browser_cache_rules()
480
  {
 
 
 
 
 
 
481
  $rules = array(
482
  '<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
483
  '<IfModule mod_expires.c>',
484
  'ExpiresActive on',
485
- 'ExpiresByType application/pdf A2592000',
486
- 'ExpiresByType image/x-icon A2592000',
487
- 'ExpiresByType image/vnd.microsoft.icon A2592000',
488
- 'ExpiresByType image/svg+xml A2592000',
489
  '',
490
- 'ExpiresByType image/jpg A2592000',
491
- 'ExpiresByType image/jpeg A2592000',
492
- 'ExpiresByType image/png A2592000',
493
- 'ExpiresByType image/gif A2592000',
494
- 'ExpiresByType image/webp A2592000',
495
  '',
496
- 'ExpiresByType video/ogg A2592000',
497
- 'ExpiresByType audio/ogg A2592000',
498
- 'ExpiresByType video/mp4 A2592000',
499
- 'ExpiresByType video/webm A2592000',
500
  '',
501
- 'ExpiresByType text/css A2592000',
502
- 'ExpiresByType text/javascript A2592000',
503
- 'ExpiresByType application/javascript A2592000',
504
- 'ExpiresByType application/x-javascript A2592000',
505
  '',
506
- 'ExpiresByType application/x-font-ttf A2592000',
507
- 'ExpiresByType application/font-woff A2592000',
508
- 'ExpiresByType application/font-woff2 A2592000',
509
- 'ExpiresByType application/vnd.ms-fontobject A2592000',
 
 
 
 
510
  '',
511
  '</IfModule>',
512
  '</FilesMatch>',
@@ -625,8 +636,8 @@ class LiteSpeed_Cache_Admin_Rules
625
  $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ;
626
  if ( ! empty( $cfg[ $id ] ) ) {
627
  $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_START ;
628
- $new_rules = array_merge( $new_rules, $this->_browser_cache_rules() ) ;
629
- $new_rules_backend = array_merge( $new_rules_backend, $this->_browser_cache_rules() ) ;
630
  $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_END ;
631
  $new_rules[] = '' ;
632
  }
@@ -640,6 +651,16 @@ class LiteSpeed_Cache_Admin_Rules
640
  $new_rules[] = '' ;
641
  }
642
 
 
 
 
 
 
 
 
 
 
 
643
  return array( $new_rules, $new_rules_backend ) ;
644
 
645
  }
43
  const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE' ;
44
  const MARKER_MINIFY = '### marker MINIFY' ;
45
  const MARKER_CORS = '### marker CORS' ;
46
+ const MARKER_WEBP = '### marker WEBP' ;
47
  const MARKER_START = ' start ###' ;
48
  const MARKER_END = ' end ###' ;
49
 
477
  * @access private
478
  * @return array Rules set
479
  */
480
+ private function _browser_cache_rules( $cfg )
481
  {
482
+ /**
483
+ * Add ttl setting
484
+ * @since 1.6.3
485
+ */
486
+ $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER_TTL ;
487
+ $ttl = $cfg[ $id ] ;
488
  $rules = array(
489
  '<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
490
  '<IfModule mod_expires.c>',
491
  'ExpiresActive on',
492
+ 'ExpiresByType application/pdf A' . $ttl,
493
+ 'ExpiresByType image/x-icon A' . $ttl,
494
+ 'ExpiresByType image/vnd.microsoft.icon A' . $ttl,
495
+ 'ExpiresByType image/svg+xml A' . $ttl,
496
  '',
497
+ 'ExpiresByType image/jpg A' . $ttl,
498
+ 'ExpiresByType image/jpeg A' . $ttl,
499
+ 'ExpiresByType image/png A' . $ttl,
500
+ 'ExpiresByType image/gif A' . $ttl,
501
+ 'ExpiresByType image/webp A' . $ttl,
502
  '',
503
+ 'ExpiresByType video/ogg A' . $ttl,
504
+ 'ExpiresByType audio/ogg A' . $ttl,
505
+ 'ExpiresByType video/mp4 A' . $ttl,
506
+ 'ExpiresByType video/webm A' . $ttl,
507
  '',
508
+ 'ExpiresByType text/css A' . $ttl,
509
+ 'ExpiresByType text/javascript A' . $ttl,
510
+ 'ExpiresByType application/javascript A' . $ttl,
511
+ 'ExpiresByType application/x-javascript A' . $ttl,
512
  '',
513
+ 'ExpiresByType application/x-font-ttf A' . $ttl,
514
+ 'ExpiresByType application/x-font-woff A' . $ttl,
515
+ 'ExpiresByType application/font-woff A' . $ttl,
516
+ 'ExpiresByType application/font-woff2 A' . $ttl,
517
+ 'ExpiresByType application/vnd.ms-fontobject A' . $ttl,
518
+ 'ExpiresByType font/ttf A' . $ttl,
519
+ 'ExpiresByType font/woff A' . $ttl,
520
+ 'ExpiresByType font/woff2 A' . $ttl,
521
  '',
522
  '</IfModule>',
523
  '</FilesMatch>',
636
  $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ;
637
  if ( ! empty( $cfg[ $id ] ) ) {
638
  $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_START ;
639
+ $new_rules = array_merge( $new_rules, $this->_browser_cache_rules( $cfg ) ) ;
640
+ $new_rules_backend = array_merge( $new_rules_backend, $this->_browser_cache_rules( $cfg ) ) ;
641
  $new_rules[] = $new_rules_backend[] = self::MARKER_BROWSER_CACHE . self::MARKER_END ;
642
  $new_rules[] = '' ;
643
  }
651
  $new_rules[] = '' ;
652
  }
653
 
654
+ // webp support
655
+ $id = LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ;
656
+ if ( ! empty( $cfg[ $id ] ) ) {
657
+ $new_rules[] = self::MARKER_WEBP . self::MARKER_START ;
658
+ $new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp"' ;
659
+ $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]' ;
660
+ $new_rules[] = self::MARKER_WEBP . self::MARKER_END ;
661
+ $new_rules[] = '' ;
662
+ }
663
+
664
  return array( $new_rules, $new_rules_backend ) ;
665
 
666
  }
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -421,6 +421,14 @@ class LiteSpeed_Cache_Admin_Settings
421
  $this->_options[ $id ] = implode( ',', $tag_ids ) ;
422
  }
423
  }
 
 
 
 
 
 
 
 
424
  }
425
 
426
  /**
@@ -481,6 +489,11 @@ class LiteSpeed_Cache_Admin_Settings
481
  $ids = array(
482
  LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
483
  LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
 
 
 
 
 
484
  ) ;
485
  foreach ( $ids as $id ) {
486
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
@@ -506,9 +519,11 @@ class LiteSpeed_Cache_Admin_Settings
506
  $ids = array(
507
  LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
508
  LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
 
509
  LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
510
  LiteSpeed_Cache_Config::OPID_JS_MINIFY,
511
  LiteSpeed_Cache_Config::OPID_JS_COMBINE,
 
512
  LiteSpeed_Cache_Config::OPID_JS_HTTP2,
513
  LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
514
  LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
@@ -517,6 +532,7 @@ class LiteSpeed_Cache_Admin_Settings
517
  LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
518
  LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
519
  LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
 
520
  ) ;
521
  foreach ( $ids as $id ) {
522
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
@@ -549,6 +565,10 @@ class LiteSpeed_Cache_Admin_Settings
549
  $id = LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ;
550
  update_option( $id, LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'uri' ) ) ;
551
 
 
 
 
 
552
  }
553
 
554
  /**
@@ -724,6 +744,21 @@ class LiteSpeed_Cache_Admin_Settings
724
  $new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
725
  }
726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
727
  // check mobile agents
728
  $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
729
  if ( ! $this->_input[ $id ] && $new_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
@@ -945,7 +980,7 @@ class LiteSpeed_Cache_Admin_Settings
945
  $max = $this->_max_int ;
946
  }
947
 
948
- return ctype_digit( $sval ) && $ival >= 0 && $ival < $max ;
949
  }
950
 
951
  /**
421
  $this->_options[ $id ] = implode( ',', $tag_ids ) ;
422
  }
423
  }
424
+
425
+ /**
426
+ * Update Role Excludes
427
+ * @since 1.6.2
428
+ */
429
+ $id = LiteSpeed_Cache_Config::EXCLUDE_CACHE_ROLES ;
430
+ update_option( $id, ! empty( $this->_input[ $id ] ) ? $this->_input[ $id ] : array() ) ;
431
+
432
  }
433
 
434
  /**
489
  $ids = array(
490
  LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
491
  LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
492
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF,
493
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP,
494
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY,
495
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF,
496
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS,
497
  ) ;
498
  foreach ( $ids as $id ) {
499
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
519
  $ids = array(
520
  LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
521
  LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
522
+ LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY,
523
  LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
524
  LiteSpeed_Cache_Config::OPID_JS_MINIFY,
525
  LiteSpeed_Cache_Config::OPID_JS_COMBINE,
526
+ LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY,
527
  LiteSpeed_Cache_Config::OPID_JS_HTTP2,
528
  LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
529
  LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
532
  LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
533
  LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
534
  LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
535
+ LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC,
536
  ) ;
537
  foreach ( $ids as $id ) {
538
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
565
  $id = LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ;
566
  update_option( $id, LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'uri' ) ) ;
567
 
568
+ // Update Role Excludes
569
+ $id = LiteSpeed_Cache_Config::EXCLUDE_OPTIMIZATION_ROLES ;
570
+ update_option( $id, ! empty( $this->_input[ $id ] ) ? $this->_input[ $id ] : array() ) ;
571
+
572
  }
573
 
574
  /**
744
  $new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
745
  }
746
 
747
+ // TTL check
748
+ $ids = array(
749
+ LiteSpeed_Cache_Config::OPID_CACHE_BROWSER_TTL => array( __( 'Default Public Cache', 'litespeed-cache' ), 30, $this->_max_int ),
750
+ ) ;
751
+ foreach ( $ids as $id => $v ) {
752
+ list( $desc, $min, $max ) = $v ;
753
+ if ( ! $this->_check_ttl( $this->_input, $id, $min, $max ) ) {
754
+ $this->_err[] = sprintf( $this->_err_msg_numeric, $desc, $min, $max ) ;
755
+ }
756
+ else {
757
+ $new_options[ $id ] = $this->_input[ $id ] ;
758
+ }
759
+ }
760
+
761
+
762
  // check mobile agents
763
  $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
764
  if ( ! $this->_input[ $id ] && $new_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
980
  $max = $this->_max_int ;
981
  }
982
 
983
+ return ctype_digit( $sval ) && $ival >= 0 && $ival <= $max ;
984
  }
985
 
986
  /**
admin/litespeed-cache-admin.class.php CHANGED
@@ -142,9 +142,11 @@ class LiteSpeed_Cache_Admin
142
  return ;
143
  }
144
 
145
- if ( LiteSpeed_Cache_Router::has_whm_msg() ) {
146
  $this->display->show_display_installed() ;
147
  }
 
 
148
  }
149
 
150
  /**
142
  return ;
143
  }
144
 
145
+ if ( LiteSpeed_Cache_GUI::has_whm_msg() ) {
146
  $this->display->show_display_installed() ;
147
  }
148
+
149
+ do_action( 'litspeed_after_admin_init' ) ;
150
  }
151
 
152
  /**
admin/tpl/crawler.php CHANGED
@@ -7,6 +7,7 @@ $sitemap_time = LiteSpeed_Cache_Crawler::get_instance()->sitemap_time() ;
7
 
8
  $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
9
 
 
10
  ?>
11
 
12
  <div class="wrap">
@@ -84,14 +85,8 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
84
  $meta = LiteSpeed_Cache_Crawler::get_instance()->get_meta() ;
85
  $is_running = $meta && $meta->is_running && time() - $meta->is_running <= $_options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION] ;
86
  if ( $meta && $meta->this_full_beginning_time ) {
87
- if ( $is_running ) {
88
- echo sprintf(__('The current sitemap crawl started at %s', 'litespeed-cache'),
89
- date('m/d/Y H:i:s' ,$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET ));
90
-
91
- }
92
- else {
93
- echo sprintf(__('The current sitemap crawl started at %s', 'litespeed-cache'),
94
- date('m/d/Y H:i:s' ,$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET ));
95
  echo "</div><div class='litespeed-desc'>";
96
  echo sprintf(__('The next complete sitemap crawl will start at %s', 'litespeed-cache'),
97
  date('m/d/Y H:i:s',$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET
@@ -128,7 +123,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 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
  />
@@ -147,7 +142,7 @@ $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
147
  ?>
148
  <?php if ( $meta && $meta->last_start_time ): ?>
149
  <div class='litespeed-desc'>
150
- <?php echo sprintf(__('<b>Last interval:</b> %s', 'litespeed-cache'), date('m/d/Y H:i:s' ,$meta->last_start_time+ LITESPEED_TIME_OFFSET )) ; ?>
151
  </div>
152
  <?php endif ; ?>
153
 
7
 
8
  $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
9
 
10
+ include_once LSWCP_DIR . "admin/tpl/inc/banner_promo.php" ;
11
  ?>
12
 
13
  <div class="wrap">
85
  $meta = LiteSpeed_Cache_Crawler::get_instance()->get_meta() ;
86
  $is_running = $meta && $meta->is_running && time() - $meta->is_running <= $_options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION] ;
87
  if ( $meta && $meta->this_full_beginning_time ) {
88
+ echo sprintf( __( 'The current sitemap crawl started at %s', 'litespeed-cache' ), LiteSpeed_Cache_Utility::readable_time( $meta->this_full_beginning_time ) ) ;
89
+ if ( ! $is_running ) {
 
 
 
 
 
 
90
  echo "</div><div class='litespeed-desc'>";
91
  echo sprintf(__('The next complete sitemap crawl will start at %s', 'litespeed-cache'),
92
  date('m/d/Y H:i:s',$meta->this_full_beginning_time + LITESPEED_TIME_OFFSET
123
  <td>
124
  <div class="litespeed-switch-drag">
125
  <input type="checkbox" name="litespeed_crawler_cron_enable" id="litespeed_crawler_cron_enable" value="1"
126
+ data-url="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE, false, true ) ; ?>"
127
  <?php if( $_options[LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE] && LiteSpeed_Cache_Router::can_crawl() ) echo "checked"; ?>
128
  <?php echo $disabled ; ?>
129
  />
142
  ?>
143
  <?php if ( $meta && $meta->last_start_time ): ?>
144
  <div class='litespeed-desc'>
145
+ <?php echo sprintf(__('<b>Last interval:</b> %s', 'litespeed-cache'), LiteSpeed_Cache_Utility::readable_time( $meta->last_start_time ) ) ; ?>
146
  </div>
147
  <?php endif ; ?>
148
 
admin/tpl/debug_log.php CHANGED
@@ -24,4 +24,9 @@ if ( ! defined( 'WPINC' ) ) die ;
24
  echo nl2br( htmlspecialchars( $logs ) ) ;
25
 
26
  ?>
 
 
 
 
 
27
  </div>
24
  echo nl2br( htmlspecialchars( $logs ) ) ;
25
 
26
  ?>
27
+
28
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_LOG, LiteSpeed_Cache_Log::TYPE_CLEAR_LOG ) ; ?>" class="litespeed-btn-success">
29
+ <?php echo __( 'Clear Log', 'litespeed-cache' ) ; ?>
30
+ </a>
31
+
32
  </div>
admin/tpl/edit_htaccess.php CHANGED
@@ -61,15 +61,13 @@ if ( defined( 'LITESPEED_ON' ) ) {
61
 
62
  <p><?php echo __('These are added by the LS Cache plugin and may cause problems if they are changed.', 'litespeed-cache'); ?></p>
63
 
64
- <textarea name="<?php echo LiteSpeed_Cache_Admin_Rules::EDITOR_TEXTAREA_NAME; ?>" wrap="off" rows="30" class="litespeed-input-long"
65
  <?php echo $readonly; ?>
66
  ><?php echo esc_textarea($content); ?></textarea>
67
 
68
  <button type="submit" class="litespeed-btn-primary"><?php echo __('Save', 'litespeed-cache'); ?></button>
69
  </form>
70
 
71
- <?php require LSWCP_DIR . 'admin/tpl/info/info_common_rewrite.php'; ?>
72
-
73
  <?php endif; ?>
74
  </div>
75
  </div>
61
 
62
  <p><?php echo __('These are added by the LS Cache plugin and may cause problems if they are changed.', 'litespeed-cache'); ?></p>
63
 
64
+ <textarea name="<?php echo LiteSpeed_Cache_Admin_Rules::EDITOR_TEXTAREA_NAME; ?>" wrap="off" rows="50" class="litespeed-input-long"
65
  <?php echo $readonly; ?>
66
  ><?php echo esc_textarea($content); ?></textarea>
67
 
68
  <button type="submit" class="litespeed-btn-primary"><?php echo __('Save', 'litespeed-cache'); ?></button>
69
  </form>
70
 
 
 
71
  <?php endif; ?>
72
  </div>
73
  </div>
admin/tpl/image_optimization.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ $media = LiteSpeed_Cache_Media::get_instance() ;
5
+
6
+ $img_count = $media->img_count() ;
7
+ $optm_summary = $media->summary_info() ;
8
+
9
+ list( $last_run, $is_running ) = $media->cron_running( false ) ;
10
+
11
+ $_optm_summary_list = array(
12
+ 'level' => array(
13
+ 'title' => __( 'Level', 'litespeed-cache' ),
14
+ 'must' => true,
15
+ ),
16
+ 'credit' => array(
17
+ 'title' => __( 'Credit', 'litespeed-cache' ),
18
+ 'desc' => __( 'Credit recovers with each successful pull.', 'litespeed-cache' ),
19
+ 'must' => true,
20
+ ),
21
+ 'reduced' => array(
22
+ 'title' => __( 'Total Reduction', 'litespeed-cache' ),
23
+ 'type' => 'file_size',
24
+ ),
25
+ 'img_taken' => array(
26
+ 'title' => __( 'Images pulled', 'litespeed-cache' ),
27
+ ),
28
+ 'fetch_failed' => array(
29
+ 'title' => __( 'Images failed to fetch', 'litespeed-cache' ),
30
+ ),
31
+ 'notify_failed' => array(
32
+ 'title' => __( 'Images failed to notify', 'litespeed-cache' ),
33
+ ),
34
+ 'pull_failed' => array(
35
+ 'title' => __( 'Images failed to pull', 'litespeed-cache' ),
36
+ ),
37
+ 'last_requested' => array(
38
+ 'title' => __( 'Last Request', 'litespeed-cache' ),
39
+ 'type' => 'date',
40
+ ),
41
+ ) ;
42
+
43
+
44
+ include_once LSWCP_DIR . "admin/tpl/inc/banner_promo.php" ;
45
+ ?>
46
+
47
+ <div class="wrap">
48
+ <h2>
49
+ <?php echo __('LiteSpeed Cache Image Optimization', 'litespeed-cache') ; ?>
50
+ <span class="litespeed-desc">
51
+ v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
52
+ </span>
53
+ </h2>
54
+ </div>
55
+
56
+ <div class="litespeed-wrap">
57
+ <div class="litespeed-body">
58
+ <h3 class="litespeed-title"><?php echo __('Optimization Summary', 'litespeed-cache') ; ?></h3>
59
+
60
+ <?php foreach ( $_optm_summary_list as $k => $v ) : ?>
61
+ <?php if ( isset( $optm_summary[ $k ] ) && ( $optm_summary[ $k ] || ! empty( $v[ 'must' ] ) ) ) : ?>
62
+ <p>
63
+ <?php echo $v[ 'title' ] ; ?>:
64
+ <b>
65
+ <?php
66
+ if ( ! empty( $v[ 'type' ] ) ) {
67
+ if ( $v[ 'type' ] == 'file_size' ) {
68
+ echo LiteSpeed_Cache_Utility::real_size( $optm_summary[ $k ] ) ;
69
+ }
70
+ if ( $v[ 'type' ] == 'date' ) {
71
+ echo LiteSpeed_Cache_Utility::readable_time( $optm_summary[ $k ] ) ;
72
+ }
73
+ }
74
+ else {
75
+ echo $optm_summary[ $k ] ;
76
+ }
77
+
78
+ if ( ! empty( $v[ 'desc' ] ) ) {
79
+ echo '<span class="litespeed-desc">' . $v[ 'desc' ] . '</span>' ;
80
+ }
81
+ ?>
82
+ </b>
83
+ </p>
84
+ <?php endif ; ?>
85
+ <?php endforeach ; ?>
86
+
87
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_SYNC_DATA ) ; ?>" class="litespeed-btn-success">
88
+ <?php echo __( 'Update Reduction Status', 'litespeed-cache' ) ; ?>
89
+ </a>
90
+ <span class="litespeed-desc">
91
+ <?php echo __( 'This will communicate with LiteSpeed\'s Image Optimization Server and retrieve the most recent status.', 'litespeed-cache' ) ; ?>
92
+ </span>
93
+
94
+ <?php include_once LSWCP_DIR . "admin/tpl/inc/api_key.php" ; ?>
95
+
96
+ <h3 class="litespeed-title"><?php echo __('Image Information', 'litespeed-cache') ; ?>
97
+ <span class="litespeed-desc"><?php echo __('Beta Version', 'litespeed-cache') ; ?></span>
98
+ </h3>
99
+
100
+ <p><?php echo sprintf( __( '<a %s>Image groups</a> total', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization:image-groups" target="_blank"' ) ; ?>: <b><?php echo $img_count[ 'total_img' ] ; ?></b></p>
101
+ <p><?php echo __('Image groups not yet requested', 'litespeed-cache') ; ?>: <b><?php echo $img_count[ 'total_not_requested' ] ; ?></b></p>
102
+ <?php if ( $img_count[ 'total_not_requested' ] ) : ?>
103
+ <?php if ( empty( $optm_summary[ 'level' ] ) ) : ?>
104
+ <a href="#" class="litespeed-btn-default disabled">
105
+ <?php echo __( 'Send Optimization Request', 'litespeed-cache' ) ; ?>
106
+ </a>
107
+ <span class="litespeed-desc">
108
+ <?php echo sprintf( __( 'Please press the %s button before sending a new request.', 'litespeed-cache' ), __( 'Update Reduction Status', 'litespeed-cache' ) ) ; ?>
109
+ </span>
110
+ <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization#image_optimization_in_litespeed_cache_for_wordpress" target="_blank"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
111
+ <?php else : ?>
112
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_OPTIMIZE ) ; ?>" class="litespeed-btn-success">
113
+ <?php echo __( 'Send Optimization Request', 'litespeed-cache' ) ; ?>
114
+ </a>
115
+ <span class="litespeed-desc">
116
+ <?php echo __( 'This will send the optimization request and the images to LiteSpeed\'s Image Optimization Server.', 'litespeed-cache' ) ; ?>
117
+ <?php echo sprintf( __( 'You can send at most %s images at once.', 'litespeed-cache' ), '<code>' . $optm_summary[ 'credit' ] . '</code>' ) ; ?>
118
+ </span>
119
+ <?php endif ; ?>
120
+ <?php endif ; ?>
121
+
122
+ <hr />
123
+
124
+ <p>
125
+ <?php echo __('Image groups requested', 'litespeed-cache') ; ?>: <b><?php echo $img_count[ 'total_requested' ] ; ?></b>
126
+ </p>
127
+ <p><?php echo __('Image groups failed to optimize', 'litespeed-cache') ; ?>: <b><?php echo $img_count[ 'total_err' ] ; ?></b></p>
128
+ <p class="litespeed-desc">
129
+ <?php echo __( 'After LiteSpeed\'s Image Optimization Server finishes optimization, it will notify your site to pull the optimized images.', 'litespeed-cache' ) ; ?>
130
+ <?php echo __( 'This process is automatic.', 'litespeed-cache' ) ; ?>
131
+ </p>
132
+ <p>
133
+ <?php echo __('Image groups notified to pull', 'litespeed-cache') ; ?>: <b><?php echo $img_count[ 'total_server_finished' ] ; ?></b>
134
+ <?php if ( $img_count[ 'total_server_finished' ] && ! $is_running ) : ?>
135
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_PULL ) ; ?>" class="litespeed-btn-success">
136
+ <?php echo __( 'Pull Images', 'litespeed-cache' ) ; ?>
137
+ </a>
138
+ <span class="litespeed-desc">
139
+ <?php echo __( 'Only press the button if the pull cron job is disabled.', 'litespeed-cache' ) ; ?>
140
+ <?php echo __( 'Images will be pulled automatically if the cron job is running.', 'litespeed-cache' ) ; ?>
141
+ </span>
142
+ <?php elseif ( $last_run ) : ?>
143
+ <span class="litespeed-desc">
144
+ <?php echo sprintf( __( 'Last pull initiated by cron at %s.', 'litespeed-cache' ), '<code>' . LiteSpeed_Cache_Utility::readable_time( $last_run ) . '</code>' ) ; ?>
145
+ </span>
146
+ <?php endif ; ?>
147
+ </p>
148
+ <p><?php echo __('Image groups optimized and pulled', 'litespeed-cache') ; ?>: <b><?php echo $img_count[ 'total_pulled' ] ; ?></b></p>
149
+ <p><a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization#image_optimization_in_litespeed_cache_for_wordpress" target="_blank"><?php echo __('Learn More', 'litespeed-cache') ; ?></a></p>
150
+
151
+ <hr />
152
+
153
+ <?php if ( ! empty( $optm_summary[ 'level' ] ) ) : ?>
154
+ <h3 class="litespeed-title"><?php echo __('Revert Optimization', 'litespeed-cache') ; ?></h3>
155
+
156
+ <span class="litespeed-desc">
157
+ <?php echo __( 'Switch all images in the media library back to their original unoptimized versions.', 'litespeed-cache' ) ; ?>
158
+ </span>
159
+
160
+ <br />
161
+
162
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_BATCH_SWITCH_ORI ) ; ?>" class="litespeed-btn-danger">
163
+ <?php echo __( 'Undo Optimization', 'litespeed-cache' ) ; ?>
164
+ </a>
165
+ <span class="litespeed-desc">
166
+ <?php echo __( 'Revert all optimized images back to their original versions.', 'litespeed-cache' ) ; ?>
167
+ </span>
168
+
169
+ <br />
170
+
171
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_BATCH_SWITCH_OPTM ) ; ?>" class="litespeed-btn-warning">
172
+ <?php echo __( 'Re-do Optimization', 'litespeed-cache' ) ; ?>
173
+ </a>
174
+ <span class="litespeed-desc">
175
+ <?php echo __( 'Switch back to using optimized images.', 'litespeed-cache' ) ; ?>
176
+ </span>
177
+
178
+ <br />
179
+ <p>
180
+ <?php echo sprintf( __( 'Results can be checked in <a %s>Media Library</a>.', 'litespeed-cache' ), 'href="upload.php?mode=list"' ) ; ?>
181
+ </p>
182
+
183
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_OPTIMIZE_RESCAN ) ; ?>" class="litespeed-btn-success">
184
+ <?php echo __( 'Send New Thumbnail Requests', 'litespeed-cache' ) ; ?>
185
+ </a>
186
+ <span class="litespeed-desc">
187
+ <?php echo __( 'Scan for any new unoptimized image thumbnail sizes and resend necessary image optimization requests.', 'litespeed-cache' ) ; ?>
188
+ </span>
189
+
190
+ <br />
191
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_IMG_OPTIMIZE_DESTROY ) ; ?>" class="litespeed-btn-danger">
192
+ <?php echo __( 'Destroy All Optimization Data!', 'litespeed-cache' ) ; ?>
193
+ </a>
194
+ <span class="litespeed-desc">
195
+ <?php echo __( 'Remove all previous image optimization requests/results, revert completed optimizations, and delete all optimization files.', 'litespeed-cache' ) ; ?>
196
+ <font class="litespeed-warning">
197
+ <?php echo __('NOTE:', 'litespeed-cache'); ?>
198
+ <?php echo sprintf( __( 'If there are unfinished requests in progress, the requests\' credits will NOT be recovered.', 'litespeed-cache' ), 'jQuery', __( 'JS Combine', 'litespeed-cache' ) ) ; ?>
199
+ </font>
200
+
201
+ </span>
202
+ <?php endif ; ?>
203
+
204
+
205
+ </div>
206
+ </div>
admin/tpl/inc/admin_footer.php CHANGED
@@ -6,7 +6,7 @@ $rate_us = sprintf(__('Rate <strong>LiteSpeed Cache</strong> with %s on WordPres
6
  '<a href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" rel="noopener noreferer" target="_blank">&#10030;&#10030;&#10030;&#10030;&#10030;</a>'
7
  );
8
  $questions = sprintf(__('If there are any questions that are not answered in the <a %s>FAQs</a>, do not hesitate to ask them on the <a %s>support forum</a>.', 'litespeed-cache'),
9
- 'href="' . get_admin_url() . 'admin.php?page=lscache-info"',
10
  'href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank"');
11
  // Change the footer text
12
  if ( !is_multisite()
6
  '<a href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" rel="noopener noreferer" target="_blank">&#10030;&#10030;&#10030;&#10030;&#10030;</a>'
7
  );
8
  $questions = sprintf(__('If there are any questions that are not answered in the <a %s>FAQs</a>, do not hesitate to ask them on the <a %s>support forum</a>.', 'litespeed-cache'),
9
+ 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp" target="_blank"',
10
  'href="https://wordpress.org/support/plugin/litespeed-cache" rel="noopener noreferrer" target="_blank"');
11
  // Change the footer text
12
  if ( !is_multisite()
admin/tpl/inc/api_key.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('WPINC')) die;
3
+
4
+ $api_key = get_option( LiteSpeed_Cache_Admin_API::DB_API_KEY ) ;
5
+
6
+ ?>
7
+
8
+
9
+ <?php if ( ! $api_key ) : ?>
10
+ <p class="litespeed-desc">
11
+ <?php echo __( 'This will also generate an API key from LiteSpeed\'s Server.', 'litespeed-cache' ) ; ?>
12
+ </p>
13
+ <?php endif ; ?>
14
+
admin/tpl/inc/banner_promo.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
4
- if ( ! LiteSpeed_Cache_Router::has_promo_msg() ) {
5
  return ;
6
  }
7
 
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
4
+ if ( ! LiteSpeed_Cache_GUI::has_promo_msg() ) {
5
  return ;
6
  }
7
 
admin/tpl/info.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $menuArr = array(
5
- 'faqs' => __('FAQs', 'litespeed-cache'),
6
- 'config' => __('Configuration', 'litespeed-cache'),
7
- 'compatibility' => __('Plugin Compatibilities', 'litespeed-cache'),
8
- 'common_rewrite' => __('Common Rewrite Rules', 'litespeed-cache'),
9
- 'admin_ip' => __('Admin IP Commands', 'litespeed-cache'),
10
- 'crawler' => __('Crawler', 'litespeed-cache'),
11
- );
12
-
13
- ?>
14
- <div class="wrap">
15
- <h2>
16
- <?php echo __('LiteSpeed Cache Information', 'litespeed-cache'); ?>
17
- <span class="litespeed-desc">
18
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
19
- </span>
20
- </h2>
21
- </div>
22
- <div class="litespeed-wrap">
23
- <h2 class="litespeed-header">
24
- <?php
25
- foreach ($menuArr as $tab => $val){
26
- echo "<a class='litespeed-tab' href='?page=lscache-info#$tab' data-litespeed-tab='$tab'>$val</a>";
27
- }
28
- ?>
29
- </h2>
30
- <div class="litespeed-body">
31
-
32
- <?php
33
- // include all tpl for faster UE
34
- foreach ($menuArr as $tab => $val) {
35
- echo "<div data-litespeed-layout='$tab'>";
36
- require LSWCP_DIR . "admin/tpl/info/info_$tab.php";
37
- echo "</div>";
38
- }
39
-
40
- ?>
41
- </div>
42
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_admin_ip.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $nocache_desc =
5
- __('This is used to display a page without caching it.', 'litespeed-cache').' '.
6
- __('An example use case is to compare a cached version of a page with an uncached version.', 'litespeed-cache');
7
-
8
- $purge_desc =
9
- __('This is used to purge most cache tags associated with the page.', 'litespeed-cache').' '.
10
- __('The lone exception is the blog ID tag.', 'litespeed-cache').' '.
11
- __('Note that this means that pages with the same cache tag will be purged as well.', 'litespeed-cache');
12
-
13
- $showheaders_desc =
14
- __('This is used to show all the cache headers associated with a page.', 'litespeed-cache').' '.
15
- __('This may be useful for debugging purposes.', 'litespeed-cache');
16
-
17
- ?>
18
-
19
- <h3 class="litespeed-title"><?php echo __('Admin IP Query String Actions', 'litespeed-cache'); ?></h3>
20
-
21
- <h4><?php echo __('The following commands are available to the admin and do not require log-in, providing quick access to actions on the various pages.', 'litespeed-cache'); ?></h4>
22
-
23
- <h4><?php echo __('Action List:', 'litespeed-cache'); ?></h4>
24
-
25
- <ul>
26
- <li><?php echo LiteSpeed_Cache::ACTION_QS_NOCACHE; ?> - <?php echo $nocache_desc; ?></li>
27
- <li><?php echo LiteSpeed_Cache::ACTION_QS_PURGE; ?> - <?php echo $purge_desc; ?></li>
28
- <li><?php echo LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE; ?> - <?php echo __('This is used to purge the first cache tag associated with the page.', 'litespeed-cache'); ?></li>
29
- <li><?php echo LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS; ?> - <?php echo $showheaders_desc; ?></li>
30
- </ul>
31
-
32
- <h5><?php echo sprintf(__('To trigger the action for a page, access the page with the query string %s', 'litespeed-cache'),
33
- '<code>?'.LiteSpeed_Cache::ACTION_KEY.'=ACTION</code>'); ?></h5>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_common_rewrite.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $notice_title = '';
5
- $notice_content = '';
6
-
7
- if ((is_multisite()) && (!is_network_admin())) {
8
- $notice_title = __('NOTE:', 'litespeed-cache');
9
- $notice_content =
10
- '<p>'.__('The following configuration can only be changed by the network admin.', 'litespeed-cache').'</p>'.
11
- '<p>'.__('Please contact the network admin to make any changes.', 'litespeed-cache').'</p>';
12
- }
13
- else {
14
- $notice_title = __('NOTICE:', 'litespeed-cache');
15
- $notice_content =
16
- '<p>'.
17
- __('The following rewrite rules can be configured in the LiteSpeed Cache settings page.', 'litespeed-cache').' '.
18
- __('Please make any needed changes on that page.', 'litespeed-cache').' '.
19
- __('It will automatically generate the correct rules in the htaccess file.', 'litespeed-cache').
20
- '</p>';
21
- }
22
- ?>
23
-
24
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Common Rewrite Rules', 'litespeed-cache'); ?></h3>
25
-
26
- <div class="litespeed-callout-warning">
27
- <h4><?php echo $notice_title; ?></h4>
28
- <?php echo $notice_content; ?>
29
- </div>
30
-
31
- <h4 class="litespeed-question litespeed-down"><?php echo __('Mobile Views:', 'litespeed-cache'); ?></h4>
32
- <div class="litespeed-answer">
33
- <p>
34
- <?php echo __('Some sites have adaptive views, meaning the page sent will adapt to the browser type (desktop vs mobile).', 'litespeed-cache'); ?>
35
- <?php echo __('This rewrite rule is used for sites that load a different page for each type.', 'litespeed-cache'); ?>
36
- </p>
37
- <p>
38
- <?php echo __('This configuration can be added on the settings page in the General tab.', 'litespeed-cache'); ?>
39
- </p>
40
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_USER_AGENT} Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi [NC]
41
- RewriteRule .* - [E=Cache-Control:vary=ismobile]</textarea>
42
- </div>
43
-
44
- <h4 class="litespeed-question litespeed-down"><?php echo __('Do Not Cache Cookies:', 'litespeed-cache'); ?></h4>
45
- <div class="litespeed-answer">
46
- <p><?php echo __('Another common rewrite rule is to notify the cache not to cache when it sees a specified cookie name.', 'litespeed-cache'); ?></p>
47
- <p><?php echo __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache'); ?></p>
48
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_COOKIE} dontcachecookie
49
- RewriteRule .* - [E=Cache-Control:no-cache]</textarea>
50
- </div>
51
-
52
- <h4 class="litespeed-question litespeed-down"><?php echo __('Do Not Cache User Agent:', 'litespeed-cache'); ?></h4>
53
- <div class="litespeed-answer">
54
- <p><?php echo __('A not so commonly used rewrite rule is to notify the cache not to cache when it sees a specified User Agent.', 'litespeed-cache'); ?></p>
55
- <p><?php echo __('This configuration can be added on the settings page in the Do Not Cache tab.', 'litespeed-cache'); ?></p>
56
- <textarea class="litespeed-textarea" rows="2" readonly>RewriteCond %{HTTP_USER_AGENT} dontcacheuseragent
57
- RewriteRule .* - [E=Cache-Control:no-cache]</textarea>
58
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_compatibility.php DELETED
@@ -1,57 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $known_compat = array(
5
- 'bbPress',
6
- 'WooCommerce',
7
- 'Contact Form 7',
8
- 'Google XML Sitemaps',
9
- 'Yoast SEO',
10
- 'Wordfence Security',
11
- 'NextGen Gallery',
12
- 'Aelia CurrencySwitcher',
13
- 'Fast Velocity Minify, thanks to Raul Peixoto',
14
- 'Autoptimize',
15
- 'Better WP Minify',
16
- 'WP Touch',
17
- 'Theme My Login',
18
- 'wpForo',
19
- 'WPLister',
20
- 'Avada',
21
- 'WP-PostRatings',
22
- );
23
-
24
- $known_uncompat = array();
25
-
26
- ?>
27
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Plugin Compatibility', 'litespeed-cache'); ?></h3>
28
-
29
- <p><a href="https://wordpress.org/support/topic/known-supported-plugins?replies=1" rel="noopener noreferrer" target="_blank"><?php echo __('Link Here', 'litespeed-cache'); ?></a></p>
30
- <p>
31
- <?php echo __('Please add a comment listing the plugins that you are using and how they are functioning on the support thread.', 'litespeed-cache'); ?>
32
- <?php echo __('With your help, we can provide the best WordPress caching solution.', 'litespeed-cache'); ?>
33
- </p>
34
-
35
- <h4><?php echo __('This is a list of plugins that are confirmed to be compatible with LiteSpeed Cache Plugin:', 'litespeed-cache'); ?></h4>
36
- <ul>
37
- <?php
38
- foreach ($known_compat as $plugin_name) {
39
- echo '<li>' . $plugin_name . '</li>';
40
- }
41
- ?>
42
- </ul>
43
-
44
- <h4><?php echo __('This is a list of known UNSUPPORTED plugins:', 'litespeed-cache'); ?></h4>
45
- <ul>
46
- <?php
47
- if($known_uncompat) {
48
- foreach ($known_uncompat as $plugin_name) {
49
- echo '<li>' . $plugin_name . '</li>';
50
- }
51
- }else{
52
- echo "<li>Nil</li>";
53
- }
54
- ?>
55
- </ul>
56
-
57
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_config.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Cache Configuration', 'litespeed-cache'); ?></h3>
5
-
6
-
7
- <h4><?php echo __('Instructions for LiteSpeed Web Server Enterprise', 'litespeed-cache'); ?></h4>
8
- <p>
9
- <?php echo __('Make sure that the server license has the LSCache module enabled.', 'litespeed-cache'); ?>
10
- <?php echo sprintf(__('A <a %s>2-CPU trial license with LSCache module</a> is available for free for %d days.', 'litespeed-cache'),
11
- 'href="https://www.litespeedtech.com/products/litespeed-web-server/download/get-a-trial-license" rel="noopener noreferrer" target="_blank"', 15); ?>
12
- </p>
13
- <p>
14
- <?php echo __('The server must be configured to have caching enabled.', 'litespeed-cache'); ?>
15
- <?php echo sprintf(__('If you are the server admin, <a %s>click here.</a>', 'litespeed-cache'),
16
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:common_installation#web_server_configuration" rel="noopener noreferrer" target="_blank"'); ?>
17
- <?php echo __('Otherwise request that the server admin configure the cache root for the server.', 'litespeed-cache'); ?>
18
- </p>
19
- <p>
20
- <?php echo __('In the .htaccess file for the WordPress installation, add the following:', 'litespeed-cache'); ?>
21
- </p>
22
- <textarea class="litespeed-textarea" rows="3" readonly>&lt;IfModule LiteSpeed&gt;
23
- CacheLookup public on
24
- &lt;/IfModule&gt;</textarea>
25
-
26
-
27
- <h4><?php echo __('Instructions for OpenLiteSpeed', 'litespeed-cache'); ?></h4>
28
- <p><?php echo __('This integration utilizes OLS\'s cache module.', 'litespeed-cache'); ?></p>
29
- <p>
30
- <?php echo sprintf(__('If it is a fresh OLS installation, the easiest way to integrate is to use <a %s>ols1clk.</a>', 'litespeed-cache'),
31
- 'href="http://open.litespeedtech.com/mediawiki/index.php/Help:1-Click_Install" rel="noopener noreferrer" target="_blank"'); ?>
32
- <?php echo sprintf(__('If using an existing WordPress installation, use the %s parameter.', 'litespeed-cache'), '--wordpresspath'); ?>
33
- <?php echo sprintf(__('Else if OLS and WordPress are already installed, please follow the instructions <a %s>here.</a>', 'litespeed-cache'),
34
- 'href="http://open.litespeedtech.com/mediawiki/index.php/Help:How_To_Set_Up_LSCache_For_WordPress" rel="noopener noreferrer" target="_blank"'); ?>
35
- </p>
36
-
37
-
38
- <div class="litespeed-h3"><?php echo __('How to test the plugin', 'litespeed-cache'); ?></div>
39
- <p><?php echo __('The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers.', 'litespeed-cache'); ?></p>
40
- <p>
41
- <?php echo sprintf(__('Visiting a page for the first time should result in a %s or %s response header for the page.', 'litespeed-cache'),
42
- '<br><code>X-LiteSpeed-Cache-Control:miss</code><br>',
43
- '<br><code>X-LiteSpeed-Cache-Control:no-cache</code><br>'); ?>
44
- </p>
45
- <p>
46
- <?php echo sprintf(__('Subsequent requests should have the %s response header until the page is updated, expired, or purged.', 'litespeed-cache'), '<code>X-LiteSpeed-Cache-Control:hit</code><br>'); ?>
47
- </p>
48
- <p>
49
- <?php echo sprintf(__('Please visit <a %s>this page</a> for more information.', 'litespeed-cache'),
50
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation#testing" rel="noopener noreferrer" target="_blank"'); ?>
51
- </p>
52
-
53
- <div class="litespeed-h3"><?php echo __( 'Cache tag prefix setting', 'litespeed-cache' ) ; ?></div>
54
- <p>
55
- <?php echo sprintf(
56
- __( 'The value of this wordpress cache tag prefix is %1$s. If you want to change the value to avoid conflicts with multiple sites, please add %2$s to %3$s.', 'litespeed-cache' ),
57
- '<code>' . LSWCP_TAG_PREFIX . '</code>',
58
- '<code>define( "LSWCP_TAG_PREFIX", "YourUniqueStringHere" ) ;</code>',
59
- '<code>wp-config.php</code>'
60
- ) ; ?>
61
- </p>
62
-
63
-
64
-
65
-
66
-
67
-
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_crawler.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title">
7
- <?php echo __('Crawler Introduction', 'litespeed-cache'); ?>
8
- <a href="javascript:;" class="litespeed-expend" data-litespeed-expend-all="crawler">+</a>
9
- </h3>
10
-
11
- <h4 class="litespeed-question litespeed-down"><?php echo __('How Does the Crawler Work?', 'litespeed-cache'); ?></h4>
12
- <div class="litespeed-answer">
13
- <p><?php echo __('Using a sitemap as a guide, LSCache’s crawler, travels its way throughout the backend, refreshing pages that have expired in the cache. The purpose is to keep the cache as fresh as possible while minimizing visitor exposure to uncached content.', 'litespeed-cache'); ?></p>
14
-
15
- <p><?php echo __('The sitemap can be generated by the crawler, or you can provide your own custom map.', 'litespeed-cache'); ?></p>
16
-
17
- <p><?php echo sprintf(__('To learn more about each of the crawler settings, see <a %s>our wiki - Crawler Settings</a>.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration#crawler_settings" target="_blank"'); ?></p>
18
- </div>
19
-
20
-
21
- <h4 class="litespeed-question litespeed-down"><?php echo __('Should I Enable the Crawler?', 'litespeed-cache'); ?></h4>
22
- <div class="litespeed-answer">
23
- <p><?php echo __('Not every site needs a crawler.', 'litespeed-cache'); ?></p>
24
-
25
- <p><?php echo __('In WordPress, the first visitor to an uncached page waits for the page to be dynamically-generated and served, and the page is then cached for subsequent visitors.', 'litespeed-cache'); ?></p>
26
-
27
- <p><?php echo __('The LSCache crawler makes the first visitor’s experience better by essentially becoming the first visitor. The crawler caches the page, and the visitor who would have been first is spared the wait. As such, the crawler realistically only benefits the first out of the many users who visit that page before it expires. If you have a small user base, then crawling impacts a greater percentage of your visitors than it would on a site that draws a large crowd.', 'litespeed-cache'); ?></p>
28
-
29
- <p><?php echo __('You should weigh this benefit against your server’s resources. If resources are plentiful, then the crawler is a nice thing to have.', 'litespeed-cache'); ?></p>
30
-
31
- <p><?php echo __('If your site is busy, you’ll find that commonly-visited pages are quickly re-cached by new visitors, without the aid of a crawler. An extra crawler task would compete for server resources while delivering minimal benefits.', 'litespeed-cache'); ?></p>
32
-
33
- <p><?php echo __('The decision to use a crawler depends on the busy-ness of the site and the availability of server resources. Ultimately, it is the hosting provider who can best make this call.', 'litespeed-cache'); ?></p>
34
- </div>
35
-
36
-
37
-
38
- <h4 class="litespeed-question litespeed-down"><?php echo __('Enabling the Crawler', 'litespeed-cache'); ?></h4>
39
- <div class="litespeed-answer">
40
- <p><?php echo __('Due to the potential of the crawler to consume considerable resources, we have put the on/off switch in the hands of the server administrators. The crawler is disabled by default and can only be enabled by an admin.', 'litespeed-cache'); ?></p>
41
-
42
- <p><?php echo sprintf(__('Instructions for enabling the crawler can be found in <a %s>our wiki - Enabling the Crawler</a>. If you do not have access to server configuration files or virtual host include files, you will need to ask your web host for assistance.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:enabling_the_crawler" target="_blank"'); ?></p>
43
- </div>
44
-
45
-
46
-
47
- <h4 class="litespeed-question litespeed-down"><?php echo __('Testing the Crawler', 'litespeed-cache'); ?></h4>
48
- <div class="litespeed-answer">
49
- <p><?php echo __('To determine whether the crawler is working as expected, you can test it with a single URL.', 'litespeed-cache'); ?></p>
50
-
51
- <ul>
52
- <li>
53
- <?php echo __('Pick a URL from your sitemap and purge it:', 'litespeed-cache'); ?><br />
54
- <?php echo __('Navigate to <b>LiteSpeed Cache > Manage > Purge By… > URL</b> and enter the full URL in the text box.', 'litespeed-cache'); ?>
55
- </li>
56
- <li>
57
- <?php echo __('Manually run the crawler:', 'litespeed-cache'); ?><br />
58
- <?php echo __('Navigate to <b>LiteSpeed Cache > Crawler</b>, make sure <b>Activation</b> is set to Enable, and press the <b>Manually run</b> button. Wait for it to finish.', 'litespeed-cache'); ?>
59
- </li>
60
- <li>
61
- <?php echo __('See if the purged URL was cached during the crawl:', 'litespeed-cache'); ?><br />
62
- <?php echo __('Turn on your browser’s Developer Tool/Inspector. Visit the URL that should have been crawled. Select the <b>Network</b> tab in the inspector, select the page request (the URL we just visited - it should be the first entry in the list), and select the <b>Header</b> tab. If the URL was crawled correctly, you will see the response header X-LiteSpeed-Cache: hit.', 'litespeed-cache'); ?>
63
- </li>
64
- </ul>
65
- </div>
66
-
67
- <h5><?php echo sprintf(__('If you don’t see X-LiteSpeed-Cache: hit, and you can’t figure out why the crawler didn’t cache the purged URL, you can visit <a %s>our support forum</a> for help.', 'litespeed-cache'), 'href="https://wordpress.org/support/plugin/litespeed-cache" target="_blank"'); ?></h5>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/info/info_faqs.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
- ?>
4
- <h3 class="litespeed-title">
5
- <?php echo __('LiteSpeed Cache FAQs', 'litespeed-cache'); ?>
6
- <a href="javascript:;" class="litespeed-expend" data-litespeed-expend-all="faqs">+</a>
7
- </h3>
8
-
9
- <h4 class="litespeed-question litespeed-down"><?php echo __('Is the LiteSpeed Cache Plugin for WordPress free?', 'litespeed-cache'); ?></h4>
10
- <div class="litespeed-answer">
11
- <p>
12
- <?php echo __('Yes, the plugin itself will remain free and open source.', 'litespeed-cache'); ?>
13
- <?php echo __('That said, a LiteSpeed server is required (see question 2)', 'litespeed-cache'); ?>
14
- </p>
15
- </div>
16
-
17
- <h4 class="litespeed-question litespeed-down"><?php echo __('What server software is required for this plugin?', 'litespeed-cache'); ?></h4>
18
- <div class="litespeed-answer">
19
- <p><?php echo __('A LiteSpeed server is required in order to use this plugin.', 'litespeed-cache'); ?></p>
20
- <ol>
21
- <li>LiteSpeed Web Server Enterprise with LSCache Module (v5.0.10+)</li>
22
- <li>OpenLiteSpeed (v1.4.17+)</li>
23
- <li>LiteSpeed WebADC (v2.0+)</li>
24
- </ol>
25
- <p><?php echo __('Any single server or cluster including a LiteSpeed server will work.', 'litespeed-cache'); ?>
26
- </div>
27
-
28
- <h4 class="litespeed-question litespeed-down"><?php echo __('Does this plugin work in a clustered environment?', 'litespeed-cache'); ?></h4>
29
- <div class="litespeed-answer">
30
- <p>
31
- <?php echo __('The cache entries are stored at the litespeed server level.', 'litespeed-cache'); ?>
32
- <?php echo __('The simplest solution is to use LiteSpeed WebADC, as the cache entries will be cached at that level.', 'litespeed-cache'); ?>
33
- </p>
34
- <p>
35
- <?php echo __('If using another load balancer, the cache entries will only be stored at the backend nodes, not at the load balancer.', 'litespeed-cache'); ?>
36
- <?php echo __('The purges will also not be synchronized across the nodes, so this is not recommended.', 'litespeed-cache'); ?>
37
- </p>
38
- <p>
39
- <?php echo sprintf(__('If a customized solution is required, please contact %s at %s', 'litespeed-cache'),
40
- 'LiteSpeed Technologies', 'info@litespeedtech.com'); ?>
41
- </p>
42
- <p><?php echo __('NOTICE: The rewrite rules created by this plugin must be copied to the WebADC', 'litespeed-cache'); ?></p>
43
- </div>
44
-
45
- <h4 class="litespeed-question litespeed-down"><?php echo __('Where are the cache entries stored?', 'litespeed-cache'); ?></h4>
46
- <div class="litespeed-answer">
47
- <p><?php echo __('The actual cached pages are stored and managed by LiteSpeed Servers. Nothing is stored on the PHP side.', 'litespeed-cache'); ?></p>
48
- </div>
49
-
50
- <h4 class="litespeed-question litespeed-down"><?php echo __('Is WooCommerce supported?', 'litespeed-cache'); ?></h4>
51
- <div class="litespeed-answer">
52
- <p>
53
- <?php echo __('In short, yes.', 'litespeed-cache'); ?>
54
- <?php echo __('However, for some woocommerce themes, the cart may not be updated correctly.', 'litespeed-cache'); ?>
55
- </p>
56
- <p><b><?php echo __('To test the cart:', 'litespeed-cache'); ?></b></p>
57
- <ul>
58
- <li><?php echo __('On a non-logged-in browser, visit and cache a page, then visit and cache a product page.', 'litespeed-cache'); ?></li>
59
- <li><?php echo __('The first page should be accessible from the product page (e.g. the shop).', 'litespeed-cache'); ?></li>
60
- <li><?php echo __('Once both pages are confirmed cached, add the product to the cart.', 'litespeed-cache'); ?></li>
61
- <li><?php echo __('After adding to the cart, visit the first page.', 'litespeed-cache'); ?></li>
62
- <li><?php echo __('The page should still be cached, and the cart should be up to date.', 'litespeed-cache'); ?></li>
63
- <li><?php echo __('If that is not the case, please add woocommerce_items_in_cart to the do not cache cookie list.', 'litespeed-cache'); ?></li>
64
- </ul>
65
- <p>
66
- <?php echo __('Some themes like Storefront and Shop Isle are built such that the cart works without the rule.', 'litespeed-cache'); ?>
67
- <?php echo __('However, other themes like the E-Commerce theme, do not, so please verify the theme used.', 'litespeed-cache'); ?>
68
- </p>
69
- </div>
70
-
71
- <h4 class="litespeed-question litespeed-down"><?php echo __('Are my images optimized?', 'litespeed-cache'); ?></h4>
72
- <div class="litespeed-answer">
73
- <p>
74
- <?php echo __('The cache plugin does not do anything with the images themselves.', 'litespeed-cache'); ?>
75
- <?php echo sprintf(__('We recommend you trying an image optimization plugin like %s to optimize your images.', 'litespeed-cache'),
76
- '<a href="https://shortpixel.com/h/af/CXNO4OI28044" rel="friend noopener noreferer" target="_blank">ShortPixel</a>'); ?>
77
- <?php echo __("It can reduce your site's images up to 90%.", 'litespeed-cache'); ?>
78
- </p>
79
- </div>
80
-
81
- <h4 class="litespeed-question litespeed-down"><?php echo __('How do I get WP-PostViews to display an updating view count?', 'litespeed-cache'); ?></h4>
82
- <div class="litespeed-answer">
83
- <ol>
84
- <li><?php echo sprintf(__('Use %1$s to replace %2$s', 'litespeed-cache'),
85
- '<code>&lt;div id="postviews_lscwp"&gt;&lt;/div&gt;</code>',
86
- '<code>&lt;?php if(function_exists(\'the_views\')) { the_views(); } ?&gt;</code>'); ?>
87
- <ul>
88
- <li><?php echo __('NOTE: The id can be changed, but the div id and the ajax function must match.', 'litespeed-cache'); ?></li>
89
- </ul>
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+"&amp;action=postviews",
97
- cache:!1,
98
- success:function(data) {
99
- if(data) {
100
- jQuery(\'#postviews_lscwp\').html(data+\' views\');
101
- }
102
- }
103
- });</textarea>'); ?>
104
- </li>
105
- <li>
106
- <?php echo __('Purge the cache to use the updated pages.', 'litespeed-cache'); ?>
107
- </li>
108
- </ol>
109
- </div>
110
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage/manage_purge.php CHANGED
@@ -26,21 +26,21 @@ $_panels = array(
26
  'desc' => __( 'Purge error pages, including 403 pages', 'litespeed-cache' ),
27
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
28
  'icon' => 'purge-403',
29
- 'append_url' => 'lserr=403',
30
  ),
31
  array(
32
  'title' => __( 'Purge 404 Error', 'litespeed-cache' ),
33
  'desc' => __( 'Purge error pages, including 404 pages', 'litespeed-cache' ),
34
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
35
  'icon' => 'purge-404',
36
- 'append_url' => 'lserr=404',
37
  ),
38
  array(
39
  'title' => __( 'Purge 500 Error', 'litespeed-cache' ),
40
  'desc' => __( 'Purge error pages, including 500 pages', 'litespeed-cache' ),
41
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
42
  'icon' => 'purge-500',
43
- 'append_url' => 'lserr=500',
44
  ),
45
  array(
46
  'title' => __( 'Purge All', 'litespeed-cache' ),
@@ -79,7 +79,7 @@ if ( ! is_multisite() || is_network_admin() ) {
79
  <?php foreach ( $_panels as $v ): ?>
80
 
81
  <a class="litespeed-panel"
82
- href="<?php echo LiteSpeed_Cache_Utility::build_url( $v[ 'tag' ], false, ! empty( $v[ 'append_url' ] ) ? $v[ 'append_url' ] : false ) ; ?>"
83
  <?php if ( ! empty( $v[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $v[ 'cfm' ] . '"' ; ?>
84
  >
85
  <section class="litespeed-panel-wrapper-icon">
26
  'desc' => __( 'Purge error pages, including 403 pages', 'litespeed-cache' ),
27
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
28
  'icon' => 'purge-403',
29
+ 'append_url' => '403',
30
  ),
31
  array(
32
  'title' => __( 'Purge 404 Error', 'litespeed-cache' ),
33
  'desc' => __( 'Purge error pages, including 404 pages', 'litespeed-cache' ),
34
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
35
  'icon' => 'purge-404',
36
+ 'append_url' => '404',
37
  ),
38
  array(
39
  'title' => __( 'Purge 500 Error', 'litespeed-cache' ),
40
  'desc' => __( 'Purge error pages, including 500 pages', 'litespeed-cache' ),
41
  'tag' => LiteSpeed_Cache::ACTION_PURGE_ERRORS,
42
  'icon' => 'purge-500',
43
+ 'append_url' => '500',
44
  ),
45
  array(
46
  'title' => __( 'Purge All', 'litespeed-cache' ),
79
  <?php foreach ( $_panels as $v ): ?>
80
 
81
  <a class="litespeed-panel"
82
+ href="<?php echo LiteSpeed_Cache_Utility::build_url( $v[ 'tag' ], ! empty( $v[ 'append_url' ] ) ? $v[ 'append_url' ] : false ) ; ?>"
83
  <?php if ( ! empty( $v[ 'cfm' ] ) ) echo 'data-litespeed-cfm="' . $v[ 'cfm' ] . '"' ; ?>
84
  >
85
  <section class="litespeed-panel-wrapper-icon">
admin/tpl/network_settings.php CHANGED
@@ -7,6 +7,7 @@ $menuArr = array(
7
  'purge' => __('Purge', 'litespeed-cache'),
8
  'excludes' => __('Excludes', 'litespeed-cache'),
9
  'advanced' => __('Advanced', 'litespeed-cache'),
 
10
  );
11
 
12
  global $_options;
7
  'purge' => __('Purge', 'litespeed-cache'),
8
  'excludes' => __('Excludes', 'litespeed-cache'),
9
  'advanced' => __('Advanced', 'litespeed-cache'),
10
+ 'media' => __('Media', 'litespeed-cache'),
11
  );
12
 
13
  global $_options;
admin/tpl/report.php CHANGED
@@ -1,7 +1,10 @@
1
  <?php
2
  if (!defined('WPINC')) die;
3
 
4
- $report = LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report();
 
 
 
5
 
6
  ?>
7
 
@@ -15,32 +18,29 @@ $report = LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_rep
15
  </div>
16
  <div class="litespeed-wrap">
17
  <div class="litespeed-body">
18
- <ul>
19
- <li><?php echo __('The environment report contains detailed information about the WordPress configuration.', 'litespeed-cache'); ?></li>
20
- <li><?php echo __('If you run into any issues, please include the contents of this text area in your support message.', 'litespeed-cache'); ?></li>
21
- <li><?php echo __('To easily grab the content, click the <b>Select All and Copy to Clipboard</b> button, to select and copy to clipboard.', 'litespeed-cache'); ?></li>
22
- <?php if ( is_writable(LSWCP_DIR) ): ?>
23
- <li><?php echo sprintf(__('Alternatively, this information is also saved in %s.', 'litespeed-cache'),
24
- LSWCP_CONTENT_FOLDER . '/plugins/litespeed-cache/environment_report.php'); ?></li>
25
- <?php endif; ?>
26
- </ul>
27
- <p>
28
- <b><?php echo __('The text area below contains the following content:', 'litespeed-cache'); ?></b>
29
- </p>
30
- <p>
31
- <span style="font-size:11px; font-style:italic">
32
- <?php echo __('Server Variables, Plugin Options, WordPress information (version, locale, active plugins, etc.), and .htaccess file content.', 'litespeed-cache'); ?>
33
- </span>
34
- </p>
35
- <p>
36
- <button class="litespeed-btn-success" id='litespeed_cache_report_copy'>
37
- <?php echo __("Select All and Copy to Clipboard", "litespeed-cache"); ?>
38
- </button>
39
- <span class="litespeed-hide" id="copy_select_all_span">
40
- <?php echo __("Environment Report copied to Clipboard!", "litespeed-cache"); ?>
41
- </span>
42
- </p>
43
- <textarea id="litespeed-report" rows="40" cols="80" readonly><?php echo $report; ?></textarea>
44
  </div>
45
  </div>
46
 
1
  <?php
2
  if (!defined('WPINC')) die;
3
 
4
+ $_report = LiteSpeed_Cache_Admin_Report::get_instance() ;
5
+ $report = $_report->generate_environment_report();
6
+
7
+ $env_ref = $_report->get_env_ref() ;
8
 
9
  ?>
10
 
18
  </div>
19
  <div class="litespeed-wrap">
20
  <div class="litespeed-body">
21
+
22
+ <h3 class="litespeed-title"><?php echo __('LiteSpeed Report Number', 'litespeed-cache') ; ?></h3>
23
+
24
+ <p><?php echo __('Report number', 'litespeed-cache') ; ?>: <b><?php echo $env_ref[ 'num' ] ; ?></b></p>
25
+ <p><?php echo __('Report date', 'litespeed-cache') ; ?>: <b><?php echo $env_ref[ 'dateline' ] ; ?></b></p>
26
+
27
+ <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_REPORT, LiteSpeed_Cache_Admin_Report::TYPE_SEND_REPORT ) ; ?>" class="litespeed-btn-warning">
28
+ <?php echo __( 'Send To LiteSpeed', 'litespeed-cache' ) ; ?>
29
+ </a>
30
+ <span class="litespeed-desc">
31
+ <?php echo __( 'Send this report to LiteSpeed. Refer to this report number when posting in the WordPress support forum.', 'litespeed-cache' ) ; ?>
32
+ </span>
33
+
34
+ <?php include_once LSWCP_DIR . "admin/tpl/inc/api_key.php" ; ?>
35
+
36
+ <h3 class="litespeed-title"><?php echo __('Report Summary', 'litespeed-cache') ; ?></h3>
37
+ <div class="litespeed-desc">
38
+ <?php echo __('The environment report contains detailed information about the WordPress configuration.', 'litespeed-cache'); ?>
39
+ <br />
40
+ <?php echo __('If you run into any issues, please refer to the report number in your support message.', 'litespeed-cache'); ?>
41
+ </div>
42
+ <textarea id="litespeed-report" rows="20" cols="100" readonly><?php echo $report; ?></textarea>
43
+
 
 
 
44
  </div>
45
  </div>
46
 
admin/tpl/setting/network_settings_media.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+ ?>
4
+ <h3 class="litespeed-title"><?php echo __( 'Network Media Settings', 'litespeed-cache' ) ; ?></h3>
5
+
6
+ <table><tbody>
7
+
8
+ <?php require LSWCP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ; ?>
9
+
10
+ </tbody></table>
admin/tpl/setting/settings_debug.php CHANGED
@@ -43,8 +43,8 @@ if ( ! defined( 'WPINC' ) ) die ;
43
  <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_ADMIN_IPS, null, false, 30 ) ; ?>
44
  <div class="litespeed-desc">
45
  <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ) ; ?><br />
46
- <?php echo sprintf( __( 'More information about the available commands can be found <a href="%s">here</a>.', 'litespeed-cache' ),
47
- get_admin_url() . 'admin.php?page=lscache-info#admin_ip' ) ; ?>
48
  </div>
49
  </td>
50
  </tr>
43
  <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_ADMIN_IPS, null, false, 30 ) ; ?>
44
  <div class="litespeed-desc">
45
  <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ) ; ?><br />
46
+ <?php echo sprintf( __( 'More information about the available commands can be found <a %s>here</a>.', 'litespeed-cache' ),
47
+ 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:admin-ip-commands" target="_blank"' ) ; ?>
48
  </div>
49
  </td>
50
  </tr>
admin/tpl/setting/settings_esi.php CHANGED
@@ -1,14 +1,6 @@
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
4
- global $wp_roles ;
5
- if ( !isset( $wp_roles ) ) {
6
- $wp_roles = new WP_Roles() ;
7
- }
8
- $roles = array_keys( $wp_roles->roles ) ;
9
-
10
- sort( $roles ) ;
11
-
12
  ?>
13
 
14
  <h3 class="litespeed-title"><?php echo __('ESI Settings', 'litespeed-cache'); ?></h3>
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
 
 
 
 
 
 
 
 
4
  ?>
5
 
6
  <h3 class="litespeed-title"><?php echo __('ESI Settings', 'litespeed-cache'); ?></h3>
admin/tpl/setting/settings_excludes.php CHANGED
@@ -59,9 +59,9 @@ if ( ! defined( 'WPINC' ) ) die ;
59
  <div class="litespeed-callout-warning">
60
  <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
61
  <ol>
62
- <li><?php echo __('If the Category ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
63
  <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
64
- '<code>http://www.example.com/category/category-id/</code>', '<code>category-id</code>'); ?></li>
65
  </ol>
66
  </div>
67
  </td>
@@ -97,9 +97,9 @@ if ( ! defined( 'WPINC' ) ) die ;
97
  <div class="litespeed-callout-warning">
98
  <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
99
  <ol>
100
- <li><?php echo __('If the Tag ID is not found, the name will be removed on save.', 'litespeed-cache'); ?></li>
101
  <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
102
- '<code>http://www.example.com/tag/category/tag-id/</code>', '<code>tag-id</code>'); ?></li>
103
  </ol>
104
  </div>
105
  </td>
@@ -116,4 +116,19 @@ if ( ! defined( 'WPINC' ) ) die ;
116
  endif ;
117
  ?>
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  </tbody></table>
59
  <div class="litespeed-callout-warning">
60
  <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
61
  <ol>
62
+ <li><?php echo __('If the category slug is not found, the category will be removed from the list on save.', 'litespeed-cache'); ?></li>
63
  <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
64
+ '<code>http://www.example.com/category/category-slug/</code>', '<code>category-slug</code>'); ?></li>
65
  </ol>
66
  </div>
67
  </td>
97
  <div class="litespeed-callout-warning">
98
  <h4><?php echo __('NOTE:', 'litespeed-cache'); ?></h4>
99
  <ol>
100
+ <li><?php echo __('If the tag slug is not found, the tag will be removed from the list on save.', 'litespeed-cache'); ?></li>
101
  <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
102
+ '<code>http://www.example.com/tag/category/tag-slug/</code>', '<code>tag-slug</code>'); ?></li>
103
  </ol>
104
  </div>
105
  </td>
116
  endif ;
117
  ?>
118
 
119
+
120
+ <tr>
121
+ <th><?php echo __('Do Not Cache Roles', 'litespeed-cache'); ?></th>
122
+ <td>
123
+ <?php foreach ( $roles as $role ): ?>
124
+ <?php $this->build_checkbox( LiteSpeed_Cache_Config::EXCLUDE_CACHE_ROLES . "][", $role, $this->config->in_exclude_cache_roles( $role ), $role ) ; ?>
125
+ <?php endforeach; ?>
126
+ <div class="litespeed-desc">
127
+ <?php echo __( 'Selected roles will be excluded from cache.', 'litespeed-cache' ) ; ?>
128
+ </div>
129
+ </td>
130
+ </tr>
131
+
132
+
133
+
134
  </tbody></table>
admin/tpl/setting/settings_general.php CHANGED
@@ -42,7 +42,7 @@ if (!defined('WPINC')) die;
42
  </div>
43
  <div class="litespeed-desc">
44
  <?php echo sprintf(__('Please visit the <a %s>Information</a> page on how to test the cache.', 'litespeed-cache'),
45
- 'href="'.get_admin_url().'admin.php?page=lscache-info"'); ?>
46
 
47
  <strong><?php echo __('NOTICE', 'litespeed-cache'); ?>: </strong><?php echo __('When disabling the cache, all cached entries for this blog will be purged.', 'litespeed-cache'); ?>
48
  <?php if ( is_multisite() ): ?>
42
  </div>
43
  <div class="litespeed-desc">
44
  <?php echo sprintf(__('Please visit the <a %s>Information</a> page on how to test the cache.', 'litespeed-cache'),
45
+ 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:configuration" target="_blank"'); ?>
46
 
47
  <strong><?php echo __('NOTICE', 'litespeed-cache'); ?>: </strong><?php echo __('When disabling the cache, all cached entries for this blog will be purged.', 'litespeed-cache'); ?>
48
  <?php if ( is_multisite() ): ?>
admin/tpl/setting/settings_inc.cache_browser.php CHANGED
@@ -17,3 +17,15 @@ if ( ! defined( 'WPINC' ) ) die ;
17
  </td>
18
  </tr>
19
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  </td>
18
  </tr>
19
 
20
+ <tr>
21
+ <th><?php echo __( 'Browser Cache TTL', 'litespeed-cache' ) ; ?></th>
22
+ <td>
23
+ <?php $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER_TTL ; ?>
24
+ <?php $this->build_input( $id ) ; ?> <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
25
+ <div class="litespeed-desc">
26
+ <?php echo sprintf( __( 'The amount of time, in seconds, that files will be stored in browser cache before expiring. Minimum is %s seconds.', 'litespeed-cache' ), 30 ) ; ?>
27
+ <?php $this->recommended($id) ; ?>
28
+ </div>
29
+ </td>
30
+ </tr>
31
+
admin/tpl/setting/settings_inc.media_webp.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ ?>
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">
12
+ <?php echo __('NOTE:', 'litespeed-cache'); ?>
13
+ <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
14
+ </font>
15
+ </div>
16
+ </td>
17
+ </tr>
18
+
admin/tpl/setting/settings_media.php CHANGED
@@ -58,5 +58,55 @@ if ( ! defined( 'WPINC' ) ) die ;
58
  </td>
59
  </tr>
60
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  </tbody></table>
58
  </td>
59
  </tr>
60
 
61
+ <tr>
62
+ <th><?php echo __( 'Disable Optimization Pull', 'litespeed-cache' ) ; ?></th>
63
+ <td>
64
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF ) ; ?>
65
+ <div class="litespeed-desc">
66
+ <?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' ) ) ; ?>
67
+ </div>
68
+ </td>
69
+ </tr>
70
+
71
+ <?php
72
+ if ( ! is_multisite() ) :
73
+ // webp
74
+ require LSWCP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ;
75
+
76
+ endif ;
77
+ ?>
78
+
79
+ <tr>
80
+ <th><?php echo __( 'Only Request WebP', 'litespeed-cache' ) ; ?></th>
81
+ <td>
82
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ) ; ?>
83
+ <div class="litespeed-desc">
84
+ <?php echo __( 'Prevent images from being replaced with optimized versions when optimizing. WebP versions will still be generated.', 'litespeed-cache' ) ; ?>
85
+ </div>
86
+ </td>
87
+ </tr>
88
+
89
+ <tr>
90
+ <th><?php echo __( 'Preserve EXIF data', 'litespeed-cache' ) ; ?></th>
91
+ <td>
92
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF ) ; ?>
93
+ <div class="litespeed-desc">
94
+ <?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ) ; ?>
95
+ <?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ) ; ?>
96
+ </div>
97
+ </td>
98
+ </tr>
99
+
100
+ <tr class="litespeed-hide">
101
+ <th><?php echo __( 'WebP Lossless Compression', 'litespeed-cache' ) ; ?></th>
102
+ <td>
103
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS ) ; ?>
104
+ <div class="litespeed-desc">
105
+ <?php echo __( 'Generate WebP images using lossless compression.', 'litespeed-cache' ) ; ?>
106
+ <?php echo __( 'This can improve quality at the cost of larger images.', 'litespeed-cache' ) ; ?>
107
+ </div>
108
+ </td>
109
+ </tr>
110
+
111
 
112
  </tbody></table>
admin/tpl/setting/settings_optimize.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
 
3
  ?>
4
 
5
  <h3 class="litespeed-title"><?php echo __( 'Optimization Settings', 'litespeed-cache' ) ; ?></h3>
@@ -48,23 +49,6 @@ if ( ! defined( 'WPINC' ) ) die ;
48
  </td>
49
  </tr>
50
 
51
- <tr>
52
- <th><?php echo __( 'CSS Excludes', 'litespeed-cache' ) ; ?></th>
53
- <td>
54
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES); ?>
55
- <div class="litespeed-desc">
56
- <?php echo __( 'Listed CSS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
57
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
58
- <?php echo __('One per line.', 'litespeed-cache'); ?>
59
- <br /><font class="litespeed-success">
60
- <?php echo __('API:', 'litespeed-cache'); ?>
61
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_css_excludes</code>' ) ; ?>
62
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
63
- </font>
64
- </div>
65
- </td>
66
- </tr>
67
-
68
  <tr>
69
  <th><?php echo __( 'JS Minify', 'litespeed-cache' ) ; ?></th>
70
  <td>
@@ -95,23 +79,6 @@ if ( ! defined( 'WPINC' ) ) die ;
95
  </td>
96
  </tr>
97
 
98
- <tr>
99
- <th><?php echo __( 'JS Excludes', 'litespeed-cache' ) ; ?></th>
100
- <td>
101
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_JS_EXCLUDES); ?>
102
- <div class="litespeed-desc">
103
- <?php echo __( 'Listed JS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
104
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
105
- <?php echo __('One per line.', 'litespeed-cache'); ?>
106
- <br /><font class="litespeed-success">
107
- <?php echo __('API:', 'litespeed-cache'); ?>
108
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_js_excludes</code>' ) ; ?>
109
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
110
- </font>
111
- </div>
112
- </td>
113
- </tr>
114
-
115
  <tr>
116
  <th><?php echo __( 'CSS/JS Cache TTL', 'litespeed-cache' ) ; ?></th>
117
  <td>
@@ -134,27 +101,6 @@ if ( ! defined( 'WPINC' ) ) die ;
134
  </td>
135
  </tr>
136
 
137
- <tr>
138
- <th><?php echo __( 'Remove Query Strings', 'litespeed-cache' ) ; ?></th>
139
- <td>
140
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ; ?>
141
- <div class="litespeed-desc">
142
- <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
143
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
144
- </div>
145
- </td>
146
- </tr>
147
-
148
- <tr>
149
- <th><?php echo __( 'Remove Google Fonts', 'litespeed-cache' ) ; ?></th>
150
- <td>
151
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ; ?>
152
- <div class="litespeed-desc">
153
- <?php echo __( 'Prevent google fonts from loading on all your pages.', 'litespeed-cache' ) ; ?>
154
- </div>
155
- </td>
156
- </tr>
157
-
158
  <tr>
159
  <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
160
  <td>
@@ -170,16 +116,6 @@ if ( ! defined( 'WPINC' ) ) die ;
170
  </td>
171
  </tr>
172
 
173
- <tr>
174
- <th><?php echo __( 'Critical CSS Rules', 'litespeed-cache' ) ; ?></th>
175
- <td>
176
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ; ?>
177
- <div class="litespeed-desc">
178
- <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
179
- </div>
180
- </td>
181
- </tr>
182
-
183
  <tr>
184
  <th><?php echo __( 'Load JS Deferred', 'litespeed-cache' ) ; ?></th>
185
  <td>
@@ -191,47 +127,6 @@ if ( ! defined( 'WPINC' ) ) die ;
191
  </td>
192
  </tr>
193
 
194
- <tr>
195
- <th><?php echo __( 'JS Deferred Excludes', 'litespeed-cache' ) ; ?></th>
196
- <td>
197
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ; ?>
198
- <div class="litespeed-desc">
199
- <?php echo __( 'Listed JS files will not be deferred.', 'litespeed-cache' ) ; ?>
200
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
201
- <?php echo __('One per line.', 'litespeed-cache'); ?>
202
- <br /><font class="litespeed-success">
203
- <?php echo __('API:', 'litespeed-cache'); ?>
204
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optm_js_defer_exc</code>' ) ; ?>
205
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-defer="1"</code>' ) ; ?>
206
- </font>
207
- </div>
208
- </td>
209
- </tr>
210
-
211
- <tr>
212
- <th><?php echo __( 'Remove WordPress Emoji', 'litespeed-cache' ) ; ?></th>
213
- <td>
214
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ; ?>
215
- <div class="litespeed-desc">
216
- <?php echo __( 'Stop loading wordpress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
217
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
218
- </div>
219
- </td>
220
- </tr>
221
-
222
- <tr>
223
- <th><?php echo __( 'URI Excludes', 'litespeed-cache' ) ; ?></th>
224
- <td>
225
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES); ?>
226
- <div class="litespeed-desc">
227
- <?php echo __( 'Prevent any optimization of listed pages.', 'litespeed-cache' ) ; ?>
228
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
229
- <?php echo sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ; ?>
230
- <?php echo __('One per line.', 'litespeed-cache'); ?>
231
- </div>
232
- </td>
233
- </tr>
234
-
235
  <tr>
236
  <th><?php echo __( 'Exclude JQuery', 'litespeed-cache' ) ; ?></th>
237
  <td>
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
+
4
  ?>
5
 
6
  <h3 class="litespeed-title"><?php echo __( 'Optimization Settings', 'litespeed-cache' ) ; ?></h3>
49
  </td>
50
  </tr>
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  <tr>
53
  <th><?php echo __( 'JS Minify', 'litespeed-cache' ) ; ?></th>
54
  <td>
79
  </td>
80
  </tr>
81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  <tr>
83
  <th><?php echo __( 'CSS/JS Cache TTL', 'litespeed-cache' ) ; ?></th>
84
  <td>
101
  </td>
102
  </tr>
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  <tr>
105
  <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
106
  <td>
116
  </td>
117
  </tr>
118
 
 
 
 
 
 
 
 
 
 
 
119
  <tr>
120
  <th><?php echo __( 'Load JS Deferred', 'litespeed-cache' ) ; ?></th>
121
  <td>
127
  </td>
128
  </tr>
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  <tr>
131
  <th><?php echo __( 'Exclude JQuery', 'litespeed-cache' ) ; ?></th>
132
  <td>
admin/tpl/setting/settings_tuning.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ ?>
5
+
6
+ <h3 class="litespeed-title"><?php echo __( 'Tuning Settings', 'litespeed-cache' ) ; ?></h3>
7
+
8
+ <table><tbody>
9
+
10
+ <tr>
11
+ <th><?php echo __( 'Combined CSS Priority', 'litespeed-cache' ) ; ?></th>
12
+ <td>
13
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY ) ; ?>
14
+ <div class="litespeed-desc">
15
+ <?php echo __( 'Load combined CSS files before other CSS files.', 'litespeed-cache' ) ; ?>
16
+ <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
17
+ <br /><font class="litespeed-warning">
18
+ <?php echo __('NOTE:', 'litespeed-cache'); ?>
19
+ <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined CSS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
20
+ </font>
21
+ <br /><font class="litespeed-success">
22
+ <?php echo __('API:', 'litespeed-cache'); ?>
23
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ) ; ?>
24
+ </font>
25
+ </div>
26
+ </td>
27
+ </tr>
28
+
29
+ <tr>
30
+ <th><?php echo __( 'CSS Excludes', 'litespeed-cache' ) ; ?></th>
31
+ <td>
32
+ <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES); ?>
33
+ <div class="litespeed-desc">
34
+ <?php echo __( 'Listed CSS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
35
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
36
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
37
+ <br /><font class="litespeed-success">
38
+ <?php echo __('API:', 'litespeed-cache'); ?>
39
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_css_excludes</code>' ) ; ?>
40
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
41
+ </font>
42
+ </div>
43
+ </td>
44
+ </tr>
45
+
46
+ <tr>
47
+ <th><?php echo __( 'Combined JS Priority', 'litespeed-cache' ) ; ?></th>
48
+ <td>
49
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY ) ; ?>
50
+ <div class="litespeed-desc">
51
+ <?php echo __( 'Load combined JS files before other JS files.', 'litespeed-cache' ) ; ?>
52
+ <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
53
+ <br /><font class="litespeed-warning">
54
+ <?php echo __('NOTE:', 'litespeed-cache'); ?>
55
+ <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined JS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
56
+ </font>
57
+ <br /><font class="litespeed-success">
58
+ <?php echo __('API:', 'litespeed-cache'); ?>
59
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top/bottom.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ) ; ?>
60
+ </font>
61
+ </div>
62
+ </td>
63
+ </tr>
64
+
65
+ <tr>
66
+ <th><?php echo __( 'JS Excludes', 'litespeed-cache' ) ; ?></th>
67
+ <td>
68
+ <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_JS_EXCLUDES); ?>
69
+ <div class="litespeed-desc">
70
+ <?php echo __( 'Listed JS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
71
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
72
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
73
+ <br /><font class="litespeed-success">
74
+ <?php echo __('API:', 'litespeed-cache'); ?>
75
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_js_excludes</code>' ) ; ?>
76
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
77
+ </font>
78
+ </div>
79
+ </td>
80
+ </tr>
81
+
82
+ <tr>
83
+ <th><?php echo __( 'Remove Query Strings', 'litespeed-cache' ) ; ?></th>
84
+ <td>
85
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ; ?>
86
+ <div class="litespeed-desc">
87
+ <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
88
+ <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
89
+ </div>
90
+ </td>
91
+ </tr>
92
+
93
+ <tr>
94
+ <th><?php echo __( 'Load Google Fonts Asynchronously', 'litespeed-cache' ) ; ?></th>
95
+ <td>
96
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ; ?>
97
+ <div class="litespeed-desc">
98
+ <?php echo __( 'This is useful if you only want to load Google Fonts asynchronously while leave other CSS intact.', 'litespeed-cache' ) ; ?>
99
+ <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ) ; ?>
100
+ </div>
101
+ </td>
102
+ </tr>
103
+
104
+ <tr>
105
+ <th><?php echo __( 'Remove Google Fonts', 'litespeed-cache' ) ; ?></th>
106
+ <td>
107
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ; ?>
108
+ <div class="litespeed-desc">
109
+ <?php echo __( 'Prevent google fonts from loading on all your pages.', 'litespeed-cache' ) ; ?>
110
+ </div>
111
+ </td>
112
+ </tr>
113
+
114
+ <tr>
115
+ <th><?php echo __( 'Critical CSS Rules', 'litespeed-cache' ) ; ?></th>
116
+ <td>
117
+ <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ; ?>
118
+ <div class="litespeed-desc">
119
+ <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
120
+ </div>
121
+ </td>
122
+ </tr>
123
+
124
+ <tr>
125
+ <th><?php echo __( 'JS Deferred Excludes', 'litespeed-cache' ) ; ?></th>
126
+ <td>
127
+ <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ; ?>
128
+ <div class="litespeed-desc">
129
+ <?php echo __( 'Listed JS files will not be deferred.', 'litespeed-cache' ) ; ?>
130
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
131
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
132
+ <br /><font class="litespeed-success">
133
+ <?php echo __('API:', 'litespeed-cache'); ?>
134
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optm_js_defer_exc</code>' ) ; ?>
135
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-defer="1"</code>' ) ; ?>
136
+ </font>
137
+ </div>
138
+ </td>
139
+ </tr>
140
+
141
+ <tr>
142
+ <th><?php echo __( 'Remove WordPress Emoji', 'litespeed-cache' ) ; ?></th>
143
+ <td>
144
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ; ?>
145
+ <div class="litespeed-desc">
146
+ <?php echo __( 'Stop loading wordpress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
147
+ <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
148
+ </div>
149
+ </td>
150
+ </tr>
151
+
152
+ <tr>
153
+ <th><?php echo __( 'URI Excludes', 'litespeed-cache' ) ; ?></th>
154
+ <td>
155
+ <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_OPTM_EXCLUDES); ?>
156
+ <div class="litespeed-desc">
157
+ <?php echo __( 'Prevent any optimization of listed pages.', 'litespeed-cache' ) ; ?>
158
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
159
+ <?php echo sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ; ?>
160
+ <?php echo __('One per line.', 'litespeed-cache'); ?>
161
+ </div>
162
+ </td>
163
+ </tr>
164
+
165
+ <tr>
166
+ <th><?php echo __('Role Excludes', 'litespeed-cache'); ?></th>
167
+ <td>
168
+ <?php foreach ( $roles as $role ): ?>
169
+ <?php $this->build_checkbox( LiteSpeed_Cache_Config::EXCLUDE_OPTIMIZATION_ROLES . "][", $role, $this->config->in_exclude_optimization_roles( $role ), $role ) ; ?>
170
+ <?php endforeach; ?>
171
+ <div class="litespeed-desc">
172
+ <?php echo __( 'Selected roles will be excluded from all optimizations.', 'litespeed-cache' ) ; ?>
173
+ </div>
174
+ </td>
175
+ </tr>
176
+
177
+
178
+ </tbody></table>
admin/tpl/settings.php CHANGED
@@ -9,6 +9,7 @@ $menu_list = array(
9
  'purge' => __('Purge', 'litespeed-cache'),
10
  'excludes' => __('Excludes', 'litespeed-cache'),
11
  'optimize' => __('Optimize', 'litespeed-cache'),
 
12
  'media' => __('Media', 'litespeed-cache'),
13
  'cdn' => __('CDN', 'litespeed-cache'),
14
  ) ;
@@ -80,6 +81,18 @@ else {
80
  $tp_tabs = array() ;
81
  }
82
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  include_once LSWCP_DIR . "admin/tpl/inc/banner_promo.php" ;
85
  ?>
9
  'purge' => __('Purge', 'litespeed-cache'),
10
  'excludes' => __('Excludes', 'litespeed-cache'),
11
  'optimize' => __('Optimize', 'litespeed-cache'),
12
+ 'tuning' => __('Tuning', 'litespeed-cache'),
13
  'media' => __('Media', 'litespeed-cache'),
14
  'cdn' => __('CDN', 'litespeed-cache'),
15
  ) ;
81
  $tp_tabs = array() ;
82
  }
83
 
84
+ /**
85
+ * Generate rules for setting usage
86
+ * @since 1.6.2
87
+ */
88
+ global $wp_roles ;
89
+ if ( !isset( $wp_roles ) ) {
90
+ $wp_roles = new WP_Roles() ;
91
+ }
92
+ $roles = array_keys( $wp_roles->roles ) ;
93
+
94
+ sort( $roles ) ;
95
+
96
 
97
  include_once LSWCP_DIR . "admin/tpl/inc/banner_promo.php" ;
98
  ?>
cli/litespeed-cache-cli-admin.class.php CHANGED
@@ -37,9 +37,11 @@ class LiteSpeed_Cache_Cli_Admin
37
 
38
  LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
39
  LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
 
40
  LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
41
  LiteSpeed_Cache_Config::OPID_JS_MINIFY,
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,
@@ -48,6 +50,7 @@ class LiteSpeed_Cache_Cli_Admin
48
  LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
49
  LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
50
  LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
 
51
 
52
  LiteSpeed_Cache_Config::OPID_CDN,
53
  LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
@@ -56,6 +59,11 @@ class LiteSpeed_Cache_Cli_Admin
56
 
57
  LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
58
  LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
 
 
 
 
 
59
  ) ;
60
  self::$purges = array(
61
  'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
@@ -146,6 +154,7 @@ class LiteSpeed_Cache_Cli_Admin
146
  case LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER:
147
  case LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM:
148
  case LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY:
 
149
 
150
  case LiteSpeed_Cache_Config::OPID_CDN:
151
  case LiteSpeed_Cache_Config::OPID_CDN_INC_IMG:
@@ -154,6 +163,11 @@ class LiteSpeed_Cache_Cli_Admin
154
 
155
  case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY:
156
  case LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY:
 
 
 
 
 
157
  //checkbox
158
  if ( $val === 'true' ) {
159
  $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
37
 
38
  LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
39
  LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
40
+ LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY,
41
  LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
42
  LiteSpeed_Cache_Config::OPID_JS_MINIFY,
43
  LiteSpeed_Cache_Config::OPID_JS_COMBINE,
44
+ LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY,
45
  LiteSpeed_Cache_Config::OPID_JS_HTTP2,
46
  LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
47
  LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
50
  LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
51
  LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
52
  LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
53
+ LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC,
54
 
55
  LiteSpeed_Cache_Config::OPID_CDN,
56
  LiteSpeed_Cache_Config::OPID_CDN_INC_IMG,
59
 
60
  LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
61
  LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
62
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF,
63
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP,
64
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY,
65
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF,
66
+ LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS,
67
  ) ;
68
  self::$purges = array(
69
  'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
154
  case LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER:
155
  case LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM:
156
  case LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY:
157
+ case LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC:
158
 
159
  case LiteSpeed_Cache_Config::OPID_CDN:
160
  case LiteSpeed_Cache_Config::OPID_CDN_INC_IMG:
163
 
164
  case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY:
165
  case LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY:
166
+ case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF:
167
+ case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP:
168
+ case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY:
169
+ case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF:
170
+ case LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS:
171
  //checkbox
172
  if ( $val === 'true' ) {
173
  $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
css/litespeed.css CHANGED
@@ -51,7 +51,7 @@
51
  }
52
 
53
  .litespeed-hide {
54
- display: none;
55
  }
56
 
57
  .litespeed-relative {
@@ -152,7 +152,7 @@
152
  }
153
 
154
  .litespeed-title a {
155
- text-decoration: none;
156
  }
157
 
158
  /********************************* nav tabs *******************************/
@@ -344,7 +344,8 @@
344
  }
345
 
346
  /********************************* btn *******************************/
347
- .litespeed-wrap [class*="litespeed-btn-"] {
 
348
  padding: 5px 10px;
349
  font-size: 14px !important;
350
  font-weight:400;
@@ -359,7 +360,8 @@
359
  height: initial;
360
  }
361
 
362
- .litespeed-wrap [class*="litespeed-btn-"]:hover {
 
363
  font-weight: 400;
364
  color: #fff;
365
  -moz-box-shadow: none;
@@ -367,7 +369,8 @@
367
  box-shadow: none;
368
  }
369
 
370
- .litespeed-wrap .litespeed-btn-danger {
 
371
  color: #cc3d6a;
372
  border: 1px solid #cc3d6a;
373
  -moz-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
@@ -375,11 +378,13 @@
375
  box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
376
  }
377
 
378
- .litespeed-wrap .litespeed-btn-danger:hover {
 
379
  background: #cc3d6a;
380
  }
381
 
382
- .litespeed-wrap .litespeed-btn-warning {
 
383
  color: #e59544;
384
  border: 1px solid #e59544;
385
  -moz-box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
@@ -387,11 +392,13 @@
387
  box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
388
  }
389
 
390
- .litespeed-wrap .litespeed-btn-warning:hover {
 
391
  background: #e59544;
392
  }
393
 
394
- .litespeed-wrap .litespeed-btn-success {
 
395
  color: #36b0b0;
396
  border: 1px solid #36b0b0;
397
  -moz-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
@@ -399,11 +406,13 @@
399
  box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
400
  }
401
 
402
- .litespeed-wrap .litespeed-btn-success:hover {
 
403
  background: #36b0b0;
404
  }
405
 
406
- .litespeed-wrap .litespeed-btn-primary {
 
407
  color: #538ac6;
408
  border: 1px solid #538ac6;
409
  -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
@@ -411,12 +420,35 @@
411
  box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
412
  }
413
 
414
- .litespeed-wrap .litespeed-btn-primary:hover {
 
415
  background: #538ac6;
416
  border-color: #538ac6;
417
  }
418
 
419
- .litespeed-wrap .litespeed-btn-xs {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
420
  padding: 1px 8px;
421
  font-size: 13px;
422
  line-height: 1.5;
@@ -424,6 +456,14 @@
424
  min-width: 100px;
425
  }
426
 
 
 
 
 
 
 
 
 
427
 
428
  /********************************* switch *******************************/
429
  .litespeed-switch {
@@ -847,7 +887,7 @@ ul.litespeed-shell-body {
847
  .litespeed-tick {
848
  display: inline-block;
849
  min-width: 125px;
850
- background: #f9fafc;
851
  padding: 5px 0 5px 0px;
852
  border-radius: 3px;
853
  cursor: pointer;
@@ -1104,7 +1144,80 @@ ul.litespeed-shell-body {
1104
  margin-left: 20px;
1105
  }
1106
 
1107
- /********************************* todo *******************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1108
  /********************************* todo *******************************/
1109
  /* input field */
1110
  .litespeed-textarea {
@@ -1150,10 +1263,11 @@ ul.litespeed-shell-body {
1150
  border-radius: 3px;
1151
  }
1152
 
1153
- .litespeed-float-submit {
1154
  position: absolute;
1155
  right: 10px;
1156
- top: 10px;
 
1157
  }
1158
 
1159
  .litespeed-body input,.litespeed-body textarea {
51
  }
52
 
53
  .litespeed-hide {
54
+ display: none !important;
55
  }
56
 
57
  .litespeed-relative {
152
  }
153
 
154
  .litespeed-title a {
155
+ text-decoration: none;
156
  }
157
 
158
  /********************************* nav tabs *******************************/
344
  }
345
 
346
  /********************************* btn *******************************/
347
+ .litespeed-wrap [class*="litespeed-btn-"],
348
+ [class*="litespeed-btn-"] {
349
  padding: 5px 10px;
350
  font-size: 14px !important;
351
  font-weight:400;
360
  height: initial;
361
  }
362
 
363
+ .litespeed-wrap [class*="litespeed-btn-"]:hover,
364
+ [class*="litespeed-btn-"]:hover {
365
  font-weight: 400;
366
  color: #fff;
367
  -moz-box-shadow: none;
369
  box-shadow: none;
370
  }
371
 
372
+ .litespeed-wrap .litespeed-btn-danger,
373
+ .litespeed-btn-danger {
374
  color: #cc3d6a;
375
  border: 1px solid #cc3d6a;
376
  -moz-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
378
  box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
379
  }
380
 
381
+ .litespeed-wrap .litespeed-btn-danger:hover,
382
+ .litespeed-btn-danger:hover {
383
  background: #cc3d6a;
384
  }
385
 
386
+ .litespeed-wrap .litespeed-btn-warning,
387
+ .litespeed-btn-warning {
388
  color: #e59544;
389
  border: 1px solid #e59544;
390
  -moz-box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
392
  box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
393
  }
394
 
395
+ .litespeed-wrap .litespeed-btn-warning:hover,
396
+ .litespeed-btn-warning:hover {
397
  background: #e59544;
398
  }
399
 
400
+ .litespeed-wrap .litespeed-btn-success,
401
+ .litespeed-btn-success {
402
  color: #36b0b0;
403
  border: 1px solid #36b0b0;
404
  -moz-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
406
  box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
407
  }
408
 
409
+ .litespeed-wrap .litespeed-btn-success:hover,
410
+ .litespeed-btn-success:hover {
411
  background: #36b0b0;
412
  }
413
 
414
+ .litespeed-wrap .litespeed-btn-primary,
415
+ .litespeed-btn-primary {
416
  color: #538ac6;
417
  border: 1px solid #538ac6;
418
  -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
420
  box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
421
  }
422
 
423
+ .litespeed-wrap .litespeed-btn-primary:hover,
424
+ .litespeed-btn-primary:hover {
425
  background: #538ac6;
426
  border-color: #538ac6;
427
  }
428
 
429
+ .litespeed-wrap .litespeed-btn-default,
430
+ .litespeed-btn-default {
431
+ color: #a7a7a7;
432
+ border: 1px solid #a7a7a7;
433
+ -moz-box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
434
+ -webkit-box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
435
+ box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
436
+ }
437
+
438
+ .litespeed-wrap .litespeed-btn-default:hover,
439
+ .litespeed-btn-default:hover {
440
+ background: #a7a7a7;
441
+ }
442
+
443
+ .litespeed-wrap .litespeed-btn-default.disabled:hover,
444
+ .litespeed-btn-default.disabled:hover {
445
+ color: #a7a7a7;
446
+ background: #fff;
447
+ }
448
+
449
+
450
+ .litespeed-wrap .litespeed-btn-xs,
451
+ .litespeed-btn-xs {
452
  padding: 1px 8px;
453
  font-size: 13px;
454
  line-height: 1.5;
456
  min-width: 100px;
457
  }
458
 
459
+ .litespeed-wrap .litespeed-btn-tiny,
460
+ .litespeed-btn-tiny {
461
+ padding: 1px 8px;
462
+ font-size: 13px;
463
+ line-height: 1.5;
464
+ border-radius: 2px;
465
+ min-width: 14px ;
466
+ }
467
 
468
  /********************************* switch *******************************/
469
  .litespeed-switch {
887
  .litespeed-tick {
888
  display: inline-block;
889
  min-width: 125px;
890
+ background: #f2f9ff;
891
  padding: 5px 0 5px 0px;
892
  border-radius: 3px;
893
  cursor: pointer;
1144
  margin-left: 20px;
1145
  }
1146
 
1147
+ /********************************* admin -> media lib icon *******************************/
1148
+ .litespeed-media-href {
1149
+ display: inline-table;
1150
+ }
1151
+
1152
+
1153
+ [class*="litespeed-icon-media-"] {
1154
+ background-size: contain;
1155
+ width: 25px;
1156
+ height: 25px;
1157
+ vertical-align: middle;
1158
+ margin: 0;
1159
+ background-repeat: no-repeat;
1160
+ display: inline-block;
1161
+ }
1162
+
1163
+ [class*="litespeed-icon-media-"]:hover {
1164
+ opacity: 0.7 ;
1165
+ }
1166
+
1167
+ .litespeed-icon-media-webp { background-image: url("../img/icons/img_webp.svg") ; }
1168
+ .litespeed-icon-media-webp-disabled { background-image: url("../img/icons/img_webp_disabled.svg") ; }
1169
+ .litespeed-icon-media-optm { background-image: url("../img/icons/img_optm.svg") ; }
1170
+ .litespeed-icon-media-optm-disabled { background-image: url("../img/icons/img_optm_disabled.svg") ; }
1171
+
1172
+ p.litespeed-txt-webp {
1173
+ color: #83b04a ;
1174
+ }
1175
+
1176
+ p.litespeed-txt-ori {
1177
+ color: #5967b3 ;
1178
+ }
1179
+
1180
+ p.litespeed-txt-disabled {
1181
+ color: #ced2d9 ;
1182
+ }
1183
+
1184
+ .litespeed-media-svg {
1185
+ vertical-align: middle;
1186
+ margin: 5px;
1187
+ width: 25px;
1188
+ height: auto;
1189
+ }
1190
+ .litespeed-pie_info {
1191
+ }
1192
+
1193
+ circle.litespeed-pie_bg {
1194
+ stroke: #cfe7f2;
1195
+ stroke-width: 2;
1196
+ fill: none;
1197
+ cx: 17.5;
1198
+ cy: 17.5;
1199
+ r: 16.5;
1200
+ }
1201
+
1202
+ circle.litespeed-pie_circle {
1203
+ animation: litespeed-pie-fill 2s reverse; /* 1 */
1204
+ stroke: #00afbf;
1205
+ stroke-width: 2;
1206
+ stroke-dasharray: 30, 100;
1207
+ stroke-linecap: round;
1208
+ fill: none;
1209
+ cx: 17;
1210
+ cy: 17.5;
1211
+ r: 16.5;
1212
+ }
1213
+
1214
+
1215
+ /********************************* utility *******************************/
1216
+ .litespeed-unicode-refresh{
1217
+
1218
+ }
1219
+
1220
+
1221
  /********************************* todo *******************************/
1222
  /* input field */
1223
  .litespeed-textarea {
1263
  border-radius: 3px;
1264
  }
1265
 
1266
+ .litespeed-wrap .litespeed-float-submit {
1267
  position: absolute;
1268
  right: 10px;
1269
+ top: 0;
1270
+ margin-top: 0;
1271
  }
1272
 
1273
  .litespeed-body input,.litespeed-body textarea {
img/icons/img_optm.svg ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="30px" height="30px" viewBox="0 0 30 30" enable-background="new 0 0 30 30" xml:space="preserve">
6
+ <path fill="#5968B3" d="M17.181,20.485H2.421l12.867-8.158l3.352,3.626l0.637,0.018c0.034-0.048,0.069-0.097,0.105-0.144
7
+ l-0.293-0.826c-0.12-0.34-0.023-0.713,0.248-0.951c0.308-0.27,0.642-0.512,0.99-0.72c0.137-0.081,0.291-0.123,0.448-0.123
8
+ c0.191,0,0.381,0.064,0.532,0.18l0.694,0.534c0.058-0.02,0.115-0.039,0.173-0.057l0.248-0.84c0.102-0.346,0.399-0.591,0.759-0.624
9
+ c0.146-0.014,0.298-0.017,0.448-0.021V6.147H1.62V21.29h15.78c-0.071-0.215-0.155-0.416-0.207-0.647
10
+ C17.181,20.59,17.183,20.538,17.181,20.485z M10.705,8.189c0.956,0,1.731,0.775,1.731,1.731c0,0.956-0.775,1.73-1.731,1.73
11
+ c-0.956,0-1.731-0.774-1.731-1.73C8.974,8.964,9.75,8.189,10.705,8.189z M2.368,9.563l7.593,5.435l-7.593,4.729V9.563z
12
+ M23.63,17.247v3.792c-0.466-0.04-0.886-0.239-1.196-0.554h0.395l-0.911-0.986c-0.021-0.115-0.036-0.233-0.036-0.355
13
+ C21.881,18.145,22.653,17.332,23.63,17.247z M24.298,20.979v-3.673c0.335,0.092,0.634,0.268,0.869,0.511v2.652
14
+ C24.932,20.712,24.633,20.888,24.298,20.979z M19.383,22.458l-0.163,0.458H0.083V4.582h25.084v8.451l-0.003-0.008
15
+ c-0.102-0.346-0.399-0.591-0.759-0.625c-0.035-0.003-0.071-0.002-0.107-0.005V5.451H0.952v16.596h16.776
16
+ c0.163,0.176,0.397,0.286,0.666,0.291l0.883-0.024C19.311,22.362,19.346,22.41,19.383,22.458z M23.794,25.418
17
+ c-0.191,0-0.378-0.012-0.563-0.027c-0.154-0.014-0.284-0.119-0.328-0.268l-0.326-1.106c-0.224-0.058-0.444-0.13-0.659-0.217
18
+ l-0.913,0.702c-0.122,0.094-0.29,0.104-0.422,0.024c-0.326-0.195-0.634-0.419-0.916-0.666c-0.115-0.102-0.157-0.263-0.106-0.408
19
+ l0.387-1.088c-0.149-0.179-0.286-0.365-0.408-0.559l-1.158,0.032c-0.149-0.003-0.294-0.086-0.354-0.227
20
+ c-0.143-0.331-0.259-0.694-0.346-1.078c-0.033-0.149,0.027-0.305,0.154-0.392l0.95-0.65c-0.009-0.115-0.014-0.231-0.014-0.349
21
+ s0.005-0.232,0.014-0.348l-0.95-0.65c-0.127-0.087-0.188-0.242-0.154-0.393c0.087-0.382,0.203-0.745,0.346-1.078
22
+ c0.061-0.143,0.19-0.232,0.354-0.228l1.158,0.032c0.122-0.193,0.259-0.38,0.408-0.557l-0.387-1.088
23
+ c-0.051-0.145-0.009-0.306,0.106-0.408c0.285-0.25,0.594-0.474,0.917-0.666c0.133-0.078,0.299-0.068,0.421,0.025l0.913,0.702
24
+ c0.219-0.088,0.439-0.161,0.659-0.216l0.326-1.105c0.043-0.147,0.172-0.253,0.325-0.268c0.371-0.035,0.758-0.035,1.132,0
25
+ c0.153,0.014,0.282,0.12,0.325,0.268l0.326,1.104c0.22,0.056,0.44,0.128,0.659,0.217l0.914-0.702
26
+ c0.121-0.094,0.288-0.104,0.421-0.024c0.325,0.194,0.633,0.418,0.916,0.666c0.116,0.101,0.158,0.263,0.106,0.408l-0.387,1.088
27
+ c0.149,0.177,0.286,0.363,0.408,0.557l1.158-0.032c0.137-0.004,0.294,0.085,0.354,0.228c0.144,0.334,0.26,0.696,0.347,1.078
28
+ c0.034,0.149-0.027,0.306-0.154,0.393l-0.95,0.65c0.009,0.115,0.013,0.23,0.013,0.348s-0.004,0.233-0.013,0.349l0.95,0.65
29
+ c0.127,0.087,0.188,0.242,0.154,0.393c-0.087,0.383-0.203,0.745-0.347,1.077c-0.062,0.141-0.214,0.228-0.354,0.227l-1.158-0.032
30
+ c-0.121,0.193-0.258,0.38-0.408,0.559l0.387,1.088c0.052,0.146,0.01,0.307-0.106,0.408c-0.283,0.248-0.592,0.472-0.916,0.666
31
+ c-0.132,0.08-0.299,0.07-0.421-0.024L25.67,23.8c-0.215,0.087-0.436,0.159-0.659,0.217l-0.326,1.106
32
+ c-0.044,0.148-0.174,0.254-0.328,0.268C24.171,25.406,23.983,25.418,23.794,25.418z M23.548,24.661c0.162,0.008,0.328,0.008,0.491,0
33
+ l0.314-1.067c0.039-0.133,0.148-0.232,0.284-0.261c0.317-0.065,0.631-0.169,0.93-0.306c0.125-0.061,0.273-0.043,0.385,0.044
34
+ l0.882,0.677c0.137-0.091,0.271-0.188,0.399-0.29l-0.374-1.05c-0.046-0.132-0.017-0.277,0.078-0.38
35
+ c0.225-0.245,0.419-0.51,0.576-0.788c0.068-0.121,0.191-0.206,0.337-0.19l1.115,0.031c0.056-0.15,0.105-0.306,0.149-0.468
36
+ l-0.919-0.629c-0.115-0.079-0.177-0.216-0.16-0.355c0.02-0.159,0.03-0.321,0.03-0.486s-0.011-0.326-0.03-0.485
37
+ c-0.017-0.139,0.045-0.276,0.16-0.355l0.919-0.629c-0.044-0.162-0.094-0.318-0.149-0.47l-1.115,0.031
38
+ c-0.143-0.006-0.268-0.069-0.337-0.189c-0.158-0.279-0.352-0.544-0.576-0.787c-0.095-0.102-0.124-0.248-0.078-0.38l0.374-1.049
39
+ c-0.129-0.103-0.262-0.199-0.399-0.29l-0.882,0.677c-0.11,0.084-0.258,0.101-0.383,0.044c-0.309-0.14-0.622-0.242-0.931-0.305
40
+ c-0.136-0.028-0.246-0.128-0.285-0.262l-0.314-1.067c-0.164-0.009-0.328-0.008-0.491,0l-0.314,1.067
41
+ c-0.039,0.133-0.149,0.234-0.285,0.262c-0.309,0.063-0.622,0.165-0.931,0.305c-0.128,0.055-0.274,0.04-0.384-0.044l-0.881-0.677
42
+ c-0.137,0.09-0.271,0.188-0.398,0.29l0.373,1.05c0.046,0.132,0.017,0.277-0.078,0.38c-0.224,0.243-0.418,0.508-0.577,0.787
43
+ c-0.067,0.12-0.204,0.18-0.336,0.189l-1.115-0.031c-0.056,0.15-0.105,0.308-0.148,0.47l0.918,0.629
44
+ c0.115,0.079,0.178,0.216,0.16,0.354c-0.019,0.159-0.03,0.321-0.03,0.486s0.012,0.327,0.031,0.487
45
+ c0.017,0.139-0.046,0.275-0.161,0.354l-0.919,0.629c0.044,0.162,0.094,0.318,0.149,0.468l1.115-0.031
46
+ c0.135-0.012,0.269,0.069,0.337,0.189c0.158,0.279,0.352,0.544,0.577,0.789c0.094,0.103,0.123,0.249,0.077,0.38l-0.373,1.05
47
+ c0.128,0.102,0.262,0.199,0.399,0.29l0.88-0.677c0.11-0.085,0.259-0.103,0.385-0.044c0.3,0.137,0.613,0.24,0.932,0.306
48
+ c0.135,0.028,0.244,0.128,0.283,0.261L23.548,24.661z M23.794,22.306c-1.744,0-3.163-1.419-3.163-3.162
49
+ c0-1.744,1.419-3.163,3.163-3.163c1.743,0,3.162,1.419,3.162,3.163C26.956,20.887,25.537,22.306,23.794,22.306z M23.794,16.73
50
+ c-1.33,0-2.413,1.082-2.413,2.413c0,1.33,1.083,2.412,2.413,2.412s2.412-1.082,2.412-2.412C26.206,17.813,25.124,16.73,23.794,16.73
51
+ z"/>
52
+ </svg>
img/icons/img_optm_disabled.svg ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="30px" height="30px" viewBox="0 0 30 30" enable-background="new 0 0 30 30" xml:space="preserve">
6
+ <path fill="#CED1D9" d="M17.181,20.485H2.421l12.867-8.158l3.352,3.626l0.637,0.018c0.034-0.048,0.069-0.097,0.105-0.144
7
+ l-0.293-0.826c-0.12-0.34-0.023-0.713,0.248-0.951c0.308-0.27,0.642-0.512,0.99-0.72c0.137-0.081,0.291-0.123,0.448-0.123
8
+ c0.191,0,0.381,0.064,0.532,0.18l0.694,0.534c0.058-0.02,0.115-0.039,0.173-0.057l0.248-0.84c0.102-0.346,0.399-0.591,0.759-0.624
9
+ c0.146-0.014,0.298-0.017,0.448-0.021V6.147H1.62V21.29h15.78c-0.071-0.215-0.155-0.416-0.207-0.647
10
+ C17.181,20.59,17.183,20.538,17.181,20.485z M10.705,8.189c0.956,0,1.731,0.775,1.731,1.731c0,0.956-0.775,1.73-1.731,1.73
11
+ c-0.956,0-1.731-0.774-1.731-1.73C8.974,8.964,9.75,8.189,10.705,8.189z M2.368,9.563l7.593,5.435l-7.593,4.729V9.563z
12
+ M23.63,17.247v3.792c-0.466-0.04-0.886-0.239-1.196-0.554h0.395l-0.911-0.986c-0.021-0.115-0.036-0.233-0.036-0.355
13
+ C21.881,18.145,22.653,17.332,23.63,17.247z M24.298,20.979v-3.673c0.335,0.092,0.634,0.268,0.869,0.511v2.652
14
+ C24.932,20.712,24.633,20.888,24.298,20.979z M19.383,22.458l-0.163,0.458H0.083V4.582h25.084v8.451l-0.003-0.008
15
+ c-0.102-0.346-0.399-0.591-0.759-0.625c-0.035-0.003-0.071-0.002-0.107-0.005V5.451H0.952v16.596h16.776
16
+ c0.163,0.176,0.397,0.286,0.666,0.291l0.883-0.024C19.311,22.362,19.346,22.41,19.383,22.458z M23.794,25.418
17
+ c-0.191,0-0.378-0.012-0.563-0.027c-0.154-0.014-0.284-0.119-0.328-0.268l-0.326-1.106c-0.224-0.058-0.444-0.13-0.659-0.217
18
+ l-0.913,0.702c-0.122,0.094-0.29,0.104-0.422,0.024c-0.326-0.195-0.634-0.419-0.916-0.666c-0.115-0.102-0.157-0.263-0.106-0.408
19
+ l0.387-1.088c-0.149-0.179-0.286-0.365-0.408-0.559l-1.158,0.032c-0.149-0.003-0.294-0.086-0.354-0.227
20
+ c-0.143-0.331-0.259-0.694-0.346-1.078c-0.033-0.149,0.027-0.305,0.154-0.392l0.95-0.65c-0.009-0.115-0.014-0.231-0.014-0.349
21
+ s0.005-0.232,0.014-0.348l-0.95-0.65c-0.127-0.087-0.188-0.242-0.154-0.393c0.087-0.382,0.203-0.745,0.346-1.078
22
+ c0.061-0.143,0.19-0.232,0.354-0.228l1.158,0.032c0.122-0.193,0.259-0.38,0.408-0.557l-0.387-1.088
23
+ c-0.051-0.145-0.009-0.306,0.106-0.408c0.285-0.25,0.594-0.474,0.917-0.666c0.133-0.078,0.299-0.068,0.421,0.025l0.913,0.702
24
+ c0.219-0.088,0.439-0.161,0.659-0.216l0.326-1.105c0.043-0.147,0.172-0.253,0.325-0.268c0.371-0.035,0.758-0.035,1.132,0
25
+ c0.153,0.014,0.282,0.12,0.325,0.268l0.326,1.104c0.22,0.056,0.44,0.128,0.659,0.217l0.914-0.702
26
+ c0.121-0.094,0.288-0.104,0.421-0.024c0.325,0.194,0.633,0.418,0.916,0.666c0.116,0.101,0.158,0.263,0.106,0.408l-0.387,1.088
27
+ c0.149,0.177,0.286,0.363,0.408,0.557l1.158-0.032c0.137-0.004,0.294,0.085,0.354,0.228c0.144,0.334,0.26,0.696,0.347,1.078
28
+ c0.034,0.149-0.027,0.306-0.154,0.393l-0.95,0.65c0.009,0.115,0.013,0.23,0.013,0.348s-0.004,0.233-0.013,0.349l0.95,0.65
29
+ c0.127,0.087,0.188,0.242,0.154,0.393c-0.087,0.383-0.203,0.745-0.347,1.077c-0.062,0.141-0.214,0.228-0.354,0.227l-1.158-0.032
30
+ c-0.121,0.193-0.258,0.38-0.408,0.559l0.387,1.088c0.052,0.146,0.01,0.307-0.106,0.408c-0.283,0.248-0.592,0.472-0.916,0.666
31
+ c-0.132,0.08-0.299,0.07-0.421-0.024L25.67,23.8c-0.215,0.087-0.436,0.159-0.659,0.217l-0.326,1.106
32
+ c-0.044,0.148-0.174,0.254-0.328,0.268C24.171,25.406,23.983,25.418,23.794,25.418z M23.548,24.661c0.162,0.008,0.328,0.008,0.491,0
33
+ l0.314-1.067c0.039-0.133,0.148-0.232,0.284-0.261c0.317-0.065,0.631-0.169,0.93-0.306c0.125-0.061,0.273-0.043,0.385,0.044
34
+ l0.882,0.677c0.137-0.091,0.271-0.188,0.399-0.29l-0.374-1.05c-0.046-0.132-0.017-0.277,0.078-0.38
35
+ c0.225-0.245,0.419-0.51,0.576-0.788c0.068-0.121,0.191-0.206,0.337-0.19l1.115,0.031c0.056-0.15,0.105-0.306,0.149-0.468
36
+ l-0.919-0.629c-0.115-0.079-0.177-0.216-0.16-0.355c0.02-0.159,0.03-0.321,0.03-0.486s-0.011-0.326-0.03-0.485
37
+ c-0.017-0.139,0.045-0.276,0.16-0.355l0.919-0.629c-0.044-0.162-0.094-0.318-0.149-0.47l-1.115,0.031
38
+ c-0.143-0.006-0.268-0.069-0.337-0.189c-0.158-0.279-0.352-0.544-0.576-0.787c-0.095-0.102-0.124-0.248-0.078-0.38l0.374-1.049
39
+ c-0.129-0.103-0.262-0.199-0.399-0.29l-0.882,0.677c-0.11,0.084-0.258,0.101-0.383,0.044c-0.309-0.14-0.622-0.242-0.931-0.305
40
+ c-0.136-0.028-0.246-0.128-0.285-0.262l-0.314-1.067c-0.164-0.009-0.328-0.008-0.491,0l-0.314,1.067
41
+ c-0.039,0.133-0.149,0.234-0.285,0.262c-0.309,0.063-0.622,0.165-0.931,0.305c-0.128,0.055-0.274,0.04-0.384-0.044l-0.881-0.677
42
+ c-0.137,0.09-0.271,0.188-0.398,0.29l0.373,1.05c0.046,0.132,0.017,0.277-0.078,0.38c-0.224,0.243-0.418,0.508-0.577,0.787
43
+ c-0.067,0.12-0.204,0.18-0.336,0.189l-1.115-0.031c-0.056,0.15-0.105,0.308-0.148,0.47l0.918,0.629
44
+ c0.115,0.079,0.178,0.216,0.16,0.354c-0.019,0.159-0.03,0.321-0.03,0.486s0.012,0.327,0.031,0.487
45
+ c0.017,0.139-0.046,0.275-0.161,0.354l-0.919,0.629c0.044,0.162,0.094,0.318,0.149,0.468l1.115-0.031
46
+ c0.135-0.012,0.269,0.069,0.337,0.189c0.158,0.279,0.352,0.544,0.577,0.789c0.094,0.103,0.123,0.249,0.077,0.38l-0.373,1.05
47
+ c0.128,0.102,0.262,0.199,0.399,0.29l0.88-0.677c0.11-0.085,0.259-0.103,0.385-0.044c0.3,0.137,0.613,0.24,0.932,0.306
48
+ c0.135,0.028,0.244,0.128,0.283,0.261L23.548,24.661z M23.794,22.306c-1.744,0-3.163-1.419-3.163-3.162
49
+ c0-1.744,1.419-3.163,3.163-3.163c1.743,0,3.162,1.419,3.162,3.163C26.956,20.887,25.537,22.306,23.794,22.306z M23.794,16.73
50
+ c-1.33,0-2.413,1.082-2.413,2.413c0,1.33,1.083,2.412,2.413,2.412s2.412-1.082,2.412-2.412C26.206,17.813,25.124,16.73,23.794,16.73
51
+ z"/>
52
+ </svg>
img/icons/img_webp.svg ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="30px" height="30px" viewBox="0 0 30 30" enable-background="new 0 0 30 30" xml:space="preserve">
6
+ <circle fill="none" cx="15" cy="15.894" r="5.317"/>
7
+ <path fill="#83B04A" d="M8.71,5.417H4.312V5.124c0-0.608,0.492-1.101,1.1-1.101h2.198c0.607,0,1.101,0.492,1.101,1.101V5.417z
8
+ M29.481,8.01v15.766c0,1.217-0.984,2.201-2.199,2.201H2.719c-1.215,0-2.2-0.984-2.2-2.201V8.01c0-1.215,0.985-2.2,2.2-2.2h17.311
9
+ l0.06,0.041l-0.596,0.408c-0.273,0.188-0.392,0.539-0.288,0.85c0.096,0.296,0.368,0.5,0.733,0.519l0.722-0.021l-0.241,0.679
10
+ c-0.111,0.312-0.001,0.665,0.266,0.858c0.128,0.093,0.28,0.143,0.439,0.143c0.162,0,0.323-0.053,0.458-0.155l0.57-0.439l0.205,0.695
11
+ c0.097,0.319,0.386,0.534,0.719,0.534s0.622-0.215,0.72-0.538L24,8.691l0.574,0.442c0.13,0.098,0.291,0.152,0.454,0.152
12
+ c0.158,0,0.31-0.048,0.442-0.143c0.266-0.194,0.374-0.547,0.264-0.857l-0.241-0.68l0.752,0.021c0.336-0.012,0.605-0.212,0.701-0.514
13
+ c0.104-0.314-0.014-0.665-0.288-0.854L26.063,5.85l0.06-0.041h1.159C28.497,5.81,29.481,6.795,29.481,8.01z M20.317,15.894
14
+ c0-2.937-2.38-5.317-5.317-5.317c-2.936,0-5.316,2.381-5.316,5.317s2.381,5.317,5.316,5.317
15
+ C17.938,21.211,20.317,18.83,20.317,15.894z M26.376,6.67c0.091,0.063,0.131,0.178,0.096,0.283
16
+ c-0.033,0.105-0.121,0.168-0.244,0.173l-1.45-0.041l0.486,1.367c0.037,0.104,0.001,0.221-0.088,0.286
17
+ c-0.09,0.064-0.212,0.063-0.3-0.004L23.727,7.85l-0.41,1.392c-0.032,0.106-0.13,0.179-0.24,0.179s-0.208-0.073-0.24-0.179
18
+ l-0.41-1.392l-1.148,0.885c-0.089,0.066-0.211,0.068-0.299,0.004c-0.09-0.065-0.126-0.182-0.089-0.286l0.486-1.367l-1.451,0.041
19
+ c-0.114-0.006-0.21-0.067-0.244-0.173c-0.035-0.105,0.005-0.221,0.096-0.283l1.197-0.82l-0.06-0.041l-1.138-0.78
20
+ c-0.091-0.063-0.131-0.178-0.096-0.283c0.034-0.105,0.132-0.163,0.244-0.173l1.451,0.041L20.89,3.248
21
+ c-0.037-0.104-0.001-0.221,0.089-0.286c0.088-0.065,0.21-0.063,0.299,0.004l1.148,0.884l0.41-1.392c0.064-0.213,0.416-0.213,0.48,0
22
+ l0.41,1.392l1.149-0.885c0.088-0.068,0.21-0.069,0.3-0.004c0.089,0.065,0.125,0.182,0.088,0.286l-0.486,1.366l1.45-0.04
23
+ c0.121,0.008,0.211,0.067,0.244,0.173c0.035,0.105-0.005,0.221-0.096,0.283l-1.138,0.78l-0.06,0.041L26.376,6.67z M25.393,6.603
24
+ l-0.798-0.547c-0.067-0.046-0.108-0.124-0.108-0.206c0-0.014,0.008-0.027,0.01-0.041c0.012-0.066,0.043-0.127,0.099-0.166
25
+ l0.798-0.547l-0.967,0.027c-0.069,0.017-0.16-0.036-0.209-0.103s-0.061-0.153-0.033-0.231l0.324-0.911l-0.766,0.589
26
+ c-0.064,0.051-0.15,0.066-0.229,0.04c-0.078-0.025-0.14-0.088-0.163-0.167l-0.273-0.929l-0.273,0.929
27
+ c-0.023,0.079-0.085,0.142-0.163,0.167c-0.078,0.026-0.164,0.012-0.229-0.04L21.646,3.88l0.324,0.91
28
+ c0.027,0.078,0.016,0.164-0.033,0.231c-0.048,0.066-0.142,0.101-0.209,0.103L20.76,5.097l0.798,0.547
29
+ c0.056,0.039,0.087,0.1,0.099,0.166c0.002,0.014,0.01,0.026,0.01,0.041c0,0.083-0.041,0.16-0.108,0.206L20.76,6.603l0.968-0.027
30
+ c0.086,0,0.161,0.037,0.209,0.103c0.049,0.067,0.061,0.153,0.033,0.231l-0.324,0.91l0.765-0.589
31
+ c0.044-0.034,0.098-0.052,0.152-0.052c0.026,0,0.052,0.004,0.077,0.012c0.078,0.025,0.14,0.088,0.163,0.167l0.273,0.929l0.273-0.929
32
+ c0.023-0.079,0.085-0.142,0.163-0.167c0.079-0.024,0.165-0.011,0.229,0.04l0.766,0.589l-0.324-0.91
33
+ c-0.027-0.078-0.016-0.164,0.033-0.231c0.048-0.067,0.121-0.122,0.209-0.103L25.393,6.603z"/>
34
+ </svg>
img/icons/img_webp_disabled.svg ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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="30px" height="30px" viewBox="0 0 30 30" enable-background="new 0 0 30 30" xml:space="preserve">
6
+ <circle fill="none" cx="15" cy="15.894" r="5.317"/>
7
+ <path fill="#D3D9CE" d="M8.71,5.417H4.312V5.124c0-0.608,0.492-1.101,1.1-1.101h2.198c0.607,0,1.101,0.492,1.101,1.101V5.417z
8
+ M29.481,8.01v15.766c0,1.217-0.984,2.201-2.199,2.201H2.719c-1.215,0-2.2-0.984-2.2-2.201V8.01c0-1.215,0.985-2.2,2.2-2.2h17.311
9
+ l0.06,0.041l-0.596,0.408c-0.273,0.188-0.392,0.539-0.288,0.85c0.096,0.296,0.368,0.5,0.733,0.519l0.722-0.021l-0.241,0.679
10
+ c-0.111,0.312-0.001,0.665,0.266,0.858c0.128,0.093,0.28,0.143,0.439,0.143c0.162,0,0.323-0.053,0.458-0.155l0.57-0.439l0.205,0.695
11
+ c0.097,0.319,0.386,0.534,0.719,0.534s0.622-0.215,0.72-0.538L24,8.691l0.574,0.442c0.13,0.098,0.291,0.152,0.454,0.152
12
+ c0.158,0,0.31-0.048,0.442-0.143c0.266-0.194,0.374-0.547,0.264-0.857l-0.241-0.68l0.752,0.021c0.336-0.012,0.605-0.212,0.701-0.514
13
+ c0.104-0.314-0.014-0.665-0.288-0.854L26.063,5.85l0.06-0.041h1.159C28.497,5.81,29.481,6.795,29.481,8.01z M20.317,15.894
14
+ c0-2.937-2.38-5.317-5.317-5.317c-2.936,0-5.316,2.381-5.316,5.317s2.381,5.317,5.316,5.317
15
+ C17.938,21.211,20.317,18.83,20.317,15.894z M26.376,6.67c0.091,0.063,0.131,0.178,0.096,0.283
16
+ c-0.033,0.105-0.121,0.168-0.244,0.173l-1.45-0.041l0.486,1.367c0.037,0.104,0.001,0.221-0.088,0.286
17
+ c-0.09,0.064-0.212,0.063-0.3-0.004L23.727,7.85l-0.41,1.392c-0.032,0.106-0.13,0.179-0.24,0.179s-0.208-0.073-0.24-0.179
18
+ l-0.41-1.392l-1.148,0.885c-0.089,0.066-0.211,0.068-0.299,0.004c-0.09-0.065-0.126-0.182-0.089-0.286l0.486-1.367l-1.451,0.041
19
+ c-0.114-0.006-0.21-0.067-0.244-0.173c-0.035-0.105,0.005-0.221,0.096-0.283l1.197-0.82l-0.06-0.041l-1.138-0.78
20
+ c-0.091-0.063-0.131-0.178-0.096-0.283c0.034-0.105,0.132-0.163,0.244-0.173l1.451,0.041L20.89,3.248
21
+ c-0.037-0.104-0.001-0.221,0.089-0.286c0.088-0.065,0.21-0.063,0.299,0.004l1.148,0.884l0.41-1.392c0.064-0.213,0.416-0.213,0.48,0
22
+ l0.41,1.392l1.149-0.885c0.088-0.068,0.21-0.069,0.3-0.004c0.089,0.065,0.125,0.182,0.088,0.286l-0.486,1.366l1.45-0.04
23
+ c0.121,0.008,0.211,0.067,0.244,0.173c0.035,0.105-0.005,0.221-0.096,0.283l-1.138,0.78l-0.06,0.041L26.376,6.67z M25.393,6.603
24
+ l-0.798-0.547c-0.067-0.046-0.108-0.124-0.108-0.206c0-0.014,0.008-0.027,0.01-0.041c0.012-0.066,0.043-0.127,0.099-0.166
25
+ l0.798-0.547l-0.967,0.027c-0.069,0.017-0.16-0.036-0.209-0.103s-0.061-0.153-0.033-0.231l0.324-0.911l-0.766,0.589
26
+ c-0.064,0.051-0.15,0.066-0.229,0.04c-0.078-0.025-0.14-0.088-0.163-0.167l-0.273-0.929l-0.273,0.929
27
+ c-0.023,0.079-0.085,0.142-0.163,0.167c-0.078,0.026-0.164,0.012-0.229-0.04L21.646,3.88l0.324,0.91
28
+ c0.027,0.078,0.016,0.164-0.033,0.231c-0.048,0.066-0.142,0.101-0.209,0.103L20.76,5.097l0.798,0.547
29
+ c0.056,0.039,0.087,0.1,0.099,0.166c0.002,0.014,0.01,0.026,0.01,0.041c0,0.083-0.041,0.16-0.108,0.206L20.76,6.603l0.968-0.027
30
+ c0.086,0,0.161,0.037,0.209,0.103c0.049,0.067,0.061,0.153,0.033,0.231l-0.324,0.91l0.765-0.589
31
+ c0.044-0.034,0.098-0.052,0.152-0.052c0.026,0,0.052,0.004,0.077,0.012c0.078,0.025,0.14,0.088,0.163,0.167l0.273,0.929l0.273-0.929
32
+ c0.023-0.079,0.085-0.142,0.163-0.167c0.079-0.024,0.165-0.011,0.229,0.04l0.766,0.589l-0.324-0.91
33
+ c-0.027-0.078-0.016-0.164,0.033-0.231c0.048-0.067,0.121-0.122,0.209-0.103L25.393,6.603z"/>
34
+ </svg>
inc/api.class.php CHANGED
@@ -169,6 +169,17 @@ class LiteSpeed_Cache_API
169
  LiteSpeed_Cache_Tag::add($tags) ;
170
  }
171
 
 
 
 
 
 
 
 
 
 
 
 
172
  /**
173
  * Add vary
174
  *
@@ -191,6 +202,28 @@ class LiteSpeed_Cache_API
191
  LiteSpeed_Cache_Purge::purge_all() ;
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  /**
195
  * Purge single action
196
  *
@@ -398,9 +431,20 @@ class LiteSpeed_Cache_API
398
  * @since 1.1.3
399
  * @access public
400
  */
401
- public static function debug($info)
 
 
 
 
 
 
 
 
 
 
 
402
  {
403
- LiteSpeed_Cache_Log::debug($info) ;
404
  }
405
 
406
  /**
@@ -447,4 +491,15 @@ class LiteSpeed_Cache_API
447
  add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
450
  }
169
  LiteSpeed_Cache_Tag::add($tags) ;
170
  }
171
 
172
+ /**
173
+ * Add public tag to cache
174
+ *
175
+ * @since 1.6.3
176
+ * @access public
177
+ */
178
+ public static function add_private( $tags )
179
+ {
180
+ LiteSpeed_Cache_Tag::add_private( $tags ) ;
181
+ }
182
+
183
  /**
184
  * Add vary
185
  *
202
  LiteSpeed_Cache_Purge::purge_all() ;
203
  }
204
 
205
+ /**
206
+ * Purge all private
207
+ *
208
+ * @since 1.6.3
209
+ * @access public
210
+ */
211
+ public static function purge_private_all()
212
+ {
213
+ LiteSpeed_Cache_Purge::add_private( '*' ) ;
214
+ }
215
+
216
+ /**
217
+ * Purge private tag
218
+ *
219
+ * @since 1.6.3
220
+ * @access public
221
+ */
222
+ public static function purge_private( $tags )
223
+ {
224
+ LiteSpeed_Cache_Purge::add_private( $tags ) ;
225
+ }
226
+
227
  /**
228
  * Purge single action
229
  *
431
  * @since 1.1.3
432
  * @access public
433
  */
434
+ public static function debug( $info, $backtrace_limit = false )
435
+ {
436
+ LiteSpeed_Cache_Log::debug( $info, $backtrace_limit ) ;
437
+ }
438
+
439
+ /**
440
+ * Log debug info ( advanced mode )
441
+ *
442
+ * @since 1.6.6.1
443
+ * @access public
444
+ */
445
+ public static function debug2( $info, $backtrace_limit = false )
446
  {
447
+ LiteSpeed_Cache_Log::debug2( $info, $backtrace_limit ) ;
448
  }
449
 
450
  /**
491
  add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
492
  }
493
 
494
+ /**
495
+ * Hook to litespeed init
496
+ *
497
+ * @since 1.6.6
498
+ * @access public
499
+ */
500
+ public static function hook_init( $hook )
501
+ {
502
+ add_action('litespeed_init', $hook) ;
503
+ }
504
+
505
  }
inc/cdn.class.php CHANGED
@@ -116,6 +116,27 @@ class LiteSpeed_Cache_CDN
116
 
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  /**
120
  * Check if the host is the CDN internal host
121
  *
@@ -144,12 +165,12 @@ class LiteSpeed_Cache_CDN
144
  * @access public
145
  * @return string The content that is after optimization
146
  */
147
- public static function run( $content )
148
  {
149
  $instance = self::get_instance() ;
150
  $instance->content = $content ;
151
 
152
- $instance->_process() ;
153
  return $instance->content ;
154
  }
155
 
@@ -173,6 +194,15 @@ class LiteSpeed_Cache_CDN
173
  return false ;
174
  }
175
 
 
 
 
 
 
 
 
 
 
176
  return true ;
177
  }
178
 
@@ -182,14 +212,14 @@ class LiteSpeed_Cache_CDN
182
  * @since 1.2.3
183
  * @access private
184
  */
185
- private function _process()
186
  {
187
  if ( defined( self::BYPASS ) ) {
188
  LiteSpeed_Cache_Log::debug2( 'CDN bypass' ) ;
189
  return ;
190
  }
191
 
192
- LiteSpeed_Cache_Log::debug( 'CDN _process' ) ;
193
 
194
  // Start replacing img src
195
  if ( $this->cfg_cdn_inc_img ) {
@@ -357,8 +387,8 @@ class LiteSpeed_Cache_CDN
357
 
358
  // Only images under wp-cotnent/wp-includes can be replaced
359
  if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
360
- if ( defined( 'UPLOADS' ) && stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
361
- LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match ' ) ;
362
  return false ;
363
  }
364
  }
116
 
117
  }
118
 
119
+ /**
120
+ * If include css/js in CDN
121
+ *
122
+ * @since 1.6.2.1
123
+ * @return bool true if included in CDN
124
+ */
125
+ public static function inc_type( $type )
126
+ {
127
+ $instance = self::get_instance() ;
128
+
129
+ if ( $type == 'css' && $instance->cfg_cdn_inc_css ) {
130
+ return true ;
131
+ }
132
+
133
+ if ( $type == 'js' && $instance->cfg_cdn_inc_js ) {
134
+ return true ;
135
+ }
136
+
137
+ return false ;
138
+ }
139
+
140
  /**
141
  * Check if the host is the CDN internal host
142
  *
165
  * @access public
166
  * @return string The content that is after optimization
167
  */
168
+ public static function finalize( $content )
169
  {
170
  $instance = self::get_instance() ;
171
  $instance->content = $content ;
172
 
173
+ $instance->_finalize() ;
174
  return $instance->content ;
175
  }
176
 
194
  return false ;
195
  }
196
 
197
+ /**
198
+ * Bypass login/reg page
199
+ * @since 1.6
200
+ */
201
+ if ( in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ), true ) ) {
202
+ LiteSpeed_Cache_Log::debug( 'CDN bypassed as is login/reg page' ) ;
203
+ return false ;
204
+ }
205
+
206
  return true ;
207
  }
208
 
212
  * @since 1.2.3
213
  * @access private
214
  */
215
+ private function _finalize()
216
  {
217
  if ( defined( self::BYPASS ) ) {
218
  LiteSpeed_Cache_Log::debug2( 'CDN bypass' ) ;
219
  return ;
220
  }
221
 
222
+ LiteSpeed_Cache_Log::debug( 'CDN _finalize' ) ;
223
 
224
  // Start replacing img src
225
  if ( $this->cfg_cdn_inc_img ) {
387
 
388
  // Only images under wp-cotnent/wp-includes can be replaced
389
  if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
390
+ if ( ! defined( 'UPLOADS' ) || stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
391
+ LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match: ' . LSWCP_CONTENT_FOLDER ) ;
392
  return false ;
393
  }
394
  }
inc/config.class.php CHANGED
@@ -16,9 +16,13 @@ class LiteSpeed_Cache_Config
16
 
17
  const OPTION_NAME = 'litespeed-cache-conf' ;
18
  const VARY_GROUP = 'litespeed-cache-vary-group' ;
 
 
19
  const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
20
  const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
21
  const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
 
 
22
 
23
  const VAL_OFF = 0 ;
24
  const VAL_ON = 1 ;
@@ -42,6 +46,7 @@ class LiteSpeed_Cache_Config
42
  const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
43
  const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
44
  const OPID_CACHE_BROWSER = 'cache_browser' ;
 
45
 
46
  const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
47
  const OPID_TIMED_URLS = 'timed_urls' ;
@@ -92,10 +97,12 @@ class LiteSpeed_Cache_Config
92
 
93
  const OPID_CSS_MINIFY = 'css_minify' ;
94
  const OPID_CSS_COMBINE = 'css_combine' ;
 
95
  const OPID_CSS_HTTP2 = 'css_http2' ;
96
  const OPID_CSS_EXCLUDES = 'css_exclude' ;
97
  const OPID_JS_MINIFY = 'js_minify' ;
98
  const OPID_JS_COMBINE = 'js_combine' ;
 
99
  const OPID_JS_HTTP2 = 'js_http2' ;
100
  const OPID_JS_EXCLUDES = 'js_exclude' ;
101
  const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
@@ -107,6 +114,7 @@ class LiteSpeed_Cache_Config
107
  const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
108
  const OPID_OPTM_EXCLUDES = 'optm_excludes' ;
109
  const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
 
110
 
111
  const OPID_CDN = 'cdn' ;
112
  const OPID_CDN_ORI = 'cdn_ori' ;
@@ -121,6 +129,11 @@ class LiteSpeed_Cache_Config
121
  const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
122
  const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
123
  const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
 
 
 
 
 
124
 
125
  const HASH = 'hash' ;
126
 
@@ -151,6 +164,8 @@ class LiteSpeed_Cache_Config
151
 
152
  protected $options ;
153
  protected $vary_groups ;
 
 
154
  protected $purge_options ;
155
 
156
  /**
@@ -186,6 +201,12 @@ class LiteSpeed_Cache_Config
186
  // Vary group settings
187
  $this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
188
 
 
 
 
 
 
 
189
  // Set security key if not initialized yet
190
  if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
191
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
@@ -311,11 +332,11 @@ class LiteSpeed_Cache_Config
311
  exit( 'no referer' ) ;
312
  }
313
 
314
- if ( empty( $_GET[ 'type' ] ) ) {
315
  exit( 'no type' ) ;
316
  }
317
 
318
- switch ( $_GET[ 'type' ] ) {
319
  case 'private' :
320
  $id = self::OPID_CACHE_URI_PRIV ;
321
  break ;
@@ -365,9 +386,57 @@ class LiteSpeed_Cache_Config
365
  $group = 99 ;
366
  }
367
 
 
 
 
 
368
  return $group ;
369
  }
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  /**
372
  * Get the configured purge options.
373
  *
@@ -411,7 +480,7 @@ class LiteSpeed_Cache_Config
411
  self::PURGE_AUTHOR,
412
  self::PURGE_MONTH,
413
  self::PURGE_TERM,
414
- self::PURGE_POST_TYPE
415
  ) ;
416
  sort($default_purge_options) ;
417
 
@@ -439,13 +508,14 @@ class LiteSpeed_Cache_Config
439
  self::ID_MOBILEVIEW_LIST => false,
440
  self::OPID_CACHE_URI_PRIV => '',
441
  self::OPID_CACHE_BROWSER => false,
 
442
 
443
  self::OPID_LOGIN_COOKIE => '',
444
  self::OPID_CHECK_ADVANCEDCACHE => true,
445
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
446
  self::OPID_ADMIN_IPS => '127.0.0.1',
447
  self::OPID_DEBUG_LEVEL => false,
448
- self::OPID_LOG_FILE_SIZE => 30,
449
  self::OPID_HEARTBEAT => true,
450
  self::OPID_DEBUG_COOKIE => false,
451
  self::OPID_COLLAPS_QS => false,
@@ -467,10 +537,12 @@ class LiteSpeed_Cache_Config
467
 
468
  self::OPID_CSS_MINIFY => false,
469
  self::OPID_CSS_COMBINE => false,
 
470
  self::OPID_CSS_HTTP2 => false,
471
  self::OPID_CSS_EXCLUDES => '',
472
  self::OPID_JS_MINIFY => false,
473
  self::OPID_JS_COMBINE => false,
 
474
  self::OPID_JS_HTTP2 => false,
475
  self::OPID_JS_EXCLUDES => '',
476
  self::OPID_OPTIMIZE_TTL => 604800,
@@ -482,6 +554,7 @@ class LiteSpeed_Cache_Config
482
  self::OPID_OPTM_EMOJI_RM => false,
483
  self::OPID_OPTM_EXCLUDES => '',
484
  self::OPID_OPTM_EXC_JQUERY => true,
 
485
 
486
  self::OPID_CDN => false,
487
  self::OPID_CDN_ORI => '',
@@ -496,6 +569,11 @@ class LiteSpeed_Cache_Config
496
  self::OPID_MEDIA_IMG_LAZY => false,
497
  self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
498
  self::OPID_MEDIA_IFRAME_LAZY => false,
 
 
 
 
 
499
 
500
  self::HASH => '',
501
 
@@ -554,10 +632,12 @@ class LiteSpeed_Cache_Config
554
  self::OPID_CACHE_MOBILE => 0, // todo: why not false
555
  self::ID_MOBILEVIEW_LIST => false,
556
  self::OPID_CACHE_BROWSER => false,
 
557
  self::OPID_LOGIN_COOKIE => '',
558
  self::OPID_CHECK_ADVANCEDCACHE => true,
559
  self::ID_NOCACHE_COOKIES => '',
560
  self::ID_NOCACHE_USERAGENTS => '',
 
561
  ) ;
562
  return $default_site_options ;
563
  }
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_MEDIA_NEED_PULL = 'litespeed-media-need-pull' ;
25
+ const ITEM_ENV_REF = 'litespeed-env-ref' ;
26
 
27
  const VAL_OFF = 0 ;
28
  const VAL_ON = 1 ;
46
  const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
47
  const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
48
  const OPID_CACHE_BROWSER = 'cache_browser' ;
49
+ const OPID_CACHE_BROWSER_TTL = 'cache_browser_ttl' ;
50
 
51
  const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
52
  const OPID_TIMED_URLS = 'timed_urls' ;
97
 
98
  const OPID_CSS_MINIFY = 'css_minify' ;
99
  const OPID_CSS_COMBINE = 'css_combine' ;
100
+ const OPID_CSS_COMBINED_PRIORITY = 'css_combined_priority' ;
101
  const OPID_CSS_HTTP2 = 'css_http2' ;
102
  const OPID_CSS_EXCLUDES = 'css_exclude' ;
103
  const OPID_JS_MINIFY = 'js_minify' ;
104
  const OPID_JS_COMBINE = 'js_combine' ;
105
+ const OPID_JS_COMBINED_PRIORITY = 'js_combined_priority' ;
106
  const OPID_JS_HTTP2 = 'js_http2' ;
107
  const OPID_JS_EXCLUDES = 'js_exclude' ;
108
  const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
114
  const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
115
  const OPID_OPTM_EXCLUDES = 'optm_excludes' ;
116
  const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
117
+ const OPID_OPTM_GGFONTS_ASYNC = 'optm_ggfonts_async' ;
118
 
119
  const OPID_CDN = 'cdn' ;
120
  const OPID_CDN_ORI = 'cdn_ori' ;
129
  const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
130
  const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
131
  const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
132
+ const OPID_MEDIA_IMG_OPTM_CRON_OFF = 'media_img_optm_cron_off' ;
133
+ const OPID_MEDIA_IMG_WEBP = 'media_img_webp' ;
134
+ const OPID_MEDIA_IMG_WEBP_ONLY = 'media_img_webp_only' ;
135
+ const OPID_MEDIA_IMG_EXIF = 'media_img_exif' ;
136
+ const OPID_MEDIA_IMG_WEBP_LOSSLESS = 'media_img_webp_lossless' ;
137
 
138
  const HASH = 'hash' ;
139
 
164
 
165
  protected $options ;
166
  protected $vary_groups ;
167
+ protected $exclude_optimization_roles ;
168
+ protected $exclude_cache_roles ;
169
  protected $purge_options ;
170
 
171
  /**
201
  // Vary group settings
202
  $this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
203
 
204
+ // Exclude optimization role setting
205
+ $this->exclude_optimization_roles = (array) get_option( self::EXCLUDE_OPTIMIZATION_ROLES ) ;
206
+
207
+ // Exclude cache role setting
208
+ $this->exclude_cache_roles = (array) get_option( self::EXCLUDE_CACHE_ROLES ) ;
209
+
210
  // Set security key if not initialized yet
211
  if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
212
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
332
  exit( 'no referer' ) ;
333
  }
334
 
335
+ if ( ! $type = LiteSpeed_Cache_Router::verify_type() ) {
336
  exit( 'no type' ) ;
337
  }
338
 
339
+ switch ( $type ) {
340
  case 'private' :
341
  $id = self::OPID_CACHE_URI_PRIV ;
342
  break ;
386
  $group = 99 ;
387
  }
388
 
389
+ if ( $group ) {
390
+ LiteSpeed_Cache_Log::debug2( 'Config: role in vary_group [group] ' . $group ) ;
391
+ }
392
+
393
  return $group ;
394
  }
395
 
396
+ /**
397
+ * Check if one user role is in exclude optimization group settings
398
+ *
399
+ * @since 1.6
400
+ * @access public
401
+ * @param string $role The user role
402
+ * @return int The set value if already set
403
+ */
404
+ public function in_exclude_optimization_roles( $role = null )
405
+ {
406
+ // Get user role
407
+ if ( $role === null ) {
408
+ $role = LiteSpeed_Cache_Router::get_role() ;
409
+ }
410
+
411
+ if ( ! $role ) {
412
+ return false ;
413
+ }
414
+
415
+ return in_array( $role, $this->exclude_optimization_roles ) ? $role : false ;
416
+ }
417
+
418
+ /**
419
+ * Check if one user role is in exclude cache group settings
420
+ *
421
+ * @since 1.6.2
422
+ * @access public
423
+ * @param string $role The user role
424
+ * @return int The set value if already set
425
+ */
426
+ public function in_exclude_cache_roles( $role = null )
427
+ {
428
+ // Get user role
429
+ if ( $role === null ) {
430
+ $role = LiteSpeed_Cache_Router::get_role() ;
431
+ }
432
+
433
+ if ( ! $role ) {
434
+ return false ;
435
+ }
436
+
437
+ return in_array( $role, $this->exclude_cache_roles ) ? $role : false ;
438
+ }
439
+
440
  /**
441
  * Get the configured purge options.
442
  *
480
  self::PURGE_AUTHOR,
481
  self::PURGE_MONTH,
482
  self::PURGE_TERM,
483
+ self::PURGE_POST_TYPE,
484
  ) ;
485
  sort($default_purge_options) ;
486
 
508
  self::ID_MOBILEVIEW_LIST => false,
509
  self::OPID_CACHE_URI_PRIV => '',
510
  self::OPID_CACHE_BROWSER => false,
511
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
512
 
513
  self::OPID_LOGIN_COOKIE => '',
514
  self::OPID_CHECK_ADVANCEDCACHE => true,
515
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
516
  self::OPID_ADMIN_IPS => '127.0.0.1',
517
  self::OPID_DEBUG_LEVEL => false,
518
+ self::OPID_LOG_FILE_SIZE => 3,
519
  self::OPID_HEARTBEAT => true,
520
  self::OPID_DEBUG_COOKIE => false,
521
  self::OPID_COLLAPS_QS => false,
537
 
538
  self::OPID_CSS_MINIFY => false,
539
  self::OPID_CSS_COMBINE => false,
540
+ self::OPID_CSS_COMBINED_PRIORITY => false,
541
  self::OPID_CSS_HTTP2 => false,
542
  self::OPID_CSS_EXCLUDES => '',
543
  self::OPID_JS_MINIFY => false,
544
  self::OPID_JS_COMBINE => false,
545
+ self::OPID_JS_COMBINED_PRIORITY => false,
546
  self::OPID_JS_HTTP2 => false,
547
  self::OPID_JS_EXCLUDES => '',
548
  self::OPID_OPTIMIZE_TTL => 604800,
554
  self::OPID_OPTM_EMOJI_RM => false,
555
  self::OPID_OPTM_EXCLUDES => '',
556
  self::OPID_OPTM_EXC_JQUERY => true,
557
+ self::OPID_OPTM_GGFONTS_ASYNC => false,
558
 
559
  self::OPID_CDN => false,
560
  self::OPID_CDN_ORI => '',
569
  self::OPID_MEDIA_IMG_LAZY => false,
570
  self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
571
  self::OPID_MEDIA_IFRAME_LAZY => false,
572
+ self::OPID_MEDIA_IMG_OPTM_CRON_OFF => false,
573
+ self::OPID_MEDIA_IMG_WEBP => false,
574
+ self::OPID_MEDIA_IMG_WEBP_ONLY => false,
575
+ self::OPID_MEDIA_IMG_EXIF => false,
576
+ self::OPID_MEDIA_IMG_WEBP_LOSSLESS => false,
577
 
578
  self::HASH => '',
579
 
632
  self::OPID_CACHE_MOBILE => 0, // todo: why not false
633
  self::ID_MOBILEVIEW_LIST => false,
634
  self::OPID_CACHE_BROWSER => false,
635
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
636
  self::OPID_LOGIN_COOKIE => '',
637
  self::OPID_CHECK_ADVANCEDCACHE => true,
638
  self::ID_NOCACHE_COOKIES => '',
639
  self::ID_NOCACHE_USERAGENTS => '',
640
+ self::OPID_MEDIA_IMG_WEBP => false,
641
  ) ;
642
  return $default_site_options ;
643
  }
inc/control.class.php CHANGED
@@ -25,6 +25,36 @@ class LiteSpeed_Cache_Control
25
  protected static $_custom_ttl = 0 ;
26
  private static $_mobile = false ;
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * 1. Initialize cacheable status for `wp` hook
30
  * 2. Hook error page tags for cacheable pages
@@ -70,7 +100,7 @@ class LiteSpeed_Cache_Control
70
  return ;
71
  }
72
  self::$_control |= self::BM_NO_VARY ;
73
- LiteSpeed_Cache_Log::debug('X Cache_control -> no-vary') ;
74
  }
75
 
76
  /**
@@ -536,6 +566,13 @@ class LiteSpeed_Cache_Control
536
  }
537
  }
538
 
 
 
 
 
 
 
 
539
  return true ;
540
  }
541
 
25
  protected static $_custom_ttl = 0 ;
26
  private static $_mobile = false ;
27
 
28
+ /**
29
+ * Init cache control
30
+ *
31
+ * @since 1.6.2
32
+ * @access private
33
+ */
34
+ private function __construct()
35
+ {
36
+ /**
37
+ * Add vary filter for Role Excludes
38
+ * @since 1.6.2
39
+ */
40
+ add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
41
+ }
42
+
43
+ /**
44
+ * Exclude role from optimization filter
45
+ *
46
+ * @since 1.6.2
47
+ * @access public
48
+ */
49
+ public function vary_add_role_exclude( $varys )
50
+ {
51
+ if ( ! LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
52
+ return $varys ;
53
+ }
54
+ $varys[ 'role_exclude_cache' ] = 1 ;
55
+ return $varys ;
56
+ }
57
+
58
  /**
59
  * 1. Initialize cacheable status for `wp` hook
60
  * 2. Hook error page tags for cacheable pages
100
  return ;
101
  }
102
  self::$_control |= self::BM_NO_VARY ;
103
+ LiteSpeed_Cache_Log::debug( 'X Cache_control -> no-vary', 3 ) ;
104
  }
105
 
106
  /**
566
  }
567
  }
568
 
569
+ // Check if is exclude roles ( Need to set Vary too )
570
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
571
+ return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
572
+ }
573
+
574
+
575
+
576
  return true ;
577
  }
578
 
inc/crawler.class.php CHANGED
@@ -326,7 +326,7 @@ class LiteSpeed_Cache_Crawler
326
  }
327
  else {
328
  $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
329
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
330
  }
331
  LiteSpeed_Cache_Log::debug($log) ;
332
  }
326
  }
327
  else {
328
  $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
329
+ // LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
330
  }
331
  LiteSpeed_Cache_Log::debug($log) ;
332
  }
inc/gui.class.php CHANGED
@@ -16,6 +16,10 @@ class LiteSpeed_Cache_GUI
16
 
17
  private static $_clean_counter = 0 ;
18
 
 
 
 
 
19
  /**
20
  * Init
21
  *
@@ -31,6 +35,90 @@ class LiteSpeed_Cache_GUI
31
  }
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Load frontend menu shortcut
36
  *
@@ -78,21 +166,21 @@ class LiteSpeed_Cache_GUI
78
  'parent' => 'litespeed-single-action',
79
  'id' => 'litespeed-single-noncache',
80
  'title' => __( 'Non cacheable', 'litespeed-cache' ),
81
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nocache', true ),
82
  ) );
83
 
84
  $wp_admin_bar->add_menu( array(
85
  'parent' => 'litespeed-single-action',
86
  'id' => 'litespeed-single-private',
87
  'title' => __( 'Private cache', 'litespeed-cache' ),
88
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=private', true ),
89
  ) );
90
 
91
  $wp_admin_bar->add_menu( array(
92
  'parent' => 'litespeed-single-action',
93
  'id' => 'litespeed-single-nonoptimize',
94
  'title' => __( 'No optimization', 'litespeed-cache' ),
95
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nonoptimize', true ),
96
  ) );
97
 
98
  $wp_admin_bar->add_menu( array(
@@ -103,13 +191,26 @@ class LiteSpeed_Cache_GUI
103
  ) );
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  /**
107
  * Clean wrapper from buffer
108
  *
109
  * @since 1.4
110
- * @access public
 
111
  */
112
- public static function clean_wrapper( $buffer )
113
  {
114
  if ( self::$_clean_counter < 1 ) {
115
  LiteSpeed_Cache_Log::debug2( "GUI bypassed by no counter" ) ;
16
 
17
  private static $_clean_counter = 0 ;
18
 
19
+ const TYPE_DISMISS_WHM = 'whm' ;
20
+ const TYPE_DISMISS_EXPIRESDEFAULT = 'ExpiresDefault' ;
21
+ const TYPE_DISMISS_PROMO = 'promo' ;
22
+
23
  /**
24
  * Init
25
  *
35
  }
36
  }
37
 
38
+ public static function pie( $percent, $width = 50 )
39
+ {
40
+ return "
41
+ <svg class='litespeed-media-svg' width='$width' viewBox='0 0 33.83098862 33.83098862' xmlns='http://www.w3.org/2000/svg'>
42
+ <circle class='litespeed-pie_bg' cx='17.5' cy='17.5' r='16.5'></circle>
43
+ <circle class='litespeed-pie_circle' cx='17' cy='17.5' r='16.5'></circle>
44
+ <g class='litespeed-pie_info'>
45
+ <text x='16.91549431' y='15.5' alignment-baseline='central' text-anchor='middle'>$percent%</text>
46
+ </g>
47
+ </svg>
48
+ ";
49
+
50
+ }
51
+
52
+ public static function dismiss()
53
+ {
54
+ switch ( LiteSpeed_Cache_Router::verify_type() ) {
55
+ case self::TYPE_DISMISS_WHM :
56
+ LiteSpeed_Cache_Activation::dismiss_whm() ;
57
+ break ;
58
+
59
+ case self::TYPE_DISMISS_EXPIRESDEFAULT :
60
+ update_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
61
+ break ;
62
+
63
+ case self::TYPE_DISMISS_PROMO :
64
+ update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
65
+ break ;
66
+
67
+ default:
68
+ break ;
69
+ }
70
+
71
+ // All dismiss actions are considered as ajax call, so just exit
72
+ exit( json_encode( array( 'success' => 1 ) ) ) ;
73
+ }
74
+
75
+ /**
76
+ * Check if has rule conflict notice
77
+ *
78
+ * @since 1.1.5
79
+ * @access public
80
+ * @return boolean
81
+ */
82
+ public static function has_msg_ruleconflict()
83
+ {
84
+ return get_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG ) == LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ;
85
+ }
86
+
87
+ /**
88
+ * Check if has whm notice
89
+ *
90
+ * @since 1.1.1
91
+ * @access public
92
+ * @return boolean
93
+ */
94
+ public static function has_whm_msg()
95
+ {
96
+ return get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
97
+ }
98
+
99
+ /**
100
+ * Check if has promotion notice
101
+ *
102
+ * @since 1.3.2
103
+ * @access public
104
+ * @return boolean
105
+ */
106
+ public static function has_promo_msg()
107
+ {
108
+ $promo = get_option( 'litespeed-banner-promo' ) ;
109
+ if ( ! $promo ) {
110
+ update_option( 'litespeed-banner-promo', time() - 86400 * 8 ) ;
111
+ return false ;
112
+ }
113
+ if ( $promo == 'done' ) {
114
+ return false ;
115
+ }
116
+ if ( $promo && time() - $promo < 864000 ) {
117
+ return false ;
118
+ }
119
+ return true ;
120
+ }
121
+
122
  /**
123
  * Load frontend menu shortcut
124
  *
166
  'parent' => 'litespeed-single-action',
167
  'id' => 'litespeed-single-noncache',
168
  'title' => __( 'Non cacheable', 'litespeed-cache' ),
169
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'nocache', false, true ),
170
  ) );
171
 
172
  $wp_admin_bar->add_menu( array(
173
  'parent' => 'litespeed-single-action',
174
  'id' => 'litespeed-single-private',
175
  'title' => __( 'Private cache', 'litespeed-cache' ),
176
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'private', false, true ),
177
  ) );
178
 
179
  $wp_admin_bar->add_menu( array(
180
  'parent' => 'litespeed-single-action',
181
  'id' => 'litespeed-single-nonoptimize',
182
  'title' => __( 'No optimization', 'litespeed-cache' ),
183
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'nonoptimize', false, true ),
184
  ) );
185
 
186
  $wp_admin_bar->add_menu( array(
191
  ) );
192
  }
193
 
194
+ /**
195
+ * Finalize buffer by GUI class
196
+ *
197
+ * @since 1.6
198
+ * @access public
199
+ */
200
+ public static function finalize( $buffer )
201
+ {
202
+ $instance = self::get_instance() ;
203
+ return $instance->_clean_wrapper( $buffer ) ;
204
+ }
205
+
206
  /**
207
  * Clean wrapper from buffer
208
  *
209
  * @since 1.4
210
+ * @since 1.6 converted to private with adding prefix _
211
+ * @access private
212
  */
213
+ private function _clean_wrapper( $buffer )
214
  {
215
  if ( self::$_clean_counter < 1 ) {
216
  LiteSpeed_Cache_Log::debug2( "GUI bypassed by no counter" ) ;
inc/litespeed-cache.class.php CHANGED
@@ -19,15 +19,13 @@ class LiteSpeed_Cache
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '1.5' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
26
  const NONCE_NAME = 'LSCWP_NONCE' ;
27
  const ACTION_KEY = 'LSCWP_CTRL' ;
28
- const ACTION_DISMISS_WHM = 'dismiss-whm' ;
29
- const ACTION_DISMISS_EXPIRESDEFAULT = 'dismiss-ExpiresDefault' ;
30
- const ACTION_DISMISS_PROMO = 'dismiss-promo' ;
31
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
32
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
33
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
@@ -54,9 +52,12 @@ class LiteSpeed_Cache
54
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
55
 
56
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
 
57
 
58
- const ACTION_SAPI_PROCEED = 'sapi_proceed' ;
59
- const ACTION_SAPI_CALLBACK = 'sapi_callback' ;
 
 
60
 
61
  const WHM_TRANSIENT = 'lscwp_whm_install' ;
62
  const WHM_TRANSIENT_VAL = 'whm_install' ;
@@ -107,20 +108,32 @@ class LiteSpeed_Cache
107
  LiteSpeed_Cache_Log::debug( 'Purge Queue found&sent: ' . $purge_queue ) ;
108
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
109
  }
 
 
 
 
 
 
110
  }
111
 
112
  /**
113
  * The plugin initializer.
114
  *
115
- * This function checks if the cache is enabled and ready to use, then
116
- * determines what actions need to be set up based on the type of user
117
- * and page accessed. Output is buffered if the cache is enabled.
118
  *
119
  * @since 1.0.0
120
  * @access public
121
  */
122
  public function init()
123
  {
 
 
 
 
 
 
124
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
125
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
126
  }
@@ -147,6 +160,12 @@ class LiteSpeed_Cache
147
  // Check minify file request in the very beginning
148
  LiteSpeed_Cache_Optimize::get_instance() ;
149
 
 
 
 
 
 
 
150
  // 1. Init vary
151
  // 2. Init cacheable status
152
  LiteSpeed_Cache_Vary::get_instance() ;
@@ -157,14 +176,8 @@ class LiteSpeed_Cache
157
  // Load public hooks
158
  $this->load_public_actions() ;
159
 
160
- // load cron task for crawler
161
- if ( self::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
162
- // keep cron intval filter
163
- LiteSpeed_Cache_Task::schedule_filter() ;
164
-
165
- // cron hook
166
- add_action( LiteSpeed_Cache_Task::CRON_ACTION_HOOK, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
167
- }
168
 
169
  // Load 3rd party hooks
170
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
@@ -274,28 +287,32 @@ class LiteSpeed_Cache
274
  $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
275
  break;
276
 
277
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
278
- LiteSpeed_Cache_Activation::dismiss_whm() ;
279
  break ;
280
 
281
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
282
- update_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
283
  break ;
284
 
285
- case LiteSpeed_Cache::ACTION_DISMISS_PROMO:
286
- LiteSpeed_Cache_Router::dismiss_promo_msg() ;
287
  break ;
288
 
289
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
290
- $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
291
  break ;
292
 
293
- case LiteSpeed_Cache::ACTION_SAPI_PROCEED:
294
- $msg = LiteSpeed_Cache_Admin_API::sapi_proceed() ;
295
  break ;
296
 
297
- case LiteSpeed_Cache::ACTION_SAPI_CALLBACK:
298
- LiteSpeed_Cache_Admin_API::sapi_callback() ;
 
 
 
 
299
  break ;
300
 
301
  default:
@@ -409,6 +426,11 @@ class LiteSpeed_Cache
409
  return ;
410
  }
411
 
 
 
 
 
 
412
  if ( $buffer === null ) {
413
  $buffer = ob_get_contents() ;
414
  }
@@ -450,18 +472,18 @@ class LiteSpeed_Cache
450
  $this->_check_is_html( $buffer ) ;
451
 
452
  // Image lazy load check
453
- $buffer = LiteSpeed_Cache_Media::run( $buffer ) ;
454
 
455
  /**
456
  * Clean wrapper mainly for esi block
457
  * NOTE: this needs to be before optimizer to avoid wrapper being removed
458
  * @since 1.4
459
  */
460
- $buffer = LiteSpeed_Cache_GUI::clean_wrapper( $buffer ) ;
461
 
462
- $buffer = LiteSpeed_Cache_Optimize::run( $buffer ) ;
463
 
464
- $buffer = LiteSpeed_Cache_CDN::run( $buffer ) ;
465
 
466
  $this->send_headers( true ) ;
467
 
@@ -498,7 +520,7 @@ class LiteSpeed_Cache
498
  // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
499
  LiteSpeed_Cache_Control::finalize() ;
500
 
501
- $vary_header = LiteSpeed_Cache_Vary::output() ;
502
 
503
  // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
504
  $tag_header = LiteSpeed_Cache_Tag::output() ;
@@ -513,13 +535,17 @@ class LiteSpeed_Cache
513
  $control_header = LiteSpeed_Cache_Control::output() ;
514
 
515
  // Init comment info
516
- $running_info_showing = defined( 'LITESPEED_IS_HTML' ) || defined( 'LSCACHE_IS_ESI' ) ;
517
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
518
  $running_info_showing = false ;
519
  LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
520
  }
521
 
522
  if ( $running_info_showing ) {
 
 
 
 
523
  $this->footer_comment .= sprintf(
524
  '<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
525
  defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '1.6.7' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
26
  const NONCE_NAME = 'LSCWP_NONCE' ;
27
  const ACTION_KEY = 'LSCWP_CTRL' ;
28
+ const ACTION_DISMISS = 'dismiss' ;
 
 
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
52
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
53
 
54
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
55
+ const ACTION_LOG = 'log' ;
56
 
57
+ const ACTION_MEDIA = 'media' ;
58
+ const ACTION_REPORT = 'report' ;
59
+ const ACTION_SAPI_PASSIVE_CALLBACK = 'sapi_passive_callback' ;
60
+ const ACTION_SAPI_AGGRESSIVE_CALLBACK = 'sapi_aggressive_callback' ;
61
 
62
  const WHM_TRANSIENT = 'lscwp_whm_install' ;
63
  const WHM_TRANSIENT_VAL = 'whm_install' ;
108
  LiteSpeed_Cache_Log::debug( 'Purge Queue found&sent: ' . $purge_queue ) ;
109
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
110
  }
111
+
112
+ /**
113
+ * Added hook before init
114
+ * @since 1.6.6
115
+ */
116
+ do_action( 'litespeed_before_init' ) ;
117
  }
118
 
119
  /**
120
  * The plugin initializer.
121
  *
122
+ * This function checks if the cache is enabled and ready to use, then determines what actions need to be set up based on the type of user and page accessed. Output is buffered if the cache is enabled.
123
+ *
124
+ * NOTE: WP user doesn't init yet
125
  *
126
  * @since 1.0.0
127
  * @access public
128
  */
129
  public function init()
130
  {
131
+ /**
132
+ * Added hook before init
133
+ * @since 1.6.6
134
+ */
135
+ do_action( 'litespeed_init' ) ;
136
+
137
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
138
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
139
  }
160
  // Check minify file request in the very beginning
161
  LiteSpeed_Cache_Optimize::get_instance() ;
162
 
163
+ /**
164
+ * Register vary filter
165
+ * @since 1.6.2
166
+ */
167
+ LiteSpeed_Cache_Control::get_instance() ;
168
+
169
  // 1. Init vary
170
  // 2. Init cacheable status
171
  LiteSpeed_Cache_Vary::get_instance() ;
176
  // Load public hooks
177
  $this->load_public_actions() ;
178
 
179
+ // load cron tasks
180
+ LiteSpeed_Cache_Task::get_instance() ;
 
 
 
 
 
 
181
 
182
  // Load 3rd party hooks
183
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
287
  $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
288
  break;
289
 
290
+ case LiteSpeed_Cache::ACTION_DISMISS:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
291
+ LiteSpeed_Cache_GUI::dismiss() ;
292
  break ;
293
 
294
+ case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
295
+ $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
296
  break ;
297
 
298
+ case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK:
299
+ LiteSpeed_Cache_Admin_API::sapi_passive_callback() ;
300
  break ;
301
 
302
+ case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK:
303
+ LiteSpeed_Cache_Admin_API::sapi_aggressive_callback() ;
304
  break ;
305
 
306
+ case LiteSpeed_Cache::ACTION_MEDIA:
307
+ $msg = LiteSpeed_Cache_Media::handler() ;
308
  break ;
309
 
310
+ case LiteSpeed_Cache::ACTION_LOG:
311
+ $msg = LiteSpeed_Cache_Log::handler() ;
312
+ break ;
313
+
314
+ case LiteSpeed_Cache::ACTION_REPORT:
315
+ $msg = LiteSpeed_Cache_Admin_Report::handler() ;
316
  break ;
317
 
318
  default:
426
  return ;
427
  }
428
 
429
+ if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
430
+ LiteSpeed_Cache_Log::debug2( 'CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
431
+ return ;
432
+ }
433
+
434
  if ( $buffer === null ) {
435
  $buffer = ob_get_contents() ;
436
  }
472
  $this->_check_is_html( $buffer ) ;
473
 
474
  // Image lazy load check
475
+ $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
476
 
477
  /**
478
  * Clean wrapper mainly for esi block
479
  * NOTE: this needs to be before optimizer to avoid wrapper being removed
480
  * @since 1.4
481
  */
482
+ $buffer = LiteSpeed_Cache_GUI::finalize( $buffer ) ;
483
 
484
+ $buffer = LiteSpeed_Cache_Optimize::finalize( $buffer ) ;
485
 
486
+ $buffer = LiteSpeed_Cache_CDN::finalize( $buffer ) ;
487
 
488
  $this->send_headers( true ) ;
489
 
520
  // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
521
  LiteSpeed_Cache_Control::finalize() ;
522
 
523
+ $vary_header = LiteSpeed_Cache_Vary::finalize() ;
524
 
525
  // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
526
  $tag_header = LiteSpeed_Cache_Tag::output() ;
535
  $control_header = LiteSpeed_Cache_Control::output() ;
536
 
537
  // Init comment info
538
+ $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
539
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
540
  $running_info_showing = false ;
541
  LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
542
  }
543
 
544
  if ( $running_info_showing ) {
545
+ // Give one more break to avoid ff crash
546
+ if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
547
+ $this->footer_comment .= "\n" ;
548
+ }
549
  $this->footer_comment .= sprintf(
550
  '<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
551
  defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
inc/log.class.php CHANGED
@@ -18,6 +18,8 @@ class LiteSpeed_Cache_Log
18
  private static $_prefix ;
19
  private static $_enabled = false ;
20
 
 
 
21
  /**
22
  * Log class Constructor
23
  *
@@ -44,6 +46,41 @@ class LiteSpeed_Cache_Log
44
  self::$_debug = true ;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Heartbeat control
49
  *
@@ -166,15 +203,29 @@ class LiteSpeed_Cache_Log
166
  * Direct call to log a debug message.
167
  *
168
  * @since 1.1.3
 
169
  * @access public
170
  * @param string $msg The debug message.
171
- * @param int $backtrace_limit Backtrace depth.
172
  */
173
  public static function debug( $msg, $backtrace_limit = false )
174
  {
175
- if ( self::get_enabled() ) {
176
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  /**
@@ -190,9 +241,7 @@ class LiteSpeed_Cache_Log
190
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
191
  return ;
192
  }
193
- if ( self::get_enabled() ) {
194
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
195
- }
196
  }
197
 
198
  /**
18
  private static $_prefix ;
19
  private static $_enabled = false ;
20
 
21
+ const TYPE_CLEAR_LOG = 'clear_log' ;
22
+
23
  /**
24
  * Log class Constructor
25
  *
46
  self::$_debug = true ;
47
  }
48
 
49
+ /**
50
+ * Handle all request actions from main cls
51
+ *
52
+ * @since 1.6.6
53
+ * @access public
54
+ */
55
+ public static function handler()
56
+ {
57
+ $instance = self::get_instance() ;
58
+
59
+ $type = LiteSpeed_Cache_Router::verify_type() ;
60
+
61
+ switch ( $type ) {
62
+ case self::TYPE_CLEAR_LOG :
63
+ $instance->_clear_log() ;
64
+ break ;
65
+
66
+ default:
67
+ break ;
68
+ }
69
+
70
+ LiteSpeed_Cache_Admin::redirect() ;
71
+ }
72
+
73
+ /**
74
+ * Clear log file
75
+ *
76
+ * @since 1.6.6
77
+ * @access private
78
+ */
79
+ private function _clear_log()
80
+ {
81
+ Litespeed_File::save( self::$log_path, '' ) ;
82
+ }
83
+
84
  /**
85
  * Heartbeat control
86
  *
203
  * Direct call to log a debug message.
204
  *
205
  * @since 1.1.3
206
+ * @since 1.6 Added array dump as 2nd param
207
  * @access public
208
  * @param string $msg The debug message.
209
+ * @param int|array $backtrace_limit Backtrace depth, Or the array to dump
210
  */
211
  public static function debug( $msg, $backtrace_limit = false )
212
  {
213
+ if ( ! self::get_enabled() ) {
214
+ return ;
215
  }
216
+
217
+ if ( $backtrace_limit !== false ) {
218
+ if ( ! is_numeric( $backtrace_limit ) ) {
219
+ $msg .= ' --- ' . var_export( $backtrace_limit, true ) ;
220
+ self::push( $msg ) ;
221
+ return ;
222
+ }
223
+
224
+ self::push( $msg, $backtrace_limit + 1 ) ;
225
+ return ;
226
+ }
227
+
228
+ self::push( $msg ) ;
229
  }
230
 
231
  /**
241
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
242
  return ;
243
  }
244
+ self::debug( $msg, $backtrace_limit ) ;
 
 
245
  }
246
 
247
  /**
inc/media.class.php CHANGED
@@ -16,47 +16,1508 @@ class LiteSpeed_Cache_Media
16
 
17
  const LAZY_LIB = '/min/lazyload.js' ;
18
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  private $content ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  /**
22
- * Init
23
  *
24
- * @since 1.4
25
  * @access private
26
  */
27
- private function __construct()
28
  {
29
- LiteSpeed_Cache_Log::debug2( 'Media init' ) ;
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- $this->_static_request_check() ;
32
  }
33
 
34
  /**
35
- * Check if the request is for static file
36
  *
37
- * @since 1.4
38
  * @access private
39
- * @return string The static file content
40
  */
41
- private function _static_request_check()
42
  {
43
- // This request is for js/css_async.js
44
- if ( strpos( $_SERVER[ 'REQUEST_URI' ], self::LAZY_LIB ) !== false ) {
45
- LiteSpeed_Cache_Log::debug( 'Media run lazyload lib' ) ;
46
 
47
- LiteSpeed_Cache_Control::set_cacheable() ;
48
- LiteSpeed_Cache_Control::set_no_vary() ;
49
- LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
50
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_LAZY' ) ;
 
51
 
52
- $file = LSWCP_DIR . 'js/lazyload.min.js' ;
 
 
 
 
 
 
53
 
54
- header( 'Content-Length: ' . filesize( $file ) ) ;
55
- header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
56
 
57
- echo file_get_contents( $file ) ;
58
- exit ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  }
61
 
62
  /**
@@ -69,7 +1530,7 @@ class LiteSpeed_Cache_Media
69
  * @access public
70
  * @return string The buffer
71
  */
72
- public static function run( $content )
73
  {
74
  if ( defined( 'LITESPEED_NO_LAZY' ) ) {
75
  LiteSpeed_Cache_Log::debug2( 'Media bypass: NO_LAZY const' ) ;
@@ -81,12 +1542,12 @@ class LiteSpeed_Cache_Media
81
  return $content ;
82
  }
83
 
84
- LiteSpeed_Cache_Log::debug( 'Media start' ) ;
85
 
86
  $instance = self::get_instance() ;
87
  $instance->content = $content ;
88
 
89
- $instance->_proceed() ;
90
  return $instance->content ;
91
  }
92
 
@@ -96,15 +1557,26 @@ class LiteSpeed_Cache_Media
96
  * @since 1.4
97
  * @access private
98
  */
99
- private function _proceed()
100
  {
101
  $cfg_img_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY ) ;
102
  $cfg_iframe_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY ) ;
103
 
104
- // image lazy load
105
  if ( $cfg_img_lazy ) {
106
- $html_list = $this->_parse_img() ;
107
  $html_list_ori = $html_list ;
 
 
 
 
 
 
 
 
 
 
 
 
108
 
109
  $placeholder = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY_PLACEHOLDER ) ?: LITESPEED_PLACEHOLDER ;
110
 
@@ -116,7 +1588,9 @@ class LiteSpeed_Cache_Media
116
 
117
  $html_list[ $k ] = $snippet ;
118
  }
 
119
 
 
120
  $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
121
  }
122
 
@@ -162,6 +1636,7 @@ class LiteSpeed_Cache_Media
162
  $excludes = explode( "\n", $excludes ) ;
163
  }
164
 
 
165
  $html_list = array() ;
166
 
167
  $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
@@ -173,6 +1648,15 @@ class LiteSpeed_Cache_Media
173
  continue ;
174
  }
175
 
 
 
 
 
 
 
 
 
 
176
  LiteSpeed_Cache_Log::debug2( 'Media: found: ' . $attrs[ 'src' ] ) ;
177
 
178
  if ( ! empty( $attrs[ 'data-no-lazy' ] ) || ! empty( $attrs[ 'data-lazyloaded' ] ) || ! empty( $attrs[ 'data-src' ] ) || ! empty( $attrs[ 'data-srcset' ] ) ) {
@@ -194,10 +1678,11 @@ class LiteSpeed_Cache_Media
194
  continue ;
195
  }
196
 
 
197
  $html_list[] = $match[ 0 ] ;
198
  }
199
 
200
- return $html_list ;
201
  }
202
 
203
  /**
@@ -238,6 +1723,116 @@ class LiteSpeed_Cache_Media
238
  return $html_list ;
239
  }
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  /**
242
  * Get the current instance object.
243
  *
16
 
17
  const LAZY_LIB = '/min/lazyload.js' ;
18
 
19
+ const TYPE_SYNC_DATA = 'sync_data' ;
20
+ const TYPE_IMG_OPTIMIZE = 'img_optm' ;
21
+ const TYPE_IMG_OPTIMIZE_RESCAN = 'img_optm_rescan' ;
22
+ const TYPE_IMG_OPTIMIZE_DESTROY = 'img_optm_destroy' ;
23
+ const TYPE_IMG_PULL = 'img_pull' ;
24
+ const TYPE_IMG_BATCH_SWITCH_ORI = 'img_optm_batch_switch_ori' ;
25
+ const TYPE_IMG_BATCH_SWITCH_OPTM = 'img_optm_batch_switch_optm' ;
26
+ const OPT_CRON_RUN = 'litespeed-img_optm_cron_run' ; // last cron running time
27
+
28
+ const DB_IMG_OPTIMIZE_DESTROY = 'litespeed-optimize-destroy' ;
29
+ const DB_IMG_OPTIMIZE_DATA = 'litespeed-optimize-data' ;
30
+ const DB_IMG_OPTIMIZE_STATUS = 'litespeed-optimize-status' ;
31
+ const DB_IMG_OPTIMIZE_STATUS_REQUESTED = 'requested' ;
32
+ const DB_IMG_OPTIMIZE_STATUS_NOTIFIED = 'notified' ;
33
+ const DB_IMG_OPTIMIZE_STATUS_PULLED = 'pulled' ;
34
+ const DB_IMG_OPTIMIZE_STATUS_FAILED = 'failed' ;
35
+ const DB_IMG_OPTIMIZE_STATUS_ERR = 'err' ;
36
+ const DB_IMG_OPTIMIZE_SIZE = 'litespeed-optimize-size' ;
37
+
38
+ const DB_IMG_OPTM_SUMMARY = 'litespeed_img_optm_summary' ;
39
+
40
  private $content ;
41
+ private $wp_upload_dir ;
42
+ private $tmp_pid ;
43
+ private $tmp_path ;
44
+ private $_img_in_queue = array() ;
45
+ private $_img_total = 0 ;
46
+
47
+ private $cfg_img_webp ;
48
+
49
+ /**
50
+ * Init
51
+ *
52
+ * @since 1.4
53
+ * @access private
54
+ */
55
+ private function __construct()
56
+ {
57
+ LiteSpeed_Cache_Log::debug2( 'Media init' ) ;
58
+
59
+ $this->wp_upload_dir = wp_upload_dir() ;
60
+
61
+ if ( $this->can_media() ) {
62
+ $this->_static_request_check() ;
63
+
64
+ $this->cfg_img_webp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP ) ;
65
+
66
+ // Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
67
+ if ( $this->cfg_img_webp ) {
68
+ /**
69
+ * Add vary filter
70
+ * @since 1.6.2
71
+ */
72
+ // Moved to htaccess
73
+ // add_filter( 'litespeed_vary', array( $this, 'vary_add' ) ) ;
74
+
75
+ //
76
+ if ( $this->webp_support() ) {
77
+ // Hook to srcset
78
+ if ( function_exists( 'wp_calculate_image_srcset' ) ) {
79
+ add_filter( 'wp_calculate_image_srcset', array( $this, 'webp_srcset' ), 988 ) ;
80
+ }
81
+ // Hook to mime icon
82
+ // add_filter( 'wp_get_attachment_image_src', array( $this, 'webp_attach_img_src' ), 988 ) ;// todo: need to check why not
83
+ // add_filter( 'wp_get_attachment_url', array( $this, 'webp_url' ), 988 ) ; // disabled to avoid wp-admin display
84
+ }
85
+ }
86
+ }
87
+
88
+ add_action( 'litspeed_after_admin_init', array( $this, 'after_admin_init' ) ) ;
89
+ }
90
+
91
+ /**
92
+ * Check if it can use Media frontend
93
+ *
94
+ * @since 1.6.2
95
+ * @access private
96
+ */
97
+ private function can_media()
98
+ {
99
+ if ( is_admin() ) {
100
+ return false ;
101
+ }
102
+
103
+ return true ;
104
+ }
105
+
106
+ /**
107
+ * Register admin menu
108
+ *
109
+ * @since 1.6.3
110
+ * @access public
111
+ */
112
+ public function after_admin_init()
113
+ {
114
+ if ( get_option( LiteSpeed_Cache_Config::ITEM_MEDIA_NEED_PULL ) ) {
115
+ add_filter( 'manage_media_columns', array( $this, 'media_row_title' ) ) ;
116
+ add_filter( 'manage_media_custom_column', array( $this, 'media_row_actions' ), 10, 2 ) ;
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Media Admin Menu -> Image Optimization Column Title
122
+ *
123
+ * @since 1.6.3
124
+ * @access public
125
+ */
126
+ public function media_row_title( $posts_columns )
127
+ {
128
+ $posts_columns[ 'imgoptm' ] = __( 'LiteSpeed Optimization', 'litespeed-cache' ) ;
129
+
130
+ return $posts_columns ;
131
+ }
132
+
133
+ /**
134
+ * Media Admin Menu -> Image Optimization Column
135
+ *
136
+ * @since 1.6.2
137
+ * @access public
138
+ */
139
+ public function media_row_actions( $column_name, $post_id )
140
+ {
141
+ if ( $column_name !== 'imgoptm' ) {
142
+ return ;
143
+ }
144
+
145
+ $local_file = get_attached_file( $post_id ) ;
146
+
147
+ $link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, 'webp' . $post_id ) ;
148
+ $desc = false ;
149
+ $cls = 'litespeed-icon-media-webp' ;
150
+ $cls_webp = '' ;
151
+ if ( file_exists( $local_file . '.webp' ) ) {
152
+ $desc = __( 'Disable WebP', 'litespeed-cache' ) ;
153
+ $cls_webp = 'litespeed-txt-webp' ;
154
+ }
155
+ elseif ( file_exists( $local_file . '.optm.webp' ) ) {
156
+ $cls .= '-disabled' ;
157
+ $desc = __( 'Enable WebP', 'litespeed-cache' ) ;
158
+ $cls_webp = 'litespeed-txt-disabled' ;
159
+ }
160
+
161
+ $link_webp = '' ;
162
+ if ( $desc ) {
163
+ $link_webp = sprintf( '<a href="%1$s" class="litespeed-media-href" title="%3$s"><span class="%2$s"></span></a>', $link, $cls, $desc ) ;
164
+ }
165
+
166
+ $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
167
+ $bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
168
+ $bk_optm_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.optm.' . $extension ;
169
+
170
+ $link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, 'orig' . $post_id ) ;
171
+ $desc = false ;
172
+ $cls = 'litespeed-icon-media-optm' ;
173
+ $cls_ori = '' ;
174
+ if ( file_exists( $bk_file ) ) {
175
+ $desc = __( 'Restore Original File', 'litespeed-cache' ) ;
176
+ $cls_ori = 'litespeed-txt-ori' ;
177
+ }
178
+ elseif ( file_exists( $bk_optm_file ) ) {
179
+ $cls .= '-disabled' ;
180
+ $desc = __( 'Switch To Optimized File', 'litespeed-cache' ) ;
181
+ $cls_ori = 'litespeed-txt-disabled' ;
182
+ }
183
+
184
+ $link_ori = '' ;
185
+ if ( $desc ) {
186
+ $link_ori = sprintf( '<a href="%1$s" class="litespeed-media-href" title="%3$s"><span class="%2$s"></span></a>', $link, $cls, $desc ) ;
187
+ }
188
+
189
+ $info_webp = '' ;
190
+ $size_meta = get_post_meta( $post_id, self::DB_IMG_OPTIMIZE_SIZE, true ) ;
191
+ if ( $size_meta && ! empty ( $size_meta[ 'webp_saved' ] ) ) {
192
+ $percent = ceil( $size_meta[ 'webp_saved' ] * 100 / $size_meta[ 'webp_total' ] ) ;
193
+ $pie_webp = LiteSpeed_Cache_GUI::pie( $percent, 30 ) ;
194
+ $txt_webp = sprintf( __( 'WebP saved %s', 'litespeed-cache' ), LiteSpeed_Cache_Utility::real_size( $size_meta[ 'webp_saved' ] ) ) ;
195
+
196
+ $info_webp = sprintf( '%s %s', $pie_webp, $txt_webp ) ;
197
+ }
198
+
199
+ $info_ori = '' ;
200
+ if ( $size_meta && ! empty ( $size_meta[ 'ori_saved' ] ) ) {
201
+ $percent = ceil( $size_meta[ 'ori_saved' ] * 100 / $size_meta[ 'ori_total' ] ) ;
202
+ $pie_ori = LiteSpeed_Cache_GUI::pie( $percent, 30 ) ;
203
+ $txt_ori = sprintf( __( 'Original saved %s', 'litespeed-cache' ), LiteSpeed_Cache_Utility::real_size( $size_meta[ 'ori_saved' ] ) ) ;
204
+
205
+ $info_ori = sprintf( '%s %s', $pie_ori, $txt_ori ) ;
206
+ }
207
+
208
+ echo "<p class='$cls_webp'>$info_webp $link_webp</p><p class='$cls_ori'>$info_ori $link_ori</p>" ;
209
+ }
210
+
211
+ /**
212
+ * Batch switch images to ori/optm version
213
+ *
214
+ * @since 1.6.2
215
+ * @access private
216
+ */
217
+ private function _batch_switch( $type )
218
+ {
219
+ global $wpdb ;
220
+ $q = "SELECT meta_value
221
+ FROM $wpdb->postmeta
222
+ WHERE meta_key = %s
223
+ " ;
224
+ $cond = array( self::DB_IMG_OPTIMIZE_DATA ) ;
225
+ $meta_value_lists = $wpdb->get_results( $wpdb->prepare( $q, $cond ) ) ;
226
+
227
+ $i = 0 ;
228
+ foreach ( $meta_value_lists as $v ) {
229
+ $meta_value_list = unserialize( $v->meta_value ) ;
230
+
231
+ foreach ( $meta_value_list as $v2 ) {
232
+ if ( $v2[ 1 ] !== 'pulled' ) {
233
+ continue ;
234
+ }
235
+
236
+ $src = $v2[ 0 ] ;
237
+ $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $src ;
238
+
239
+ $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
240
+ $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
241
+ $bk_file = $local_filename . '.bk.' . $extension ;
242
+ $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
243
+
244
+ // switch to ori
245
+ if ( $type === self::TYPE_IMG_BATCH_SWITCH_ORI ) {
246
+ if ( ! file_exists( $bk_file ) ) {
247
+ continue ;
248
+ }
249
+
250
+ $i ++ ;
251
+
252
+ rename( $local_file, $bk_optm_file ) ;
253
+ rename( $bk_file, $local_file ) ;
254
+ }
255
+ // switch to optm
256
+ elseif ( $type === self::TYPE_IMG_BATCH_SWITCH_OPTM ) {
257
+ if ( ! file_exists( $bk_optm_file ) ) {
258
+ continue ;
259
+ }
260
+
261
+ $i ++ ;
262
+
263
+ rename( $local_file, $bk_file ) ;
264
+ rename( $bk_optm_file, $local_file ) ;
265
+ }
266
+
267
+ }
268
+ }
269
+
270
+ LiteSpeed_Cache_Log::debug( 'Media: batch switched images total: ' . $i ) ;
271
+
272
+ }
273
+
274
+ /**
275
+ * Switch image between original one and optimized one
276
+ *
277
+ * @since 1.6.2
278
+ * @access private
279
+ */
280
+ private function _switch_optm_file( $type )
281
+ {
282
+ $pid = substr( $type, 4 ) ;
283
+ $switch_type = substr( $type, 0, 4 ) ;
284
+
285
+ global $wpdb ;
286
+ $q = "SELECT meta_value
287
+ FROM $wpdb->postmeta
288
+ WHERE post_id = %d AND meta_key = %s
289
+ " ;
290
+ $cond = array( $pid, self::DB_IMG_OPTIMIZE_DATA ) ;
291
+ $meta_value_list = $wpdb->get_var( $wpdb->prepare( $q, $cond ) ) ;
292
+ $meta_value_list = unserialize( $meta_value_list ) ;
293
+
294
+ $msg = 'Unknown Msg' ;
295
+
296
+ foreach ( $meta_value_list as $v ) {
297
+ if ( $v[ 1 ] !== 'pulled' ) {
298
+ continue ;
299
+ }
300
+
301
+ $src = $v[ 0 ] ;
302
+ $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $src ;
303
+
304
+ // to switch webp file
305
+ if ( $switch_type === 'webp' ) {
306
+ if ( file_exists( $local_file . '.webp' ) ) {
307
+ rename( $local_file . '.webp', $local_file . '.optm.webp' ) ;
308
+ LiteSpeed_Cache_Log::debug( 'Media: Disabled WebP: ' . $local_file ) ;
309
+
310
+ $msg = __( 'Disabled WebP file successfully.', 'litespeed-cache' ) ;
311
+ }
312
+ elseif ( file_exists( $local_file . '.optm.webp' ) ) {
313
+ rename( $local_file . '.optm.webp', $local_file . '.webp' ) ;
314
+ LiteSpeed_Cache_Log::debug( 'Media: Enable WebP: ' . $local_file ) ;
315
+
316
+ $msg = __( 'Enabled WebP file successfully.', 'litespeed-cache' ) ;
317
+ }
318
+ }
319
+ // to switch original file
320
+ else {
321
+ $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
322
+ $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
323
+ $bk_file = $local_filename . '.bk.' . $extension ;
324
+ $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
325
+
326
+ // revert ori back
327
+ if ( file_exists( $bk_file ) ) {
328
+ rename( $local_file, $bk_optm_file ) ;
329
+ rename( $bk_file, $local_file ) ;
330
+ LiteSpeed_Cache_Log::debug( 'Media: Restore original img: ' . $bk_file ) ;
331
+
332
+ $msg = __( 'Restored original file successfully.', 'litespeed-cache' ) ;
333
+ }
334
+ elseif ( file_exists( $bk_optm_file ) ) {
335
+ rename( $local_file, $bk_file ) ;
336
+ rename( $bk_optm_file, $local_file ) ;
337
+ LiteSpeed_Cache_Log::debug( 'Media: Switch to optm img: ' . $local_file ) ;
338
+
339
+ $msg = __( 'Switched to optimized file successfully.', 'litespeed-cache' ) ;
340
+ }
341
+
342
+ }
343
+ }
344
+
345
+ LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
346
+ }
347
+
348
+ /**
349
+ * Get wp size info
350
+ *
351
+ * NOTE: this is not used because it has to be after admin_init
352
+ *
353
+ * @since 1.6.2
354
+ * @access private
355
+ * @return array $sizes Data for all currently-registered image sizes.
356
+ */
357
+ private function get_image_sizes() {
358
+ global $_wp_additional_image_sizes ;
359
+ $sizes = array();
360
+
361
+ foreach ( get_intermediate_image_sizes() as $_size ) {
362
+ if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
363
+ $sizes[ $_size ][ 'width' ] = get_option( $_size . '_size_w' ) ;
364
+ $sizes[ $_size ][ 'height' ] = get_option( $_size . '_size_h' ) ;
365
+ $sizes[ $_size ][ 'crop' ] = (bool) get_option( $_size . '_crop' ) ;
366
+ } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
367
+ $sizes[ $_size ] = array(
368
+ 'width' => $_wp_additional_image_sizes[ $_size ][ 'width' ],
369
+ 'height' => $_wp_additional_image_sizes[ $_size ][ 'height' ],
370
+ 'crop' => $_wp_additional_image_sizes[ $_size ][ 'crop' ]
371
+ ) ;
372
+ }
373
+ }
374
+
375
+ return $sizes ;
376
+ }
377
+
378
+
379
+ /**
380
+ * Exclude role from optimization filter
381
+ *
382
+ * @since 1.6.2
383
+ * @access public
384
+ */
385
+ private function webp_support()
386
+ {
387
+ if ( empty( $_SERVER[ 'HTTP_ACCEPT' ] ) || strpos( $_SERVER[ 'HTTP_ACCEPT' ], 'image/webp' ) === false ) {
388
+ return false ;
389
+ }
390
+
391
+ return true ;
392
+ }
393
+
394
+ /**
395
+ * Check if the request is for static file
396
+ *
397
+ * @since 1.4
398
+ * @access private
399
+ * @return string The static file content
400
+ */
401
+ private function _static_request_check()
402
+ {
403
+ // This request is for js/css_async.js
404
+ if ( strpos( $_SERVER[ 'REQUEST_URI' ], self::LAZY_LIB ) !== false ) {
405
+ LiteSpeed_Cache_Log::debug( 'Media run lazyload lib' ) ;
406
+
407
+ LiteSpeed_Cache_Control::set_cacheable() ;
408
+ LiteSpeed_Cache_Control::set_no_vary() ;
409
+ LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
410
+ LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_LAZY' ) ;
411
+
412
+ $file = LSWCP_DIR . 'js/lazyload.min.js' ;
413
+
414
+ header( 'Content-Length: ' . filesize( $file ) ) ;
415
+ header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
416
+
417
+ echo file_get_contents( $file ) ;
418
+ exit ;
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Sync data from litespeed IAPI server
424
+ *
425
+ * @since 1.6.5
426
+ * @access private
427
+ */
428
+ private function _sync_data()
429
+ {
430
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_MEDIA_SYNC_DATA ) ;
431
+
432
+ if ( ! is_array( $json ) ) {
433
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to post to LiteSpeed IAPI server ', $json ) ;
434
+ $msg = __( 'Failed to communicate with LiteSpeed IAPI server', 'litespeed-cache' ) . ': ' . $json ;
435
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
436
+ return ;
437
+ }
438
+
439
+ if ( ! empty( $json ) ) {
440
+ update_option( self::DB_IMG_OPTM_SUMMARY, $json ) ;
441
+ }
442
+
443
+ $msg = __( 'Communicated with LiteSpeed Image Optimization Server successfully.', 'litespeed-cache' ) ;
444
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
445
+
446
+ LiteSpeed_Cache_Admin::redirect() ;
447
+
448
+ }
449
+
450
+ /**
451
+ * Handle all request actions from main cls
452
+ *
453
+ * @since 1.6
454
+ * @access public
455
+ */
456
+ public static function handler()
457
+ {
458
+ $instance = self::get_instance() ;
459
+
460
+ $type = LiteSpeed_Cache_Router::verify_type() ;
461
+
462
+ switch ( $type ) {
463
+ /**
464
+ * Batch switch
465
+ * @since 1.6.3
466
+ */
467
+ case self::TYPE_IMG_BATCH_SWITCH_ORI :
468
+ case self::TYPE_IMG_BATCH_SWITCH_OPTM :
469
+ $instance->_batch_switch( $type ) ;
470
+ break ;
471
+
472
+ case self::TYPE_SYNC_DATA :
473
+ $instance->_sync_data() ;
474
+ break ;
475
+
476
+ case self::TYPE_IMG_OPTIMIZE :
477
+ $instance->_img_optimize() ;
478
+ break ;
479
+
480
+ case self::TYPE_IMG_OPTIMIZE_RESCAN :
481
+ $instance->_img_optimize_rescan() ;
482
+ break ;
483
+
484
+ case self::TYPE_IMG_OPTIMIZE_DESTROY :
485
+ $instance->_img_optimize_destroy() ;
486
+ break ;
487
+
488
+ case self::TYPE_IMG_PULL :
489
+ LiteSpeed_Cache_Log::debug( 'Media: Manually running Cron pull_optimized_img' ) ;
490
+ $instance->_pull_optimized_img() ;
491
+ break ;
492
+
493
+ case substr( $type, 0, 4 ) === 'webp' :
494
+ case substr( $type, 0, 4 ) === 'orig' :
495
+ $instance->_switch_optm_file( $type ) ;
496
+ break ;
497
+
498
+ default:
499
+ break ;
500
+ }
501
+
502
+ LiteSpeed_Cache_Admin::redirect() ;
503
+ }
504
+
505
+ /**
506
+ * Check if fetch cron is running
507
+ *
508
+ * @since 1.6.2
509
+ * @access public
510
+ */
511
+ public function cron_running( $bool_res = true )
512
+ {
513
+ $last_run = get_option( self::OPT_CRON_RUN ) ;
514
+
515
+ $is_running = $last_run && time() - $last_run <= 120 ;
516
+
517
+ if ( $bool_res ) {
518
+ return $is_running ;
519
+ }
520
+
521
+ return array( $last_run, $is_running ) ;
522
+ }
523
+
524
+ /**
525
+ * Update fetch cron timestamp tag
526
+ *
527
+ * @since 1.6.2
528
+ * @access private
529
+ */
530
+ private function _update_cron_running()
531
+ {
532
+ update_option( self::OPT_CRON_RUN, time() ) ;
533
+ }
534
+
535
+ /**
536
+ * Pull optimized img
537
+ *
538
+ * @since 1.6
539
+ * @access public
540
+ */
541
+ public static function pull_optimized_img()
542
+ {
543
+ LiteSpeed_Cache_Log::debug( 'Media: Cron pull_optimized_img started' ) ;
544
+ $instance = self::get_instance() ;
545
+ $instance->_pull_optimized_img() ;
546
+ }
547
+
548
+ /**
549
+ * Pull optimized img
550
+ *
551
+ * @since 1.6
552
+ * @access private
553
+ */
554
+ private function _pull_optimized_img()
555
+ {
556
+ if ( $this->cron_running() ) {
557
+ LiteSpeed_Cache_Log::debug( 'Media: fetch cron is running' ) ;
558
+ return ;
559
+ }
560
+
561
+ global $wpdb ;
562
+
563
+ $q = "SELECT a.meta_id, a.post_id, b.meta_id as bmeta_id, b.meta_value, c.meta_id as cmeta_id, c.meta_value as cmeta_value
564
+ FROM $wpdb->postmeta a
565
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.post_id
566
+ LEFT JOIN $wpdb->postmeta c ON c.post_id = a.post_id AND c.meta_key = %s
567
+ WHERE a.meta_key = %s AND a.meta_value = %s AND b.meta_key = %s
568
+ ORDER BY a.post_id DESC
569
+ LIMIT 1
570
+ " ;
571
+ $cond = array( self::DB_IMG_OPTIMIZE_SIZE, self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED, self::DB_IMG_OPTIMIZE_DATA ) ;
572
+ $query = $wpdb->prepare( $q, $cond ) ;
573
+
574
+ $webp_only = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ) ;
575
+
576
+ for ( $i=0 ; $i < 10 ; $i++ ) {
577
+ $meta_value_row = $wpdb->get_row( $query ) ;
578
+
579
+ if ( ! $meta_value_row ) {
580
+ break ;
581
+ }
582
+
583
+ $meta_value = unserialize( $meta_value_row->meta_value ) ;
584
+
585
+ if ( $meta_value_row->cmeta_value ) {
586
+ $cmeta_value = unserialize( $meta_value_row->cmeta_value ) ;
587
+ }
588
+ else {
589
+ $cmeta_value = array(
590
+ 'ori_total' => 0,
591
+ 'ori_saved' => 0,
592
+ 'webp_total' => 0,
593
+ 'webp_saved' => 0,
594
+ ) ;
595
+ }
596
+
597
+ // Start fetching
598
+ foreach ( $meta_value as $md5 => $v2 ) {
599
+
600
+ /**
601
+ * Update cron timestamp to avoid duplicated running
602
+ * @since 1.6.2
603
+ */
604
+ $this->_update_cron_running() ;
605
+
606
+ if ( $v2[ 1 ] === self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
607
+ $server = $v2[ 2 ] ;
608
+ // send fetch request
609
+ $data = array(
610
+ 'pid' => $meta_value_row->post_id,
611
+ 'src_md5' => $md5,
612
+ 'meta' => $meta_value_row->meta_value,
613
+ ) ;
614
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG, $data, $server ) ;
615
+ if ( empty( $json[ 'webp' ] ) ) {
616
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to pull optimized img: ', $json ) ;
617
+ return ;
618
+ }
619
+
620
+ $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v2[ 0 ] ;
621
+ $ori_size = filesize( $local_file ) ;
622
+
623
+ /**
624
+ * Use wp orignal get func to avoid allow_url_open off issue
625
+ * @since 1.6.5
626
+ */
627
+ // Fetch webp image
628
+ $response = wp_remote_get( $json[ 'webp' ], array( 'timeout' => 15 ) ) ;
629
+ if ( is_wp_error( $response ) ) {
630
+ $error_message = $response->get_error_message() ;
631
+ LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
632
+ return ;
633
+ }
634
+
635
+ file_put_contents( $local_file . '.webp', $response[ 'body' ] ) ;
636
+
637
+ if ( ! file_exists( $local_file . '.webp' ) ) {
638
+ return ;
639
+ }
640
+
641
+ // Unknown issue
642
+ if ( md5_file( $local_file . '.webp' ) !== $json[ 'webp_md5' ] ) {
643
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to pull optimized img WebP: file md5 dismatch, server md5: ' . $json[ 'webp_md5' ] ) ;
644
+
645
+ // update status to failed
646
+ $meta_value[ $md5 ][ 1 ] = self::DB_IMG_OPTIMIZE_STATUS_FAILED ;
647
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d ";
648
+ $wpdb->query( $wpdb->prepare( $q, array( serialize( $meta_value ), $meta_value_row->bmeta_id ) ) ) ;
649
+
650
+ // Notify server to update status
651
+ LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server ) ;
652
+
653
+ return ;// exit from running pull process
654
+ }
655
+
656
+ // log webp file saved size summary
657
+ $saved = $ori_size - filesize( $local_file . '.webp' ) ;
658
+ if ( $saved > 0 ) {
659
+ $cmeta_value[ 'webp_total' ] += $ori_size ;
660
+ $cmeta_value[ 'webp_saved' ] += $saved ;
661
+ }
662
+
663
+ LiteSpeed_Cache_Log::debug( 'Media: Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
664
+
665
+ // Fetch optimized image itself
666
+ if ( ! $webp_only && ! empty( $json[ 'target_file' ] ) ) {
667
+
668
+ // Fetch failed, unkown issue, return
669
+ // NOTE: if this failed more than 5 times, next time fetching webp will touch err limit on server side, whole image will be failed
670
+ $response = wp_remote_get( $json[ 'target_file' ], array( 'timeout' => 15 ) ) ;
671
+ if ( is_wp_error( $response ) ) {
672
+ $error_message = $response->get_error_message() ;
673
+ LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
674
+ return ;
675
+ }
676
+
677
+ file_put_contents( $local_file . '.tmp', $response[ 'body' ] ) ;
678
+ // Unknown issue
679
+ if ( md5_file( $local_file . '.tmp' ) !== $json[ 'target_md5' ] ) {
680
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to pull optimized img iteself: file md5 dismatch, server md5: ' . $json[ 'target_md5' ] ) ;
681
+
682
+ // update status to failed
683
+ $meta_value[ $md5 ][ 1 ] = self::DB_IMG_OPTIMIZE_STATUS_FAILED ;
684
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d ";
685
+ $wpdb->query( $wpdb->prepare( $q, array( serialize( $meta_value ), $meta_value_row->bmeta_id ) ) ) ;
686
+
687
+ // Notify server to update status
688
+ LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PULL_IMG_FAILED, $data, $server ) ;
689
+
690
+ return ; // exit from running pull process
691
+ }
692
+
693
+ // log webp file saved size summary
694
+ $saved = $ori_size - filesize( $local_file . '.tmp' ) ;
695
+ if ( $saved > 0 ) {
696
+ $cmeta_value[ 'ori_total' ] += $ori_size ;
697
+ $cmeta_value[ 'ori_saved' ] += $saved ;
698
+ }
699
+
700
+ // Backup ori img
701
+ $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
702
+ $bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
703
+ rename( $local_file, $bk_file ) ;
704
+
705
+ // Replace ori img
706
+ rename( $local_file . '.tmp', $local_file ) ;
707
+
708
+ LiteSpeed_Cache_Log::debug( 'Media: Pulled optimized img: ' . $local_file ) ;
709
+ }
710
+
711
+
712
+ // Update meta value
713
+ $meta_value[ $md5 ][ 1 ] = self::DB_IMG_OPTIMIZE_STATUS_PULLED ;
714
+ }
715
+ }
716
+
717
+ LiteSpeed_Cache_Log::debug( 'Media: Pulled optimized img done, updating record pid: ' . $meta_value_row->post_id ) ;
718
+
719
+ // Update data tag
720
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d ";
721
+ $wpdb->query( $wpdb->prepare( $q, array( serialize( $meta_value ), $meta_value_row->bmeta_id ) ) ) ;
722
+
723
+ /**
724
+ * Update size saved info
725
+ * @since 1.6.5
726
+ */
727
+ if ( $meta_value_row->cmeta_id ) {
728
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d ";
729
+ $wpdb->query( $wpdb->prepare( $q, array( serialize( $cmeta_value ), $meta_value_row->cmeta_id ) ) ) ;
730
+ }
731
+ else {
732
+ $q = "INSERT INTO $wpdb->postmeta SET meta_value = %s, meta_id = %d, meta_key = %s, post_id = %d ";
733
+ $wpdb->query( $wpdb->prepare( $q, array( serialize( $cmeta_value ), $meta_value_row->cmeta_id, self::DB_IMG_OPTIMIZE_SIZE, $meta_value_row->post_id ) ) ) ;
734
+ }
735
+
736
+ // Update status tag if all pulled or still has requested img
737
+ $has_notify = false ;// it may be bypassed in above loop
738
+ $has_request = false ;
739
+ foreach ( $meta_value as $v2 ) {
740
+ if ( $v2[ 1 ] === self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) {
741
+ $has_request = true ;
742
+ }
743
+ if ( $v2[ 1 ] === self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
744
+ $has_notify = true ;
745
+ }
746
+ }
747
+
748
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d ";
749
+
750
+ // Update pid status
751
+ if ( ! $has_notify ) {
752
+ $new_status = self::DB_IMG_OPTIMIZE_STATUS_PULLED ;
753
+ if ( $has_request ) {
754
+ $new_status = self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ;
755
+ }
756
+ LiteSpeed_Cache_Log::debug( 'Media: Updated pid status: ' . $new_status ) ;
757
+
758
+ $wpdb->query( $wpdb->prepare( $q, array( $new_status, $meta_value_row->meta_id ) ) ) ;
759
+ }
760
+ }
761
+
762
+ // If all pulled, update tag to done
763
+ $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s LIMIT 1" ;
764
+ $meta_value_list = $wpdb->get_row( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ) ) ;
765
+ if ( ! $meta_value_list ) {
766
+ LiteSpeed_Cache_Log::debug( 'Media: Marked poll status to all pulled ' ) ;
767
+ update_option( LiteSpeed_Cache_Config::ITEM_MEDIA_NEED_PULL, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ;
768
+ }
769
+ }
770
+
771
+ /**
772
+ * Check if need to do a pull for optimized img
773
+ *
774
+ * @since 1.6
775
+ * @access public
776
+ */
777
+ public static function check_need_pull()
778
+ {
779
+ $tag = get_option( LiteSpeed_Cache_Config::ITEM_MEDIA_NEED_PULL ) ;
780
+ return defined( 'DOING_CRON' ) && $tag && $tag === self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ;
781
+ }
782
+
783
+ /**
784
+ * Show an image's optm status
785
+ *
786
+ * @since 1.6.5
787
+ * @access public
788
+ */
789
+ public function check_img()
790
+ {
791
+ $pid = $_POST[ 'data' ] ;
792
+
793
+ LiteSpeed_Cache_Log::debug( 'Media: Check image [ID] ' . $pid ) ;
794
+
795
+ $data = array() ;
796
+
797
+ $data[ 'img_count' ] = $this->img_count() ;
798
+
799
+ $info = get_post_meta( $pid, self::DB_IMG_OPTIMIZE_STATUS, true ) ;
800
+ $data[ self::DB_IMG_OPTIMIZE_STATUS ] = $info ;
801
+
802
+ $info = get_post_meta( $pid, self::DB_IMG_OPTIMIZE_DATA, true ) ;
803
+ $data[ self::DB_IMG_OPTIMIZE_DATA ] = $info ;
804
+
805
+ echo json_encode( $data ) ;
806
+ exit;
807
+ }
808
+
809
+ /**
810
+ * parse LiteSpeed IAPI server data
811
+ *
812
+ * @since 1.6.5
813
+ * @access public
814
+ */
815
+ private function _parse_notify_data()
816
+ {
817
+ $notified_data = unserialize( base64_decode( $_POST[ 'data' ] ) ) ;
818
+ if ( empty( $notified_data ) || ! is_array( $notified_data ) ) {
819
+ LiteSpeed_Cache_Log::debug( 'Media: notify exit: no notified data' ) ;
820
+ exit( json_encode( 'no notified data' ) ) ;
821
+ }
822
+
823
+ if ( empty( $_POST[ 'server' ] ) || substr( $_POST[ 'server' ], -21 ) !== 'api.litespeedtech.com' ) {
824
+ LiteSpeed_Cache_Log::debug( 'Media: notify exit: no/wrong server' ) ;
825
+ exit( json_encode( 'no/wrong server' ) ) ;
826
+ }
827
+
828
+ $_allowed_status = array( self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED, self::DB_IMG_OPTIMIZE_STATUS_ERR, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
829
+
830
+ if ( empty( $_POST[ 'status' ] ) || ! in_array( $_POST[ 'status' ], $_allowed_status ) ) {
831
+ LiteSpeed_Cache_Log::debug( 'Media: notify exit: no/wrong status' ) ;
832
+ exit( json_encode( 'no/wrong status' ) ) ;
833
+ }
834
+
835
+ return array( $notified_data, $_POST[ 'server' ], $_POST[ 'status' ] ) ;
836
+ }
837
+
838
+ /**
839
+ * LiteSpeed Child server notify Client img status changed
840
+ *
841
+ * @since 1.6
842
+ * @since 1.6.5 Added err/request status free switch
843
+ * @access public
844
+ */
845
+ public function notify_img()
846
+ {
847
+ list( $notified_data, $server, $status ) = $this->_parse_notify_data() ;
848
+
849
+ global $wpdb ;
850
+
851
+ $pids = array_keys( $notified_data ) ;
852
+
853
+ $q = "SELECT meta_id, post_id, meta_value FROM $wpdb->postmeta WHERE post_id IN ( " . implode( ',', array_fill( 0, count( $pids ), '%d' ) ) . " ) AND meta_key = %s" ;
854
+ $meta_value_list = $wpdb->get_results( $wpdb->prepare( $q, array_merge( $pids, array( self::DB_IMG_OPTIMIZE_DATA ) ) ) ) ;
855
+
856
+ $need_pull = false ;
857
+
858
+ foreach ( $meta_value_list as $v ) {
859
+ $changed = false ;
860
+ $md52src_list = unserialize( $v->meta_value ) ;
861
+ // replace src tag from requested to notified
862
+ foreach ( $md52src_list as $md5 => $v2 ) {
863
+ if ( in_array( $md5, $notified_data[ $v->post_id ] ) && $v2[ 1 ] !== self::DB_IMG_OPTIMIZE_STATUS_PULLED ) {
864
+ $md52src_list[ $md5 ][ 1 ] = $status ;
865
+ $md52src_list[ $md5 ][ 2 ] = $server ;
866
+ $changed = true ;
867
+ }
868
+ }
869
+
870
+ if ( ! $changed ) {
871
+ LiteSpeed_Cache_Log::debug( 'Media: notify_img [status] ' . $status . ' continue: no changed meta [pid] ' . $v->post_id ) ;
872
+ continue ;
873
+ }
874
+
875
+ $new_status = $this->_get_status_by_meta_data( $md52src_list, $status ) ;
876
+
877
+ // Save meta data
878
+ $md52src_list = serialize( $md52src_list ) ;
879
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d" ;
880
+ $wpdb->query( $wpdb->prepare( $q, array( $md52src_list, $v->meta_id ) ) ) ;
881
+
882
+ // Overwrite post meta status to the latest one
883
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE post_id = %d AND meta_key = %s" ;
884
+ // If partly needs notified to pull, notified should overwrite this post's status always
885
+ $wpdb->query( $wpdb->prepare( $q, array( $new_status, $v->post_id, self::DB_IMG_OPTIMIZE_STATUS ) ) ) ;
886
+
887
+ LiteSpeed_Cache_Log::debug( 'Media: notify_img [status] ' . $status . ' updated post_meta [pid] ' . $v->post_id ) ;
888
+
889
+ if ( $status == self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
890
+ $need_pull = true ;
891
+ }
892
+ }
893
+
894
+ if ( $need_pull ) {
895
+ update_option( LiteSpeed_Cache_Config::ITEM_MEDIA_NEED_PULL, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ;
896
+ }
897
+
898
+ // redo count err
899
+
900
+ echo json_encode( array( 'count' => count( $notified_data ) ) ) ;
901
+ exit() ;
902
+ }
903
+
904
+ /**
905
+ * Generate post's img optm status from child images meta value
906
+ *
907
+ * @since 1.6.7
908
+ * @access private
909
+ */
910
+ private function _get_status_by_meta_data( $md52src_list, $default_status )
911
+ {
912
+ $has_notify = false ;
913
+ $has_request = false ;
914
+ $has_pull = false ;
915
+
916
+ foreach ( $md52src_list as $v ) {
917
+ if ( $v[ 1 ] == self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
918
+ $has_notify = true ;
919
+ }
920
+ if ( $v[ 1 ] == self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) {
921
+ $has_request = true ;
922
+ }
923
+ if ( $v[ 1 ] == self::DB_IMG_OPTIMIZE_STATUS_PULLED ) {
924
+ $has_pull = true ;
925
+ }
926
+ }
927
+
928
+ if ( $has_notify ) {
929
+ $new_status = self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ;
930
+ }
931
+ elseif ( $has_request ) {
932
+ $new_status = self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ;
933
+ }
934
+ elseif ( $has_pull ) {
935
+ $new_status = self::DB_IMG_OPTIMIZE_STATUS_PULLED ;
936
+ }
937
+ else {
938
+ $new_status = $default_status ;
939
+ }
940
+
941
+ return $new_status ;
942
+
943
+ }
944
+
945
+ /**
946
+ * Parse wp's meta value
947
+ *
948
+ * @since 1.6.7
949
+ * @access private
950
+ */
951
+ private function _parse_wp_meta_value( $v )
952
+ {
953
+ if ( ! $v->meta_value ) {
954
+ LiteSpeed_Cache_Log::debug( 'Media: bypassed parsing meta due to no meta_value: pid ' . $v->post_id ) ;
955
+ return false ;
956
+ }
957
+
958
+ try {
959
+ $meta_value = unserialize( $v->meta_value ) ;
960
+ }
961
+ catch ( \Exception $e ) {
962
+ LiteSpeed_Cache_Log::debug( 'Media: bypassed parsing meta due to meta_value not json: pid ' . $v->post_id ) ;
963
+ return false ;
964
+ }
965
+
966
+ if ( empty( $meta_value[ 'file' ] ) ) {
967
+ LiteSpeed_Cache_Log::debug( 'Media: bypassed parsing meta due to no ori file: pid ' . $v->post_id ) ;
968
+ return false ;
969
+ }
970
+
971
+ return $meta_value ;
972
+
973
+ }
974
+
975
+ /**
976
+ * Push img to LiteSpeed IAPI server
977
+ *
978
+ * @since 1.6.7
979
+ * @access private
980
+ */
981
+ private function _push_img_in_queue_to_ls()
982
+ {
983
+ $data = array(
984
+ 'list' => $this->_img_in_queue,
985
+ 'webp_only' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_ONLY ),
986
+ 'keep_exif' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_EXIF ),
987
+ 'webp_lossless' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_WEBP_LOSSLESS ),
988
+ ) ;
989
+
990
+ // Push to LiteSpeed IAPI server
991
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_REQUEST_OPTIMIZE, LiteSpeed_Cache_Utility::arr2str( $data ) ) ;
992
+
993
+ if ( $json === null ) {// admin_api will handle common err
994
+ return null ;
995
+ }
996
+
997
+ if ( ! is_array( $json ) ) {
998
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to post to LiteSpeed IAPI server ', $json ) ;
999
+ $msg = sprintf( __( 'Failed to push to LiteSpeed IAPI server: %s', 'litespeed-cache' ), $json ) ;
1000
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1001
+ return null ;
1002
+ }
1003
+
1004
+ // Check data format
1005
+ if ( empty( $json[ 'pids' ] ) || ! is_array( $json[ 'pids' ] ) ) {
1006
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to parse data from LiteSpeed IAPI server ', $json[ 'pids' ] ) ;
1007
+ $msg = sprintf( __( 'Failed to parse data from LiteSpeed IAPI server: %s', 'litespeed-cache' ), $json[ 'pids' ] ) ;
1008
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1009
+ return null ;
1010
+ }
1011
+
1012
+ LiteSpeed_Cache_Log::debug( 'Media: posts data from LiteSpeed IAPI server count: ' . count( $json[ 'pids' ] ) ) ;
1013
+
1014
+ return $json ;
1015
+
1016
+ }
1017
 
1018
  /**
1019
+ * Send destroy all requests cmd to LiteSpeed IAPI server and get the link to finish it ( avoid click by mistake )
1020
  *
1021
+ * @since 1.6.7
1022
  * @access private
1023
  */
1024
+ private function _img_optimize_destroy()
1025
  {
1026
+ LiteSpeed_Cache_Log::debug( 'Media: sending DESTROY cmd to LiteSpeed IAPI' ) ;
1027
+
1028
+ // Mark request time to avoid duplicated request
1029
+ update_option( self::DB_IMG_OPTIMIZE_DESTROY, time() ) ;
1030
+
1031
+ // Push to LiteSpeed IAPI server
1032
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_REQUEST_DESTROY ) ;
1033
+
1034
+ // confirm link will be displayed by Admin_API automatically
1035
+ if ( is_array( $json ) && $json ) {
1036
+ LiteSpeed_Cache_Log::debug( 'Media: cmd result', $json ) ;
1037
+ }
1038
 
 
1039
  }
1040
 
1041
  /**
1042
+ * Callback from LiteSpeed IAPI server to destroy all optm data
1043
  *
1044
+ * @since 1.6.7
1045
  * @access private
 
1046
  */
1047
+ public function img_optimize_destroy_callback()
1048
  {
1049
+ global $wpdb ;
1050
+ LiteSpeed_Cache_Log::debug( 'Media: excuting DESTROY process' ) ;
 
1051
 
1052
+ $request_time = get_option( self::DB_IMG_OPTIMIZE_DESTROY ) ;
1053
+ if ( time() - $request_time > 300 ) {
1054
+ LiteSpeed_Cache_Log::debug( 'Media: terminate DESTROY process due to timeout' ) ;
1055
+ exit( 'Destroy callback timeout ( 300 seconds )' ) ;
1056
+ }
1057
 
1058
+ // Start deleting files
1059
+ $q = "SELECT * from $wpdb->postmeta WHERE meta_key = %s" ;
1060
+ $list = $wpdb->get_results( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_DATA ) ) ) ;
1061
+ if ( $list ) {
1062
+ foreach ( $list as $v ) {
1063
+ $meta_value_list = unserialize( $v->meta_value ) ;
1064
+ foreach ( $meta_value_list as $v2 ) {
1065
 
1066
+ $src = $v2[ 0 ] ;
1067
+ $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $src ;
1068
 
1069
+ // del webp
1070
+ file_exists( $local_file . '.webp' ) && unlink( $local_file . '.webp' ) ;
1071
+ file_exists( $local_file . '.optm.webp' ) && unlink( $local_file . '.optm.webp' ) ;
1072
+
1073
+ $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1074
+ $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1075
+ $bk_file = $local_filename . '.bk.' . $extension ;
1076
+ $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1077
+
1078
+ // del optimized ori
1079
+ if ( file_exists( $bk_file ) ) {
1080
+ unlink( $local_file ) ;
1081
+ rename( $bk_file, $local_file ) ;
1082
+ }
1083
+ file_exists( $bk_optm_file ) && unlink( $bk_optm_file ) ;
1084
+ }
1085
+ }
1086
+ }
1087
+
1088
+ // Delete optm info
1089
+ $q = "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'litespeed-optimize%'" ;
1090
+ $wpdb->query( $q ) ;
1091
+
1092
+ // Clear credit info
1093
+ delete_option( self::DB_IMG_OPTM_SUMMARY ) ;
1094
+
1095
+ exit( 'ok' ) ;
1096
+ }
1097
+
1098
+ /**
1099
+ * Resend requested img to LiteSpeed IAPI server
1100
+ *
1101
+ * @since 1.6.7
1102
+ * @access private
1103
+ */
1104
+ private function _img_optimize_rescan()
1105
+ {
1106
+ LiteSpeed_Cache_Log::debug( 'Media: resend requested images' ) ;
1107
+
1108
+ $_credit = (int) $this->summary_info( 'credit' ) ;
1109
+
1110
+ global $wpdb ;
1111
+
1112
+ $q = "SELECT a.post_id, a.meta_value, b.meta_id as bmeta_id, c.meta_id as cmeta_id, c.meta_value as cmeta_value
1113
+ FROM $wpdb->postmeta a
1114
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.post_id
1115
+ LEFT JOIN $wpdb->postmeta c ON c.post_id = a.post_id
1116
+ WHERE a.meta_key = '_wp_attachment_metadata'
1117
+ AND b.meta_key = %s
1118
+ AND c.meta_key = %s
1119
+ LIMIT %d
1120
+ " ;
1121
+ $limit_rows = apply_filters( 'litespeed_img_optm_resend_rows', 300 ) ;
1122
+ $list = $wpdb->get_results( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_DATA, $limit_rows ) ) ) ;
1123
+ if ( ! $list ) {
1124
+ LiteSpeed_Cache_Log::debug( 'Media: resend request bypassed: no image found' ) ;
1125
+ $msg = __( 'No image found', 'litespeed-cache' ) ;
1126
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1127
+ return ;
1128
+ }
1129
+
1130
+ // meta list
1131
+ $optm_data_list = array() ;
1132
+ $optm_data_pid2mid_list = array() ;
1133
+
1134
+ foreach ( $list as $v ) {
1135
+ // wp meta
1136
+ $meta_value = $this->_parse_wp_meta_value( $v ) ;
1137
+ if ( ! $meta_value ) {
1138
+ continue ;
1139
+ }
1140
+ if ( empty( $meta_value[ 'sizes' ] ) ) {
1141
+ continue ;
1142
+ }
1143
+
1144
+ $optm_data_pid2mid_list[ $v->post_id ] = array( 'status_mid' => $v->bmeta_id, 'data_mid' => $v->cmeta_id ) ;
1145
+
1146
+ // prepare for pushing
1147
+ $this->tmp_pid = $v->post_id ;
1148
+ $this->tmp_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/' ;
1149
+
1150
+ // ls optimized meta
1151
+ $optm_meta = $optm_data_list[ $v->post_id ] = unserialize( $v->cmeta_value ) ;
1152
+ $optm_list = array() ;
1153
+ foreach ( $optm_meta as $md5 => $optm_row ) {
1154
+ $optm_list[] = $optm_row[ 0 ] ;
1155
+ // only do for requested/notified img
1156
+ // if ( ! in_array( $optm_row[ 1 ], array( self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ) ) {
1157
+ // continue ;
1158
+ // }
1159
+ }
1160
+
1161
+ // check if there is new files from wp meta
1162
+ $img_queue = array() ;
1163
+ foreach ( $meta_value[ 'sizes' ] as $v2 ) {
1164
+ $curr_file = $this->tmp_path . $v2[ 'file' ] ;
1165
+
1166
+ // new child file OR not finished yet
1167
+ if ( ! in_array( $curr_file, $optm_list ) ) {
1168
+ $img_queue[] = $v2 ;
1169
+ }
1170
+ }
1171
+
1172
+ // nothing to add
1173
+ if ( ! $img_queue ) {
1174
+ continue ;
1175
+ }
1176
+
1177
+ $num_will_incease = count( $img_queue ) ;
1178
+ if ( $this->_img_total + $num_will_incease > $_credit ) {
1179
+ LiteSpeed_Cache_Log::debug( 'Media: resend img request hit limit: [total] ' . $this->_img_total . " \t[add] $num_will_incease \t[credit] $_credit" ) ;
1180
+ break ;
1181
+ }
1182
+
1183
+ foreach ( $img_queue as $v2 ) {
1184
+ $this->_img_queue( $v2 ) ;
1185
+ }
1186
+ }
1187
+
1188
+ // push to LiteSpeed IAPI server
1189
+ if ( empty( $this->_img_in_queue ) ) {
1190
+ $msg = __( 'No image found.', 'litespeed-cache' ) ;
1191
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1192
+ return ;
1193
+ }
1194
+
1195
+ $total_groups = count( $this->_img_in_queue ) ;
1196
+ LiteSpeed_Cache_Log::debug( 'Media: prepared images to push: groups ' . $total_groups . ' images ' . $this->_img_total ) ;
1197
+
1198
+ // Push to LiteSpeed IAPI server
1199
+ $json = $this->_push_img_in_queue_to_ls() ;
1200
+ if ( $json === null ) {
1201
+ return ;
1202
+ }
1203
+ // Returned data is the requested and notifed images
1204
+ $pids = $json[ 'pids' ] ;
1205
+
1206
+ LiteSpeed_Cache_Log::debug( 'Media: returned data from LiteSpeed IAPI server count: ' . count( $pids ) ) ;
1207
+
1208
+ $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d" ;
1209
+
1210
+ // Update data
1211
+ foreach ( $pids as $pid ) {
1212
+ $md52src_list = $optm_data_list[ $pid ] ;
1213
+
1214
+ foreach ( $this->_img_in_queue[ $pid ] as $md5 => $src_data ) {
1215
+ $md52src_list[ $md5 ] = array( $src_data[ 'file' ], self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
1216
+ }
1217
+
1218
+ $new_status = $this->_get_status_by_meta_data( $md52src_list, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
1219
+
1220
+ $md52src_list = serialize( $md52src_list ) ;
1221
+
1222
+ // Store data
1223
+ $wpdb->query( $wpdb->prepare( $q, array( $new_status, $optm_data_pid2mid_list[ $pid ][ 'status_mid' ] ) ) ) ;
1224
+ $wpdb->query( $wpdb->prepare( $q, array( $md52src_list, $optm_data_pid2mid_list[ $pid ][ 'data_mid' ] ) ) ) ;
1225
+ }
1226
+
1227
+ $accepted_groups = count( $pids ) ;
1228
+ $accepted_imgs = $json[ 'total' ] ;
1229
+
1230
+ $msg = sprintf( __( 'Pushed %1$s groups with %2$s images to LiteSpeed optimization server, accepted %3$s groups with %4$s images.', 'litespeed-cache' ), $total_groups, $this->_img_total, $accepted_groups, $accepted_imgs ) ;
1231
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1232
+
1233
+ // Update credit info
1234
+ if ( isset( $json[ 'credit' ] ) ) {
1235
+ $this->_update_credit( $json[ 'credit' ] ) ;
1236
+ }
1237
+
1238
+ }
1239
+
1240
+ /**
1241
+ * Push raw img to LiteSpeed IAPI server
1242
+ *
1243
+ * @since 1.6
1244
+ * @access private
1245
+ */
1246
+ private function _img_optimize()
1247
+ {
1248
+ $_credit = (int) $this->summary_info( 'credit' ) ;
1249
+ $credit_recovered = (int) $this->summary_info( 'credit_recovered' ) ;
1250
+
1251
+ LiteSpeed_Cache_Log::debug( 'Media preparing images to push' ) ;
1252
+
1253
+ global $wpdb ;
1254
+ // Get images
1255
+ $q = "SELECT b.post_id, b.meta_value
1256
+ FROM $wpdb->posts a
1257
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1258
+ LEFT JOIN $wpdb->postmeta c ON c.post_id = a.ID AND c.meta_key = %s
1259
+ WHERE a.post_type = 'attachment'
1260
+ AND a.post_status = 'inherit'
1261
+ AND a.post_mime_type IN ('image/jpeg', 'image/png')
1262
+ AND b.meta_key = '_wp_attachment_metadata'
1263
+ AND c.post_id IS NULL
1264
+ ORDER BY a.ID DESC
1265
+ LIMIT %d
1266
+ " ;
1267
+ $q = $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, apply_filters( 'litespeed_img_optimize_max_rows', 100 ) ) ) ;
1268
+
1269
+ $img_set = array() ;
1270
+ $list = $wpdb->get_results( $q ) ;
1271
+ if ( ! $list ) {
1272
+ LiteSpeed_Cache_Log::debug( 'Media optimize bypass: no image found' ) ;
1273
+ return ;
1274
+ }
1275
+
1276
+ LiteSpeed_Cache_Log::debug( 'Media found images: ' . count( $list ) ) ;
1277
+
1278
+ foreach ( $list as $v ) {
1279
+
1280
+ $meta_value = $this->_parse_wp_meta_value( $v ) ;
1281
+ if ( ! $meta_value ) {
1282
+ continue ;
1283
+ }
1284
+
1285
+ /**
1286
+ * Only send 500 images one time
1287
+ * @since 1.6.3
1288
+ * @since 1.6.5 use credit limit
1289
+ */
1290
+ $num_will_incease = 1 ;
1291
+ if ( ! empty( $meta_value[ 'sizes' ] ) ) {
1292
+ $num_will_incease += count( $meta_value[ 'sizes' ] ) ;
1293
+ }
1294
+ if ( $this->_img_total + $num_will_incease > $_credit ) {
1295
+ if ( ! $this->_img_total ) {
1296
+ $msg = sprintf( __( 'Number of images in one image group (%s) exceeds the credit (%s)', 'litespeed-cache' ), $num_will_incease, $_credit ) ;
1297
+ LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1298
+ }
1299
+ LiteSpeed_Cache_Log::debug( 'Media img request hit limit: [total] ' . $this->_img_total . " \t[add] $num_will_incease \t[credit] $_credit" ) ;
1300
+ break ;
1301
+ }
1302
+ /**
1303
+ * Check if need to test run ( new user only allow 1 group at first time)
1304
+ * @since 1.6.6.1
1305
+ */
1306
+ if ( $this->_img_total && ! $credit_recovered ) {
1307
+ LiteSpeed_Cache_Log::debug( 'Media: test run only allow 1 group ' ) ;
1308
+ break ;
1309
+ }
1310
+
1311
+ // push orig image to queue
1312
+ $this->tmp_pid = $v->post_id ;
1313
+ $this->tmp_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/' ;
1314
+ $this->_img_queue( $meta_value, true ) ;
1315
+ if ( ! empty( $meta_value[ 'sizes' ] ) ) {
1316
+ array_map( array( $this, '_img_queue' ), $meta_value[ 'sizes' ] ) ;
1317
+ }
1318
+
1319
+ }
1320
+
1321
+ // push to LiteSpeed IAPI server
1322
+ if ( empty( $this->_img_in_queue ) ) {
1323
+ $msg = __( 'No image found.', 'litespeed-cache' ) ;
1324
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1325
+ return ;
1326
  }
1327
+
1328
+ $total_groups = count( $this->_img_in_queue ) ;
1329
+ LiteSpeed_Cache_Log::debug( 'Media prepared images to push: groups ' . $total_groups . ' images ' . $this->_img_total ) ;
1330
+
1331
+ // Push to LiteSpeed IAPI server
1332
+ $json = $this->_push_img_in_queue_to_ls() ;
1333
+ if ( $json === null ) {
1334
+ return ;
1335
+ }
1336
+ $pids = $json[ 'pids' ] ;
1337
+
1338
+ // Exclude those who have meta already
1339
+ $q = "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s and post_id in ( " . implode( ',', array_fill( 0, count( $pids ), '%s' ) ) . " )" ;
1340
+ $tmp = $wpdb->get_results( $wpdb->prepare( $q, array_merge( array( self::DB_IMG_OPTIMIZE_STATUS ), $pids ) ) ) ;
1341
+ $exists_pids = array() ;
1342
+ foreach ( $tmp as $v ) {
1343
+ $exists_pids[] = $v->post_id ;
1344
+ }
1345
+ if ( $exists_pids ) {
1346
+ LiteSpeed_Cache_Log::debug( 'Media: existing posts data from LiteSpeed IAPI server count: ' . count( $exists_pids ) ) ;
1347
+ }
1348
+ $pids = array_diff( $pids, $exists_pids ) ;
1349
+
1350
+ if ( ! $pids ) {
1351
+ LiteSpeed_Cache_Log::debug( 'Media: Failed to store data from LiteSpeed IAPI server with empty pids' ) ;
1352
+ LiteSpeed_Cache_Admin_Display::error( __( 'Post data is empty.', 'litespeed-cache' ) ) ;
1353
+ return ;
1354
+ }
1355
+
1356
+ LiteSpeed_Cache_Log::debug( 'Media: diff posts data from LiteSpeed IAPI server count: ' . count( $pids ) ) ;
1357
+
1358
+ $q = "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES " ;
1359
+ $data_to_add = array() ;
1360
+ foreach ( $pids as $pid ) {
1361
+ $data_to_add[] = $pid ;
1362
+ $data_to_add[] = self::DB_IMG_OPTIMIZE_STATUS ;
1363
+ $data_to_add[] = self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ;
1364
+ $data_to_add[] = $pid ;
1365
+ $data_to_add[] = self::DB_IMG_OPTIMIZE_DATA ;
1366
+ $md52src_list = array() ;
1367
+ foreach ( $this->_img_in_queue[ $pid ] as $md5 => $src_data ) {
1368
+ $md52src_list[ $md5 ] = array( $src_data[ 'file' ], self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
1369
+ }
1370
+ $data_to_add[] = serialize( $md52src_list ) ;
1371
+ }
1372
+ // Add placeholder
1373
+ $q .= implode( ',', array_map(
1374
+ function( $el ) { return '(' . implode( ',', $el ) . ')' ; },
1375
+ array_chunk( array_fill( 0, count( $data_to_add ), '%s' ), 3 )
1376
+ ) ) ;
1377
+ // Store data
1378
+ $wpdb->query( $wpdb->prepare( $q, $data_to_add ) ) ;
1379
+
1380
+
1381
+ $accepted_groups = count( $pids ) ;
1382
+ $accepted_imgs = $json[ 'total' ] ;
1383
+
1384
+ $msg = sprintf( __( 'Pushed %1$s groups with %2$s images to LiteSpeed optimization server, accepted %3$s groups with %4$s images.', 'litespeed-cache' ), $total_groups, $this->_img_total, $accepted_groups, $accepted_imgs ) ;
1385
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1386
+
1387
+ // Update credit info
1388
+ if ( isset( $json[ 'credit' ] ) ) {
1389
+ $this->_update_credit( $json[ 'credit' ] ) ;
1390
+ }
1391
+ }
1392
+
1393
+ /**
1394
+ * Add a new img to queue which will be pushed to LiteSpeed
1395
+ *
1396
+ * @since 1.6
1397
+ * @access private
1398
+ */
1399
+ private function _img_queue( $meta_value, $ori_file = false )
1400
+ {
1401
+ if ( empty( $meta_value[ 'file' ] ) || empty( $meta_value[ 'width' ] ) || empty( $meta_value[ 'height' ] ) ) {
1402
+ LiteSpeed_Cache_Log::debug2( 'Media bypass image due to lack of file/w/h: pid ' . $this->tmp_pid, $meta_value ) ;
1403
+ return ;
1404
+ }
1405
+
1406
+ if ( ! $ori_file ) {
1407
+ $meta_value[ 'file' ] = $this->tmp_path . $meta_value[ 'file' ] ;
1408
+ }
1409
+
1410
+ // check file exists or not
1411
+ $real_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $meta_value[ 'file' ] ;
1412
+ if ( ! file_exists( $real_file ) ) {
1413
+ LiteSpeed_Cache_Log::debug2( 'Media bypass image due to file not exist: pid ' . $this->tmp_pid . ' ' . $real_file ) ;
1414
+ return ;
1415
+ }
1416
+
1417
+ LiteSpeed_Cache_Log::debug2( 'Media adding image: pid ' . $this->tmp_pid ) ;
1418
+
1419
+ $img_info = array(
1420
+ 'url' => $this->wp_upload_dir[ 'baseurl' ] . '/' . $meta_value[ 'file' ],
1421
+ 'file' => $meta_value[ 'file' ], // not needed in LiteSpeed sapi, just leave for local storage after post
1422
+ 'width' => $meta_value[ 'width' ],
1423
+ 'height' => $meta_value[ 'height' ],
1424
+ 'mime_type' => ! empty( $meta_value[ 'mime-type' ] ) ? $meta_value[ 'mime-type' ] : '' ,
1425
+ ) ;
1426
+ $md5 = md5_file( $real_file ) ;
1427
+
1428
+ if ( empty( $this->_img_in_queue[ $this->tmp_pid ] ) ) {
1429
+ $this->_img_in_queue[ $this->tmp_pid ] = array() ;
1430
+ }
1431
+ $this->_img_in_queue[ $this->tmp_pid ][ $md5 ] = $img_info ;
1432
+ $this->_img_total ++ ;
1433
+ }
1434
+
1435
+ /**
1436
+ * Update client credit info
1437
+ *
1438
+ * @since 1.6.5
1439
+ * @access private
1440
+ */
1441
+ private function _update_credit( $credit )
1442
+ {
1443
+ $summary = (array) get_option( self::DB_IMG_OPTM_SUMMARY ) ;
1444
+ $summary[ 'credit' ] = $credit ;
1445
+
1446
+ update_option( self::DB_IMG_OPTM_SUMMARY, $summary ) ;
1447
+ }
1448
+
1449
+ /**
1450
+ * Get optm summary
1451
+ *
1452
+ * @since 1.6.5
1453
+ * @access public
1454
+ */
1455
+ public function summary_info( $field = false )
1456
+ {
1457
+ $optm_summary = (array) get_option( self::DB_IMG_OPTM_SUMMARY ) ;
1458
+
1459
+ if ( ! $field ) {
1460
+ return $optm_summary ;
1461
+ }
1462
+ return ! empty( $optm_summary[ $field ] ) ? $optm_summary[ $field ] : 0 ;
1463
+ }
1464
+
1465
+ /**
1466
+ * Count images
1467
+ *
1468
+ * @since 1.6
1469
+ * @access public
1470
+ */
1471
+ public function img_count()
1472
+ {
1473
+ global $wpdb ;
1474
+ $q = "SELECT count(*)
1475
+ FROM $wpdb->posts a
1476
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1477
+ WHERE a.post_type = 'attachment'
1478
+ AND a.post_status = 'inherit'
1479
+ AND a.post_mime_type IN ('image/jpeg', 'image/png')
1480
+ AND b.meta_key = '_wp_attachment_metadata'
1481
+ " ;
1482
+ // $q = "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'inherit' AND post_mime_type IN ('image/jpeg', 'image/png') " ;
1483
+ $total_img = $wpdb->get_var( $q ) ;
1484
+
1485
+ $q = "SELECT count(*)
1486
+ FROM $wpdb->posts a
1487
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1488
+ LEFT JOIN $wpdb->postmeta c ON c.post_id = a.ID
1489
+ WHERE a.post_type = 'attachment'
1490
+ AND a.post_status = 'inherit'
1491
+ AND a.post_mime_type IN ('image/jpeg', 'image/png')
1492
+ AND b.meta_key = '_wp_attachment_metadata'
1493
+ AND c.meta_key = %s
1494
+ AND c.meta_value= %s
1495
+ " ;
1496
+ $total_requested = $wpdb->get_var( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ) ) ;
1497
+ $total_server_finished = $wpdb->get_var( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ) ) ;
1498
+ $total_pulled = $wpdb->get_var( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ) ;
1499
+ $total_err = $wpdb->get_var( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_STATUS_ERR ) ) ) ;
1500
+
1501
+ $q = "SELECT count(*)
1502
+ FROM $wpdb->posts a
1503
+ LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1504
+ LEFT JOIN $wpdb->postmeta c ON c.post_id = a.ID AND c.meta_key = %s
1505
+ WHERE a.post_type = 'attachment'
1506
+ AND a.post_status = 'inherit'
1507
+ AND a.post_mime_type IN ('image/jpeg', 'image/png')
1508
+ AND b.meta_key = '_wp_attachment_metadata'
1509
+ AND c.post_id IS NULL
1510
+ " ;
1511
+ $total_not_requested = $wpdb->get_var( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS ) ) ) ;
1512
+
1513
+ return array(
1514
+ 'total_img' => $total_img,
1515
+ 'total_not_requested' => $total_not_requested,
1516
+ 'total_requested' => $total_requested,
1517
+ 'total_err' => $total_err,
1518
+ 'total_server_finished' => $total_server_finished,
1519
+ 'total_pulled' => $total_pulled,
1520
+ ) ;
1521
  }
1522
 
1523
  /**
1530
  * @access public
1531
  * @return string The buffer
1532
  */
1533
+ public static function finalize( $content )
1534
  {
1535
  if ( defined( 'LITESPEED_NO_LAZY' ) ) {
1536
  LiteSpeed_Cache_Log::debug2( 'Media bypass: NO_LAZY const' ) ;
1542
  return $content ;
1543
  }
1544
 
1545
+ LiteSpeed_Cache_Log::debug( 'Media finalize' ) ;
1546
 
1547
  $instance = self::get_instance() ;
1548
  $instance->content = $content ;
1549
 
1550
+ $instance->_finalize() ;
1551
  return $instance->content ;
1552
  }
1553
 
1557
  * @since 1.4
1558
  * @access private
1559
  */
1560
+ private function _finalize()
1561
  {
1562
  $cfg_img_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY ) ;
1563
  $cfg_iframe_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY ) ;
1564
 
 
1565
  if ( $cfg_img_lazy ) {
1566
+ list( $src_list, $html_list ) = $this->_parse_img() ;
1567
  $html_list_ori = $html_list ;
1568
+ }
1569
+
1570
+ /**
1571
+ * Use webp for optimized images
1572
+ * @since 1.6.2
1573
+ */
1574
+ if ( $this->cfg_img_webp && $this->webp_support() ) {
1575
+ $this->_replace_buffer_img_webp() ;
1576
+ }
1577
+
1578
+ // image lazy load
1579
+ if ( $cfg_img_lazy ) {
1580
 
1581
  $placeholder = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY_PLACEHOLDER ) ?: LITESPEED_PLACEHOLDER ;
1582
 
1588
 
1589
  $html_list[ $k ] = $snippet ;
1590
  }
1591
+ }
1592
 
1593
+ if ( $cfg_img_lazy ) {
1594
  $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
1595
  }
1596
 
1636
  $excludes = explode( "\n", $excludes ) ;
1637
  }
1638
 
1639
+ $src_list = array() ;
1640
  $html_list = array() ;
1641
 
1642
  $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
1648
  continue ;
1649
  }
1650
 
1651
+ /**
1652
+ * Add src validation to bypass base64 img src
1653
+ * @since 1.6
1654
+ */
1655
+ if ( strpos( $attrs[ 'src' ], 'base64' ) !== false || substr( $attrs[ 'src' ], 0, 5 ) === 'data:' ) {
1656
+ LiteSpeed_Cache_Log::debug2( 'Media bypassed base64 img' ) ;
1657
+ continue ;
1658
+ }
1659
+
1660
  LiteSpeed_Cache_Log::debug2( 'Media: found: ' . $attrs[ 'src' ] ) ;
1661
 
1662
  if ( ! empty( $attrs[ 'data-no-lazy' ] ) || ! empty( $attrs[ 'data-lazyloaded' ] ) || ! empty( $attrs[ 'data-src' ] ) || ! empty( $attrs[ 'data-srcset' ] ) ) {
1678
  continue ;
1679
  }
1680
 
1681
+ $src_list[] = $attrs[ 'src' ] ;
1682
  $html_list[] = $match[ 0 ] ;
1683
  }
1684
 
1685
+ return array( $src_list, $html_list ) ;
1686
  }
1687
 
1688
  /**
1723
  return $html_list ;
1724
  }
1725
 
1726
+ /**
1727
+ * Replace image src to webp
1728
+ *
1729
+ * @since 1.6.2
1730
+ * @access private
1731
+ */
1732
+ private function _replace_buffer_img_webp()
1733
+ {
1734
+ preg_match_all( '#<img([^>]+?)src=([\'"\\\]*)([^\'"\s\\\>]+)([\'"\\\]*)([^>]*)>#i', $this->content, $matches ) ;
1735
+ foreach ( $matches[ 3 ] as $k => $url ) {
1736
+ // Check if is a DATA-URI
1737
+ if ( strpos( $url, 'data:image' ) !== false ) {
1738
+ continue ;
1739
+ }
1740
+
1741
+ if ( ! $url2 = $this->_replace_webp( $url ) ) {
1742
+ continue ;
1743
+ }
1744
+
1745
+ $html_snippet = sprintf(
1746
+ '<img %1$s src=%2$s %3$s>',
1747
+ $matches[ 1 ][ $k ],
1748
+ $matches[ 2 ][ $k ] . $url2 . $matches[ 4 ][ $k ],
1749
+ $matches[ 5 ][ $k ]
1750
+ ) ;
1751
+ $this->content = str_replace( $matches[ 0 ][ $k ], $html_snippet, $this->content ) ;
1752
+ }
1753
+ }
1754
+
1755
+ /**
1756
+ * Hook to wp_get_attachment_image_src
1757
+ *
1758
+ * @since 1.6.2
1759
+ * @access public
1760
+ * @param array $img The URL of the attachment image src, the width, the height
1761
+ * @return array
1762
+ */
1763
+ public function webp_attach_img_src( $img )
1764
+ {
1765
+ LiteSpeed_Cache_Log::debug2( 'Media changing attach src: ' . $img[0] ) ;
1766
+ if ( $img && $url = $this->_replace_webp( $img[ 0 ] ) ) {
1767
+ $img[ 0 ] = $url ;
1768
+ }
1769
+ return $img ;
1770
+ }
1771
+
1772
+ /**
1773
+ * Try to replace img url
1774
+ *
1775
+ * @since 1.6.2
1776
+ * @access public
1777
+ * @param string $url
1778
+ * @return string
1779
+ */
1780
+ public function webp_url( $url )
1781
+ {
1782
+ if ( $url && $url2 = $this->_replace_webp( $url ) ) {
1783
+ $url = $url2 ;
1784
+ }
1785
+ return $url ;
1786
+ }
1787
+
1788
+ /**
1789
+ * Hook to replace WP responsive images
1790
+ *
1791
+ * @since 1.6.2
1792
+ * @access public
1793
+ * @param array $srcs
1794
+ * @return array
1795
+ */
1796
+ public function webp_srcset( $srcs )
1797
+ {
1798
+ if ( $srcs ) {
1799
+ foreach ( $srcs as $w => $data ) {
1800
+ if( ! $url = $this->_replace_webp( $data[ 'url' ] ) ) {
1801
+ continue ;
1802
+ }
1803
+ $srcs[ $w ][ 'url' ] = $url ;
1804
+ }
1805
+ }
1806
+ return $srcs ;
1807
+ }
1808
+
1809
+ /**
1810
+ * Replace internal image src to webp
1811
+ *
1812
+ * @since 1.6.2
1813
+ * @access private
1814
+ */
1815
+ private function _replace_webp( $url )
1816
+ {
1817
+ LiteSpeed_Cache_Log::debug2( 'Media: webp replacing: ' . $url ) ;
1818
+ if ( LiteSpeed_Cache_Utility::is_internal_file( $url ) ) {
1819
+ // check if has webp file
1820
+ if ( LiteSpeed_Cache_Utility::is_internal_file( $url . '.webp' ) ) {
1821
+ $url .= '.webp' ;
1822
+ }
1823
+ else {
1824
+ LiteSpeed_Cache_Log::debug2( 'Media: no WebP file, bypassed' ) ;
1825
+ return false ;
1826
+ }
1827
+ }
1828
+ else {
1829
+ LiteSpeed_Cache_Log::debug2( 'Media: no file, bypassed' ) ;
1830
+ return false ;
1831
+ }
1832
+
1833
+ return $url ;
1834
+ }
1835
+
1836
  /**
1837
  * Get the current instance object.
1838
  *
inc/optimize.class.php CHANGED
@@ -32,6 +32,7 @@ class LiteSpeed_Cache_Optimize
32
  private $cfg_js_defer_exc = false ;
33
  private $cfg_qs_rm ;
34
  private $cfg_exc_jquery ;
 
35
 
36
 
37
  private $html_foot = '' ; // The html info append to <body>
@@ -64,6 +65,7 @@ class LiteSpeed_Cache_Optimize
64
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
65
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
66
  $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
 
67
 
68
  $this->_static_request_check() ;
69
 
@@ -97,6 +99,27 @@ class LiteSpeed_Cache_Optimize
97
  }
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
102
  /**
@@ -111,6 +134,13 @@ class LiteSpeed_Cache_Optimize
111
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
112
  remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
113
  remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
 
 
 
 
 
 
 
114
  }
115
 
116
  /**
@@ -141,7 +171,7 @@ class LiteSpeed_Cache_Optimize
141
  private function _static_request_check()
142
  {
143
  // This request is for js/css_async.js
144
- if ( $this->cfg_css_async && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
145
  LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
146
 
147
  LiteSpeed_Cache_Control::set_cacheable() ;
@@ -248,7 +278,7 @@ class LiteSpeed_Cache_Optimize
248
  * @access public
249
  * @return string The content that is after optimization
250
  */
251
- public static function run( $content )
252
  {
253
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
254
  return $content ;
@@ -269,6 +299,13 @@ class LiteSpeed_Cache_Optimize
269
  }
270
  }
271
 
 
 
 
 
 
 
 
272
  LiteSpeed_Cache_Log::debug( 'Optimizer start' ) ;
273
 
274
  $instance = self::get_instance() ;
@@ -295,7 +332,7 @@ class LiteSpeed_Cache_Optimize
295
 
296
  // Parse css from content
297
  $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
298
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async ) {
299
  // To remove google fonts
300
  if ( $ggfonts_rm ) {
301
  $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
@@ -312,6 +349,8 @@ class LiteSpeed_Cache_Optimize
312
 
313
  // IF combine
314
  if ( $this->cfg_css_combine ) {
 
 
315
  $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
316
 
317
  $snippet = '' ;
@@ -322,19 +361,30 @@ class LiteSpeed_Cache_Optimize
322
  // Handle css async load
323
  if ( $this->cfg_css_async ) {
324
  // Only ignored html snippet needs async
325
- list( $noscript, $ignored_html_async ) = $this->_async_css_list( $ignored_html ) ;
326
 
327
- $noscript .= $snippet ;
328
  $snippet = '' ;
329
  foreach ( $urls as $url ) {
330
  $snippet .= "<link rel='preload' data-asynced='1' data-optimized='2' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
331
  }
332
 
333
- $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
334
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
 
 
 
 
 
 
335
  }
336
  else {
337
- $this->html_head .= implode( '', $ignored_html ) . $snippet ;
 
 
 
 
 
 
338
  }
339
 
340
  // Move all css to top
@@ -363,16 +413,30 @@ class LiteSpeed_Cache_Optimize
363
  // Handle css lazy load if not handled async loaded yet
364
  if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
365
  // async html
366
- list( $noscript, $html_list_async ) = $this->_async_css_list( $html_list ) ;
367
-
368
- // add noscript
369
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
370
 
371
  // Replace async css
372
  $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
373
 
374
  }
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  // Parse js from buffer as needed
377
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
378
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
@@ -386,6 +450,8 @@ class LiteSpeed_Cache_Optimize
386
 
387
  // IF combine
388
  if ( $this->cfg_js_combine ) {
 
 
389
  // separate head/foot js/raw html
390
  $head_js = array() ;
391
  $head_ignored_html = array() ;
@@ -401,7 +467,7 @@ class LiteSpeed_Cache_Optimize
401
  }
402
  foreach ( $ignored_html as $src => $html ) {
403
  if ( in_array( $src, $head_src_list ) ) {
404
- $head_ignored_html[] = $html ;
405
  }
406
  else {
407
  $foot_ignored_html[] = $html ;
@@ -421,7 +487,27 @@ class LiteSpeed_Cache_Optimize
421
  if ( $this->cfg_js_defer ) {
422
  $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
423
  }
424
- $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
  $snippet = '' ;
427
  if ( $foot_js ) {
@@ -436,7 +522,14 @@ class LiteSpeed_Cache_Optimize
436
  if ( $this->cfg_js_defer ) {
437
  $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
438
  }
439
- $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
 
 
 
 
 
 
 
440
 
441
  // Will move all js to top/bottom
442
  $this->content = str_replace( $html_list, '', $this->content ) ;
@@ -467,16 +560,26 @@ class LiteSpeed_Cache_Optimize
467
 
468
 
469
  // Append async compatibility lib to head
470
- if ( $this->cfg_css_async ) {
471
  $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
472
  $this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
473
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
474
  }
475
 
 
 
 
 
476
  // Replace html head part
477
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
478
  if ( $this->html_head ) {
479
- $this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
 
 
 
 
 
 
480
  }
481
 
482
  // Replace html foot part
@@ -493,10 +596,10 @@ class LiteSpeed_Cache_Optimize
493
  try {
494
  litespeed_load_vendor() ;
495
  $this->content = Minify_HTML::minify( $this->content ) ;
496
- $this->content .= '<!-- Page optimized by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->' ;
497
 
498
  } catch ( ErrorException $e ) {
499
- LiteSpeed_Cache_Control::debug( 'Error when optimizing HTML: ' . $e->getMessage() ) ;
500
  error_log( 'LiteSpeed Optimizer optimizing HTML Error: ' . $e->getMessage() ) ;
501
  // If failed to minify HTML, restore original content
502
  $this->content = $ori ;
@@ -556,7 +659,6 @@ class LiteSpeed_Cache_Optimize
556
  */
557
  private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
558
  {
559
- $noscript = '' ;
560
  $html_list_ori = $html_list ;
561
 
562
  $tag = $file_type === 'css' ? 'link' : 'script' ;
@@ -573,8 +675,7 @@ class LiteSpeed_Cache_Optimize
573
 
574
  // Handle css async load
575
  if ( $file_type === 'css' && $this->cfg_css_async ) {
576
- list( $noscript, $html_list ) = $this->_async_css_list( $html_list ) ;
577
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
578
  }
579
 
580
  // Handle js defer
@@ -631,7 +732,7 @@ class LiteSpeed_Cache_Optimize
631
 
632
  // Check if is external URL
633
  $url_parsed = parse_url( $src ) ;
634
- if ( ! $file_info = $this->_is_file_url( $src ) ) {
635
  $ignored_html[ $src ] = $html_list[ $key ] ;
636
  LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist' ) ;
637
  continue ;
@@ -659,57 +760,6 @@ class LiteSpeed_Cache_Optimize
659
  return array( $ignored_html, $src_queue_list, $file_size_list ) ;
660
  }
661
 
662
- /**
663
- * Check if an URL is a internal existing file
664
- *
665
- * @since 1.2.2
666
- * @access private
667
- * @return string|bool The real path of file OR false
668
- */
669
- private function _is_file_url( $url )
670
- {
671
- $url_parsed = parse_url( $url ) ;
672
- if ( isset( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
673
- // Check if is cdn path
674
- if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
675
- return false ;
676
- }
677
- }
678
-
679
- if ( empty( $url_parsed[ 'path' ] ) ) {
680
- return false ;
681
- }
682
-
683
- // Need to replace child blog path for assets, ref: .htaccess
684
- if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
685
- $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
686
- $replacement = PATH_CURRENT_SITE . '$2' ;
687
- $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
688
- // $current_blog = (int) get_current_blog_id() ;
689
- // $main_blog_id = (int) get_network()->site_id ;
690
- // if ( $current_blog === $main_blog_id ) {
691
- // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
692
- // }
693
- // else {
694
- // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
695
- // }
696
- }
697
-
698
- // Parse file path
699
- if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
700
- $file_path = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
701
- }
702
- else {
703
- $file_path = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
704
- }
705
- $file_path = realpath( $file_path ) ;
706
- if ( ! is_file( $file_path ) ) {
707
- return false ;
708
- }
709
-
710
- return array( $file_path, filesize( $file_path ) ) ;
711
- }
712
-
713
  /**
714
  * Run minify process and return final content
715
  *
@@ -730,7 +780,7 @@ class LiteSpeed_Cache_Optimize
730
  // Parse real file path
731
  $real_files = array() ;
732
  foreach ( $urls as $url ) {
733
- $real_file = $this->_is_file_url( $url ) ;
734
  if ( ! $real_file ) {
735
  continue ;
736
  }
@@ -820,7 +870,10 @@ class LiteSpeed_Cache_Optimize
820
  }
821
  $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
822
 
823
- if ( ! empty( $attrs[ 'data-optimized' ] ) ) {
 
 
 
824
  continue ;
825
  }
826
  if ( empty( $attrs[ 'src' ] ) ) {
@@ -869,7 +922,7 @@ class LiteSpeed_Cache_Optimize
869
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
870
  continue ;
871
  }
872
- if ( ! empty( $attrs[ 'data-optimized' ] ) ) {
873
  continue ;
874
  }
875
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
@@ -908,11 +961,10 @@ class LiteSpeed_Cache_Optimize
908
  * @since 1.3
909
  * @access private
910
  * @param array $html_list Orignal css array
911
- * @return array array( (string)noscript, (array)css_async_list )
912
  */
913
  private function _async_css_list( $html_list )
914
  {
915
- $noscript = '' ;
916
  foreach ( $html_list as $k => $ori ) {
917
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
918
  LiteSpeed_Cache_Log::debug2( 'Optm bypass: attr data-asynced exist' ) ;
@@ -924,14 +976,14 @@ class LiteSpeed_Cache_Optimize
924
  continue ;
925
  }
926
 
927
- // Append to noscript content
928
- $noscript .= $ori ;
929
  // async replacement
930
  $v = str_replace( 'stylesheet', 'preload', $ori ) ;
931
  $v = str_replace( '<link', "<link data-asynced='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
 
 
932
  $html_list[ $k ] = $v ;
933
  }
934
- return array( $noscript, $html_list ) ;
935
  }
936
 
937
  /**
@@ -1030,7 +1082,19 @@ class LiteSpeed_Cache_Optimize
1030
  return ;
1031
  }
1032
 
1033
- $uri = LiteSpeed_Cache_Utility::url2uri( $url ) ;
 
 
 
 
 
 
 
 
 
 
 
 
1034
 
1035
  if ( ! $uri ) {
1036
  return ;
@@ -1081,7 +1145,7 @@ class LiteSpeed_Cache_Optimize
1081
  $content = $this->minify_minify->serve( $this->minify_controller, $this->minify_options ) ;
1082
 
1083
  } catch ( ErrorException $e ) {
1084
- LiteSpeed_Cache_Control::debug( 'Error when serving from optimizer: ' . $e->getMessage() ) ;
1085
  error_log( 'LiteSpeed Optimizer serving Error: ' . $e->getMessage() ) ;
1086
  return false ;
1087
  }
32
  private $cfg_js_defer_exc = false ;
33
  private $cfg_qs_rm ;
34
  private $cfg_exc_jquery ;
35
+ private $cfg_ggfonts_async ;
36
 
37
 
38
  private $html_foot = '' ; // The html info append to <body>
65
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
66
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
67
  $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
68
+ $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
69
 
70
  $this->_static_request_check() ;
71
 
99
  }
100
  }
101
 
102
+ /**
103
+ * Add vary filter for Role Excludes
104
+ * @since 1.6
105
+ */
106
+ add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
107
+
108
+ }
109
+
110
+ /**
111
+ * Exclude role from optimization filter
112
+ *
113
+ * @since 1.6
114
+ * @access public
115
+ */
116
+ public function vary_add_role_exclude( $varys )
117
+ {
118
+ if ( ! LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
119
+ return $varys ;
120
+ }
121
+ $varys[ 'role_exclude_optm' ] = 1 ;
122
+ return $varys ;
123
  }
124
 
125
  /**
134
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
135
  remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
136
  remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
137
+ /**
138
+ * Added for better result
139
+ * @since 1.6.2.1
140
+ */
141
+ remove_action( 'wp_print_styles', 'print_emoji_styles' ) ;
142
+ remove_action( 'admin_print_styles', 'print_emoji_styles' ) ;
143
+ remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ) ;
144
  }
145
 
146
  /**
171
  private function _static_request_check()
172
  {
173
  // This request is for js/css_async.js
174
+ if ( ( $this->cfg_css_async || $this->cfg_ggfonts_async ) && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
175
  LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
176
 
177
  LiteSpeed_Cache_Control::set_cacheable() ;
278
  * @access public
279
  * @return string The content that is after optimization
280
  */
281
+ public static function finalize( $content )
282
  {
283
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
284
  return $content ;
299
  }
300
  }
301
 
302
+ // Check if is exclude optm roles ( Need to set Vary too )
303
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
304
+ LiteSpeed_Cache_Log::debug( 'Optimizer bypass: hit Role Excludes setting: ' . $result ) ;
305
+ return $content ;
306
+ }
307
+
308
+
309
  LiteSpeed_Cache_Log::debug( 'Optimizer start' ) ;
310
 
311
  $instance = self::get_instance() ;
332
 
333
  // Parse css from content
334
  $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
335
+ if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
336
  // To remove google fonts
337
  if ( $ggfonts_rm ) {
338
  $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
349
 
350
  // IF combine
351
  if ( $this->cfg_css_combine ) {
352
+ $enqueue_first = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY ) ;
353
+
354
  $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
355
 
356
  $snippet = '' ;
361
  // Handle css async load
362
  if ( $this->cfg_css_async ) {
363
  // Only ignored html snippet needs async
364
+ $ignored_html_async = $this->_async_css_list( $ignored_html ) ;
365
 
 
366
  $snippet = '' ;
367
  foreach ( $urls as $url ) {
368
  $snippet .= "<link rel='preload' data-asynced='1' data-optimized='2' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
369
  }
370
 
371
+ // enqueue combined file first
372
+ if ( $enqueue_first ) {
373
+ $this->html_head .= $snippet . implode( '', $ignored_html_async ) ;
374
+ }
375
+ else {
376
+ $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
377
+ }
378
+
379
  }
380
  else {
381
+ // enqueue combined file first
382
+ if ( $enqueue_first ) {
383
+ $this->html_head .= $snippet . implode( '', $ignored_html ) ;
384
+ }
385
+ else {
386
+ $this->html_head .= implode( '', $ignored_html ) . $snippet ;
387
+ }
388
  }
389
 
390
  // Move all css to top
413
  // Handle css lazy load if not handled async loaded yet
414
  if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
415
  // async html
416
+ $html_list_async = $this->_async_css_list( $html_list ) ;
 
 
 
417
 
418
  // Replace async css
419
  $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
420
 
421
  }
422
 
423
+ // Handle google fonts async
424
+ if ( ! $this->cfg_css_async && $this->cfg_ggfonts_async ) {
425
+ foreach ( $html_list as $k => $v ) {
426
+ if ( strpos( $src_list[ $k ], 'fonts.googleapis.com' ) === false ) {
427
+ unset( $html_list[ $k ] ) ;
428
+ continue ;
429
+ }
430
+
431
+ LiteSpeed_Cache_Log::debug( 'Optm: google fonts async loading: ' . $src_list[ $k ] ) ;
432
+ }
433
+ // async html
434
+ $html_list_async = $this->_async_css_list( $html_list ) ;
435
+
436
+ // Replace async css
437
+ $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
438
+ }
439
+
440
  // Parse js from buffer as needed
441
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
442
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
450
 
451
  // IF combine
452
  if ( $this->cfg_js_combine ) {
453
+ $enqueue_first = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY ) ;
454
+
455
  // separate head/foot js/raw html
456
  $head_js = array() ;
457
  $head_ignored_html = array() ;
467
  }
468
  foreach ( $ignored_html as $src => $html ) {
469
  if ( in_array( $src, $head_src_list ) ) {
470
+ $head_ignored_html[ $src ] = $html ;
471
  }
472
  else {
473
  $foot_ignored_html[] = $html ;
487
  if ( $this->cfg_js_defer ) {
488
  $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
489
  }
490
+
491
+ /**
492
+ * Enqueue combined file first
493
+ * @since 1.6
494
+ */
495
+ if ( $enqueue_first ) {
496
+ // Make jQuery to be the first one
497
+ // Suppose jQuery is in header
498
+ foreach ( $head_ignored_html as $src => $html ) {
499
+ if ( $this->_is_jquery( $src ) ) {
500
+ // jQuery should be always the first one
501
+ $this->html_head .= $html ;
502
+ unset( $head_ignored_html[ $src ] ) ;
503
+ break ;
504
+ }
505
+ }
506
+ $this->html_head .= $snippet . implode( '', $head_ignored_html ) ;
507
+ }
508
+ else {
509
+ $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
510
+ }
511
 
512
  $snippet = '' ;
513
  if ( $foot_js ) {
522
  if ( $this->cfg_js_defer ) {
523
  $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
524
  }
525
+
526
+ // enqueue combined file first
527
+ if ( $enqueue_first ) {
528
+ $this->html_foot .= $snippet . implode( '', $foot_ignored_html ) ;
529
+ }
530
+ else {
531
+ $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
532
+ }
533
 
534
  // Will move all js to top/bottom
535
  $this->content = str_replace( $html_list, '', $this->content ) ;
560
 
561
 
562
  // Append async compatibility lib to head
563
+ if ( $this->cfg_css_async || $this->cfg_ggfonts_async ) {
564
  $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
565
  $this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
566
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
567
  }
568
 
569
+ if ( $this->cfg_ggfonts_async ) {
570
+ $this->html_head .= '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
571
+ }
572
+
573
  // Replace html head part
574
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
575
  if ( $this->html_head ) {
576
+ // Put header content to be after charset
577
+ if ( strpos( $this->content, '<meta charset' ) !== false ) {
578
+ $this->content = preg_replace( '#<meta charset([^>]*)>#isU', '<meta charset$1>' . $this->html_head , $this->content, 1 ) ;
579
+ }
580
+ else {
581
+ $this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
582
+ }
583
  }
584
 
585
  // Replace html foot part
596
  try {
597
  litespeed_load_vendor() ;
598
  $this->content = Minify_HTML::minify( $this->content ) ;
599
+ $this->content .= "\n" . '<!-- Page optimized by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->' ;
600
 
601
  } catch ( ErrorException $e ) {
602
+ LiteSpeed_Cache_Log::debug( 'Error when optimizing HTML: ' . $e->getMessage() ) ;
603
  error_log( 'LiteSpeed Optimizer optimizing HTML Error: ' . $e->getMessage() ) ;
604
  // If failed to minify HTML, restore original content
605
  $this->content = $ori ;
659
  */
660
  private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
661
  {
 
662
  $html_list_ori = $html_list ;
663
 
664
  $tag = $file_type === 'css' ? 'link' : 'script' ;
675
 
676
  // Handle css async load
677
  if ( $file_type === 'css' && $this->cfg_css_async ) {
678
+ $html_list = $this->_async_css_list( $html_list ) ;
 
679
  }
680
 
681
  // Handle js defer
732
 
733
  // Check if is external URL
734
  $url_parsed = parse_url( $src ) ;
735
+ if ( ! $file_info = LiteSpeed_Cache_Utility::is_internal_file( $src ) ) {
736
  $ignored_html[ $src ] = $html_list[ $key ] ;
737
  LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist' ) ;
738
  continue ;
760
  return array( $ignored_html, $src_queue_list, $file_size_list ) ;
761
  }
762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  /**
764
  * Run minify process and return final content
765
  *
780
  // Parse real file path
781
  $real_files = array() ;
782
  foreach ( $urls as $url ) {
783
+ $real_file = LiteSpeed_Cache_Utility::is_internal_file( $url ) ;
784
  if ( ! $real_file ) {
785
  continue ;
786
  }
870
  }
871
  $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
872
 
873
+ if ( isset( $attrs[ 'data-optimized' ] ) ) {
874
+ continue ;
875
+ }
876
+ if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
877
  continue ;
878
  }
879
  if ( empty( $attrs[ 'src' ] ) ) {
922
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
923
  continue ;
924
  }
925
+ if ( isset( $attrs[ 'data-optimized' ] ) ) {
926
  continue ;
927
  }
928
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
961
  * @since 1.3
962
  * @access private
963
  * @param array $html_list Orignal css array
964
+ * @return array (array)css_async_list
965
  */
966
  private function _async_css_list( $html_list )
967
  {
 
968
  foreach ( $html_list as $k => $ori ) {
969
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
970
  LiteSpeed_Cache_Log::debug2( 'Optm bypass: attr data-asynced exist' ) ;
976
  continue ;
977
  }
978
 
 
 
979
  // async replacement
980
  $v = str_replace( 'stylesheet', 'preload', $ori ) ;
981
  $v = str_replace( '<link', "<link data-asynced='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
982
+ // Append to noscript content
983
+ $v .= '<noscript>' . $ori . '</noscript>' ;
984
  $html_list[ $k ] = $v ;
985
  }
986
+ return $html_list ;
987
  }
988
 
989
  /**
1082
  return ;
1083
  }
1084
 
1085
+ /**
1086
+ * For CDN enabled ones, bypass http/2 push
1087
+ * @since 1.6.2.1
1088
+ */
1089
+ if ( LiteSpeed_Cache_CDN::inc_type( $file_type ) ) {
1090
+ return ;
1091
+ }
1092
+
1093
+ /**
1094
+ * Keep QS for constance by set 2nd param to true
1095
+ * @since 1.6.2.1
1096
+ */
1097
+ $uri = LiteSpeed_Cache_Utility::url2uri( $url, true ) ;
1098
 
1099
  if ( ! $uri ) {
1100
  return ;
1145
  $content = $this->minify_minify->serve( $this->minify_controller, $this->minify_options ) ;
1146
 
1147
  } catch ( ErrorException $e ) {
1148
+ LiteSpeed_Cache_Log::debug( 'Error when serving from optimizer: ' . $e->getMessage() ) ;
1149
  error_log( 'LiteSpeed Optimizer serving Error: ' . $e->getMessage() ) ;
1150
  return false ;
1151
  }
inc/purge.class.php CHANGED
@@ -36,6 +36,7 @@ class LiteSpeed_Cache_Purge
36
  }
37
 
38
  self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
 
39
 
40
  // Send purge header immediately
41
  $curr_built = self::_build() ;
@@ -66,6 +67,8 @@ class LiteSpeed_Cache_Purge
66
  return ;
67
  }
68
 
 
 
69
  self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
70
 
71
  // Send purge header immediately
@@ -169,11 +172,13 @@ class LiteSpeed_Cache_Purge
169
  public static function purge_errors()
170
  {
171
  self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
172
- if ( ! isset( $_GET[ 'lserr' ] ) || ! in_array( $_GET[ 'lserr' ], array( '403', '404', '500' ) ) ) {
 
 
173
  return ;
174
  }
175
 
176
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $_GET[ 'lserr' ] ) ;
177
  }
178
 
179
  /**
36
  }
37
 
38
  self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
39
+ LiteSpeed_Cache_Log::debug( 'Purge: added ' . implode( ',', $tags ), 3 ) ;
40
 
41
  // Send purge header immediately
42
  $curr_built = self::_build() ;
67
  return ;
68
  }
69
 
70
+ LiteSpeed_Cache_Log::debug( 'Purge: added [private] ' . implode( ',', $tags ), 3 ) ;
71
+
72
  self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
73
 
74
  // Send purge header immediately
172
  public static function purge_errors()
173
  {
174
  self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
175
+
176
+ $type = LiteSpeed_Cache_Router::verify_type() ;
177
+ if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
178
  return ;
179
  }
180
 
181
+ self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
182
  }
183
 
184
  /**
inc/router.class.php CHANGED
@@ -21,10 +21,64 @@ class LiteSpeed_Cache_Router
21
  private static $_ip ;
22
  private static $_action ;
23
  private static $_is_admin_ip ;
24
- private static $_has_whm_msg ;
25
- private static $_has_msg_ruleconflict ;
26
  private static $_frontend_path ;
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Get frontend path
30
  *
@@ -64,71 +118,6 @@ class LiteSpeed_Cache_Router
64
  return self::$_esi_enabled ;
65
  }
66
 
67
- /**
68
- * Check if has rule conflict notice
69
- *
70
- * @since 1.1.5
71
- * @access public
72
- * @return boolean
73
- */
74
- public static function has_msg_ruleconflict()
75
- {
76
- if ( ! isset( self::$_has_msg_ruleconflict ) ) {
77
- self::$_has_msg_ruleconflict = get_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG ) == LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ;
78
- }
79
- return self::$_has_msg_ruleconflict ;
80
- }
81
-
82
- /**
83
- * Check if has whm notice
84
- *
85
- * @since 1.1.1
86
- * @access public
87
- * @return boolean
88
- */
89
- public static function has_whm_msg()
90
- {
91
- if ( ! isset( self::$_has_whm_msg ) ) {
92
- self::$_has_whm_msg = get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
93
- }
94
- return self::$_has_whm_msg ;
95
- }
96
-
97
- /**
98
- * Check if has promotion notice
99
- *
100
- * @since 1.3.2
101
- * @access public
102
- * @return boolean
103
- */
104
- public static function has_promo_msg()
105
- {
106
- $promo = get_option( 'litespeed-banner-promo' ) ;
107
- if ( ! $promo ) {
108
- update_option( 'litespeed-banner-promo', time() - 86400 * 8 ) ;
109
- return false ;
110
- }
111
- if ( $promo == 'done' ) {
112
- return false ;
113
- }
114
- if ( $promo && time() - $promo < 864000 ) {
115
- return false ;
116
- }
117
- return true ;
118
- }
119
-
120
- /**
121
- * update promotion notice
122
- *
123
- * @since 1.3.2
124
- * @access public
125
- * @return boolean
126
- */
127
- public static function dismiss_promo_msg()
128
- {
129
- update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
130
- }
131
-
132
  /**
133
  * Check if crawler is enabled on server level
134
  *
@@ -218,6 +207,35 @@ class LiteSpeed_Cache_Router
218
  return self::$_is_admin_ip ;
219
  }
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  /**
222
  * Check privilege and nonce for the action
223
  *
@@ -226,16 +244,17 @@ class LiteSpeed_Cache_Router
226
  */
227
  private function verify_action()
228
  {
229
- if( empty( $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ) ) {
 
230
  return ;
231
  }
232
 
233
- $action = $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ;
234
  $_is_public_action = false ;
235
 
236
  // Each action must have a valid nonce unless its from admin ip and is public action
237
  // Validate requests nonce (from admin logged in page or cli)
238
- if ( ! $this->verify_nonce( $action ) && ! $this->_verify_sapi_token( $action ) ) {
239
  // check if it is from admin ip
240
  if ( ! $this->is_admin_ip() ) {
241
  LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
@@ -323,19 +342,30 @@ class LiteSpeed_Cache_Router
323
  case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
324
  case LiteSpeed_Cache::ACTION_DO_CRAWL:
325
  case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
326
- case LiteSpeed_Cache::ACTION_SAPI_PROCEED:
327
  if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
328
  self::$_action = $action ;
329
  }
330
  return ;
331
 
332
- case LiteSpeed_Cache::ACTION_SAPI_CALLBACK : // as long as it passed nonce check
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  self::$_action = $action ;
334
  return ;
335
 
336
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:
337
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
338
- case LiteSpeed_Cache::ACTION_DISMISS_PROMO:
339
  if ( self::is_ajax() ) {
340
  self::$_action = $action ;
341
  }
@@ -349,16 +379,43 @@ class LiteSpeed_Cache_Router
349
  }
350
 
351
  /**
352
- * Verify sapi token
353
  *
354
  * @since 1.5
355
  * @access private
356
  * @param string $action
357
  * @return bool
358
  */
359
- private function _verify_sapi_token( $action )
360
  {
361
- return LiteSpeed_Cache_Admin_API::sapi_token_check() && $action === LiteSpeed_Cache::ACTION_SAPI_CALLBACK ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  }
363
 
364
  /**
@@ -412,10 +469,11 @@ class LiteSpeed_Cache_Router
412
  * Get client ip
413
  *
414
  * @since 1.1.0
415
- * @access private
 
416
  * @return string
417
  */
418
- private function get_ip()
419
  {
420
  $_ip = '' ;
421
  if ( function_exists( 'apache_request_headers' ) ) {
21
  private static $_ip ;
22
  private static $_action ;
23
  private static $_is_admin_ip ;
 
 
24
  private static $_frontend_path ;
25
 
26
+ /**
27
+ * Get user id
28
+ *
29
+ * @since 1.6.2
30
+ */
31
+ public static function get_uid()
32
+ {
33
+ if ( defined( 'LITESPEED_WP_UID' ) ) {
34
+ return LITESPEED_WP_UID ;
35
+ }
36
+
37
+ $user = wp_get_current_user() ;
38
+ $user_id = $user->ID ;
39
+
40
+ LiteSpeed_Cache_Log::debug( 'Router: get_uid: ' . $user_id, 3 ) ;
41
+
42
+ define( 'LITESPEED_WP_UID', $user_id ) ;
43
+
44
+ return LITESPEED_WP_UID ;
45
+ }
46
+
47
+ /**
48
+ * Get user role
49
+ *
50
+ * @since 1.6.2
51
+ */
52
+ public static function get_role( $uid = null )
53
+ {
54
+ if ( defined( 'LITESPEED_WP_ROLE' ) ) {
55
+ return LITESPEED_WP_ROLE ;
56
+ }
57
+
58
+ if ( $uid === null ) {
59
+ $uid = self::get_uid() ;
60
+ }
61
+
62
+ $role = false ;
63
+ if ( $uid ) {
64
+ $user = get_userdata( $uid ) ;
65
+ if ( is_array( $user->roles ) ) {
66
+ $tmp = array_values( $user->roles ) ;
67
+ $role = array_shift( $tmp ) ;
68
+ }
69
+ }
70
+ LiteSpeed_Cache_Log::debug( 'Router: get_role: ' . $role ) ;
71
+
72
+ if ( ! $role ) {
73
+ // Guest user
74
+ LiteSpeed_Cache_Log::debug( 'Router: role: guest' ) ;
75
+ }
76
+
77
+ define( 'LITESPEED_WP_ROLE', $role ) ;
78
+
79
+ return LITESPEED_WP_ROLE ;
80
+ }
81
+
82
  /**
83
  * Get frontend path
84
  *
118
  return self::$_esi_enabled ;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Check if crawler is enabled on server level
123
  *
207
  return self::$_is_admin_ip ;
208
  }
209
 
210
+ /**
211
+ * Create type value for url
212
+ *
213
+ * @since 1.6
214
+ * @access public
215
+ */
216
+ public static function build_type( $val )
217
+ {
218
+ return array( 'type' => $val ) ;
219
+ }
220
+
221
+ /**
222
+ * Get type value
223
+ *
224
+ * @since 1.6
225
+ * @access public
226
+ */
227
+ public static function verify_type()
228
+ {
229
+ if ( empty( $_REQUEST[ 'type' ] ) ) {
230
+ LiteSpeed_Cache_Log::debug( 'Router no type', 2 ) ;
231
+ return false ;
232
+ }
233
+
234
+ LiteSpeed_Cache_Log::debug( 'Router parsed type: ' . $_REQUEST[ 'type' ], 2 ) ;
235
+
236
+ return $_REQUEST[ 'type' ] ;
237
+ }
238
+
239
  /**
240
  * Check privilege and nonce for the action
241
  *
244
  */
245
  private function verify_action()
246
  {
247
+ if ( empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
248
+ LiteSpeed_Cache_Log::debug2( 'LSCWP_CTRL bypassed empty' ) ;
249
  return ;
250
  }
251
 
252
+ $action = $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ;
253
  $_is_public_action = false ;
254
 
255
  // Each action must have a valid nonce unless its from admin ip and is public action
256
  // Validate requests nonce (from admin logged in page or cli)
257
+ if ( ! $this->verify_nonce( $action ) && ! $this->_verify_sapi_passive( $action ) && ! $this->_verify_sapi_aggressive( $action ) ) {
258
  // check if it is from admin ip
259
  if ( ! $this->is_admin_ip() ) {
260
  LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
342
  case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
343
  case LiteSpeed_Cache::ACTION_DO_CRAWL:
344
  case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
345
+ case LiteSpeed_Cache::ACTION_MEDIA:
346
  if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
347
  self::$_action = $action ;
348
  }
349
  return ;
350
 
351
+ case LiteSpeed_Cache::ACTION_LOG:
352
+ if ( $_can_network_option || $_can_option ) {
353
+ self::$_action = $action ;
354
+ }
355
+ return ;
356
+
357
+ case LiteSpeed_Cache::ACTION_REPORT:
358
+ if ( $_can_option && ! $_is_network_admin ) {
359
+ self::$_action = $action ;
360
+ }
361
+ return ;
362
+
363
+ case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK :
364
+ case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK :
365
  self::$_action = $action ;
366
  return ;
367
 
368
+ case LiteSpeed_Cache::ACTION_DISMISS:
 
 
369
  if ( self::is_ajax() ) {
370
  self::$_action = $action ;
371
  }
379
  }
380
 
381
  /**
382
+ * Verify sapi passive callback
383
  *
384
  * @since 1.5
385
  * @access private
386
  * @param string $action
387
  * @return bool
388
  */
389
+ private function _verify_sapi_passive( $action )
390
  {
391
+ if ( $action === LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK ) {
392
+ if ( LiteSpeed_Cache_Admin_API::sapi_valiate_passive_callback() ) {
393
+ return true ;
394
+ }
395
+ exit( 'wrong passive callback' ) ;
396
+ }
397
+
398
+ return false ;
399
+ }
400
+
401
+ /**
402
+ * Verify sapi aggressive callback
403
+ *
404
+ * @since 1.6
405
+ * @access private
406
+ * @param string $action
407
+ * @return bool
408
+ */
409
+ private function _verify_sapi_aggressive( $action )
410
+ {
411
+ if ( $action === LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK ) {
412
+ if ( LiteSpeed_Cache_Admin_API::sapi_validate_aggressive_callback() ) {
413
+ return true ;
414
+ }
415
+
416
+ exit( 'wrong aggressive callback' ) ;
417
+ }
418
+ return false ;
419
  }
420
 
421
  /**
469
  * Get client ip
470
  *
471
  * @since 1.1.0
472
+ * @since 1.6.5 changed to public
473
+ * @access public
474
  * @return string
475
  */
476
+ public static function get_ip()
477
  {
478
  $_ip = '' ;
479
  if ( function_exists( 'apache_request_headers' ) ) {
inc/tag.class.php CHANGED
@@ -151,6 +151,22 @@ class LiteSpeed_Cache_Tag
151
  self::$_tags = array_merge( self::$_tags, $tags ) ;
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  /**
155
  * Return tags for Admin QS
156
  *
151
  self::$_tags = array_merge( self::$_tags, $tags ) ;
152
  }
153
 
154
+ /**
155
+ * Adds private cache tags to the list of cache tags for the current page.
156
+ *
157
+ * @since 1.6.3
158
+ * @access public
159
+ * @param mixed $tags A string or array of cache tags to add to the current list.
160
+ */
161
+ public static function add_private( $tags )
162
+ {
163
+ if ( ! is_array( $tags ) ) {
164
+ $tags = array( $tags ) ;
165
+ }
166
+
167
+ self::$_tags_priv = array_merge( self::$_tags_priv, $tags ) ;
168
+ }
169
+
170
  /**
171
  * Return tags for Admin QS
172
  *
inc/task.class.php CHANGED
@@ -11,8 +11,42 @@
11
  */
12
  class LiteSpeed_Cache_Task
13
  {
14
- const CRON_ACTION_HOOK = 'litespeed_crawl_trigger' ;
15
- const CRON_FITLER = 'litespeed_crawl_filter' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  /**
18
  * Enable/Disable cron task
@@ -66,32 +100,64 @@ class LiteSpeed_Cache_Task
66
  }
67
  }
68
 
69
- if ( $is_active ) {
70
- self::schedule_filter() ;
71
- }
72
- else {
73
  self::clear() ;
74
  }
75
 
76
  }
77
 
78
  /**
79
- * Schedule cron
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  *
81
  * @since 1.1.0
82
  * @access public
83
  */
84
- public static function schedule_filter()
85
  {
86
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
87
 
88
  // Schedule event here to see if it can lost again or not
89
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK ) ) {
90
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
91
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK ) ;
92
  }
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Register cron interval
97
  *
@@ -99,17 +165,17 @@ class LiteSpeed_Cache_Task
99
  * @access public
100
  * @param array $schedules WP Hook
101
  */
102
- public static function lscache_cron_filter( $schedules )
103
  {
104
  $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
105
  // $wp_schedules = wp_get_schedules() ;
106
- if ( ! array_key_exists( self::CRON_FITLER, $schedules ) ) {
107
  // if ( LiteSpeed_Cache_Log::get_enabled() ) {
108
  // LiteSpeed_Cache_Log::push('Crawler cron log: ......cron filter '.$interval.' added......') ;
109
  // }
110
- $schedules[self::CRON_FITLER] = array(
111
  'interval' => $interval,
112
- 'display' => __( 'LiteSpeed Cache Custom Cron', 'litespeed-cache' ),
113
  ) ;
114
  }
115
  return $schedules ;
@@ -124,6 +190,24 @@ class LiteSpeed_Cache_Task
124
  public static function clear()
125
  {
126
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
127
- wp_clear_scheduled_hook( self::CRON_ACTION_HOOK ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
 
129
  }
11
  */
12
  class LiteSpeed_Cache_Task
13
  {
14
+ private static $_instance ;
15
+
16
+ const CRON_ACTION_HOOK_CRAWLER = 'litespeed_crawl_trigger' ;
17
+ const CRON_ACTION_HOOK_IMGOPTM = 'litespeed_imgoptm_trigger' ;
18
+ const CRON_FITLER_CRAWLER = 'litespeed_crawl_filter' ;
19
+ const CRON_FITLER_IMGOPTM = 'litespeed_imgoptm_filter' ;
20
+
21
+ /**
22
+ * Init
23
+ *
24
+ * @since 1.6
25
+ * @access private
26
+ */
27
+ private function __construct()
28
+ {
29
+ LiteSpeed_Cache_Log::debug2( 'Task init' ) ;
30
+
31
+ // Register crawler cron
32
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
33
+ // keep cron intval filter
34
+ self::schedule_filter_crawler() ;
35
+
36
+ // cron hook
37
+ add_action( self::CRON_ACTION_HOOK_CRAWLER, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
38
+ }
39
+
40
+ // Register img optimization fetch ( always fetch immediately )
41
+ if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF ) && LiteSpeed_Cache_Media::check_need_pull() ) {
42
+ self::schedule_filter_imgoptm() ;
43
+
44
+ add_action( self::CRON_ACTION_HOOK_IMGOPTM, 'LiteSpeed_Cache_Media::pull_optimized_img' ) ;
45
+ }
46
+ else {
47
+ // wp_clear_scheduled_hook( self::CRON_ACTION_HOOK_IMGOPTM ) ;
48
+ }
49
+ }
50
 
51
  /**
52
  * Enable/Disable cron task
100
  }
101
  }
102
 
103
+ if ( ! $is_active ) {
 
 
 
104
  self::clear() ;
105
  }
106
 
107
  }
108
 
109
  /**
110
+ * Schedule cron img optimization
111
+ *
112
+ * @since 1.6.1
113
+ * @access public
114
+ */
115
+ public static function schedule_filter_imgoptm()
116
+ {
117
+ add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter_imgoptm' ) ;
118
+
119
+ // Schedule event here to see if it can lost again or not
120
+ if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_IMGOPTM ) ) {
121
+ LiteSpeed_Cache_Log::debug( 'Cron log: ......img optimization cron hook register......' ) ;
122
+ wp_schedule_event( time(), self::CRON_FITLER_IMGOPTM, self::CRON_ACTION_HOOK_IMGOPTM ) ;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Schedule cron crawler
128
  *
129
  * @since 1.1.0
130
  * @access public
131
  */
132
+ public static function schedule_filter_crawler()
133
  {
134
+ add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter_crawler' ) ;
135
 
136
  // Schedule event here to see if it can lost again or not
137
+ if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_CRAWLER ) ) {
138
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
139
+ wp_schedule_event( time(), self::CRON_FITLER_CRAWLER, self::CRON_ACTION_HOOK_CRAWLER ) ;
140
  }
141
  }
142
 
143
+ /**
144
+ * Register cron interval imgoptm
145
+ *
146
+ * @since 1.6.1
147
+ * @access public
148
+ * @param array $schedules WP Hook
149
+ */
150
+ public static function lscache_cron_filter_imgoptm( $schedules )
151
+ {
152
+ if ( ! array_key_exists( self::CRON_FITLER_IMGOPTM, $schedules ) ) {
153
+ $schedules[ self::CRON_FITLER_IMGOPTM ] = array(
154
+ 'interval' => 60,
155
+ 'display' => __( 'LiteSpeed Cache Custom Cron ImgOptm', 'litespeed-cache' ),
156
+ ) ;
157
+ }
158
+ return $schedules ;
159
+ }
160
+
161
  /**
162
  * Register cron interval
163
  *
165
  * @access public
166
  * @param array $schedules WP Hook
167
  */
168
+ public static function lscache_cron_filter_crawler( $schedules )
169
  {
170
  $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
171
  // $wp_schedules = wp_get_schedules() ;
172
+ if ( ! array_key_exists( self::CRON_FITLER_CRAWLER, $schedules ) ) {
173
  // if ( LiteSpeed_Cache_Log::get_enabled() ) {
174
  // LiteSpeed_Cache_Log::push('Crawler cron log: ......cron filter '.$interval.' added......') ;
175
  // }
176
+ $schedules[ self::CRON_FITLER_CRAWLER ] = array(
177
  'interval' => $interval,
178
+ 'display' => __( 'LiteSpeed Cache Custom Cron Crawler', 'litespeed-cache' ),
179
  ) ;
180
  }
181
  return $schedules ;
190
  public static function clear()
191
  {
192
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
193
+ wp_clear_scheduled_hook( self::CRON_ACTION_HOOK_CRAWLER ) ;
194
+ }
195
+
196
+
197
+ /**
198
+ * Get the current instance object.
199
+ *
200
+ * @since 1.6
201
+ * @access public
202
+ * @return Current class instance.
203
+ */
204
+ public static function get_instance()
205
+ {
206
+ if ( ! isset( self::$_instance ) ) {
207
+ self::$_instance = new self() ;
208
+ }
209
+
210
+ return self::$_instance ;
211
  }
212
+
213
  }
inc/utility.class.php CHANGED
@@ -11,6 +11,101 @@
11
  */
12
  class LiteSpeed_Cache_Utility
13
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * Parse attributes from string
16
  *
@@ -23,7 +118,7 @@ class LiteSpeed_Cache_Utility
23
  public static function parse_attr( $str )
24
  {
25
  $attrs = array() ;
26
- preg_match_all( '#(\w+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
27
  foreach ( $matches as $match ) {
28
  $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
29
  }
@@ -129,13 +224,20 @@ class LiteSpeed_Cache_Utility
129
  * Convert URL to URI
130
  *
131
  * @since 1.2.2
 
132
  * @access public
133
  */
134
- public static function url2uri( $url )
135
  {
136
  $url = trim( $url ) ;
137
  $uri = @parse_url( $url, PHP_URL_PATH ) ;
138
- return $uri ;
 
 
 
 
 
 
139
  }
140
 
141
  /**
@@ -213,17 +315,18 @@ class LiteSpeed_Cache_Utility
213
  *
214
  * Assumes user capabilities are already checked.
215
  *
 
216
  * @access public
217
  * @param string $action The LSCWP_CTRL action to do in the url.
218
- * @param string $ajax_action AJAX call's action
219
- * @param string $append_str The appending string to url
220
  * @return string The built url.
221
  */
222
- public static function build_url( $action, $ajax_action = false, $append_str = false, $page = null )
223
  {
224
  $prefix = '?' ;
225
 
226
- if ( $ajax_action === false ) {
227
  if ( $page ) {
228
  // If use admin url
229
  if ( $page === true ) {
@@ -256,7 +359,7 @@ class LiteSpeed_Cache_Utility
256
  }
257
  }
258
  else {
259
- $combined = 'admin-ajax.php?action=' . $ajax_action . '&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
260
  }
261
 
262
  if ( is_network_admin() ) {
@@ -267,12 +370,93 @@ class LiteSpeed_Cache_Utility
267
  }
268
  $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
269
 
270
- if ( $append_str ) {
271
- $url .= '&' . $append_str ;
 
 
 
 
 
 
272
  }
273
 
274
  return $url ;
275
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  }
277
 
278
 
11
  */
12
  class LiteSpeed_Cache_Utility
13
  {
14
+
15
+ /**
16
+ * Set seconds/timestamp to readable format
17
+ *
18
+ * @since 1.6.5
19
+ * @access public
20
+ */
21
+ public static function readable_time( $seconds_or_timestamp, $timeout = 3600 )
22
+ {
23
+
24
+ if ( strlen( $seconds_or_timestamp ) == 10 ) {
25
+ $seconds = time() - $seconds_or_timestamp ;
26
+ if ( $seconds > $timeout ) {
27
+ return date( 'm/d/Y H:i:s', $seconds_or_timestamp + LITESPEED_TIME_OFFSET ) ;
28
+ }
29
+ }
30
+ else {
31
+ $seconds = $seconds_or_timestamp ;
32
+ }
33
+
34
+ $res = '';
35
+ if ( $seconds > 86400 ) {
36
+ $num = floor( $seconds / 86400 ) ;
37
+ $res .= $num . 'd ' ;
38
+ $seconds %= 86400 ;
39
+ }
40
+
41
+ if ( $seconds > 3600 ) {
42
+ if ( $res ) {
43
+ $res .= ', ' ;
44
+ }
45
+ $num = floor( $seconds / 3600 ) ;
46
+ $res .= $num . 'h ' ;
47
+ $seconds %= 3600 ;
48
+ }
49
+
50
+ if ( $seconds > 60 ) {
51
+ if ( $res ) {
52
+ $res .= ', ' ;
53
+ }
54
+ $num = floor( $seconds / 60 ) ;
55
+ $res .= $num . 'm ' ;
56
+ $seconds %= 60 ;
57
+ }
58
+
59
+ if ( $seconds > 0 ) {
60
+ $res .= $seconds . 's ' ;
61
+ }
62
+
63
+ $res = sprintf( __( ' %s ago ', 'litespeed-cache' ), $res ) ;
64
+
65
+ return $res ;
66
+ }
67
+
68
+
69
+ /**
70
+ * Convert array to string
71
+ *
72
+ * @since 1.6
73
+ * @access public
74
+ * @return string
75
+ */
76
+ public static function arr2str( $arr )
77
+ {
78
+ if ( ! is_array( $arr ) ) {
79
+ return $arr ;
80
+ }
81
+
82
+ return base64_encode( serialize( $arr ) ) ;
83
+ }
84
+
85
+ /**
86
+ * Get human readable size
87
+ *
88
+ * @since 1.6
89
+ * @access public
90
+ * @return string
91
+ */
92
+ public static function real_size( $filesize )
93
+ {
94
+ if ( $filesize >= 1073741824 ) {
95
+ $filesize = round( $filesize / 1073741824 * 100 ) / 100 . 'G' ;
96
+ }
97
+ elseif ( $filesize >= 1048576 ) {
98
+ $filesize = round( $filesize / 1048576 * 100 ) / 100 . 'M' ;
99
+ }
100
+ elseif ( $filesize >= 1024 ) {
101
+ $filesize = round( $filesize / 1024 * 100 ) / 100 . 'K' ;
102
+ }
103
+ else {
104
+ $filesize = $filesize . 'B' ;
105
+ }
106
+ return $filesize ;
107
+ }
108
+
109
  /**
110
  * Parse attributes from string
111
  *
118
  public static function parse_attr( $str )
119
  {
120
  $attrs = array() ;
121
+ preg_match_all( '#([\w-]+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
122
  foreach ( $matches as $match ) {
123
  $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
124
  }
224
  * Convert URL to URI
225
  *
226
  * @since 1.2.2
227
+ * @since 1.6.2.1 Added 2nd param keep_qs
228
  * @access public
229
  */
230
+ public static function url2uri( $url, $keep_qs = false )
231
  {
232
  $url = trim( $url ) ;
233
  $uri = @parse_url( $url, PHP_URL_PATH ) ;
234
+ $qs = @parse_url( $url, PHP_URL_QUERY ) ;
235
+
236
+ if ( ! $keep_qs || ! $qs ) {
237
+ return $uri ;
238
+ }
239
+
240
+ return $uri . '?' . $qs ;
241
  }
242
 
243
  /**
315
  *
316
  * Assumes user capabilities are already checked.
317
  *
318
+ * @since 1.6 Changed order of 2nd&3rd param, changed 3rd param `append_str` to 2nd `type`
319
  * @access public
320
  * @param string $action The LSCWP_CTRL action to do in the url.
321
+ * @param string $is_ajax if is AJAX call or not
322
+ * @param string $type The appending type to url
323
  * @return string The built url.
324
  */
325
+ public static function build_url( $action, $type = false, $is_ajax = false, $page = null )
326
  {
327
  $prefix = '?' ;
328
 
329
+ if ( ! $is_ajax ) {
330
  if ( $page ) {
331
  // If use admin url
332
  if ( $page === true ) {
359
  }
360
  }
361
  else {
362
+ $combined = 'admin-ajax.php?action=litespeed_ajax&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
363
  }
364
 
365
  if ( is_network_admin() ) {
370
  }
371
  $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
372
 
373
+ if ( $type ) {
374
+ // Remove potential param `type` from url
375
+ $url = parse_url( htmlspecialchars_decode( $url ) ) ;
376
+ parse_str( $url[ 'query' ], $query ) ;
377
+ $url[ 'query' ] = http_build_query( array_merge( $query, LiteSpeed_Cache_Router::build_type( $type ) ) ) ;
378
+ self::compatibility() ;
379
+ $url = http_build_url( $url ) ;
380
+ $url = htmlspecialchars( $url ) ;
381
  }
382
 
383
  return $url ;
384
  }
385
+
386
+ /**
387
+ * Check if an URL is a internal existing file
388
+ *
389
+ * @since 1.2.2
390
+ * @since 1.6.2 Moved here from optm.cls due to usage of media.cls
391
+ * @access public
392
+ * @return string|bool The real path of file OR false
393
+ */
394
+ public static function is_internal_file( $url )
395
+ {
396
+ $url_parsed = parse_url( $url ) ;
397
+ if ( isset( $url_parsed[ 'host' ] ) && ! self::internal( $url_parsed[ 'host' ] ) ) {
398
+ // Check if is cdn path
399
+ // Do this to avoid user hardcoded src in tpl
400
+ if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
401
+ LiteSpeed_Cache_Log::debug2( 'Utility: external' ) ;
402
+ return false ;
403
+ }
404
+ }
405
+
406
+ if ( empty( $url_parsed[ 'path' ] ) ) {
407
+ return false ;
408
+ }
409
+
410
+ // Need to replace child blog path for assets, ref: .htaccess
411
+ if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
412
+ $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
413
+ $replacement = PATH_CURRENT_SITE . '$2' ;
414
+ $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
415
+ // $current_blog = (int) get_current_blog_id() ;
416
+ // $main_blog_id = (int) get_network()->site_id ;
417
+ // if ( $current_blog === $main_blog_id ) {
418
+ // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
419
+ // }
420
+ // else {
421
+ // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
422
+ // }
423
+ }
424
+
425
+ // Parse file path
426
+ /**
427
+ * Trying to fix pure /.htaccess rewrite to /wordpress case
428
+ *
429
+ * Add `define( 'LITESPEED_WP_REALPATH', '/wordpress' ) ;` in wp-config.php in this case
430
+ *
431
+ * @internal #611001 - Combine & Minify not working?
432
+ * @since 1.6.3
433
+ */
434
+ if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
435
+ if ( defined( 'LITESPEED_WP_REALPATH' ) ) {
436
+ $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . LITESPEED_WP_REALPATH . $url_parsed[ 'path' ] ;
437
+ }
438
+ else {
439
+ $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
440
+ }
441
+ }
442
+ else {
443
+ $file_path_ori = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
444
+ }
445
+
446
+ $file_path = realpath( $file_path_ori ) ;
447
+ if ( ! is_file( $file_path ) ) {
448
+ LiteSpeed_Cache_Log::debug2( 'Utility: file not exist: ' . $file_path_ori ) ;
449
+ return false ;
450
+ }
451
+
452
+ return array( $file_path, filesize( $file_path ) ) ;
453
+ }
454
+
455
+
456
+
457
+
458
+
459
+
460
  }
461
 
462
 
inc/vary.class.php CHANGED
@@ -28,9 +28,6 @@ class LiteSpeed_Cache_Vary
28
  {
29
  // logged in user
30
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
31
- // Make sure the cookie value is corrent
32
- self::add_logged_in() ;
33
-
34
  // If not esi, check cache logged-in user setting
35
  if ( ! LiteSpeed_Cache_Router::esi_enabled() ) {
36
  // If cache logged-in, then init cacheable to private
@@ -52,15 +49,12 @@ class LiteSpeed_Cache_Vary
52
  }
53
 
54
  // register logout hook to clear login status
55
- add_action( 'clear_auth_cookie', 'LiteSpeed_Cache_Vary::remove_logged_in' ) ;
56
 
57
  }
58
  else {
59
- // Make sure the cookie value is corrent
60
- self::remove_logged_in() ;
61
-
62
  // Set vary cookie for logging in user, otherwise the user will hit public with vary=0 (guest version)
63
- add_action( 'set_logged_in_cookie', 'LiteSpeed_Cache_Vary::add_logged_in', 10, 4 ) ;
64
  add_action( 'wp_login', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
65
 
66
  LiteSpeed_Cache_Control::init_cacheable() ;
@@ -76,6 +70,15 @@ class LiteSpeed_Cache_Vary
76
  // Set vary cookie for commenter.
77
  add_action('set_comment_cookies', array( $this, 'append_commenter' ) ) ;
78
 
 
 
 
 
 
 
 
 
 
79
  /******** Below to the end is only for cookie name setting check ********/
80
  // Get specific cookie name
81
  $db_cookie = false ;
@@ -189,83 +192,158 @@ class LiteSpeed_Cache_Vary
189
  * Append user status with logged in
190
  *
191
  * @since 1.1.3
 
192
  * @access public
193
  */
194
- public static function add_logged_in( $logged_in_cookie = false, $expire = false, $expiration = false, $user_id = false )
195
  {
 
196
  // If the cookie is lost somehow, set it
197
- $vary = self::generate_vary( $user_id ) ;
198
- $current_vary = self::has_vary() ;
199
- if ( $current_vary !== $vary && $current_vary !== 'commenter' ) {
200
- // $_COOKIE[ self::$_vary_name ] = $vary ; // not needed
201
-
202
- // save it
203
- if ( ! $expire ) {
204
- $expire = time() + 2 * DAY_IN_SECONDS ;
205
- }
206
- self::_cookie( $vary, $expire ) ;
207
- LiteSpeed_Cache_Control::set_nocache( 'adding logged in status' ) ;
208
- }
209
  }
210
 
211
  /**
212
  * Remove user logged in status
213
  *
214
  * @since 1.1.3
 
215
  * @access public
216
  */
217
- public static function remove_logged_in()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  {
219
- // If the cookie is set and not commenter, unset it.
 
 
 
 
 
 
 
 
 
 
220
  $current_vary = self::has_vary() ;
221
- if ( $current_vary && $current_vary !== 'commenter' ) {
222
- // remove logged in status from global var
223
- // unset( $_COOKIE[ self::$_vary_name ] ) ; // not needed
224
 
225
  // save it
226
- self::_cookie() ;
227
- LiteSpeed_Cache_Control::set_nocache( 'removing logged in status' ) ;
 
 
 
 
228
  }
229
  }
230
 
231
  /**
232
- * Get user vary tag based on admin_bar & role
233
  *
234
- * @since 1.2.0
235
- * @access public
 
 
 
 
236
  */
237
- public static function generate_vary( $user_id )
238
  {
239
- if ( ! $user_id ) {
240
- $user = wp_get_current_user() ;
241
- $user_id = $user->ID ;
242
- LiteSpeed_Cache_Log::debug2( 'getting user_id: ' . $user_id ) ;
 
 
 
243
  }
244
- $vary = array( 'logged-in' => 1 ) ;
245
  // get user's group id
246
- $user = get_userdata( $user_id ) ;
247
- if ( empty( $user->roles[ 0 ] ) ) {
248
- // Guest user
249
- LiteSpeed_Cache_Log::debug( 'Vary role id: failed, guest' ) ;
250
- return false ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
 
 
 
252
 
253
- // parge role group from settings
254
- $gid = $user->roles[ 0 ] ?: 0 ;
255
- if ( $role_group = LiteSpeed_Cache_Config::get_instance()->in_vary_group( $gid ) ) {
256
- $vary[ 'role' ] = $role_group ;
257
- LiteSpeed_Cache_Log::debug2( 'Vary role group: ' . $gid ) ;
258
  }
259
 
260
- // Get admin bar set
261
- // see @_get_admin_bar_pref()
262
- $pref = get_user_option( 'show_admin_bar_front', $user_id ) ;
263
- LiteSpeed_Cache_Log::debug2( 'Vary show_admin_bar_front: ' . $pref ) ;
264
- $admin_bar = $pref === false || $pref === 'true' ;
 
265
 
266
- if ( $admin_bar ) {
267
- $vary[ 'admin_bar' ] = 1 ;
268
- LiteSpeed_Cache_Log::debug2( 'Vary admin bar : true' ) ;
269
  }
270
 
271
  ksort( $vary ) ;
@@ -274,16 +352,13 @@ class LiteSpeed_Cache_Vary
274
  $res[] = $key . ':' . $val ;
275
  }
276
 
277
- if ( ! $res ) {
278
- return false ;
279
- }
280
-
281
  $res = implode( ';', $res ) ;
282
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
283
  return $res ;
284
  }
285
  // Encrypt in production
286
  return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
 
287
  }
288
 
289
  /**
@@ -363,7 +438,7 @@ class LiteSpeed_Cache_Vary
363
  * @access private
364
  * @return array An array of all vary cookies currently added.
365
  */
366
- private static function _format_vary_cookies()
367
  {
368
  if ( empty(self::$_vary_cookies) ) {
369
  return false ;
@@ -389,15 +464,31 @@ class LiteSpeed_Cache_Vary
389
  * @return mixed false if the user has the postpass cookie. Empty string
390
  * if the post is not password protected. Vary header otherwise.
391
  */
392
- public static function output()
393
  {
394
- if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
395
- return ;
396
- }
397
- $tp_cookies = self::_format_vary_cookies() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  global $post ;
399
  if ( ! empty($post->post_password) ) {
400
  if ( isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
 
401
  // If user has password cookie, do not cache
402
  LiteSpeed_Cache_Control::set_nocache('password protected vary') ;
403
  return ;
@@ -407,9 +498,12 @@ class LiteSpeed_Cache_Vary
407
  }
408
 
409
  if ( empty($tp_cookies) ) {
 
410
  return ;
411
  }
 
412
  return self::X_HEADER . ': ' . implode(',', $tp_cookies) ;
 
413
  }
414
 
415
  /**
28
  {
29
  // logged in user
30
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
 
 
 
31
  // If not esi, check cache logged-in user setting
32
  if ( ! LiteSpeed_Cache_Router::esi_enabled() ) {
33
  // If cache logged-in, then init cacheable to private
49
  }
50
 
51
  // register logout hook to clear login status
52
+ add_action( 'clear_auth_cookie', array( $this, 'remove_logged_in' ) ) ;
53
 
54
  }
55
  else {
 
 
 
56
  // Set vary cookie for logging in user, otherwise the user will hit public with vary=0 (guest version)
57
+ add_action( 'set_logged_in_cookie', array( $this, 'add_logged_in' ), 10, 4 ) ;
58
  add_action( 'wp_login', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
59
 
60
  LiteSpeed_Cache_Control::init_cacheable() ;
70
  // Set vary cookie for commenter.
71
  add_action('set_comment_cookies', array( $this, 'append_commenter' ) ) ;
72
 
73
+ /**
74
+ * Don't change for REST call because they don't carry on user info usually
75
+ * @since 1.6.7
76
+ */
77
+ add_action( 'rest_api_init', function(){
78
+ LiteSpeed_Cache_Log::debug( 'Vary: Rest API init disabled vary change' ) ;
79
+ add_filter( 'litespeed_can_change_vary', '__return_false' ) ;
80
+ } ) ;
81
+
82
  /******** Below to the end is only for cookie name setting check ********/
83
  // Get specific cookie name
84
  $db_cookie = false ;
192
  * Append user status with logged in
193
  *
194
  * @since 1.1.3
195
+ * @since 1.6.2 Removed static referral
196
  * @access public
197
  */
198
+ public function add_logged_in( $logged_in_cookie = false, $expire = false, $expiration = false, $uid = false )
199
  {
200
+ LiteSpeed_Cache_Log::debug( 'Vary: add_logged_in' ) ;
201
  // If the cookie is lost somehow, set it
202
+ $this->_update_default_vary( $uid, $expire ) ;
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
 
205
  /**
206
  * Remove user logged in status
207
  *
208
  * @since 1.1.3
209
+ * @since 1.6.2 Removed static referral
210
  * @access public
211
  */
212
+ public function remove_logged_in()
213
+ {
214
+ LiteSpeed_Cache_Log::debug( 'Vary: remove_logged_in' ) ;
215
+ // Force update vary to remove login status
216
+ $this->_update_default_vary( -1 ) ;
217
+ }
218
+
219
+ /**
220
+ * Check if can change default vary
221
+ *
222
+ * @since 1.6.2
223
+ * @access private
224
+ */
225
+ private function can_change_vary()
226
+ {
227
+ // Don't change for ajax due to ajax not sending webp header
228
+ /**
229
+ * Added `litespeed_ajax_vary` hook for 3rd party to set vary when doing ajax call ( Login With Ajax )
230
+ * @since 1.6.6
231
+ */
232
+ if ( LiteSpeed_Cache_Router::is_ajax() && ! apply_filters( 'litespeed_ajax_vary', false ) ) {
233
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to ajax call' ) ;
234
+ return false ;
235
+ }
236
+
237
+ /**
238
+ * POST request can set vary to fix #820789 login "loop" guest cache issue
239
+ * @since 1.6.5
240
+ */
241
+ if ( $_SERVER["REQUEST_METHOD"] !== 'GET' && $_SERVER["REQUEST_METHOD"] !== 'POST' ) {
242
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to method not get/post' ) ;
243
+ return false ;
244
+ }
245
+
246
+ if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
247
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
248
+ return false ;
249
+ }
250
+
251
+ return true ;
252
+ }
253
+
254
+ /**
255
+ * Update default vary
256
+ *
257
+ * @since 1.6.2
258
+ * @since 1.6.6.1 Add ran check to make it only run once ( No run multiple times due to login process doesn't have valid uid from router::get_uid )
259
+ * @access private
260
+ */
261
+ private function _update_default_vary( $uid = false, $expire = false )
262
  {
263
+ // Make sure header output only run once
264
+ if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
265
+ define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
266
+ }
267
+ else {
268
+ LiteSpeed_Cache_Log::debug2( "Vary: _update_default_vary bypassed due to run already" ) ;
269
+ return ;
270
+ }
271
+
272
+ // If the cookie is lost somehow, set it
273
+ $vary = $this->_finalize_default_vary( $uid ) ;
274
  $current_vary = self::has_vary() ;
275
+ if ( $current_vary !== $vary && $current_vary !== 'commenter' && $this->can_change_vary() ) {
276
+ // $_COOKIE[ self::$_vary_name ] = $vary ; // not needed
 
277
 
278
  // save it
279
+ if ( ! $expire ) {
280
+ $expire = time() + 2 * DAY_IN_SECONDS ;
281
+ }
282
+ self::_cookie( $vary, $expire ) ;
283
+ LiteSpeed_Cache_Log::debug( "Vary: set_cookie ---> $vary" ) ;
284
+ LiteSpeed_Cache_Control::set_nocache( 'changing default vary' . " $current_vary => $vary" ) ;
285
  }
286
  }
287
 
288
  /**
289
+ * Finalize default vary
290
  *
291
+ * Get user vary tag based on admin_bar & role
292
+ *
293
+ * NOTE: Login process will also call this because it does not call wp hook as normal page loading
294
+ *
295
+ * @since 1.6.2
296
+ * @access private
297
  */
298
+ private function _finalize_default_vary( $uid = false )
299
  {
300
+ $vary = array() ;
301
+
302
+ if ( ! $uid ) {
303
+ $uid = LiteSpeed_Cache_Router::get_uid() ;
304
+ }
305
+ else {
306
+ LiteSpeed_Cache_Log::debug( 'Vary: uid: ' . $uid ) ;
307
  }
308
+
309
  // get user's group id
310
+ $role = LiteSpeed_Cache_Router::get_role( $uid ) ;
311
+
312
+ if ( $uid > 0 && $role ) {
313
+ $vary[ 'logged-in' ] = 1 ;
314
+
315
+ // parse role group from settings
316
+ if ( $role_group = LiteSpeed_Cache_Config::get_instance()->in_vary_group( $role ) ) {
317
+ $vary[ 'role' ] = $role_group ;
318
+ }
319
+
320
+ // Get admin bar set
321
+ // see @_get_admin_bar_pref()
322
+ $pref = get_user_option( 'show_admin_bar_front', $uid ) ;
323
+ LiteSpeed_Cache_Log::debug2( 'Vary: show_admin_bar_front: ' . $pref ) ;
324
+ $admin_bar = $pref === false || $pref === 'true' ;
325
+
326
+ if ( $admin_bar ) {
327
+ $vary[ 'admin_bar' ] = 1 ;
328
+ LiteSpeed_Cache_Log::debug2( 'Vary: admin bar : true' ) ;
329
+ }
330
+
331
  }
332
+ else {
333
+ // Guest user
334
+ LiteSpeed_Cache_Log::debug( 'Vary: role id: failed, guest' ) ;
335
 
 
 
 
 
 
336
  }
337
 
338
+ /**
339
+ * Add filter
340
+ * @since 1.6 Added for Role Excludes for optimization cls
341
+ * @since 1.6.2 Hooked to webp
342
+ */
343
+ $vary = apply_filters( 'litespeed_vary', $vary ) ;
344
 
345
+ if ( ! $vary ) {
346
+ return false ;
 
347
  }
348
 
349
  ksort( $vary ) ;
352
  $res[] = $key . ':' . $val ;
353
  }
354
 
 
 
 
 
355
  $res = implode( ';', $res ) ;
356
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
357
  return $res ;
358
  }
359
  // Encrypt in production
360
  return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
361
+
362
  }
363
 
364
  /**
438
  * @access private
439
  * @return array An array of all vary cookies currently added.
440
  */
441
+ private function _format_vary_cookies()
442
  {
443
  if ( empty(self::$_vary_cookies) ) {
444
  return false ;
464
  * @return mixed false if the user has the postpass cookie. Empty string
465
  * if the post is not password protected. Vary header otherwise.
466
  */
467
+ public static function finalize()
468
  {
469
+ return self::get_instance()->_finalize() ;
470
+
471
+ }
472
+
473
+ private function _finalize()
474
+ {
475
+ // Finalize default vary
476
+ $this->_update_default_vary() ;
477
+
478
+ /**
479
+ * Non caccheable page can still set vary ( for logged in process )
480
+ * @since 1.6.6.1
481
+ */
482
+ // if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
483
+ // LiteSpeed_Cache_Log::debug2( 'Vary: bypass finalize due to not cacheable' ) ;
484
+ // return false;
485
+ // }
486
+
487
+ $tp_cookies = $this->_format_vary_cookies() ;
488
  global $post ;
489
  if ( ! empty($post->post_password) ) {
490
  if ( isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
491
+ LiteSpeed_Cache_Log::debug( 'Vary: finalize bypassed due to password protected vary ' ) ;
492
  // If user has password cookie, do not cache
493
  LiteSpeed_Cache_Control::set_nocache('password protected vary') ;
494
  return ;
498
  }
499
 
500
  if ( empty($tp_cookies) ) {
501
+ LiteSpeed_Cache_Log::debug( 'Vary: finalize bypassed due to no vary ' ) ;
502
  return ;
503
  }
504
+
505
  return self::X_HEADER . ': ' . implode(',', $tp_cookies) ;
506
+
507
  }
508
 
509
  /**
includes/litespeed-cache-api.class.php CHANGED
@@ -169,6 +169,17 @@ class LiteSpeed_Cache_API
169
  LiteSpeed_Cache_Tag::add($tags) ;
170
  }
171
 
 
 
 
 
 
 
 
 
 
 
 
172
  /**
173
  * Add vary
174
  *
@@ -191,6 +202,28 @@ class LiteSpeed_Cache_API
191
  LiteSpeed_Cache_Purge::purge_all() ;
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  /**
195
  * Purge single action
196
  *
@@ -398,9 +431,20 @@ class LiteSpeed_Cache_API
398
  * @since 1.1.3
399
  * @access public
400
  */
401
- public static function debug($info)
 
 
 
 
 
 
 
 
 
 
 
402
  {
403
- LiteSpeed_Cache_Log::debug($info) ;
404
  }
405
 
406
  /**
@@ -447,4 +491,15 @@ class LiteSpeed_Cache_API
447
  add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
448
  }
449
 
 
 
 
 
 
 
 
 
 
 
 
450
  }
169
  LiteSpeed_Cache_Tag::add($tags) ;
170
  }
171
 
172
+ /**
173
+ * Add public tag to cache
174
+ *
175
+ * @since 1.6.3
176
+ * @access public
177
+ */
178
+ public static function add_private( $tags )
179
+ {
180
+ LiteSpeed_Cache_Tag::add_private( $tags ) ;
181
+ }
182
+
183
  /**
184
  * Add vary
185
  *
202
  LiteSpeed_Cache_Purge::purge_all() ;
203
  }
204
 
205
+ /**
206
+ * Purge all private
207
+ *
208
+ * @since 1.6.3
209
+ * @access public
210
+ */
211
+ public static function purge_private_all()
212
+ {
213
+ LiteSpeed_Cache_Purge::add_private( '*' ) ;
214
+ }
215
+
216
+ /**
217
+ * Purge private tag
218
+ *
219
+ * @since 1.6.3
220
+ * @access public
221
+ */
222
+ public static function purge_private( $tags )
223
+ {
224
+ LiteSpeed_Cache_Purge::add_private( $tags ) ;
225
+ }
226
+
227
  /**
228
  * Purge single action
229
  *
431
  * @since 1.1.3
432
  * @access public
433
  */
434
+ public static function debug( $info, $backtrace_limit = false )
435
+ {
436
+ LiteSpeed_Cache_Log::debug( $info, $backtrace_limit ) ;
437
+ }
438
+
439
+ /**
440
+ * Log debug info ( advanced mode )
441
+ *
442
+ * @since 1.6.6.1
443
+ * @access public
444
+ */
445
+ public static function debug2( $info, $backtrace_limit = false )
446
  {
447
+ LiteSpeed_Cache_Log::debug2( $info, $backtrace_limit ) ;
448
  }
449
 
450
  /**
491
  add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
492
  }
493
 
494
+ /**
495
+ * Hook to litespeed init
496
+ *
497
+ * @since 1.6.6
498
+ * @access public
499
+ */
500
+ public static function hook_init( $hook )
501
+ {
502
+ add_action('litespeed_init', $hook) ;
503
+ }
504
+
505
  }
includes/litespeed-cache-cdn.class.php CHANGED
@@ -116,6 +116,27 @@ class LiteSpeed_Cache_CDN
116
 
117
  }
118
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  /**
120
  * Check if the host is the CDN internal host
121
  *
@@ -144,12 +165,12 @@ class LiteSpeed_Cache_CDN
144
  * @access public
145
  * @return string The content that is after optimization
146
  */
147
- public static function run( $content )
148
  {
149
  $instance = self::get_instance() ;
150
  $instance->content = $content ;
151
 
152
- $instance->_process() ;
153
  return $instance->content ;
154
  }
155
 
@@ -173,6 +194,15 @@ class LiteSpeed_Cache_CDN
173
  return false ;
174
  }
175
 
 
 
 
 
 
 
 
 
 
176
  return true ;
177
  }
178
 
@@ -182,14 +212,14 @@ class LiteSpeed_Cache_CDN
182
  * @since 1.2.3
183
  * @access private
184
  */
185
- private function _process()
186
  {
187
  if ( defined( self::BYPASS ) ) {
188
  LiteSpeed_Cache_Log::debug2( 'CDN bypass' ) ;
189
  return ;
190
  }
191
 
192
- LiteSpeed_Cache_Log::debug( 'CDN _process' ) ;
193
 
194
  // Start replacing img src
195
  if ( $this->cfg_cdn_inc_img ) {
@@ -357,8 +387,8 @@ class LiteSpeed_Cache_CDN
357
 
358
  // Only images under wp-cotnent/wp-includes can be replaced
359
  if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
360
- if ( defined( 'UPLOADS' ) && stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
361
- LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match ' ) ;
362
  return false ;
363
  }
364
  }
116
 
117
  }
118
 
119
+ /**
120
+ * If include css/js in CDN
121
+ *
122
+ * @since 1.6.2.1
123
+ * @return bool true if included in CDN
124
+ */
125
+ public static function inc_type( $type )
126
+ {
127
+ $instance = self::get_instance() ;
128
+
129
+ if ( $type == 'css' && $instance->cfg_cdn_inc_css ) {
130
+ return true ;
131
+ }
132
+
133
+ if ( $type == 'js' && $instance->cfg_cdn_inc_js ) {
134
+ return true ;
135
+ }
136
+
137
+ return false ;
138
+ }
139
+
140
  /**
141
  * Check if the host is the CDN internal host
142
  *
165
  * @access public
166
  * @return string The content that is after optimization
167
  */
168
+ public static function finalize( $content )
169
  {
170
  $instance = self::get_instance() ;
171
  $instance->content = $content ;
172
 
173
+ $instance->_finalize() ;
174
  return $instance->content ;
175
  }
176
 
194
  return false ;
195
  }
196
 
197
+ /**
198
+ * Bypass login/reg page
199
+ * @since 1.6
200
+ */
201
+ if ( in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ), true ) ) {
202
+ LiteSpeed_Cache_Log::debug( 'CDN bypassed as is login/reg page' ) ;
203
+ return false ;
204
+ }
205
+
206
  return true ;
207
  }
208
 
212
  * @since 1.2.3
213
  * @access private
214
  */
215
+ private function _finalize()
216
  {
217
  if ( defined( self::BYPASS ) ) {
218
  LiteSpeed_Cache_Log::debug2( 'CDN bypass' ) ;
219
  return ;
220
  }
221
 
222
+ LiteSpeed_Cache_Log::debug( 'CDN _finalize' ) ;
223
 
224
  // Start replacing img src
225
  if ( $this->cfg_cdn_inc_img ) {
387
 
388
  // Only images under wp-cotnent/wp-includes can be replaced
389
  if ( stripos( $url_parsed[ 'path' ], LSWCP_CONTENT_FOLDER ) === false && stripos( $url_parsed[ 'path' ], 'wp-includes' ) === false && stripos( $url_parsed[ 'path' ], '/min/' ) === false ) {
390
+ if ( ! defined( 'UPLOADS' ) || stripos( $url_parsed[ 'path' ], UPLOADS ) === false ) {
391
+ LiteSpeed_Cache_Log::debug2( 'CDN: rewriting failed: path not match: ' . LSWCP_CONTENT_FOLDER ) ;
392
  return false ;
393
  }
394
  }
includes/litespeed-cache-config.class.php CHANGED
@@ -16,9 +16,13 @@ class LiteSpeed_Cache_Config
16
 
17
  const OPTION_NAME = 'litespeed-cache-conf' ;
18
  const VARY_GROUP = 'litespeed-cache-vary-group' ;
 
 
19
  const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
20
  const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
21
  const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
 
 
22
 
23
  const VAL_OFF = 0 ;
24
  const VAL_ON = 1 ;
@@ -42,6 +46,7 @@ class LiteSpeed_Cache_Config
42
  const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
43
  const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
44
  const OPID_CACHE_BROWSER = 'cache_browser' ;
 
45
 
46
  const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
47
  const OPID_TIMED_URLS = 'timed_urls' ;
@@ -92,10 +97,12 @@ class LiteSpeed_Cache_Config
92
 
93
  const OPID_CSS_MINIFY = 'css_minify' ;
94
  const OPID_CSS_COMBINE = 'css_combine' ;
 
95
  const OPID_CSS_HTTP2 = 'css_http2' ;
96
  const OPID_CSS_EXCLUDES = 'css_exclude' ;
97
  const OPID_JS_MINIFY = 'js_minify' ;
98
  const OPID_JS_COMBINE = 'js_combine' ;
 
99
  const OPID_JS_HTTP2 = 'js_http2' ;
100
  const OPID_JS_EXCLUDES = 'js_exclude' ;
101
  const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
@@ -107,6 +114,7 @@ class LiteSpeed_Cache_Config
107
  const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
108
  const OPID_OPTM_EXCLUDES = 'optm_excludes' ;
109
  const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
 
110
 
111
  const OPID_CDN = 'cdn' ;
112
  const OPID_CDN_ORI = 'cdn_ori' ;
@@ -121,6 +129,11 @@ class LiteSpeed_Cache_Config
121
  const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
122
  const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
123
  const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
 
 
 
 
 
124
 
125
  const HASH = 'hash' ;
126
 
@@ -151,6 +164,8 @@ class LiteSpeed_Cache_Config
151
 
152
  protected $options ;
153
  protected $vary_groups ;
 
 
154
  protected $purge_options ;
155
 
156
  /**
@@ -186,6 +201,12 @@ class LiteSpeed_Cache_Config
186
  // Vary group settings
187
  $this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
188
 
 
 
 
 
 
 
189
  // Set security key if not initialized yet
190
  if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
191
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
@@ -311,11 +332,11 @@ class LiteSpeed_Cache_Config
311
  exit( 'no referer' ) ;
312
  }
313
 
314
- if ( empty( $_GET[ 'type' ] ) ) {
315
  exit( 'no type' ) ;
316
  }
317
 
318
- switch ( $_GET[ 'type' ] ) {
319
  case 'private' :
320
  $id = self::OPID_CACHE_URI_PRIV ;
321
  break ;
@@ -365,9 +386,57 @@ class LiteSpeed_Cache_Config
365
  $group = 99 ;
366
  }
367
 
 
 
 
 
368
  return $group ;
369
  }
370
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  /**
372
  * Get the configured purge options.
373
  *
@@ -411,7 +480,7 @@ class LiteSpeed_Cache_Config
411
  self::PURGE_AUTHOR,
412
  self::PURGE_MONTH,
413
  self::PURGE_TERM,
414
- self::PURGE_POST_TYPE
415
  ) ;
416
  sort($default_purge_options) ;
417
 
@@ -439,13 +508,14 @@ class LiteSpeed_Cache_Config
439
  self::ID_MOBILEVIEW_LIST => false,
440
  self::OPID_CACHE_URI_PRIV => '',
441
  self::OPID_CACHE_BROWSER => false,
 
442
 
443
  self::OPID_LOGIN_COOKIE => '',
444
  self::OPID_CHECK_ADVANCEDCACHE => true,
445
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
446
  self::OPID_ADMIN_IPS => '127.0.0.1',
447
  self::OPID_DEBUG_LEVEL => false,
448
- self::OPID_LOG_FILE_SIZE => 30,
449
  self::OPID_HEARTBEAT => true,
450
  self::OPID_DEBUG_COOKIE => false,
451
  self::OPID_COLLAPS_QS => false,
@@ -467,10 +537,12 @@ class LiteSpeed_Cache_Config
467
 
468
  self::OPID_CSS_MINIFY => false,
469
  self::OPID_CSS_COMBINE => false,
 
470
  self::OPID_CSS_HTTP2 => false,
471
  self::OPID_CSS_EXCLUDES => '',
472
  self::OPID_JS_MINIFY => false,
473
  self::OPID_JS_COMBINE => false,
 
474
  self::OPID_JS_HTTP2 => false,
475
  self::OPID_JS_EXCLUDES => '',
476
  self::OPID_OPTIMIZE_TTL => 604800,
@@ -482,6 +554,7 @@ class LiteSpeed_Cache_Config
482
  self::OPID_OPTM_EMOJI_RM => false,
483
  self::OPID_OPTM_EXCLUDES => '',
484
  self::OPID_OPTM_EXC_JQUERY => true,
 
485
 
486
  self::OPID_CDN => false,
487
  self::OPID_CDN_ORI => '',
@@ -496,6 +569,11 @@ class LiteSpeed_Cache_Config
496
  self::OPID_MEDIA_IMG_LAZY => false,
497
  self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
498
  self::OPID_MEDIA_IFRAME_LAZY => false,
 
 
 
 
 
499
 
500
  self::HASH => '',
501
 
@@ -554,10 +632,12 @@ class LiteSpeed_Cache_Config
554
  self::OPID_CACHE_MOBILE => 0, // todo: why not false
555
  self::ID_MOBILEVIEW_LIST => false,
556
  self::OPID_CACHE_BROWSER => false,
 
557
  self::OPID_LOGIN_COOKIE => '',
558
  self::OPID_CHECK_ADVANCEDCACHE => true,
559
  self::ID_NOCACHE_COOKIES => '',
560
  self::ID_NOCACHE_USERAGENTS => '',
 
561
  ) ;
562
  return $default_site_options ;
563
  }
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_MEDIA_NEED_PULL = 'litespeed-media-need-pull' ;
25
+ const ITEM_ENV_REF = 'litespeed-env-ref' ;
26
 
27
  const VAL_OFF = 0 ;
28
  const VAL_ON = 1 ;
46
  const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
47
  const OPID_CACHE_URI_PRIV = 'cache_uri_priv' ;
48
  const OPID_CACHE_BROWSER = 'cache_browser' ;
49
+ const OPID_CACHE_BROWSER_TTL = 'cache_browser_ttl' ;
50
 
51
  const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
52
  const OPID_TIMED_URLS = 'timed_urls' ;
97
 
98
  const OPID_CSS_MINIFY = 'css_minify' ;
99
  const OPID_CSS_COMBINE = 'css_combine' ;
100
+ const OPID_CSS_COMBINED_PRIORITY = 'css_combined_priority' ;
101
  const OPID_CSS_HTTP2 = 'css_http2' ;
102
  const OPID_CSS_EXCLUDES = 'css_exclude' ;
103
  const OPID_JS_MINIFY = 'js_minify' ;
104
  const OPID_JS_COMBINE = 'js_combine' ;
105
+ const OPID_JS_COMBINED_PRIORITY = 'js_combined_priority' ;
106
  const OPID_JS_HTTP2 = 'js_http2' ;
107
  const OPID_JS_EXCLUDES = 'js_exclude' ;
108
  const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
114
  const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
115
  const OPID_OPTM_EXCLUDES = 'optm_excludes' ;
116
  const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
117
+ const OPID_OPTM_GGFONTS_ASYNC = 'optm_ggfonts_async' ;
118
 
119
  const OPID_CDN = 'cdn' ;
120
  const OPID_CDN_ORI = 'cdn_ori' ;
129
  const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
130
  const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
131
  const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
132
+ const OPID_MEDIA_IMG_OPTM_CRON_OFF = 'media_img_optm_cron_off' ;
133
+ const OPID_MEDIA_IMG_WEBP = 'media_img_webp' ;
134
+ const OPID_MEDIA_IMG_WEBP_ONLY = 'media_img_webp_only' ;
135
+ const OPID_MEDIA_IMG_EXIF = 'media_img_exif' ;
136
+ const OPID_MEDIA_IMG_WEBP_LOSSLESS = 'media_img_webp_lossless' ;
137
 
138
  const HASH = 'hash' ;
139
 
164
 
165
  protected $options ;
166
  protected $vary_groups ;
167
+ protected $exclude_optimization_roles ;
168
+ protected $exclude_cache_roles ;
169
  protected $purge_options ;
170
 
171
  /**
201
  // Vary group settings
202
  $this->vary_groups = (array) get_option( self::VARY_GROUP ) ;
203
 
204
+ // Exclude optimization role setting
205
+ $this->exclude_optimization_roles = (array) get_option( self::EXCLUDE_OPTIMIZATION_ROLES ) ;
206
+
207
+ // Exclude cache role setting
208
+ $this->exclude_cache_roles = (array) get_option( self::EXCLUDE_CACHE_ROLES ) ;
209
+
210
  // Set security key if not initialized yet
211
  if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
212
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
332
  exit( 'no referer' ) ;
333
  }
334
 
335
+ if ( ! $type = LiteSpeed_Cache_Router::verify_type() ) {
336
  exit( 'no type' ) ;
337
  }
338
 
339
+ switch ( $type ) {
340
  case 'private' :
341
  $id = self::OPID_CACHE_URI_PRIV ;
342
  break ;
386
  $group = 99 ;
387
  }
388
 
389
+ if ( $group ) {
390
+ LiteSpeed_Cache_Log::debug2( 'Config: role in vary_group [group] ' . $group ) ;
391
+ }
392
+
393
  return $group ;
394
  }
395
 
396
+ /**
397
+ * Check if one user role is in exclude optimization group settings
398
+ *
399
+ * @since 1.6
400
+ * @access public
401
+ * @param string $role The user role
402
+ * @return int The set value if already set
403
+ */
404
+ public function in_exclude_optimization_roles( $role = null )
405
+ {
406
+ // Get user role
407
+ if ( $role === null ) {
408
+ $role = LiteSpeed_Cache_Router::get_role() ;
409
+ }
410
+
411
+ if ( ! $role ) {
412
+ return false ;
413
+ }
414
+
415
+ return in_array( $role, $this->exclude_optimization_roles ) ? $role : false ;
416
+ }
417
+
418
+ /**
419
+ * Check if one user role is in exclude cache group settings
420
+ *
421
+ * @since 1.6.2
422
+ * @access public
423
+ * @param string $role The user role
424
+ * @return int The set value if already set
425
+ */
426
+ public function in_exclude_cache_roles( $role = null )
427
+ {
428
+ // Get user role
429
+ if ( $role === null ) {
430
+ $role = LiteSpeed_Cache_Router::get_role() ;
431
+ }
432
+
433
+ if ( ! $role ) {
434
+ return false ;
435
+ }
436
+
437
+ return in_array( $role, $this->exclude_cache_roles ) ? $role : false ;
438
+ }
439
+
440
  /**
441
  * Get the configured purge options.
442
  *
480
  self::PURGE_AUTHOR,
481
  self::PURGE_MONTH,
482
  self::PURGE_TERM,
483
+ self::PURGE_POST_TYPE,
484
  ) ;
485
  sort($default_purge_options) ;
486
 
508
  self::ID_MOBILEVIEW_LIST => false,
509
  self::OPID_CACHE_URI_PRIV => '',
510
  self::OPID_CACHE_BROWSER => false,
511
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
512
 
513
  self::OPID_LOGIN_COOKIE => '',
514
  self::OPID_CHECK_ADVANCEDCACHE => true,
515
  self::OPID_DEBUG => self::LOG_LEVEL_NONE,
516
  self::OPID_ADMIN_IPS => '127.0.0.1',
517
  self::OPID_DEBUG_LEVEL => false,
518
+ self::OPID_LOG_FILE_SIZE => 3,
519
  self::OPID_HEARTBEAT => true,
520
  self::OPID_DEBUG_COOKIE => false,
521
  self::OPID_COLLAPS_QS => false,
537
 
538
  self::OPID_CSS_MINIFY => false,
539
  self::OPID_CSS_COMBINE => false,
540
+ self::OPID_CSS_COMBINED_PRIORITY => false,
541
  self::OPID_CSS_HTTP2 => false,
542
  self::OPID_CSS_EXCLUDES => '',
543
  self::OPID_JS_MINIFY => false,
544
  self::OPID_JS_COMBINE => false,
545
+ self::OPID_JS_COMBINED_PRIORITY => false,
546
  self::OPID_JS_HTTP2 => false,
547
  self::OPID_JS_EXCLUDES => '',
548
  self::OPID_OPTIMIZE_TTL => 604800,
554
  self::OPID_OPTM_EMOJI_RM => false,
555
  self::OPID_OPTM_EXCLUDES => '',
556
  self::OPID_OPTM_EXC_JQUERY => true,
557
+ self::OPID_OPTM_GGFONTS_ASYNC => false,
558
 
559
  self::OPID_CDN => false,
560
  self::OPID_CDN_ORI => '',
569
  self::OPID_MEDIA_IMG_LAZY => false,
570
  self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
571
  self::OPID_MEDIA_IFRAME_LAZY => false,
572
+ self::OPID_MEDIA_IMG_OPTM_CRON_OFF => false,
573
+ self::OPID_MEDIA_IMG_WEBP => false,
574
+ self::OPID_MEDIA_IMG_WEBP_ONLY => false,
575
+ self::OPID_MEDIA_IMG_EXIF => false,
576
+ self::OPID_MEDIA_IMG_WEBP_LOSSLESS => false,
577
 
578
  self::HASH => '',
579
 
632
  self::OPID_CACHE_MOBILE => 0, // todo: why not false
633
  self::ID_MOBILEVIEW_LIST => false,
634
  self::OPID_CACHE_BROWSER => false,
635
+ self::OPID_CACHE_BROWSER_TTL => 2592000,
636
  self::OPID_LOGIN_COOKIE => '',
637
  self::OPID_CHECK_ADVANCEDCACHE => true,
638
  self::ID_NOCACHE_COOKIES => '',
639
  self::ID_NOCACHE_USERAGENTS => '',
640
+ self::OPID_MEDIA_IMG_WEBP => false,
641
  ) ;
642
  return $default_site_options ;
643
  }
includes/litespeed-cache-control.class.php CHANGED
@@ -25,6 +25,36 @@ class LiteSpeed_Cache_Control
25
  protected static $_custom_ttl = 0 ;
26
  private static $_mobile = false ;
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * 1. Initialize cacheable status for `wp` hook
30
  * 2. Hook error page tags for cacheable pages
@@ -70,7 +100,7 @@ class LiteSpeed_Cache_Control
70
  return ;
71
  }
72
  self::$_control |= self::BM_NO_VARY ;
73
- LiteSpeed_Cache_Log::debug('X Cache_control -> no-vary') ;
74
  }
75
 
76
  /**
@@ -536,6 +566,13 @@ class LiteSpeed_Cache_Control
536
  }
537
  }
538
 
 
 
 
 
 
 
 
539
  return true ;
540
  }
541
 
25
  protected static $_custom_ttl = 0 ;
26
  private static $_mobile = false ;
27
 
28
+ /**
29
+ * Init cache control
30
+ *
31
+ * @since 1.6.2
32
+ * @access private
33
+ */
34
+ private function __construct()
35
+ {
36
+ /**
37
+ * Add vary filter for Role Excludes
38
+ * @since 1.6.2
39
+ */
40
+ add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
41
+ }
42
+
43
+ /**
44
+ * Exclude role from optimization filter
45
+ *
46
+ * @since 1.6.2
47
+ * @access public
48
+ */
49
+ public function vary_add_role_exclude( $varys )
50
+ {
51
+ if ( ! LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
52
+ return $varys ;
53
+ }
54
+ $varys[ 'role_exclude_cache' ] = 1 ;
55
+ return $varys ;
56
+ }
57
+
58
  /**
59
  * 1. Initialize cacheable status for `wp` hook
60
  * 2. Hook error page tags for cacheable pages
100
  return ;
101
  }
102
  self::$_control |= self::BM_NO_VARY ;
103
+ LiteSpeed_Cache_Log::debug( 'X Cache_control -> no-vary', 3 ) ;
104
  }
105
 
106
  /**
566
  }
567
  }
568
 
569
+ // Check if is exclude roles ( Need to set Vary too )
570
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
571
+ return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
572
+ }
573
+
574
+
575
+
576
  return true ;
577
  }
578
 
includes/litespeed-cache-crawler.class.php CHANGED
@@ -326,7 +326,7 @@ class LiteSpeed_Cache_Crawler
326
  }
327
  else {
328
  $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
329
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
330
  }
331
  LiteSpeed_Cache_Log::debug($log) ;
332
  }
326
  }
327
  else {
328
  $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
329
+ // LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
330
  }
331
  LiteSpeed_Cache_Log::debug($log) ;
332
  }
includes/litespeed-cache-gui.class.php CHANGED
@@ -16,6 +16,10 @@ class LiteSpeed_Cache_GUI
16
 
17
  private static $_clean_counter = 0 ;
18
 
 
 
 
 
19
  /**
20
  * Init
21
  *
@@ -31,6 +35,90 @@ class LiteSpeed_Cache_GUI
31
  }
32
  }
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  /**
35
  * Load frontend menu shortcut
36
  *
@@ -78,21 +166,21 @@ class LiteSpeed_Cache_GUI
78
  'parent' => 'litespeed-single-action',
79
  'id' => 'litespeed-single-noncache',
80
  'title' => __( 'Non cacheable', 'litespeed-cache' ),
81
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nocache', true ),
82
  ) );
83
 
84
  $wp_admin_bar->add_menu( array(
85
  'parent' => 'litespeed-single-action',
86
  'id' => 'litespeed-single-private',
87
  'title' => __( 'Private cache', 'litespeed-cache' ),
88
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=private', true ),
89
  ) );
90
 
91
  $wp_admin_bar->add_menu( array(
92
  'parent' => 'litespeed-single-action',
93
  'id' => 'litespeed-single-nonoptimize',
94
  'title' => __( 'No optimization', 'litespeed-cache' ),
95
- 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, false, 'type=nonoptimize', true ),
96
  ) );
97
 
98
  $wp_admin_bar->add_menu( array(
@@ -103,13 +191,26 @@ class LiteSpeed_Cache_GUI
103
  ) );
104
  }
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  /**
107
  * Clean wrapper from buffer
108
  *
109
  * @since 1.4
110
- * @access public
 
111
  */
112
- public static function clean_wrapper( $buffer )
113
  {
114
  if ( self::$_clean_counter < 1 ) {
115
  LiteSpeed_Cache_Log::debug2( "GUI bypassed by no counter" ) ;
16
 
17
  private static $_clean_counter = 0 ;
18
 
19
+ const TYPE_DISMISS_WHM = 'whm' ;
20
+ const TYPE_DISMISS_EXPIRESDEFAULT = 'ExpiresDefault' ;
21
+ const TYPE_DISMISS_PROMO = 'promo' ;
22
+
23
  /**
24
  * Init
25
  *
35
  }
36
  }
37
 
38
+ public static function pie( $percent, $width = 50 )
39
+ {
40
+ return "
41
+ <svg class='litespeed-media-svg' width='$width' viewBox='0 0 33.83098862 33.83098862' xmlns='http://www.w3.org/2000/svg'>
42
+ <circle class='litespeed-pie_bg' cx='17.5' cy='17.5' r='16.5'></circle>
43
+ <circle class='litespeed-pie_circle' cx='17' cy='17.5' r='16.5'></circle>
44
+ <g class='litespeed-pie_info'>
45
+ <text x='16.91549431' y='15.5' alignment-baseline='central' text-anchor='middle'>$percent%</text>
46
+ </g>
47
+ </svg>
48
+ ";
49
+
50
+ }
51
+
52
+ public static function dismiss()
53
+ {
54
+ switch ( LiteSpeed_Cache_Router::verify_type() ) {
55
+ case self::TYPE_DISMISS_WHM :
56
+ LiteSpeed_Cache_Activation::dismiss_whm() ;
57
+ break ;
58
+
59
+ case self::TYPE_DISMISS_EXPIRESDEFAULT :
60
+ update_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
61
+ break ;
62
+
63
+ case self::TYPE_DISMISS_PROMO :
64
+ update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
65
+ break ;
66
+
67
+ default:
68
+ break ;
69
+ }
70
+
71
+ // All dismiss actions are considered as ajax call, so just exit
72
+ exit( json_encode( array( 'success' => 1 ) ) ) ;
73
+ }
74
+
75
+ /**
76
+ * Check if has rule conflict notice
77
+ *
78
+ * @since 1.1.5
79
+ * @access public
80
+ * @return boolean
81
+ */
82
+ public static function has_msg_ruleconflict()
83
+ {
84
+ return get_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG ) == LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ;
85
+ }
86
+
87
+ /**
88
+ * Check if has whm notice
89
+ *
90
+ * @since 1.1.1
91
+ * @access public
92
+ * @return boolean
93
+ */
94
+ public static function has_whm_msg()
95
+ {
96
+ return get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
97
+ }
98
+
99
+ /**
100
+ * Check if has promotion notice
101
+ *
102
+ * @since 1.3.2
103
+ * @access public
104
+ * @return boolean
105
+ */
106
+ public static function has_promo_msg()
107
+ {
108
+ $promo = get_option( 'litespeed-banner-promo' ) ;
109
+ if ( ! $promo ) {
110
+ update_option( 'litespeed-banner-promo', time() - 86400 * 8 ) ;
111
+ return false ;
112
+ }
113
+ if ( $promo == 'done' ) {
114
+ return false ;
115
+ }
116
+ if ( $promo && time() - $promo < 864000 ) {
117
+ return false ;
118
+ }
119
+ return true ;
120
+ }
121
+
122
  /**
123
  * Load frontend menu shortcut
124
  *
166
  'parent' => 'litespeed-single-action',
167
  'id' => 'litespeed-single-noncache',
168
  'title' => __( 'Non cacheable', 'litespeed-cache' ),
169
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'nocache', false, true ),
170
  ) );
171
 
172
  $wp_admin_bar->add_menu( array(
173
  'parent' => 'litespeed-single-action',
174
  'id' => 'litespeed-single-private',
175
  'title' => __( 'Private cache', 'litespeed-cache' ),
176
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'private', false, true ),
177
  ) );
178
 
179
  $wp_admin_bar->add_menu( array(
180
  'parent' => 'litespeed-single-action',
181
  'id' => 'litespeed-single-nonoptimize',
182
  'title' => __( 'No optimization', 'litespeed-cache' ),
183
+ 'href' => LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_FRONT_EXCLUDE, 'nonoptimize', false, true ),
184
  ) );
185
 
186
  $wp_admin_bar->add_menu( array(
191
  ) );
192
  }
193
 
194
+ /**
195
+ * Finalize buffer by GUI class
196
+ *
197
+ * @since 1.6
198
+ * @access public
199
+ */
200
+ public static function finalize( $buffer )
201
+ {
202
+ $instance = self::get_instance() ;
203
+ return $instance->_clean_wrapper( $buffer ) ;
204
+ }
205
+
206
  /**
207
  * Clean wrapper from buffer
208
  *
209
  * @since 1.4
210
+ * @since 1.6 converted to private with adding prefix _
211
+ * @access private
212
  */
213
+ private function _clean_wrapper( $buffer )
214
  {
215
  if ( self::$_clean_counter < 1 ) {
216
  LiteSpeed_Cache_Log::debug2( "GUI bypassed by no counter" ) ;
includes/litespeed-cache-log.class.php CHANGED
@@ -18,6 +18,8 @@ class LiteSpeed_Cache_Log
18
  private static $_prefix ;
19
  private static $_enabled = false ;
20
 
 
 
21
  /**
22
  * Log class Constructor
23
  *
@@ -44,6 +46,41 @@ class LiteSpeed_Cache_Log
44
  self::$_debug = true ;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Heartbeat control
49
  *
@@ -166,15 +203,29 @@ class LiteSpeed_Cache_Log
166
  * Direct call to log a debug message.
167
  *
168
  * @since 1.1.3
 
169
  * @access public
170
  * @param string $msg The debug message.
171
- * @param int $backtrace_limit Backtrace depth.
172
  */
173
  public static function debug( $msg, $backtrace_limit = false )
174
  {
175
- if ( self::get_enabled() ) {
176
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
177
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
 
180
  /**
@@ -190,9 +241,7 @@ class LiteSpeed_Cache_Log
190
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
191
  return ;
192
  }
193
- if ( self::get_enabled() ) {
194
- self::push( $msg, $backtrace_limit !== false ? $backtrace_limit+1 : false ) ;
195
- }
196
  }
197
 
198
  /**
18
  private static $_prefix ;
19
  private static $_enabled = false ;
20
 
21
+ const TYPE_CLEAR_LOG = 'clear_log' ;
22
+
23
  /**
24
  * Log class Constructor
25
  *
46
  self::$_debug = true ;
47
  }
48
 
49
+ /**
50
+ * Handle all request actions from main cls
51
+ *
52
+ * @since 1.6.6
53
+ * @access public
54
+ */
55
+ public static function handler()
56
+ {
57
+ $instance = self::get_instance() ;
58
+
59
+ $type = LiteSpeed_Cache_Router::verify_type() ;
60
+
61
+ switch ( $type ) {
62
+ case self::TYPE_CLEAR_LOG :
63
+ $instance->_clear_log() ;
64
+ break ;
65
+
66
+ default:
67
+ break ;
68
+ }
69
+
70
+ LiteSpeed_Cache_Admin::redirect() ;
71
+ }
72
+
73
+ /**
74
+ * Clear log file
75
+ *
76
+ * @since 1.6.6
77
+ * @access private
78
+ */
79
+ private function _clear_log()
80
+ {
81
+ Litespeed_File::save( self::$log_path, '' ) ;
82
+ }
83
+
84
  /**
85
  * Heartbeat control
86
  *
203
  * Direct call to log a debug message.
204
  *
205
  * @since 1.1.3
206
+ * @since 1.6 Added array dump as 2nd param
207
  * @access public
208
  * @param string $msg The debug message.
209
+ * @param int|array $backtrace_limit Backtrace depth, Or the array to dump
210
  */
211
  public static function debug( $msg, $backtrace_limit = false )
212
  {
213
+ if ( ! self::get_enabled() ) {
214
+ return ;
215
  }
216
+
217
+ if ( $backtrace_limit !== false ) {
218
+ if ( ! is_numeric( $backtrace_limit ) ) {
219
+ $msg .= ' --- ' . var_export( $backtrace_limit, true ) ;
220
+ self::push( $msg ) ;
221
+ return ;
222
+ }
223
+
224
+ self::push( $msg, $backtrace_limit + 1 ) ;
225
+ return ;
226
+ }
227
+
228
+ self::push( $msg ) ;
229
  }
230
 
231
  /**
241
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
242
  return ;
243
  }
244
+ self::debug( $msg, $backtrace_limit ) ;
 
 
245
  }
246
 
247
  /**
includes/litespeed-cache-optimize.class.php CHANGED
@@ -32,6 +32,7 @@ class LiteSpeed_Cache_Optimize
32
  private $cfg_js_defer_exc = false ;
33
  private $cfg_qs_rm ;
34
  private $cfg_exc_jquery ;
 
35
 
36
 
37
  private $html_foot = '' ; // The html info append to <body>
@@ -64,6 +65,7 @@ class LiteSpeed_Cache_Optimize
64
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
65
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
66
  $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
 
67
 
68
  $this->_static_request_check() ;
69
 
@@ -97,6 +99,27 @@ class LiteSpeed_Cache_Optimize
97
  }
98
  }
99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
 
102
  /**
@@ -111,6 +134,13 @@ class LiteSpeed_Cache_Optimize
111
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
112
  remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
113
  remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
 
 
 
 
 
 
 
114
  }
115
 
116
  /**
@@ -141,7 +171,7 @@ class LiteSpeed_Cache_Optimize
141
  private function _static_request_check()
142
  {
143
  // This request is for js/css_async.js
144
- if ( $this->cfg_css_async && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
145
  LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
146
 
147
  LiteSpeed_Cache_Control::set_cacheable() ;
@@ -248,7 +278,7 @@ class LiteSpeed_Cache_Optimize
248
  * @access public
249
  * @return string The content that is after optimization
250
  */
251
- public static function run( $content )
252
  {
253
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
254
  return $content ;
@@ -269,6 +299,13 @@ class LiteSpeed_Cache_Optimize
269
  }
270
  }
271
 
 
 
 
 
 
 
 
272
  LiteSpeed_Cache_Log::debug( 'Optimizer start' ) ;
273
 
274
  $instance = self::get_instance() ;
@@ -295,7 +332,7 @@ class LiteSpeed_Cache_Optimize
295
 
296
  // Parse css from content
297
  $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
298
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async ) {
299
  // To remove google fonts
300
  if ( $ggfonts_rm ) {
301
  $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
@@ -312,6 +349,8 @@ class LiteSpeed_Cache_Optimize
312
 
313
  // IF combine
314
  if ( $this->cfg_css_combine ) {
 
 
315
  $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
316
 
317
  $snippet = '' ;
@@ -322,19 +361,30 @@ class LiteSpeed_Cache_Optimize
322
  // Handle css async load
323
  if ( $this->cfg_css_async ) {
324
  // Only ignored html snippet needs async
325
- list( $noscript, $ignored_html_async ) = $this->_async_css_list( $ignored_html ) ;
326
 
327
- $noscript .= $snippet ;
328
  $snippet = '' ;
329
  foreach ( $urls as $url ) {
330
  $snippet .= "<link rel='preload' data-asynced='1' data-optimized='2' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
331
  }
332
 
333
- $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
334
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
 
 
 
 
 
 
335
  }
336
  else {
337
- $this->html_head .= implode( '', $ignored_html ) . $snippet ;
 
 
 
 
 
 
338
  }
339
 
340
  // Move all css to top
@@ -363,16 +413,30 @@ class LiteSpeed_Cache_Optimize
363
  // Handle css lazy load if not handled async loaded yet
364
  if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
365
  // async html
366
- list( $noscript, $html_list_async ) = $this->_async_css_list( $html_list ) ;
367
-
368
- // add noscript
369
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
370
 
371
  // Replace async css
372
  $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
373
 
374
  }
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  // Parse js from buffer as needed
377
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
378
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
@@ -386,6 +450,8 @@ class LiteSpeed_Cache_Optimize
386
 
387
  // IF combine
388
  if ( $this->cfg_js_combine ) {
 
 
389
  // separate head/foot js/raw html
390
  $head_js = array() ;
391
  $head_ignored_html = array() ;
@@ -401,7 +467,7 @@ class LiteSpeed_Cache_Optimize
401
  }
402
  foreach ( $ignored_html as $src => $html ) {
403
  if ( in_array( $src, $head_src_list ) ) {
404
- $head_ignored_html[] = $html ;
405
  }
406
  else {
407
  $foot_ignored_html[] = $html ;
@@ -421,7 +487,27 @@ class LiteSpeed_Cache_Optimize
421
  if ( $this->cfg_js_defer ) {
422
  $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
423
  }
424
- $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
425
 
426
  $snippet = '' ;
427
  if ( $foot_js ) {
@@ -436,7 +522,14 @@ class LiteSpeed_Cache_Optimize
436
  if ( $this->cfg_js_defer ) {
437
  $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
438
  }
439
- $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
 
 
 
 
 
 
 
440
 
441
  // Will move all js to top/bottom
442
  $this->content = str_replace( $html_list, '', $this->content ) ;
@@ -467,16 +560,26 @@ class LiteSpeed_Cache_Optimize
467
 
468
 
469
  // Append async compatibility lib to head
470
- if ( $this->cfg_css_async ) {
471
  $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
472
  $this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
473
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
474
  }
475
 
 
 
 
 
476
  // Replace html head part
477
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
478
  if ( $this->html_head ) {
479
- $this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
 
 
 
 
 
 
480
  }
481
 
482
  // Replace html foot part
@@ -493,10 +596,10 @@ class LiteSpeed_Cache_Optimize
493
  try {
494
  litespeed_load_vendor() ;
495
  $this->content = Minify_HTML::minify( $this->content ) ;
496
- $this->content .= '<!-- Page optimized by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->' ;
497
 
498
  } catch ( ErrorException $e ) {
499
- LiteSpeed_Cache_Control::debug( 'Error when optimizing HTML: ' . $e->getMessage() ) ;
500
  error_log( 'LiteSpeed Optimizer optimizing HTML Error: ' . $e->getMessage() ) ;
501
  // If failed to minify HTML, restore original content
502
  $this->content = $ori ;
@@ -556,7 +659,6 @@ class LiteSpeed_Cache_Optimize
556
  */
557
  private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
558
  {
559
- $noscript = '' ;
560
  $html_list_ori = $html_list ;
561
 
562
  $tag = $file_type === 'css' ? 'link' : 'script' ;
@@ -573,8 +675,7 @@ class LiteSpeed_Cache_Optimize
573
 
574
  // Handle css async load
575
  if ( $file_type === 'css' && $this->cfg_css_async ) {
576
- list( $noscript, $html_list ) = $this->_async_css_list( $html_list ) ;
577
- $this->html_head .= '<noscript>' . $noscript . '</noscript>' ;
578
  }
579
 
580
  // Handle js defer
@@ -631,7 +732,7 @@ class LiteSpeed_Cache_Optimize
631
 
632
  // Check if is external URL
633
  $url_parsed = parse_url( $src ) ;
634
- if ( ! $file_info = $this->_is_file_url( $src ) ) {
635
  $ignored_html[ $src ] = $html_list[ $key ] ;
636
  LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist' ) ;
637
  continue ;
@@ -659,57 +760,6 @@ class LiteSpeed_Cache_Optimize
659
  return array( $ignored_html, $src_queue_list, $file_size_list ) ;
660
  }
661
 
662
- /**
663
- * Check if an URL is a internal existing file
664
- *
665
- * @since 1.2.2
666
- * @access private
667
- * @return string|bool The real path of file OR false
668
- */
669
- private function _is_file_url( $url )
670
- {
671
- $url_parsed = parse_url( $url ) ;
672
- if ( isset( $url_parsed[ 'host' ] ) && ! LiteSpeed_Cache_Utility::internal( $url_parsed[ 'host' ] ) ) {
673
- // Check if is cdn path
674
- if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
675
- return false ;
676
- }
677
- }
678
-
679
- if ( empty( $url_parsed[ 'path' ] ) ) {
680
- return false ;
681
- }
682
-
683
- // Need to replace child blog path for assets, ref: .htaccess
684
- if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
685
- $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
686
- $replacement = PATH_CURRENT_SITE . '$2' ;
687
- $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
688
- // $current_blog = (int) get_current_blog_id() ;
689
- // $main_blog_id = (int) get_network()->site_id ;
690
- // if ( $current_blog === $main_blog_id ) {
691
- // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
692
- // }
693
- // else {
694
- // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
695
- // }
696
- }
697
-
698
- // Parse file path
699
- if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
700
- $file_path = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
701
- }
702
- else {
703
- $file_path = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
704
- }
705
- $file_path = realpath( $file_path ) ;
706
- if ( ! is_file( $file_path ) ) {
707
- return false ;
708
- }
709
-
710
- return array( $file_path, filesize( $file_path ) ) ;
711
- }
712
-
713
  /**
714
  * Run minify process and return final content
715
  *
@@ -730,7 +780,7 @@ class LiteSpeed_Cache_Optimize
730
  // Parse real file path
731
  $real_files = array() ;
732
  foreach ( $urls as $url ) {
733
- $real_file = $this->_is_file_url( $url ) ;
734
  if ( ! $real_file ) {
735
  continue ;
736
  }
@@ -820,7 +870,10 @@ class LiteSpeed_Cache_Optimize
820
  }
821
  $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
822
 
823
- if ( ! empty( $attrs[ 'data-optimized' ] ) ) {
 
 
 
824
  continue ;
825
  }
826
  if ( empty( $attrs[ 'src' ] ) ) {
@@ -869,7 +922,7 @@ class LiteSpeed_Cache_Optimize
869
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
870
  continue ;
871
  }
872
- if ( ! empty( $attrs[ 'data-optimized' ] ) ) {
873
  continue ;
874
  }
875
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
@@ -908,11 +961,10 @@ class LiteSpeed_Cache_Optimize
908
  * @since 1.3
909
  * @access private
910
  * @param array $html_list Orignal css array
911
- * @return array array( (string)noscript, (array)css_async_list )
912
  */
913
  private function _async_css_list( $html_list )
914
  {
915
- $noscript = '' ;
916
  foreach ( $html_list as $k => $ori ) {
917
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
918
  LiteSpeed_Cache_Log::debug2( 'Optm bypass: attr data-asynced exist' ) ;
@@ -924,14 +976,14 @@ class LiteSpeed_Cache_Optimize
924
  continue ;
925
  }
926
 
927
- // Append to noscript content
928
- $noscript .= $ori ;
929
  // async replacement
930
  $v = str_replace( 'stylesheet', 'preload', $ori ) ;
931
  $v = str_replace( '<link', "<link data-asynced='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
 
 
932
  $html_list[ $k ] = $v ;
933
  }
934
- return array( $noscript, $html_list ) ;
935
  }
936
 
937
  /**
@@ -1030,7 +1082,19 @@ class LiteSpeed_Cache_Optimize
1030
  return ;
1031
  }
1032
 
1033
- $uri = LiteSpeed_Cache_Utility::url2uri( $url ) ;
 
 
 
 
 
 
 
 
 
 
 
 
1034
 
1035
  if ( ! $uri ) {
1036
  return ;
@@ -1081,7 +1145,7 @@ class LiteSpeed_Cache_Optimize
1081
  $content = $this->minify_minify->serve( $this->minify_controller, $this->minify_options ) ;
1082
 
1083
  } catch ( ErrorException $e ) {
1084
- LiteSpeed_Cache_Control::debug( 'Error when serving from optimizer: ' . $e->getMessage() ) ;
1085
  error_log( 'LiteSpeed Optimizer serving Error: ' . $e->getMessage() ) ;
1086
  return false ;
1087
  }
32
  private $cfg_js_defer_exc = false ;
33
  private $cfg_qs_rm ;
34
  private $cfg_exc_jquery ;
35
+ private $cfg_ggfonts_async ;
36
 
37
 
38
  private $html_foot = '' ; // The html info append to <body>
65
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
66
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
67
  $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
68
+ $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
69
 
70
  $this->_static_request_check() ;
71
 
99
  }
100
  }
101
 
102
+ /**
103
+ * Add vary filter for Role Excludes
104
+ * @since 1.6
105
+ */
106
+ add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
107
+
108
+ }
109
+
110
+ /**
111
+ * Exclude role from optimization filter
112
+ *
113
+ * @since 1.6
114
+ * @access public
115
+ */
116
+ public function vary_add_role_exclude( $varys )
117
+ {
118
+ if ( ! LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
119
+ return $varys ;
120
+ }
121
+ $varys[ 'role_exclude_optm' ] = 1 ;
122
+ return $varys ;
123
  }
124
 
125
  /**
134
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
135
  remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
136
  remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
137
+ /**
138
+ * Added for better result
139
+ * @since 1.6.2.1
140
+ */
141
+ remove_action( 'wp_print_styles', 'print_emoji_styles' ) ;
142
+ remove_action( 'admin_print_styles', 'print_emoji_styles' ) ;
143
+ remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ) ;
144
  }
145
 
146
  /**
171
  private function _static_request_check()
172
  {
173
  // This request is for js/css_async.js
174
+ if ( ( $this->cfg_css_async || $this->cfg_ggfonts_async ) && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
175
  LiteSpeed_Cache_Log::debug( 'Optimizer start serving static file' ) ;
176
 
177
  LiteSpeed_Cache_Control::set_cacheable() ;
278
  * @access public
279
  * @return string The content that is after optimization
280
  */
281
+ public static function finalize( $content )
282
  {
283
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
284
  return $content ;
299
  }
300
  }
301
 
302
+ // Check if is exclude optm roles ( Need to set Vary too )
303
+ if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
304
+ LiteSpeed_Cache_Log::debug( 'Optimizer bypass: hit Role Excludes setting: ' . $result ) ;
305
+ return $content ;
306
+ }
307
+
308
+
309
  LiteSpeed_Cache_Log::debug( 'Optimizer start' ) ;
310
 
311
  $instance = self::get_instance() ;
332
 
333
  // Parse css from content
334
  $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
335
+ if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
336
  // To remove google fonts
337
  if ( $ggfonts_rm ) {
338
  $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
349
 
350
  // IF combine
351
  if ( $this->cfg_css_combine ) {
352
+ $enqueue_first = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY ) ;
353
+
354
  $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
355
 
356
  $snippet = '' ;
361
  // Handle css async load
362
  if ( $this->cfg_css_async ) {
363
  // Only ignored html snippet needs async
364
+ $ignored_html_async = $this->_async_css_list( $ignored_html ) ;
365
 
 
366
  $snippet = '' ;
367
  foreach ( $urls as $url ) {
368
  $snippet .= "<link rel='preload' data-asynced='1' data-optimized='2' as='style' onload='this.rel=\"stylesheet\"' href='$url' />" ;
369
  }
370
 
371
+ // enqueue combined file first
372
+ if ( $enqueue_first ) {
373
+ $this->html_head .= $snippet . implode( '', $ignored_html_async ) ;
374
+ }
375
+ else {
376
+ $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
377
+ }
378
+
379
  }
380
  else {
381
+ // enqueue combined file first
382
+ if ( $enqueue_first ) {
383
+ $this->html_head .= $snippet . implode( '', $ignored_html ) ;
384
+ }
385
+ else {
386
+ $this->html_head .= implode( '', $ignored_html ) . $snippet ;
387
+ }
388
  }
389
 
390
  // Move all css to top
413
  // Handle css lazy load if not handled async loaded yet
414
  if ( $this->cfg_css_async && ! $this->cfg_css_minify && ! $this->cfg_css_combine ) {
415
  // async html
416
+ $html_list_async = $this->_async_css_list( $html_list ) ;
 
 
 
417
 
418
  // Replace async css
419
  $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
420
 
421
  }
422
 
423
+ // Handle google fonts async
424
+ if ( ! $this->cfg_css_async && $this->cfg_ggfonts_async ) {
425
+ foreach ( $html_list as $k => $v ) {
426
+ if ( strpos( $src_list[ $k ], 'fonts.googleapis.com' ) === false ) {
427
+ unset( $html_list[ $k ] ) ;
428
+ continue ;
429
+ }
430
+
431
+ LiteSpeed_Cache_Log::debug( 'Optm: google fonts async loading: ' . $src_list[ $k ] ) ;
432
+ }
433
+ // async html
434
+ $html_list_async = $this->_async_css_list( $html_list ) ;
435
+
436
+ // Replace async css
437
+ $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
438
+ }
439
+
440
  // Parse js from buffer as needed
441
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
442
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
450
 
451
  // IF combine
452
  if ( $this->cfg_js_combine ) {
453
+ $enqueue_first = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY ) ;
454
+
455
  // separate head/foot js/raw html
456
  $head_js = array() ;
457
  $head_ignored_html = array() ;
467
  }
468
  foreach ( $ignored_html as $src => $html ) {
469
  if ( in_array( $src, $head_src_list ) ) {
470
+ $head_ignored_html[ $src ] = $html ;
471
  }
472
  else {
473
  $foot_ignored_html[] = $html ;
487
  if ( $this->cfg_js_defer ) {
488
  $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
489
  }
490
+
491
+ /**
492
+ * Enqueue combined file first
493
+ * @since 1.6
494
+ */
495
+ if ( $enqueue_first ) {
496
+ // Make jQuery to be the first one
497
+ // Suppose jQuery is in header
498
+ foreach ( $head_ignored_html as $src => $html ) {
499
+ if ( $this->_is_jquery( $src ) ) {
500
+ // jQuery should be always the first one
501
+ $this->html_head .= $html ;
502
+ unset( $head_ignored_html[ $src ] ) ;
503
+ break ;
504
+ }
505
+ }
506
+ $this->html_head .= $snippet . implode( '', $head_ignored_html ) ;
507
+ }
508
+ else {
509
+ $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
510
+ }
511
 
512
  $snippet = '' ;
513
  if ( $foot_js ) {
522
  if ( $this->cfg_js_defer ) {
523
  $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
524
  }
525
+
526
+ // enqueue combined file first
527
+ if ( $enqueue_first ) {
528
+ $this->html_foot .= $snippet . implode( '', $foot_ignored_html ) ;
529
+ }
530
+ else {
531
+ $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
532
+ }
533
 
534
  // Will move all js to top/bottom
535
  $this->content = str_replace( $html_list, '', $this->content ) ;
560
 
561
 
562
  // Append async compatibility lib to head
563
+ if ( $this->cfg_css_async || $this->cfg_ggfonts_async ) {
564
  $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
565
  $this->html_head .= "<script src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
566
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
567
  }
568
 
569
+ if ( $this->cfg_ggfonts_async ) {
570
+ $this->html_head .= '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
571
+ }
572
+
573
  // Replace html head part
574
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
575
  if ( $this->html_head ) {
576
+ // Put header content to be after charset
577
+ if ( strpos( $this->content, '<meta charset' ) !== false ) {
578
+ $this->content = preg_replace( '#<meta charset([^>]*)>#isU', '<meta charset$1>' . $this->html_head , $this->content, 1 ) ;
579
+ }
580
+ else {
581
+ $this->content = preg_replace( '#<head([^>]*)>#isU', '<head$1>' . $this->html_head , $this->content, 1 ) ;
582
+ }
583
  }
584
 
585
  // Replace html foot part
596
  try {
597
  litespeed_load_vendor() ;
598
  $this->content = Minify_HTML::minify( $this->content ) ;
599
+ $this->content .= "\n" . '<!-- Page optimized by LiteSpeed Cache on '.date('Y-m-d H:i:s').' -->' ;
600
 
601
  } catch ( ErrorException $e ) {
602
+ LiteSpeed_Cache_Log::debug( 'Error when optimizing HTML: ' . $e->getMessage() ) ;
603
  error_log( 'LiteSpeed Optimizer optimizing HTML Error: ' . $e->getMessage() ) ;
604
  // If failed to minify HTML, restore original content
605
  $this->content = $ori ;
659
  */
660
  private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
661
  {
 
662
  $html_list_ori = $html_list ;
663
 
664
  $tag = $file_type === 'css' ? 'link' : 'script' ;
675
 
676
  // Handle css async load
677
  if ( $file_type === 'css' && $this->cfg_css_async ) {
678
+ $html_list = $this->_async_css_list( $html_list ) ;
 
679
  }
680
 
681
  // Handle js defer
732
 
733
  // Check if is external URL
734
  $url_parsed = parse_url( $src ) ;
735
+ if ( ! $file_info = LiteSpeed_Cache_Utility::is_internal_file( $src ) ) {
736
  $ignored_html[ $src ] = $html_list[ $key ] ;
737
  LiteSpeed_Cache_Log::debug2( 'Optm: Abort external/non-exist' ) ;
738
  continue ;
760
  return array( $ignored_html, $src_queue_list, $file_size_list ) ;
761
  }
762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  /**
764
  * Run minify process and return final content
765
  *
780
  // Parse real file path
781
  $real_files = array() ;
782
  foreach ( $urls as $url ) {
783
+ $real_file = LiteSpeed_Cache_Utility::is_internal_file( $url ) ;
784
  if ( ! $real_file ) {
785
  continue ;
786
  }
870
  }
871
  $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
872
 
873
+ if ( isset( $attrs[ 'data-optimized' ] ) ) {
874
+ continue ;
875
+ }
876
+ if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
877
  continue ;
878
  }
879
  if ( empty( $attrs[ 'src' ] ) ) {
922
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
923
  continue ;
924
  }
925
+ if ( isset( $attrs[ 'data-optimized' ] ) ) {
926
  continue ;
927
  }
928
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
961
  * @since 1.3
962
  * @access private
963
  * @param array $html_list Orignal css array
964
+ * @return array (array)css_async_list
965
  */
966
  private function _async_css_list( $html_list )
967
  {
 
968
  foreach ( $html_list as $k => $ori ) {
969
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
970
  LiteSpeed_Cache_Log::debug2( 'Optm bypass: attr data-asynced exist' ) ;
976
  continue ;
977
  }
978
 
 
 
979
  // async replacement
980
  $v = str_replace( 'stylesheet', 'preload', $ori ) ;
981
  $v = str_replace( '<link', "<link data-asynced='1' as='style' onload='this.rel=\"stylesheet\"' ", $v ) ;
982
+ // Append to noscript content
983
+ $v .= '<noscript>' . $ori . '</noscript>' ;
984
  $html_list[ $k ] = $v ;
985
  }
986
+ return $html_list ;
987
  }
988
 
989
  /**
1082
  return ;
1083
  }
1084
 
1085
+ /**
1086
+ * For CDN enabled ones, bypass http/2 push
1087
+ * @since 1.6.2.1
1088
+ */
1089
+ if ( LiteSpeed_Cache_CDN::inc_type( $file_type ) ) {
1090
+ return ;
1091
+ }
1092
+
1093
+ /**
1094
+ * Keep QS for constance by set 2nd param to true
1095
+ * @since 1.6.2.1
1096
+ */
1097
+ $uri = LiteSpeed_Cache_Utility::url2uri( $url, true ) ;
1098
 
1099
  if ( ! $uri ) {
1100
  return ;
1145
  $content = $this->minify_minify->serve( $this->minify_controller, $this->minify_options ) ;
1146
 
1147
  } catch ( ErrorException $e ) {
1148
+ LiteSpeed_Cache_Log::debug( 'Error when serving from optimizer: ' . $e->getMessage() ) ;
1149
  error_log( 'LiteSpeed Optimizer serving Error: ' . $e->getMessage() ) ;
1150
  return false ;
1151
  }
includes/litespeed-cache-purge.class.php CHANGED
@@ -36,6 +36,7 @@ class LiteSpeed_Cache_Purge
36
  }
37
 
38
  self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
 
39
 
40
  // Send purge header immediately
41
  $curr_built = self::_build() ;
@@ -66,6 +67,8 @@ class LiteSpeed_Cache_Purge
66
  return ;
67
  }
68
 
 
 
69
  self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
70
 
71
  // Send purge header immediately
@@ -169,11 +172,13 @@ class LiteSpeed_Cache_Purge
169
  public static function purge_errors()
170
  {
171
  self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
172
- if ( ! isset( $_GET[ 'lserr' ] ) || ! in_array( $_GET[ 'lserr' ], array( '403', '404', '500' ) ) ) {
 
 
173
  return ;
174
  }
175
 
176
- self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $_GET[ 'lserr' ] ) ;
177
  }
178
 
179
  /**
36
  }
37
 
38
  self::$_pub_purge = array_merge( self::$_pub_purge, $tags ) ;
39
+ LiteSpeed_Cache_Log::debug( 'Purge: added ' . implode( ',', $tags ), 3 ) ;
40
 
41
  // Send purge header immediately
42
  $curr_built = self::_build() ;
67
  return ;
68
  }
69
 
70
+ LiteSpeed_Cache_Log::debug( 'Purge: added [private] ' . implode( ',', $tags ), 3 ) ;
71
+
72
  self::$_priv_purge = array_merge( self::$_priv_purge, $tags ) ;
73
 
74
  // Send purge header immediately
172
  public static function purge_errors()
173
  {
174
  self::add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
175
+
176
+ $type = LiteSpeed_Cache_Router::verify_type() ;
177
+ if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
178
  return ;
179
  }
180
 
181
+ self::add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
182
  }
183
 
184
  /**
includes/litespeed-cache-router.class.php CHANGED
@@ -21,10 +21,64 @@ class LiteSpeed_Cache_Router
21
  private static $_ip ;
22
  private static $_action ;
23
  private static $_is_admin_ip ;
24
- private static $_has_whm_msg ;
25
- private static $_has_msg_ruleconflict ;
26
  private static $_frontend_path ;
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
  * Get frontend path
30
  *
@@ -64,71 +118,6 @@ class LiteSpeed_Cache_Router
64
  return self::$_esi_enabled ;
65
  }
66
 
67
- /**
68
- * Check if has rule conflict notice
69
- *
70
- * @since 1.1.5
71
- * @access public
72
- * @return boolean
73
- */
74
- public static function has_msg_ruleconflict()
75
- {
76
- if ( ! isset( self::$_has_msg_ruleconflict ) ) {
77
- self::$_has_msg_ruleconflict = get_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG ) == LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ;
78
- }
79
- return self::$_has_msg_ruleconflict ;
80
- }
81
-
82
- /**
83
- * Check if has whm notice
84
- *
85
- * @since 1.1.1
86
- * @access public
87
- * @return boolean
88
- */
89
- public static function has_whm_msg()
90
- {
91
- if ( ! isset( self::$_has_whm_msg ) ) {
92
- self::$_has_whm_msg = get_transient( LiteSpeed_Cache::WHM_TRANSIENT ) == LiteSpeed_Cache::WHM_TRANSIENT_VAL ;
93
- }
94
- return self::$_has_whm_msg ;
95
- }
96
-
97
- /**
98
- * Check if has promotion notice
99
- *
100
- * @since 1.3.2
101
- * @access public
102
- * @return boolean
103
- */
104
- public static function has_promo_msg()
105
- {
106
- $promo = get_option( 'litespeed-banner-promo' ) ;
107
- if ( ! $promo ) {
108
- update_option( 'litespeed-banner-promo', time() - 86400 * 8 ) ;
109
- return false ;
110
- }
111
- if ( $promo == 'done' ) {
112
- return false ;
113
- }
114
- if ( $promo && time() - $promo < 864000 ) {
115
- return false ;
116
- }
117
- return true ;
118
- }
119
-
120
- /**
121
- * update promotion notice
122
- *
123
- * @since 1.3.2
124
- * @access public
125
- * @return boolean
126
- */
127
- public static function dismiss_promo_msg()
128
- {
129
- update_option( 'litespeed-banner-promo', ! empty( $_GET[ 'done' ] ) ? 'done' : time() ) ;
130
- }
131
-
132
  /**
133
  * Check if crawler is enabled on server level
134
  *
@@ -218,6 +207,35 @@ class LiteSpeed_Cache_Router
218
  return self::$_is_admin_ip ;
219
  }
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  /**
222
  * Check privilege and nonce for the action
223
  *
@@ -226,16 +244,17 @@ class LiteSpeed_Cache_Router
226
  */
227
  private function verify_action()
228
  {
229
- if( empty( $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ) ) {
 
230
  return ;
231
  }
232
 
233
- $action = $_REQUEST[LiteSpeed_Cache::ACTION_KEY] ;
234
  $_is_public_action = false ;
235
 
236
  // Each action must have a valid nonce unless its from admin ip and is public action
237
  // Validate requests nonce (from admin logged in page or cli)
238
- if ( ! $this->verify_nonce( $action ) && ! $this->_verify_sapi_token( $action ) ) {
239
  // check if it is from admin ip
240
  if ( ! $this->is_admin_ip() ) {
241
  LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
@@ -323,19 +342,30 @@ class LiteSpeed_Cache_Router
323
  case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
324
  case LiteSpeed_Cache::ACTION_DO_CRAWL:
325
  case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
326
- case LiteSpeed_Cache::ACTION_SAPI_PROCEED:
327
  if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
328
  self::$_action = $action ;
329
  }
330
  return ;
331
 
332
- case LiteSpeed_Cache::ACTION_SAPI_CALLBACK : // as long as it passed nonce check
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  self::$_action = $action ;
334
  return ;
335
 
336
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:
337
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
338
- case LiteSpeed_Cache::ACTION_DISMISS_PROMO:
339
  if ( self::is_ajax() ) {
340
  self::$_action = $action ;
341
  }
@@ -349,16 +379,43 @@ class LiteSpeed_Cache_Router
349
  }
350
 
351
  /**
352
- * Verify sapi token
353
  *
354
  * @since 1.5
355
  * @access private
356
  * @param string $action
357
  * @return bool
358
  */
359
- private function _verify_sapi_token( $action )
360
  {
361
- return LiteSpeed_Cache_Admin_API::sapi_token_check() && $action === LiteSpeed_Cache::ACTION_SAPI_CALLBACK ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
  }
363
 
364
  /**
@@ -412,10 +469,11 @@ class LiteSpeed_Cache_Router
412
  * Get client ip
413
  *
414
  * @since 1.1.0
415
- * @access private
 
416
  * @return string
417
  */
418
- private function get_ip()
419
  {
420
  $_ip = '' ;
421
  if ( function_exists( 'apache_request_headers' ) ) {
21
  private static $_ip ;
22
  private static $_action ;
23
  private static $_is_admin_ip ;
 
 
24
  private static $_frontend_path ;
25
 
26
+ /**
27
+ * Get user id
28
+ *
29
+ * @since 1.6.2
30
+ */
31
+ public static function get_uid()
32
+ {
33
+ if ( defined( 'LITESPEED_WP_UID' ) ) {
34
+ return LITESPEED_WP_UID ;
35
+ }
36
+
37
+ $user = wp_get_current_user() ;
38
+ $user_id = $user->ID ;
39
+
40
+ LiteSpeed_Cache_Log::debug( 'Router: get_uid: ' . $user_id, 3 ) ;
41
+
42
+ define( 'LITESPEED_WP_UID', $user_id ) ;
43
+
44
+ return LITESPEED_WP_UID ;
45
+ }
46
+
47
+ /**
48
+ * Get user role
49
+ *
50
+ * @since 1.6.2
51
+ */
52
+ public static function get_role( $uid = null )
53
+ {
54
+ if ( defined( 'LITESPEED_WP_ROLE' ) ) {
55
+ return LITESPEED_WP_ROLE ;
56
+ }
57
+
58
+ if ( $uid === null ) {
59
+ $uid = self::get_uid() ;
60
+ }
61
+
62
+ $role = false ;
63
+ if ( $uid ) {
64
+ $user = get_userdata( $uid ) ;
65
+ if ( is_array( $user->roles ) ) {
66
+ $tmp = array_values( $user->roles ) ;
67
+ $role = array_shift( $tmp ) ;
68
+ }
69
+ }
70
+ LiteSpeed_Cache_Log::debug( 'Router: get_role: ' . $role ) ;
71
+
72
+ if ( ! $role ) {
73
+ // Guest user
74
+ LiteSpeed_Cache_Log::debug( 'Router: role: guest' ) ;
75
+ }
76
+
77
+ define( 'LITESPEED_WP_ROLE', $role ) ;
78
+
79
+ return LITESPEED_WP_ROLE ;
80
+ }
81
+
82
  /**
83
  * Get frontend path
84
  *
118
  return self::$_esi_enabled ;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Check if crawler is enabled on server level
123
  *
207
  return self::$_is_admin_ip ;
208
  }
209
 
210
+ /**
211
+ * Create type value for url
212
+ *
213
+ * @since 1.6
214
+ * @access public
215
+ */
216
+ public static function build_type( $val )
217
+ {
218
+ return array( 'type' => $val ) ;
219
+ }
220
+
221
+ /**
222
+ * Get type value
223
+ *
224
+ * @since 1.6
225
+ * @access public
226
+ */
227
+ public static function verify_type()
228
+ {
229
+ if ( empty( $_REQUEST[ 'type' ] ) ) {
230
+ LiteSpeed_Cache_Log::debug( 'Router no type', 2 ) ;
231
+ return false ;
232
+ }
233
+
234
+ LiteSpeed_Cache_Log::debug( 'Router parsed type: ' . $_REQUEST[ 'type' ], 2 ) ;
235
+
236
+ return $_REQUEST[ 'type' ] ;
237
+ }
238
+
239
  /**
240
  * Check privilege and nonce for the action
241
  *
244
  */
245
  private function verify_action()
246
  {
247
+ if ( empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
248
+ LiteSpeed_Cache_Log::debug2( 'LSCWP_CTRL bypassed empty' ) ;
249
  return ;
250
  }
251
 
252
+ $action = $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ;
253
  $_is_public_action = false ;
254
 
255
  // Each action must have a valid nonce unless its from admin ip and is public action
256
  // Validate requests nonce (from admin logged in page or cli)
257
+ if ( ! $this->verify_nonce( $action ) && ! $this->_verify_sapi_passive( $action ) && ! $this->_verify_sapi_aggressive( $action ) ) {
258
  // check if it is from admin ip
259
  if ( ! $this->is_admin_ip() ) {
260
  LiteSpeed_Cache_Log::debug( 'LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
342
  case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
343
  case LiteSpeed_Cache::ACTION_DO_CRAWL:
344
  case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
345
+ case LiteSpeed_Cache::ACTION_MEDIA:
346
  if ( defined( 'LITESPEED_ON' ) && $_can_option && ! $_is_network_admin ) {
347
  self::$_action = $action ;
348
  }
349
  return ;
350
 
351
+ case LiteSpeed_Cache::ACTION_LOG:
352
+ if ( $_can_network_option || $_can_option ) {
353
+ self::$_action = $action ;
354
+ }
355
+ return ;
356
+
357
+ case LiteSpeed_Cache::ACTION_REPORT:
358
+ if ( $_can_option && ! $_is_network_admin ) {
359
+ self::$_action = $action ;
360
+ }
361
+ return ;
362
+
363
+ case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK :
364
+ case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK :
365
  self::$_action = $action ;
366
  return ;
367
 
368
+ case LiteSpeed_Cache::ACTION_DISMISS:
 
 
369
  if ( self::is_ajax() ) {
370
  self::$_action = $action ;
371
  }
379
  }
380
 
381
  /**
382
+ * Verify sapi passive callback
383
  *
384
  * @since 1.5
385
  * @access private
386
  * @param string $action
387
  * @return bool
388
  */
389
+ private function _verify_sapi_passive( $action )
390
  {
391
+ if ( $action === LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK ) {
392
+ if ( LiteSpeed_Cache_Admin_API::sapi_valiate_passive_callback() ) {
393
+ return true ;
394
+ }
395
+ exit( 'wrong passive callback' ) ;
396
+ }
397
+
398
+ return false ;
399
+ }
400
+
401
+ /**
402
+ * Verify sapi aggressive callback
403
+ *
404
+ * @since 1.6
405
+ * @access private
406
+ * @param string $action
407
+ * @return bool
408
+ */
409
+ private function _verify_sapi_aggressive( $action )
410
+ {
411
+ if ( $action === LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK ) {
412
+ if ( LiteSpeed_Cache_Admin_API::sapi_validate_aggressive_callback() ) {
413
+ return true ;
414
+ }
415
+
416
+ exit( 'wrong aggressive callback' ) ;
417
+ }
418
+ return false ;
419
  }
420
 
421
  /**
469
  * Get client ip
470
  *
471
  * @since 1.1.0
472
+ * @since 1.6.5 changed to public
473
+ * @access public
474
  * @return string
475
  */
476
+ public static function get_ip()
477
  {
478
  $_ip = '' ;
479
  if ( function_exists( 'apache_request_headers' ) ) {
includes/litespeed-cache-tag.class.php CHANGED
@@ -151,6 +151,22 @@ class LiteSpeed_Cache_Tag
151
  self::$_tags = array_merge( self::$_tags, $tags ) ;
152
  }
153
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  /**
155
  * Return tags for Admin QS
156
  *
151
  self::$_tags = array_merge( self::$_tags, $tags ) ;
152
  }
153
 
154
+ /**
155
+ * Adds private cache tags to the list of cache tags for the current page.
156
+ *
157
+ * @since 1.6.3
158
+ * @access public
159
+ * @param mixed $tags A string or array of cache tags to add to the current list.
160
+ */
161
+ public static function add_private( $tags )
162
+ {
163
+ if ( ! is_array( $tags ) ) {
164
+ $tags = array( $tags ) ;
165
+ }
166
+
167
+ self::$_tags_priv = array_merge( self::$_tags_priv, $tags ) ;
168
+ }
169
+
170
  /**
171
  * Return tags for Admin QS
172
  *
includes/litespeed-cache-task.class.php CHANGED
@@ -11,8 +11,42 @@
11
  */
12
  class LiteSpeed_Cache_Task
13
  {
14
- const CRON_ACTION_HOOK = 'litespeed_crawl_trigger' ;
15
- const CRON_FITLER = 'litespeed_crawl_filter' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  /**
18
  * Enable/Disable cron task
@@ -66,32 +100,64 @@ class LiteSpeed_Cache_Task
66
  }
67
  }
68
 
69
- if ( $is_active ) {
70
- self::schedule_filter() ;
71
- }
72
- else {
73
  self::clear() ;
74
  }
75
 
76
  }
77
 
78
  /**
79
- * Schedule cron
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  *
81
  * @since 1.1.0
82
  * @access public
83
  */
84
- public static function schedule_filter()
85
  {
86
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
87
 
88
  // Schedule event here to see if it can lost again or not
89
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK ) ) {
90
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
91
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK ) ;
92
  }
93
  }
94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  /**
96
  * Register cron interval
97
  *
@@ -99,17 +165,17 @@ class LiteSpeed_Cache_Task
99
  * @access public
100
  * @param array $schedules WP Hook
101
  */
102
- public static function lscache_cron_filter( $schedules )
103
  {
104
  $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
105
  // $wp_schedules = wp_get_schedules() ;
106
- if ( ! array_key_exists( self::CRON_FITLER, $schedules ) ) {
107
  // if ( LiteSpeed_Cache_Log::get_enabled() ) {
108
  // LiteSpeed_Cache_Log::push('Crawler cron log: ......cron filter '.$interval.' added......') ;
109
  // }
110
- $schedules[self::CRON_FITLER] = array(
111
  'interval' => $interval,
112
- 'display' => __( 'LiteSpeed Cache Custom Cron', 'litespeed-cache' ),
113
  ) ;
114
  }
115
  return $schedules ;
@@ -124,6 +190,24 @@ class LiteSpeed_Cache_Task
124
  public static function clear()
125
  {
126
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
127
- wp_clear_scheduled_hook( self::CRON_ACTION_HOOK ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  }
 
129
  }
11
  */
12
  class LiteSpeed_Cache_Task
13
  {
14
+ private static $_instance ;
15
+
16
+ const CRON_ACTION_HOOK_CRAWLER = 'litespeed_crawl_trigger' ;
17
+ const CRON_ACTION_HOOK_IMGOPTM = 'litespeed_imgoptm_trigger' ;
18
+ const CRON_FITLER_CRAWLER = 'litespeed_crawl_filter' ;
19
+ const CRON_FITLER_IMGOPTM = 'litespeed_imgoptm_filter' ;
20
+
21
+ /**
22
+ * Init
23
+ *
24
+ * @since 1.6
25
+ * @access private
26
+ */
27
+ private function __construct()
28
+ {
29
+ LiteSpeed_Cache_Log::debug2( 'Task init' ) ;
30
+
31
+ // Register crawler cron
32
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
33
+ // keep cron intval filter
34
+ self::schedule_filter_crawler() ;
35
+
36
+ // cron hook
37
+ add_action( self::CRON_ACTION_HOOK_CRAWLER, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
38
+ }
39
+
40
+ // Register img optimization fetch ( always fetch immediately )
41
+ if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_OPTM_CRON_OFF ) && LiteSpeed_Cache_Media::check_need_pull() ) {
42
+ self::schedule_filter_imgoptm() ;
43
+
44
+ add_action( self::CRON_ACTION_HOOK_IMGOPTM, 'LiteSpeed_Cache_Media::pull_optimized_img' ) ;
45
+ }
46
+ else {
47
+ // wp_clear_scheduled_hook( self::CRON_ACTION_HOOK_IMGOPTM ) ;
48
+ }
49
+ }
50
 
51
  /**
52
  * Enable/Disable cron task
100
  }
101
  }
102
 
103
+ if ( ! $is_active ) {
 
 
 
104
  self::clear() ;
105
  }
106
 
107
  }
108
 
109
  /**
110
+ * Schedule cron img optimization
111
+ *
112
+ * @since 1.6.1
113
+ * @access public
114
+ */
115
+ public static function schedule_filter_imgoptm()
116
+ {
117
+ add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter_imgoptm' ) ;
118
+
119
+ // Schedule event here to see if it can lost again or not
120
+ if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_IMGOPTM ) ) {
121
+ LiteSpeed_Cache_Log::debug( 'Cron log: ......img optimization cron hook register......' ) ;
122
+ wp_schedule_event( time(), self::CRON_FITLER_IMGOPTM, self::CRON_ACTION_HOOK_IMGOPTM ) ;
123
+ }
124
+ }
125
+
126
+ /**
127
+ * Schedule cron crawler
128
  *
129
  * @since 1.1.0
130
  * @access public
131
  */
132
+ public static function schedule_filter_crawler()
133
  {
134
+ add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter_crawler' ) ;
135
 
136
  // Schedule event here to see if it can lost again or not
137
+ if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_CRAWLER ) ) {
138
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
139
+ wp_schedule_event( time(), self::CRON_FITLER_CRAWLER, self::CRON_ACTION_HOOK_CRAWLER ) ;
140
  }
141
  }
142
 
143
+ /**
144
+ * Register cron interval imgoptm
145
+ *
146
+ * @since 1.6.1
147
+ * @access public
148
+ * @param array $schedules WP Hook
149
+ */
150
+ public static function lscache_cron_filter_imgoptm( $schedules )
151
+ {
152
+ if ( ! array_key_exists( self::CRON_FITLER_IMGOPTM, $schedules ) ) {
153
+ $schedules[ self::CRON_FITLER_IMGOPTM ] = array(
154
+ 'interval' => 60,
155
+ 'display' => __( 'LiteSpeed Cache Custom Cron ImgOptm', 'litespeed-cache' ),
156
+ ) ;
157
+ }
158
+ return $schedules ;
159
+ }
160
+
161
  /**
162
  * Register cron interval
163
  *
165
  * @access public
166
  * @param array $schedules WP Hook
167
  */
168
+ public static function lscache_cron_filter_crawler( $schedules )
169
  {
170
  $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
171
  // $wp_schedules = wp_get_schedules() ;
172
+ if ( ! array_key_exists( self::CRON_FITLER_CRAWLER, $schedules ) ) {
173
  // if ( LiteSpeed_Cache_Log::get_enabled() ) {
174
  // LiteSpeed_Cache_Log::push('Crawler cron log: ......cron filter '.$interval.' added......') ;
175
  // }
176
+ $schedules[ self::CRON_FITLER_CRAWLER ] = array(
177
  'interval' => $interval,
178
+ 'display' => __( 'LiteSpeed Cache Custom Cron Crawler', 'litespeed-cache' ),
179
  ) ;
180
  }
181
  return $schedules ;
190
  public static function clear()
191
  {
192
  LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
193
+ wp_clear_scheduled_hook( self::CRON_ACTION_HOOK_CRAWLER ) ;
194
+ }
195
+
196
+
197
+ /**
198
+ * Get the current instance object.
199
+ *
200
+ * @since 1.6
201
+ * @access public
202
+ * @return Current class instance.
203
+ */
204
+ public static function get_instance()
205
+ {
206
+ if ( ! isset( self::$_instance ) ) {
207
+ self::$_instance = new self() ;
208
+ }
209
+
210
+ return self::$_instance ;
211
  }
212
+
213
  }
includes/litespeed-cache-utility.class.php CHANGED
@@ -11,6 +11,101 @@
11
  */
12
  class LiteSpeed_Cache_Utility
13
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  /**
15
  * Parse attributes from string
16
  *
@@ -23,7 +118,7 @@ class LiteSpeed_Cache_Utility
23
  public static function parse_attr( $str )
24
  {
25
  $attrs = array() ;
26
- preg_match_all( '#(\w+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
27
  foreach ( $matches as $match ) {
28
  $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
29
  }
@@ -129,13 +224,20 @@ class LiteSpeed_Cache_Utility
129
  * Convert URL to URI
130
  *
131
  * @since 1.2.2
 
132
  * @access public
133
  */
134
- public static function url2uri( $url )
135
  {
136
  $url = trim( $url ) ;
137
  $uri = @parse_url( $url, PHP_URL_PATH ) ;
138
- return $uri ;
 
 
 
 
 
 
139
  }
140
 
141
  /**
@@ -213,17 +315,18 @@ class LiteSpeed_Cache_Utility
213
  *
214
  * Assumes user capabilities are already checked.
215
  *
 
216
  * @access public
217
  * @param string $action The LSCWP_CTRL action to do in the url.
218
- * @param string $ajax_action AJAX call's action
219
- * @param string $append_str The appending string to url
220
  * @return string The built url.
221
  */
222
- public static function build_url( $action, $ajax_action = false, $append_str = false, $page = null )
223
  {
224
  $prefix = '?' ;
225
 
226
- if ( $ajax_action === false ) {
227
  if ( $page ) {
228
  // If use admin url
229
  if ( $page === true ) {
@@ -256,7 +359,7 @@ class LiteSpeed_Cache_Utility
256
  }
257
  }
258
  else {
259
- $combined = 'admin-ajax.php?action=' . $ajax_action . '&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
260
  }
261
 
262
  if ( is_network_admin() ) {
@@ -267,12 +370,93 @@ class LiteSpeed_Cache_Utility
267
  }
268
  $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
269
 
270
- if ( $append_str ) {
271
- $url .= '&' . $append_str ;
 
 
 
 
 
 
272
  }
273
 
274
  return $url ;
275
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  }
277
 
278
 
11
  */
12
  class LiteSpeed_Cache_Utility
13
  {
14
+
15
+ /**
16
+ * Set seconds/timestamp to readable format
17
+ *
18
+ * @since 1.6.5
19
+ * @access public
20
+ */
21
+ public static function readable_time( $seconds_or_timestamp, $timeout = 3600 )
22
+ {
23
+
24
+ if ( strlen( $seconds_or_timestamp ) == 10 ) {
25
+ $seconds = time() - $seconds_or_timestamp ;
26
+ if ( $seconds > $timeout ) {
27
+ return date( 'm/d/Y H:i:s', $seconds_or_timestamp + LITESPEED_TIME_OFFSET ) ;
28
+ }
29
+ }
30
+ else {
31
+ $seconds = $seconds_or_timestamp ;
32
+ }
33
+
34
+ $res = '';
35
+ if ( $seconds > 86400 ) {
36
+ $num = floor( $seconds / 86400 ) ;
37
+ $res .= $num . 'd ' ;
38
+ $seconds %= 86400 ;
39
+ }
40
+
41
+ if ( $seconds > 3600 ) {
42
+ if ( $res ) {
43
+ $res .= ', ' ;
44
+ }
45
+ $num = floor( $seconds / 3600 ) ;
46
+ $res .= $num . 'h ' ;
47
+ $seconds %= 3600 ;
48
+ }
49
+
50
+ if ( $seconds > 60 ) {
51
+ if ( $res ) {
52
+ $res .= ', ' ;
53
+ }
54
+ $num = floor( $seconds / 60 ) ;
55
+ $res .= $num . 'm ' ;
56
+ $seconds %= 60 ;
57
+ }
58
+
59
+ if ( $seconds > 0 ) {
60
+ $res .= $seconds . 's ' ;
61
+ }
62
+
63
+ $res = sprintf( __( ' %s ago ', 'litespeed-cache' ), $res ) ;
64
+
65
+ return $res ;
66
+ }
67
+
68
+
69
+ /**
70
+ * Convert array to string
71
+ *
72
+ * @since 1.6
73
+ * @access public
74
+ * @return string
75
+ */
76
+ public static function arr2str( $arr )
77
+ {
78
+ if ( ! is_array( $arr ) ) {
79
+ return $arr ;
80
+ }
81
+
82
+ return base64_encode( serialize( $arr ) ) ;
83
+ }
84
+
85
+ /**
86
+ * Get human readable size
87
+ *
88
+ * @since 1.6
89
+ * @access public
90
+ * @return string
91
+ */
92
+ public static function real_size( $filesize )
93
+ {
94
+ if ( $filesize >= 1073741824 ) {
95
+ $filesize = round( $filesize / 1073741824 * 100 ) / 100 . 'G' ;
96
+ }
97
+ elseif ( $filesize >= 1048576 ) {
98
+ $filesize = round( $filesize / 1048576 * 100 ) / 100 . 'M' ;
99
+ }
100
+ elseif ( $filesize >= 1024 ) {
101
+ $filesize = round( $filesize / 1024 * 100 ) / 100 . 'K' ;
102
+ }
103
+ else {
104
+ $filesize = $filesize . 'B' ;
105
+ }
106
+ return $filesize ;
107
+ }
108
+
109
  /**
110
  * Parse attributes from string
111
  *
118
  public static function parse_attr( $str )
119
  {
120
  $attrs = array() ;
121
+ preg_match_all( '#([\w-]+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
122
  foreach ( $matches as $match ) {
123
  $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
124
  }
224
  * Convert URL to URI
225
  *
226
  * @since 1.2.2
227
+ * @since 1.6.2.1 Added 2nd param keep_qs
228
  * @access public
229
  */
230
+ public static function url2uri( $url, $keep_qs = false )
231
  {
232
  $url = trim( $url ) ;
233
  $uri = @parse_url( $url, PHP_URL_PATH ) ;
234
+ $qs = @parse_url( $url, PHP_URL_QUERY ) ;
235
+
236
+ if ( ! $keep_qs || ! $qs ) {
237
+ return $uri ;
238
+ }
239
+
240
+ return $uri . '?' . $qs ;
241
  }
242
 
243
  /**
315
  *
316
  * Assumes user capabilities are already checked.
317
  *
318
+ * @since 1.6 Changed order of 2nd&3rd param, changed 3rd param `append_str` to 2nd `type`
319
  * @access public
320
  * @param string $action The LSCWP_CTRL action to do in the url.
321
+ * @param string $is_ajax if is AJAX call or not
322
+ * @param string $type The appending type to url
323
  * @return string The built url.
324
  */
325
+ public static function build_url( $action, $type = false, $is_ajax = false, $page = null )
326
  {
327
  $prefix = '?' ;
328
 
329
+ if ( ! $is_ajax ) {
330
  if ( $page ) {
331
  // If use admin url
332
  if ( $page === true ) {
359
  }
360
  }
361
  else {
362
+ $combined = 'admin-ajax.php?action=litespeed_ajax&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
363
  }
364
 
365
  if ( is_network_admin() ) {
370
  }
371
  $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
372
 
373
+ if ( $type ) {
374
+ // Remove potential param `type` from url
375
+ $url = parse_url( htmlspecialchars_decode( $url ) ) ;
376
+ parse_str( $url[ 'query' ], $query ) ;
377
+ $url[ 'query' ] = http_build_query( array_merge( $query, LiteSpeed_Cache_Router::build_type( $type ) ) ) ;
378
+ self::compatibility() ;
379
+ $url = http_build_url( $url ) ;
380
+ $url = htmlspecialchars( $url ) ;
381
  }
382
 
383
  return $url ;
384
  }
385
+
386
+ /**
387
+ * Check if an URL is a internal existing file
388
+ *
389
+ * @since 1.2.2
390
+ * @since 1.6.2 Moved here from optm.cls due to usage of media.cls
391
+ * @access public
392
+ * @return string|bool The real path of file OR false
393
+ */
394
+ public static function is_internal_file( $url )
395
+ {
396
+ $url_parsed = parse_url( $url ) ;
397
+ if ( isset( $url_parsed[ 'host' ] ) && ! self::internal( $url_parsed[ 'host' ] ) ) {
398
+ // Check if is cdn path
399
+ // Do this to avoid user hardcoded src in tpl
400
+ if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
401
+ LiteSpeed_Cache_Log::debug2( 'Utility: external' ) ;
402
+ return false ;
403
+ }
404
+ }
405
+
406
+ if ( empty( $url_parsed[ 'path' ] ) ) {
407
+ return false ;
408
+ }
409
+
410
+ // Need to replace child blog path for assets, ref: .htaccess
411
+ if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
412
+ $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
413
+ $replacement = PATH_CURRENT_SITE . '$2' ;
414
+ $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
415
+ // $current_blog = (int) get_current_blog_id() ;
416
+ // $main_blog_id = (int) get_network()->site_id ;
417
+ // if ( $current_blog === $main_blog_id ) {
418
+ // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
419
+ // }
420
+ // else {
421
+ // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
422
+ // }
423
+ }
424
+
425
+ // Parse file path
426
+ /**
427
+ * Trying to fix pure /.htaccess rewrite to /wordpress case
428
+ *
429
+ * Add `define( 'LITESPEED_WP_REALPATH', '/wordpress' ) ;` in wp-config.php in this case
430
+ *
431
+ * @internal #611001 - Combine & Minify not working?
432
+ * @since 1.6.3
433
+ */
434
+ if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
435
+ if ( defined( 'LITESPEED_WP_REALPATH' ) ) {
436
+ $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . LITESPEED_WP_REALPATH . $url_parsed[ 'path' ] ;
437
+ }
438
+ else {
439
+ $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
440
+ }
441
+ }
442
+ else {
443
+ $file_path_ori = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
444
+ }
445
+
446
+ $file_path = realpath( $file_path_ori ) ;
447
+ if ( ! is_file( $file_path ) ) {
448
+ LiteSpeed_Cache_Log::debug2( 'Utility: file not exist: ' . $file_path_ori ) ;
449
+ return false ;
450
+ }
451
+
452
+ return array( $file_path, filesize( $file_path ) ) ;
453
+ }
454
+
455
+
456
+
457
+
458
+
459
+
460
  }
461
 
462
 
includes/litespeed-cache-vary.class.php CHANGED
@@ -28,9 +28,6 @@ class LiteSpeed_Cache_Vary
28
  {
29
  // logged in user
30
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
31
- // Make sure the cookie value is corrent
32
- self::add_logged_in() ;
33
-
34
  // If not esi, check cache logged-in user setting
35
  if ( ! LiteSpeed_Cache_Router::esi_enabled() ) {
36
  // If cache logged-in, then init cacheable to private
@@ -52,15 +49,12 @@ class LiteSpeed_Cache_Vary
52
  }
53
 
54
  // register logout hook to clear login status
55
- add_action( 'clear_auth_cookie', 'LiteSpeed_Cache_Vary::remove_logged_in' ) ;
56
 
57
  }
58
  else {
59
- // Make sure the cookie value is corrent
60
- self::remove_logged_in() ;
61
-
62
  // Set vary cookie for logging in user, otherwise the user will hit public with vary=0 (guest version)
63
- add_action( 'set_logged_in_cookie', 'LiteSpeed_Cache_Vary::add_logged_in', 10, 4 ) ;
64
  add_action( 'wp_login', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
65
 
66
  LiteSpeed_Cache_Control::init_cacheable() ;
@@ -76,6 +70,15 @@ class LiteSpeed_Cache_Vary
76
  // Set vary cookie for commenter.
77
  add_action('set_comment_cookies', array( $this, 'append_commenter' ) ) ;
78
 
 
 
 
 
 
 
 
 
 
79
  /******** Below to the end is only for cookie name setting check ********/
80
  // Get specific cookie name
81
  $db_cookie = false ;
@@ -189,83 +192,158 @@ class LiteSpeed_Cache_Vary
189
  * Append user status with logged in
190
  *
191
  * @since 1.1.3
 
192
  * @access public
193
  */
194
- public static function add_logged_in( $logged_in_cookie = false, $expire = false, $expiration = false, $user_id = false )
195
  {
 
196
  // If the cookie is lost somehow, set it
197
- $vary = self::generate_vary( $user_id ) ;
198
- $current_vary = self::has_vary() ;
199
- if ( $current_vary !== $vary && $current_vary !== 'commenter' ) {
200
- // $_COOKIE[ self::$_vary_name ] = $vary ; // not needed
201
-
202
- // save it
203
- if ( ! $expire ) {
204
- $expire = time() + 2 * DAY_IN_SECONDS ;
205
- }
206
- self::_cookie( $vary, $expire ) ;
207
- LiteSpeed_Cache_Control::set_nocache( 'adding logged in status' ) ;
208
- }
209
  }
210
 
211
  /**
212
  * Remove user logged in status
213
  *
214
  * @since 1.1.3
 
215
  * @access public
216
  */
217
- public static function remove_logged_in()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  {
219
- // If the cookie is set and not commenter, unset it.
 
 
 
 
 
 
 
 
 
 
220
  $current_vary = self::has_vary() ;
221
- if ( $current_vary && $current_vary !== 'commenter' ) {
222
- // remove logged in status from global var
223
- // unset( $_COOKIE[ self::$_vary_name ] ) ; // not needed
224
 
225
  // save it
226
- self::_cookie() ;
227
- LiteSpeed_Cache_Control::set_nocache( 'removing logged in status' ) ;
 
 
 
 
228
  }
229
  }
230
 
231
  /**
232
- * Get user vary tag based on admin_bar & role
233
  *
234
- * @since 1.2.0
235
- * @access public
 
 
 
 
236
  */
237
- public static function generate_vary( $user_id )
238
  {
239
- if ( ! $user_id ) {
240
- $user = wp_get_current_user() ;
241
- $user_id = $user->ID ;
242
- LiteSpeed_Cache_Log::debug2( 'getting user_id: ' . $user_id ) ;
 
 
 
243
  }
244
- $vary = array( 'logged-in' => 1 ) ;
245
  // get user's group id
246
- $user = get_userdata( $user_id ) ;
247
- if ( empty( $user->roles[ 0 ] ) ) {
248
- // Guest user
249
- LiteSpeed_Cache_Log::debug( 'Vary role id: failed, guest' ) ;
250
- return false ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
251
  }
 
 
 
252
 
253
- // parge role group from settings
254
- $gid = $user->roles[ 0 ] ?: 0 ;
255
- if ( $role_group = LiteSpeed_Cache_Config::get_instance()->in_vary_group( $gid ) ) {
256
- $vary[ 'role' ] = $role_group ;
257
- LiteSpeed_Cache_Log::debug2( 'Vary role group: ' . $gid ) ;
258
  }
259
 
260
- // Get admin bar set
261
- // see @_get_admin_bar_pref()
262
- $pref = get_user_option( 'show_admin_bar_front', $user_id ) ;
263
- LiteSpeed_Cache_Log::debug2( 'Vary show_admin_bar_front: ' . $pref ) ;
264
- $admin_bar = $pref === false || $pref === 'true' ;
 
265
 
266
- if ( $admin_bar ) {
267
- $vary[ 'admin_bar' ] = 1 ;
268
- LiteSpeed_Cache_Log::debug2( 'Vary admin bar : true' ) ;
269
  }
270
 
271
  ksort( $vary ) ;
@@ -274,16 +352,13 @@ class LiteSpeed_Cache_Vary
274
  $res[] = $key . ':' . $val ;
275
  }
276
 
277
- if ( ! $res ) {
278
- return false ;
279
- }
280
-
281
  $res = implode( ';', $res ) ;
282
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
283
  return $res ;
284
  }
285
  // Encrypt in production
286
  return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
 
287
  }
288
 
289
  /**
@@ -363,7 +438,7 @@ class LiteSpeed_Cache_Vary
363
  * @access private
364
  * @return array An array of all vary cookies currently added.
365
  */
366
- private static function _format_vary_cookies()
367
  {
368
  if ( empty(self::$_vary_cookies) ) {
369
  return false ;
@@ -389,15 +464,31 @@ class LiteSpeed_Cache_Vary
389
  * @return mixed false if the user has the postpass cookie. Empty string
390
  * if the post is not password protected. Vary header otherwise.
391
  */
392
- public static function output()
393
  {
394
- if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
395
- return ;
396
- }
397
- $tp_cookies = self::_format_vary_cookies() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
398
  global $post ;
399
  if ( ! empty($post->post_password) ) {
400
  if ( isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
 
401
  // If user has password cookie, do not cache
402
  LiteSpeed_Cache_Control::set_nocache('password protected vary') ;
403
  return ;
@@ -407,9 +498,12 @@ class LiteSpeed_Cache_Vary
407
  }
408
 
409
  if ( empty($tp_cookies) ) {
 
410
  return ;
411
  }
 
412
  return self::X_HEADER . ': ' . implode(',', $tp_cookies) ;
 
413
  }
414
 
415
  /**
28
  {
29
  // logged in user
30
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
 
 
 
31
  // If not esi, check cache logged-in user setting
32
  if ( ! LiteSpeed_Cache_Router::esi_enabled() ) {
33
  // If cache logged-in, then init cacheable to private
49
  }
50
 
51
  // register logout hook to clear login status
52
+ add_action( 'clear_auth_cookie', array( $this, 'remove_logged_in' ) ) ;
53
 
54
  }
55
  else {
 
 
 
56
  // Set vary cookie for logging in user, otherwise the user will hit public with vary=0 (guest version)
57
+ add_action( 'set_logged_in_cookie', array( $this, 'add_logged_in' ), 10, 4 ) ;
58
  add_action( 'wp_login', 'LiteSpeed_Cache_Purge::purge_on_logout' ) ;
59
 
60
  LiteSpeed_Cache_Control::init_cacheable() ;
70
  // Set vary cookie for commenter.
71
  add_action('set_comment_cookies', array( $this, 'append_commenter' ) ) ;
72
 
73
+ /**
74
+ * Don't change for REST call because they don't carry on user info usually
75
+ * @since 1.6.7
76
+ */
77
+ add_action( 'rest_api_init', function(){
78
+ LiteSpeed_Cache_Log::debug( 'Vary: Rest API init disabled vary change' ) ;
79
+ add_filter( 'litespeed_can_change_vary', '__return_false' ) ;
80
+ } ) ;
81
+
82
  /******** Below to the end is only for cookie name setting check ********/
83
  // Get specific cookie name
84
  $db_cookie = false ;
192
  * Append user status with logged in
193
  *
194
  * @since 1.1.3
195
+ * @since 1.6.2 Removed static referral
196
  * @access public
197
  */
198
+ public function add_logged_in( $logged_in_cookie = false, $expire = false, $expiration = false, $uid = false )
199
  {
200
+ LiteSpeed_Cache_Log::debug( 'Vary: add_logged_in' ) ;
201
  // If the cookie is lost somehow, set it
202
+ $this->_update_default_vary( $uid, $expire ) ;
 
 
 
 
 
 
 
 
 
 
 
203
  }
204
 
205
  /**
206
  * Remove user logged in status
207
  *
208
  * @since 1.1.3
209
+ * @since 1.6.2 Removed static referral
210
  * @access public
211
  */
212
+ public function remove_logged_in()
213
+ {
214
+ LiteSpeed_Cache_Log::debug( 'Vary: remove_logged_in' ) ;
215
+ // Force update vary to remove login status
216
+ $this->_update_default_vary( -1 ) ;
217
+ }
218
+
219
+ /**
220
+ * Check if can change default vary
221
+ *
222
+ * @since 1.6.2
223
+ * @access private
224
+ */
225
+ private function can_change_vary()
226
+ {
227
+ // Don't change for ajax due to ajax not sending webp header
228
+ /**
229
+ * Added `litespeed_ajax_vary` hook for 3rd party to set vary when doing ajax call ( Login With Ajax )
230
+ * @since 1.6.6
231
+ */
232
+ if ( LiteSpeed_Cache_Router::is_ajax() && ! apply_filters( 'litespeed_ajax_vary', false ) ) {
233
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to ajax call' ) ;
234
+ return false ;
235
+ }
236
+
237
+ /**
238
+ * POST request can set vary to fix #820789 login "loop" guest cache issue
239
+ * @since 1.6.5
240
+ */
241
+ if ( $_SERVER["REQUEST_METHOD"] !== 'GET' && $_SERVER["REQUEST_METHOD"] !== 'POST' ) {
242
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to method not get/post' ) ;
243
+ return false ;
244
+ }
245
+
246
+ if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
247
+ LiteSpeed_Cache_Log::debug( 'Vary: can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
248
+ return false ;
249
+ }
250
+
251
+ return true ;
252
+ }
253
+
254
+ /**
255
+ * Update default vary
256
+ *
257
+ * @since 1.6.2
258
+ * @since 1.6.6.1 Add ran check to make it only run once ( No run multiple times due to login process doesn't have valid uid from router::get_uid )
259
+ * @access private
260
+ */
261
+ private function _update_default_vary( $uid = false, $expire = false )
262
  {
263
+ // Make sure header output only run once
264
+ if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
265
+ define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
266
+ }
267
+ else {
268
+ LiteSpeed_Cache_Log::debug2( "Vary: _update_default_vary bypassed due to run already" ) ;
269
+ return ;
270
+ }
271
+
272
+ // If the cookie is lost somehow, set it
273
+ $vary = $this->_finalize_default_vary( $uid ) ;
274
  $current_vary = self::has_vary() ;
275
+ if ( $current_vary !== $vary && $current_vary !== 'commenter' && $this->can_change_vary() ) {
276
+ // $_COOKIE[ self::$_vary_name ] = $vary ; // not needed
 
277
 
278
  // save it
279
+ if ( ! $expire ) {
280
+ $expire = time() + 2 * DAY_IN_SECONDS ;
281
+ }
282
+ self::_cookie( $vary, $expire ) ;
283
+ LiteSpeed_Cache_Log::debug( "Vary: set_cookie ---> $vary" ) ;
284
+ LiteSpeed_Cache_Control::set_nocache( 'changing default vary' . " $current_vary => $vary" ) ;
285
  }
286
  }
287
 
288
  /**
289
+ * Finalize default vary
290
  *
291
+ * Get user vary tag based on admin_bar & role
292
+ *
293
+ * NOTE: Login process will also call this because it does not call wp hook as normal page loading
294
+ *
295
+ * @since 1.6.2
296
+ * @access private
297
  */
298
+ private function _finalize_default_vary( $uid = false )
299
  {
300
+ $vary = array() ;
301
+
302
+ if ( ! $uid ) {
303
+ $uid = LiteSpeed_Cache_Router::get_uid() ;
304
+ }
305
+ else {
306
+ LiteSpeed_Cache_Log::debug( 'Vary: uid: ' . $uid ) ;
307
  }
308
+
309
  // get user's group id
310
+ $role = LiteSpeed_Cache_Router::get_role( $uid ) ;
311
+
312
+ if ( $uid > 0 && $role ) {
313
+ $vary[ 'logged-in' ] = 1 ;
314
+
315
+ // parse role group from settings
316
+ if ( $role_group = LiteSpeed_Cache_Config::get_instance()->in_vary_group( $role ) ) {
317
+ $vary[ 'role' ] = $role_group ;
318
+ }
319
+
320
+ // Get admin bar set
321
+ // see @_get_admin_bar_pref()
322
+ $pref = get_user_option( 'show_admin_bar_front', $uid ) ;
323
+ LiteSpeed_Cache_Log::debug2( 'Vary: show_admin_bar_front: ' . $pref ) ;
324
+ $admin_bar = $pref === false || $pref === 'true' ;
325
+
326
+ if ( $admin_bar ) {
327
+ $vary[ 'admin_bar' ] = 1 ;
328
+ LiteSpeed_Cache_Log::debug2( 'Vary: admin bar : true' ) ;
329
+ }
330
+
331
  }
332
+ else {
333
+ // Guest user
334
+ LiteSpeed_Cache_Log::debug( 'Vary: role id: failed, guest' ) ;
335
 
 
 
 
 
 
336
  }
337
 
338
+ /**
339
+ * Add filter
340
+ * @since 1.6 Added for Role Excludes for optimization cls
341
+ * @since 1.6.2 Hooked to webp
342
+ */
343
+ $vary = apply_filters( 'litespeed_vary', $vary ) ;
344
 
345
+ if ( ! $vary ) {
346
+ return false ;
 
347
  }
348
 
349
  ksort( $vary ) ;
352
  $res[] = $key . ':' . $val ;
353
  }
354
 
 
 
 
 
355
  $res = implode( ';', $res ) ;
356
  if ( LiteSpeed_Cache_Log::get_enabled() ) {
357
  return $res ;
358
  }
359
  // Encrypt in production
360
  return md5( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::HASH ) . $res ) ;
361
+
362
  }
363
 
364
  /**
438
  * @access private
439
  * @return array An array of all vary cookies currently added.
440
  */
441
+ private function _format_vary_cookies()
442
  {
443
  if ( empty(self::$_vary_cookies) ) {
444
  return false ;
464
  * @return mixed false if the user has the postpass cookie. Empty string
465
  * if the post is not password protected. Vary header otherwise.
466
  */
467
+ public static function finalize()
468
  {
469
+ return self::get_instance()->_finalize() ;
470
+
471
+ }
472
+
473
+ private function _finalize()
474
+ {
475
+ // Finalize default vary
476
+ $this->_update_default_vary() ;
477
+
478
+ /**
479
+ * Non caccheable page can still set vary ( for logged in process )
480
+ * @since 1.6.6.1
481
+ */
482
+ // if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
483
+ // LiteSpeed_Cache_Log::debug2( 'Vary: bypass finalize due to not cacheable' ) ;
484
+ // return false;
485
+ // }
486
+
487
+ $tp_cookies = $this->_format_vary_cookies() ;
488
  global $post ;
489
  if ( ! empty($post->post_password) ) {
490
  if ( isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
491
+ LiteSpeed_Cache_Log::debug( 'Vary: finalize bypassed due to password protected vary ' ) ;
492
  // If user has password cookie, do not cache
493
  LiteSpeed_Cache_Control::set_nocache('password protected vary') ;
494
  return ;
498
  }
499
 
500
  if ( empty($tp_cookies) ) {
501
+ LiteSpeed_Cache_Log::debug( 'Vary: finalize bypassed due to no vary ' ) ;
502
  return ;
503
  }
504
+
505
  return self::X_HEADER . ': ' . implode(',', $tp_cookies) ;
506
+
507
  }
508
 
509
  /**
includes/litespeed-cache.class.php CHANGED
@@ -19,15 +19,13 @@ class LiteSpeed_Cache
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
- const PLUGIN_VERSION = '1.5' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
26
  const NONCE_NAME = 'LSCWP_NONCE' ;
27
  const ACTION_KEY = 'LSCWP_CTRL' ;
28
- const ACTION_DISMISS_WHM = 'dismiss-whm' ;
29
- const ACTION_DISMISS_EXPIRESDEFAULT = 'dismiss-ExpiresDefault' ;
30
- const ACTION_DISMISS_PROMO = 'dismiss-promo' ;
31
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
32
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
33
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
@@ -54,9 +52,12 @@ class LiteSpeed_Cache
54
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
55
 
56
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
 
57
 
58
- const ACTION_SAPI_PROCEED = 'sapi_proceed' ;
59
- const ACTION_SAPI_CALLBACK = 'sapi_callback' ;
 
 
60
 
61
  const WHM_TRANSIENT = 'lscwp_whm_install' ;
62
  const WHM_TRANSIENT_VAL = 'whm_install' ;
@@ -107,20 +108,32 @@ class LiteSpeed_Cache
107
  LiteSpeed_Cache_Log::debug( 'Purge Queue found&sent: ' . $purge_queue ) ;
108
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
109
  }
 
 
 
 
 
 
110
  }
111
 
112
  /**
113
  * The plugin initializer.
114
  *
115
- * This function checks if the cache is enabled and ready to use, then
116
- * determines what actions need to be set up based on the type of user
117
- * and page accessed. Output is buffered if the cache is enabled.
118
  *
119
  * @since 1.0.0
120
  * @access public
121
  */
122
  public function init()
123
  {
 
 
 
 
 
 
124
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
125
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
126
  }
@@ -147,6 +160,12 @@ class LiteSpeed_Cache
147
  // Check minify file request in the very beginning
148
  LiteSpeed_Cache_Optimize::get_instance() ;
149
 
 
 
 
 
 
 
150
  // 1. Init vary
151
  // 2. Init cacheable status
152
  LiteSpeed_Cache_Vary::get_instance() ;
@@ -157,14 +176,8 @@ class LiteSpeed_Cache
157
  // Load public hooks
158
  $this->load_public_actions() ;
159
 
160
- // load cron task for crawler
161
- if ( self::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
162
- // keep cron intval filter
163
- LiteSpeed_Cache_Task::schedule_filter() ;
164
-
165
- // cron hook
166
- add_action( LiteSpeed_Cache_Task::CRON_ACTION_HOOK, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
167
- }
168
 
169
  // Load 3rd party hooks
170
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
@@ -274,28 +287,32 @@ class LiteSpeed_Cache
274
  $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
275
  break;
276
 
277
- case LiteSpeed_Cache::ACTION_DISMISS_WHM:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
278
- LiteSpeed_Cache_Activation::dismiss_whm() ;
279
  break ;
280
 
281
- case LiteSpeed_Cache::ACTION_DISMISS_EXPIRESDEFAULT:
282
- update_option( LiteSpeed_Cache_Admin_Display::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
283
  break ;
284
 
285
- case LiteSpeed_Cache::ACTION_DISMISS_PROMO:
286
- LiteSpeed_Cache_Router::dismiss_promo_msg() ;
287
  break ;
288
 
289
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
290
- $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
291
  break ;
292
 
293
- case LiteSpeed_Cache::ACTION_SAPI_PROCEED:
294
- $msg = LiteSpeed_Cache_Admin_API::sapi_proceed() ;
295
  break ;
296
 
297
- case LiteSpeed_Cache::ACTION_SAPI_CALLBACK:
298
- LiteSpeed_Cache_Admin_API::sapi_callback() ;
 
 
 
 
299
  break ;
300
 
301
  default:
@@ -409,6 +426,11 @@ class LiteSpeed_Cache
409
  return ;
410
  }
411
 
 
 
 
 
 
412
  if ( $buffer === null ) {
413
  $buffer = ob_get_contents() ;
414
  }
@@ -450,18 +472,18 @@ class LiteSpeed_Cache
450
  $this->_check_is_html( $buffer ) ;
451
 
452
  // Image lazy load check
453
- $buffer = LiteSpeed_Cache_Media::run( $buffer ) ;
454
 
455
  /**
456
  * Clean wrapper mainly for esi block
457
  * NOTE: this needs to be before optimizer to avoid wrapper being removed
458
  * @since 1.4
459
  */
460
- $buffer = LiteSpeed_Cache_GUI::clean_wrapper( $buffer ) ;
461
 
462
- $buffer = LiteSpeed_Cache_Optimize::run( $buffer ) ;
463
 
464
- $buffer = LiteSpeed_Cache_CDN::run( $buffer ) ;
465
 
466
  $this->send_headers( true ) ;
467
 
@@ -498,7 +520,7 @@ class LiteSpeed_Cache
498
  // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
499
  LiteSpeed_Cache_Control::finalize() ;
500
 
501
- $vary_header = LiteSpeed_Cache_Vary::output() ;
502
 
503
  // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
504
  $tag_header = LiteSpeed_Cache_Tag::output() ;
@@ -513,13 +535,17 @@ class LiteSpeed_Cache
513
  $control_header = LiteSpeed_Cache_Control::output() ;
514
 
515
  // Init comment info
516
- $running_info_showing = defined( 'LITESPEED_IS_HTML' ) || defined( 'LSCACHE_IS_ESI' ) ;
517
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
518
  $running_info_showing = false ;
519
  LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
520
  }
521
 
522
  if ( $running_info_showing ) {
 
 
 
 
523
  $this->footer_comment .= sprintf(
524
  '<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
525
  defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
19
  private static $_instance ;
20
 
21
  const PLUGIN_NAME = 'litespeed-cache' ;
22
+ const PLUGIN_VERSION = '1.6.7' ;
23
 
24
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
25
 
26
  const NONCE_NAME = 'LSCWP_NONCE' ;
27
  const ACTION_KEY = 'LSCWP_CTRL' ;
28
+ const ACTION_DISMISS = 'dismiss' ;
 
 
29
  const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
30
  const ACTION_SAVE_SETTINGS = 'save-settings' ;
31
  const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
52
  const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
53
 
54
  const ACTION_DB_OPTIMIZE = 'db_optimize' ;
55
+ const ACTION_LOG = 'log' ;
56
 
57
+ const ACTION_MEDIA = 'media' ;
58
+ const ACTION_REPORT = 'report' ;
59
+ const ACTION_SAPI_PASSIVE_CALLBACK = 'sapi_passive_callback' ;
60
+ const ACTION_SAPI_AGGRESSIVE_CALLBACK = 'sapi_aggressive_callback' ;
61
 
62
  const WHM_TRANSIENT = 'lscwp_whm_install' ;
63
  const WHM_TRANSIENT_VAL = 'whm_install' ;
108
  LiteSpeed_Cache_Log::debug( 'Purge Queue found&sent: ' . $purge_queue ) ;
109
  delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
110
  }
111
+
112
+ /**
113
+ * Added hook before init
114
+ * @since 1.6.6
115
+ */
116
+ do_action( 'litespeed_before_init' ) ;
117
  }
118
 
119
  /**
120
  * The plugin initializer.
121
  *
122
+ * This function checks if the cache is enabled and ready to use, then determines what actions need to be set up based on the type of user and page accessed. Output is buffered if the cache is enabled.
123
+ *
124
+ * NOTE: WP user doesn't init yet
125
  *
126
  * @since 1.0.0
127
  * @access public
128
  */
129
  public function init()
130
  {
131
+ /**
132
+ * Added hook before init
133
+ * @since 1.6.6
134
+ */
135
+ do_action( 'litespeed_init' ) ;
136
+
137
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
138
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
139
  }
160
  // Check minify file request in the very beginning
161
  LiteSpeed_Cache_Optimize::get_instance() ;
162
 
163
+ /**
164
+ * Register vary filter
165
+ * @since 1.6.2
166
+ */
167
+ LiteSpeed_Cache_Control::get_instance() ;
168
+
169
  // 1. Init vary
170
  // 2. Init cacheable status
171
  LiteSpeed_Cache_Vary::get_instance() ;
176
  // Load public hooks
177
  $this->load_public_actions() ;
178
 
179
+ // load cron tasks
180
+ LiteSpeed_Cache_Task::get_instance() ;
 
 
 
 
 
 
181
 
182
  // Load 3rd party hooks
183
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
287
  $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
288
  break;
289
 
290
+ case LiteSpeed_Cache::ACTION_DISMISS:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
291
+ LiteSpeed_Cache_GUI::dismiss() ;
292
  break ;
293
 
294
+ case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
295
+ $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
296
  break ;
297
 
298
+ case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK:
299
+ LiteSpeed_Cache_Admin_API::sapi_passive_callback() ;
300
  break ;
301
 
302
+ case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK:
303
+ LiteSpeed_Cache_Admin_API::sapi_aggressive_callback() ;
304
  break ;
305
 
306
+ case LiteSpeed_Cache::ACTION_MEDIA:
307
+ $msg = LiteSpeed_Cache_Media::handler() ;
308
  break ;
309
 
310
+ case LiteSpeed_Cache::ACTION_LOG:
311
+ $msg = LiteSpeed_Cache_Log::handler() ;
312
+ break ;
313
+
314
+ case LiteSpeed_Cache::ACTION_REPORT:
315
+ $msg = LiteSpeed_Cache_Admin_Report::handler() ;
316
  break ;
317
 
318
  default:
426
  return ;
427
  }
428
 
429
+ if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
430
+ LiteSpeed_Cache_Log::debug2( 'CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
431
+ return ;
432
+ }
433
+
434
  if ( $buffer === null ) {
435
  $buffer = ob_get_contents() ;
436
  }
472
  $this->_check_is_html( $buffer ) ;
473
 
474
  // Image lazy load check
475
+ $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
476
 
477
  /**
478
  * Clean wrapper mainly for esi block
479
  * NOTE: this needs to be before optimizer to avoid wrapper being removed
480
  * @since 1.4
481
  */
482
+ $buffer = LiteSpeed_Cache_GUI::finalize( $buffer ) ;
483
 
484
+ $buffer = LiteSpeed_Cache_Optimize::finalize( $buffer ) ;
485
 
486
+ $buffer = LiteSpeed_Cache_CDN::finalize( $buffer ) ;
487
 
488
  $this->send_headers( true ) ;
489
 
520
  // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
521
  LiteSpeed_Cache_Control::finalize() ;
522
 
523
+ $vary_header = LiteSpeed_Cache_Vary::finalize() ;
524
 
525
  // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
526
  $tag_header = LiteSpeed_Cache_Tag::output() ;
535
  $control_header = LiteSpeed_Cache_Control::output() ;
536
 
537
  // Init comment info
538
+ $running_info_showing = ( defined( 'LITESPEED_IS_HTML' ) && LITESPEED_IS_HTML ) || ( defined( 'LSCACHE_IS_ESI' ) && LSCACHE_IS_ESI ) ;
539
  if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
540
  $running_info_showing = false ;
541
  LiteSpeed_Cache_Log::debug( 'ESI silence' ) ;
542
  }
543
 
544
  if ( $running_info_showing ) {
545
+ // Give one more break to avoid ff crash
546
+ if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
547
+ $this->footer_comment .= "\n" ;
548
+ }
549
  $this->footer_comment .= sprintf(
550
  '<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
551
  defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
js/lazyload.lib.js CHANGED
@@ -124,7 +124,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
124
  }
125
  };
126
 
127
- var supportsClassList = !!document.body.classList;
128
 
129
  var addClass = function addClass(element, className) {
130
  if (supportsClassList) {
124
  }
125
  };
126
 
127
+ var supportsClassList = 'classList' in document.createElement('p');
128
 
129
  var addClass = function addClass(element, className) {
130
  if (supportsClassList) {
js/lazyload.min.js CHANGED
@@ -1,2 +1,2 @@
1
- var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null},t=function(e,t){return e.getAttribute("data-"+t)},n=function(e,t,n){return e.setAttribute("data-"+t,n)},s=function(e){return e.filter(function(e){return!t(e,"was-processed")})},r=function(e,t){var n=new e(t),s=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(s)},o=function(e,n){var s=n.data_srcset,r=n.data_sizes,o=e.parentElement;if("PICTURE"===o.tagName)for(var a,i=0;a=o.children[i];i+=1)if("SOURCE"===a.tagName){var c=t(a,s);c&&a.setAttribute("srcset",c);var l=t(a,r);l&&a.setAttribute("sizes",l)}},a=function(e,n){var s=n.data_src,r=n.data_srcset,a=n.data_sizes,i=e.tagName,c=t(e,s);if("IMG"===i){o(e,n);var l=t(e,r);l&&e.setAttribute("srcset",l);var u=t(e,a);return u&&e.setAttribute("sizes",u),void(c&&e.setAttribute("src",c))}"IFRAME"!==i?c&&(e.style.backgroundImage='url("'+c+'")'):c&&e.setAttribute("src",c)},i=!!document.body.classList,c=function(e,t){i?e.classList.add(t):e.className+=(e.className?" ":"")+t},l=function(e,t){i?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},u=function(e,t){e&&e(t)},d=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},f=function(e,t){var n=function n(r){_(r,!0,t),d(e,n,s)},s=function s(r){_(r,!1,t),d(e,n,s)};e.addEventListener("load",n),e.addEventListener("error",s)},_=function(e,t,n){var s=e.target;l(s,n.class_loading),c(s,t?n.class_loaded:n.class_error),u(t?n.callback_load:n.callback_error,s)},v=function(e,t){["IMG","IFRAME"].indexOf(e.tagName)>-1&&(f(e,t),c(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),u(t.callback_set,e)},b=function(t,n){this._settings=_extends({},e,t),this._setObserver(),this.update(n)};b.prototype={_setObserver:function(){var e=this;if("IntersectionObserver"in window){var t=this._settings;this._observer=new IntersectionObserver(function(n){n.forEach(function(n){if(n.intersectionRatio>0){var s=n.target;v(s,t),e._observer.unobserve(s)}}),e._elements=s(e._elements)},{root:t.container===document?null:t.container,rootMargin:t.threshold+"px"})}},update:function(e){var t=this,n=this._settings,r=e||n.container.querySelectorAll(n.elements_selector);this._elements=s(Array.prototype.slice.call(r)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){v(e,n)}),this._elements=s(this._elements))},destroy:function(){var e=this;this._observer&&(s(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var m=window.lazyLoadOptions;return m&&function(e,t){if(t.length)for(var n,s=0;n=t[s];s+=1)r(e,n);else r(e,t)}(b,m),b});
2
  !function(e,t){"use strict";var n,a,d=function(){n=new LazyLoad({elements_selector:"[data-lazyloaded]"}),a=function(){n.update()},e.MutationObserver&&new MutationObserver(a).observe(t.documentElement,{childList:!0,subtree:!0,attributes:!0})};e.addEventListener?e.addEventListener("load",d,!1):e.attachEvent("onload",d)}(window,document);
1
+ var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var e={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null},t=function(e,t){return e.getAttribute("data-"+t)},n=function(e,t,n){return e.setAttribute("data-"+t,n)},s=function(e){return e.filter(function(e){return!t(e,"was-processed")})},r=function(e,t){var n=new e(t),s=new CustomEvent("LazyLoad::Initialized",{detail:{instance:n}});window.dispatchEvent(s)},o=function(e,n){var s=n.data_srcset,r=n.data_sizes,o=e.parentElement;if("PICTURE"===o.tagName)for(var a,i=0;a=o.children[i];i+=1)if("SOURCE"===a.tagName){var c=t(a,s);c&&a.setAttribute("srcset",c);var l=t(a,r);l&&a.setAttribute("sizes",l)}},a=function(e,n){var s=n.data_src,r=n.data_srcset,a=n.data_sizes,i=e.tagName,c=t(e,s);if("IMG"===i){o(e,n);var l=t(e,r);l&&e.setAttribute("srcset",l);var u=t(e,a);return u&&e.setAttribute("sizes",u),void(c&&e.setAttribute("src",c))}"IFRAME"!==i?c&&(e.style.backgroundImage='url("'+c+'")'):c&&e.setAttribute("src",c)},i="classList"in document.createElement("p"),c=function(e,t){i?e.classList.add(t):e.className+=(e.className?" ":"")+t},l=function(e,t){i?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},u=function(e,t){e&&e(t)},d=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},f=function(e,t){var n=function n(r){_(r,!0,t),d(e,n,s)},s=function s(r){_(r,!1,t),d(e,n,s)};e.addEventListener("load",n),e.addEventListener("error",s)},_=function(e,t,n){var s=e.target;l(s,n.class_loading),c(s,t?n.class_loaded:n.class_error),u(t?n.callback_load:n.callback_error,s)},v=function(e,t){["IMG","IFRAME"].indexOf(e.tagName)>-1&&(f(e,t),c(e,t.class_loading)),a(e,t),n(e,"was-processed",!0),u(t.callback_set,e)},m=function(t,n){this._settings=_extends({},e,t),this._setObserver(),this.update(n)};m.prototype={_setObserver:function(){var e=this;if("IntersectionObserver"in window){var t=this._settings;this._observer=new IntersectionObserver(function(n){n.forEach(function(n){if(n.intersectionRatio>0){var s=n.target;v(s,t),e._observer.unobserve(s)}}),e._elements=s(e._elements)},{root:t.container===document?null:t.container,rootMargin:t.threshold+"px"})}},update:function(e){var t=this,n=this._settings,r=e||n.container.querySelectorAll(n.elements_selector);this._elements=s(Array.prototype.slice.call(r)),this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):(this._elements.forEach(function(e){v(e,n)}),this._elements=s(this._elements))},destroy:function(){var e=this;this._observer&&(s(this._elements).forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null}};var b=window.lazyLoadOptions;return b&&function(e,t){if(t.length)for(var n,s=0;n=t[s];s+=1)r(e,n);else r(e,t)}(m,b),m});
2
  !function(e,t){"use strict";var n,a,d=function(){n=new LazyLoad({elements_selector:"[data-lazyloaded]"}),a=function(){n.update()},e.MutationObserver&&new MutationObserver(a).observe(t.documentElement,{childList:!0,subtree:!0,attributes:!0})};e.addEventListener?e.addEventListener("load",d,!1):e.attachEvent("onload",d)}(window,document);
js/litespeed-cache-admin.js CHANGED
@@ -98,13 +98,6 @@ var _litespeed_dots ;
98
  $('[data-purgeby='+this.value+']').show() ;
99
  }) ;
100
 
101
- // Select All and Copy to Clipboard
102
- $("#litespeed_cache_report_copy").click(function() {
103
- $('#litespeed-report').select() ;
104
- document.execCommand('copy') ;
105
- $('#copy_select_all_span').fadeIn('slow').delay(1000).fadeOut('slow') ;
106
- }) ;
107
-
108
  // Settings->General->Enable mobile view
109
  $('#conf_mobileview_enabled_1').click(function() {
110
  if($(this).is(':checked')){
98
  $('[data-purgeby='+this.value+']').show() ;
99
  }) ;
100
 
 
 
 
 
 
 
 
101
  // Settings->General->Enable mobile view
102
  $('#conf_mobileview_enabled_1').click(function() {
103
  if($(this).is(':checked')){
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.5\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2017-10-17 18:43:22+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -12,8 +12,16 @@ msgstr ""
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
- #: admin/admin-api.class.php:153
16
- msgid "Generate the key from server successfully"
 
 
 
 
 
 
 
 
17
  msgstr ""
18
 
19
  #: admin/litespeed-cache-admin-display.class.php:140
@@ -21,7 +29,7 @@ msgid "Manage"
21
  msgstr ""
22
 
23
  #: admin/litespeed-cache-admin-display.class.php:142
24
- #: admin/litespeed-cache-admin-display.class.php:237
25
  msgid "Settings"
26
  msgstr ""
27
 
@@ -29,43 +37,47 @@ msgstr ""
29
  msgid "Edit .htaccess"
30
  msgstr ""
31
 
32
- #: admin/litespeed-cache-admin-display.class.php:148
33
- msgid "Information"
34
  msgstr ""
35
 
36
- #: admin/litespeed-cache-admin-display.class.php:152 admin/tpl/info.php:10
37
- #: admin/tpl/settings.php:28
38
  msgid "Crawler"
39
  msgstr ""
40
 
41
- #: admin/litespeed-cache-admin-display.class.php:156
42
- msgid "Environment Report"
43
  msgstr ""
44
 
45
- #: admin/litespeed-cache-admin-display.class.php:160
46
  #: admin/tpl/setting/settings_debug.php:10
47
  msgid "Debug Log"
48
  msgstr ""
49
 
50
- #: admin/litespeed-cache-admin-display.class.php:257
51
  msgid ""
52
  "It is recommended that LiteSpeed Cache be purged after updating a plugin."
53
  msgstr ""
54
 
55
- #: admin/litespeed-cache-admin-display.class.php:297
56
  msgid "LiteSpeed Cache Purge All"
57
  msgstr ""
58
 
59
- #: admin/litespeed-cache-admin-display.class.php:806
60
- #: admin/tpl/setting/settings_optimize.php:240
 
 
 
61
  msgid "ON"
62
  msgstr ""
63
 
64
- #: admin/litespeed-cache-admin-display.class.php:810
 
 
65
  msgid "OFF"
66
  msgstr ""
67
 
68
- #: admin/litespeed-cache-admin-display.class.php:843
69
  msgid "Recommended value: %s"
70
  msgstr ""
71
 
@@ -285,57 +297,61 @@ msgstr ""
285
  msgid "%s file did not find a place to insert define."
286
  msgstr ""
287
 
288
- #: admin/litespeed-cache-admin-optimize.class.php:144
289
  msgid "Clean all successfully."
290
  msgstr ""
291
 
292
- #: admin/litespeed-cache-admin-optimize.class.php:151
293
  msgid "Clean post revisions successfully."
294
  msgstr ""
295
 
296
- #: admin/litespeed-cache-admin-optimize.class.php:155
297
  msgid "Clean auto drafts successfully."
298
  msgstr ""
299
 
300
- #: admin/litespeed-cache-admin-optimize.class.php:159
301
  msgid "Clean trashed posts and pages successfully."
302
  msgstr ""
303
 
304
- #: admin/litespeed-cache-admin-optimize.class.php:163
305
  msgid "Clean spam comments successfully."
306
  msgstr ""
307
 
308
- #: admin/litespeed-cache-admin-optimize.class.php:167
309
  msgid "Clean trashed comments successfully."
310
  msgstr ""
311
 
312
- #: admin/litespeed-cache-admin-optimize.class.php:171
313
  msgid "Clean trackbacks and pingbacks successfully."
314
  msgstr ""
315
 
316
- #: admin/litespeed-cache-admin-optimize.class.php:175
317
  msgid "Clean expired transients successfully."
318
  msgstr ""
319
 
320
- #: admin/litespeed-cache-admin-optimize.class.php:179
321
  msgid "Clean all transients successfully."
322
  msgstr ""
323
 
324
- #: admin/litespeed-cache-admin-optimize.class.php:189
325
  msgid "Optimized all tables."
326
  msgstr ""
327
 
328
- #: admin/litespeed-cache-admin-optimize.class.php:194
329
  msgid "Clean all CSS/JS optimizer data successfully."
330
  msgstr ""
331
 
332
- #: admin/litespeed-cache-admin-rules.class.php:657
 
 
 
 
333
  msgid ""
334
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
335
  "%2$s"
336
  msgstr ""
337
 
338
- #: admin/litespeed-cache-admin-rules.class.php:855
339
  msgid "File Saved."
340
  msgstr ""
341
 
@@ -348,6 +364,7 @@ msgid "Site options saved."
348
  msgstr ""
349
 
350
  #: admin/litespeed-cache-admin-settings.class.php:258
 
351
  msgid "Default Public Cache"
352
  msgstr ""
353
 
@@ -375,225 +392,225 @@ msgstr ""
375
  msgid "500"
376
  msgstr ""
377
 
378
- #: admin/litespeed-cache-admin-settings.class.php:590
379
  #: admin/tpl/setting/settings_debug.php:75
380
  msgid "Log File Size Limit"
381
  msgstr ""
382
 
383
- #: admin/litespeed-cache-admin-settings.class.php:656
384
  #: admin/tpl/setting/settings_crawler.php:10
385
  msgid "Delay"
386
  msgstr ""
387
 
388
- #: admin/litespeed-cache-admin-settings.class.php:657
389
  #: admin/tpl/setting/settings_crawler.php:22
390
  msgid "Run Duration"
391
  msgstr ""
392
 
393
- #: admin/litespeed-cache-admin-settings.class.php:658
394
  msgid "Cron Interval"
395
  msgstr ""
396
 
397
- #: admin/litespeed-cache-admin-settings.class.php:659
398
  msgid "Whole Interval"
399
  msgstr ""
400
 
401
- #: admin/litespeed-cache-admin-settings.class.php:660
402
  #: admin/tpl/setting/settings_crawler.php:58
403
  msgid "Threads"
404
  msgstr ""
405
 
406
- #: admin/litespeed-cache-admin.class.php:203
407
  msgid ""
408
  "For this scenario only, the network admin may uncheck \"Check Advanced Cache"
409
  "\" in LiteSpeed Cache settings."
410
  msgstr ""
411
 
412
- #: admin/litespeed-cache-admin.class.php:205
413
  msgid ""
414
  "For this scenario only, please uncheck \"Check Advanced Cache\" in LiteSpeed "
415
  "Cache settings."
416
  msgstr ""
417
 
418
- #: admin/litespeed-cache-admin.class.php:207
419
  msgid ""
420
  "Please disable/deactivate any other Full Page Cache solutions that are "
421
  "currently being used."
422
  msgstr ""
423
 
424
- #: admin/litespeed-cache-admin.class.php:208
425
  msgid ""
426
  "LiteSpeed Cache does work with other cache solutions, but only their non-"
427
  "page caching offerings—such as minifying css/js files."
428
  msgstr ""
429
 
430
- #: admin/tpl/crawler.php:14 admin/tpl/crawler.php:80
431
  msgid "LiteSpeed Cache Crawler"
432
  msgstr ""
433
 
434
- #: admin/tpl/crawler.php:22
435
  msgid "Crawler File"
436
  msgstr ""
437
 
438
- #: admin/tpl/crawler.php:24
439
  msgid "Generate Crawler File"
440
  msgstr ""
441
 
442
- #: admin/tpl/crawler.php:29
443
  msgid "Generated at %s"
444
  msgstr ""
445
 
446
- #: admin/tpl/crawler.php:33
447
  msgid ""
448
  "On click, this will create a crawler sitemap file in plugin directory %s."
449
  msgstr ""
450
 
451
- #: admin/tpl/crawler.php:43
452
  msgid "%d hours"
453
  msgstr ""
454
 
455
- #: admin/tpl/crawler.php:46
456
  msgid "%d hour"
457
  msgstr ""
458
 
459
- #: admin/tpl/crawler.php:53
460
  msgid "%d minutes"
461
  msgstr ""
462
 
463
- #: admin/tpl/crawler.php:56
464
  msgid "%d minute"
465
  msgstr ""
466
 
467
- #: admin/tpl/crawler.php:60
468
  msgid "Crawler Cron"
469
  msgstr ""
470
 
471
- #: admin/tpl/crawler.php:63 admin/tpl/setting/settings_optimize.php:9
472
- #: admin/tpl/settings.php:117
473
  msgid "WARNING"
474
  msgstr ""
475
 
476
- #: admin/tpl/crawler.php:64
477
  msgid ""
478
  "The crawler feature is not enabled on the LiteSpeed server. Please consult "
479
  "your server admin."
480
  msgstr ""
481
 
482
- #: admin/tpl/crawler.php:65
483
  msgid ""
484
  "See <a %s>Introduction for Enabling the Crawler</a> for detailed infomation."
485
  msgstr ""
486
 
487
- #: admin/tpl/crawler.php:70
488
  msgid "Cron Name"
489
  msgstr ""
490
 
491
- #: admin/tpl/crawler.php:71
492
  msgid "Run Frequency"
493
  msgstr ""
494
 
495
- #: admin/tpl/crawler.php:72
496
  msgid "Last Status"
497
  msgstr ""
498
 
499
- #: admin/tpl/crawler.php:73
500
  msgid "Activation"
501
  msgstr ""
502
 
503
- #: admin/tpl/crawler.php:74
504
  msgid "Actions"
505
  msgstr ""
506
 
507
- #: admin/tpl/crawler.php:88 admin/tpl/crawler.php:93
508
  msgid "The current sitemap crawl started at %s"
509
  msgstr ""
510
 
511
- #: admin/tpl/crawler.php:96
512
  msgid "The next complete sitemap crawl will start at %s"
513
  msgstr ""
514
 
515
- #: admin/tpl/crawler.php:110
516
  msgid "The last complete run cost %s seconds"
517
  msgstr ""
518
 
519
- #: admin/tpl/crawler.php:120
520
  msgid "Is running"
521
  msgstr ""
522
 
523
- #: admin/tpl/crawler.php:136 admin/tpl/setting/settings_general.php:30
524
  msgid "Enable"
525
  msgstr ""
526
 
527
- #: admin/tpl/crawler.php:136 admin/tpl/esi_widget_edit.php:58
528
  #: admin/tpl/setting/settings_general.php:24
529
  msgid "Disable"
530
  msgstr ""
531
 
532
- #: admin/tpl/crawler.php:143
533
  msgid "Reset position"
534
  msgstr ""
535
 
536
- #: admin/tpl/crawler.php:146
537
  msgid "Manually run"
538
  msgstr ""
539
 
540
- #: admin/tpl/crawler.php:150
541
  msgid "<b>Last interval:</b> %s"
542
  msgstr ""
543
 
544
- #: admin/tpl/crawler.php:156
545
  msgid "<b>Ended reason:</b> %s"
546
  msgstr ""
547
 
548
- #: admin/tpl/crawler.php:162
549
  msgid "<b>Last crawled:</b> %s item(s)"
550
  msgstr ""
551
 
552
- #: admin/tpl/crawler.php:170
553
  msgid "Run frequency is set by the Interval Between Runs setting."
554
  msgstr ""
555
 
556
- #: admin/tpl/crawler.php:171
557
  msgid "Only one crawler can run concurrently."
558
  msgstr ""
559
 
560
- #: admin/tpl/crawler.php:172
561
  msgid ""
562
  "If both the cron and manual run start at a similar time, the first one to "
563
  "start will run."
564
  msgstr ""
565
 
566
- #: admin/tpl/crawler.php:173
567
  msgid ""
568
  "Please follow <a %s>Hooking WP-Cron Into the System Task Scheduler</a> to "
569
  "create the system cron task."
570
  msgstr ""
571
 
572
- #: admin/tpl/crawler.php:178
573
  msgid "Watch Crawler Status"
574
  msgstr ""
575
 
576
- #: admin/tpl/crawler.php:185
577
  msgid "Show crawler status"
578
  msgstr ""
579
 
580
- #: admin/tpl/crawler.php:203
581
  msgid "No crawler meta file generated yet"
582
  msgstr ""
583
 
584
- #: admin/tpl/crawler.php:208
585
  msgid "Sitemap Generation Blacklist"
586
  msgstr ""
587
 
588
- #: admin/tpl/crawler.php:217 admin/tpl/edit_htaccess.php:68
589
  msgid "Save"
590
  msgstr ""
591
 
592
- #: admin/tpl/crawler.php:221
593
  msgid "Current blacklist has %s item(s)."
594
  msgstr ""
595
 
596
- #: admin/tpl/crawler.php:222
597
  msgid ""
598
  "All Urls which returned no-cache tags will be added here, after the initial "
599
  "crawling."
@@ -603,6 +620,10 @@ msgstr ""
603
  msgid "LiteSpeed Cache Debug Log Viewer"
604
  msgstr ""
605
 
 
 
 
 
606
  #: admin/tpl/edit_htaccess.php:31
607
  msgid "LiteSpeed Cache Edit .htaccess"
608
  msgstr ""
@@ -637,7 +658,7 @@ msgid ""
637
  "changed."
638
  msgstr ""
639
 
640
- #: admin/tpl/esi_widget_edit.php:30 admin/tpl/setting/settings_esi.php:35
641
  msgid "Enable ESI"
642
  msgstr ""
643
 
@@ -663,7 +684,8 @@ msgstr ""
663
  #: admin/tpl/setting/settings_general.php:108
664
  #: admin/tpl/setting/settings_general.php:121
665
  #: admin/tpl/setting/settings_general.php:134
666
- #: admin/tpl/setting/settings_optimize.php:119
 
667
  msgid "seconds"
668
  msgstr ""
669
 
@@ -675,218 +697,191 @@ msgstr ""
675
  msgid "A TTL of 0 indicates do not cache."
676
  msgstr ""
677
 
678
- #: admin/tpl/inc/admin_footer.php:5
679
- msgid ""
680
- "Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like "
681
- "us!"
682
  msgstr ""
683
 
684
- #: admin/tpl/inc/admin_footer.php:8
685
- msgid ""
686
- "If there are any questions that are not answered in the <a %s>FAQs</a>, do "
687
- "not hesitate to ask them on the <a %s>support forum</a>."
688
  msgstr ""
689
 
690
- #: admin/tpl/inc/banner_promo.php:14
691
- msgid "Welcome to LiteSpeed"
692
  msgstr ""
693
 
694
- #: admin/tpl/inc/banner_promo.php:17
695
- msgid "Thank you for using LiteSpeed."
696
  msgstr ""
697
 
698
- #: admin/tpl/inc/banner_promo.php:19
699
- msgid ""
700
- "If you have any questions, please do not hesitate to let us know in <a "
701
- "%s>our support forum</a> or by <a %s>submitting a ticket with us</a>."
702
  msgstr ""
703
 
704
- #: admin/tpl/inc/banner_promo.php:26
705
- msgid ""
706
- "This plugin is created with love by LiteSpeed. Your rating is the simplest "
707
- "way to support us. We really appreciate it!"
708
  msgstr ""
709
 
710
- #: admin/tpl/inc/banner_promo.php:29
711
- msgid "Sure I'd love to!"
712
  msgstr ""
713
 
714
- #: admin/tpl/inc/banner_promo.php:30
715
- msgid "I've already left a review"
716
  msgstr ""
717
 
718
- #: admin/tpl/inc/banner_promo.php:31
719
- msgid "Maybe later"
720
  msgstr ""
721
 
722
- #: admin/tpl/inc/check_cache_disabled.php:10
723
- msgid ""
724
- "WARNING: LiteSpeed cache is disabled. The functionalities here can not work."
725
  msgstr ""
726
 
727
- #: admin/tpl/inc/help_tabs.php:7
728
- msgid "Overview"
729
  msgstr ""
730
 
731
- #: admin/tpl/inc/help_tabs.php:9
732
- msgid "LiteSpeed Cache is a page cache built into LiteSpeed Web Server."
733
  msgstr ""
734
 
735
- #: admin/tpl/inc/help_tabs.php:10
736
  msgid ""
737
- "This plugin communicates with LiteSpeed Web Server to let it know which "
738
- "pages are cacheable and when to purge them."
739
  msgstr ""
740
 
741
- #: admin/tpl/inc/help_tabs.php:11
742
- msgid ""
743
- "A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be "
744
- "installed and enabled."
745
  msgstr ""
746
 
747
- #: admin/tpl/inc/help_tabs.php:22
748
- msgid "For more information:"
749
  msgstr ""
750
 
751
- #: admin/tpl/inc/help_tabs.php:24
752
- msgid "Support Forum"
753
  msgstr ""
754
 
755
- #: admin/tpl/inc/show_display_installed.php:5
756
- msgid "LiteSpeed Cache plugin is installed!"
757
  msgstr ""
758
 
759
- #: admin/tpl/inc/show_display_installed.php:6
760
- msgid ""
761
- "This message indicates that the plugin was installed by the server admin."
762
  msgstr ""
763
 
764
- #: admin/tpl/inc/show_display_installed.php:7
765
- msgid ""
766
- "The LiteSpeed Cache plugin is used to cache pages - a simple way to improve "
767
- "the performance of the site."
768
  msgstr ""
769
 
770
- #: admin/tpl/inc/show_display_installed.php:8
771
- msgid ""
772
- "However, there is no way of knowing all the possible customizations that "
773
- "were implemented."
774
  msgstr ""
775
 
776
- #: admin/tpl/inc/show_display_installed.php:9
777
  msgid ""
778
- "For that reason, please test the site to make sure everything still "
779
- "functions properly."
780
  msgstr ""
781
 
782
- #: admin/tpl/inc/show_display_installed.php:11
783
- msgid "Examples of test cases include:"
784
  msgstr ""
785
 
786
- #: admin/tpl/inc/show_display_installed.php:13
787
- msgid "Visit the site while logged out."
788
  msgstr ""
789
 
790
- #: admin/tpl/inc/show_display_installed.php:14
791
- msgid "Create a post, make sure the front page is accurate."
792
  msgstr ""
793
 
794
- #: admin/tpl/inc/show_display_installed.php:16
795
  msgid ""
796
- "If there are any questions, the team is always happy to answer any questions "
797
- "on the <a %s>support forum</a>."
798
  msgstr ""
799
 
800
- #: admin/tpl/inc/show_display_installed.php:19
801
- msgid ""
802
- "If you would rather not move at litespeed, you can deactivate this plugin."
803
  msgstr ""
804
 
805
- #: admin/tpl/inc/show_error_cookie.php:4
806
- msgid "NOTICE: Database login cookie did not match your login cookie."
807
  msgstr ""
808
 
809
- #: admin/tpl/inc/show_error_cookie.php:5
810
- msgid ""
811
- "If the login cookie was recently changed in the settings, please log out and "
812
- "back in."
813
  msgstr ""
814
 
815
- #: admin/tpl/inc/show_error_cookie.php:6
816
- msgid ""
817
- "If not, please verify the setting in the <a href=\"%1$s\">Advanced tab</a>."
818
  msgstr ""
819
 
820
- #: admin/tpl/inc/show_error_cookie.php:10
821
- msgid ""
822
- "If using OpenLiteSpeed, the server must be restarted once for the changes to "
823
- "take effect."
824
  msgstr ""
825
 
826
- #: admin/tpl/inc/show_rule_conflict.php:5
827
- msgid ""
828
- "Unexpected cache rule %2$s found in %1$s file. This rule may cause visitors "
829
- "to see old versions of pages due to the browser caching html pages. If you "
830
- "are sure that html pages are not being browser cached, this message can be "
831
- "dismissed. (<a %3$s>Learn More</a>)"
832
  msgstr ""
833
 
834
- #: admin/tpl/info/info_admin_ip.php:5
835
- msgid "This is used to display a page without caching it."
836
  msgstr ""
837
 
838
- #: admin/tpl/info/info_admin_ip.php:6
839
- msgid ""
840
- "An example use case is to compare a cached version of a page with an "
841
- "uncached version."
842
  msgstr ""
843
 
844
- #: admin/tpl/info/info_admin_ip.php:9
845
- msgid "This is used to purge most cache tags associated with the page."
 
 
846
  msgstr ""
847
 
848
- #: admin/tpl/info/info_admin_ip.php:10
849
- msgid "The lone exception is the blog ID tag."
850
  msgstr ""
851
 
852
- #: admin/tpl/info/info_admin_ip.php:11
853
- msgid ""
854
- "Note that this means that pages with the same cache tag will be purged as "
855
- "well."
856
  msgstr ""
857
 
858
- #: admin/tpl/info/info_admin_ip.php:14
859
- msgid "This is used to show all the cache headers associated with a page."
860
  msgstr ""
861
 
862
- #: admin/tpl/info/info_admin_ip.php:15
863
- msgid "This may be useful for debugging purposes."
864
  msgstr ""
865
 
866
- #: admin/tpl/info/info_admin_ip.php:19
867
- msgid "Admin IP Query String Actions"
868
  msgstr ""
869
 
870
- #: admin/tpl/info/info_admin_ip.php:21
871
- msgid ""
872
- "The following commands are available to the admin and do not require log-in, "
873
- "providing quick access to actions on the various pages."
874
  msgstr ""
875
 
876
- #: admin/tpl/info/info_admin_ip.php:23
877
- msgid "Action List:"
 
 
878
  msgstr ""
879
 
880
- #: admin/tpl/info/info_admin_ip.php:28
881
- msgid "This is used to purge the first cache tag associated with the page."
882
  msgstr ""
883
 
884
- #: admin/tpl/info/info_admin_ip.php:32
885
  msgid ""
886
- "To trigger the action for a page, access the page with the query string %s"
 
887
  msgstr ""
888
 
889
- #: admin/tpl/info/info_common_rewrite.php:8
890
  #: admin/tpl/setting/settings_excludes.php:60
891
  #: admin/tpl/setting/settings_excludes.php:98
892
  #: admin/tpl/setting/settings_inc.cache_browser.php:12
@@ -895,547 +890,183 @@ msgstr ""
895
  #: admin/tpl/setting/settings_inc.cache_resources.php:15
896
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:22
897
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:21
898
- #: admin/tpl/setting/settings_optimize.php:242
 
 
 
899
  msgid "NOTE:"
900
  msgstr ""
901
 
902
- #: admin/tpl/info/info_common_rewrite.php:10
903
- msgid "The following configuration can only be changed by the network admin."
904
- msgstr ""
905
-
906
- #: admin/tpl/info/info_common_rewrite.php:11
907
- msgid "Please contact the network admin to make any changes."
908
- msgstr ""
909
-
910
- #: admin/tpl/info/info_common_rewrite.php:14
911
- #: admin/tpl/setting/settings_advanced.php:6
912
- msgid "NOTICE:"
913
- msgstr ""
914
-
915
- #: admin/tpl/info/info_common_rewrite.php:17
916
  msgid ""
917
- "The following rewrite rules can be configured in the LiteSpeed Cache "
918
- "settings page."
919
- msgstr ""
920
-
921
- #: admin/tpl/info/info_common_rewrite.php:18
922
- msgid "Please make any needed changes on that page."
923
- msgstr ""
924
-
925
- #: admin/tpl/info/info_common_rewrite.php:19
926
- msgid "It will automatically generate the correct rules in the htaccess file."
927
- msgstr ""
928
-
929
- #: admin/tpl/info/info_common_rewrite.php:24
930
- msgid "LiteSpeed Cache Common Rewrite Rules"
931
- msgstr ""
932
-
933
- #: admin/tpl/info/info_common_rewrite.php:31
934
- msgid "Mobile Views:"
935
  msgstr ""
936
 
937
- #: admin/tpl/info/info_common_rewrite.php:34
938
- msgid ""
939
- "Some sites have adaptive views, meaning the page sent will adapt to the "
940
- "browser type (desktop vs mobile)."
941
- msgstr ""
942
-
943
- #: admin/tpl/info/info_common_rewrite.php:35
944
- msgid ""
945
- "This rewrite rule is used for sites that load a different page for each type."
946
- msgstr ""
947
-
948
- #: admin/tpl/info/info_common_rewrite.php:38
949
- msgid ""
950
- "This configuration can be added on the settings page in the General tab."
951
- msgstr ""
952
-
953
- #: admin/tpl/info/info_common_rewrite.php:44
954
- msgid "Do Not Cache Cookies:"
955
- msgstr ""
956
-
957
- #: admin/tpl/info/info_common_rewrite.php:46
958
- msgid ""
959
- "Another common rewrite rule is to notify the cache not to cache when it sees "
960
- "a specified cookie name."
961
- msgstr ""
962
-
963
- #: admin/tpl/info/info_common_rewrite.php:47
964
- #: admin/tpl/info/info_common_rewrite.php:55
965
- msgid ""
966
- "This configuration can be added on the settings page in the Do Not Cache tab."
967
- msgstr ""
968
-
969
- #: admin/tpl/info/info_common_rewrite.php:52
970
- msgid "Do Not Cache User Agent:"
971
- msgstr ""
972
-
973
- #: admin/tpl/info/info_common_rewrite.php:54
974
- msgid ""
975
- "A not so commonly used rewrite rule is to notify the cache not to cache when "
976
- "it sees a specified User Agent."
977
- msgstr ""
978
-
979
- #: admin/tpl/info/info_compatibility.php:27
980
- msgid "LiteSpeed Cache Plugin Compatibility"
981
- msgstr ""
982
-
983
- #: admin/tpl/info/info_compatibility.php:29
984
- msgid "Link Here"
985
- msgstr ""
986
-
987
- #: admin/tpl/info/info_compatibility.php:31
988
- msgid ""
989
- "Please add a comment listing the plugins that you are using and how they are "
990
- "functioning on the support thread."
991
- msgstr ""
992
-
993
- #: admin/tpl/info/info_compatibility.php:32
994
- msgid "With your help, we can provide the best WordPress caching solution."
995
- msgstr ""
996
-
997
- #: admin/tpl/info/info_compatibility.php:35
998
- msgid ""
999
- "This is a list of plugins that are confirmed to be compatible with LiteSpeed "
1000
- "Cache Plugin:"
1001
- msgstr ""
1002
-
1003
- #: admin/tpl/info/info_compatibility.php:44
1004
- msgid "This is a list of known UNSUPPORTED plugins:"
1005
- msgstr ""
1006
-
1007
- #: admin/tpl/info/info_config.php:4
1008
- msgid "LiteSpeed Cache Configuration"
1009
- msgstr ""
1010
-
1011
- #: admin/tpl/info/info_config.php:7
1012
- msgid "Instructions for LiteSpeed Web Server Enterprise"
1013
- msgstr ""
1014
-
1015
- #: admin/tpl/info/info_config.php:9
1016
- msgid "Make sure that the server license has the LSCache module enabled."
1017
- msgstr ""
1018
-
1019
- #: admin/tpl/info/info_config.php:10
1020
- msgid ""
1021
- "A <a %s>2-CPU trial license with LSCache module</a> is available for free "
1022
- "for %d days."
1023
- msgstr ""
1024
-
1025
- #: admin/tpl/info/info_config.php:14
1026
- msgid "The server must be configured to have caching enabled."
1027
- msgstr ""
1028
-
1029
- #: admin/tpl/info/info_config.php:15
1030
- msgid "If you are the server admin, <a %s>click here.</a>"
1031
- msgstr ""
1032
-
1033
- #: admin/tpl/info/info_config.php:17
1034
- msgid ""
1035
- "Otherwise request that the server admin configure the cache root for the "
1036
- "server."
1037
- msgstr ""
1038
-
1039
- #: admin/tpl/info/info_config.php:20
1040
- msgid ""
1041
- "In the .htaccess file for the WordPress installation, add the following:"
1042
- msgstr ""
1043
-
1044
- #: admin/tpl/info/info_config.php:27
1045
- msgid "Instructions for OpenLiteSpeed"
1046
- msgstr ""
1047
-
1048
- #: admin/tpl/info/info_config.php:28
1049
- msgid "This integration utilizes OLS's cache module."
1050
- msgstr ""
1051
-
1052
- #: admin/tpl/info/info_config.php:30
1053
- msgid ""
1054
- "If it is a fresh OLS installation, the easiest way to integrate is to use <a "
1055
- "%s>ols1clk.</a>"
1056
- msgstr ""
1057
-
1058
- #: admin/tpl/info/info_config.php:32
1059
- msgid "If using an existing WordPress installation, use the %s parameter."
1060
- msgstr ""
1061
-
1062
- #: admin/tpl/info/info_config.php:33
1063
- msgid ""
1064
- "Else if OLS and WordPress are already installed, please follow the "
1065
- "instructions <a %s>here.</a>"
1066
- msgstr ""
1067
-
1068
- #: admin/tpl/info/info_config.php:38
1069
- msgid "How to test the plugin"
1070
- msgstr ""
1071
-
1072
- #: admin/tpl/info/info_config.php:39
1073
- msgid ""
1074
- "The LiteSpeed Cache Plugin utilizes LiteSpeed specific response headers."
1075
- msgstr ""
1076
-
1077
- #: admin/tpl/info/info_config.php:41
1078
- msgid ""
1079
- "Visiting a page for the first time should result in a %s or %s response "
1080
- "header for the page."
1081
- msgstr ""
1082
-
1083
- #: admin/tpl/info/info_config.php:46
1084
- msgid ""
1085
- "Subsequent requests should have the %s response header until the page is "
1086
- "updated, expired, or purged."
1087
- msgstr ""
1088
-
1089
- #: admin/tpl/info/info_config.php:49
1090
- msgid "Please visit <a %s>this page</a> for more information."
1091
- msgstr ""
1092
-
1093
- #: admin/tpl/info/info_config.php:53
1094
- msgid "Cache tag prefix setting"
1095
- msgstr ""
1096
-
1097
- #: admin/tpl/info/info_config.php:56
1098
- msgid ""
1099
- "The value of this wordpress cache tag prefix is %1$s. If you want to change "
1100
- "the value to avoid conflicts with multiple sites, please add %2$s to %3$s."
1101
- msgstr ""
1102
-
1103
- #: admin/tpl/info/info_crawler.php:7
1104
- msgid "Crawler Introduction"
1105
- msgstr ""
1106
-
1107
- #: admin/tpl/info/info_crawler.php:11
1108
- msgid "How Does the Crawler Work?"
1109
- msgstr ""
1110
-
1111
- #: admin/tpl/info/info_crawler.php:13
1112
- msgid ""
1113
- "Using a sitemap as a guide, LSCache’s crawler, travels its way throughout "
1114
- "the backend, refreshing pages that have expired in the cache. The purpose is "
1115
- "to keep the cache as fresh as possible while minimizing visitor exposure to "
1116
- "uncached content."
1117
- msgstr ""
1118
-
1119
- #: admin/tpl/info/info_crawler.php:15
1120
- msgid ""
1121
- "The sitemap can be generated by the crawler, or you can provide your own "
1122
- "custom map."
1123
- msgstr ""
1124
-
1125
- #: admin/tpl/info/info_crawler.php:17
1126
- msgid ""
1127
- "To learn more about each of the crawler settings, see <a %s>our wiki - "
1128
- "Crawler Settings</a>."
1129
- msgstr ""
1130
-
1131
- #: admin/tpl/info/info_crawler.php:21
1132
- msgid "Should I Enable the Crawler?"
1133
- msgstr ""
1134
-
1135
- #: admin/tpl/info/info_crawler.php:23
1136
- msgid "Not every site needs a crawler."
1137
  msgstr ""
1138
 
1139
- #: admin/tpl/info/info_crawler.php:25
1140
  msgid ""
1141
- "In WordPress, the first visitor to an uncached page waits for the page to "
1142
- "be dynamically-generated and served, and the page is then cached for "
1143
- "subsequent visitors."
1144
  msgstr ""
1145
 
1146
- #: admin/tpl/info/info_crawler.php:27
1147
  msgid ""
1148
- "The LSCache crawler makes the first visitor’s experience better by "
1149
- "essentially becoming the first visitor. The crawler caches the page, and the "
1150
- "visitor who would have been first is spared the wait. As such, the crawler "
1151
- "realistically only benefits the first out of the many users who visit that "
1152
- "page before it expires. If you have a small user base, then crawling impacts "
1153
- "a greater percentage of your visitors than it would on a site that draws a "
1154
- "large crowd."
1155
  msgstr ""
1156
 
1157
- #: admin/tpl/info/info_crawler.php:29
1158
- msgid ""
1159
- "You should weigh this benefit against your server’s resources. If resources "
1160
- "are plentiful, then the crawler is a nice thing to have."
1161
  msgstr ""
1162
 
1163
- #: admin/tpl/info/info_crawler.php:31
1164
- msgid ""
1165
- "If your site is busy, you’ll find that commonly-visited pages are quickly re-"
1166
- "cached by new visitors, without the aid of a crawler. An extra crawler task "
1167
- "would compete for server resources while delivering minimal benefits."
1168
- msgstr ""
1169
-
1170
- #: admin/tpl/info/info_crawler.php:33
1171
- msgid ""
1172
- "The decision to use a crawler depends on the busy-ness of the site and the "
1173
- "availability of server resources. Ultimately, it is the hosting provider who "
1174
- "can best make this call."
1175
  msgstr ""
1176
 
1177
- #: admin/tpl/info/info_crawler.php:38
1178
- msgid "Enabling the Crawler"
1179
  msgstr ""
1180
 
1181
- #: admin/tpl/info/info_crawler.php:40
1182
  msgid ""
1183
- "Due to the potential of the crawler to consume considerable resources, we "
1184
- "have put the on/off switch in the hands of the server administrators. The "
1185
- "crawler is disabled by default and can only be enabled by an admin."
1186
  msgstr ""
1187
 
1188
- #: admin/tpl/info/info_crawler.php:42
1189
  msgid ""
1190
- "Instructions for enabling the crawler can be found in <a %s>our wiki - "
1191
- "Enabling the Crawler</a>. If you do not have access to server configuration "
1192
- "files or virtual host include files, you will need to ask your web host for "
1193
- "assistance."
1194
  msgstr ""
1195
 
1196
- #: admin/tpl/info/info_crawler.php:47
1197
- msgid "Testing the Crawler"
1198
  msgstr ""
1199
 
1200
- #: admin/tpl/info/info_crawler.php:49
1201
- msgid ""
1202
- "To determine whether the crawler is working as expected, you can test it "
1203
- "with a single URL."
1204
  msgstr ""
1205
 
1206
- #: admin/tpl/info/info_crawler.php:53
1207
- msgid "Pick a URL from your sitemap and purge it:"
1208
  msgstr ""
1209
 
1210
- #: admin/tpl/info/info_crawler.php:54
1211
  msgid ""
1212
- "Navigate to <b>LiteSpeed Cache > Manage > Purge By… > URL</b> and enter the "
1213
- "full URL in the text box."
1214
- msgstr ""
1215
-
1216
- #: admin/tpl/info/info_crawler.php:57
1217
- msgid "Manually run the crawler:"
1218
  msgstr ""
1219
 
1220
- #: admin/tpl/info/info_crawler.php:58
1221
- msgid ""
1222
- "Navigate to <b>LiteSpeed Cache > Crawler</b>, make sure <b>Activation</b> is "
1223
- "set to Enable, and press the <b>Manually run</b> button. Wait for it to "
1224
- "finish."
1225
  msgstr ""
1226
 
1227
- #: admin/tpl/info/info_crawler.php:61
1228
- msgid "See if the purged URL was cached during the crawl:"
1229
  msgstr ""
1230
 
1231
- #: admin/tpl/info/info_crawler.php:62
1232
  msgid ""
1233
- "Turn on your browser’s Developer Tool/Inspector. Visit the URL that should "
1234
- "have been crawled. Select the <b>Network</b> tab in the inspector, select "
1235
- "the page request (the URL we just visited - it should be the first entry in "
1236
- "the list), and select the <b>Header</b> tab. If the URL was crawled "
1237
- "correctly, you will see the response header X-LiteSpeed-Cache: hit."
1238
  msgstr ""
1239
 
1240
- #: admin/tpl/info/info_crawler.php:67
1241
  msgid ""
1242
- "If you don’t see X-LiteSpeed-Cache: hit, and you can’t figure out why the "
1243
- "crawler didn’t cache the purged URL, you can visit <a %s>our support forum</"
1244
- "a> for help."
1245
- msgstr ""
1246
-
1247
- #: admin/tpl/info/info_faqs.php:5
1248
- msgid "LiteSpeed Cache FAQs"
1249
- msgstr ""
1250
-
1251
- #: admin/tpl/info/info_faqs.php:9
1252
- msgid "Is the LiteSpeed Cache Plugin for WordPress free?"
1253
- msgstr ""
1254
-
1255
- #: admin/tpl/info/info_faqs.php:12
1256
- msgid "Yes, the plugin itself will remain free and open source."
1257
- msgstr ""
1258
-
1259
- #: admin/tpl/info/info_faqs.php:13
1260
- msgid "That said, a LiteSpeed server is required (see question 2)"
1261
- msgstr ""
1262
-
1263
- #: admin/tpl/info/info_faqs.php:17
1264
- msgid "What server software is required for this plugin?"
1265
- msgstr ""
1266
-
1267
- #: admin/tpl/info/info_faqs.php:19
1268
- msgid "A LiteSpeed server is required in order to use this plugin."
1269
- msgstr ""
1270
-
1271
- #: admin/tpl/info/info_faqs.php:25
1272
- msgid "Any single server or cluster including a LiteSpeed server will work."
1273
  msgstr ""
1274
 
1275
- #: admin/tpl/info/info_faqs.php:28
1276
- msgid "Does this plugin work in a clustered environment?"
1277
  msgstr ""
1278
 
1279
- #: admin/tpl/info/info_faqs.php:31
1280
- msgid "The cache entries are stored at the litespeed server level."
1281
  msgstr ""
1282
 
1283
- #: admin/tpl/info/info_faqs.php:32
1284
- msgid ""
1285
- "The simplest solution is to use LiteSpeed WebADC, as the cache entries will "
1286
- "be cached at that level."
1287
  msgstr ""
1288
 
1289
- #: admin/tpl/info/info_faqs.php:35
1290
  msgid ""
1291
- "If using another load balancer, the cache entries will only be stored at the "
1292
- "backend nodes, not at the load balancer."
1293
  msgstr ""
1294
 
1295
- #: admin/tpl/info/info_faqs.php:36
1296
  msgid ""
1297
- "The purges will also not be synchronized across the nodes, so this is not "
1298
- "recommended."
1299
- msgstr ""
1300
-
1301
- #: admin/tpl/info/info_faqs.php:39
1302
- msgid "If a customized solution is required, please contact %s at %s"
1303
  msgstr ""
1304
 
1305
- #: admin/tpl/info/info_faqs.php:42
1306
  msgid ""
1307
- "NOTICE: The rewrite rules created by this plugin must be copied to the WebADC"
1308
- msgstr ""
1309
-
1310
- #: admin/tpl/info/info_faqs.php:45
1311
- msgid "Where are the cache entries stored?"
1312
  msgstr ""
1313
 
1314
- #: admin/tpl/info/info_faqs.php:47
1315
  msgid ""
1316
- "The actual cached pages are stored and managed by LiteSpeed Servers. Nothing "
1317
- "is stored on the PHP side."
1318
- msgstr ""
1319
-
1320
- #: admin/tpl/info/info_faqs.php:50
1321
- msgid "Is WooCommerce supported?"
1322
  msgstr ""
1323
 
1324
- #: admin/tpl/info/info_faqs.php:53
1325
- msgid "In short, yes."
1326
  msgstr ""
1327
 
1328
- #: admin/tpl/info/info_faqs.php:54
1329
- msgid ""
1330
- "However, for some woocommerce themes, the cart may not be updated correctly."
1331
  msgstr ""
1332
 
1333
- #: admin/tpl/info/info_faqs.php:56
1334
- msgid "To test the cart:"
1335
  msgstr ""
1336
 
1337
- #: admin/tpl/info/info_faqs.php:58
1338
  msgid ""
1339
- "On a non-logged-in browser, visit and cache a page, then visit and cache a "
1340
- "product page."
1341
  msgstr ""
1342
 
1343
- #: admin/tpl/info/info_faqs.php:59
1344
  msgid ""
1345
- "The first page should be accessible from the product page (e.g. the shop)."
1346
- msgstr ""
1347
-
1348
- #: admin/tpl/info/info_faqs.php:60
1349
- msgid "Once both pages are confirmed cached, add the product to the cart."
1350
- msgstr ""
1351
-
1352
- #: admin/tpl/info/info_faqs.php:61
1353
- msgid "After adding to the cart, visit the first page."
1354
- msgstr ""
1355
-
1356
- #: admin/tpl/info/info_faqs.php:62
1357
- msgid "The page should still be cached, and the cart should be up to date."
1358
  msgstr ""
1359
 
1360
- #: admin/tpl/info/info_faqs.php:63
1361
- msgid ""
1362
- "If that is not the case, please add woocommerce_items_in_cart to the do not "
1363
- "cache cookie list."
1364
  msgstr ""
1365
 
1366
- #: admin/tpl/info/info_faqs.php:66
1367
  msgid ""
1368
- "Some themes like Storefront and Shop Isle are built such that the cart works "
1369
- "without the rule."
1370
  msgstr ""
1371
 
1372
- #: admin/tpl/info/info_faqs.php:67
1373
  msgid ""
1374
- "However, other themes like the E-Commerce theme, do not, so please verify "
1375
- "the theme used."
1376
- msgstr ""
1377
-
1378
- #: admin/tpl/info/info_faqs.php:71
1379
- msgid "Are my images optimized?"
1380
- msgstr ""
1381
-
1382
- #: admin/tpl/info/info_faqs.php:74
1383
- msgid "The cache plugin does not do anything with the images themselves."
1384
  msgstr ""
1385
 
1386
- #: admin/tpl/info/info_faqs.php:75
1387
  msgid ""
1388
- "We recommend you trying an image optimization plugin like %s to optimize "
1389
- "your images."
1390
- msgstr ""
1391
-
1392
- #: admin/tpl/info/info_faqs.php:77
1393
- msgid "It can reduce your site's images up to 90%."
1394
- msgstr ""
1395
-
1396
- #: admin/tpl/info/info_faqs.php:81
1397
- msgid "How do I get WP-PostViews to display an updating view count?"
1398
- msgstr ""
1399
-
1400
- #: admin/tpl/info/info_faqs.php:84
1401
- msgid "Use %1$s to replace %2$s"
1402
  msgstr ""
1403
 
1404
- #: admin/tpl/info/info_faqs.php:88
1405
  msgid ""
1406
- "NOTE: The id can be changed, but the div id and the ajax function must match."
1407
- msgstr ""
1408
-
1409
- #: admin/tpl/info/info_faqs.php:91
1410
- msgid "Replace the ajax query in %1$s with %2$s"
1411
- msgstr ""
1412
-
1413
- #: admin/tpl/info/info_faqs.php:106
1414
- msgid "Purge the cache to use the updated pages."
1415
- msgstr ""
1416
-
1417
- #: admin/tpl/info.php:5
1418
- msgid "FAQs"
1419
- msgstr ""
1420
-
1421
- #: admin/tpl/info.php:6
1422
- msgid "Configuration"
1423
- msgstr ""
1424
-
1425
- #: admin/tpl/info.php:7
1426
- msgid "Plugin Compatibilities"
1427
- msgstr ""
1428
-
1429
- #: admin/tpl/info.php:8
1430
- msgid "Common Rewrite Rules"
1431
- msgstr ""
1432
-
1433
- #: admin/tpl/info.php:9
1434
- msgid "Admin IP Commands"
1435
- msgstr ""
1436
-
1437
- #: admin/tpl/info.php:16
1438
- msgid "LiteSpeed Cache Information"
1439
  msgstr ""
1440
 
1441
  #: admin/tpl/manage/manage_db.php:6
@@ -1638,11 +1269,11 @@ msgstr ""
1638
  #: admin/tpl/setting/settings_excludes.php:94
1639
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:19
1640
  #: admin/tpl/setting/settings_media.php:27
1641
- #: admin/tpl/setting/settings_optimize.php:58
1642
- #: admin/tpl/setting/settings_optimize.php:105
1643
- #: admin/tpl/setting/settings_optimize.php:201
1644
- #: admin/tpl/setting/settings_optimize.php:230
1645
  #: admin/tpl/setting/settings_purge.php:79
 
 
 
 
1646
  msgid "One per line."
1647
  msgstr ""
1648
 
@@ -1713,56 +1344,58 @@ msgid "Excludes"
1713
  msgstr ""
1714
 
1715
  #: admin/tpl/network_settings.php:9 admin/tpl/setting/settings_debug.php:65
1716
- #: admin/tpl/settings.php:19
1717
  msgid "Advanced"
1718
  msgstr ""
1719
 
1720
- #: admin/tpl/network_settings.php:19
1721
- msgid "LiteSpeed Cache Network Settings"
1722
  msgstr ""
1723
 
1724
- #: admin/tpl/report.php:10
1725
- msgid "LiteSpeed Cache Report"
1726
  msgstr ""
1727
 
1728
- #: admin/tpl/report.php:19
1729
- msgid ""
1730
- "The environment report contains detailed information about the WordPress "
1731
- "configuration."
1732
  msgstr ""
1733
 
1734
- #: admin/tpl/report.php:20
1735
- msgid ""
1736
- "If you run into any issues, please include the contents of this text area in "
1737
- "your support message."
1738
  msgstr ""
1739
 
1740
- #: admin/tpl/report.php:21
1741
- msgid ""
1742
- "To easily grab the content, click the <b>Select All and Copy to Clipboard</"
1743
- "b> button, to select and copy to clipboard."
1744
  msgstr ""
1745
 
1746
- #: admin/tpl/report.php:23
1747
- msgid "Alternatively, this information is also saved in %s."
1748
  msgstr ""
1749
 
1750
  #: admin/tpl/report.php:28
1751
- msgid "The text area below contains the following content:"
1752
  msgstr ""
1753
 
1754
- #: admin/tpl/report.php:32
1755
  msgid ""
1756
- "Server Variables, Plugin Options, WordPress information (version, locale, "
1757
- "active plugins, etc.), and .htaccess file content."
 
 
 
 
1758
  msgstr ""
1759
 
1760
- #: admin/tpl/report.php:37
1761
- msgid "Select All and Copy to Clipboard"
 
 
1762
  msgstr ""
1763
 
1764
  #: admin/tpl/report.php:40
1765
- msgid "Environment Report copied to Clipboard!"
 
 
1766
  msgstr ""
1767
 
1768
  #: admin/tpl/setting/network_settings_cache.php:4
@@ -1825,10 +1458,18 @@ msgstr ""
1825
  msgid "This will disable the settings page on all subsites."
1826
  msgstr ""
1827
 
 
 
 
 
1828
  #: admin/tpl/setting/network_settings_purge.php:4
1829
  msgid "Purge Network Settings"
1830
  msgstr ""
1831
 
 
 
 
 
1832
  #: admin/tpl/setting/settings_advanced.php:8
1833
  msgid "These settings are meant for ADVANCED USERS ONLY."
1834
  msgstr ""
@@ -1993,7 +1634,7 @@ msgstr ""
1993
 
1994
  #: admin/tpl/setting/settings_cache.php:62
1995
  #: admin/tpl/setting/settings_excludes.php:14
1996
- #: admin/tpl/setting/settings_optimize.php:229
1997
  msgid "For example, for %s, %s can be used here."
1998
  msgstr ""
1999
 
@@ -2338,8 +1979,7 @@ msgstr ""
2338
 
2339
  #: admin/tpl/setting/settings_debug.php:46
2340
  msgid ""
2341
- "More information about the available commands can be found <a href=\"%s"
2342
- "\">here</a>."
2343
  msgstr ""
2344
 
2345
  #: admin/tpl/setting/settings_debug.php:53
@@ -2416,17 +2056,17 @@ msgstr ""
2416
  msgid "Filters containing these strings (one per line) will not be logged."
2417
  msgstr ""
2418
 
2419
- #: admin/tpl/setting/settings_esi.php:14
2420
  msgid "ESI Settings"
2421
  msgstr ""
2422
 
2423
- #: admin/tpl/setting/settings_esi.php:17
2424
  msgid ""
2425
  "With ESI (Edge Side Includes), pages may be served from cache for logged-in "
2426
  "users."
2427
  msgstr ""
2428
 
2429
- #: admin/tpl/setting/settings_esi.php:18
2430
  msgid ""
2431
  "ESI allows you to designate parts of your dynamic page as separate fragments "
2432
  "that are then assembled together to make the whole page. In other words, ESI "
@@ -2435,42 +2075,42 @@ msgid ""
2435
  "cached at all."
2436
  msgstr ""
2437
 
2438
- #: admin/tpl/setting/settings_esi.php:20
2439
  msgid "Learn more about public cache vs. private cache <a %s>on our blog</a>."
2440
  msgstr ""
2441
 
2442
- #: admin/tpl/setting/settings_esi.php:29
2443
  msgid "Available in LiteSpeed Enterprise version"
2444
  msgstr ""
2445
 
2446
- #: admin/tpl/setting/settings_esi.php:39
2447
  msgid ""
2448
  "Enable caches public pages for logged in users and serves the Admin Bar and "
2449
  "Comment Form via ESI blocks. These two blocks will be uncached unless "
2450
  "enabled below."
2451
  msgstr ""
2452
 
2453
- #: admin/tpl/setting/settings_esi.php:45
2454
  msgid "Cache Admin Bar"
2455
  msgstr ""
2456
 
2457
- #: admin/tpl/setting/settings_esi.php:49
2458
  msgid "Cache the build-in Admin Bar ESI block."
2459
  msgstr ""
2460
 
2461
- #: admin/tpl/setting/settings_esi.php:55
2462
  msgid "Cache Comment Form"
2463
  msgstr ""
2464
 
2465
- #: admin/tpl/setting/settings_esi.php:59
2466
  msgid "Cache the build-in Comment Form ESI block."
2467
  msgstr ""
2468
 
2469
- #: admin/tpl/setting/settings_esi.php:65
2470
  msgid "Vary Group"
2471
  msgstr ""
2472
 
2473
- #: admin/tpl/setting/settings_esi.php:80
2474
  msgid ""
2475
  "If your site contains public content that certain user roles can see but "
2476
  "other roles cannot, you can specify a Vary Group for those user roles. For "
@@ -2523,7 +2163,9 @@ msgid "categories"
2523
  msgstr ""
2524
 
2525
  #: admin/tpl/setting/settings_excludes.php:62
2526
- msgid "If the Category ID is not found, the name will be removed on save."
 
 
2527
  msgstr ""
2528
 
2529
  #: admin/tpl/setting/settings_excludes.php:63
@@ -2544,7 +2186,16 @@ msgid "tags"
2544
  msgstr ""
2545
 
2546
  #: admin/tpl/setting/settings_excludes.php:100
2547
- msgid "If the Tag ID is not found, the name will be removed on save."
 
 
 
 
 
 
 
 
 
2548
  msgstr ""
2549
 
2550
  #: admin/tpl/setting/settings_general.php:9
@@ -2560,7 +2211,7 @@ msgid "Please visit the <a %s>Information</a> page on how to test the cache."
2560
  msgstr ""
2561
 
2562
  #: admin/tpl/setting/settings_general.php:47
2563
- #: admin/tpl/setting/settings_optimize.php:15
2564
  msgid "NOTICE"
2565
  msgstr ""
2566
 
@@ -2666,6 +2317,7 @@ msgstr ""
2666
  #: admin/tpl/setting/settings_inc.cache_resources.php:16
2667
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:23
2668
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:22
 
2669
  msgid "This setting will edit the .htaccess file."
2670
  msgstr ""
2671
 
@@ -2675,6 +2327,16 @@ msgid ""
2675
  "LiteSpeed browser cache setting</a>."
2676
  msgstr ""
2677
 
 
 
 
 
 
 
 
 
 
 
2678
  #: admin/tpl/setting/settings_inc.cache_favicon.php:7
2679
  msgid "Cache favicon.ico"
2680
  msgstr ""
@@ -2768,6 +2430,16 @@ msgstr ""
2768
  msgid "SYNTAX: Separate each user agent with a bar, %s."
2769
  msgstr ""
2770
 
 
 
 
 
 
 
 
 
 
 
2771
  #: admin/tpl/setting/settings_inc.purge_on_upgrade.php:7
2772
  msgid "Purge All On Upgrade"
2773
  msgstr ""
@@ -2804,33 +2476,35 @@ msgid "Listed images will not be lazy loaded."
2804
  msgstr ""
2805
 
2806
  #: admin/tpl/setting/settings_media.php:26
2807
- #: admin/tpl/setting/settings_optimize.php:57
2808
- #: admin/tpl/setting/settings_optimize.php:104
2809
- #: admin/tpl/setting/settings_optimize.php:200
2810
- #: admin/tpl/setting/settings_optimize.php:228
2811
  msgid "Both full URLs and partial strings can be used."
2812
  msgstr ""
2813
 
2814
  #: admin/tpl/setting/settings_media.php:29
2815
- #: admin/tpl/setting/settings_optimize.php:60
2816
- #: admin/tpl/setting/settings_optimize.php:107
2817
- #: admin/tpl/setting/settings_optimize.php:166
2818
- #: admin/tpl/setting/settings_optimize.php:203
 
 
2819
  msgid "API:"
2820
  msgstr ""
2821
 
2822
  #: admin/tpl/setting/settings_media.php:30
2823
- #: admin/tpl/setting/settings_optimize.php:61
2824
- #: admin/tpl/setting/settings_optimize.php:108
2825
- #: admin/tpl/setting/settings_optimize.php:204
2826
  msgid "Filter %s is supported."
2827
  msgstr ""
2828
 
2829
  #: admin/tpl/setting/settings_media.php:31
2830
- #: admin/tpl/setting/settings_optimize.php:62
2831
- #: admin/tpl/setting/settings_optimize.php:109
2832
- #: admin/tpl/setting/settings_optimize.php:167
2833
- #: admin/tpl/setting/settings_optimize.php:205
2834
  msgid "Elements with attribute %s in html code will be excluded."
2835
  msgstr ""
2836
 
@@ -2866,196 +2540,170 @@ msgstr ""
2866
  msgid "Load iframes only when they enter the viewport."
2867
  msgstr ""
2868
 
2869
- #: admin/tpl/setting/settings_optimize.php:5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2870
  msgid "Optimization Settings"
2871
  msgstr ""
2872
 
2873
- #: admin/tpl/setting/settings_optimize.php:10
2874
  msgid ""
2875
  "Failed to create Optimizer table. Please follow <a %s>Table Creation "
2876
  "guidance from LiteSpeed Wiki</a> to finish setup."
2877
  msgstr ""
2878
 
2879
- #: admin/tpl/setting/settings_optimize.php:16
2880
  msgid ""
2881
  "Please test thoroughly when enabling any option in this list. After changing "
2882
  "Minify/Combine settings, please do a Purge All action."
2883
  msgstr ""
2884
 
2885
- #: admin/tpl/setting/settings_optimize.php:22
2886
  msgid "CSS Minify"
2887
  msgstr ""
2888
 
2889
- #: admin/tpl/setting/settings_optimize.php:26
2890
  msgid "Minify CSS files."
2891
  msgstr ""
2892
 
2893
- #: admin/tpl/setting/settings_optimize.php:32
2894
  msgid "CSS Combine"
2895
  msgstr ""
2896
 
2897
- #: admin/tpl/setting/settings_optimize.php:36
2898
  msgid "Combine CSS files."
2899
  msgstr ""
2900
 
2901
- #: admin/tpl/setting/settings_optimize.php:42
2902
  msgid "CSS HTTP/2 Push"
2903
  msgstr ""
2904
 
2905
- #: admin/tpl/setting/settings_optimize.php:46
2906
  msgid ""
2907
  "Pre-send internal CSS files to the browser before they are requested. "
2908
  "(Requires the HTTP/2 protocol)"
2909
  msgstr ""
2910
 
2911
- #: admin/tpl/setting/settings_optimize.php:52
2912
- msgid "CSS Excludes"
2913
- msgstr ""
2914
-
2915
- #: admin/tpl/setting/settings_optimize.php:56
2916
- msgid "Listed CSS files will not be minified/combined."
2917
- msgstr ""
2918
-
2919
- #: admin/tpl/setting/settings_optimize.php:69
2920
  msgid "JS Minify"
2921
  msgstr ""
2922
 
2923
- #: admin/tpl/setting/settings_optimize.php:73
2924
  msgid "Minify JS files."
2925
  msgstr ""
2926
 
2927
- #: admin/tpl/setting/settings_optimize.php:79
2928
- #: admin/tpl/setting/settings_optimize.php:243
2929
- msgid "JS Combine"
2930
- msgstr ""
2931
-
2932
- #: admin/tpl/setting/settings_optimize.php:83
2933
  msgid "Combine JS files."
2934
  msgstr ""
2935
 
2936
- #: admin/tpl/setting/settings_optimize.php:89
2937
  msgid "JS HTTP/2 Push"
2938
  msgstr ""
2939
 
2940
- #: admin/tpl/setting/settings_optimize.php:93
2941
  msgid ""
2942
  "Pre-send internal JS files to the browser before they are requested. "
2943
  "(Requires the HTTP/2 protocol)"
2944
  msgstr ""
2945
 
2946
- #: admin/tpl/setting/settings_optimize.php:99
2947
- msgid "JS Excludes"
2948
- msgstr ""
2949
-
2950
- #: admin/tpl/setting/settings_optimize.php:103
2951
- msgid "Listed JS files will not be minified/combined."
2952
- msgstr ""
2953
-
2954
- #: admin/tpl/setting/settings_optimize.php:116
2955
  msgid "CSS/JS Cache TTL"
2956
  msgstr ""
2957
 
2958
- #: admin/tpl/setting/settings_optimize.php:121
2959
  msgid ""
2960
  "Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s "
2961
  "seconds."
2962
  msgstr ""
2963
 
2964
- #: admin/tpl/setting/settings_optimize.php:128
2965
  msgid "HTML Minify"
2966
  msgstr ""
2967
 
2968
- #: admin/tpl/setting/settings_optimize.php:132
2969
  msgid "Minify HTML content."
2970
  msgstr ""
2971
 
2972
- #: admin/tpl/setting/settings_optimize.php:138
2973
- msgid "Remove Query Strings"
 
2974
  msgstr ""
2975
 
2976
- #: admin/tpl/setting/settings_optimize.php:142
2977
- msgid "Remove query strings from static resources."
2978
  msgstr ""
2979
 
2980
- #: admin/tpl/setting/settings_optimize.php:143
2981
- #: admin/tpl/setting/settings_optimize.php:164
2982
- #: admin/tpl/setting/settings_optimize.php:189
2983
- #: admin/tpl/setting/settings_optimize.php:217
2984
  msgid ""
2985
  "This can improve your speed score in services like Pingdom, GTmetrix and "
2986
  "PageSpeed."
2987
  msgstr ""
2988
 
2989
- #: admin/tpl/setting/settings_optimize.php:149
2990
- msgid "Remove Google Fonts"
2991
- msgstr ""
2992
-
2993
- #: admin/tpl/setting/settings_optimize.php:153
2994
- msgid "Prevent google fonts from loading on all your pages."
2995
- msgstr ""
2996
-
2997
- #: admin/tpl/setting/settings_optimize.php:159
2998
- #: admin/tpl/setting/settings_optimize.php:178
2999
- msgid "Load CSS Asynchronously"
3000
- msgstr ""
3001
-
3002
- #: admin/tpl/setting/settings_optimize.php:163
3003
- msgid "Optimize CSS delivery. This will load Google Fonts asynchronously too."
3004
- msgstr ""
3005
-
3006
- #: admin/tpl/setting/settings_optimize.php:174
3007
- msgid "Critical CSS Rules"
3008
- msgstr ""
3009
-
3010
- #: admin/tpl/setting/settings_optimize.php:178
3011
- msgid "Specify critical CSS rules for above-the-fold content when enabling %s."
3012
- msgstr ""
3013
-
3014
- #: admin/tpl/setting/settings_optimize.php:184
3015
  msgid "Load JS Deferred"
3016
  msgstr ""
3017
 
3018
- #: admin/tpl/setting/settings_optimize.php:188
3019
  msgid "Doing so can help reduce resource contention and improve performance."
3020
  msgstr ""
3021
 
3022
- #: admin/tpl/setting/settings_optimize.php:195
3023
- msgid "JS Deferred Excludes"
3024
- msgstr ""
3025
-
3026
- #: admin/tpl/setting/settings_optimize.php:199
3027
- msgid "Listed JS files will not be deferred."
3028
- msgstr ""
3029
-
3030
- #: admin/tpl/setting/settings_optimize.php:212
3031
- msgid "Remove WordPress Emoji"
3032
- msgstr ""
3033
-
3034
- #: admin/tpl/setting/settings_optimize.php:216
3035
- msgid ""
3036
- "Stop loading wordpress.org emoji. Browser default emoji will be displayed "
3037
- "instead."
3038
- msgstr ""
3039
-
3040
- #: admin/tpl/setting/settings_optimize.php:223
3041
- msgid "URI Excludes"
3042
- msgstr ""
3043
-
3044
- #: admin/tpl/setting/settings_optimize.php:227
3045
- msgid "Prevent any optimization of listed pages."
3046
- msgstr ""
3047
-
3048
- #: admin/tpl/setting/settings_optimize.php:236
3049
  msgid "Exclude JQuery"
3050
  msgstr ""
3051
 
3052
- #: admin/tpl/setting/settings_optimize.php:240
3053
  msgid ""
3054
  "Improve compatibility with inline JS by preventing jQuery optimization. "
3055
  "(Recommended Setting: %s)"
3056
  msgstr ""
3057
 
3058
- #: admin/tpl/setting/settings_optimize.php:243
3059
  msgid ""
3060
  "If there is any JS error related to %1$s when enabled %2$s, please try this "
3061
  "option."
@@ -3114,7 +2762,7 @@ msgid "Auto Purge Rules For Publish/Update"
3114
  msgstr ""
3115
 
3116
  #: admin/tpl/setting/settings_purge.php:47
3117
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:663
3118
  msgid "Note:"
3119
  msgstr ""
3120
 
@@ -3168,53 +2816,191 @@ msgstr ""
3168
  msgid "Current server time is %s."
3169
  msgstr ""
3170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3171
  #: admin/tpl/settings.php:11
3172
  msgid "Optimize"
3173
  msgstr ""
3174
 
3175
  #: admin/tpl/settings.php:12
3176
- msgid "Media"
3177
  msgstr ""
3178
 
3179
- #: admin/tpl/settings.php:13
3180
  msgid "CDN"
3181
  msgstr ""
3182
 
3183
- #: admin/tpl/settings.php:16
3184
  msgid "ESI"
3185
  msgstr ""
3186
 
3187
- #: admin/tpl/settings.php:22
3188
  msgid "Debug"
3189
  msgstr ""
3190
 
3191
- #: admin/tpl/settings.php:25
3192
  msgid "Compatibilities"
3193
  msgstr ""
3194
 
3195
- #: admin/tpl/settings.php:65
3196
  msgid "WARNING: Third party tab input invalid."
3197
  msgstr ""
3198
 
3199
- #: admin/tpl/settings.php:72
3200
  msgid "WARNING: Third party config slug contains invalid characters."
3201
  msgstr ""
3202
 
3203
- #: admin/tpl/settings.php:89
3204
  msgid "LiteSpeed Cache Settings"
3205
  msgstr ""
3206
 
3207
- #: admin/tpl/settings.php:119
3208
  msgid "The network admin selected use primary site configs for all subsites."
3209
  msgstr ""
3210
 
3211
- #: admin/tpl/settings.php:120
3212
  msgid ""
3213
  "The following options are selected, but are not editable in this settings "
3214
  "page."
3215
  msgstr ""
3216
 
3217
- #: admin/tpl/settings.php:142 admin/tpl/settings.php:145
3218
  msgid "Save Changes"
3219
  msgstr ""
3220
 
@@ -3259,80 +3045,170 @@ msgstr ""
3259
  msgid "Reached end of sitemap file. Crawling completed."
3260
  msgstr ""
3261
 
3262
- #: inc/gui.class.php:65 includes/litespeed-cache-gui.class.php:65
3263
  msgid "Purge this page"
3264
  msgstr ""
3265
 
3266
- #: inc/gui.class.php:73 includes/litespeed-cache-gui.class.php:73
3267
  msgid "Mark this page as "
3268
  msgstr ""
3269
 
3270
- #: inc/gui.class.php:80 includes/litespeed-cache-gui.class.php:80
3271
  msgid "Non cacheable"
3272
  msgstr ""
3273
 
3274
- #: inc/gui.class.php:87 includes/litespeed-cache-gui.class.php:87
3275
  msgid "Private cache"
3276
  msgstr ""
3277
 
3278
- #: inc/gui.class.php:94 includes/litespeed-cache-gui.class.php:94
3279
  msgid "No optimization"
3280
  msgstr ""
3281
 
3282
- #: inc/gui.class.php:101 includes/litespeed-cache-gui.class.php:101
3283
  msgid "More settings"
3284
  msgstr ""
3285
 
3286
- #: inc/litespeed-cache.class.php:226 includes/litespeed-cache.class.php:226
3287
  msgid "Crawler blacklist is saved."
3288
  msgstr ""
3289
 
3290
- #: inc/litespeed-cache.class.php:231 includes/litespeed-cache.class.php:231
3291
  msgid "Notified LiteSpeed Web Server to purge the front page."
3292
  msgstr ""
3293
 
3294
- #: inc/litespeed-cache.class.php:236 includes/litespeed-cache.class.php:236
3295
  msgid "Notified LiteSpeed Web Server to purge pages."
3296
  msgstr ""
3297
 
3298
- #: inc/litespeed-cache.class.php:241 includes/litespeed-cache.class.php:241
3299
  msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
3300
  msgstr ""
3301
 
3302
- #: inc/litespeed-cache.class.php:246 includes/litespeed-cache.class.php:246
3303
  msgid "Notified LiteSpeed Web Server to purge error pages."
3304
  msgstr ""
3305
 
3306
- #: inc/litespeed-cache.class.php:252 includes/litespeed-cache.class.php:252
3307
  msgid "Notified LiteSpeed Web Server to purge all caches."
3308
  msgstr ""
3309
 
3310
- #: inc/litespeed-cache.class.php:259 includes/litespeed-cache.class.php:259
3311
  msgid "Notified LiteSpeed Web Server to purge everything."
3312
  msgstr ""
3313
 
3314
- #: inc/litespeed-cache.class.php:274 includes/litespeed-cache.class.php:274
3315
  msgid "Notified LiteSpeed Web Server to purge the list."
3316
  msgstr ""
3317
 
3318
- #: inc/purge.class.php:203 includes/litespeed-cache-purge.class.php:203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3319
  msgid "Purge category %s"
3320
  msgstr ""
3321
 
3322
- #: inc/purge.class.php:230 includes/litespeed-cache-purge.class.php:230
3323
  msgid "Purge Post ID %s"
3324
  msgstr ""
3325
 
3326
- #: inc/purge.class.php:259 includes/litespeed-cache-purge.class.php:259
3327
  msgid "Purge tag %s"
3328
  msgstr ""
3329
 
3330
- #: inc/purge.class.php:293 includes/litespeed-cache-purge.class.php:293
3331
  msgid "Purge url %s"
3332
  msgstr ""
3333
 
3334
- #: inc/task.class.php:112 includes/litespeed-cache-task.class.php:112
3335
- msgid "LiteSpeed Cache Custom Cron"
 
 
 
 
 
 
 
 
3336
  msgstr ""
3337
 
3338
  #: lib/litespeed/litespeed-crawler.class.php:174
@@ -3388,68 +3264,76 @@ msgstr ""
3388
  msgid "Failed to write to %s."
3389
  msgstr ""
3390
 
3391
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:607
3392
  msgid "WooCommerce"
3393
  msgstr ""
3394
 
3395
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:610
3396
  msgid "Purge product on changes to the quantity or stock status."
3397
  msgstr ""
3398
 
3399
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:611
3400
  msgid "Purge categories only when stock status changes."
3401
  msgstr ""
3402
 
3403
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:612
3404
  msgid "Purge product and categories only when the stock status changes."
3405
  msgstr ""
3406
 
3407
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:613
3408
  msgid "Purge product only when the stock status changes."
3409
  msgstr ""
3410
 
3411
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:614
3412
  msgid "Do not purge categories on changes to the quantity or stock status."
3413
  msgstr ""
3414
 
3415
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:615
3416
  msgid ""
3417
  "Always purge both product and categories on changes to the quantity or stock "
3418
  "status."
3419
  msgstr ""
3420
 
3421
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:618
3422
  msgid ""
3423
  "Determines how changes in product quantity and product stock status affect "
3424
  "product pages and their associated category pages."
3425
  msgstr ""
3426
 
3427
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:619
3428
  msgid ""
3429
  "Checking this option will force the shop page to use the front page TTL "
3430
  "setting."
3431
  msgstr ""
3432
 
3433
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:620
3434
  msgid ""
3435
  "For example, if the homepage for the site is located at %1$s, the shop page "
3436
  "may be located at %2$s."
3437
  msgstr ""
3438
 
3439
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:648
3440
  msgid "Product Update Interval"
3441
  msgstr ""
3442
 
3443
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:655
3444
  msgid "Use Front Page TTL for the Shop Page"
3445
  msgstr ""
3446
 
3447
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:665
 
 
 
 
 
 
 
 
3448
  msgid "After verifying that the cache works in general, please test the cart."
3449
  msgstr ""
3450
 
3451
- #: thirdparty/lscwp-3rd-woocommerce.cls.php:666
3452
- msgid "To test the cart, visit the %s."
3453
  msgstr ""
3454
 
3455
  #. Plugin Name of the plugin/theme
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.7\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2017-12-15 17:17:00+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
12
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
  "Language-Team: LANGUAGE <LL@li.org>\n"
14
 
15
+ #: admin/admin-api.class.php:213
16
+ msgid "IAPI Error %s"
17
+ msgstr ""
18
+
19
+ #: admin/admin-api.class.php:275
20
+ msgid "Failed to communicate with LiteSpeed image server"
21
+ msgstr ""
22
+
23
+ #: admin/admin-api.class.php:283 admin/admin-api.class.php:291
24
+ msgid "Message from LiteSpeed image server"
25
  msgstr ""
26
 
27
  #: admin/litespeed-cache-admin-display.class.php:140
29
  msgstr ""
30
 
31
  #: admin/litespeed-cache-admin-display.class.php:142
32
+ #: admin/litespeed-cache-admin-display.class.php:232
33
  msgid "Settings"
34
  msgstr ""
35
 
37
  msgid "Edit .htaccess"
38
  msgstr ""
39
 
40
+ #: admin/litespeed-cache-admin-display.class.php:149
41
+ msgid "Image Optimization"
42
  msgstr ""
43
 
44
+ #: admin/litespeed-cache-admin-display.class.php:150 admin/tpl/settings.php:29
 
45
  msgid "Crawler"
46
  msgstr ""
47
 
48
+ #: admin/litespeed-cache-admin-display.class.php:151
49
+ msgid "Report"
50
  msgstr ""
51
 
52
+ #: admin/litespeed-cache-admin-display.class.php:155
53
  #: admin/tpl/setting/settings_debug.php:10
54
  msgid "Debug Log"
55
  msgstr ""
56
 
57
+ #: admin/litespeed-cache-admin-display.class.php:252
58
  msgid ""
59
  "It is recommended that LiteSpeed Cache be purged after updating a plugin."
60
  msgstr ""
61
 
62
+ #: admin/litespeed-cache-admin-display.class.php:292
63
  msgid "LiteSpeed Cache Purge All"
64
  msgstr ""
65
 
66
+ #: admin/litespeed-cache-admin-display.class.php:834
67
+ #: admin/tpl/setting/settings_media.php:66
68
+ #: admin/tpl/setting/settings_optimize.php:135
69
+ #: admin/tpl/setting/settings_tuning.php:19
70
+ #: admin/tpl/setting/settings_tuning.php:55
71
  msgid "ON"
72
  msgstr ""
73
 
74
+ #: admin/litespeed-cache-admin-display.class.php:838
75
+ #: admin/tpl/setting/settings_tuning.php:16
76
+ #: admin/tpl/setting/settings_tuning.php:52
77
  msgid "OFF"
78
  msgstr ""
79
 
80
+ #: admin/litespeed-cache-admin-display.class.php:871
81
  msgid "Recommended value: %s"
82
  msgstr ""
83
 
297
  msgid "%s file did not find a place to insert define."
298
  msgstr ""
299
 
300
+ #: admin/litespeed-cache-admin-optimize.class.php:141
301
  msgid "Clean all successfully."
302
  msgstr ""
303
 
304
+ #: admin/litespeed-cache-admin-optimize.class.php:148
305
  msgid "Clean post revisions successfully."
306
  msgstr ""
307
 
308
+ #: admin/litespeed-cache-admin-optimize.class.php:152
309
  msgid "Clean auto drafts successfully."
310
  msgstr ""
311
 
312
+ #: admin/litespeed-cache-admin-optimize.class.php:156
313
  msgid "Clean trashed posts and pages successfully."
314
  msgstr ""
315
 
316
+ #: admin/litespeed-cache-admin-optimize.class.php:160
317
  msgid "Clean spam comments successfully."
318
  msgstr ""
319
 
320
+ #: admin/litespeed-cache-admin-optimize.class.php:164
321
  msgid "Clean trashed comments successfully."
322
  msgstr ""
323
 
324
+ #: admin/litespeed-cache-admin-optimize.class.php:168
325
  msgid "Clean trackbacks and pingbacks successfully."
326
  msgstr ""
327
 
328
+ #: admin/litespeed-cache-admin-optimize.class.php:172
329
  msgid "Clean expired transients successfully."
330
  msgstr ""
331
 
332
+ #: admin/litespeed-cache-admin-optimize.class.php:176
333
  msgid "Clean all transients successfully."
334
  msgstr ""
335
 
336
+ #: admin/litespeed-cache-admin-optimize.class.php:186
337
  msgid "Optimized all tables."
338
  msgstr ""
339
 
340
+ #: admin/litespeed-cache-admin-optimize.class.php:191
341
  msgid "Clean all CSS/JS optimizer data successfully."
342
  msgstr ""
343
 
344
+ #: admin/litespeed-cache-admin-report.class.php:60
345
+ msgid "Failed to push to LiteSpeed server: %s"
346
+ msgstr ""
347
+
348
+ #: admin/litespeed-cache-admin-rules.class.php:678
349
  msgid ""
350
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
351
  "%2$s"
352
  msgstr ""
353
 
354
+ #: admin/litespeed-cache-admin-rules.class.php:876
355
  msgid "File Saved."
356
  msgstr ""
357
 
364
  msgstr ""
365
 
366
  #: admin/litespeed-cache-admin-settings.class.php:258
367
+ #: admin/litespeed-cache-admin-settings.class.php:749
368
  msgid "Default Public Cache"
369
  msgstr ""
370
 
392
  msgid "500"
393
  msgstr ""
394
 
395
+ #: admin/litespeed-cache-admin-settings.class.php:610
396
  #: admin/tpl/setting/settings_debug.php:75
397
  msgid "Log File Size Limit"
398
  msgstr ""
399
 
400
+ #: admin/litespeed-cache-admin-settings.class.php:676
401
  #: admin/tpl/setting/settings_crawler.php:10
402
  msgid "Delay"
403
  msgstr ""
404
 
405
+ #: admin/litespeed-cache-admin-settings.class.php:677
406
  #: admin/tpl/setting/settings_crawler.php:22
407
  msgid "Run Duration"
408
  msgstr ""
409
 
410
+ #: admin/litespeed-cache-admin-settings.class.php:678
411
  msgid "Cron Interval"
412
  msgstr ""
413
 
414
+ #: admin/litespeed-cache-admin-settings.class.php:679
415
  msgid "Whole Interval"
416
  msgstr ""
417
 
418
+ #: admin/litespeed-cache-admin-settings.class.php:680
419
  #: admin/tpl/setting/settings_crawler.php:58
420
  msgid "Threads"
421
  msgstr ""
422
 
423
+ #: admin/litespeed-cache-admin.class.php:205
424
  msgid ""
425
  "For this scenario only, the network admin may uncheck \"Check Advanced Cache"
426
  "\" in LiteSpeed Cache settings."
427
  msgstr ""
428
 
429
+ #: admin/litespeed-cache-admin.class.php:207
430
  msgid ""
431
  "For this scenario only, please uncheck \"Check Advanced Cache\" in LiteSpeed "
432
  "Cache settings."
433
  msgstr ""
434
 
435
+ #: admin/litespeed-cache-admin.class.php:209
436
  msgid ""
437
  "Please disable/deactivate any other Full Page Cache solutions that are "
438
  "currently being used."
439
  msgstr ""
440
 
441
+ #: admin/litespeed-cache-admin.class.php:210
442
  msgid ""
443
  "LiteSpeed Cache does work with other cache solutions, but only their non-"
444
  "page caching offerings—such as minifying css/js files."
445
  msgstr ""
446
 
447
+ #: admin/tpl/crawler.php:15 admin/tpl/crawler.php:81
448
  msgid "LiteSpeed Cache Crawler"
449
  msgstr ""
450
 
451
+ #: admin/tpl/crawler.php:23
452
  msgid "Crawler File"
453
  msgstr ""
454
 
455
+ #: admin/tpl/crawler.php:25
456
  msgid "Generate Crawler File"
457
  msgstr ""
458
 
459
+ #: admin/tpl/crawler.php:30
460
  msgid "Generated at %s"
461
  msgstr ""
462
 
463
+ #: admin/tpl/crawler.php:34
464
  msgid ""
465
  "On click, this will create a crawler sitemap file in plugin directory %s."
466
  msgstr ""
467
 
468
+ #: admin/tpl/crawler.php:44
469
  msgid "%d hours"
470
  msgstr ""
471
 
472
+ #: admin/tpl/crawler.php:47
473
  msgid "%d hour"
474
  msgstr ""
475
 
476
+ #: admin/tpl/crawler.php:54
477
  msgid "%d minutes"
478
  msgstr ""
479
 
480
+ #: admin/tpl/crawler.php:57
481
  msgid "%d minute"
482
  msgstr ""
483
 
484
+ #: admin/tpl/crawler.php:61
485
  msgid "Crawler Cron"
486
  msgstr ""
487
 
488
+ #: admin/tpl/crawler.php:64 admin/tpl/setting/settings_optimize.php:10
489
+ #: admin/tpl/settings.php:130
490
  msgid "WARNING"
491
  msgstr ""
492
 
493
+ #: admin/tpl/crawler.php:65
494
  msgid ""
495
  "The crawler feature is not enabled on the LiteSpeed server. Please consult "
496
  "your server admin."
497
  msgstr ""
498
 
499
+ #: admin/tpl/crawler.php:66
500
  msgid ""
501
  "See <a %s>Introduction for Enabling the Crawler</a> for detailed infomation."
502
  msgstr ""
503
 
504
+ #: admin/tpl/crawler.php:71
505
  msgid "Cron Name"
506
  msgstr ""
507
 
508
+ #: admin/tpl/crawler.php:72
509
  msgid "Run Frequency"
510
  msgstr ""
511
 
512
+ #: admin/tpl/crawler.php:73
513
  msgid "Last Status"
514
  msgstr ""
515
 
516
+ #: admin/tpl/crawler.php:74
517
  msgid "Activation"
518
  msgstr ""
519
 
520
+ #: admin/tpl/crawler.php:75
521
  msgid "Actions"
522
  msgstr ""
523
 
524
+ #: admin/tpl/crawler.php:88
525
  msgid "The current sitemap crawl started at %s"
526
  msgstr ""
527
 
528
+ #: admin/tpl/crawler.php:91
529
  msgid "The next complete sitemap crawl will start at %s"
530
  msgstr ""
531
 
532
+ #: admin/tpl/crawler.php:105
533
  msgid "The last complete run cost %s seconds"
534
  msgstr ""
535
 
536
+ #: admin/tpl/crawler.php:115
537
  msgid "Is running"
538
  msgstr ""
539
 
540
+ #: admin/tpl/crawler.php:131 admin/tpl/setting/settings_general.php:30
541
  msgid "Enable"
542
  msgstr ""
543
 
544
+ #: admin/tpl/crawler.php:131 admin/tpl/esi_widget_edit.php:58
545
  #: admin/tpl/setting/settings_general.php:24
546
  msgid "Disable"
547
  msgstr ""
548
 
549
+ #: admin/tpl/crawler.php:138
550
  msgid "Reset position"
551
  msgstr ""
552
 
553
+ #: admin/tpl/crawler.php:141
554
  msgid "Manually run"
555
  msgstr ""
556
 
557
+ #: admin/tpl/crawler.php:145
558
  msgid "<b>Last interval:</b> %s"
559
  msgstr ""
560
 
561
+ #: admin/tpl/crawler.php:151
562
  msgid "<b>Ended reason:</b> %s"
563
  msgstr ""
564
 
565
+ #: admin/tpl/crawler.php:157
566
  msgid "<b>Last crawled:</b> %s item(s)"
567
  msgstr ""
568
 
569
+ #: admin/tpl/crawler.php:165
570
  msgid "Run frequency is set by the Interval Between Runs setting."
571
  msgstr ""
572
 
573
+ #: admin/tpl/crawler.php:166
574
  msgid "Only one crawler can run concurrently."
575
  msgstr ""
576
 
577
+ #: admin/tpl/crawler.php:167
578
  msgid ""
579
  "If both the cron and manual run start at a similar time, the first one to "
580
  "start will run."
581
  msgstr ""
582
 
583
+ #: admin/tpl/crawler.php:168
584
  msgid ""
585
  "Please follow <a %s>Hooking WP-Cron Into the System Task Scheduler</a> to "
586
  "create the system cron task."
587
  msgstr ""
588
 
589
+ #: admin/tpl/crawler.php:173
590
  msgid "Watch Crawler Status"
591
  msgstr ""
592
 
593
+ #: admin/tpl/crawler.php:180
594
  msgid "Show crawler status"
595
  msgstr ""
596
 
597
+ #: admin/tpl/crawler.php:198
598
  msgid "No crawler meta file generated yet"
599
  msgstr ""
600
 
601
+ #: admin/tpl/crawler.php:203
602
  msgid "Sitemap Generation Blacklist"
603
  msgstr ""
604
 
605
+ #: admin/tpl/crawler.php:212 admin/tpl/edit_htaccess.php:68
606
  msgid "Save"
607
  msgstr ""
608
 
609
+ #: admin/tpl/crawler.php:216
610
  msgid "Current blacklist has %s item(s)."
611
  msgstr ""
612
 
613
+ #: admin/tpl/crawler.php:217
614
  msgid ""
615
  "All Urls which returned no-cache tags will be added here, after the initial "
616
  "crawling."
620
  msgid "LiteSpeed Cache Debug Log Viewer"
621
  msgstr ""
622
 
623
+ #: admin/tpl/debug_log.php:29
624
+ msgid "Clear Log"
625
+ msgstr ""
626
+
627
  #: admin/tpl/edit_htaccess.php:31
628
  msgid "LiteSpeed Cache Edit .htaccess"
629
  msgstr ""
658
  "changed."
659
  msgstr ""
660
 
661
+ #: admin/tpl/esi_widget_edit.php:30 admin/tpl/setting/settings_esi.php:27
662
  msgid "Enable ESI"
663
  msgstr ""
664
 
684
  #: admin/tpl/setting/settings_general.php:108
685
  #: admin/tpl/setting/settings_general.php:121
686
  #: admin/tpl/setting/settings_general.php:134
687
+ #: admin/tpl/setting/settings_inc.cache_browser.php:24
688
+ #: admin/tpl/setting/settings_optimize.php:86
689
  msgid "seconds"
690
  msgstr ""
691
 
697
  msgid "A TTL of 0 indicates do not cache."
698
  msgstr ""
699
 
700
+ #: admin/tpl/image_optimization.php:13
701
+ msgid "Level"
 
 
702
  msgstr ""
703
 
704
+ #: admin/tpl/image_optimization.php:17
705
+ msgid "Credit"
 
 
706
  msgstr ""
707
 
708
+ #: admin/tpl/image_optimization.php:18
709
+ msgid "Credit recovers with each successful pull."
710
  msgstr ""
711
 
712
+ #: admin/tpl/image_optimization.php:22
713
+ msgid "Total Reduction"
714
  msgstr ""
715
 
716
+ #: admin/tpl/image_optimization.php:26
717
+ msgid "Images pulled"
 
 
718
  msgstr ""
719
 
720
+ #: admin/tpl/image_optimization.php:29
721
+ msgid "Images failed to fetch"
 
 
722
  msgstr ""
723
 
724
+ #: admin/tpl/image_optimization.php:32
725
+ msgid "Images failed to notify"
726
  msgstr ""
727
 
728
+ #: admin/tpl/image_optimization.php:35
729
+ msgid "Images failed to pull"
730
  msgstr ""
731
 
732
+ #: admin/tpl/image_optimization.php:38
733
+ msgid "Last Request"
734
  msgstr ""
735
 
736
+ #: admin/tpl/image_optimization.php:49
737
+ msgid "LiteSpeed Cache Image Optimization"
 
738
  msgstr ""
739
 
740
+ #: admin/tpl/image_optimization.php:58
741
+ msgid "Optimization Summary"
742
  msgstr ""
743
 
744
+ #: admin/tpl/image_optimization.php:88 admin/tpl/image_optimization.php:108
745
+ msgid "Update Reduction Status"
746
  msgstr ""
747
 
748
+ #: admin/tpl/image_optimization.php:91
749
  msgid ""
750
+ "This will communicate with LiteSpeed's Image Optimization Server and "
751
+ "retrieve the most recent status."
752
  msgstr ""
753
 
754
+ #: admin/tpl/image_optimization.php:96
755
+ msgid "Image Information"
 
 
756
  msgstr ""
757
 
758
+ #: admin/tpl/image_optimization.php:97
759
+ msgid "Beta Version"
760
  msgstr ""
761
 
762
+ #: admin/tpl/image_optimization.php:100
763
+ msgid "<a %s>Image groups</a> total"
764
  msgstr ""
765
 
766
+ #: admin/tpl/image_optimization.php:101
767
+ msgid "Image groups not yet requested"
768
  msgstr ""
769
 
770
+ #: admin/tpl/image_optimization.php:105 admin/tpl/image_optimization.php:113
771
+ msgid "Send Optimization Request"
 
772
  msgstr ""
773
 
774
+ #: admin/tpl/image_optimization.php:108
775
+ msgid "Please press the %s button before sending a new request."
 
 
776
  msgstr ""
777
 
778
+ #: admin/tpl/image_optimization.php:110 admin/tpl/image_optimization.php:149
779
+ msgid "Learn More"
 
 
780
  msgstr ""
781
 
782
+ #: admin/tpl/image_optimization.php:116
783
  msgid ""
784
+ "This will send the optimization request and the images to LiteSpeed's Image "
785
+ "Optimization Server."
786
  msgstr ""
787
 
788
+ #: admin/tpl/image_optimization.php:117
789
+ msgid "You can send at most %s images at once."
790
  msgstr ""
791
 
792
+ #: admin/tpl/image_optimization.php:125
793
+ msgid "Image groups requested"
794
  msgstr ""
795
 
796
+ #: admin/tpl/image_optimization.php:127
797
+ msgid "Image groups failed to optimize"
798
  msgstr ""
799
 
800
+ #: admin/tpl/image_optimization.php:129
801
  msgid ""
802
+ "After LiteSpeed's Image Optimization Server finishes optimization, it will "
803
+ "notify your site to pull the optimized images."
804
  msgstr ""
805
 
806
+ #: admin/tpl/image_optimization.php:130
807
+ msgid "This process is automatic."
 
808
  msgstr ""
809
 
810
+ #: admin/tpl/image_optimization.php:133
811
+ msgid "Image groups notified to pull"
812
  msgstr ""
813
 
814
+ #: admin/tpl/image_optimization.php:136
815
+ msgid "Pull Images"
 
 
816
  msgstr ""
817
 
818
+ #: admin/tpl/image_optimization.php:139
819
+ msgid "Only press the button if the pull cron job is disabled."
 
820
  msgstr ""
821
 
822
+ #: admin/tpl/image_optimization.php:140
823
+ msgid "Images will be pulled automatically if the cron job is running."
 
 
824
  msgstr ""
825
 
826
+ #: admin/tpl/image_optimization.php:144
827
+ msgid "Last pull initiated by cron at %s."
 
 
 
 
828
  msgstr ""
829
 
830
+ #: admin/tpl/image_optimization.php:148
831
+ msgid "Image groups optimized and pulled"
832
  msgstr ""
833
 
834
+ #: admin/tpl/image_optimization.php:154
835
+ msgid "Revert Optimization"
 
 
836
  msgstr ""
837
 
838
+ #: admin/tpl/image_optimization.php:157
839
+ msgid ""
840
+ "Switch all images in the media library back to their original unoptimized "
841
+ "versions."
842
  msgstr ""
843
 
844
+ #: admin/tpl/image_optimization.php:163
845
+ msgid "Undo Optimization"
846
  msgstr ""
847
 
848
+ #: admin/tpl/image_optimization.php:166
849
+ msgid "Revert all optimized images back to their original versions."
 
 
850
  msgstr ""
851
 
852
+ #: admin/tpl/image_optimization.php:172
853
+ msgid "Re-do Optimization"
854
  msgstr ""
855
 
856
+ #: admin/tpl/image_optimization.php:175
857
+ msgid "Switch back to using optimized images."
858
  msgstr ""
859
 
860
+ #: admin/tpl/image_optimization.php:180
861
+ msgid "Results can be checked in <a %s>Media Library</a>."
862
  msgstr ""
863
 
864
+ #: admin/tpl/image_optimization.php:184
865
+ msgid "Send New Thumbnail Requests"
 
 
866
  msgstr ""
867
 
868
+ #: admin/tpl/image_optimization.php:187
869
+ msgid ""
870
+ "Scan for any new unoptimized image thumbnail sizes and resend necessary "
871
+ "image optimization requests."
872
  msgstr ""
873
 
874
+ #: admin/tpl/image_optimization.php:192
875
+ msgid "Destroy All Optimization Data!"
876
  msgstr ""
877
 
878
+ #: admin/tpl/image_optimization.php:195
879
  msgid ""
880
+ "Remove all previous image optimization requests/results, revert completed "
881
+ "optimizations, and delete all optimization files."
882
  msgstr ""
883
 
884
+ #: admin/tpl/image_optimization.php:197
885
  #: admin/tpl/setting/settings_excludes.php:60
886
  #: admin/tpl/setting/settings_excludes.php:98
887
  #: admin/tpl/setting/settings_inc.cache_browser.php:12
890
  #: admin/tpl/setting/settings_inc.cache_resources.php:15
891
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:22
892
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:21
893
+ #: admin/tpl/setting/settings_inc.media_webp.php:12
894
+ #: admin/tpl/setting/settings_optimize.php:137
895
+ #: admin/tpl/setting/settings_tuning.php:18
896
+ #: admin/tpl/setting/settings_tuning.php:54
897
  msgid "NOTE:"
898
  msgstr ""
899
 
900
+ #: admin/tpl/image_optimization.php:198
 
 
 
 
 
 
 
 
 
 
 
 
 
901
  msgid ""
902
+ "If there are unfinished requests in progress, the requests' credits will NOT "
903
+ "be recovered."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
904
  msgstr ""
905
 
906
+ #: admin/tpl/image_optimization.php:198
907
+ #: admin/tpl/setting/settings_optimize.php:63
908
+ #: admin/tpl/setting/settings_optimize.php:138
909
+ msgid "JS Combine"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
910
  msgstr ""
911
 
912
+ #: admin/tpl/inc/admin_footer.php:5
913
  msgid ""
914
+ "Rate <strong>LiteSpeed Cache</strong> with %s on WordPress.org if you like "
915
+ "us!"
 
916
  msgstr ""
917
 
918
+ #: admin/tpl/inc/admin_footer.php:8
919
  msgid ""
920
+ "If there are any questions that are not answered in the <a %s>FAQs</a>, do "
921
+ "not hesitate to ask them on the <a %s>support forum</a>."
 
 
 
 
 
922
  msgstr ""
923
 
924
+ #: admin/tpl/inc/api_key.php:11
925
+ msgid "This will also generate an API key from LiteSpeed's Server."
 
 
926
  msgstr ""
927
 
928
+ #: admin/tpl/inc/banner_promo.php:14
929
+ msgid "Welcome to LiteSpeed"
 
 
 
 
 
 
 
 
 
 
930
  msgstr ""
931
 
932
+ #: admin/tpl/inc/banner_promo.php:17
933
+ msgid "Thank you for using LiteSpeed."
934
  msgstr ""
935
 
936
+ #: admin/tpl/inc/banner_promo.php:19
937
  msgid ""
938
+ "If you have any questions, please do not hesitate to let us know in <a "
939
+ "%s>our support forum</a> or by <a %s>submitting a ticket with us</a>."
 
940
  msgstr ""
941
 
942
+ #: admin/tpl/inc/banner_promo.php:26
943
  msgid ""
944
+ "This plugin is created with love by LiteSpeed. Your rating is the simplest "
945
+ "way to support us. We really appreciate it!"
 
 
946
  msgstr ""
947
 
948
+ #: admin/tpl/inc/banner_promo.php:29
949
+ msgid "Sure I'd love to!"
950
  msgstr ""
951
 
952
+ #: admin/tpl/inc/banner_promo.php:30
953
+ msgid "I've already left a review"
 
 
954
  msgstr ""
955
 
956
+ #: admin/tpl/inc/banner_promo.php:31
957
+ msgid "Maybe later"
958
  msgstr ""
959
 
960
+ #: admin/tpl/inc/check_cache_disabled.php:10
961
  msgid ""
962
+ "WARNING: LiteSpeed cache is disabled. The functionalities here can not work."
 
 
 
 
 
963
  msgstr ""
964
 
965
+ #: admin/tpl/inc/help_tabs.php:7
966
+ msgid "Overview"
 
 
 
967
  msgstr ""
968
 
969
+ #: admin/tpl/inc/help_tabs.php:9
970
+ msgid "LiteSpeed Cache is a page cache built into LiteSpeed Web Server."
971
  msgstr ""
972
 
973
+ #: admin/tpl/inc/help_tabs.php:10
974
  msgid ""
975
+ "This plugin communicates with LiteSpeed Web Server to let it know which "
976
+ "pages are cacheable and when to purge them."
 
 
 
977
  msgstr ""
978
 
979
+ #: admin/tpl/inc/help_tabs.php:11
980
  msgid ""
981
+ "A LiteSpeed server (OLS, LSWS, WebADC) and its LSCache module must be "
982
+ "installed and enabled."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
983
  msgstr ""
984
 
985
+ #: admin/tpl/inc/help_tabs.php:22
986
+ msgid "For more information:"
987
  msgstr ""
988
 
989
+ #: admin/tpl/inc/help_tabs.php:24
990
+ msgid "Support Forum"
991
  msgstr ""
992
 
993
+ #: admin/tpl/inc/show_display_installed.php:5
994
+ msgid "LiteSpeed Cache plugin is installed!"
 
 
995
  msgstr ""
996
 
997
+ #: admin/tpl/inc/show_display_installed.php:6
998
  msgid ""
999
+ "This message indicates that the plugin was installed by the server admin."
 
1000
  msgstr ""
1001
 
1002
+ #: admin/tpl/inc/show_display_installed.php:7
1003
  msgid ""
1004
+ "The LiteSpeed Cache plugin is used to cache pages - a simple way to improve "
1005
+ "the performance of the site."
 
 
 
 
1006
  msgstr ""
1007
 
1008
+ #: admin/tpl/inc/show_display_installed.php:8
1009
  msgid ""
1010
+ "However, there is no way of knowing all the possible customizations that "
1011
+ "were implemented."
 
 
 
1012
  msgstr ""
1013
 
1014
+ #: admin/tpl/inc/show_display_installed.php:9
1015
  msgid ""
1016
+ "For that reason, please test the site to make sure everything still "
1017
+ "functions properly."
 
 
 
 
1018
  msgstr ""
1019
 
1020
+ #: admin/tpl/inc/show_display_installed.php:11
1021
+ msgid "Examples of test cases include:"
1022
  msgstr ""
1023
 
1024
+ #: admin/tpl/inc/show_display_installed.php:13
1025
+ msgid "Visit the site while logged out."
 
1026
  msgstr ""
1027
 
1028
+ #: admin/tpl/inc/show_display_installed.php:14
1029
+ msgid "Create a post, make sure the front page is accurate."
1030
  msgstr ""
1031
 
1032
+ #: admin/tpl/inc/show_display_installed.php:16
1033
  msgid ""
1034
+ "If there are any questions, the team is always happy to answer any questions "
1035
+ "on the <a %s>support forum</a>."
1036
  msgstr ""
1037
 
1038
+ #: admin/tpl/inc/show_display_installed.php:19
1039
  msgid ""
1040
+ "If you would rather not move at litespeed, you can deactivate this plugin."
 
 
 
 
 
 
 
 
 
 
 
 
1041
  msgstr ""
1042
 
1043
+ #: admin/tpl/inc/show_error_cookie.php:4
1044
+ msgid "NOTICE: Database login cookie did not match your login cookie."
 
 
1045
  msgstr ""
1046
 
1047
+ #: admin/tpl/inc/show_error_cookie.php:5
1048
  msgid ""
1049
+ "If the login cookie was recently changed in the settings, please log out and "
1050
+ "back in."
1051
  msgstr ""
1052
 
1053
+ #: admin/tpl/inc/show_error_cookie.php:6
1054
  msgid ""
1055
+ "If not, please verify the setting in the <a href=\"%1$s\">Advanced tab</a>."
 
 
 
 
 
 
 
 
 
1056
  msgstr ""
1057
 
1058
+ #: admin/tpl/inc/show_error_cookie.php:10
1059
  msgid ""
1060
+ "If using OpenLiteSpeed, the server must be restarted once for the changes to "
1061
+ "take effect."
 
 
 
 
 
 
 
 
 
 
 
 
1062
  msgstr ""
1063
 
1064
+ #: admin/tpl/inc/show_rule_conflict.php:5
1065
  msgid ""
1066
+ "Unexpected cache rule %2$s found in %1$s file. This rule may cause visitors "
1067
+ "to see old versions of pages due to the browser caching html pages. If you "
1068
+ "are sure that html pages are not being browser cached, this message can be "
1069
+ "dismissed. (<a %3$s>Learn More</a>)"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1070
  msgstr ""
1071
 
1072
  #: admin/tpl/manage/manage_db.php:6
1269
  #: admin/tpl/setting/settings_excludes.php:94
1270
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:19
1271
  #: admin/tpl/setting/settings_media.php:27
 
 
 
 
1272
  #: admin/tpl/setting/settings_purge.php:79
1273
+ #: admin/tpl/setting/settings_tuning.php:36
1274
+ #: admin/tpl/setting/settings_tuning.php:72
1275
+ #: admin/tpl/setting/settings_tuning.php:131
1276
+ #: admin/tpl/setting/settings_tuning.php:160
1277
  msgid "One per line."
1278
  msgstr ""
1279
 
1344
  msgstr ""
1345
 
1346
  #: admin/tpl/network_settings.php:9 admin/tpl/setting/settings_debug.php:65
1347
+ #: admin/tpl/settings.php:20
1348
  msgid "Advanced"
1349
  msgstr ""
1350
 
1351
+ #: admin/tpl/network_settings.php:10 admin/tpl/settings.php:13
1352
+ msgid "Media"
1353
  msgstr ""
1354
 
1355
+ #: admin/tpl/network_settings.php:20
1356
+ msgid "LiteSpeed Cache Network Settings"
1357
  msgstr ""
1358
 
1359
+ #: admin/tpl/report.php:13
1360
+ msgid "LiteSpeed Cache Report"
 
 
1361
  msgstr ""
1362
 
1363
+ #: admin/tpl/report.php:22
1364
+ msgid "LiteSpeed Report Number"
 
 
1365
  msgstr ""
1366
 
1367
+ #: admin/tpl/report.php:24
1368
+ msgid "Report number"
 
 
1369
  msgstr ""
1370
 
1371
+ #: admin/tpl/report.php:25
1372
+ msgid "Report date"
1373
  msgstr ""
1374
 
1375
  #: admin/tpl/report.php:28
1376
+ msgid "Send To LiteSpeed"
1377
  msgstr ""
1378
 
1379
+ #: admin/tpl/report.php:31
1380
  msgid ""
1381
+ "Send this report to LiteSpeed. Refer to this report number when posting in "
1382
+ "the WordPress support forum."
1383
+ msgstr ""
1384
+
1385
+ #: admin/tpl/report.php:36
1386
+ msgid "Report Summary"
1387
  msgstr ""
1388
 
1389
+ #: admin/tpl/report.php:38
1390
+ msgid ""
1391
+ "The environment report contains detailed information about the WordPress "
1392
+ "configuration."
1393
  msgstr ""
1394
 
1395
  #: admin/tpl/report.php:40
1396
+ msgid ""
1397
+ "If you run into any issues, please refer to the report number in your "
1398
+ "support message."
1399
  msgstr ""
1400
 
1401
  #: admin/tpl/setting/network_settings_cache.php:4
1458
  msgid "This will disable the settings page on all subsites."
1459
  msgstr ""
1460
 
1461
+ #: admin/tpl/setting/network_settings_media.php:4
1462
+ msgid "Network Media Settings"
1463
+ msgstr ""
1464
+
1465
  #: admin/tpl/setting/network_settings_purge.php:4
1466
  msgid "Purge Network Settings"
1467
  msgstr ""
1468
 
1469
+ #: admin/tpl/setting/settings_advanced.php:6
1470
+ msgid "NOTICE:"
1471
+ msgstr ""
1472
+
1473
  #: admin/tpl/setting/settings_advanced.php:8
1474
  msgid "These settings are meant for ADVANCED USERS ONLY."
1475
  msgstr ""
1634
 
1635
  #: admin/tpl/setting/settings_cache.php:62
1636
  #: admin/tpl/setting/settings_excludes.php:14
1637
+ #: admin/tpl/setting/settings_tuning.php:159
1638
  msgid "For example, for %s, %s can be used here."
1639
  msgstr ""
1640
 
1979
 
1980
  #: admin/tpl/setting/settings_debug.php:46
1981
  msgid ""
1982
+ "More information about the available commands can be found <a %s>here</a>."
 
1983
  msgstr ""
1984
 
1985
  #: admin/tpl/setting/settings_debug.php:53
2056
  msgid "Filters containing these strings (one per line) will not be logged."
2057
  msgstr ""
2058
 
2059
+ #: admin/tpl/setting/settings_esi.php:6
2060
  msgid "ESI Settings"
2061
  msgstr ""
2062
 
2063
+ #: admin/tpl/setting/settings_esi.php:9
2064
  msgid ""
2065
  "With ESI (Edge Side Includes), pages may be served from cache for logged-in "
2066
  "users."
2067
  msgstr ""
2068
 
2069
+ #: admin/tpl/setting/settings_esi.php:10
2070
  msgid ""
2071
  "ESI allows you to designate parts of your dynamic page as separate fragments "
2072
  "that are then assembled together to make the whole page. In other words, ESI "
2075
  "cached at all."
2076
  msgstr ""
2077
 
2078
+ #: admin/tpl/setting/settings_esi.php:12
2079
  msgid "Learn more about public cache vs. private cache <a %s>on our blog</a>."
2080
  msgstr ""
2081
 
2082
+ #: admin/tpl/setting/settings_esi.php:21
2083
  msgid "Available in LiteSpeed Enterprise version"
2084
  msgstr ""
2085
 
2086
+ #: admin/tpl/setting/settings_esi.php:31
2087
  msgid ""
2088
  "Enable caches public pages for logged in users and serves the Admin Bar and "
2089
  "Comment Form via ESI blocks. These two blocks will be uncached unless "
2090
  "enabled below."
2091
  msgstr ""
2092
 
2093
+ #: admin/tpl/setting/settings_esi.php:37
2094
  msgid "Cache Admin Bar"
2095
  msgstr ""
2096
 
2097
+ #: admin/tpl/setting/settings_esi.php:41
2098
  msgid "Cache the build-in Admin Bar ESI block."
2099
  msgstr ""
2100
 
2101
+ #: admin/tpl/setting/settings_esi.php:47
2102
  msgid "Cache Comment Form"
2103
  msgstr ""
2104
 
2105
+ #: admin/tpl/setting/settings_esi.php:51
2106
  msgid "Cache the build-in Comment Form ESI block."
2107
  msgstr ""
2108
 
2109
+ #: admin/tpl/setting/settings_esi.php:57
2110
  msgid "Vary Group"
2111
  msgstr ""
2112
 
2113
+ #: admin/tpl/setting/settings_esi.php:72
2114
  msgid ""
2115
  "If your site contains public content that certain user roles can see but "
2116
  "other roles cannot, you can specify a Vary Group for those user roles. For "
2163
  msgstr ""
2164
 
2165
  #: admin/tpl/setting/settings_excludes.php:62
2166
+ msgid ""
2167
+ "If the category slug is not found, the category will be removed from the "
2168
+ "list on save."
2169
  msgstr ""
2170
 
2171
  #: admin/tpl/setting/settings_excludes.php:63
2186
  msgstr ""
2187
 
2188
  #: admin/tpl/setting/settings_excludes.php:100
2189
+ msgid ""
2190
+ "If the tag slug is not found, the tag will be removed from the list on save."
2191
+ msgstr ""
2192
+
2193
+ #: admin/tpl/setting/settings_excludes.php:121
2194
+ msgid "Do Not Cache Roles"
2195
+ msgstr ""
2196
+
2197
+ #: admin/tpl/setting/settings_excludes.php:127
2198
+ msgid "Selected roles will be excluded from cache."
2199
  msgstr ""
2200
 
2201
  #: admin/tpl/setting/settings_general.php:9
2211
  msgstr ""
2212
 
2213
  #: admin/tpl/setting/settings_general.php:47
2214
+ #: admin/tpl/setting/settings_optimize.php:16
2215
  msgid "NOTICE"
2216
  msgstr ""
2217
 
2317
  #: admin/tpl/setting/settings_inc.cache_resources.php:16
2318
  #: admin/tpl/setting/settings_inc.exclude_cookies.php:23
2319
  #: admin/tpl/setting/settings_inc.exclude_useragent.php:22
2320
+ #: admin/tpl/setting/settings_inc.media_webp.php:13
2321
  msgid "This setting will edit the .htaccess file."
2322
  msgstr ""
2323
 
2327
  "LiteSpeed browser cache setting</a>."
2328
  msgstr ""
2329
 
2330
+ #: admin/tpl/setting/settings_inc.cache_browser.php:21
2331
+ msgid "Browser Cache TTL"
2332
+ msgstr ""
2333
+
2334
+ #: admin/tpl/setting/settings_inc.cache_browser.php:26
2335
+ msgid ""
2336
+ "The amount of time, in seconds, that files will be stored in browser cache "
2337
+ "before expiring. Minimum is %s seconds."
2338
+ msgstr ""
2339
+
2340
  #: admin/tpl/setting/settings_inc.cache_favicon.php:7
2341
  msgid "Cache favicon.ico"
2342
  msgstr ""
2430
  msgid "SYNTAX: Separate each user agent with a bar, %s."
2431
  msgstr ""
2432
 
2433
+ #: admin/tpl/setting/settings_inc.media_webp.php:6
2434
+ msgid "Image WebP Replacement"
2435
+ msgstr ""
2436
+
2437
+ #: admin/tpl/setting/settings_inc.media_webp.php:10
2438
+ msgid ""
2439
+ "Significantly improve load time by replacing images with their optimized %s "
2440
+ "versions."
2441
+ msgstr ""
2442
+
2443
  #: admin/tpl/setting/settings_inc.purge_on_upgrade.php:7
2444
  msgid "Purge All On Upgrade"
2445
  msgstr ""
2476
  msgstr ""
2477
 
2478
  #: admin/tpl/setting/settings_media.php:26
2479
+ #: admin/tpl/setting/settings_tuning.php:35
2480
+ #: admin/tpl/setting/settings_tuning.php:71
2481
+ #: admin/tpl/setting/settings_tuning.php:130
2482
+ #: admin/tpl/setting/settings_tuning.php:158
2483
  msgid "Both full URLs and partial strings can be used."
2484
  msgstr ""
2485
 
2486
  #: admin/tpl/setting/settings_media.php:29
2487
+ #: admin/tpl/setting/settings_optimize.php:112
2488
+ #: admin/tpl/setting/settings_tuning.php:22
2489
+ #: admin/tpl/setting/settings_tuning.php:38
2490
+ #: admin/tpl/setting/settings_tuning.php:58
2491
+ #: admin/tpl/setting/settings_tuning.php:74
2492
+ #: admin/tpl/setting/settings_tuning.php:133
2493
  msgid "API:"
2494
  msgstr ""
2495
 
2496
  #: admin/tpl/setting/settings_media.php:30
2497
+ #: admin/tpl/setting/settings_tuning.php:39
2498
+ #: admin/tpl/setting/settings_tuning.php:75
2499
+ #: admin/tpl/setting/settings_tuning.php:134
2500
  msgid "Filter %s is supported."
2501
  msgstr ""
2502
 
2503
  #: admin/tpl/setting/settings_media.php:31
2504
+ #: admin/tpl/setting/settings_optimize.php:113
2505
+ #: admin/tpl/setting/settings_tuning.php:40
2506
+ #: admin/tpl/setting/settings_tuning.php:76
2507
+ #: admin/tpl/setting/settings_tuning.php:135
2508
  msgid "Elements with attribute %s in html code will be excluded."
2509
  msgstr ""
2510
 
2540
  msgid "Load iframes only when they enter the viewport."
2541
  msgstr ""
2542
 
2543
+ #: admin/tpl/setting/settings_media.php:62
2544
+ msgid "Disable Optimization Pull"
2545
+ msgstr ""
2546
+
2547
+ #: admin/tpl/setting/settings_media.php:66
2548
+ msgid ""
2549
+ "Set this option to %s to disable the cron job responsible for fetching "
2550
+ "optimized images from LiteSpeed's Image Server."
2551
+ msgstr ""
2552
+
2553
+ #: admin/tpl/setting/settings_media.php:80
2554
+ msgid "Only Request WebP"
2555
+ msgstr ""
2556
+
2557
+ #: admin/tpl/setting/settings_media.php:84
2558
+ msgid ""
2559
+ "Prevent images from being replaced with optimized versions when optimizing. "
2560
+ "WebP versions will still be generated."
2561
+ msgstr ""
2562
+
2563
+ #: admin/tpl/setting/settings_media.php:90
2564
+ msgid "Preserve EXIF data"
2565
+ msgstr ""
2566
+
2567
+ #: admin/tpl/setting/settings_media.php:94
2568
+ msgid ""
2569
+ "Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing."
2570
+ msgstr ""
2571
+
2572
+ #: admin/tpl/setting/settings_media.php:95
2573
+ msgid "This will increase the size of optimized files."
2574
+ msgstr ""
2575
+
2576
+ #: admin/tpl/setting/settings_media.php:101
2577
+ msgid "WebP Lossless Compression"
2578
+ msgstr ""
2579
+
2580
+ #: admin/tpl/setting/settings_media.php:105
2581
+ msgid "Generate WebP images using lossless compression."
2582
+ msgstr ""
2583
+
2584
+ #: admin/tpl/setting/settings_media.php:106
2585
+ msgid "This can improve quality at the cost of larger images."
2586
+ msgstr ""
2587
+
2588
+ #: admin/tpl/setting/settings_optimize.php:6
2589
  msgid "Optimization Settings"
2590
  msgstr ""
2591
 
2592
+ #: admin/tpl/setting/settings_optimize.php:11
2593
  msgid ""
2594
  "Failed to create Optimizer table. Please follow <a %s>Table Creation "
2595
  "guidance from LiteSpeed Wiki</a> to finish setup."
2596
  msgstr ""
2597
 
2598
+ #: admin/tpl/setting/settings_optimize.php:17
2599
  msgid ""
2600
  "Please test thoroughly when enabling any option in this list. After changing "
2601
  "Minify/Combine settings, please do a Purge All action."
2602
  msgstr ""
2603
 
2604
+ #: admin/tpl/setting/settings_optimize.php:23
2605
  msgid "CSS Minify"
2606
  msgstr ""
2607
 
2608
+ #: admin/tpl/setting/settings_optimize.php:27
2609
  msgid "Minify CSS files."
2610
  msgstr ""
2611
 
2612
+ #: admin/tpl/setting/settings_optimize.php:33
2613
  msgid "CSS Combine"
2614
  msgstr ""
2615
 
2616
+ #: admin/tpl/setting/settings_optimize.php:37
2617
  msgid "Combine CSS files."
2618
  msgstr ""
2619
 
2620
+ #: admin/tpl/setting/settings_optimize.php:43
2621
  msgid "CSS HTTP/2 Push"
2622
  msgstr ""
2623
 
2624
+ #: admin/tpl/setting/settings_optimize.php:47
2625
  msgid ""
2626
  "Pre-send internal CSS files to the browser before they are requested. "
2627
  "(Requires the HTTP/2 protocol)"
2628
  msgstr ""
2629
 
2630
+ #: admin/tpl/setting/settings_optimize.php:53
 
 
 
 
 
 
 
 
2631
  msgid "JS Minify"
2632
  msgstr ""
2633
 
2634
+ #: admin/tpl/setting/settings_optimize.php:57
2635
  msgid "Minify JS files."
2636
  msgstr ""
2637
 
2638
+ #: admin/tpl/setting/settings_optimize.php:67
 
 
 
 
 
2639
  msgid "Combine JS files."
2640
  msgstr ""
2641
 
2642
+ #: admin/tpl/setting/settings_optimize.php:73
2643
  msgid "JS HTTP/2 Push"
2644
  msgstr ""
2645
 
2646
+ #: admin/tpl/setting/settings_optimize.php:77
2647
  msgid ""
2648
  "Pre-send internal JS files to the browser before they are requested. "
2649
  "(Requires the HTTP/2 protocol)"
2650
  msgstr ""
2651
 
2652
+ #: admin/tpl/setting/settings_optimize.php:83
 
 
 
 
 
 
 
 
2653
  msgid "CSS/JS Cache TTL"
2654
  msgstr ""
2655
 
2656
+ #: admin/tpl/setting/settings_optimize.php:88
2657
  msgid ""
2658
  "Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s "
2659
  "seconds."
2660
  msgstr ""
2661
 
2662
+ #: admin/tpl/setting/settings_optimize.php:95
2663
  msgid "HTML Minify"
2664
  msgstr ""
2665
 
2666
+ #: admin/tpl/setting/settings_optimize.php:99
2667
  msgid "Minify HTML content."
2668
  msgstr ""
2669
 
2670
+ #: admin/tpl/setting/settings_optimize.php:105
2671
+ #: admin/tpl/setting/settings_tuning.php:119
2672
+ msgid "Load CSS Asynchronously"
2673
  msgstr ""
2674
 
2675
+ #: admin/tpl/setting/settings_optimize.php:109
2676
+ msgid "Optimize CSS delivery. This will load Google Fonts asynchronously too."
2677
  msgstr ""
2678
 
2679
+ #: admin/tpl/setting/settings_optimize.php:110
2680
+ #: admin/tpl/setting/settings_optimize.php:125
2681
+ #: admin/tpl/setting/settings_tuning.php:88
2682
+ #: admin/tpl/setting/settings_tuning.php:147
2683
  msgid ""
2684
  "This can improve your speed score in services like Pingdom, GTmetrix and "
2685
  "PageSpeed."
2686
  msgstr ""
2687
 
2688
+ #: admin/tpl/setting/settings_optimize.php:120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2689
  msgid "Load JS Deferred"
2690
  msgstr ""
2691
 
2692
+ #: admin/tpl/setting/settings_optimize.php:124
2693
  msgid "Doing so can help reduce resource contention and improve performance."
2694
  msgstr ""
2695
 
2696
+ #: admin/tpl/setting/settings_optimize.php:131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2697
  msgid "Exclude JQuery"
2698
  msgstr ""
2699
 
2700
+ #: admin/tpl/setting/settings_optimize.php:135
2701
  msgid ""
2702
  "Improve compatibility with inline JS by preventing jQuery optimization. "
2703
  "(Recommended Setting: %s)"
2704
  msgstr ""
2705
 
2706
+ #: admin/tpl/setting/settings_optimize.php:138
2707
  msgid ""
2708
  "If there is any JS error related to %1$s when enabled %2$s, please try this "
2709
  "option."
2762
  msgstr ""
2763
 
2764
  #: admin/tpl/setting/settings_purge.php:47
2765
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:795
2766
  msgid "Note:"
2767
  msgstr ""
2768
 
2816
  msgid "Current server time is %s."
2817
  msgstr ""
2818
 
2819
+ #: admin/tpl/setting/settings_tuning.php:6
2820
+ msgid "Tuning Settings"
2821
+ msgstr ""
2822
+
2823
+ #: admin/tpl/setting/settings_tuning.php:11
2824
+ msgid "Combined CSS Priority"
2825
+ msgstr ""
2826
+
2827
+ #: admin/tpl/setting/settings_tuning.php:15
2828
+ msgid "Load combined CSS files before other CSS files."
2829
+ msgstr ""
2830
+
2831
+ #: admin/tpl/setting/settings_tuning.php:16
2832
+ #: admin/tpl/setting/settings_tuning.php:52
2833
+ msgid "Set to %s by default."
2834
+ msgstr ""
2835
+
2836
+ #: admin/tpl/setting/settings_tuning.php:19
2837
+ msgid ""
2838
+ "Only set to %s when changing the order of combined and uncombined CSS is "
2839
+ "needed."
2840
+ msgstr ""
2841
+
2842
+ #: admin/tpl/setting/settings_tuning.php:23
2843
+ msgid ""
2844
+ "Elements with attribute %s in html code will be excluded from moving to top."
2845
+ msgstr ""
2846
+
2847
+ #: admin/tpl/setting/settings_tuning.php:30
2848
+ msgid "CSS Excludes"
2849
+ msgstr ""
2850
+
2851
+ #: admin/tpl/setting/settings_tuning.php:34
2852
+ msgid "Listed CSS files will not be minified/combined."
2853
+ msgstr ""
2854
+
2855
+ #: admin/tpl/setting/settings_tuning.php:47
2856
+ msgid "Combined JS Priority"
2857
+ msgstr ""
2858
+
2859
+ #: admin/tpl/setting/settings_tuning.php:51
2860
+ msgid "Load combined JS files before other JS files."
2861
+ msgstr ""
2862
+
2863
+ #: admin/tpl/setting/settings_tuning.php:55
2864
+ msgid ""
2865
+ "Only set to %s when changing the order of combined and uncombined JS is "
2866
+ "needed."
2867
+ msgstr ""
2868
+
2869
+ #: admin/tpl/setting/settings_tuning.php:59
2870
+ msgid ""
2871
+ "Elements with attribute %s in html code will be excluded from moving to top/"
2872
+ "bottom."
2873
+ msgstr ""
2874
+
2875
+ #: admin/tpl/setting/settings_tuning.php:66
2876
+ msgid "JS Excludes"
2877
+ msgstr ""
2878
+
2879
+ #: admin/tpl/setting/settings_tuning.php:70
2880
+ msgid "Listed JS files will not be minified/combined."
2881
+ msgstr ""
2882
+
2883
+ #: admin/tpl/setting/settings_tuning.php:83
2884
+ msgid "Remove Query Strings"
2885
+ msgstr ""
2886
+
2887
+ #: admin/tpl/setting/settings_tuning.php:87
2888
+ msgid "Remove query strings from static resources."
2889
+ msgstr ""
2890
+
2891
+ #: admin/tpl/setting/settings_tuning.php:94
2892
+ msgid "Load Google Fonts Asynchronously"
2893
+ msgstr ""
2894
+
2895
+ #: admin/tpl/setting/settings_tuning.php:98
2896
+ msgid ""
2897
+ "This is useful if you only want to load Google Fonts asynchronously while "
2898
+ "leave other CSS intact."
2899
+ msgstr ""
2900
+
2901
+ #: admin/tpl/setting/settings_tuning.php:99
2902
+ msgid ""
2903
+ "This will also add a preconnect to Google for faster Google Fonts "
2904
+ "downloading."
2905
+ msgstr ""
2906
+
2907
+ #: admin/tpl/setting/settings_tuning.php:105
2908
+ msgid "Remove Google Fonts"
2909
+ msgstr ""
2910
+
2911
+ #: admin/tpl/setting/settings_tuning.php:109
2912
+ msgid "Prevent google fonts from loading on all your pages."
2913
+ msgstr ""
2914
+
2915
+ #: admin/tpl/setting/settings_tuning.php:115
2916
+ msgid "Critical CSS Rules"
2917
+ msgstr ""
2918
+
2919
+ #: admin/tpl/setting/settings_tuning.php:119
2920
+ msgid "Specify critical CSS rules for above-the-fold content when enabling %s."
2921
+ msgstr ""
2922
+
2923
+ #: admin/tpl/setting/settings_tuning.php:125
2924
+ msgid "JS Deferred Excludes"
2925
+ msgstr ""
2926
+
2927
+ #: admin/tpl/setting/settings_tuning.php:129
2928
+ msgid "Listed JS files will not be deferred."
2929
+ msgstr ""
2930
+
2931
+ #: admin/tpl/setting/settings_tuning.php:142
2932
+ msgid "Remove WordPress Emoji"
2933
+ msgstr ""
2934
+
2935
+ #: admin/tpl/setting/settings_tuning.php:146
2936
+ msgid ""
2937
+ "Stop loading wordpress.org emoji. Browser default emoji will be displayed "
2938
+ "instead."
2939
+ msgstr ""
2940
+
2941
+ #: admin/tpl/setting/settings_tuning.php:153
2942
+ msgid "URI Excludes"
2943
+ msgstr ""
2944
+
2945
+ #: admin/tpl/setting/settings_tuning.php:157
2946
+ msgid "Prevent any optimization of listed pages."
2947
+ msgstr ""
2948
+
2949
+ #: admin/tpl/setting/settings_tuning.php:166
2950
+ msgid "Role Excludes"
2951
+ msgstr ""
2952
+
2953
+ #: admin/tpl/setting/settings_tuning.php:172
2954
+ msgid "Selected roles will be excluded from all optimizations."
2955
+ msgstr ""
2956
+
2957
  #: admin/tpl/settings.php:11
2958
  msgid "Optimize"
2959
  msgstr ""
2960
 
2961
  #: admin/tpl/settings.php:12
2962
+ msgid "Tuning"
2963
  msgstr ""
2964
 
2965
+ #: admin/tpl/settings.php:14
2966
  msgid "CDN"
2967
  msgstr ""
2968
 
2969
+ #: admin/tpl/settings.php:17
2970
  msgid "ESI"
2971
  msgstr ""
2972
 
2973
+ #: admin/tpl/settings.php:23
2974
  msgid "Debug"
2975
  msgstr ""
2976
 
2977
+ #: admin/tpl/settings.php:26
2978
  msgid "Compatibilities"
2979
  msgstr ""
2980
 
2981
+ #: admin/tpl/settings.php:66
2982
  msgid "WARNING: Third party tab input invalid."
2983
  msgstr ""
2984
 
2985
+ #: admin/tpl/settings.php:73
2986
  msgid "WARNING: Third party config slug contains invalid characters."
2987
  msgstr ""
2988
 
2989
+ #: admin/tpl/settings.php:102
2990
  msgid "LiteSpeed Cache Settings"
2991
  msgstr ""
2992
 
2993
+ #: admin/tpl/settings.php:132
2994
  msgid "The network admin selected use primary site configs for all subsites."
2995
  msgstr ""
2996
 
2997
+ #: admin/tpl/settings.php:133
2998
  msgid ""
2999
  "The following options are selected, but are not editable in this settings "
3000
  "page."
3001
  msgstr ""
3002
 
3003
+ #: admin/tpl/settings.php:155 admin/tpl/settings.php:158
3004
  msgid "Save Changes"
3005
  msgstr ""
3006
 
3045
  msgid "Reached end of sitemap file. Crawling completed."
3046
  msgstr ""
3047
 
3048
+ #: inc/gui.class.php:153 includes/litespeed-cache-gui.class.php:153
3049
  msgid "Purge this page"
3050
  msgstr ""
3051
 
3052
+ #: inc/gui.class.php:161 includes/litespeed-cache-gui.class.php:161
3053
  msgid "Mark this page as "
3054
  msgstr ""
3055
 
3056
+ #: inc/gui.class.php:168 includes/litespeed-cache-gui.class.php:168
3057
  msgid "Non cacheable"
3058
  msgstr ""
3059
 
3060
+ #: inc/gui.class.php:175 includes/litespeed-cache-gui.class.php:175
3061
  msgid "Private cache"
3062
  msgstr ""
3063
 
3064
+ #: inc/gui.class.php:182 includes/litespeed-cache-gui.class.php:182
3065
  msgid "No optimization"
3066
  msgstr ""
3067
 
3068
+ #: inc/gui.class.php:189 includes/litespeed-cache-gui.class.php:189
3069
  msgid "More settings"
3070
  msgstr ""
3071
 
3072
+ #: inc/litespeed-cache.class.php:239 includes/litespeed-cache.class.php:239
3073
  msgid "Crawler blacklist is saved."
3074
  msgstr ""
3075
 
3076
+ #: inc/litespeed-cache.class.php:244 includes/litespeed-cache.class.php:244
3077
  msgid "Notified LiteSpeed Web Server to purge the front page."
3078
  msgstr ""
3079
 
3080
+ #: inc/litespeed-cache.class.php:249 includes/litespeed-cache.class.php:249
3081
  msgid "Notified LiteSpeed Web Server to purge pages."
3082
  msgstr ""
3083
 
3084
+ #: inc/litespeed-cache.class.php:254 includes/litespeed-cache.class.php:254
3085
  msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
3086
  msgstr ""
3087
 
3088
+ #: inc/litespeed-cache.class.php:259 includes/litespeed-cache.class.php:259
3089
  msgid "Notified LiteSpeed Web Server to purge error pages."
3090
  msgstr ""
3091
 
3092
+ #: inc/litespeed-cache.class.php:265 includes/litespeed-cache.class.php:265
3093
  msgid "Notified LiteSpeed Web Server to purge all caches."
3094
  msgstr ""
3095
 
3096
+ #: inc/litespeed-cache.class.php:272 includes/litespeed-cache.class.php:272
3097
  msgid "Notified LiteSpeed Web Server to purge everything."
3098
  msgstr ""
3099
 
3100
+ #: inc/litespeed-cache.class.php:287 includes/litespeed-cache.class.php:287
3101
  msgid "Notified LiteSpeed Web Server to purge the list."
3102
  msgstr ""
3103
 
3104
+ #: inc/media.class.php:128
3105
+ msgid "LiteSpeed Optimization"
3106
+ msgstr ""
3107
+
3108
+ #: inc/media.class.php:152
3109
+ msgid "Disable WebP"
3110
+ msgstr ""
3111
+
3112
+ #: inc/media.class.php:157
3113
+ msgid "Enable WebP"
3114
+ msgstr ""
3115
+
3116
+ #: inc/media.class.php:175
3117
+ msgid "Restore Original File"
3118
+ msgstr ""
3119
+
3120
+ #: inc/media.class.php:180
3121
+ msgid "Switch To Optimized File"
3122
+ msgstr ""
3123
+
3124
+ #: inc/media.class.php:194
3125
+ msgid "WebP saved %s"
3126
+ msgstr ""
3127
+
3128
+ #: inc/media.class.php:203
3129
+ msgid "Original saved %s"
3130
+ msgstr ""
3131
+
3132
+ #: inc/media.class.php:310
3133
+ msgid "Disabled WebP file successfully."
3134
+ msgstr ""
3135
+
3136
+ #: inc/media.class.php:316
3137
+ msgid "Enabled WebP file successfully."
3138
+ msgstr ""
3139
+
3140
+ #: inc/media.class.php:332
3141
+ msgid "Restored original file successfully."
3142
+ msgstr ""
3143
+
3144
+ #: inc/media.class.php:339
3145
+ msgid "Switched to optimized file successfully."
3146
+ msgstr ""
3147
+
3148
+ #: inc/media.class.php:434
3149
+ msgid "Failed to communicate with LiteSpeed IAPI server"
3150
+ msgstr ""
3151
+
3152
+ #: inc/media.class.php:443
3153
+ msgid "Communicated with LiteSpeed Image Optimization Server successfully."
3154
+ msgstr ""
3155
+
3156
+ #: inc/media.class.php:999
3157
+ msgid "Failed to push to LiteSpeed IAPI server: %s"
3158
+ msgstr ""
3159
+
3160
+ #: inc/media.class.php:1007
3161
+ msgid "Failed to parse data from LiteSpeed IAPI server: %s"
3162
+ msgstr ""
3163
+
3164
+ #: inc/media.class.php:1125
3165
+ msgid "No image found"
3166
+ msgstr ""
3167
+
3168
+ #: inc/media.class.php:1190 inc/media.class.php:1323
3169
+ msgid "No image found."
3170
+ msgstr ""
3171
+
3172
+ #: inc/media.class.php:1230 inc/media.class.php:1384
3173
+ msgid ""
3174
+ "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
3175
+ "accepted %3$s groups with %4$s images."
3176
+ msgstr ""
3177
+
3178
+ #: inc/media.class.php:1296
3179
+ msgid "Number of images in one image group (%s) exceeds the credit (%s)"
3180
+ msgstr ""
3181
+
3182
+ #: inc/media.class.php:1352
3183
+ msgid "Post data is empty."
3184
+ msgstr ""
3185
+
3186
+ #: inc/purge.class.php:208 includes/litespeed-cache-purge.class.php:208
3187
  msgid "Purge category %s"
3188
  msgstr ""
3189
 
3190
+ #: inc/purge.class.php:235 includes/litespeed-cache-purge.class.php:235
3191
  msgid "Purge Post ID %s"
3192
  msgstr ""
3193
 
3194
+ #: inc/purge.class.php:264 includes/litespeed-cache-purge.class.php:264
3195
  msgid "Purge tag %s"
3196
  msgstr ""
3197
 
3198
+ #: inc/purge.class.php:298 includes/litespeed-cache-purge.class.php:298
3199
  msgid "Purge url %s"
3200
  msgstr ""
3201
 
3202
+ #: inc/task.class.php:155 includes/litespeed-cache-task.class.php:155
3203
+ msgid "LiteSpeed Cache Custom Cron ImgOptm"
3204
+ msgstr ""
3205
+
3206
+ #: inc/task.class.php:178 includes/litespeed-cache-task.class.php:178
3207
+ msgid "LiteSpeed Cache Custom Cron Crawler"
3208
+ msgstr ""
3209
+
3210
+ #: inc/utility.class.php:63 includes/litespeed-cache-utility.class.php:63
3211
+ msgid " %s ago "
3212
  msgstr ""
3213
 
3214
  #: lib/litespeed/litespeed-crawler.class.php:174
3264
  msgid "Failed to write to %s."
3265
  msgstr ""
3266
 
3267
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:730
3268
  msgid "WooCommerce"
3269
  msgstr ""
3270
 
3271
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:733
3272
  msgid "Purge product on changes to the quantity or stock status."
3273
  msgstr ""
3274
 
3275
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:734
3276
  msgid "Purge categories only when stock status changes."
3277
  msgstr ""
3278
 
3279
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:735
3280
  msgid "Purge product and categories only when the stock status changes."
3281
  msgstr ""
3282
 
3283
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:736
3284
  msgid "Purge product only when the stock status changes."
3285
  msgstr ""
3286
 
3287
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:737
3288
  msgid "Do not purge categories on changes to the quantity or stock status."
3289
  msgstr ""
3290
 
3291
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:738
3292
  msgid ""
3293
  "Always purge both product and categories on changes to the quantity or stock "
3294
  "status."
3295
  msgstr ""
3296
 
3297
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:741
3298
  msgid ""
3299
  "Determines how changes in product quantity and product stock status affect "
3300
  "product pages and their associated category pages."
3301
  msgstr ""
3302
 
3303
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:742
3304
  msgid ""
3305
  "Checking this option will force the shop page to use the front page TTL "
3306
  "setting."
3307
  msgstr ""
3308
 
3309
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:743
3310
  msgid ""
3311
  "For example, if the homepage for the site is located at %1$s, the shop page "
3312
  "may be located at %2$s."
3313
  msgstr ""
3314
 
3315
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:771
3316
  msgid "Product Update Interval"
3317
  msgstr ""
3318
 
3319
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:778
3320
  msgid "Use Front Page TTL for the Shop Page"
3321
  msgstr ""
3322
 
3323
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:785
3324
+ msgid "Privately Cache Cart"
3325
+ msgstr ""
3326
+
3327
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:789
3328
+ msgid "Privately cache cart when not empty."
3329
+ msgstr ""
3330
+
3331
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:797
3332
  msgid "After verifying that the cache works in general, please test the cart."
3333
  msgstr ""
3334
 
3335
+ #: thirdparty/lscwp-3rd-woocommerce.cls.php:798
3336
+ msgid "To test the cart, visit the <a %s>FAQ</a>."
3337
  msgstr ""
3338
 
3339
  #. Plugin Name of the plugin/theme
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.5
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
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.6.7
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  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.5
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 CDN support, Browser Cache and Lazyload images!*
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,6 +47,8 @@ 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
  * PageSpeed score optimization
51
  * Load CSS/JS Asynchronously
52
  * Lazyload images/iframes
@@ -113,8 +115,9 @@ If you have any API requirements, please inform us anytime in [WP Forum](https:/
113
  * [WPLister](https://www.wplab.com/plugins/wp-lister/)
114
  * [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
115
  * [Avada 5.1 RC1+](https://avada.theme-fusion.com/)
116
- * Elegant Themes Divi 3.0.67+
117
  * [Caldera Forms](https://wordpress.org/plugins/caldera-forms/) 1.5.6.2+
 
118
 
119
  = Known Uncompatible Plugins =
120
 
@@ -176,9 +179,7 @@ Please see [our API wiki](https://www.litespeedtech.com/support/wiki/doku.php/li
176
 
177
  = Are my images optimized? =
178
 
179
- LSCWP does not do anything with your images.
180
-
181
- If you want to optimize your images, we recommend trying a plugin like [ShortPixel](https://shortpixel.com/h/af/CXNO4OI28044/). It can reduce your site's images up to 90%.
182
 
183
  = How do I get WP-PostViews to display an updating view count? =
184
 
@@ -224,20 +225,128 @@ For more detailed information about crawler setup, please see [our blog post](ht
224
  3. Admin Settings - Purge
225
  4. Admin Settings - Excludes
226
  5. Admin Settings - Optimize
227
- 6. Admin Settings - Media
228
- 7. Admin Settings - CDN
229
- 8. Admin Settings - ESI
230
- 9. Admin Settings - Crawler
231
- 10. Admin Settings - Thirdparty WooCommerce
232
- 11. Admin Management - Purge
233
- 12. Admin Management - DB Optimizer
234
- 13. Admin Crawler Status Page
235
- 14. Cache Miss Example
236
- 15. Cache Hit Example
237
- 16. Frontend Adminbar Shortcut
 
238
 
239
  == Changelog ==
240
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
241
  = 1.5 - October 17 2017 =
242
  * [NEW FEATURE] Exclude JQuery (to fix inline JS error when using JS Combine).
243
  * [NEW FEATURE] Load JQuery Remotely.
2
  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.9.1
6
+ Stable tag: 1.6.7
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
+ LSCWP now includes additional optimization features, including Database Optimization, Minification and Combination of CSS and JS files, HTTP/2 push CDN support, Browser Cache, Lazyload images and image optimization!
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
+ * Image optimization
51
+ * WebP image format support
52
  * PageSpeed score optimization
53
  * Load CSS/JS Asynchronously
54
  * Lazyload images/iframes
115
  * [WPLister](https://www.wplab.com/plugins/wp-lister/)
116
  * [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
117
  * [Avada 5.1 RC1+](https://avada.theme-fusion.com/)
118
+ * [Elegant Themes Divi 3.0.67+](https://www.elegantthemes.com/gallery/divi/)
119
  * [Caldera Forms](https://wordpress.org/plugins/caldera-forms/) 1.5.6.2+
120
+ * Login With Ajax
121
 
122
  = Known Uncompatible Plugins =
123
 
179
 
180
  = Are my images optimized? =
181
 
182
+ Yes we do. LSCWP v1.6+ can optimize your images.
 
 
183
 
184
  = How do I get WP-PostViews to display an updating view count? =
185
 
225
  3. Admin Settings - Purge
226
  4. Admin Settings - Excludes
227
  5. Admin Settings - Optimize
228
+ 6. Admin Settings - Tuning
229
+ 7. Admin Settings - Media
230
+ 8. Admin Settings - CDN
231
+ 9. Admin Settings - ESI
232
+ 10. Admin Settings - Crawler
233
+ 11. Admin Settings - Thirdparty WooCommerce
234
+ 12. Admin Management - Purge
235
+ 13. Admin Management - DB Optimizer
236
+ 14. Admin Crawler Status Page
237
+ 15. Cache Miss Example
238
+ 16. Cache Hit Example
239
+ 17. Frontend Adminbar Shortcut
240
 
241
  == Changelog ==
242
 
243
+ = 1.6.7 - December 15 2017 =
244
+ * [IAPI] Added ability to scan for new image thumbnail sizes and auto-resend image optimization requests.
245
+ * [IAPI] Added ability to destroy all optimization data.
246
+ * [IAPI] Updated IAPI to v1.6.7.
247
+ * [INTEGRATION] Fixed certain 3rd party plugins calling REST without user nonce causing logged in users to be served as guest.
248
+
249
+ = 1.6.6.1 - December 8 2017 =
250
+ * [IAPI] Limit first-time submission to one image group for test-run purposes.
251
+ * [BUGFIX] Fixed vary group generation issue associated with custom user role plugins.
252
+ * [BUGFIX] Fixed WooCommerce issue where logged-in users were erroneously purged when ESI is off.
253
+ * [BUGFIX] Fixed WooCommerce cache miss issue when ESI is off.
254
+
255
+ = 1.6.6 - December 6 2017 =
256
+ * [NEW FEATURE] Preserve EXIF in Media setting.
257
+ * [NEW FEATURE] Clear log button in Debug Log Viewer.
258
+ * [IAPI] Fixed notified images resetting to previous status when pulling.
259
+ * [IAPI] Fixed HTTPS compatibility for image optimization initialization.
260
+ * [IAPI] An error message is now displayed when image optimization request submission is bypassed due to a lack of credit.
261
+ * [IAPI] IAPI v1.6.6.
262
+ * [IMPROVEMENT] Support JS data-no-optimize attribute to bypass optimization.
263
+ * [GUI] Added image group wiki link.
264
+ * [INTEGRATION] Improved compatibility with Login With Ajax.
265
+ * [INTEGRATION] Added function_exists check for WooCommerce to avoid 500 errors.
266
+
267
+ = 1.6.5.1 - December 1 2017 =
268
+ * [HOTFIX] Fixed warning message on Edit .htaccess page.
269
+
270
+ = 1.6.5 - November 30 2017 =
271
+ * [IAPI] Manually pull image optimization action button.
272
+ * [IAPI] Automatic credit system for image optimization to bypass unfinished image optimization error.
273
+ * [IAPI] Notify failed images from LiteSpeed's Image Server.
274
+ * [IAPI] Reset/Clear failed images feature.
275
+ * [IAPI] Redesigned report page.
276
+ * [REFACTOR] Moved pull_img logic from admin_api to media.
277
+ * [BUGFIX] Fixed a compatibility issue for clients who have allow_url_open setting off.
278
+ * [BUGFIX] Fixed logged in users sometimes being served from guest cache.
279
+ * [UPDATE] Environment report is no longer saved to a file.
280
+ * [UPDATE] Removed crawler reset notification.
281
+ * [GUI] Added more details on image optimization.
282
+ * [GUI] Removed info page from admin menu.
283
+ * [GUI] Moved environment report from network level to single site level.
284
+ * [GUI] Crawler time added in a user friendly format.
285
+ * [INTEGRATION] Improved compatibility with FacetWP json call.
286
+
287
+ = 1.6.4 - November 22 2017 =
288
+ * [NEW FEATURE] Send env reports privately with a new built-in report number referral system.
289
+ * [IAPI] Increased request timeout to fix a cUrl 28 timeout issue.
290
+ * [BUGFIX] Fixed a TTL max value validation bug.
291
+ * [INTEGRATION] Improved Contact Form 7 REST call compatibility for logged in users.
292
+ * Thanks for all your ratings. That encouraged us to be more diligent. Happy Thanksgiving.
293
+
294
+ = 1.6.3 - November 17 2017 =
295
+ * [NEW FEATURE] Only async Google Fonts setting.
296
+ * [NEW FEATURE] Only create WebP images when optimizing setting.
297
+ * [NEW FEATURE] Batch switch images to original/optimized versions in Image Optimization.
298
+ * [NEW FEATURE] Browser Cache TTL setting.
299
+ * [NEW FEATURE] Cache WooCommerce Cart setting.
300
+ * [IMPROVEMENT] Moved optimized JS/CSS snippet in header html to after meta charset.
301
+ * [IMPROVEMENT] Added a constant for better JS/CSS optimization compatibility for different dir WordPress installation.
302
+ * [IAPI] Take over failed callback check instead of bypassing it.
303
+ * [IAPI] Image optimization requests are now limited to 500 images per request.
304
+ * [BUGFIX] Fixed a parsing failure bug not using attributes in html elements with dash.
305
+ * [BUGFIX] Fixed a bug causing non-script code to move to the top of a page when not using combination.
306
+ * [UPDATE] Added detailed logs for external link detection.
307
+ * [UPDATE] Added new lines in footer comment to avoid Firefox crash when enabled HTML minify.
308
+ * [API] `Purge private` / `Purge private all` / `Add private tag` functions.
309
+ * [GUI] Redesigned image optimization operation links in Media Lib list.
310
+ * [GUI] Tweaked wp-admin form save button position.
311
+ * [GUI] Added "learn more" link for image optimization.
312
+
313
+ = 1.6.2.1 - November 6 2017 =
314
+ * [INTEGRATION] Improved compatibility with old WooCommerce versions to avoid unknown 500 errors.
315
+ * [BUGFIX] Fixed WebP images sometimes being used in non-supported browsers.
316
+ * [BUGFIX] Kept query strings for HTTP/2 push to avoid re-fetching pushed sources.
317
+ * [BUGFIX] Excluded JS/CSS from HTTP/2 push when using CDN.
318
+ * [GUI] Fixed a typo in Media list.
319
+ * [GUI] Made more image optimization strings translatable.
320
+ * [GUI] Updated Tuning description to include API documentation.
321
+
322
+ = 1.6.2 - November 3 2017 =
323
+ * [NEW FEATURE] Do Not Cache Roles.
324
+ * [NEW FEATURE] Use WebP Images for supported browsers.
325
+ * [NEW FEATURE] Disable Optimization Poll ON/OFF Switch in Media tab.
326
+ * [NEW FEATURE] Revert image optimization per image in Media list.
327
+ * [NEW FEATURE] Disable/Enable image WebP per image in Media list.
328
+ * [IAPI] Limit optimized images fetching cron to a single process.
329
+ * [IAPI] Updated IAPI to v1.6.2.
330
+ * [IAPI] Fixed repeating image request issue by adding a failure status to local images.
331
+ * [REFACTOR] Refactored login vary logic.
332
+
333
+ = 1.6.1 - October 29 2017 =
334
+ * [IAPI] Updated LiteSpeed Image Optimization Server API to v1.6.1.
335
+
336
+ = 1.6 - October 27 2017 =
337
+ * [NEW FEATURE] Image Optimization.
338
+ * [NEW FEATURE] Role Excludes for Optimization.
339
+ * [NEW FEATURE] Combined CSS/JS Priority.
340
+ * [IMPROVEMENT] Bypass CDN for login/register page.
341
+ * [UPDATE] Expanded ExpiresByType rules to include new font types. ( Thanks to JMCA2 )
342
+ * [UPDATE] Removed duplicated type param in admin action link.
343
+ * [BUGFIX] Fixed CDN wrongly replacing img base64 and "fake" src in JS.
344
+ * [BUGFIX] Fixed image lazy load replacing base64 src.
345
+ * [BUGFIX] Fixed a typo in Optimize class exception.
346
+ * [GUI] New Tuning tab in admin settings panel.
347
+ * [REFACTOR] Simplified router by reducing actions and adding types.
348
+ * [REFACTOR] Renamed `run()` to `finalize()` in buffer process.
349
+
350
  = 1.5 - October 17 2017 =
351
  * [NEW FEATURE] Exclude JQuery (to fix inline JS error when using JS Combine).
352
  * [NEW FEATURE] Load JQuery Remotely.
thirdparty/lscwp-3rd-contact-form-7.cls.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Third Party integration with Contact Form 7.
4
+ *
5
+ * @since 1.6.4
6
+ * @package LiteSpeed_Cache
7
+ * @subpackage LiteSpeed_Cache/thirdparty
8
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
9
+ */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die() ;
12
+ }
13
+ LiteSpeed_Cache_API::register( 'LiteSpeed_Cache_ThirdParty_Contact_Form_7' ) ;
14
+
15
+ class LiteSpeed_Cache_ThirdParty_Contact_Form_7
16
+ {
17
+ /**
18
+ * Detects if is active.
19
+ *
20
+ * @since 1.6.4
21
+ * @access public
22
+ *
23
+ */
24
+ public static function detect()
25
+ {
26
+ if ( defined( 'WPCF7_VERSION' ) ) {
27
+ add_action( 'rest_api_init', 'LiteSpeed_Cache_ThirdParty_Contact_Form_7::disable_vary_change' ) ;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Disable vary change for refill to avoid auto-logout issue
33
+ *
34
+ * @since 1.6.4
35
+ * @access public
36
+ */
37
+ public static function disable_vary_change()
38
+ {
39
+ if ( strpos( $_SERVER[ 'REQUEST_URI' ], '/wp-json/contact-form-7' ) !== false ) {
40
+ LiteSpeed_Cache_API::debug( '3rd cf7 set no change vary' ) ;
41
+ add_filter( 'litespeed_can_change_vary', '__return_false' ) ;
42
+ }
43
+ }
44
+
45
+ }
46
+
thirdparty/lscwp-3rd-login-with-ajax.cls.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Third Party integration with the Login-with-ajax plugin.
4
+ *
5
+ * @since 1.6.6
6
+ * @package LiteSpeed_Cache
7
+ * @subpackage LiteSpeed_Cache/thirdparty
8
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
9
+ */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ die() ;
12
+ }
13
+
14
+ LiteSpeed_Cache_API::hook_init( 'LiteSpeed_Cache_ThirdParty_Login_With_Ajax::detect' ) ;
15
+
16
+ class LiteSpeed_Cache_ThirdParty_Login_With_Ajax
17
+ {
18
+ /**
19
+ * Detects if installed.
20
+ *
21
+ * @since 1.6.6
22
+ * @access public
23
+ */
24
+ public static function detect()
25
+ {
26
+ if ( defined( 'LOGIN_WITH_AJAX_VERSION' ) ) {
27
+ LiteSpeed_Cache_API::debug( '3rd lwa found' ) ;
28
+ if ( ! empty( $_REQUEST[ "login-with-ajax" ] ) ) {
29
+ LiteSpeed_Cache_API::debug( '3rd lwa set change vary' ) ;
30
+ add_filter( 'litespeed_ajax_vary', '__return_true' ) ;
31
+ }
32
+ }
33
+ }
34
+
35
+ }
thirdparty/lscwp-3rd-woocommerce.cls.php CHANGED
@@ -3,6 +3,7 @@
3
  * The Third Party integration with the WooCommerce plugin.
4
  *
5
  * @since 1.0.5
 
6
  * @package LiteSpeed_Cache
7
  * @subpackage LiteSpeed_Cache/thirdparty
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
@@ -14,10 +15,13 @@ LiteSpeed_Cache_API::register('LiteSpeed_Cache_ThirdParty_WooCommerce') ;
14
 
15
  class LiteSpeed_Cache_ThirdParty_WooCommerce
16
  {
 
 
17
  const CACHETAG_SHOP = 'WC_S' ;
18
  const CACHETAG_TERM = 'WC_T.' ;
19
  const OPTION_UPDATE_INTERVAL = 'wc_update_interval' ;
20
  const OPTION_SHOP_FRONT_TTL = 'wc_shop_use_front_ttl' ;
 
21
  const OPT_PQS_CS = 0 ; // flush product on quantity + stock change, categories on stock change
22
  const OPT_PS_CS = 1 ; // flush product and categories on stock change
23
  const OPT_PS_CN = 2 ; // flush product on stock change, categories no flush
@@ -29,6 +33,9 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
29
  const ESI_PARAM_PATH = 'wc_path' ;
30
  const ESI_PARAM_LOCATED = 'wc_located' ;
31
 
 
 
 
32
  /**
33
  * Detects if WooCommerce is installed.
34
  *
@@ -40,39 +47,88 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
40
  if ( ! defined( 'WOOCOMMERCE_VERSION' ) ) {
41
  return ;
42
  }
43
- LiteSpeed_Cache_API::hook_control( 'LiteSpeed_Cache_ThirdParty_WooCommerce::set_control' ) ;
44
- LiteSpeed_Cache_API::hook_tag( 'LiteSpeed_Cache_ThirdParty_WooCommerce::set_tag' ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  // Purging a product on stock change should only occur during product purchase. This function will add the purging callback when an order is complete.
47
- add_action( 'woocommerce_product_set_stock', 'LiteSpeed_Cache_ThirdParty_WooCommerce::purge_product' ) ;
48
 
49
- LiteSpeed_Cache_API::hook_get_options( 'LiteSpeed_Cache_ThirdParty_WooCommerce::get_config' ) ;
50
- add_action( 'comment_post', 'LiteSpeed_Cache_ThirdParty_WooCommerce::add_review', 10, 3 ) ;
51
 
52
- if ( LiteSpeed_Cache_API::esi_enabled() ) {
53
- if ( ! is_shop() ) {
54
- LiteSpeed_Cache_API::hook_tpl_not_esi( 'LiteSpeed_Cache_ThirdParty_WooCommerce::set_block_template' ) ;
55
  // No need for add-to-cart button
56
- // LiteSpeed_Cache_API::hook_tpl_esi( 'wc-add-to-cart-form', 'LiteSpeed_Cache_ThirdParty_WooCommerce::load_add_to_cart_form_block' ) ;
57
 
58
- LiteSpeed_Cache_API::hook_tpl_esi( 'storefront-cart-header', 'LiteSpeed_Cache_ThirdParty_WooCommerce::load_cart_header' ) ;
59
- LiteSpeed_Cache_API::hook_tpl_esi( 'widget', 'LiteSpeed_Cache_ThirdParty_WooCommerce::register_post_view' ) ;
60
  }
61
 
62
- if ( is_product() ) {
63
- LiteSpeed_Cache_API::hook_esi_param( 'widget', 'LiteSpeed_Cache_ThirdParty_WooCommerce::add_post_id' ) ;
64
  }
65
 
66
- LiteSpeed_Cache_API::hook_tpl_not_esi( 'LiteSpeed_Cache_ThirdParty_WooCommerce::set_swap_header_cart' ) ;
67
  }
68
 
69
  if ( is_admin() ) {
70
- LiteSpeed_Cache_API::hook_purge_post( 'LiteSpeed_Cache_ThirdParty_WooCommerce::backend_purge' ) ;
71
- add_action( 'delete_term_relationships', 'LiteSpeed_Cache_ThirdParty_WooCommerce::delete_rel', 10, 2 ) ;
72
- LiteSpeed_Cache_API::hook_setting_tab( 'LiteSpeed_Cache_ThirdParty_WooCommerce::add_config', 10, 3 ) ;
73
- LiteSpeed_Cache_API::hook_setting_save( 'LiteSpeed_Cache_ThirdParty_WooCommerce::save_config', 10, 2 ) ;
74
- LiteSpeed_Cache_API::hook_widget_default_options( 'LiteSpeed_Cache_ThirdParty_WooCommerce::wc_widget_default', 10, 2 ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
77
 
78
  /**
@@ -81,11 +137,12 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
81
  * in woocommerce_before_template_part to see if it's something I can ESI.
82
  *
83
  * @since 1.1.0
 
84
  * @access public
85
  */
86
- public static function set_block_template()
87
  {
88
- add_action('woocommerce_before_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::block_template', 999, 4) ;
89
  }
90
 
91
  /**
@@ -96,14 +153,15 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
96
  * Will remove storefront_header_cart in storefront_header.
97
  *
98
  * @since 1.1.0
 
99
  * @access public
100
  */
101
- public static function set_swap_header_cart()
102
  {
103
  $priority = has_action('storefront_header', 'storefront_header_cart') ;
104
  if ( $priority !== false ) {
105
  remove_action('storefront_header', 'storefront_header_cart', $priority) ;
106
- add_action('storefront_header', 'LiteSpeed_Cache_ThirdParty_WooCommerce::esi_cart_header', $priority) ;
107
  }
108
  }
109
 
@@ -115,6 +173,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
115
  * The function parameters will be passed to the esi request.
116
  *
117
  * @since 1.1.0
 
118
  * @access public
119
  * @global type $post Needed for post id
120
  * @param type $template_name
@@ -122,13 +181,13 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
122
  * @param type $located
123
  * @param type $args
124
  */
125
- public static function block_template($template_name, $template_path, $located, $args)
126
  {
127
  if ( strpos($template_name, 'add-to-cart') === false ) {
128
  if ( strpos($template_name, 'related.php') !== false ) {
129
- remove_action('woocommerce_before_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::block_template', 999) ;
130
- add_filter('woocommerce_related_products_args', 'LiteSpeed_Cache_ThirdParty_WooCommerce::add_related_tags') ;
131
- add_action('woocommerce_after_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_template', 999) ;
132
  }
133
  return ;
134
  }
@@ -141,8 +200,8 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
141
  self::ESI_PARAM_PATH => $template_path,
142
  self::ESI_PARAM_LOCATED => $located
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
  echo LiteSpeed_Cache_API::clean_wrapper_begin() ;
148
  }
@@ -153,16 +212,17 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
153
  * end_template.
154
  *
155
  * @since 1.1.0
 
156
  * @access public
157
  */
158
- public static function end_form($template_name = '')
159
  {
160
  if ( ! empty($template_name) && strpos($template_name, 'add-to-cart') === false ) {
161
  return ;
162
  }
163
  echo LiteSpeed_Cache_API::clean_wrapper_end() ;
164
- remove_action('woocommerce_after_add_to_cart_form', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form') ;
165
- remove_action('woocommerce_after_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_form', 999) ;
166
  }
167
 
168
  /**
@@ -171,11 +231,12 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
171
  * The page will be purged if any of the products are changed.
172
  *
173
  * @since 1.1.0
 
174
  * @access public
175
  * @param array $args The arguments used to build the related products section.
176
  * @return array The unchanged arguments.
177
  */
178
- public static function add_related_tags($args)
179
  {
180
  if ( empty($args) || ! isset($args['post__in']) ) {
181
  return $args ;
@@ -192,14 +253,15 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
192
  * If the template contains 'add-to-cart', clean the buffer.
193
  *
194
  * @since 1.1.0
 
195
  * @access public
196
  * @param type $template_name
197
  */
198
- public static function end_template($template_name)
199
  {
200
  if ( strpos($template_name, 'related.php') !== false ) {
201
- remove_action('woocommerce_after_template_part', 'LiteSpeed_Cache_ThirdParty_WooCommerce::end_template', 999) ;
202
- self::set_block_template() ;
203
  }
204
  }
205
 
@@ -208,9 +270,10 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
208
  * If I want to ESI the request, block it and build my esi code block.
209
  *
210
  * @since 1.1.0
 
211
  * @access public
212
  */
213
- public static function esi_cart_header()
214
  {
215
  echo LiteSpeed_Cache_API::esi_url('storefront-cart-header', 'STOREFRONT_CART_HEADER') ;
216
  }
@@ -220,9 +283,10 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
220
  * Generates the cart header for esi display.
221
  *
222
  * @since 1.1.0
 
223
  * @access public
224
  */
225
- public static function load_cart_header()
226
  {
227
  storefront_header_cart() ;
228
  }
@@ -233,17 +297,18 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
233
  * for esi display.
234
  *
235
  * @since 1.1.0
 
236
  * @access public
237
  * @global type $post
238
  * @global type $wp_query
239
  * @param type $params
240
  */
241
- public static function load_add_to_cart_form_block($params)
242
  {
243
  global $post, $wp_query ;
244
  $post = get_post($params[self::ESI_PARAM_POSTID]) ;
245
  $wp_query->setup_postdata($post) ;
246
- wc_get_template($params[self::ESI_PARAM_NAME], $params[self::ESI_PARAM_ARGS], $params[self::ESI_PARAM_PATH]) ;
247
  }
248
 
249
  /**
@@ -253,10 +318,11 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
253
  * Currently, this widget should not be cached.
254
  *
255
  * @since 1.1.0
 
256
  * @access public
257
  * @param array $params Widget parameter array
258
  */
259
- public static function register_post_view($params)
260
  {
261
  if ( $params[LiteSpeed_Cache_API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed' ) {
262
  return ;
@@ -266,7 +332,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
266
  }
267
  $id = $params[self::ESI_PARAM_POSTID] ;
268
  $esi_post = get_post($id) ;
269
- $product = wc_get_product($esi_post) ;
270
 
271
  if ( empty($product) ) {
272
  return ;
@@ -274,7 +340,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
274
 
275
  global $post ;
276
  $post = $esi_post ;
277
- wc_track_product_view() ;
278
  }
279
 
280
  /**
@@ -283,11 +349,12 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
283
  * This is needed in the esi request to update the cookie properly.
284
  *
285
  * @since 1.1.0
 
286
  * @access public
287
  * @param array $params The current ESI parameters.
288
  * @return array The updated esi parameters.
289
  */
290
- public static function add_post_id($params)
291
  {
292
  if ( ! isset($params) || ! isset($params[LiteSpeed_Cache_API::PARAM_NAME]) || $params[LiteSpeed_Cache_API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed' ) {
293
  return $params ;
@@ -303,12 +370,13 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
303
  * This function will set it to enable and no cache by default.
304
  *
305
  * @since 1.1.0
 
306
  * @access public
307
  * @param array $options The current default widget options.
308
  * @param type $widget The current widget to configure.
309
  * @return array The updated default widget options.
310
  */
311
- public static function wc_widget_default($options, $widget)
312
  {
313
  if ( ! is_array($options) ) {
314
  return $options ;
@@ -328,12 +396,13 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
328
  /**
329
  * Check and set shop front page ttl
330
  *
331
- * @access private
332
  * @since 1.1.3
 
 
333
  */
334
- private static function set_ttl()
335
  {
336
- if ( is_shop() ) {
337
  if ( LiteSpeed_Cache_API::config( self::OPTION_SHOP_FRONT_TTL ) ) {
338
  LiteSpeed_Cache_API::set_use_frontpage_ttl() ;
339
  }
@@ -343,10 +412,11 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
343
  /**
344
  * Set WooCommerce cache tags based on page type.
345
  *
346
- * @access public
347
  * @since 1.0.9
 
 
348
  */
349
- public static function set_tag()
350
  {
351
  $id = get_the_ID() ;
352
  if ( $id === false ) {
@@ -369,10 +439,10 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
369
  LiteSpeed_Cache_API::set_ttl( $ttl ) ;
370
  }
371
 
372
- if ( is_shop() ) {
373
  LiteSpeed_Cache_API::tag_add(self::CACHETAG_SHOP) ;
374
  }
375
- if ( ! is_product_taxonomy() ) {
376
  return ;
377
  }
378
  if ( isset($GLOBALS['product_cat']) ) {
@@ -401,21 +471,30 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
401
  * Check if the page is cacheable according to WooCommerce.
402
  *
403
  * @since 1.0.5
 
404
  * @access public
405
  * @param string $esi_id The ESI block id if a request is an ESI request.
406
  * @return boolean True if cacheable, false if not.
407
  */
408
- public static function set_control($esi_id)
409
  {
410
  if ( LiteSpeed_Cache_API::not_cacheable() ) {
411
  return ;
412
  }
413
 
 
 
 
 
 
 
 
 
414
  $woocom = WC() ;
415
  if ( ! isset($woocom) ) {
416
  return ;
417
  }
418
- self::set_ttl() ;
419
 
420
  // For later versions, DONOTCACHEPAGE should be set.
421
  // No need to check uri/qs.
@@ -428,6 +507,9 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
428
  elseif ( version_compare($woocom->version, '2.1.0', '>=') ) {
429
  $err = false ;
430
 
 
 
 
431
  /**
432
  * From woo/inc/class-wc-cache-helper.php:prevent_caching()
433
  * @since 1.4
@@ -439,13 +521,31 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
439
  elseif ( is_null($woocom->cart) ) {
440
  $err = 'null cart' ;
441
  }
442
- elseif ( $woocom->cart->get_cart_contents_count() !== 0 && ! LiteSpeed_Cache_Router::esi_enabled() ) {
443
- $err = 'cart is not empty' ;
 
 
 
 
 
 
 
 
 
 
 
444
  }
445
  elseif ( $esi_id === 'storefront-cart-header' ) {
446
- $err = 'ESI cart should be nocache' ;
 
 
 
 
 
 
 
447
  }
448
- elseif ( wc_notice_count() > 0 ) {
449
  $err = 'has wc notice' ;
450
  }
451
 
@@ -480,11 +580,12 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
480
  /**
481
  * Purge a product page and related pages (based on settings) on checkout.
482
  *
483
- * @access public
484
  * @since 1.0.9
 
 
485
  * @param WC_Product $product
486
  */
487
- public static function purge_product($product)
488
  {
489
  $config = LiteSpeed_Cache_API::config(self::OPTION_UPDATE_INTERVAL) ;
490
  if ( is_null($config) ) {
@@ -492,13 +593,13 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
492
  }
493
 
494
  if ( $config === self::OPT_PQS_CQS ) {
495
- self::backend_purge($product->get_id()) ;
496
  }
497
  elseif ( $config !== self::OPT_PQS_CS && $product->is_in_stock() ) {
498
  return ;
499
  }
500
  elseif ( $config !== self::OPT_PS_CN && ! $product->is_in_stock() ) {
501
- self::backend_purge($product->get_id()) ;
502
  }
503
 
504
  LiteSpeed_Cache_API::purge(LiteSpeed_Cache_API::TYPE_POST . $product->get_id()) ;
@@ -509,13 +610,18 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
509
  * the term ids array is not empty, will add purge tags to the deleted
510
  * terms.
511
  *
512
- * @access public
513
  * @since 1.0.9
 
 
514
  * @param int $post_id Object ID.
515
  * @param array $term_ids An array of term taxonomy IDs.
516
  */
517
- public static function delete_rel($post_id, $term_ids)
518
  {
 
 
 
 
519
  if ( empty($term_ids) || wc_get_product($post_id) === false ) {
520
  return ;
521
  }
@@ -527,23 +633,32 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
527
  /**
528
  * Purge a product's categories and tags pages in case they are affected.
529
  *
530
- * @access public
531
  * @since 1.0.9
 
 
532
  * @param int $post_id Post id that is about to be purged
533
  */
534
- public static function backend_purge($post_id)
535
  {
 
 
 
 
536
  if ( ! isset($post_id) || wc_get_product($post_id) === false ) {
537
  return ;
538
  }
539
 
540
- $cats = self::get_cats($post_id) ;
541
  if ( ! empty($cats) ) {
542
  foreach ( $cats as $cat ) {
543
  LiteSpeed_Cache_API::purge(self::CACHETAG_TERM . $cat) ;
544
  }
545
  }
546
 
 
 
 
 
547
  $tags = wc_get_product_terms($post_id, 'product_tag', array('fields' => 'ids')) ;
548
  if ( ! empty($tags) ) {
549
  foreach ( $tags as $tag ) {
@@ -556,13 +671,18 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
556
  * When a product has a new review added, purge the recent reviews widget.
557
  *
558
  * @since 1.1.0
 
559
  * @access public
560
  * @param $unused
561
  * @param integer $comment_approved Whether the comment is approved or not.
562
  * @param array $commentdata Information about the comment.
563
  */
564
- public static function add_review($unused, $comment_approved, $commentdata)
565
  {
 
 
 
 
566
  $post_id = $commentdata['comment_post_ID'] ;
567
  if ( $comment_approved !== 1 || ! isset($post_id) || wc_get_product($post_id) === false ) {
568
  return ;
@@ -578,16 +698,18 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
578
  * Hooked to the litespeed_cache_get_options filter.
579
  * This will return the option names needed as well as the default options.
580
  *
 
581
  * @param array $configs
582
  * @return array
583
  */
584
- public static function get_config($configs)
585
  {
586
  if ( ! is_array($configs) ) {
587
  return $configs ;
588
  }
589
  $configs[self::OPTION_UPDATE_INTERVAL] = self::OPT_PQS_CS ;
590
  $configs[self::OPTION_SHOP_FRONT_TTL] = true ;
 
591
 
592
  return $configs ;
593
  }
@@ -597,12 +719,13 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
597
  * Adds the integration configuration options (currently, to determine
598
  * purge rules)
599
  *
 
600
  * @param array $tabs Third party tabs added.
601
  * @param array $options Current options used.
602
  * @param string $option_group The option group to surround the option id.
603
  * @return mixed False on failure, updated tabs otherwise.
604
  */
605
- public static function add_config($tabs, $options, $option_group)
606
  {
607
  $_title = __('WooCommerce', 'litespeed-cache') ;
608
  $_slug = 'woocom' ;
@@ -658,12 +781,21 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
658
  <div class='litespeed-desc'>$ttl_desc</div>
659
  </td>
660
  </tr>
 
 
 
 
 
 
 
 
 
661
  </tbody></table>
662
  <div class='litespeed-callout-warning'>
663
  <h4>" . __('Note:', 'litespeed-cache') . "</h4>
664
  <i>
665
  " . __('After verifying that the cache works in general, please test the cart.', 'litespeed-cache') . "
666
- " . sprintf(__('To test the cart, visit the %s.', 'litespeed-cache'), '<a href=' . get_admin_url() . 'admin.php?page=lscache-info>FAQ</a>') . "
667
  </i>
668
  </div>
669
 
@@ -685,11 +817,12 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
685
  * Parses the input for this integration's options and updates
686
  * the options array accordingly.
687
  *
 
688
  * @param array $options The saved options array.
689
  * @param array $input The input options array.
690
  * @return mixed false on failure, updated $options otherwise.
691
  */
692
- public static function save_config($options, $input)
693
  {
694
  if ( ! isset($options) ) {
695
  return $options ;
@@ -710,6 +843,7 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
710
  }
711
 
712
  $options[ self::OPTION_SHOP_FRONT_TTL ] = LiteSpeed_Cache_API::parse_onoff( $input, self::OPTION_SHOP_FRONT_TTL ) ;
 
713
 
714
  return $options ;
715
  }
@@ -719,14 +853,19 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
719
  * category ids.
720
  *
721
  * @since 1.0.10
 
722
  * @access private
723
  * @param int $product_id The product id
724
  * @return array An array of category ids.
725
  */
726
- private static function get_cats($product_id)
727
  {
 
 
 
 
728
  $woocom = WC() ;
729
- if ( isset($woocom) && version_compare($woocom->version, '2.5.0', '>=') ) {
730
  return wc_get_product_cat_ids($product_id) ;
731
  }
732
  $product_cats = wp_get_post_terms($product_id, 'product_cat', array("fields" => "ids")) ;
@@ -737,5 +876,20 @@ class LiteSpeed_Cache_ThirdParty_WooCommerce
737
  return $product_cats ;
738
  }
739
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
740
  }
741
 
3
  * The Third Party integration with the WooCommerce plugin.
4
  *
5
  * @since 1.0.5
6
+ * @since 1.6.6 Added function_exists check for compatibility
7
  * @package LiteSpeed_Cache
8
  * @subpackage LiteSpeed_Cache/thirdparty
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
15
 
16
  class LiteSpeed_Cache_ThirdParty_WooCommerce
17
  {
18
+ private static $_instance ;
19
+
20
  const CACHETAG_SHOP = 'WC_S' ;
21
  const CACHETAG_TERM = 'WC_T.' ;
22
  const OPTION_UPDATE_INTERVAL = 'wc_update_interval' ;
23
  const OPTION_SHOP_FRONT_TTL = 'wc_shop_use_front_ttl' ;
24
+ const OPTION_WOO_CACHE_CART = 'woo_cache_cart' ;
25
  const OPT_PQS_CS = 0 ; // flush product on quantity + stock change, categories on stock change
26
  const OPT_PS_CS = 1 ; // flush product and categories on stock change
27
  const OPT_PS_CN = 2 ; // flush product on stock change, categories no flush
33
  const ESI_PARAM_PATH = 'wc_path' ;
34
  const ESI_PARAM_LOCATED = 'wc_located' ;
35
 
36
+ private $cache_cart ;
37
+ private $esi_eanbled ;
38
+
39
  /**
40
  * Detects if WooCommerce is installed.
41
  *
47
  if ( ! defined( 'WOOCOMMERCE_VERSION' ) ) {
48
  return ;
49
  }
50
+
51
+ self::get_instance()->add_hooks() ;
52
+
53
+ }
54
+
55
+ /**
56
+ * Add hooks to woo actions
57
+ *
58
+ * @since 1.6.3
59
+ * @access public
60
+ */
61
+ public function add_hooks()
62
+ {
63
+ $this->cache_cart = LiteSpeed_Cache_API::config( self::OPTION_WOO_CACHE_CART ) ;
64
+ $this->esi_eanbled = LiteSpeed_Cache_API::esi_enabled() ;
65
+
66
+ LiteSpeed_Cache_API::hook_control( array( $this, 'set_control' ) ) ;
67
+ LiteSpeed_Cache_API::hook_tag( array( $this, 'set_tag' ) ) ;
68
 
69
  // Purging a product on stock change should only occur during product purchase. This function will add the purging callback when an order is complete.
70
+ add_action( 'woocommerce_product_set_stock', array( $this, 'purge_product' ) ) ;
71
 
72
+ LiteSpeed_Cache_API::hook_get_options( array( $this, 'get_config' ) ) ;
73
+ add_action( 'comment_post', array( $this, 'add_review' ), 10, 3 ) ;
74
 
75
+ if ( $this->esi_eanbled ) {
76
+ if ( function_exists( 'is_shop' ) && ! is_shop() ) {
77
+ LiteSpeed_Cache_API::hook_tpl_not_esi( array( $this, 'set_block_template' ) ) ;
78
  // No need for add-to-cart button
79
+ // LiteSpeed_Cache_API::hook_tpl_esi( 'wc-add-to-cart-form', array( $this, 'load_add_to_cart_form_block' ) ) ;
80
 
81
+ LiteSpeed_Cache_API::hook_tpl_esi( 'storefront-cart-header', array( $this, 'load_cart_header' ) ) ;
82
+ LiteSpeed_Cache_API::hook_tpl_esi( 'widget', array( $this, 'register_post_view' ) ) ;
83
  }
84
 
85
+ if ( function_exists( 'is_product' ) && is_product() ) {
86
+ LiteSpeed_Cache_API::hook_esi_param( 'widget', array( $this, 'add_post_id' ) ) ;
87
  }
88
 
89
+ LiteSpeed_Cache_API::hook_tpl_not_esi( array( $this, 'set_swap_header_cart' ) ) ;
90
  }
91
 
92
  if ( is_admin() ) {
93
+ LiteSpeed_Cache_API::hook_purge_post( array( $this, 'backend_purge' ) ) ;
94
+ add_action( 'delete_term_relationships', array( $this, 'delete_rel' ), 10, 2 ) ;
95
+ LiteSpeed_Cache_API::hook_setting_tab( array( $this, 'add_config' ), 10, 3 ) ;
96
+ LiteSpeed_Cache_API::hook_setting_save( array( $this, 'save_config' ), 10, 2 ) ;
97
+ LiteSpeed_Cache_API::hook_widget_default_options( array( $this, 'wc_widget_default' ), 10, 2 ) ;
98
+ }
99
+
100
+ // Purge cart if is ESI / Purge private if not enabled ESI
101
+ if ( $this->cache_cart ) {
102
+ $hooks_to_purge = array(
103
+ 'woocommerce_add_to_cart', 'woocommerce_ajax_added_to_cart',
104
+ 'woocommerce_remove_cart_item',
105
+ 'woocommerce_restore_cart_item',
106
+ 'woocommerce_after_cart_item_quantity_update',
107
+ 'woocommerce_applied_coupon', 'woocommerce_removed_coupon',
108
+ 'woocommerce_checkout_order_processed',
109
+ ) ;
110
+ foreach ( $hooks_to_purge as $v ) {
111
+ if ( $this->esi_eanbled ) {
112
+ add_action( $v, array( $this, 'purge_esi' ) ) ;
113
+ }
114
+ else {
115
+ add_action( $v, 'LiteSpeed_Cache_API::purge_private_all' ) ;
116
+ }
117
+ }
118
  }
119
+
120
+ }
121
+
122
+ /**
123
+ * Purge esi private tag
124
+ *
125
+ * @since 1.6.3
126
+ * @access public
127
+ */
128
+ public function purge_esi()
129
+ {
130
+ LiteSpeed_Cache_API::debug( '3rd woo purge ESI in action: ' . current_filter() ) ;
131
+ LiteSpeed_Cache_API::purge_private( LiteSpeed_Cache_Tag::TYPE_ESI . 'storefront-cart-header' ) ;
132
  }
133
 
134
  /**
137
  * in woocommerce_before_template_part to see if it's something I can ESI.
138
  *
139
  * @since 1.1.0
140
+ * @since 1.6.3 Removed static
141
  * @access public
142
  */
143
+ public function set_block_template()
144
  {
145
+ add_action('woocommerce_before_template_part', array( $this, 'block_template' ), 999, 4) ;
146
  }
147
 
148
  /**
153
  * Will remove storefront_header_cart in storefront_header.
154
  *
155
  * @since 1.1.0
156
+ * @since 1.6.3 Removed static
157
  * @access public
158
  */
159
+ public function set_swap_header_cart()
160
  {
161
  $priority = has_action('storefront_header', 'storefront_header_cart') ;
162
  if ( $priority !== false ) {
163
  remove_action('storefront_header', 'storefront_header_cart', $priority) ;
164
+ add_action('storefront_header', array( $this, 'esi_cart_header' ), $priority) ;
165
  }
166
  }
167
 
173
  * The function parameters will be passed to the esi request.
174
  *
175
  * @since 1.1.0
176
+ * @since 1.6.3 Removed static
177
  * @access public
178
  * @global type $post Needed for post id
179
  * @param type $template_name
181
  * @param type $located
182
  * @param type $args
183
  */
184
+ public function block_template($template_name, $template_path, $located, $args)
185
  {
186
  if ( strpos($template_name, 'add-to-cart') === false ) {
187
  if ( strpos($template_name, 'related.php') !== false ) {
188
+ remove_action('woocommerce_before_template_part', array( $this, 'block_template' ), 999) ;
189
+ add_filter('woocommerce_related_products_args', array( $this, 'add_related_tags' ) ) ;
190
+ add_action('woocommerce_after_template_part', array( $this, 'end_template' ), 999) ;
191
  }
192
  return ;
193
  }
200
  self::ESI_PARAM_PATH => $template_path,
201
  self::ESI_PARAM_LOCATED => $located
202
  ) ;
203
+ add_action('woocommerce_after_add_to_cart_form', array( $this, 'end_form' ) ) ;
204
+ add_action('woocommerce_after_template_part', array( $this, 'end_form' ), 999) ;
205
  echo LiteSpeed_Cache_API::esi_url('wc-add-to-cart-form', 'WC_CART_FORM', $params) ;
206
  echo LiteSpeed_Cache_API::clean_wrapper_begin() ;
207
  }
212
  * end_template.
213
  *
214
  * @since 1.1.0
215
+ * @since 1.6.3 Removed static
216
  * @access public
217
  */
218
+ public function end_form($template_name = '')
219
  {
220
  if ( ! empty($template_name) && strpos($template_name, 'add-to-cart') === false ) {
221
  return ;
222
  }
223
  echo LiteSpeed_Cache_API::clean_wrapper_end() ;
224
+ remove_action('woocommerce_after_add_to_cart_form', array( $this, 'end_form' ) ) ;
225
+ remove_action('woocommerce_after_template_part', array( $this, 'end_form' ), 999) ;
226
  }
227
 
228
  /**
231
  * The page will be purged if any of the products are changed.
232
  *
233
  * @since 1.1.0
234
+ * @since 1.6.3 Removed static
235
  * @access public
236
  * @param array $args The arguments used to build the related products section.
237
  * @return array The unchanged arguments.
238
  */
239
+ public function add_related_tags($args)
240
  {
241
  if ( empty($args) || ! isset($args['post__in']) ) {
242
  return $args ;
253
  * If the template contains 'add-to-cart', clean the buffer.
254
  *
255
  * @since 1.1.0
256
+ * @since 1.6.3 Removed static
257
  * @access public
258
  * @param type $template_name
259
  */
260
+ public function end_template($template_name)
261
  {
262
  if ( strpos($template_name, 'related.php') !== false ) {
263
+ remove_action('woocommerce_after_template_part', array( $this, 'end_template' ), 999) ;
264
+ $this->set_block_template() ;
265
  }
266
  }
267
 
270
  * If I want to ESI the request, block it and build my esi code block.
271
  *
272
  * @since 1.1.0
273
+ * @since 1.6.3 Removed static
274
  * @access public
275
  */
276
+ public function esi_cart_header()
277
  {
278
  echo LiteSpeed_Cache_API::esi_url('storefront-cart-header', 'STOREFRONT_CART_HEADER') ;
279
  }
283
  * Generates the cart header for esi display.
284
  *
285
  * @since 1.1.0
286
+ * @since 1.6.3 Removed static
287
  * @access public
288
  */
289
+ public function load_cart_header()
290
  {
291
  storefront_header_cart() ;
292
  }
297
  * for esi display.
298
  *
299
  * @since 1.1.0
300
+ * @since 1.6.3 Removed static
301
  * @access public
302
  * @global type $post
303
  * @global type $wp_query
304
  * @param type $params
305
  */
306
+ public function load_add_to_cart_form_block($params)
307
  {
308
  global $post, $wp_query ;
309
  $post = get_post($params[self::ESI_PARAM_POSTID]) ;
310
  $wp_query->setup_postdata($post) ;
311
+ function_exists( 'wc_get_template' ) && wc_get_template($params[self::ESI_PARAM_NAME], $params[self::ESI_PARAM_ARGS], $params[self::ESI_PARAM_PATH]) ;
312
  }
313
 
314
  /**
318
  * Currently, this widget should not be cached.
319
  *
320
  * @since 1.1.0
321
+ * @since 1.6.3 Removed static
322
  * @access public
323
  * @param array $params Widget parameter array
324
  */
325
+ public function register_post_view($params)
326
  {
327
  if ( $params[LiteSpeed_Cache_API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed' ) {
328
  return ;
332
  }
333
  $id = $params[self::ESI_PARAM_POSTID] ;
334
  $esi_post = get_post($id) ;
335
+ $product = function_exists( 'wc_get_product' ) ? wc_get_product($esi_post) : false ;
336
 
337
  if ( empty($product) ) {
338
  return ;
340
 
341
  global $post ;
342
  $post = $esi_post ;
343
+ function_exists( 'wc_track_product_view' ) && wc_track_product_view() ;
344
  }
345
 
346
  /**
349
  * This is needed in the esi request to update the cookie properly.
350
  *
351
  * @since 1.1.0
352
+ * @since 1.6.3 Removed static
353
  * @access public
354
  * @param array $params The current ESI parameters.
355
  * @return array The updated esi parameters.
356
  */
357
+ public function add_post_id($params)
358
  {
359
  if ( ! isset($params) || ! isset($params[LiteSpeed_Cache_API::PARAM_NAME]) || $params[LiteSpeed_Cache_API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed' ) {
360
  return $params ;
370
  * This function will set it to enable and no cache by default.
371
  *
372
  * @since 1.1.0
373
+ * @since 1.6.3 Removed static
374
  * @access public
375
  * @param array $options The current default widget options.
376
  * @param type $widget The current widget to configure.
377
  * @return array The updated default widget options.
378
  */
379
+ public function wc_widget_default($options, $widget)
380
  {
381
  if ( ! is_array($options) ) {
382
  return $options ;
396
  /**
397
  * Check and set shop front page ttl
398
  *
 
399
  * @since 1.1.3
400
+ * @since 1.6.3 Removed static
401
+ * @access private
402
  */
403
+ private function set_ttl()
404
  {
405
+ if ( function_exists( 'is_shop' ) && is_shop() ) {
406
  if ( LiteSpeed_Cache_API::config( self::OPTION_SHOP_FRONT_TTL ) ) {
407
  LiteSpeed_Cache_API::set_use_frontpage_ttl() ;
408
  }
412
  /**
413
  * Set WooCommerce cache tags based on page type.
414
  *
 
415
  * @since 1.0.9
416
+ * @since 1.6.3 Removed static
417
+ * @access public
418
  */
419
+ public function set_tag()
420
  {
421
  $id = get_the_ID() ;
422
  if ( $id === false ) {
439
  LiteSpeed_Cache_API::set_ttl( $ttl ) ;
440
  }
441
 
442
+ if ( function_exists( 'is_shop' ) && is_shop() ) {
443
  LiteSpeed_Cache_API::tag_add(self::CACHETAG_SHOP) ;
444
  }
445
+ if ( function_exists( 'is_product_taxonomy' ) && ! is_product_taxonomy() ) {
446
  return ;
447
  }
448
  if ( isset($GLOBALS['product_cat']) ) {
471
  * Check if the page is cacheable according to WooCommerce.
472
  *
473
  * @since 1.0.5
474
+ * @since 1.6.3 Removed static
475
  * @access public
476
  * @param string $esi_id The ESI block id if a request is an ESI request.
477
  * @return boolean True if cacheable, false if not.
478
  */
479
+ public function set_control($esi_id)
480
  {
481
  if ( LiteSpeed_Cache_API::not_cacheable() ) {
482
  return ;
483
  }
484
 
485
+ /**
486
+ * Avoid possible 500 issue
487
+ * @since 1.6.2.1
488
+ */
489
+ if ( ! function_exists( 'WC' ) ) {
490
+ return ;
491
+ }
492
+
493
  $woocom = WC() ;
494
  if ( ! isset($woocom) ) {
495
  return ;
496
  }
497
+ $this->set_ttl() ;
498
 
499
  // For later versions, DONOTCACHEPAGE should be set.
500
  // No need to check uri/qs.
507
  elseif ( version_compare($woocom->version, '2.1.0', '>=') ) {
508
  $err = false ;
509
 
510
+ if ( ! function_exists( 'wc_get_page_id' ) ) {
511
+ return ;
512
+ }
513
  /**
514
  * From woo/inc/class-wc-cache-helper.php:prevent_caching()
515
  * @since 1.4
521
  elseif ( is_null($woocom->cart) ) {
522
  $err = 'null cart' ;
523
  }
524
+ elseif ( ! $this->esi_eanbled && $woocom->cart->get_cart_contents_count() !== 0 ) {
525
+ if ( $this->cache_cart ) {
526
+ LiteSpeed_Cache_API::set_cache_private() ;
527
+ /**
528
+ * no rewrite rule to set no vary, so can't set no_vary otherwise it will always miss as can't match vary
529
+ * @since 1.6.6.1
530
+ */
531
+ // LiteSpeed_Cache_API::set_cache_no_vary() ;
532
+ LiteSpeed_Cache_API::add_private( LiteSpeed_Cache_Tag::TYPE_ESI . 'storefront-cart-header' ) ;
533
+ }
534
+ else {
535
+ $err = 'cart is not empty' ;
536
+ }
537
  }
538
  elseif ( $esi_id === 'storefront-cart-header' ) {
539
+ if ( $this->cache_cart ) {
540
+ LiteSpeed_Cache_API::set_cache_private() ;
541
+ LiteSpeed_Cache_API::set_cache_no_vary() ;
542
+ LiteSpeed_Cache_API::add_private( LiteSpeed_Cache_Tag::TYPE_ESI . 'storefront-cart-header' ) ;
543
+ }
544
+ else {
545
+ $err = 'ESI cart should be nocache' ;
546
+ }
547
  }
548
+ elseif ( function_exists( 'wc_notice_count' ) && wc_notice_count() > 0 ) {
549
  $err = 'has wc notice' ;
550
  }
551
 
580
  /**
581
  * Purge a product page and related pages (based on settings) on checkout.
582
  *
 
583
  * @since 1.0.9
584
+ * @since 1.6.3 Removed static
585
+ * @access public
586
  * @param WC_Product $product
587
  */
588
+ public function purge_product($product)
589
  {
590
  $config = LiteSpeed_Cache_API::config(self::OPTION_UPDATE_INTERVAL) ;
591
  if ( is_null($config) ) {
593
  }
594
 
595
  if ( $config === self::OPT_PQS_CQS ) {
596
+ $this->backend_purge($product->get_id()) ;
597
  }
598
  elseif ( $config !== self::OPT_PQS_CS && $product->is_in_stock() ) {
599
  return ;
600
  }
601
  elseif ( $config !== self::OPT_PS_CN && ! $product->is_in_stock() ) {
602
+ $this->backend_purge($product->get_id()) ;
603
  }
604
 
605
  LiteSpeed_Cache_API::purge(LiteSpeed_Cache_API::TYPE_POST . $product->get_id()) ;
610
  * the term ids array is not empty, will add purge tags to the deleted
611
  * terms.
612
  *
 
613
  * @since 1.0.9
614
+ * @since 1.6.3 Removed static
615
+ * @access public
616
  * @param int $post_id Object ID.
617
  * @param array $term_ids An array of term taxonomy IDs.
618
  */
619
+ public function delete_rel($post_id, $term_ids)
620
  {
621
+ if ( ! function_exists( 'wc_get_product' ) ) {
622
+ return ;
623
+ }
624
+
625
  if ( empty($term_ids) || wc_get_product($post_id) === false ) {
626
  return ;
627
  }
633
  /**
634
  * Purge a product's categories and tags pages in case they are affected.
635
  *
 
636
  * @since 1.0.9
637
+ * @since 1.6.3 Removed static
638
+ * @access public
639
  * @param int $post_id Post id that is about to be purged
640
  */
641
+ public function backend_purge($post_id)
642
  {
643
+ if ( ! function_exists( 'wc_get_product' ) ) {
644
+ return ;
645
+ }
646
+
647
  if ( ! isset($post_id) || wc_get_product($post_id) === false ) {
648
  return ;
649
  }
650
 
651
+ $cats = $this->get_cats($post_id) ;
652
  if ( ! empty($cats) ) {
653
  foreach ( $cats as $cat ) {
654
  LiteSpeed_Cache_API::purge(self::CACHETAG_TERM . $cat) ;
655
  }
656
  }
657
 
658
+ if ( ! function_exists( 'wc_get_product_terms' ) ) {
659
+ return ;
660
+ }
661
+
662
  $tags = wc_get_product_terms($post_id, 'product_tag', array('fields' => 'ids')) ;
663
  if ( ! empty($tags) ) {
664
  foreach ( $tags as $tag ) {
671
  * When a product has a new review added, purge the recent reviews widget.
672
  *
673
  * @since 1.1.0
674
+ * @since 1.6.3 Removed static
675
  * @access public
676
  * @param $unused
677
  * @param integer $comment_approved Whether the comment is approved or not.
678
  * @param array $commentdata Information about the comment.
679
  */
680
+ public function add_review($unused, $comment_approved, $commentdata)
681
  {
682
+ if ( ! function_exists( 'wc_get_product' ) ) {
683
+ return ;
684
+ }
685
+
686
  $post_id = $commentdata['comment_post_ID'] ;
687
  if ( $comment_approved !== 1 || ! isset($post_id) || wc_get_product($post_id) === false ) {
688
  return ;
698
  * Hooked to the litespeed_cache_get_options filter.
699
  * This will return the option names needed as well as the default options.
700
  *
701
+ * @since 1.6.3 Removed static
702
  * @param array $configs
703
  * @return array
704
  */
705
+ public function get_config($configs)
706
  {
707
  if ( ! is_array($configs) ) {
708
  return $configs ;
709
  }
710
  $configs[self::OPTION_UPDATE_INTERVAL] = self::OPT_PQS_CS ;
711
  $configs[self::OPTION_SHOP_FRONT_TTL] = true ;
712
+ $configs[self::OPTION_WOO_CACHE_CART] = true ;
713
 
714
  return $configs ;
715
  }
719
  * Adds the integration configuration options (currently, to determine
720
  * purge rules)
721
  *
722
+ * @since 1.6.3 Removed static
723
  * @param array $tabs Third party tabs added.
724
  * @param array $options Current options used.
725
  * @param string $option_group The option group to surround the option id.
726
  * @return mixed False on failure, updated tabs otherwise.
727
  */
728
+ public function add_config($tabs, $options, $option_group)
729
  {
730
  $_title = __('WooCommerce', 'litespeed-cache') ;
731
  $_slug = 'woocom' ;
781
  <div class='litespeed-desc'>$ttl_desc</div>
782
  </td>
783
  </tr>
784
+ <tr>
785
+ <th>" . __('Privately Cache Cart', 'litespeed-cache') . "</th>
786
+ <td>
787
+ " . LiteSpeed_Cache_API::build_switch( self::OPTION_WOO_CACHE_CART, false, true ) . "
788
+ <div class='litespeed-desc'>"
789
+ . __( 'Privately cache cart when not empty.', 'litespeed-cache' ) . "
790
+ </div>
791
+ </td>
792
+ </tr>
793
  </tbody></table>
794
  <div class='litespeed-callout-warning'>
795
  <h4>" . __('Note:', 'litespeed-cache') . "</h4>
796
  <i>
797
  " . __('After verifying that the cache works in general, please test the cart.', 'litespeed-cache') . "
798
+ " . sprintf(__('To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:configuration" target="_blank"' ) . "
799
  </i>
800
  </div>
801
 
817
  * Parses the input for this integration's options and updates
818
  * the options array accordingly.
819
  *
820
+ * @since 1.6.3 Removed static
821
  * @param array $options The saved options array.
822
  * @param array $input The input options array.
823
  * @return mixed false on failure, updated $options otherwise.
824
  */
825
+ public function save_config($options, $input)
826
  {
827
  if ( ! isset($options) ) {
828
  return $options ;
843
  }
844
 
845
  $options[ self::OPTION_SHOP_FRONT_TTL ] = LiteSpeed_Cache_API::parse_onoff( $input, self::OPTION_SHOP_FRONT_TTL ) ;
846
+ $options[ self::OPTION_WOO_CACHE_CART ] = LiteSpeed_Cache_API::parse_onoff( $input, self::OPTION_WOO_CACHE_CART ) ;
847
 
848
  return $options ;
849
  }
853
  * category ids.
854
  *
855
  * @since 1.0.10
856
+ * @since 1.6.3 Removed static
857
  * @access private
858
  * @param int $product_id The product id
859
  * @return array An array of category ids.
860
  */
861
+ private function get_cats($product_id)
862
  {
863
+ if ( ! function_exists( 'WC' ) ) {
864
+ return ;
865
+ }
866
+
867
  $woocom = WC() ;
868
+ if ( isset($woocom) && version_compare($woocom->version, '2.5.0', '>=') && function_exists( 'wc_get_product_cat_ids' ) ) {
869
  return wc_get_product_cat_ids($product_id) ;
870
  }
871
  $product_cats = wp_get_post_terms($product_id, 'product_cat', array("fields" => "ids")) ;
876
  return $product_cats ;
877
  }
878
 
879
+ /**
880
+ * Get the current instance object.
881
+ *
882
+ * @since 1.6.3
883
+ * @access public
884
+ * @return Current class instance.
885
+ */
886
+ public static function get_instance()
887
+ {
888
+ if ( ! isset( self::$_instance ) ) {
889
+ self::$_instance = new self() ;
890
+ }
891
+
892
+ return self::$_instance ;
893
+ }
894
  }
895
 
thirdparty/lscwp-3rd-wplister.cls.php CHANGED
@@ -25,9 +25,9 @@ class LiteSpeed_Cache_ThirdParty_WPLister
25
  {
26
  if ( defined('WOOCOMMERCE_VERSION') && defined('WPLISTER_VERSION') ) {
27
  // User reported this will sync correctly.
28
- add_action('wplister_revise_inventory_status', 'LiteSpeed_Cache_ThirdParty_WooCommerce::backend_purge') ;
29
  // Added as a safety measure for WPLister Pro only.
30
- add_action('wplister_inventory_status_changed', 'LiteSpeed_Cache_ThirdParty_WooCommerce::backend_purge') ;
31
  }
32
  }
33
 
25
  {
26
  if ( defined('WOOCOMMERCE_VERSION') && defined('WPLISTER_VERSION') ) {
27
  // User reported this will sync correctly.
28
+ add_action('wplister_revise_inventory_status', array( LiteSpeed_Cache_ThirdParty_WooCommerce::get_instance(), 'backend_purge' ) ) ;
29
  // Added as a safety measure for WPLister Pro only.
30
+ add_action('wplister_inventory_status_changed', array( LiteSpeed_Cache_ThirdParty_WooCommerce::get_instance(), 'backend_purge' ) ) ;
31
  }
32
  }
33
 
thirdparty/lscwp-registry-3rd.php CHANGED
@@ -20,6 +20,7 @@ $thirdparty_list = array(
20
  'autoptimize',
21
  'bbpress',
22
  'betterwp-minify',
 
23
  'nextgengallery',
24
  'theme-my-login',
25
  'woocommerce',
@@ -30,6 +31,7 @@ $thirdparty_list = array(
30
  'wpforo',
31
  'avada',
32
  'wp-postratings',
 
33
  ) ;
34
 
35
  foreach ($thirdparty_list as $val) {
20
  'autoptimize',
21
  'bbpress',
22
  'betterwp-minify',
23
+ 'contact-form-7',
24
  'nextgengallery',
25
  'theme-my-login',
26
  'woocommerce',
31
  'wpforo',
32
  'avada',
33
  'wp-postratings',
34
+ 'login-with-ajax',
35
  ) ;
36
 
37
  foreach ($thirdparty_list as $val) {