LiteSpeed Cache - Version 3.0.9

Version Description

  • May 13 2020 =
  • Purge Comment cache can be successfully purged now.
  • Data Better MySQL charset support for crawler/image optimize table creation. (@Roshan Jonah)
  • API New hook to fire after Purge All. (@salvatorefresta)
  • Crawler Resolve IP for crawler.
  • Task PHP5.3 Cron compatibility fix.
  • 3rd Elementor edit mode compatibility.
  • Page Optimize Fixed an issue where Purge Stale returned 404 for next visitor on CSS/JS.
  • Page Optimize Fixed the PHP warning when srcset doesn't have size info inside. (@gvidano)
  • Cloud Fixed the potential PHP warning when applying for the domain key.
  • Core PHP DIR const replacement. (@MathiasReker)
Download this release

Release Info

Developer hailite
Plugin Icon 128x128 LiteSpeed Cache
Version 3.0.9
Comparing to
See all releases

Code changes from version 2.9.9.2 to 3.0.9

Files changed (145) hide show
  1. admin/admin-api.class.php +0 -551
  2. admin/class-litespeed-cache-admin.php +0 -7
  3. admin/litespeed-cache-admin-display.class.php +0 -1195
  4. admin/litespeed-cache-admin-error.class.php +0 -249
  5. admin/litespeed-cache-admin-optimize.class.php +0 -201
  6. admin/litespeed-cache-admin-rules.class.php +0 -1050
  7. admin/litespeed-cache-admin-settings.class.php +0 -1438
  8. admin/litespeed-cache-admin.class.php +0 -302
  9. admin/tpl/api/quic.login.php +0 -37
  10. admin/tpl/api/quic.register.php +0 -41
  11. admin/tpl/api/quic.user_welcome.php +0 -21
  12. admin/tpl/crawler.php +0 -257
  13. admin/tpl/debug_log.php +0 -45
  14. admin/tpl/edit_htaccess.php +0 -79
  15. admin/tpl/image_optimization.php +0 -45
  16. admin/tpl/import_export.php +0 -70
  17. admin/tpl/inc/img_optm.communicate_notify.php +0 -10
  18. admin/tpl/inc/img_optm.initialize.php +0 -38
  19. admin/tpl/inc/img_optm.level_info.php +0 -46
  20. admin/tpl/inc/img_optm.percentage_summary.php +0 -33
  21. admin/tpl/inc/img_optm.summary.php +0 -312
  22. admin/tpl/manage.php +0 -56
  23. admin/tpl/manage/manage_db.php +0 -93
  24. admin/tpl/network_settings.php +0 -60
  25. admin/tpl/report.php +0 -92
  26. admin/tpl/setting/network_settings_advanced.php +0 -13
  27. admin/tpl/setting/network_settings_cache.php +0 -18
  28. admin/tpl/setting/network_settings_excludes.php +0 -15
  29. admin/tpl/setting/network_settings_media.php +0 -10
  30. admin/tpl/setting/network_settings_purge.php +0 -10
  31. admin/tpl/setting/settings_advanced.php +0 -121
  32. admin/tpl/setting/settings_cache.php +0 -90
  33. admin/tpl/setting/settings_cdn.php +0 -273
  34. admin/tpl/setting/settings_compatibilities.php +0 -38
  35. admin/tpl/setting/settings_crawler.php +0 -305
  36. admin/tpl/setting/settings_debug.php +0 -173
  37. admin/tpl/setting/settings_esi.php +0 -99
  38. admin/tpl/setting/settings_excludes.php +0 -146
  39. admin/tpl/setting/settings_general.php +0 -164
  40. admin/tpl/setting/settings_inc.cache_browser.php +0 -31
  41. admin/tpl/setting/settings_inc.cache_favicon.php +0 -18
  42. admin/tpl/setting/settings_inc.cache_mobile.php +0 -70
  43. admin/tpl/setting/settings_inc.cache_object.php +0 -157
  44. admin/tpl/setting/settings_inc.cache_resources.php +0 -19
  45. admin/tpl/setting/settings_inc.check_adv_file.php +0 -23
  46. admin/tpl/setting/settings_inc.exclude_cookies.php +0 -27
  47. admin/tpl/setting/settings_inc.exclude_useragent.php +0 -26
  48. admin/tpl/setting/settings_inc.media_webp.php +0 -17
  49. admin/tpl/setting/settings_inc.purge_on_upgrade.php +0 -14
  50. admin/tpl/setting/settings_media.php +0 -269
  51. admin/tpl/setting/settings_optimize.php +0 -281
  52. admin/tpl/setting/settings_purge.php +0 -102
  53. admin/tpl/setting/settings_tuning.php +0 -200
  54. admin/tpl/settings.php +0 -220
  55. {css → assets/css}/fonts/litespeedfont.eot +0 -0
  56. {css → assets/css}/fonts/litespeedfont.svg +0 -0
  57. {css → assets/css}/fonts/litespeedfont.ttf +0 -0
  58. {css → assets/css}/fonts/litespeedfont.woff +0 -0
  59. {css → assets/css}/iziModal.min.css +0 -0
  60. assets/css/litespeed-legacy.css +58 -0
  61. assets/css/litespeed.css +3545 -0
  62. {img → assets/img}/Litespeed.icon.svg +0 -0
  63. {img → assets/img}/icons/all.svg +0 -0
  64. {img → assets/img}/icons/all_transients.svg +0 -0
  65. {img → assets/img}/icons/auto_draft.svg +0 -0
  66. {img → assets/img}/icons/cross_icon.svg +0 -0
  67. {img → assets/img}/icons/db.svg +0 -0
  68. {img → assets/img}/icons/empty-cache.svg +0 -0
  69. {img → assets/img}/icons/expired_transient.svg +0 -0
  70. {img → assets/img}/icons/img_optm.svg +0 -0
  71. {img → assets/img}/icons/img_optm_disabled.svg +0 -0
  72. {img → assets/img}/icons/img_webp.svg +0 -0
  73. {img → assets/img}/icons/img_webp_disabled.svg +0 -0
  74. {img → assets/img}/icons/optimize_tables.svg +0 -0
  75. {img → assets/img}/icons/purge-403.svg +0 -0
  76. {img → assets/img}/icons/purge-404.svg +0 -0
  77. {img → assets/img}/icons/purge-500.svg +0 -0
  78. {img → assets/img}/icons/purge-all.svg +0 -0
  79. {img → assets/img}/icons/purge-cssjs.svg +0 -0
  80. {img → assets/img}/icons/purge-front.svg +0 -0
  81. {img → assets/img}/icons/purge-object.svg +0 -0
  82. {img → assets/img}/icons/purge-opcache.svg +0 -0
  83. {img → assets/img}/icons/purge-pages.svg +0 -0
  84. {img → assets/img}/icons/revision.svg +0 -0
  85. {img → assets/img}/icons/spam_comment.svg +0 -0
  86. {img → assets/img}/icons/success_icon.svg +0 -0
  87. {img → assets/img}/icons/trackback-pingback.svg +0 -0
  88. {img → assets/img}/icons/trash_comment.svg +0 -0
  89. {img → assets/img}/icons/trash_post.svg +0 -0
  90. {img → assets/img}/lscwp-logo_90x90.png +0 -0
  91. assets/img/quic-cloud-icon-16x16.svg +22 -0
  92. {img → assets/img}/slack-logo.png +0 -0
  93. {js → assets/js}/css_async.js +0 -0
  94. {js → assets/js}/css_async.min.js +0 -0
  95. {js → assets/js}/instant_click.min.js +0 -0
  96. {js → assets/js}/instant_click.ori.js +0 -0
  97. {js → assets/js}/iziModal.min.js +0 -0
  98. {js → assets/js}/lazyload.init.js +7 -3
  99. {js → assets/js}/lazyload.lib.js +0 -0
  100. {js → assets/js}/lazyload.min.js +1 -1
  101. {js → assets/js}/litespeed-cache-admin.js +86 -39
  102. assets/js/vue.min.js +1 -0
  103. {js → assets/js}/webfontloader.js +0 -0
  104. {js → assets/js}/webfontloader.min.js +0 -0
  105. autoload.php +42 -0
  106. cli/debug.cls.php +40 -0
  107. cli/image.cls.php +166 -0
  108. cli/litespeed-cache-cli-admin.class.php +0 -341
  109. cli/litespeed-cache-cli-iapi.class.php +0 -200
  110. cli/litespeed-cache-cli-purge.class.php +0 -302
  111. cli/online.cls.php +142 -0
  112. cli/option.cls.php +353 -0
  113. cli/purge.cls.php +307 -0
  114. css/litespeed.css +0 -2413
  115. data/.htaccess +0 -0
  116. data/const.default.ini +588 -24
  117. data/const.network_default.ini +104 -0
  118. inc/activation.class.php +0 -554
  119. inc/api.class.php +0 -658
  120. inc/cdn/quic.class.php +0 -257
  121. inc/config.class.php +0 -819
  122. inc/const.cls.php +0 -662
  123. inc/control.class.php +0 -772
  124. inc/crawler-sitemap.class.php +0 -160
  125. inc/crawler.class.php +0 -660
  126. inc/css.cls.php +0 -363
  127. inc/data.class.php +0 -359
  128. inc/data_structure/img_optm.sql +0 -20
  129. inc/data_structure/optm.sql +0 -8
  130. inc/doc.cls.php +0 -42
  131. inc/img_optm.class.php +0 -2168
  132. inc/import.class.php +0 -291
  133. inc/litespeed-cache.class.php +0 -774
  134. inc/litespeed.autoload.php +0 -151
  135. inc/log.class.php +0 -498
  136. inc/media.class.php +0 -1084
  137. inc/object.lib.php +1 -653
  138. inc/purge.class.php +0 -1051
  139. inc/rest.cls.php +0 -123
  140. inc/router.class.php +0 -715
  141. inc/task.class.php +0 -274
  142. inc/utility.class.php +0 -833
  143. includes/advanced-cache.php +0 -20
  144. includes/deprecated-litespeed-cache-tags.class.php +0 -12
  145. includes/litespeed-cache-api.class.php +0 -407
admin/admin-api.class.php DELETED
@@ -1,551 +0,0 @@
1
- <?php
2
- /**
3
- * Admin API
4
- *
5
- * @since 1.5
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/admin
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Admin_API
16
- {
17
- private static $_instance ;
18
-
19
- private $_iapi_key ;
20
- private $_iapi_cloud ;
21
-
22
- const DB_API_KEY = 'litespeed_api_key' ;
23
- const DB_API_CLOUD = 'litespeed_api_cloud' ;
24
- const DB_API_KEY_HASH = 'litespeed_api_key_hash' ;
25
-
26
- // For each request, send a callback to confirm
27
- const TYPE_REQUEST_CALLBACK = 'request_callback' ;
28
- const TYPE_NOTIFY_IMG = 'notify_img' ;
29
- const TYPE_CHECK_IMG = 'check_img' ;
30
- const TYPE_IMG_DESTROY_CALLBACK = 'imgoptm_destroy' ;
31
- const TYPE_RESET_KEY = 'reset_key' ;
32
-
33
- const IAPI_ACTION_REQUEST_KEY = 'request_key' ;
34
- const IAPI_ACTION_LIST_CLOUDS = 'list_clouds' ;
35
- const IAPI_ACTION_MEDIA_SYNC_DATA = 'media_sync_data' ;
36
- const IAPI_ACTION_REQUEST_OPTIMIZE = 'request_optimize' ;
37
- const IAPI_ACTION_IMG_TAKEN = 'client_img_taken' ;
38
- const IAPI_ACTION_REQUEST_DESTROY = 'imgoptm_destroy' ;
39
- const IAPI_ACTION_REQUEST_DESTROY_UNFINISHED = 'imgoptm_destroy_unfinished' ;
40
- const IAPI_ACTION_ENV_REPORT = 'env_report' ;
41
- const IAPI_ACTION_PLACEHOLDER = 'placeholder' ;
42
- const IAPI_ACTION_CCSS = 'ccss' ;
43
- const IAPI_ACTION_PAGESCORE = 'pagescore' ;
44
-
45
- /**
46
- * Init
47
- *
48
- * @since 1.5
49
- * @access private
50
- */
51
- private function __construct()
52
- {
53
- $this->_iapi_key = get_option( self::DB_API_KEY ) ?: '' ;
54
- $this->_iapi_cloud = get_option( self::DB_API_CLOUD ) ?: '' ;
55
- }
56
-
57
- /**
58
- * Handle all request actions from main cls
59
- *
60
- * @since 1.7.2
61
- * @access public
62
- */
63
- public static function handler()
64
- {
65
- $instance = self::get_instance() ;
66
-
67
- $type = LiteSpeed_Cache_Router::verify_type() ;
68
-
69
- switch ( $type ) {
70
- case self::TYPE_RESET_KEY :
71
- $instance->_reset_key() ;
72
- break ;
73
-
74
- default:
75
- break ;
76
- }
77
-
78
- LiteSpeed_Cache_Admin::redirect() ;
79
- }
80
-
81
- /**
82
- * Handle aggressive callback requests from LiteSpeed image server
83
- *
84
- * @since 1.6
85
- * @since 1.6.7 Added destroy callback
86
- * @access public
87
- */
88
- public static function sapi_aggressive_callback()
89
- {
90
- $instance = self::get_instance() ;
91
-
92
- switch ( LiteSpeed_Cache_Router::verify_type() ) {
93
- case self::TYPE_NOTIFY_IMG :
94
- LiteSpeed_Cache_Img_Optm::get_instance()->notify_img() ;
95
- break ;
96
-
97
- case self::TYPE_CHECK_IMG :
98
- $instance->validate_lsserver() ;
99
- LiteSpeed_Cache_Img_Optm::get_instance()->check_img() ;
100
- break ;
101
-
102
- case self::TYPE_IMG_DESTROY_CALLBACK :
103
- LiteSpeed_Cache_Img_Optm::get_instance()->img_optimize_destroy_callback() ;
104
- break ;
105
-
106
- default:
107
- break ;
108
- }
109
-
110
- exit ;
111
- }
112
-
113
- /**
114
- * Validate litespeed api server IP
115
- *
116
- * @since 1.6.5
117
- * @access public
118
- */
119
- public function validate_lsserver()
120
- {
121
- $ip = gethostbyname( 'wp.api.litespeedtech.com' ) ;
122
- if ( $ip != LiteSpeed_Cache_Router::get_ip() ) {
123
- exit( 'wrong ip' ) ;
124
- }
125
- }
126
-
127
- /**
128
- * Handle passive callback requests from LiteSpeed image server
129
- *
130
- * @since 1.6
131
- * @access public
132
- */
133
- public static function sapi_passive_callback()
134
- {
135
- $instance = self::get_instance() ;
136
-
137
- switch ( LiteSpeed_Cache_Router::verify_type() ) {
138
- case self::TYPE_REQUEST_CALLBACK :
139
- $instance->_request_callback() ;
140
- break ;
141
-
142
- default:
143
- break ;
144
- }
145
-
146
- exit ;
147
- }
148
-
149
- /**
150
- * request key callback from LiteSpeed
151
- *
152
- * @since 1.5
153
- * @access private
154
- */
155
- private function _request_callback()
156
- {
157
- $key_hash = get_option( self::DB_API_KEY_HASH ) ;
158
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback request hash: ' . $key_hash ) ;
159
- exit( $key_hash ) ;
160
- }
161
-
162
- /**
163
- * Check if is valid callback from litespeed passive request
164
- *
165
- * @since 1.5
166
- * @access public
167
- * @return bool True if correct
168
- */
169
- public static function sapi_valiate_passive_callback()
170
- {
171
- if ( empty( $_REQUEST[ 'hash' ] ) ) {
172
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback bypassed passive check' ) ;
173
- return false ;
174
- }
175
- $instance = self::get_instance() ;
176
-
177
- // use tmp hash to check
178
- $key_hash = get_option( self::DB_API_KEY_HASH ) ;
179
- $hash_check = md5( $key_hash ) === $_REQUEST[ 'hash' ] ;
180
-
181
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback hash check ' . $key_hash . ': ' . ( $hash_check ? 'passed' : 'failed' ) ) ;
182
-
183
- return $hash_check ;
184
- }
185
-
186
- /**
187
- * Check if is valid callback from litespeed aggressive request
188
- *
189
- * @since 1.6
190
- * @access public
191
- * @return bool True if correct
192
- */
193
- public static function sapi_validate_aggressive_callback()
194
- {
195
- $instance = self::get_instance() ;
196
-
197
- // don't have auth_key yet
198
- if ( ! $instance->_iapi_key ) {
199
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive check failed: No init key' ) ;
200
- return false ;
201
- }
202
-
203
- // Once client has auth_key, each time when callback to check, need to carry on this key
204
- if ( empty( $_REQUEST[ 'auth_key' ] ) ) {
205
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive check failed: lack of auth_key' ) ;
206
- return false ;
207
- }
208
-
209
- $res = md5( $instance->_iapi_key ) === $_REQUEST[ 'auth_key' ] ;
210
- LiteSpeed_Cache_Log::debug( '[IAPI] __callback aggressive auth_key check: ' . ( $res ? 'passed' : 'failed' ) ) ;
211
- return $res ;
212
- }
213
-
214
- /**
215
- * Get data from LiteSpeed cloud server
216
- *
217
- * @since 2.9
218
- * @access public
219
- */
220
- public static function get( $action, $data = array(), $server = false )
221
- {
222
- $instance = self::get_instance() ;
223
-
224
- /**
225
- * All requests must have closet cloud server too
226
- * @since 2.9
227
- */
228
- if ( ! $instance->_iapi_cloud ) {
229
- $instance->_detect_cloud() ;
230
- }
231
-
232
- return $instance->_get( $action, $data, $server ) ;
233
- }
234
-
235
- /**
236
- * Post data to LiteSpeed cloud server
237
- *
238
- * @since 1.6
239
- * @access public
240
- */
241
- public static function post( $action, $data = false, $server = false, $no_hash = false, $time_out = false )
242
- {
243
- $instance = self::get_instance() ;
244
-
245
- /**
246
- * All requests must have closet cloud server too
247
- * @since 2.9
248
- */
249
- if ( ! $instance->_iapi_cloud ) {
250
- $instance->_detect_cloud() ;
251
- }
252
-
253
- /**
254
- * All requests must have api_key first
255
- * @since 1.6.5
256
- */
257
- if ( ! $instance->_iapi_key ) {
258
- $instance->_request_key() ;
259
- }
260
-
261
- return $instance->_post( $action, $data, $server, $no_hash, $time_out ) ;
262
- }
263
-
264
- /**
265
- * request key from LiteSpeed
266
- *
267
- * This needs callback validation, so don't use for generic services which don't need security
268
- *
269
- * @since 1.5
270
- * @access private
271
- */
272
- private function _request_key()
273
- {
274
- LiteSpeed_Cache_Log::debug( '[IAPI] req auth_key' ) ;
275
-
276
- // Send request to LiteSpeed
277
- $json = $this->_post( self::IAPI_ACTION_REQUEST_KEY, home_url(), true ) ;
278
-
279
- // Check if get key&server correctly
280
- if ( empty( $json[ 'auth_key' ] ) ) {
281
- LiteSpeed_Cache_Log::debug( '[IAPI] request key failed: ', $json ) ;
282
-
283
- if ( $json ) {
284
- $msg = sprintf( __( 'IAPI Error %s', 'litespeed-cache' ), $json ) ;
285
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
286
- }
287
- return ;
288
- }
289
-
290
- // store data into option locally
291
- update_option( self::DB_API_KEY, $json[ 'auth_key' ] ) ;
292
- LiteSpeed_Cache_Log::debug( '[IAPI] applied auth_key' ) ;
293
-
294
- $this->_iapi_key = $json[ 'auth_key' ] ;
295
- }
296
-
297
- /**
298
- * ping clouds from LiteSpeed
299
- *
300
- * @since 2.9
301
- * @access private
302
- */
303
- private function _detect_cloud()
304
- {
305
- // Send request to LiteSpeed
306
- $json = $this->_post( self::IAPI_ACTION_LIST_CLOUDS, home_url(), false, true ) ;
307
-
308
- // Check if get list correctly
309
- if ( empty( $json[ 'list' ] ) ) {
310
- LiteSpeed_Cache_Log::debug( '[IAPI] request cloud list failed: ', $json ) ;
311
-
312
- if ( $json ) {
313
- $msg = sprintf( __( 'IAPI Error %s', 'litespeed-cache' ), $json ) ;
314
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
315
- }
316
- return ;
317
- }
318
-
319
- // Ping closest cloud
320
- $speed_list = array() ;
321
- foreach ( $json[ 'list' ] as $v ) {
322
- $speed_list[ $v ] = LiteSpeed_Cache_Utility::ping( $v ) ;
323
- }
324
- $min = min( $speed_list ) ;
325
-
326
- if ( $min == 99999 ) {
327
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to ping all clouds' ) ;
328
- return ;
329
- }
330
- $closest = array_search( $min, $speed_list ) ;
331
-
332
- LiteSpeed_Cache_Log::debug( '[IAPI] Found closest cloud ' . $closest ) ;
333
-
334
- // store data into option locally
335
- update_option( self::DB_API_CLOUD, $closest ) ;
336
-
337
- $this->_iapi_cloud = $closest ;
338
-
339
- // sync API key
340
- $this->_request_key() ;
341
- }
342
-
343
- /**
344
- * delete key
345
- *
346
- * @since 1.7.2
347
- * @access private
348
- */
349
- private function _reset_key()
350
- {
351
- delete_option( self::DB_API_KEY ) ;
352
- delete_option( self::DB_API_CLOUD ) ;
353
- LiteSpeed_Cache_Log::debug( '[IAPI] delete auth_key & closest cloud' ) ;
354
-
355
- $msg = __( 'Reset IAPI key successfully.', 'litespeed-cache' ) ;
356
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
357
- }
358
-
359
- /**
360
- * Get data from LiteSpeed cloud server
361
- *
362
- * @since 2.9
363
- * @access private
364
- */
365
- private function _get( $action, $data = false, $server = false )
366
- {
367
-
368
- if ( $server == false ) {
369
- $server = 'https://wp.api.litespeedtech.com' ;
370
- }
371
- elseif ( $server === true ) {
372
- $server = $this->_iapi_cloud ;
373
- }
374
-
375
- $url = $server . '/' . $action ;
376
-
377
- if ( $data ) {
378
- $url .= '?' . http_build_query( $data ) ;
379
- }
380
-
381
- LiteSpeed_Cache_Log::debug( '[IAPI] getting from : ' . $url ) ;
382
-
383
- $response = wp_remote_get( $url, array( 'timeout' => 15 ) ) ;
384
-
385
- // Parse response data
386
- if ( is_wp_error( $response ) ) {
387
- $error_message = $response->get_error_message() ;
388
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to get: ' . $error_message ) ;
389
- return false ;
390
- }
391
-
392
- $data = $response[ 'body' ] ;
393
-
394
- return $data ;
395
-
396
- }
397
-
398
- /**
399
- * Post data to LiteSpeed cloud server
400
- *
401
- * @since 1.6
402
- * @access private
403
- * @return string | array Must return an error msg string or json array
404
- */
405
- private function _post( $action, $data = false, $server = false, $no_hash = false, $time_out = false )
406
- {
407
- $hash = 'no_hash' ;
408
- if ( ! $no_hash ) {
409
- $hash = Litespeed_String::rrand( 16 ) ;
410
- // store hash
411
- update_option( self::DB_API_KEY_HASH, $hash ) ;
412
- }
413
-
414
- if ( $server == false ) {
415
- $server = 'https://wp.api.litespeedtech.com' ;
416
- }
417
- elseif ( $server === true ) {
418
- $server = $this->_iapi_cloud ;
419
- }
420
-
421
- $url = $server . '/' . $action ;
422
-
423
- LiteSpeed_Cache_Log::debug( '[IAPI] posting to : ' . $url ) ;
424
-
425
- $param = array(
426
- 'auth_key' => $this->_iapi_key,
427
- 'cloud' => $this->_iapi_cloud,
428
- 'v' => LiteSpeed_Cache::PLUGIN_VERSION,
429
- 'hash' => $hash,
430
- 'data' => $data,
431
- ) ;
432
- /**
433
- * Extended timeout to avoid cUrl 28 timeout issue as we need callback validation
434
- * @since 1.6.4
435
- */
436
- $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => $time_out ?: 15 ) ) ;
437
-
438
- if ( is_wp_error( $response ) ) {
439
- $error_message = $response->get_error_message() ;
440
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to post: ' . $error_message ) ;
441
- return $error_message ;
442
- }
443
-
444
- // parse data from server
445
- $json = json_decode( $response[ 'body' ], true ) ;
446
-
447
- if ( ! is_array( $json ) ) {
448
- LiteSpeed_Cache_Log::debug( '[IAPI] failed to decode post json: ' . $response[ 'body' ] ) ;
449
-
450
- $msg = __( 'Failed to post via WordPress', 'litespeed-cache' ) . ': ' . $response[ 'body' ] ;
451
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
452
-
453
- return false ;
454
- }
455
-
456
- if ( ! empty( $json[ '_err' ] ) ) {
457
- LiteSpeed_Cache_Log::debug( '[IAPI] _err: ' . $json[ '_err' ] ) ;
458
- $msg = __( 'Failed to communicate with LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_err' ] ;
459
- $msg .= $this->_parse_link( $json ) ;
460
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
461
- return false ;
462
- }
463
-
464
- if ( ! empty( $json[ '_503' ] ) ) {
465
- LiteSpeed_Cache_Log::debug( '[IAPI] service 503 unavailable temporarily. ' . $json[ '_503' ] ) ;
466
-
467
- $msg = __( 'We are working hard to improve your Image Optimization experience. The service will be unavailable while we work. We apologize for any inconvenience.', 'litespeed-cache' ) ;
468
- $msg .= ' ' . $json[ '_503' ] ;
469
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
470
-
471
- return false ;
472
- }
473
-
474
- if ( ! empty( $json[ '_info' ] ) ) {
475
- LiteSpeed_Cache_Log::debug( '[IAPI] _info: ' . $json[ '_info' ] ) ;
476
- $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_info' ] ;
477
- $msg .= $this->_parse_link( $json ) ;
478
- LiteSpeed_Cache_Admin_Display::info( $msg ) ;
479
- unset( $json[ '_info' ] ) ;
480
- }
481
-
482
- if ( ! empty( $json[ '_note' ] ) ) {
483
- LiteSpeed_Cache_Log::debug( '[IAPI] _note: ' . $json[ '_note' ] ) ;
484
- $msg = __( 'Message from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_note' ] ;
485
- $msg .= $this->_parse_link( $json ) ;
486
- LiteSpeed_Cache_Admin_Display::note( $msg ) ;
487
- unset( $json[ '_note' ] ) ;
488
- }
489
-
490
- if ( ! empty( $json[ '_success' ] ) ) {
491
- LiteSpeed_Cache_Log::debug( '[IAPI] _success: ' . $json[ '_success' ] ) ;
492
- $msg = __( 'Good news from LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_success' ] ;
493
- $msg .= $this->_parse_link( $json ) ;
494
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
495
- unset( $json[ '_success' ] ) ;
496
- }
497
-
498
- // Upgrade is required
499
- if ( ! empty( $json[ '_err_req_v' ] ) ) {
500
- LiteSpeed_Cache_Log::debug( '[IAPI] _err_req_v: ' . $json[ '_err_req_v' ] ) ;
501
- $msg = sprintf( __( '%s plugin version %s required for this action.', 'litespeed-cache' ), LiteSpeed_Cache::NAME, 'v' . $json[ '_err_req_v' ] . '+' ) ;
502
-
503
- // Append upgrade link
504
- $msg2 = ' ' . LiteSpeed_Cache_GUI::plugin_upgrade_link( LiteSpeed_Cache::NAME, LiteSpeed_Cache::PLUGIN_NAME, $json[ '_err_req_v' ] ) ;
505
-
506
- $msg2 .= $this->_parse_link( $json ) ;
507
- LiteSpeed_Cache_Admin_Display::error( $msg . $msg2 ) ;
508
- return false ;
509
- }
510
-
511
- return $json ;
512
- }
513
-
514
- /**
515
- * Parse _links from json
516
- *
517
- * @since 1.6.5
518
- * @since 1.6.7 Self clean the parameter
519
- * @access private
520
- */
521
- private function _parse_link( &$json )
522
- {
523
- $msg = '' ;
524
-
525
- if ( ! empty( $json[ '_links' ] ) ) {
526
- foreach ( $json[ '_links' ] as $v ) {
527
- $msg .= ' ' . sprintf( '<a href="%s" class="%s" target="_blank">%s</a>', $v[ 'link' ], ! empty( $v[ 'cls' ] ) ? $v[ 'cls' ] : '', $v[ 'title' ] ) ;
528
- }
529
-
530
- unset( $json[ '_links' ] ) ;
531
- }
532
-
533
- return $msg ;
534
- }
535
-
536
- /**
537
- * Get the current instance object.
538
- *
539
- * @since 1.5
540
- * @access public
541
- * @return Current class instance.
542
- */
543
- public static function get_instance()
544
- {
545
- if ( ! isset( self::$_instance ) ) {
546
- self::$_instance = new self() ;
547
- }
548
-
549
- return self::$_instance ;
550
- }
551
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/class-litespeed-cache-admin.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
- /**
3
- * ONLY for WHM plugin old version backward compatibility @Aug/2/2017
4
- */
5
-
6
-
7
- require_once dirname(__FILE__) . '/litespeed-cache-admin.class.php' ;
 
 
 
 
 
 
 
admin/litespeed-cache-admin-display.class.php DELETED
@@ -1,1195 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Display
17
- {
18
- private static $_instance ;
19
-
20
- const NOTICE_BLUE = 'notice notice-info' ;
21
- const NOTICE_GREEN = 'notice notice-success' ;
22
- const NOTICE_RED = 'notice notice-error' ;
23
- const NOTICE_YELLOW = 'notice notice-warning' ;
24
- const LITESPEED_MSG = 'litespeed_messages' ;
25
-
26
- const PURGEBY_CAT = '0' ;
27
- const PURGEBY_PID = '1' ;
28
- const PURGEBY_TAG = '2' ;
29
- const PURGEBY_URL = '3' ;
30
-
31
- const PURGEBYOPT_SELECT = 'purgeby' ;
32
- const PURGEBYOPT_LIST = 'purgebylist' ;
33
-
34
- const DISMISS_MSG = 'litespeed-cache-dismiss' ;
35
- const RULECONFLICT_ON = 'ExpiresDefault_1' ;
36
- const RULECONFLICT_DISMISSED = 'ExpiresDefault_0' ;
37
-
38
- private $config ;
39
- private $messages = array() ;
40
- private $disable_all = false ;
41
- private $default_settings = array() ;
42
-
43
- /**
44
- * Initialize the class and set its properties.
45
- *
46
- * @since 1.0.7
47
- * @access private
48
- */
49
- private function __construct()
50
- {
51
- // load assets
52
- if( ! empty($_GET['page']) &&
53
- (substr($_GET['page'], 0, 8) == 'lscache-' || $_GET['page'] == 'litespeedcache') ) {
54
- add_action('admin_enqueue_scripts', array($this, 'load_assets')) ;
55
- }
56
-
57
- // main css
58
- add_action('admin_enqueue_scripts', array($this, 'enqueue_style')) ;
59
- // Main js
60
- add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')) ;
61
-
62
- $is_network_admin = is_network_admin() ;
63
-
64
- // Quick access menu
65
- if ( is_multisite() && $is_network_admin ) {
66
- $manage = 'manage_network_options' ;
67
- }
68
- else {
69
- $manage = 'manage_options' ;
70
- }
71
- if ( current_user_can($manage) ) {
72
- add_action( 'wp_before_admin_bar_render', array( LiteSpeed_Cache_GUI::get_instance(), 'backend_shortcut' ) ) ;
73
-
74
- // add_action('admin_enqueue_scripts', array($this, 'check_messages')) ;// We can do this bcos admin_notices hook is after admin_enqueue_scripts hook in wp-admin/admin-header.php
75
- add_action( is_network_admin() ? 'network_admin_notices' : 'admin_notices', array( $this, 'display_messages' ) ) ;
76
- }
77
-
78
- /**
79
- * In case this is called outside the admin page
80
- * @see https://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
81
- * @since 2.0
82
- */
83
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
84
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;
85
- }
86
-
87
- // add menus ( Also check for mu-plugins)
88
- if ( $is_network_admin && ( is_plugin_active_for_network( LSCWP_BASENAME ) || defined( 'LSCWP_MU_PLUGIN' ) ) ) {
89
- add_action('network_admin_menu', array($this, 'register_admin_menu')) ;
90
- }
91
- else {
92
- add_action('admin_menu', array($this, 'register_admin_menu')) ;
93
- }
94
-
95
- $this->config = LiteSpeed_Cache_Config::get_instance() ;
96
-
97
- // get default setting values
98
- $this->default_settings = $this->config->get_default_options() ;
99
- }
100
-
101
- /**
102
- * Load LiteSpeed assets
103
- *
104
- * @since 1.1.0
105
- * @access public
106
- * @param array $hook WP hook
107
- */
108
- public function load_assets($hook)
109
- {
110
- // Admin footer
111
- add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
112
-
113
- if( defined( 'LITESPEED_ON' ) ) {
114
- // Help tab
115
- $this->add_help_tabs() ;
116
-
117
- global $pagenow ;
118
- if ( $pagenow === 'plugins.php' ) {//todo: check if work
119
- add_action('wp_default_scripts', array($this, 'set_update_text'), 0) ;
120
- add_action('wp_default_scripts', array($this, 'unset_update_text'), 20) ;
121
- }
122
- }
123
-
124
- }
125
-
126
- /**
127
- * Update latest release news for v3.0
128
- *
129
- * @since 2.9.9.1
130
- */
131
- private function _fetch_recommended()
132
- {
133
- $news = get_option( 'litespeed-recommended', array() );
134
- if ( ! empty( $news[ 'utime' ] ) && time() - $news[ 'utime' ] < 86400*1 ) {
135
- return $news;
136
- }
137
-
138
- $data = LiteSpeed_Cache_Admin_API::post( 'news' );
139
- $news[ 'utime' ] = time();
140
- update_option( 'litespeed-recommended', $news );
141
- if ( empty( $data[ 'id' ] ) ) {
142
- return $news;
143
- }
144
-
145
- // Save news
146
- if ( empty( $news[ 'id' ] ) || $news[ 'id' ] != $data[ 'id' ] ) {
147
- $news[ 'id' ] = $data[ 'id' ];
148
- $news[ 'plugin' ] = ! empty( $data[ 'plugin' ] ) ? $data[ 'plugin' ] : '';
149
- $news[ 'title' ] = ! empty( $data[ 'title' ] ) ? $data[ 'title' ] : '';
150
- $news[ 'content' ] = ! empty( $data[ 'content' ] ) ? $data[ 'content' ] : '';
151
- $news[ 'zip' ] = ! empty( $data[ 'zip' ] ) ? $data[ 'zip' ] : '';
152
- $news[ 'new' ] = 1;
153
-
154
- if ( $news[ 'plugin' ] ) {
155
- $plugin_info = LiteSpeed_Cache_Activation::get_instance()->dash_notifier_get_plugin_info( $news[ 'plugin' ] );
156
- if ( $plugin_info && ! empty( $plugin_info->name ) ) {
157
- $news[ 'plugin_name' ] = $plugin_info->name;
158
- }
159
- }
160
-
161
- update_option( 'litespeed-recommended', $news );
162
- }
163
-
164
- return $news;
165
- }
166
-
167
- /**
168
- * Load latest news
169
- *
170
- * @since 2.9.9.1
171
- */
172
- private function _show_recommended()
173
- {
174
- // Fetch v3.0 info to show
175
- $news = $this->_fetch_recommended();
176
- if ( ! $news || empty( $news[ 'new' ] ) ) {
177
- return;
178
- }
179
-
180
- if ( ! empty( $news[ 'plugin' ] ) && LiteSpeed_Cache_Activation::get_instance()->dash_notifier_is_plugin_active( $news[ 'plugin' ] ) ) {
181
- return;
182
- }
183
-
184
- ?>
185
- <div class="litespeed-wrap notice notice-success litespeed-banner-promo-full">
186
-
187
- <div class="litespeed-banner-promo-content">
188
- <h3 class="litespeed-banner-title litespeed-top15"><?php echo $news[ 'title' ] ; ?></h3>
189
- <div class="litespeed-banner-description">
190
- <div class="litespeed-banner-description-padding-right-15">
191
- <p class="litespeed-banner-desciption-content">
192
- <?php echo $news[ 'content' ]; ?>
193
- </p>
194
- </div>
195
- <div class="litespeed-row-flex litespeed-banner-description">
196
- <div class="litespeed-banner-description-padding-right-15">
197
- <?php if ( ! empty( $news[ 'plugin' ] ) ) : ?>
198
- <?php $install_link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_INSTALL_3RD, false, null, array( 'plugin' => $news[ 'plugin' ] ) ); ?>
199
- <a href="<?php echo $install_link ; ?>" class="litespeed-btn-success litespeed-btn-mini">
200
- <?php echo __( 'Install', 'litespeed-cache' ); ?>
201
- <?php if ( ! empty( $news[ 'plugin_name' ] ) ) echo $news[ 'plugin_name' ]; ?>
202
- </a>
203
- <?php endif; ?>
204
- <?php if ( ! empty( $news[ 'zip' ] ) ) : ?>
205
- <?php $install_link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_INSTALL_ZIP ); ?>
206
- <a href="<?php echo $install_link ; ?>" class="litespeed-btn-success litespeed-btn-mini">
207
- <?php echo __( 'Install Beta Version', 'litespeed-cache' ); ?>
208
- </a>
209
- <?php endif; ?>
210
- </div>
211
- </div>
212
- </div>
213
- </div>
214
-
215
- <div>
216
- <?php $dismiss_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_DISMISS_RECOMMENDED ) ; ?>
217
- <span class="screen-reader-text">Dismiss this notice.</span>
218
- <a href="<?php echo $dismiss_url ; ?>" class="litespeed-notice-dismiss">X</a>
219
- </div>
220
- </div>
221
- <?php
222
- }
223
-
224
- /**
225
- * Output litespeed form info
226
- *
227
- * @since 1.1.0
228
- * @access public
229
- * @param string $action
230
- */
231
- public function form_action( $action, $type = false )
232
- {
233
- echo '<input type="hidden" name="' . LiteSpeed_Cache::ACTION_KEY . '" value="' . $action . '" />' ;
234
- if ( $type ) {
235
- echo '<input type="hidden" name="type" value="' . $type . '" />' ;
236
- }
237
- wp_nonce_field($action, LiteSpeed_Cache::NONCE_NAME) ;
238
- }
239
-
240
-
241
- /**
242
- * Register the admin menu display.
243
- *
244
- * @since 1.0.0
245
- * @access public
246
- */
247
- public function register_admin_menu()
248
- {
249
- $capability = is_network_admin() ? 'manage_network_options' : 'manage_options' ;
250
- if ( current_user_can($capability) ) {
251
- // root menu
252
- add_menu_page('LiteSpeed Cache', 'LiteSpeed Cache', 'manage_options', 'lscache-settings') ;
253
-
254
- // sub menus
255
- $this->add_submenu(__('Settings', 'litespeed-cache'), 'lscache-settings', 'show_menu_settings') ;
256
-
257
- $this->add_submenu(__('Manage', 'litespeed-cache'), 'lscache-dash', 'show_menu_manage') ;
258
-
259
- if ( ! is_multisite() || is_network_admin() ) {
260
- $this->add_submenu(__('Edit .htaccess', 'litespeed-cache'), LiteSpeed_Cache::PAGE_EDIT_HTACCESS, 'show_menu_edit_htaccess') ;
261
- }
262
-
263
- if ( ! is_network_admin() ) {
264
- $this->add_submenu(__('Image Optimization', 'litespeed-cache'), 'lscache-optimization', 'show_optimization') ;
265
- $this->add_submenu(__('Crawler', 'litespeed-cache'), 'lscache-crawler', 'show_crawler') ;
266
- $this->add_submenu(__('Report', 'litespeed-cache'), 'lscache-report', 'show_report') ;
267
- $this->add_submenu(__('Import / Export', 'litespeed-cache'), 'lscache-import', 'show_import_export') ;
268
- }
269
-
270
- defined( 'LSCWP_LOG' ) && $this->add_submenu(__('Debug Log', 'litespeed-cache'), 'lscache-debug', 'show_debug_log') ;
271
-
272
- // sub menus under options
273
- add_options_page('LiteSpeed Cache', 'LiteSpeed Cache', $capability, 'litespeedcache', array($this, 'show_menu_settings')) ;
274
- }
275
- }
276
-
277
- /**
278
- * Helper function to set up a submenu page.
279
- *
280
- * @since 1.0.4
281
- * @access private
282
- * @param string $menu_title The title that appears on the menu.
283
- * @param string $menu_slug The slug of the page.
284
- * @param string $callback The callback to call if selected.
285
- */
286
- private function add_submenu($menu_title, $menu_slug, $callback)
287
- {
288
- add_submenu_page('lscache-settings', $menu_title, $menu_title, 'manage_options', $menu_slug, array($this, $callback)) ;
289
- }
290
-
291
- /**
292
- * Register the stylesheets for the admin area.
293
- *
294
- * @since 1.0.14
295
- * @access public
296
- */
297
- public function enqueue_style()
298
- {
299
- wp_enqueue_style(LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'css/litespeed.css', array(), LiteSpeed_Cache::PLUGIN_VERSION, 'all') ;
300
- }
301
-
302
- /**
303
- * Register the JavaScript for the admin area.
304
- *
305
- * @since 1.0.0
306
- * @access public
307
- */
308
- public function enqueue_scripts()
309
- {
310
- wp_register_script( LiteSpeed_Cache::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'js/litespeed-cache-admin.js', array(), LiteSpeed_Cache::PLUGIN_VERSION, false ) ;
311
-
312
- $localize_data = array() ;
313
- if ( LiteSpeed_Cache_GUI::has_whm_msg() ) {
314
- $ajax_url_dismiss_whm = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_WHM, true ) ;
315
- $localize_data[ 'ajax_url_dismiss_whm' ] = $ajax_url_dismiss_whm ;
316
- }
317
-
318
- if ( LiteSpeed_Cache_GUI::has_msg_ruleconflict() ) {
319
- $ajax_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_EXPIRESDEFAULT, true ) ;
320
- $localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
321
- }
322
-
323
- $promo_tag = LiteSpeed_Cache_GUI::get_instance()->show_promo( true ) ;
324
- if ( $promo_tag ) {
325
- $ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true, null, array( 'promo_tag' => $promo_tag ) ) ;
326
- $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
327
- }
328
-
329
- if ( $localize_data ) {
330
- wp_localize_script(LiteSpeed_Cache::PLUGIN_NAME, 'litespeed_data', $localize_data ) ;
331
- }
332
-
333
- wp_enqueue_script( LiteSpeed_Cache::PLUGIN_NAME ) ;
334
- }
335
-
336
- /**
337
- * Callback that adds LiteSpeed Cache's action links.
338
- *
339
- * @since 1.0.0
340
- * @access public
341
- * @param array $links Previously added links from other plugins.
342
- * @return array Links array with the litespeed cache one appended.
343
- */
344
- public function add_plugin_links($links)
345
- {
346
- //$links[] = '<a href="' . admin_url('admin.php?page=litespeedcache') .'">Settings</a>';
347
- $links[] = '<a href="' . admin_url('options-general.php?page=litespeedcache') . '">' . __('Settings', 'litespeed-cache') . '</a>' ;
348
-
349
- return $links ;
350
- }
351
-
352
- /**
353
- * Add text to recommend updating upon update success.
354
- *
355
- * @since 1.0.8.1
356
- * @access public
357
- * @param string $translations
358
- * @param string $text
359
- * @return string
360
- */
361
- public function add_update_text($translations, $text)
362
- {
363
- if ( $text !== 'Updated!' ) {
364
- return $translations ;
365
- }
366
-
367
- return $translations . ' ' . __('It is recommended that LiteSpeed Cache be purged after updating a plugin.', 'litespeed-cache') ;
368
- }
369
-
370
- /**
371
- * Add the filter to update plugin update text.
372
- *
373
- * @since 1.0.8.1
374
- * @access public
375
- */
376
- public function set_update_text()
377
- {
378
- add_filter('gettext', array($this, 'add_update_text'), 10, 2) ;
379
- }
380
-
381
- /**
382
- * Remove the filter to update plugin update text.
383
- *
384
- * @since 1.0.8.1
385
- * @access public
386
- */
387
- public function unset_update_text()
388
- {
389
- remove_filter('gettext', array($this, 'add_update_text')) ;
390
- }
391
-
392
- /**
393
- * Change the admin footer text on LiteSpeed Cache admin pages.
394
- *
395
- * @since 1.0.13
396
- * @param string $footer_text
397
- * @return string
398
- */
399
- public function admin_footer_text($footer_text)
400
- {
401
- require_once LSCWP_DIR . 'admin/tpl/inc/admin_footer.php' ;
402
-
403
- return $footer_text ;
404
- }
405
-
406
- /**
407
- * Whether to disable all settings or not.
408
- *
409
- * Currently used for 'use primary subsite settings'
410
- *
411
- * @since 1.0.13
412
- * @access public
413
- * @return bool True to disable all settings, false otherwise.
414
- */
415
- public function get_disable_all()
416
- {
417
- return $this->disable_all ;
418
- }
419
-
420
- /**
421
- * Set to disable all settings.
422
- *
423
- * @since 1.0.13
424
- * @access public
425
- */
426
- public function set_disable_all()
427
- {
428
- $this->disable_all = true ;
429
- }
430
-
431
- /**
432
- * If show compatibility tab in settings
433
- * @since 1.1.0
434
- * @return bool True if shows
435
- */
436
- public function show_compatibility_tab()
437
- {
438
- return function_exists('the_views') ;
439
- }
440
-
441
- /**
442
- * Displays the help tab in the admin pages.
443
- *
444
- * @since 1.0.0
445
- * @access public
446
- */
447
- public function add_help_tabs()
448
- {
449
- require_once LSCWP_DIR . 'admin/tpl/inc/help_tabs.php' ;
450
- }
451
-
452
- /**
453
- * Builds the html for a single notice.
454
- *
455
- * @since 1.0.7
456
- * @access public
457
- * @param string $color The color to use for the notice.
458
- * @param string $str The notice message.
459
- * @return string The built notice html.
460
- */
461
- public static function build_notice($color, $str)
462
- {
463
- return '<div class="' . $color . ' is-dismissible"><p>'. $str . '</p></div>' ;
464
- }
465
-
466
- /**
467
- * Get the error description
468
- *
469
- * @since 1.1.0
470
- * @param init $err_code
471
- * @param mixed $args
472
- * @return mixed String or false
473
- */
474
- public static function get_error($err_code, $args = null)
475
- {
476
- $error = LiteSpeed_Cache_Admin_Error::get_instance()->convert_code_to_error($err_code) ;
477
- if ( empty($error) ) {
478
- return false ;
479
- }
480
- $error = 'ERROR ' . $err_code . ': ' . $error ;
481
- if ( ! is_null($args) ) {
482
- if ( is_array($args) ) {
483
- $error = vsprintf($error, $args) ;
484
- }
485
- else {
486
- $error = sprintf($error, $args) ;
487
- }
488
- }
489
- return $error ;
490
- }
491
-
492
- /**
493
- * Adds an error to the admin notice system.
494
- *
495
- * This function will get the error message by error code and arguments
496
- * and append it to the list of outgoing errors.
497
- *
498
- * @access public
499
- * @since 1.1.0
500
- * @param int $err_code The error code to retrieve.
501
- * @param mixed $args Null if no arguments, an array if multiple arguments,
502
- * else a single argument.
503
- */
504
- public static function add_error($err_code, $args = null)
505
- {
506
- $error = self::get_error($err_code, $args) ;
507
- if( ! $error ) {
508
- return false ;
509
- }
510
- self::add_notice(self::NOTICE_RED, $error) ;
511
- }
512
-
513
- /**
514
- * Display info notice
515
- *
516
- * @since 1.6.5
517
- * @access public
518
- */
519
- public static function info( $msg )
520
- {
521
- self::add_notice( self::NOTICE_BLUE, $msg ) ;
522
- }
523
-
524
- /**
525
- * Display note notice
526
- *
527
- * @since 1.6.5
528
- * @access public
529
- */
530
- public static function note( $msg )
531
- {
532
- self::add_notice( self::NOTICE_YELLOW, $msg ) ;
533
- }
534
-
535
- /**
536
- * Display success notice
537
- *
538
- * @since 1.6
539
- * @access public
540
- */
541
- public static function succeed( $msg )
542
- {
543
- self::add_notice( self::NOTICE_GREEN, $msg ) ;
544
- }
545
-
546
- /**
547
- * Display error notice
548
- *
549
- * @since 1.6
550
- * @access public
551
- */
552
- public static function error( $msg )
553
- {
554
- self::add_notice( self::NOTICE_RED, $msg ) ;
555
- }
556
-
557
- /**
558
- * Adds a notice to display on the admin page. Multiple messages of the
559
- * same color may be added in a single call. If the list is empty, this
560
- * method will add the action to display notices.
561
- *
562
- * @since 1.0.7
563
- * @access public
564
- * @param string $color One of the available constants provided by this
565
- * class.
566
- * @param mixed $msg May be a string for a single message or an array for
567
- * multiple.
568
- */
569
- public static function add_notice($color, $msg)
570
- {
571
- // Bypass adding for CLI or cron
572
- if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
573
- // WP CLI will show the info directly
574
- if ( defined( 'WP_CLI' ) && WP_CLI ) {
575
- $msg = strip_tags( $msg ) ;
576
- if ( $color == self::NOTICE_RED ) {
577
- WP_CLI::error( $msg ) ;
578
- }
579
- else {
580
- WP_CLI::success( $msg ) ;
581
- }
582
- }
583
- return ;
584
- }
585
-
586
- $messages = (array)get_option( self::LITESPEED_MSG ) ;
587
- if( ! $messages ) {
588
- $messages = array() ;
589
- }
590
- if ( is_array($msg) ) {
591
- foreach ($msg as $str) {
592
- $messages[] = self::build_notice($color, $str) ;
593
- }
594
- }
595
- else {
596
- $messages[] = self::build_notice($color, $msg) ;
597
- }
598
- update_option( self::LITESPEED_MSG, $messages ) ;
599
- }
600
-
601
- /**
602
- * Display notices and errors in dashboard
603
- *
604
- * @since 1.1.0
605
- * @access public
606
- */
607
- public function display_messages()
608
- {
609
- // One time msg
610
- $messages = get_option( self::LITESPEED_MSG ) ;
611
- if( is_array($messages) ) {
612
- $messages = array_unique($messages) ;
613
-
614
- $added_thickbox = false ;
615
- foreach ($messages as $msg) {
616
- // Added for popup links
617
- if ( strpos( $msg, 'TB_iframe' ) && ! $added_thickbox ) {
618
- add_thickbox();
619
- $added_thickbox = true ;
620
- }
621
- echo $msg ;
622
- }
623
- }
624
- delete_option( self::LITESPEED_MSG ) ;
625
-
626
- if( empty($_GET['page']) || (substr($_GET['page'], 0, 8) !== 'lscache-' && $_GET['page'] !== 'litespeedcache') ) {
627
- global $pagenow;
628
- if ( $pagenow != 'plugins.php' ) { // && $pagenow != 'index.php'
629
- return;
630
- }
631
- }
632
-
633
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_NEWS ) ) {
634
- return;
635
- }
636
-
637
- /**
638
- * Check promo msg first
639
- * @since 2.9
640
- */
641
- LiteSpeed_Cache_GUI::get_instance()->show_promo() ;
642
-
643
- // Show version news
644
- $this->_show_recommended();
645
- }
646
-
647
- /**
648
- * Hooked to the in_widget_form action.
649
- * Appends LiteSpeed Cache settings to the widget edit settings screen.
650
- * This will append the esi on/off selector and ttl text.
651
- *
652
- * @access public
653
- * @since 1.1.0
654
- * @param type $widget
655
- * @param type $return
656
- * @param type $instance
657
- */
658
- public function show_widget_edit($widget, $return, $instance)
659
- {
660
- require LSCWP_DIR . 'admin/tpl/esi_widget_edit.php' ;
661
- }
662
-
663
- /**
664
- * Displays the cache management page.
665
- *
666
- * @since 1.0.0
667
- * @access public
668
- */
669
- public function show_menu_manage()
670
- {
671
- require_once LSCWP_DIR . 'admin/tpl/manage.php' ;
672
- }
673
-
674
- /**
675
- * Outputs the LiteSpeed Cache settings page.
676
- *
677
- * @since 1.0.0
678
- * @access public
679
- */
680
- public function show_menu_settings()
681
- {
682
- if ( is_network_admin() ) {
683
- require_once LSCWP_DIR . 'admin/tpl/network_settings.php' ;
684
- }
685
- else {
686
- if ( $_GET['page'] != 'litespeedcache' ) {// ls settings msg need to display manually
687
- settings_errors() ;
688
- }
689
- require_once LSCWP_DIR . 'admin/tpl/settings.php' ;
690
- }
691
- }
692
-
693
- /**
694
- * Displays the edit_htaccess admin page.
695
- *
696
- * This function will try to load the .htaccess file contents.
697
- * If it fails, it will echo the error message.
698
- *
699
- * @since 1.0.4
700
- * @access public
701
- */
702
- public function show_menu_edit_htaccess()
703
- {
704
- require_once LSCWP_DIR . 'admin/tpl/edit_htaccess.php' ;
705
- }
706
-
707
- /**
708
- * Outputs the html for the Environment Report page.
709
- *
710
- * @since 1.0.12
711
- * @access public
712
- */
713
- public function show_report()
714
- {
715
- require_once LSCWP_DIR . 'admin/tpl/report.php' ;
716
- }
717
-
718
- /**
719
- * Outputs the html for the Import/Export page.
720
- *
721
- * @since 1.8.2
722
- * @access public
723
- */
724
- public function show_import_export()
725
- {
726
- require_once LSCWP_DIR . 'admin/tpl/import_export.php' ;
727
- }
728
-
729
- /**
730
- * Outputs the crawler operation page.
731
- *
732
- * @since 1.1.0
733
- * @access public
734
- */
735
- public function show_crawler()
736
- {
737
- require_once LSCWP_DIR . 'admin/tpl/crawler.php' ;
738
- }
739
-
740
- /**
741
- * Outputs the optimization operation page.
742
- *
743
- * @since 1.6
744
- * @access public
745
- */
746
- public function show_optimization()
747
- {
748
- require_once LSCWP_DIR . 'admin/tpl/image_optimization.php' ;
749
- }
750
-
751
- /**
752
- * Outputs the debug log.
753
- *
754
- * @since 1.1.5
755
- * @access public
756
- */
757
- public function show_debug_log()
758
- {
759
- require_once LSCWP_DIR . 'admin/tpl/debug_log.php' ;
760
- }
761
-
762
- /**
763
- * Outputs a notice to the admin panel when the plugin is installed
764
- * via the WHM plugin.
765
- *
766
- * @since 1.0.12
767
- * @access public
768
- */
769
- public function show_display_installed()
770
- {
771
- require_once LSCWP_DIR . 'admin/tpl/inc/show_display_installed.php' ;
772
- }
773
-
774
- /**
775
- * Display error cookie msg.
776
- *
777
- * @since 1.0.12
778
- * @access public
779
- */
780
- public static function show_error_cookie()
781
- {
782
- require_once LSCWP_DIR . 'admin/tpl/inc/show_error_cookie.php' ;
783
- }
784
-
785
- /**
786
- * Display warning if lscache is disabled
787
- *
788
- * @since 2.1
789
- * @access public
790
- */
791
- public function cache_disabled_warning()
792
- {
793
- include LSCWP_DIR . "admin/tpl/inc/check_cache_disabled.php" ;
794
- }
795
-
796
- /**
797
- * Build a textarea
798
- *
799
- * @since 1.1.0
800
- * @since 1.7 Changed cols param order to be the 2nd from 4th
801
- * @access public
802
- * @param string $id
803
- * @param string $val Value of input
804
- * @param boolean $disabled If this input is disabled or not
805
- * @param int $cols The width of textarea
806
- */
807
- public function build_textarea( $id, $cols = false, $val = null, $disabled = false, $cls = '' )
808
- {
809
- if ( strpos( $id, '[' ) === false ) {
810
- if ( $val === null ) {
811
- global $_options ;
812
- $val = $_options[$id] ;
813
- }
814
-
815
- $id = "[$id]" ;
816
- }
817
-
818
- $disabled = $disabled ? ' disabled ' : '' ;
819
-
820
- if ( ! $cols ) {
821
- $cols = 80 ;
822
- }
823
-
824
- if ( $cls ) {
825
- $cls = " class='$cls' " ;
826
- }
827
-
828
- echo "<textarea name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' rows='5' cols='$cols' $cls $disabled>" . esc_textarea($val) . "</textarea>" ;
829
- }
830
-
831
- /**
832
- * Build a textarea based on separate stored option data
833
- *
834
- * @since 1.5
835
- * @since 1.7 Changed cols param order to be the 2nd from 4th
836
- * @access public
837
- * @param string $id
838
- * @param int $cols The width of textarea
839
- */
840
- public function build_textarea2( $id, $cols = false )
841
- {
842
- // Get default val for separate item
843
- $val = $this->config->get_item( $id, true ) ;
844
-
845
- $this->build_textarea( $id, $cols, $val, false, 'litespeed-textarea-success' ) ;
846
- }
847
-
848
- /**
849
- * Build a text input field
850
- *
851
- * @since 1.1.0
852
- * @since 1.7 Added [] check and wrapper to $id, moved $readonly/$id_attr
853
- * @access public
854
- * @param string $id
855
- * @param string $style Appending styles
856
- * @param boolean $readonly If is readonly
857
- * @param string $id_attr ID for this field
858
- * @param string $val Field value
859
- * @param string $attrs Additional attributes
860
- * @param string $type Input type
861
- */
862
- public function build_input( $id, $style = false, $val = null, $id_attr = null, $attrs = '', $type = 'text', $readonly = false )
863
- {
864
- if ( strpos( $id, '[' ) === false ) {
865
- if ( $val === null ) {
866
- global $_options ;
867
- $val = $_options[ $id ] ;
868
- }
869
-
870
- $id = "[$id]" ;
871
- }
872
-
873
- $readonly = $readonly ? ' readonly ' : '' ;
874
- if ( $id_attr !== null ) {
875
- $id_attr = " id='$id_attr' " ;
876
- }
877
-
878
- if ( $type == 'text' ) {
879
- $style = "litespeed-regular-text $style" ;
880
- }
881
-
882
- echo "<input type='$type' class='$style' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' value='" . esc_textarea( $val ) ."' $readonly $id_attr $attrs /> " ;
883
- }
884
-
885
- /**
886
- * Build a checkbox html snippet
887
- *
888
- * @since 1.1.0
889
- * @access public
890
- * @param string $id
891
- * @param string $title
892
- * @param bool $checked
893
- */
894
- public function build_checkbox($id, $title, $checked, $value = 1 )
895
- {
896
- $checked = $checked ? ' checked ' : '' ;
897
-
898
- $label_id = str_replace( array( '[', ']' ), '_', $id ) ;
899
-
900
- if ( $value !== 1 ) {
901
- $label_id .= '_' . $value ;
902
- }
903
-
904
- echo "<div class='litespeed-tick'>
905
- <label for='conf_$label_id'>$title</label>
906
- <input type='checkbox' name='" . LiteSpeed_Cache_Config::OPTION_NAME . "[$id]' id='conf_$label_id' value='$value' $checked />
907
- </div>" ;
908
- }
909
-
910
- /**
911
- * Build a toggle checkbox html snippet
912
- *
913
- * @since 1.7
914
- */
915
- public function build_toggle( $id, $checked = null, $title_on = null, $title_off = null )
916
- {
917
- if ( strpos( $id, '[' ) === false ) {
918
- if ( $checked === null ) {
919
- global $_options ;
920
- $to_be_checked = null ;
921
- if ( isset( $_options[ $id ] ) ) {
922
- $to_be_checked = $_options[ $id ] ;
923
- }
924
- $checked = $to_be_checked ? true : false ;
925
- }
926
- $id = "[$id]" ;
927
- }
928
- $checked = $checked ? 1 : 0 ;
929
-
930
- if ( $title_on === null ) {
931
- $title_on = __( 'ON', 'litespeed-cache' ) ;
932
- $title_off = __( 'OFF', 'litespeed-cache' ) ;
933
- }
934
-
935
- if ( $checked ) {
936
- $cls = 'primary' ;
937
- }
938
- else {
939
- $cls = 'default litespeed-toggleoff' ;
940
- }
941
-
942
- echo "<div class='litespeed-toggle litespeed-toggle-btn litespeed-toggle-btn-$cls' data-litespeed-toggle-on='primary' data-litespeed-toggle-off='default'>
943
- <input name='" . LiteSpeed_Cache_Config::OPTION_NAME . "$id' type='hidden' value='$checked' />
944
- <div class='litespeed-toggle-group'>
945
- <label class='litespeed-toggle-btn litespeed-toggle-btn-primary litespeed-toggle-on'>$title_on</label>
946
- <label class='litespeed-toggle-btn litespeed-toggle-btn-default litespeed-toggle-active litespeed-toggle-off'>$title_off</label>
947
- <span class='litespeed-toggle-handle litespeed-toggle-btn litespeed-toggle-btn-default'></span>
948
- </div>
949
- </div>" ;
950
- }
951
-
952
- /**
953
- * Build a switch div html snippet
954
- *
955
- * @since 1.1.0
956
- * @since 1.7 removed param $disable
957
- * @access public
958
- * @param string $id
959
- * @param boolean $return Return the html or echo it
960
- * @param boolean $checked If the value is on
961
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
962
- */
963
- public function build_switch($id, $checked = null, $return = false, $id_attr = null)
964
- {
965
- $id_attr_on = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_ON ;
966
- $id_attr_off = $id_attr === null ? null : $id_attr . '_' . LiteSpeed_Cache_Config::VAL_OFF ;
967
- $html = '<div class="litespeed-switch">' ;
968
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_OFF, null, $checked === null ? null : !$checked, $id_attr_off) ;
969
- $html .= $this->build_radio($id, LiteSpeed_Cache_Config::VAL_ON, null, $checked, $id_attr_on) ;
970
- $html .= '</div>' ;
971
-
972
- if ( $return ) {
973
- return $html ;
974
- }
975
- else {
976
- echo $html ;
977
- }
978
- }
979
-
980
- /**
981
- * Build a radio input html codes and output
982
- *
983
- * @since 1.1.0
984
- * @access public
985
- * @param string $id
986
- * @param string $val Default value of this input
987
- * @param string $txt Title of this input
988
- * @param bool $checked If checked or not
989
- * @param string $id_attr ID for this field, set to true if want to use a not specified unique value
990
- */
991
- public function build_radio($id, $val, $txt = null, $checked = null, $id_attr = null)
992
- {
993
- if ( strpos( $id, '[' ) === false ) {
994
- if ( $checked === null ) {
995
- global $_options ;
996
- $to_be_checked = null ;
997
- if ( isset( $_options[ $id ] ) ) {
998
- $to_be_checked = is_int( $val ) ? (int)$_options[ $id ] : $_options[ $id ] ;
999
- }
1000
-
1001
- $checked = $to_be_checked === $val ? true : false ;
1002
- }
1003
-
1004
- $id = "[$id]" ;
1005
- }
1006
-
1007
- if ( $id_attr === null ) {
1008
- $id_attr = is_int($val) ? "conf_" . str_replace( array( '[', ']' ), '_', $id ) . "_$val" : md5($val) ;
1009
- }
1010
- elseif ( $id_attr === true ) {
1011
- $id_attr = md5($val) ;
1012
- }
1013
-
1014
- if ( $txt === null ){
1015
- if ( $val === LiteSpeed_Cache_Config::VAL_ON ){
1016
- $txt = __( 'ON', 'litespeed-cache' ) ;
1017
- }
1018
-
1019
- if ( $val === LiteSpeed_Cache_Config::VAL_OFF ){
1020
- $txt = __( 'OFF', 'litespeed-cache' ) ;
1021
- }
1022
- }
1023
-
1024
- $checked = $checked ? ' checked ' : '' ;
1025
-
1026
- return "<input type='radio' autocomplete='off' name='". LiteSpeed_Cache_Config::OPTION_NAME . "$id' id='$id_attr' value='$val' $checked /> <label for='$id_attr'>$txt</label>" ;
1027
- }
1028
-
1029
- /**
1030
- * Display default value
1031
- *
1032
- * @since 1.1.1
1033
- * @access public
1034
- * @param string $id The setting tag
1035
- */
1036
- public function recommended( $id, $is_item = false )
1037
- {
1038
- $val = '' ;
1039
- if ( ! $is_item ) {
1040
- if ( isset( $this->default_settings[ $id ] ) ) {
1041
- $val = $this->default_settings[ $id ] ;
1042
- }
1043
- }
1044
- else {
1045
- $val = $this->config->default_item( $id ) ;
1046
- }
1047
-
1048
- if ( $val ) {
1049
- if ( ! is_numeric( $val ) && strpos( $val, "\n" ) !== false ) {
1050
- $val = "<textarea readonly rows='5' class='litespeed-left10'>$val</textarea>" ;
1051
- }
1052
- else {
1053
- $val = "<code>$val</code>" ;
1054
- }
1055
- echo sprintf( __( 'Recommended value: %s', 'litespeed-cache' ), $val ) ;
1056
- }
1057
- }
1058
-
1059
- /**
1060
- * Display API environment variable support
1061
- *
1062
- * @since 1.8.3
1063
- * @access private
1064
- */
1065
- private function _api_env_var()
1066
- {
1067
- $args = func_get_args() ;
1068
- $s = '<code>' . implode( '</code>, <code>', $args ) . '</code>' ;
1069
-
1070
- echo '<font class="litespeed-success"> '
1071
- . __( 'API', 'litespeed-cache' ) . ': '
1072
- . sprintf( __( 'Server variable(s) %s available to override this setting.', 'litespeed-cache' ), $s ) ;
1073
-
1074
- $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:server_variables' ) ;
1075
- }
1076
-
1077
- /**
1078
- * Display learn more link
1079
- *
1080
- * @since 2.6.1
1081
- * @access public
1082
- */
1083
- public function learn_more( $link, $title = false, $class = false )
1084
- {
1085
- if ( $class ) {
1086
- $class = " class='$class' " ;
1087
- }
1088
-
1089
- if ( ! $title ) {
1090
- $title = __( 'Learn More', 'litespeed-cache' ) ;
1091
- }
1092
-
1093
- echo " <a href='$link' target='_blank' $class>$title</a>" ;
1094
- }
1095
-
1096
- /**
1097
- * Display URI setting example
1098
- *
1099
- * @since 2.6.1
1100
- * @access private
1101
- */
1102
- private function _uri_usage_example()
1103
- {
1104
- echo __( 'The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache' ) ;
1105
- echo ' ' . sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ;
1106
- echo '<br /><i>' ;
1107
- echo sprintf( __( 'To match the beginning, add %s to the beginning of the item.', 'litespeed-cache' ), '<code>^</code>' ) ;
1108
- echo ' ' . sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ;
1109
- echo ' ' . __( 'One per line.', 'litespeed-cache' ) ;
1110
- echo '</i>' ;
1111
- }
1112
-
1113
- /**
1114
- * Return groups string
1115
- *
1116
- * @since 2.0
1117
- * @access public
1118
- */
1119
- public static function print_plural( $num, $kind = 'group' )
1120
- {
1121
- if ( $num > 1 ) {
1122
- switch ( $kind ) {
1123
- case 'group' :
1124
- return sprintf( __( '%s groups', 'litespeed-cache' ), $num ) ;
1125
-
1126
- case 'image' :
1127
- return sprintf( __( '%s images', 'litespeed-cache' ), $num ) ;
1128
-
1129
- default:
1130
- return $num ;
1131
- }
1132
-
1133
- }
1134
-
1135
- switch ( $kind ) {
1136
- case 'group' :
1137
- return sprintf( __( '%s group', 'litespeed-cache' ), $num ) ;
1138
-
1139
- case 'image' :
1140
- return sprintf( __( '%s image', 'litespeed-cache' ), $num ) ;
1141
-
1142
- default:
1143
- return $num ;
1144
- }
1145
- }
1146
-
1147
- /**
1148
- * Return guidance html
1149
- *
1150
- * @since 2.0
1151
- * @access public
1152
- */
1153
- public static function guidance( $title, $steps, $current_step )
1154
- {
1155
- if ( $current_step === 'done' ) {
1156
- $current_step = count( $steps ) + 1 ;
1157
- }
1158
-
1159
- $percentage = ' (' . floor( ( $current_step - 1 ) * 100 / count( $steps ) ) . '%)' ;
1160
-
1161
- $html = '<div class="litespeed-guide">'
1162
- . '<h2>' . $title . $percentage . '</h2>'
1163
- . '<ol>' ;
1164
- foreach ( $steps as $k => $v ) {
1165
- $step = $k + 1 ;
1166
- if ( $current_step > $step ) {
1167
- $html .= '<li class="litespeed-guide-done">' ;
1168
- }
1169
- else {
1170
- $html .= '<li>' ;
1171
- }
1172
- $html .= $v . '</li>' ;
1173
- }
1174
-
1175
- $html .= '</ol></div>' ;
1176
-
1177
- return $html ;
1178
- }
1179
-
1180
- /**
1181
- * Get the current instance object.
1182
- *
1183
- * @since 1.1.0
1184
- * @access public
1185
- * @return Current class instance.
1186
- */
1187
- public static function get_instance()
1188
- {
1189
- if ( ! isset(self::$_instance) ) {
1190
- self::$_instance = new self() ;
1191
- }
1192
-
1193
- return self::$_instance ;
1194
- }
1195
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-error.class.php DELETED
@@ -1,249 +0,0 @@
1
- <?php
2
- /**
3
- * The admin errors
4
- *
5
- *
6
- * @since 1.0.15
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Error
17
- {
18
- private static $_instance ;
19
-
20
- const NOTICE_BLUE = 'notice notice-info' ;
21
- const NOTICE_GREEN = 'notice notice-success' ;
22
- const NOTICE_RED = 'notice notice-error' ;
23
- const NOTICE_YELLOW = 'notice notice-warning' ;
24
- const E_PHP_VER = 1000 ;
25
- const E_WP_VER = 1010 ;
26
-
27
- const E_PURGE_FORM = 2000 ;
28
- const E_PURGEBY_EMPTY = 2010 ;
29
- const E_PURGEBY_BAD = 2020 ;
30
- const E_PURGEBY_CAT_INV = 2030 ;
31
- const E_PURGEBY_TAG_INV = 2040 ;
32
- const E_PURGEBY_URL_BAD = 2050 ;
33
-
34
- const E_PURGEBY_PID_NUM = 2500 ;
35
- const E_PURGEBY_PID_DNE = 2510 ;
36
- const E_PURGEBY_URL_INV = 2520 ;
37
- const E_PURGEBY_CAT_DNE = 2530 ;
38
- const E_PURGEBY_TAG_DNE = 2540 ;
39
-
40
- const E_SETTING_ADMIN_IP_INV = 3000 ;
41
- const E_SETTING_TEST_IP_INV = 3010 ;
42
- const E_SETTING_SITE_IP = 3020 ;
43
- const E_SETTING_CUSTOM_SITEMAP_READ = 3030 ;
44
- const E_SETTING_CUSTOM_SITEMAP_PARSE = 3031 ;
45
-
46
- const E_SETTING_CAT = 3510 ;
47
- const E_SETTING_TAG = 3520 ;
48
- const E_SETTING_LC = 3530 ; // login cookie setting
49
- const E_SETTING_REWRITE = 3540 ;
50
-
51
- const E_LC_HTA = 4000 ; // login cookie .htaccess not correct
52
-
53
- const E_HTA_DNF = 4500 ; // .htaccess did not find.
54
-
55
- const E_LC_MISMATCH = 5000 ; // login cookie mismatch
56
-
57
- const E_CONF = 9000 ; // general config failed to write.
58
- const E_HTA_BU = 9010 ; // backup
59
- const E_HTA_PUT = 9020 ; // failed to put
60
- const E_HTA_GET = 9030 ; // failed to get
61
- const E_HTA_RW = 9040 ; // read write
62
- const E_HTA_R = 9041 ; // read
63
- const E_HTA_W = 9042 ; // write
64
- const E_HTA_ORDER = 9050 ; // prefix found after suffix
65
- const E_HTA_SAVE = 9060 ;
66
- const E_CONF_WRITE = 9070 ;
67
- const E_CONF_FIND = 9080 ;
68
-
69
- /**
70
- * Get the error message by code.
71
- *
72
- * @since 1.0.15
73
- * @access public
74
- * @param int $err_code The error code to retrieve.
75
- * @return string The error message if matching, else an empty string.
76
- */
77
- public function convert_code_to_error($err_code)
78
- {
79
- if ( ! is_numeric($err_code) ) {
80
- return false ;
81
- }
82
-
83
- switch ($err_code){
84
- case self::E_PHP_VER:
85
- return '<strong>'
86
- . __('The installed PHP version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
87
- . '</strong><br /> '
88
- . sprintf(__('The LiteSpeed Cache Plugin requires at least PHP %s.', 'litespeed-cache'), '5.3')
89
- . ' '
90
- . sprintf(__('The currently installed version is PHP %s, which is out-dated and insecure.', 'litespeed-cache'), PHP_VERSION)
91
- . ' '
92
- . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
93
- array('a' => array('href' => array()))), 'plugins.php?plugin_status=active') ;
94
-
95
- case self::E_WP_VER:
96
- return '<strong>'
97
- . __('The installed WordPress version is too old for the LiteSpeed Cache Plugin.', 'litespeed-cache')
98
- . '</strong><br />'
99
- . sprintf(__('The LiteSpeed Cache Plugin requires at least WordPress %s.', 'litespeed-cache'), '3.3')
100
- . ' '
101
- . sprintf(wp_kses(__('Please upgrade or go to <a href="%s">active plugins</a> and deactivate the LiteSpeed Cache plugin to hide this message.', 'litespeed-cache'),
102
- array('a' => array('href' => array()))), 'plugins.php?plugin_status=active') ;
103
-
104
- // Admin action errors.
105
- case self::E_PURGE_FORM:
106
- return __('Something went wrong with the form! Please try again.', 'litespeed-cache') ;
107
-
108
- case self::E_PURGEBY_EMPTY:
109
- return __('Tried to purge list with empty list.', 'litespeed-cache') ;
110
-
111
- case self::E_PURGEBY_BAD:
112
- return __('Bad Purge By selected value.', 'litespeed-cache') ;
113
-
114
- case self::E_PURGEBY_CAT_INV:
115
- return __('Failed to purge by category, invalid category slug.', 'litespeed-cache') ;
116
-
117
- case self::E_PURGEBY_TAG_INV:
118
- return __('Failed to purge by tag, invalid tag slug.', 'litespeed-cache') ;
119
-
120
- case self::E_PURGEBY_URL_BAD:
121
- return __('Failed to purge by url, contained "<".', 'litespeed-cache') ;
122
-
123
- // Admin actions with expected parameters for message.
124
- case self::E_PURGEBY_PID_NUM:
125
- return __('Failed to purge by Post ID, given ID is not numeric: %s', 'litespeed-cache') ;
126
-
127
- case self::E_PURGEBY_PID_DNE:
128
- return __('Failed to purge by Post ID, given ID does not exist or is not published: %s',
129
- 'litespeed-cache') ;
130
-
131
- case self::E_PURGEBY_URL_INV:
132
- return __('Failed to purge by url, invalid input: %s.', 'litespeed-cache') ;
133
-
134
- case self::E_PURGEBY_CAT_DNE:
135
- return __('Failed to purge by category, does not exist: %s', 'litespeed-cache') ;
136
-
137
- case self::E_PURGEBY_TAG_DNE:
138
- return __('Failed to purge by tag, does not exist: %s', 'litespeed-cache') ;
139
-
140
- // Admin settings errors.
141
- case self::E_SETTING_ADMIN_IP_INV:
142
- return __('Invalid data in Admin IPs.', 'litespeed-cache') ;
143
-
144
- case self::E_SETTING_TEST_IP_INV:
145
- return __('Invalid data in Test IPs.', 'litespeed-cache') ;
146
-
147
- case self::E_SETTING_SITE_IP:
148
- return __('Invalid Site IP: %s', 'litespeed-cache') ;
149
-
150
- case self::E_SETTING_CUSTOM_SITEMAP_READ:
151
- return __('Can not fetch Custom Sitemap: %s', 'litespeed-cache') ;
152
-
153
- case self::E_SETTING_CUSTOM_SITEMAP_PARSE:
154
- return __('Can not parse custom sitemap xml file: %s.', 'litespeed-cache') . ' '
155
- . sprintf(__('Please make sure the file is xml format and the %s extension is installed on the server.', 'litespeed-cache'), 'php-xml') ;
156
-
157
- case self::E_SETTING_CAT:
158
- // %s is the category attempted to be added.
159
- return __('Removed category "%s" from list, ID does not exist.',
160
- 'litespeed-cache') ;
161
-
162
- case self::E_SETTING_TAG:
163
- // %s is the tag attempted to be added.
164
- return __('Removed tag "%s" from list, ID does not exist.',
165
- 'litespeed-cache') ;
166
-
167
- case self::E_SETTING_LC:
168
- return __('Invalid login cookie. Invalid characters found: %s',
169
- 'litespeed-cache') ;
170
-
171
- case self::E_SETTING_REWRITE:
172
- return __('Invalid Rewrite List.', 'litespeed-cache') . ' '
173
- . __('Empty or invalid rule.', 'litespeed-cache') . ' '
174
- . __('Rule: %1$s, list: %2$s', 'litespeed-cache') ;
175
-
176
- // Login cookie in settings did not match .htaccess.
177
- case self::E_LC_HTA:
178
- return __('Tried to parse for existing login cookie.', 'litespeed-cache') . ' '
179
- . sprintf(__('%s file not valid. Please verify contents.', 'litespeed-cache'), '.htaccess') ;
180
-
181
- // Could not find something in the .htaccess file. Expect parameter.
182
- case self::E_HTA_DNF:
183
- return __('Could not find %s.', 'litespeed-cache') ;
184
-
185
- // Mismatched login cookie.
186
- case self::E_LC_MISMATCH:
187
- return __('This site is a subdirectory install.', 'litespeed-cache') . ' '
188
- . __('Login cookies do not match.', 'litespeed-cache') . ' '
189
- . __('Please remove both and set the login cookie in LiteSpeed Cache advanced settings.', 'litespeed-cache') ;
190
-
191
- case self::E_CONF:
192
- return __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
193
- . sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
194
-
195
- // .htaccess problem.
196
- case self::E_HTA_BU:
197
- return __('Failed to back up file, aborted changes.', 'litespeed-cache') ;
198
-
199
- case self::E_HTA_PUT:
200
- return sprintf(__('Failed to put contents into %s', 'litespeed-cache'), '.htaccess') ;
201
-
202
- case self::E_HTA_GET:
203
- return sprintf(__('Failed to get %s file contents.', 'litespeed-cache'), '.htaccess') ;
204
-
205
- case self::E_HTA_RW:
206
- return sprintf(__('%s file not readable or not writable.', 'litespeed-cache'), '.htaccess') ;
207
-
208
- case self::E_HTA_R:
209
- return sprintf(__('%s file not readable.', 'litespeed-cache'), '.htaccess') ;
210
-
211
- case self::E_HTA_W:
212
- return sprintf(__('%s file not writable.', 'litespeed-cache'), '.htaccess') ;
213
-
214
- case self::E_HTA_SAVE:
215
- return sprintf(__('Failed to overwrite %s.', 'litespeed-cache'), '.htaccess') ;
216
-
217
- // wp-config problem.
218
- case self::E_CONF_WRITE:
219
- $err = sprintf(__('The %1$s file not writable for %2$s', 'litespeed-cache'), 'wp-config', '\'WP_CACHE\'') ;
220
- break ;
221
-
222
- case self::E_CONF_FIND:
223
- $err = sprintf(__('%s file did not find a place to insert define.', 'litespeed-cache'), 'wp-config') ;
224
- break ;
225
-
226
- default:
227
- return false ;
228
- }
229
-
230
- return $err . '<br />' . __('LiteSpeed Cache was unable to write to the wp-config.php file.', 'litespeed-cache') . ' '
231
- . sprintf(__('Please add the following to the wp-config.php file: %s', 'litespeed-cache'), '<br><pre>define(\'WP_CACHE\', true);</pre>') ;
232
- }
233
-
234
- /**
235
- * Get the current instance object.
236
- *
237
- * @since 1.1.0
238
- * @access public
239
- * @return Current class instance.
240
- */
241
- public static function get_instance()
242
- {
243
- if ( ! isset(self::$_instance) ) {
244
- self::$_instance = new self() ;
245
- }
246
-
247
- return self::$_instance ;
248
- }
249
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-optimize.class.php DELETED
@@ -1,201 +0,0 @@
1
- <?php
2
- /**
3
- * The admin optimize tool
4
- *
5
- *
6
- * @since 1.2.1
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Optimize
17
- {
18
- private static $_types = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients' ) ;
19
-
20
- /**
21
- * Generate operation URL
22
- *
23
- * @since 1.2.1
24
- * @access public
25
- * @param string $type The type to proceed
26
- * @return string The final URL
27
- */
28
- public static function generate_url( $type )
29
- {
30
- $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DB_OPTIMIZE, $type ) ;
31
- return $url ;
32
- }
33
-
34
- /**
35
- * Run DB Cleaner
36
- *
37
- * @since 1.2.1
38
- * @access public
39
- */
40
- public static function run_db_clean()
41
- {
42
- if( ! $type = LiteSpeed_Cache_Router::verify_type() ) {
43
- return ;
44
- }
45
-
46
- $res = '' ;
47
-
48
- if ( is_multisite() && is_network_admin() ) {
49
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
50
- foreach ( $blogs as $blog_id ) {
51
- switch_to_blog( $blog_id ) ;
52
- $res = self::db_clean( $type ) ;
53
- restore_current_blog() ;
54
- }
55
- }
56
- else {
57
- $res = self::db_clean( $type ) ;
58
- }
59
-
60
- return $res ;
61
-
62
- }
63
-
64
- /**
65
- * Clean/Optimize WP tables
66
- *
67
- * @since 1.2.1
68
- * @access public
69
- * @param string $type The type to clean
70
- * @param bool $ignore_multisite If ignore multisite check
71
- * @return int The rows that will be affected
72
- */
73
- public static function db_count( $type, $ignore_multisite = false )
74
- {
75
- if ( $type === 'all' ) {
76
- $num = 0 ;
77
- foreach ( self::$_types as $val ) {
78
- $num += self::db_count( $val ) ;
79
- }
80
- return $num ;
81
- }
82
-
83
- if ( ! $ignore_multisite ) {
84
- if ( is_multisite() && is_network_admin() ) {
85
- $num = 0 ;
86
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
87
- foreach ( $blogs as $blog_id ) {
88
- switch_to_blog( $blog_id ) ;
89
- $num += self::db_count( $type, true ) ;
90
- restore_current_blog() ;
91
- }
92
- return $num ;
93
- }
94
- }
95
-
96
- global $wpdb ;
97
-
98
- switch ( $type ) {
99
- case 'revision':
100
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_type = 'revision'" ) ;
101
-
102
- case 'auto_draft':
103
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" ) ;
104
-
105
- case 'trash_post':
106
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->posts` WHERE post_status = 'trash'" ) ;
107
-
108
- case 'spam_comment':
109
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'spam'" ) ;
110
-
111
- case 'trash_comment':
112
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_approved = 'trash'" ) ;
113
-
114
- case 'trackback-pingback':
115
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" ) ;
116
-
117
- case 'expired_transient':
118
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() ) ;
119
-
120
- case 'all_transients':
121
- return $wpdb->get_var( "SELECT COUNT(*) FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'" ) ;
122
-
123
- case 'optimize_tables':
124
- return $wpdb->get_var( "SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" ) ;
125
-
126
- case 'all_cssjs' :
127
- return $wpdb->get_var( "SELECT COUNT(*) FROM `" . LiteSpeed_Cache_Data::get_optm_table() . "`" ) ;
128
- }
129
-
130
- return '-' ;
131
- }
132
-
133
- /**
134
- * Clean/Optimize WP tables
135
- *
136
- * @since 1.2.1
137
- * @access public
138
- * @param string $type The type to clean
139
- */
140
- public static function db_clean( $type )
141
- {
142
- if ( $type === 'all' ) {
143
- foreach ( self::$_types as $val ) {
144
- self::db_clean( $val ) ;
145
- }
146
- return __( 'Clean all successfully.', 'litespeed-cache' ) ;
147
- }
148
-
149
- global $wpdb ;
150
- switch ( $type ) {
151
- case 'revision':
152
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_type = 'revision'" ) ;
153
- return __( 'Clean post revisions successfully.', 'litespeed-cache' ) ;
154
-
155
- case 'auto_draft':
156
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'auto-draft'" ) ;
157
- return __( 'Clean auto drafts successfully.', 'litespeed-cache' ) ;
158
-
159
- case 'trash_post':
160
- $wpdb->query( "DELETE FROM `$wpdb->posts` WHERE post_status = 'trash'" ) ;
161
- return __( 'Clean trashed posts and pages successfully.', 'litespeed-cache' ) ;
162
-
163
- case 'spam_comment':
164
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'spam'" ) ;
165
- return __( 'Clean spam comments successfully.', 'litespeed-cache' ) ;
166
-
167
- case 'trash_comment':
168
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_approved = 'trash'" ) ;
169
- return __( 'Clean trashed comments successfully.', 'litespeed-cache' ) ;
170
-
171
- case 'trackback-pingback':
172
- $wpdb->query( "DELETE FROM `$wpdb->comments` WHERE comment_type = 'trackback' OR comment_type = 'pingback'" ) ;
173
- return __( 'Clean trackbacks and pingbacks successfully.', 'litespeed-cache' ) ;
174
-
175
- case 'expired_transient':
176
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '_transient_timeout%' AND option_value < " . time() ) ;
177
- return __( 'Clean expired transients successfully.', 'litespeed-cache' ) ;
178
-
179
- case 'all_transients':
180
- $wpdb->query( "DELETE FROM `$wpdb->options` WHERE option_name LIKE '%_transient_%'" ) ;
181
- return __( 'Clean all transients successfully.', 'litespeed-cache' ) ;
182
-
183
- case 'optimize_tables':
184
- $sql = "SELECT table_name, data_free FROM information_schema.tables WHERE table_schema = '" . DB_NAME . "' and Engine <> 'InnoDB' and data_free > 0" ;
185
- $result = $wpdb->get_results( $sql ) ;
186
- if ( $result ) {
187
- foreach ( $result as $row ) {
188
- $wpdb->query( 'OPTIMIZE TABLE ' . $row->table_name ) ;
189
- }
190
- }
191
- return __( 'Optimized all tables.', 'litespeed-cache' ) ;
192
-
193
- case 'all_cssjs' :
194
- LiteSpeed_Cache_Purge::purge_all() ;
195
- $wpdb->query( "TRUNCATE `" . LiteSpeed_Cache_Data::get_optm_table() . "`" ) ;
196
- return __( 'Clean all CSS/JS optimizer data successfully.', 'litespeed-cache' ) ;
197
-
198
- }
199
-
200
- }
201
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-rules.class.php DELETED
@@ -1,1050 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Rules
17
- {
18
- private static $_instance ;
19
-
20
- const EDITOR_TEXTAREA_NAME = 'lscwp_ht_editor' ;
21
-
22
- private $frontend_htaccess = null ;
23
- private $backend_htaccess = null ;
24
- private $theme_htaccess = null ;// Not used yet
25
- private $frontend_htaccess_readable = false ;
26
- private $frontend_htaccess_writable = false ;
27
- private $backend_htaccess_readable = false ;
28
- private $backend_htaccess_writable = false ;
29
- private $theme_htaccess_readable = false ;
30
- private $theme_htaccess_writable = false ;
31
-
32
- const LS_MODULE_START = '<IfModule LiteSpeed>' ;
33
- const EXPIRES_MODULE_START = '<IfModule mod_expires.c>' ;
34
- const LS_MODULE_END = '</IfModule>' ;
35
- const LS_MODULE_REWRITE_START = '<IfModule mod_rewrite.c>' ;
36
- const REWRITE_ON = 'RewriteEngine on' ;
37
- private static $LS_MODULE_REWRITE_ON ;
38
- const LS_MODULE_DONOTEDIT = "## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##" ;
39
- const MARKER = 'LSCACHE' ;
40
- const MARKER_NONLS = 'NON_LSCACHE' ;
41
- const MARKER_LOGIN_COOKIE = '### marker LOGIN COOKIE' ;
42
- const MARKER_MOBILE = '### marker MOBILE' ;
43
- const MARKER_NOCACHE_COOKIES = '### marker NOCACHE COOKIES' ;
44
- const MARKER_NOCACHE_USER_AGENTS = '### marker NOCACHE USER AGENTS' ;
45
- const MARKER_CACHE_RESOURCE = '### marker CACHE RESOURCE' ;
46
- const MARKER_FAVICON = '### marker FAVICON' ;
47
- const MARKER_BROWSER_CACHE = '### marker BROWSER CACHE' ;
48
- const MARKER_MINIFY = '### marker MINIFY' ;
49
- const MARKER_CORS = '### marker CORS' ;
50
- const MARKER_WEBP = '### marker WEBP' ;
51
- const MARKER_DROPQS = '### marker DROPQS' ;
52
- const MARKER_START = ' start ###' ;
53
- const MARKER_END = ' end ###' ;
54
-
55
- const RW_PATTERN_RES = '/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php' ;
56
-
57
- /**
58
- * Initialize the class and set its properties.
59
- *
60
- * @since 1.0.7
61
- * @access private
62
- */
63
- private function __construct()
64
- {
65
- $this->path_set() ;
66
- // Filter for frontend&backend htaccess path
67
- $this->frontend_htaccess = apply_filters( 'litespeed_frontend_htaccess', $this->frontend_htaccess ) ;
68
- $this->backend_htaccess = apply_filters( 'litespeed_backend_htaccess', $this->backend_htaccess ) ;
69
-
70
- clearstatcache() ;
71
-
72
- // frontend .htaccess privilege
73
- $test_permissions = file_exists($this->frontend_htaccess) ? $this->frontend_htaccess : dirname($this->frontend_htaccess) ;
74
- if ( is_readable($test_permissions) ) {
75
- $this->frontend_htaccess_readable = true ;
76
- }
77
- if ( is_writable($test_permissions) ) {
78
- $this->frontend_htaccess_writable = true ;
79
- }
80
-
81
- self::$LS_MODULE_REWRITE_ON = array(
82
- self::REWRITE_ON,
83
- "CacheLookup on",
84
- "RewriteRule .* - [E=Cache-Control:no-autoflush]",
85
- "RewriteRule ^min/\w+\.(css|js) - [E=cache-control:no-vary]",
86
- ) ;
87
-
88
- // backend .htaccess privilege
89
- if ( $this->frontend_htaccess === $this->backend_htaccess ) {
90
- $this->backend_htaccess_readable = $this->frontend_htaccess_readable;
91
- $this->backend_htaccess_writable = $this->frontend_htaccess_writable;
92
- }
93
- else{
94
- $test_permissions = file_exists($this->backend_htaccess) ? $this->backend_htaccess : dirname($this->backend_htaccess);
95
- if ( is_readable($test_permissions) ) {
96
- $this->backend_htaccess_readable = true;
97
- }
98
- if ( is_writable($test_permissions) ) {
99
- $this->backend_htaccess_writable = true;
100
- }
101
- }
102
- }
103
-
104
- /**
105
- * Get if htaccess file is readable
106
- *
107
- * @since 1.1.0
108
- * @return string
109
- */
110
- public static function readable($kind = 'frontend')
111
- {
112
- if( $kind === 'frontend' ) {
113
- return self::get_instance()->frontend_htaccess_readable ;
114
- }
115
- if( $kind === 'backend' ) {
116
- return self::get_instance()->backend_htaccess_readable ;
117
- }
118
- }
119
-
120
- /**
121
- * Get if htaccess file is writable
122
- *
123
- * @since 1.1.0
124
- * @return string
125
- */
126
- public static function writable($kind = 'frontend')
127
- {
128
- if( $kind === 'frontend' ) {
129
- return self::get_instance()->frontend_htaccess_writable ;
130
- }
131
- if( $kind === 'backend' ) {
132
- return self::get_instance()->backend_htaccess_writable ;
133
- }
134
- }
135
-
136
- /**
137
- * Get frontend htaccess path
138
- *
139
- * @since 1.1.0
140
- * @return string
141
- */
142
- public static function get_frontend_htaccess()
143
- {
144
- return self::get_instance()->frontend_htaccess ;
145
- }
146
-
147
- /**
148
- * Get backend htaccess path
149
- *
150
- * @since 1.1.0
151
- * @return string
152
- */
153
- public static function get_backend_htaccess()
154
- {
155
- return self::get_instance()->backend_htaccess ;
156
- }
157
-
158
- /**
159
- * Check to see if .htaccess exists starting at $start_path and going up directories until it hits DOCUMENT_ROOT.
160
- *
161
- * As dirname() strips the ending '/', paths passed in must exclude the final '/'
162
- *
163
- * If can't find, return false
164
- *
165
- * @since 1.0.11
166
- * @access private
167
- * @param string $start_path The first directory level to search.
168
- * @return string The deepest path where .htaccess exists, False if not.
169
- */
170
- private function htaccess_search( $start_path )
171
- {
172
- while ( ! file_exists( $start_path . '/.htaccess' ) ) {
173
- if ( $start_path === '/' || ! $start_path ) {
174
- return false ;
175
- }
176
- if ( ! empty( $_SERVER[ 'DOCUMENT_ROOT' ] ) && $start_path === $_SERVER[ 'DOCUMENT_ROOT' ] ) {
177
- return false ;
178
- }
179
- $start_path = dirname( $start_path ) ;
180
- }
181
-
182
- return $start_path ;
183
- }
184
-
185
- /**
186
- * Set the path class variables.
187
- *
188
- * @since 1.0.11
189
- * @access private
190
- */
191
- private function path_set()
192
- {
193
- $frontend = LiteSpeed_Cache_Router::frontend_path() ;
194
- $frontend_htaccess_search = $this->htaccess_search( $frontend ) ;// The existing .htaccess path to be used for frontend .htaccess
195
- $this->frontend_htaccess = ( $frontend_htaccess_search ?: $frontend ) . '/.htaccess' ;
196
-
197
- $backend = realpath( ABSPATH ) ; // /home/user/public_html/backend/
198
- if ( $frontend == $backend ) {
199
- $this->backend_htaccess = $this->frontend_htaccess ;
200
- return ;
201
- }
202
-
203
- // Backend is a different path
204
- $backend_htaccess_search = $this->htaccess_search( $backend ) ;
205
- // Found affected .htaccess
206
- if ( $backend_htaccess_search ) {
207
- $this->backend_htaccess = $backend_htaccess_search . '/.htaccess' ;
208
- return ;
209
- }
210
-
211
- // Frontend path is the parent of backend path
212
- if ( stripos( $backend, $frontend . '/' ) === 0 ) {
213
- // backend use frontend htaccess
214
- $this->backend_htaccess = $this->frontend_htaccess ;
215
- return ;
216
- }
217
-
218
- $this->backend_htaccess = $backend . '/.htaccess' ;
219
- }
220
-
221
- /**
222
- * Get corresponding htaccess path
223
- *
224
- * @since 1.1.0
225
- * @param string $kind Frontend or backend
226
- * @return string Path
227
- */
228
- public function htaccess_path($kind = 'frontend')
229
- {
230
- switch ( $kind ) {
231
- case 'frontend':
232
- $path = $this->frontend_htaccess ;
233
- break ;
234
-
235
- case 'backend':
236
- $path = $this->backend_htaccess ;
237
- break ;
238
-
239
- default:
240
- $path = $this->frontend_htaccess ;
241
- break ;
242
- }
243
- return $path ;
244
- }
245
-
246
- /**
247
- * Get the content of the rules file.
248
- * If can't read, will add error msg to dashboard
249
- * Only when need to add error msg, this function is used, otherwise use file_get_contents directly
250
- *
251
- * @since 1.0.4
252
- * @since 2.9 Used exception for failed reading
253
- * @access public
254
- * @param string $path The path to get the content from.
255
- * @return boolean True if succeeded, false otherwise.
256
- */
257
- public function htaccess_read($kind = 'frontend')
258
- {
259
- $path = $this->htaccess_path($kind) ;
260
-
261
- if( ! $path || ! file_exists($path) ) {
262
- return "\n" ;
263
- }
264
- if ( ! self::readable($kind) || ! self::writable($kind) ) {
265
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_RW ) ) ;
266
- }
267
-
268
- $content = file_get_contents($path) ;
269
- if ( $content === false ) {
270
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_GET ) ) ;
271
- }
272
-
273
- // Remove ^M characters.
274
- $content = str_ireplace("\x0D", "", $content) ;
275
- return $content ;
276
- }
277
-
278
- /**
279
- * Try to save the rules file changes.
280
- *
281
- * This function is used by both the edit .htaccess admin page and
282
- * the common rewrite rule configuration options.
283
- *
284
- * This function will create a backup with _lscachebak appended to the file name
285
- * prior to making any changese. If creating the backup fails, an error is returned.
286
- *
287
- * @since 1.0.4
288
- * @since 1.0.12 - Introduce $backup parameter and make function public
289
- * @access public
290
- * @param string $content The new content to put into the rules file.
291
- * @param string $kind The htaccess to edit. Default is frontend htaccess file.
292
- * @param boolean $backup Whether to create backups or not.
293
- * @return boolean true on success, else false.
294
- */
295
- public function htaccess_save($content, $kind = 'frontend', $backup = true)
296
- {
297
- $path = $this->htaccess_path($kind) ;
298
-
299
- if ( ! self::readable($kind) ) {
300
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ) ;
301
- }
302
-
303
- if ( ! self::writable($kind) ) {
304
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ) ) ;
305
- }
306
-
307
- //failed to backup, not good.
308
- if ( $backup && $this->htaccess_backup($kind) === false ) {
309
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_BU ) ) ;
310
- }
311
-
312
- // File put contents will truncate by default. Will create file if doesn't exist.
313
- $ret = file_put_contents($path, $content, LOCK_EX) ;
314
- if ( $ret === false ) {
315
- throw new Exception( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_SAVE ) ) ;
316
- }
317
- }
318
-
319
- /**
320
- * Try to backup the .htaccess file.
321
- * This function will attempt to create a .htaccess_lscachebak_orig first.
322
- * If that is already created, it will attempt to create .htaccess_lscachebak_[1-10]
323
- * If 10 are already created, zip the current set of backups (sans _orig).
324
- * If a zip already exists, overwrite it.
325
- *
326
- * @since 1.0.10
327
- * @access private
328
- * @param string $kind The htaccess to edit. Default is frontend htaccess file.
329
- * @return boolean True on success, else false on failure.
330
- */
331
- private function htaccess_backup($kind = 'frontend')
332
- {
333
- $path = $this->htaccess_path($kind) ;
334
- $bak = '_lscachebak_orig' ;
335
- $i = 1 ;
336
-
337
- if ( ! file_exists($path) ) {
338
- return true ;
339
- }
340
-
341
- if ( file_exists($path . $bak) ) {
342
- $bak = sprintf("_lscachebak_%02d", $i) ;
343
- while (file_exists($path . $bak)) {
344
- $i++ ;
345
- $bak = sprintf("_lscachebak_%02d", $i) ;
346
- }
347
- }
348
-
349
- if ( $i <= 10 || ! class_exists('ZipArchive') ) {
350
- $ret = copy($path, $path . $bak) ;
351
- return $ret ;
352
- }
353
-
354
- $zip = new ZipArchive ;
355
- $dir = dirname($path) ;
356
- $arr = scandir($dir) ;
357
- $parsed = preg_grep('/\.htaccess_lscachebak_[0-9]+/', $arr) ;
358
-
359
- if ( empty($parsed) ) {
360
- return false ;
361
- }
362
-
363
- $res = $zip->open($dir . '/.lscache_htaccess_bak.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE) ;
364
- if ( $res !== true ) {
365
- error_log('Warning: Failed to archive wordpress backups in ' . $dir) ;
366
- $ret = copy($path, $path . $bak) ;
367
- return $ret ;
368
- }
369
-
370
- foreach ($parsed as $key => $val) {
371
- $parsed[$key] = $dir . '/' . $val ;
372
- if ( ! $zip->addFile($parsed[$key], $val) ) {
373
- error_log('Warning: Failed to archive backup file ' . $val) ;
374
- $zip->close() ;
375
- $ret = copy($path, $path . $bak) ;
376
- return $ret ;
377
- }
378
- }
379
-
380
- $ret = $zip->close() ;
381
- if ( ! $ret ) {
382
- error_log('Warning: Failed to close archive.') ;
383
- return $ret ;
384
- }
385
- $bak = '_lscachebak_01' ;
386
-
387
- foreach ($parsed as $delFile) {
388
- unlink($delFile) ;
389
- }
390
-
391
- $ret = copy($path, $path . $bak) ;
392
- return $ret ;
393
- }
394
-
395
- /**
396
- * Get mobile view rule from htaccess file
397
- *
398
- * @since 1.1.0
399
- * @return string Mobile Agents value
400
- */
401
- public function get_rewrite_rule_mobile_agents()
402
- {
403
- $rules = $this->_get_rule_by(self::MARKER_MOBILE) ;
404
- if( ! isset($rules[0]) ) {
405
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, self::MARKER_MOBILE) ;
406
- return false ;
407
- }
408
- $rule = trim($rules[0]) ;
409
- $pattern = '/RewriteCond\s%{HTTP_USER_AGENT}\s+([^[\n]*)\s+[[]*/' ;
410
- $matches = array() ;
411
- $num_matches = preg_match($pattern, $rule, $matches) ;
412
- if ( $num_matches === false ) {
413
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_DNF, 'a match') ;
414
- return false ;
415
- }
416
- $match = trim($matches[1]) ;
417
- return $match ;
418
- }
419
-
420
- /**
421
- * Parse rewrites rule from the .htaccess file.
422
- *
423
- * @since 1.1.0
424
- * @access public
425
- * @param string $kind The kind of htaccess to search in
426
- * @return array
427
- */
428
- public function get_rewrite_rule_login_cookie($kind = 'frontend')
429
- {
430
- $rule = $this->_get_rule_by(self::MARKER_LOGIN_COOKIE, $kind) ;
431
- if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
432
- return false ;
433
- }
434
-
435
- $rule_cookie = substr( $rule, strlen( 'RewriteRule .? - [E=' ), -1 ) ;
436
-
437
- if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
438
- return trim( $rule_cookie, '"' ) ;
439
- }
440
-
441
- return $rule_cookie ;
442
- }
443
-
444
- /**
445
- * Get rewrite rules based on tags
446
- * @param string $cond The tag to be used
447
- * @param string $kind Frontend or backend .htaccess file
448
- * @return mixed Rules
449
- */
450
- private function _get_rule_by($cond, $kind = 'frontend')
451
- {
452
- clearstatcache() ;
453
- $path = $this->htaccess_path($kind) ;
454
- if ( ! self::readable($kind) ) {
455
- return false ;
456
- }
457
-
458
- $rules = Litespeed_File::extract_from_markers($path, self::MARKER) ;
459
- if( ! in_array($cond . self::MARKER_START, $rules) || ! in_array($cond . self::MARKER_END, $rules) ) {
460
- return false ;
461
- }
462
-
463
- $key_start = array_search($cond . self::MARKER_START, $rules) ;
464
- $key_end = array_search($cond . self::MARKER_END, $rules) ;
465
- if( $key_start === false || $key_end === false ) {
466
- return false ;
467
- }
468
-
469
- $results = array_slice($rules, $key_start+1, $key_end-$key_start-1) ;
470
- if( ! $results ) {
471
- return false ;
472
- }
473
- if( count($results) == 1 ) {
474
- return trim($results[0]) ;
475
- }
476
- return array_filter($results) ;
477
- }
478
-
479
- /**
480
- * Generate browser cache rules
481
- *
482
- * @since 1.3
483
- * @access private
484
- * @return array Rules set
485
- */
486
- private function _browser_cache_rules( $cfg )
487
- {
488
- /**
489
- * Add ttl setting
490
- * @since 1.6.3
491
- */
492
- $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER_TTL ;
493
- $ttl = $cfg[ $id ] ;
494
- $rules = array(
495
- self::EXPIRES_MODULE_START,
496
- // '<FilesMatch "\.(pdf|ico|svg|xml|jpg|jpeg|png|gif|webp|ogg|mp4|webm|js|css|woff|woff2|ttf|eot)(\.gz)?$">',
497
- 'ExpiresActive on',
498
- 'ExpiresByType application/pdf A' . $ttl,
499
- 'ExpiresByType image/x-icon A' . $ttl,
500
- 'ExpiresByType image/vnd.microsoft.icon A' . $ttl,
501
- 'ExpiresByType image/svg+xml A' . $ttl,
502
- '',
503
- 'ExpiresByType image/jpg A' . $ttl,
504
- 'ExpiresByType image/jpeg A' . $ttl,
505
- 'ExpiresByType image/png A' . $ttl,
506
- 'ExpiresByType image/gif A' . $ttl,
507
- 'ExpiresByType image/webp A' . $ttl,
508
- '',
509
- 'ExpiresByType video/ogg A' . $ttl,
510
- 'ExpiresByType audio/ogg A' . $ttl,
511
- 'ExpiresByType video/mp4 A' . $ttl,
512
- 'ExpiresByType video/webm A' . $ttl,
513
- '',
514
- 'ExpiresByType text/css A' . $ttl,
515
- 'ExpiresByType text/javascript A' . $ttl,
516
- 'ExpiresByType application/javascript A' . $ttl,
517
- 'ExpiresByType application/x-javascript A' . $ttl,
518
- '',
519
- 'ExpiresByType application/x-font-ttf A' . $ttl,
520
- 'ExpiresByType application/x-font-woff A' . $ttl,
521
- 'ExpiresByType application/font-woff A' . $ttl,
522
- 'ExpiresByType application/font-woff2 A' . $ttl,
523
- 'ExpiresByType application/vnd.ms-fontobject A' . $ttl,
524
- 'ExpiresByType font/ttf A' . $ttl,
525
- 'ExpiresByType font/woff A' . $ttl,
526
- 'ExpiresByType font/woff2 A' . $ttl,
527
- '',
528
- // '</FilesMatch>',
529
- self::LS_MODULE_END,
530
- ) ;
531
- return $rules ;
532
- }
533
-
534
- /**
535
- * Generate minify rules
536
- *
537
- * @since 2.1.2
538
- * @access private
539
- * @return array Rules set
540
- */
541
- private function _minify_rules()
542
- {
543
- $rules = array(
544
- self::LS_MODULE_REWRITE_START,
545
- self::REWRITE_ON,
546
- 'RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} ^(.*)/min/(\w+)\.(css|js)$',
547
- 'RewriteCond %1/' . basename( LSCWP_CONTENT_DIR ) . '/cache/$2/$1.$2 -f',
548
- 'RewriteRule min/(\w+)\.(css|js) ' . basename( LSCWP_CONTENT_DIR ) . '/cache/$2/$1.$2 [L]',
549
- self::LS_MODULE_END,
550
- ) ;
551
- return $rules ;
552
- }
553
-
554
- /**
555
- * Generate CORS rules for fonts
556
- *
557
- * @since 1.5
558
- * @access private
559
- * @return array Rules set
560
- */
561
- private function _cors_rules()
562
- {
563
- return array(
564
- '<FilesMatch "\.(ttf|ttc|otf|eot|woff|woff2|font\.css)$">',
565
- '<IfModule mod_headers.c>',
566
- 'Header set Access-Control-Allow-Origin "*"',
567
- '</IfModule>',
568
- '</FilesMatch>',
569
- ) ;
570
- }
571
-
572
- /**
573
- * Generate rewrite rules based on settings
574
- *
575
- * @since 1.3
576
- * @access private
577
- * @param array $cfg The settings to be used for rewrite rule
578
- * @return array Rules array
579
- */
580
- private function _generate_rules( $cfg, $disable_lscache_detail_rules = false )
581
- {
582
- $new_rules = array() ;
583
- $new_rules_nonls = array() ;
584
- $new_rules_backend = array() ;
585
- $new_rules_backend_nonls = array() ;
586
-
587
- if ( ! $disable_lscache_detail_rules ) {
588
- // mobile agents
589
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
590
- if ( ! empty( $cfg[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) && ! empty( $cfg[ $id ] ) ) {
591
- $new_rules[] = self::MARKER_MOBILE . self::MARKER_START ;
592
- $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] . ' [NC]' ;
593
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=ismobile]' ;
594
- $new_rules[] = self::MARKER_MOBILE . self::MARKER_END ;
595
- $new_rules[] = '' ;
596
- }
597
-
598
- // nocache cookie
599
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
600
- if ( ! empty( $cfg[ $id ] ) ) {
601
- $new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_START ;
602
- $new_rules[] = 'RewriteCond %{HTTP_COOKIE} ' . $cfg[ $id ] ;
603
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
604
- $new_rules[] = self::MARKER_NOCACHE_COOKIES . self::MARKER_END ;
605
- $new_rules[] = '' ;
606
- }
607
-
608
- // nocache user agents
609
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
610
- if ( ! empty( $cfg[ $id ] ) ) {
611
- $new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_START ;
612
- $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} ' . $cfg[ $id ] ;
613
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:no-cache]' ;
614
- $new_rules[] = self::MARKER_NOCACHE_USER_AGENTS . self::MARKER_END ;
615
- $new_rules[] = '' ;
616
- }
617
-
618
- // caching php resource
619
- $id = LiteSpeed_Cache_Config::OPID_CACHE_RES ;
620
- if ( ! empty( $cfg[ $id ] ) ) {
621
- $new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_START ;
622
- $new_rules[] = $new_rules_backend[] = 'RewriteRule ' . LSCWP_CONTENT_FOLDER . self::RW_PATTERN_RES . ' - [E=cache-control:max-age=3600]' ;
623
- $new_rules[] = $new_rules_backend[] = self::MARKER_CACHE_RESOURCE . self::MARKER_END ;
624
- $new_rules[] = $new_rules_backend[] = '' ;
625
- }
626
-
627
- // check login cookie
628
- $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
629
-
630
- // Need to keep this due to different behavior of OLS when handling response vary header @Sep/22/2018
631
- if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
632
- if ( ! empty( $cfg[ $id ] ) ) {
633
- $cfg[ $id ] .= ',wp-postpass_' . COOKIEHASH ;
634
- }
635
- else {
636
- $cfg[ $id ] = 'wp-postpass_' . COOKIEHASH ;
637
- }
638
- }
639
-
640
- $tp_cookies = apply_filters( 'litespeed_cache_api_vary', array() ) ;
641
- if ( ! empty( $tp_cookies ) && is_array( $tp_cookies ) ) {
642
- if ( ! empty( $cfg[ $id ] ) ) {
643
- $cfg[ $id ] .= ',' . implode( ',', $tp_cookies ) ;
644
- }
645
- else {
646
- $cfg[ $id ] = implode( ',', $tp_cookies ) ;
647
- }
648
- }
649
- // frontend and backend
650
- if ( ! empty( $cfg[ $id ] ) ) {
651
- $env = 'Cache-Vary:' . $cfg[ $id ] ;
652
- if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
653
- $env = '"' . $env . '"' ;
654
- }
655
- $new_rules[] = $new_rules_backend[] = self::MARKER_LOGIN_COOKIE . self::MARKER_START ;
656
- $new_rules[] = $new_rules_backend[] = 'RewriteRule .? - [E=' . $env . ']' ;
657
- $new_rules[] = $new_rules_backend[] = self::MARKER_LOGIN_COOKIE . self::MARKER_END ;
658
- $new_rules[] = '' ;
659
- }
660
-
661
- // favicon
662
- // frontend and backend
663
- $id = LiteSpeed_Cache_Config::OPID_CACHE_FAVICON ;
664
- if ( ! empty( $cfg[ $id ] ) ) {
665
- $new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_START ;
666
- $new_rules[] = $new_rules_backend[] = 'RewriteRule favicon\.ico$ - [E=cache-control:max-age=86400]' ;
667
- $new_rules[] = $new_rules_backend[] = self::MARKER_FAVICON . self::MARKER_END ;
668
- $new_rules[] = '' ;
669
- }
670
-
671
- // CORS font rules
672
- $id = LiteSpeed_Cache_Config::OPID_CDN ;
673
- if ( ! empty( $cfg[ $id ] ) ) {
674
- $new_rules[] = self::MARKER_CORS . self::MARKER_START ;
675
- $new_rules = array_merge( $new_rules, $this->_cors_rules() ) ;
676
- $new_rules[] = self::MARKER_CORS . self::MARKER_END ;
677
- $new_rules[] = '' ;
678
- }
679
-
680
- // webp support
681
- $id = LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ;
682
- if ( ! empty( $cfg[ $id ] ) ) {
683
- $new_rules[] = self::MARKER_WEBP . self::MARKER_START ;
684
- $new_rules[] = 'RewriteCond %{HTTP_ACCEPT} "image/webp" [or]' ;
685
- $new_rules[] = 'RewriteCond %{HTTP_USER_AGENT} "Page Speed"' ;
686
- $new_rules[] = 'RewriteRule .* - [E=Cache-Control:vary=%{ENV:LSCACHE_VARY_VALUE}+webp]' ;
687
- $new_rules[] = self::MARKER_WEBP . self::MARKER_END ;
688
- $new_rules[] = '' ;
689
- }
690
-
691
- // drop qs support
692
- $id = LiteSpeed_Cache_Config::ITEM_CACHE_DROP_QS ;
693
- if ( $cfg_info = get_option( $id ) ) {
694
- $new_rules[] = self::MARKER_DROPQS . self::MARKER_START ;
695
- foreach ( explode( "\n", $cfg_info ) as $v ) {
696
- $new_rules[] = 'CacheKeyModify -qs:' . $v ;
697
- }
698
- $new_rules[] = self::MARKER_DROPQS . self::MARKER_END ;
699
- $new_rules[] = '' ;
700
- }
701
- }
702
-
703
- // Browser cache
704
- $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ;
705
- if ( ! empty( $cfg[ $id ] ) ) {
706
- $new_rules_nonls[] = $new_rules_backend_nonls[] = self::MARKER_BROWSER_CACHE . self::MARKER_START ;
707
- $new_rules_nonls = array_merge( $new_rules_nonls, $this->_browser_cache_rules( $cfg ) ) ;
708
- $new_rules_backend_nonls = array_merge( $new_rules_backend_nonls, $this->_browser_cache_rules( $cfg ) ) ;
709
- $new_rules_nonls[] = $new_rules_backend_nonls[] = self::MARKER_BROWSER_CACHE . self::MARKER_END ;
710
- $new_rules_nonls[] = '' ;
711
- }
712
-
713
- // CSS/JS static file rewrite
714
- $new_rules_nonls[] = $new_rules_backend_nonls[] = self::MARKER_MINIFY . self::MARKER_START ;
715
- $new_rules_nonls = array_merge( $new_rules_nonls, $this->_minify_rules() ) ;
716
- $new_rules_backend_nonls = array_merge( $new_rules_backend_nonls, $this->_minify_rules() ) ;
717
- $new_rules_nonls[] = $new_rules_backend_nonls[] = self::MARKER_MINIFY . self::MARKER_END ;
718
- $new_rules_nonls[] = '' ;
719
-
720
- // Add module wrapper for LiteSpeed rules
721
- if ( $new_rules || $disable_lscache_detail_rules ) {
722
- $new_rules = $this->_wrap_ls_module( $new_rules ) ;
723
- }
724
-
725
- if ( $new_rules_backend || $disable_lscache_detail_rules ) {
726
- $new_rules_backend = $this->_wrap_ls_module( $new_rules_backend ) ;
727
- }
728
-
729
- return array( $new_rules, $new_rules_backend, $new_rules_nonls, $new_rules_backend_nonls ) ;
730
- }
731
-
732
- /**
733
- * Add LitSpeed module wrapper with rewrite on
734
- *
735
- * @since 2.1.1
736
- * @access private
737
- */
738
- private function _wrap_ls_module( $rules = array() )
739
- {
740
- return array_merge(
741
- array( self::LS_MODULE_START ),
742
- self::$LS_MODULE_REWRITE_ON,
743
- array( '' ),
744
- $rules,
745
- array( self::LS_MODULE_END )
746
- ) ;
747
- }
748
-
749
- /**
750
- * Insert LitSpeed module wrapper with rewrite on
751
- *
752
- * @since 2.1.1
753
- * @access public
754
- */
755
- public function insert_ls_wrapper()
756
- {
757
- $rules = $this->_wrap_ls_module() ;
758
- return $this->_insert_wrapper( $rules ) ;
759
- }
760
-
761
- /**
762
- * wrap rules with module on info
763
- *
764
- * @since 1.1.5
765
- * @param array $rules
766
- * @return array wrapped rules with module info
767
- */
768
- private function _wrap_do_no_edit( $rules )
769
- {
770
- // When to clear rules, don't need DONOTEDIT msg
771
- if ( $rules === false || ! is_array( $rules ) ) {
772
- return $rules ;
773
- }
774
-
775
- $rules = array_merge(
776
- array( self::LS_MODULE_DONOTEDIT ),
777
- $rules,
778
- array( self::LS_MODULE_DONOTEDIT )
779
- ) ;
780
-
781
- return $rules ;
782
- }
783
-
784
- /**
785
- * Write to htaccess with rules
786
- *
787
- * @since 1.1.0
788
- * @access private
789
- * @param array $rules
790
- * @param string $kind which htaccess
791
- */
792
- private function _insert_wrapper( $rules = array(), $kind = false, $marker = false )
793
- {
794
- if ( $kind === false ) {
795
- $kind = 'frontend' ;
796
- }
797
-
798
- // Default marker is LiteSpeed marker `LSCACHE`
799
- if ( $marker === false ) {
800
- $marker = self::MARKER ;
801
- }
802
-
803
- $res = $this->htaccess_backup( $kind ) ;
804
- if ( ! $res ) {
805
- return false ;
806
- }
807
-
808
- return Litespeed_File::insert_with_markers( $this->htaccess_path($kind), $this->_wrap_do_no_edit( $rules ), $marker, true ) ;
809
- }
810
-
811
- /**
812
- * Update rewrite rules based on setting
813
- *
814
- * @since 1.3
815
- * @access public
816
- * @param array $cfg The rules that need to be set.
817
- */
818
- public function update( $cfg, $disable_lscache_detail_rules = false )
819
- {
820
- if ( ! LiteSpeed_Cache_Admin_Rules::readable() ) {
821
- return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
822
- }
823
-
824
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
825
- if ( ! LiteSpeed_Cache_Admin_Rules::readable( 'backend' ) ) {
826
- return LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_R ) ;
827
- }
828
- }
829
-
830
- list( $frontend_rules, $backend_rules, $frontend_rules_nonls, $backend_rules_nonls ) = $this->_generate_rules( $cfg, $disable_lscache_detail_rules ) ;
831
-
832
- // Check frontend content
833
- list( $rules, $rules_nonls ) = $this->_extract_rules() ;
834
-
835
- // Check Non-LiteSpeed rules
836
- if ( $this->_wrap_do_no_edit( $frontend_rules_nonls ) != $rules_nonls ) {
837
- LiteSpeed_Cache_Log::debug( '[Rules] Update non-ls frontend rules' ) ;
838
- // Need to update frontend htaccess
839
- if ( ! $this->_insert_wrapper( $frontend_rules_nonls, false, self::MARKER_NONLS ) ) {
840
- $manual_guide_codes = $this->_rewrite_codes_msg( $this->frontend_htaccess, $frontend_rules_nonls, self::MARKER_NONLS ) ;
841
- LiteSpeed_Cache_Log::debug( '[Rules] Update Failed' ) ;
842
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
843
- }
844
- }
845
-
846
- // Check LiteSpeed rules
847
- if ( $this->_wrap_do_no_edit( $frontend_rules ) != $rules ) {
848
- LiteSpeed_Cache_Log::debug( '[Rules] Update frontend rules' ) ;
849
- // Need to update frontend htaccess
850
- if ( ! $this->_insert_wrapper( $frontend_rules ) ) {
851
- LiteSpeed_Cache_Log::debug( '[Rules] Update Failed' ) ;
852
- $manual_guide_codes = $this->_rewrite_codes_msg( $this->frontend_htaccess, $frontend_rules ) ;
853
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
854
- }
855
- }
856
-
857
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
858
- list( $rules, $rules_nonls ) = $this->_extract_rules( 'backend' ) ;
859
-
860
- // Check Non-LiteSpeed rules for backend
861
- if ( $this->_wrap_do_no_edit( $backend_rules_nonls ) != $rules_nonls ) {
862
- LiteSpeed_Cache_Log::debug( '[Rules] Update non-ls backend rules' ) ;
863
- // Need to update frontend htaccess
864
- if ( ! $this->_insert_wrapper( $backend_rules_nonls, 'backend', self::MARKER_NONLS ) ) {
865
- LiteSpeed_Cache_Log::debug( '[Rules] Update Failed' ) ;
866
- $manual_guide_codes = $this->_rewrite_codes_msg( $this->backend_htaccess, $backend_rules_nonls, self::MARKER_NONLS ) ;
867
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
868
- }
869
- }
870
-
871
- // Check backend content
872
- if ( $this->_wrap_do_no_edit( $backend_rules ) != $rules ) {
873
- LiteSpeed_Cache_Log::debug( '[Rules] Update backend rules' ) ;
874
- // Need to update backend htaccess
875
- if ( ! $this->_insert_wrapper( $backend_rules, 'backend' ) ) {
876
- LiteSpeed_Cache_Log::debug( '[Rules] Update Failed' ) ;
877
- $manual_guide_codes = $this->_rewrite_codes_msg( $this->backend_htaccess, $backend_rules ) ;
878
- return array( LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_HTA_W ), $manual_guide_codes ) ;
879
- }
880
- }
881
- }
882
-
883
- return true ;
884
- }
885
-
886
- /**
887
- * Get existing rewrite rules
888
- *
889
- * @since 1.3
890
- * @access private
891
- * @param string $kind Frontend or backend .htaccess file
892
- * @return bool|array False if failed to read, rules array otherwise
893
- */
894
- private function _extract_rules( $kind = 'frontend' )
895
- {
896
- clearstatcache() ;
897
- $path = $this->htaccess_path( $kind ) ;
898
- if ( ! self::readable( $kind ) ) {
899
- return false ;
900
- }
901
-
902
- $rules = Litespeed_File::extract_from_markers( $path, self::MARKER ) ;
903
- $rules_nonls = Litespeed_File::extract_from_markers( $path, self::MARKER_NONLS ) ;
904
-
905
- return array( $rules, $rules_nonls ) ;
906
- }
907
-
908
- /**
909
- * Output the msg with rules plain data for manual insert
910
- *
911
- * @since 1.1.5
912
- * @param string $file
913
- * @param array $rules
914
- * @return string final msg to output
915
- */
916
- private function _rewrite_codes_msg( $file, $rules, $marker = false )
917
- {
918
- return sprintf( __( '<p>Please add/replace the following codes into the beginning of %1$s:</p> %2$s' , 'litespeed-cache' ),
919
- $file,
920
- '<textarea style="width:100%;" rows="10" readonly>' . htmlspecialchars( $this->_wrap_rules_with_marker( $rules, $marker ) ) . '</textarea>'
921
- ) ;
922
- }
923
-
924
- /**
925
- * Generate rules plain data for manual insert
926
- *
927
- * @since 1.1.5
928
- * @param array $rules
929
- * @return array final rules data for htaccess
930
- */
931
- private function _wrap_rules_with_marker( $rules, $marker = false )
932
- {
933
- // Default marker is LiteSpeed marker `LSCACHE`
934
- if ( $marker === false ) {
935
- $marker = self::MARKER ;
936
- }
937
-
938
- $start_marker = "# BEGIN {$marker}" ;
939
- $end_marker = "# END {$marker}" ;
940
- $new_file_data = implode( "\n", array_merge(
941
- array( $start_marker ),
942
- $this->_wrap_do_no_edit($rules),
943
- array( $end_marker )
944
- ) ) ;
945
-
946
- return $new_file_data ;
947
- }
948
-
949
- /**
950
- * Clear the rules file of any changes added by the plugin specifically.
951
- *
952
- * @since 1.0.4
953
- * @access public
954
- * @param string $clear_all Deactivation will give true, so clear all rules, otherwise only clear lscache related rules.
955
- */
956
- public function clear_rules()
957
- {
958
- $this->_insert_wrapper( false ) ;// Use false to avoid do-not-edit msg
959
- // Clear non ls rules
960
- $this->_insert_wrapper( false, false, self::MARKER_NONLS ) ;
961
-
962
- if ( $this->frontend_htaccess !== $this->backend_htaccess ) {
963
- $this->_insert_wrapper( false, 'backend' ) ;
964
- $this->_insert_wrapper( false, 'backend', self::MARKER_NONLS ) ;
965
- }
966
- }
967
-
968
- /**
969
- * Only used to clear old rules when upgrade to v1.1.0
970
- */
971
- public function deprecated_clear_rules()
972
- {
973
- $RW_WRAPPER = 'PLUGIN - Do not edit the contents of this block!' ;
974
- $pattern = '/###LSCACHE START ' . $RW_WRAPPER . '###.*###LSCACHE END ' . $RW_WRAPPER . '###\n?/s' ;
975
- clearstatcache() ;
976
- if ( ! file_exists($this->frontend_htaccess) || ! self::writable() ) {
977
- return ;
978
- }
979
- $content = file_get_contents($this->frontend_htaccess) ;
980
- if( ! $content ) {
981
- return ;
982
- }
983
-
984
- $buf = preg_replace($pattern, '', $content) ;
985
- $buf = preg_replace("|<IfModule LiteSpeed>\s*</IfModule>|isU", '', $buf) ;
986
-
987
- $this->htaccess_save($buf) ;
988
-
989
- // clear backend htaccess
990
- if ( $this->frontend_htaccess === $this->backend_htaccess ) {
991
- return ;
992
- }
993
-
994
- if ( ! file_exists($this->backend_htaccess) || ! self::writable('backend') ) {
995
- return ;
996
- }
997
- $content = file_get_contents($this->backend_htaccess) ;
998
- if( ! $content ) {
999
- return ;
1000
- }
1001
-
1002
- $buf = preg_replace($pattern, '', $content) ;
1003
- $buf = preg_replace("|<IfModule LiteSpeed>\n*</IfModule>|isU", '', $buf) ;
1004
- $this->htaccess_save($buf, 'backend') ;
1005
- }
1006
-
1007
- /**
1008
- * Parses the .htaccess buffer when the admin saves changes in the edit .htaccess page.
1009
- * Only admin can do this
1010
- *
1011
- * @since 1.0.4
1012
- * @since 2.9 Used exception when saving
1013
- * @access public
1014
- */
1015
- public function htaccess_editor_save()
1016
- {
1017
- if ( ! isset( $_POST[ self::EDITOR_TEXTAREA_NAME ] ) ) {
1018
- return ;
1019
- }
1020
-
1021
- $content = LiteSpeed_Cache_Admin::cleanup_text($_POST[self::EDITOR_TEXTAREA_NAME]) ;
1022
-
1023
- try {
1024
- $this->htaccess_save($content) ;
1025
- } catch( \Exception $e ) {
1026
- LiteSpeed_Cache_Admin_Display::error( $e->getMessage() ) ;
1027
- return ;
1028
- }
1029
-
1030
- LiteSpeed_Cache_Admin_Display::succeed( __( 'File Saved.', 'litespeed-cache' ) ) ;
1031
-
1032
- }
1033
-
1034
- /**
1035
- * Get the current instance object.
1036
- *
1037
- * @since 1.1.0
1038
- * @access public
1039
- * @return Current class instance.
1040
- */
1041
- public static function get_instance()
1042
- {
1043
- if ( ! isset( self::$_instance ) ) {
1044
- self::$_instance = new self() ;
1045
- }
1046
-
1047
- return self::$_instance ;
1048
- }
1049
- }
1050
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin-settings.class.php DELETED
@@ -1,1438 +0,0 @@
1
- <?php
2
- /**
3
- * The admin settings handler of the plugin.
4
- *
5
- *
6
- * @since 1.1.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin_Settings
17
- {
18
- private static $_instance ;
19
-
20
- private $_input ;
21
- private $_options ;
22
- private $_err = array() ;
23
-
24
- private $_max_int = 2147483647 ;
25
-
26
- /**
27
- * Init
28
- *
29
- * @since 1.3
30
- * @access private
31
- */
32
- private function __construct()
33
- {
34
- }
35
-
36
- /**
37
- * Callback function that will validate any changes made in the settings page.
38
- *
39
- * NOTE: Anytime that validate_plugin_settings is called, `convert_options_to_input` must be done first if not from option page
40
- *
41
- * @since 1.0.0
42
- * @access public
43
- * @param array $input The configuration selected by the admin when clicking save.
44
- * @return array The updated configuration options.
45
- */
46
- public function validate_plugin_settings( $input, $revert_options_to_input = false )
47
- {
48
- // Revert options to initial input
49
- if ( $revert_options_to_input ) {
50
- $input = LiteSpeed_Cache_Config::convert_options_to_input( $input ) ;
51
- }
52
-
53
- LiteSpeed_Cache_Log::debug( '[Settings] validate_plugin_settings called' ) ;
54
- $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
55
-
56
- if ( LiteSpeed_Cache_Admin_Display::get_instance()->get_disable_all() ) {
57
- add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, __( '\'Use primary site settings\' set by Network Administrator.', 'litespeed-cache' ) ) ;
58
-
59
- return $this->_options ;
60
- }
61
-
62
- $this->_input = $input ;
63
-
64
- $this->_validate_general() ;
65
-
66
- $this->_validate_cache() ;
67
-
68
- $this->_validate_purge() ;
69
-
70
- $this->_validate_exclude() ;
71
-
72
- $this->_validate_optimize() ;
73
-
74
- $this->_validate_media() ;
75
-
76
- $this->_validate_cdn() ;
77
-
78
- $this->_validate_adv() ;
79
-
80
- $this->_validate_debug() ;
81
-
82
- $this->_validate_crawler() ; // Network setup doesn't run validate_plugin_settings
83
-
84
- if ( ! is_multisite() ) {
85
- $this->_validate_singlesite() ;
86
- }
87
-
88
- // if ( LSWCP_ESI_SUPPORT ) {
89
- $orig_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
90
-
91
- $this->_validate_esi() ;
92
-
93
- $new_esi_enabled = $this->_options[ LiteSpeed_Cache_Config::OPID_ESI_ENABLE ] ;
94
-
95
- if ( $orig_esi_enabled !== $new_esi_enabled ) {
96
- LiteSpeed_Cache_Purge::purge_all( 'ESI changed' ) ;
97
- }
98
- // }
99
-
100
- if ( ! empty( $this->_err ) ) {
101
- add_settings_error( LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, implode( '<br />', $this->_err ) ) ;
102
-
103
- return $this->_options ;
104
- }
105
-
106
- if ( defined( 'LITESPEED_CLI' ) ) {
107
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
108
- $cron_val = $this->_options[ $id ] ;
109
- // assign crawler_cron_active to $this->_options if exists in $this->_input separately for CLI
110
- // This has to be specified cos crawler cron activation is not set in admin setting page
111
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
112
- if ( $cron_val != $this->_options[ $id ] ) {
113
- // check if need to enable crawler cron
114
- LiteSpeed_Cache_Task::update( $this->_options ) ;
115
- }
116
- }
117
-
118
- $this->_validate_thirdparty() ;
119
-
120
- /**
121
- * Check if need to send cfg to CDN or not
122
- * @since 2.3
123
- */
124
- $id = LiteSpeed_Cache_Config::OPT_CDN_QUIC ;
125
- if ( $this->_options[ $id ] ) {
126
- // Send to Quic CDN
127
- LiteSpeed_Cache_CDN_Quic::sync_config( $this->_options ) ;
128
- }
129
-
130
- return $this->_options ;
131
- }
132
-
133
- /**
134
- * Validates the single site specific settings.
135
- *
136
- * @since 1.0.12
137
- * @access private
138
- */
139
- private function _validate_singlesite()
140
- {
141
- /**
142
- * Handle files:
143
- * 1) wp-config.php;
144
- * 2) adv-cache.php;
145
- * 3) object-cache.php;
146
- * 4) .htaccess;
147
- */
148
-
149
- /* 1) wp-config.php; */
150
- $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO ;
151
- if ( $this->_options[ $id ] ) {// todo: If not enabled, may need to remove cache var?
152
- $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
153
- if ( $ret !== true ) {
154
- $this->_err[] = $ret ;
155
- }
156
- }
157
-
158
- /* 2) adv-cache.php; */
159
-
160
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
161
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
162
- if ( $this->_options[ $id ] ) {
163
- LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;
164
- }
165
-
166
- /* 3) object-cache.php; */
167
-
168
- /**
169
- * Validate Object Cache
170
- * @since 1.8
171
- */
172
- $new_options = $this->_validate_object_cache() ;
173
- $this->_options = array_merge( $this->_options, $new_options ) ;
174
-
175
- /* 4) .htaccess; */
176
-
177
- // Parse rewrite rule settings
178
- $new_options = $this->_validate_rewrite_settings() ;
179
- $this->_options = array_merge( $this->_options, $new_options ) ;
180
-
181
- // Try to update rewrite rules
182
- $disable_lscache_detail_rules = false ;
183
- if ( defined( 'LITESPEED_NEW_OFF' ) ) {
184
- // Clear lscache rules but keep lscache module rules, keep non-lscache rules
185
- $disable_lscache_detail_rules = true ;
186
- }
187
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $this->_options, $disable_lscache_detail_rules ) ;
188
- if ( $res !== true ) {
189
- if ( ! is_array( $res ) ) {
190
- $this->_err[] = $res ;
191
- }
192
- else {
193
- $this->_err = array_merge( $this->_err, $res ) ;
194
- }
195
- }
196
-
197
- /**
198
- * Keep self up-to-date
199
- * @since 2.7.2
200
- */
201
- $id = LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ;
202
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
203
-
204
- }
205
-
206
- /**
207
- * Parses any changes made by the network admin on the network settings.
208
- *
209
- * @since 1.0.4
210
- * @access public
211
- */
212
- public function validate_network_settings( $input, $revert_options_to_input = false )
213
- {
214
- // Revert options to initial input
215
- if ( $revert_options_to_input ) {
216
- $input = LiteSpeed_Cache_Config::convert_options_to_input( $input ) ;
217
- }
218
-
219
- $this->_input = LiteSpeed_Cache_Admin::cleanup_text( $input ) ;
220
-
221
- $options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
222
-
223
-
224
- /**
225
- * Handle files:
226
- * 1) wp-config.php;
227
- * 2) adv-cache.php;
228
- * 3) object-cache.php;
229
- * 4) .htaccess;
230
- */
231
-
232
- /* 1) wp-config.php; */
233
-
234
- $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
235
- $network_enabled = self::parse_onoff( $this->_input, $id ) ;
236
- if ( $network_enabled ) {
237
- $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
238
- if ( $ret !== true ) {
239
- $this->_err[] = $ret ;
240
- }
241
- }
242
- elseif ( $options[ $id ] != $network_enabled ) {
243
- LiteSpeed_Cache_Purge::purge_all( 'Network enable changed' ) ;
244
- }
245
-
246
- $options[ $id ] = $network_enabled ;
247
-
248
- /* 2) adv-cache.php; */
249
-
250
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
251
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
252
- if ( $options[ $id ] ) {
253
- LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;
254
- }
255
-
256
- /* 3) object-cache.php; */
257
-
258
- /**
259
- * Validate Object Cache
260
- * @since 1.8
261
- */
262
- $new_options = $this->_validate_object_cache() ;
263
- $options = array_merge( $options, $new_options ) ;
264
-
265
- /* 4) .htaccess; */
266
-
267
- // Parse rewrite settings from input
268
- $new_options = $this->_validate_rewrite_settings() ;
269
- $options = array_merge( $options, $new_options ) ;
270
-
271
- // Update htaccess
272
- $disable_lscache_detail_rules = false ;
273
- if ( ! $network_enabled ) {
274
- // Clear lscache rules but keep lscache module rules, keep non-lscache rules
275
- // Need to set cachePublicOn in case subblogs turn on cache manually
276
- $disable_lscache_detail_rules = true ;
277
- }
278
- // NOTE: Network admin still need to make a lscache wrapper to avoid subblogs cache not work
279
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options, $disable_lscache_detail_rules ) ;
280
- if ( $res !== true ) {
281
- if ( ! is_array( $res ) ) {
282
- $this->_err[] = $res ;
283
- }
284
- else {
285
- $this->_err = array_merge( $this->_err, $res ) ;
286
- }
287
- }
288
-
289
- $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
290
- $orig_primary = $options[ $id ] ;
291
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
292
- if ( $orig_primary != $options[ $id ] ) {
293
- LiteSpeed_Cache_Purge::purge_all( 'Network use_primary changed' ) ;
294
- }
295
-
296
- $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
297
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
298
-
299
- $id = LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ;
300
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
301
-
302
- if ( ! empty( $this->_err ) ) {
303
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $this->_err ) ;
304
- return ;
305
- }
306
-
307
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __( 'Site options saved.', 'litespeed-cache' ) ) ;
308
- update_site_option( LiteSpeed_Cache_Config::OPTION_NAME, $options ) ;
309
- }
310
-
311
- /**
312
- * Validates object cache settings.
313
- *
314
- * @since 1.8
315
- * @access private
316
- */
317
- private function _validate_object_cache()
318
- {
319
- $new_options = array() ;
320
-
321
- $ids = array(
322
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT,
323
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND,
324
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_ADMIN,
325
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_TRANSIENTS,
326
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PERSISTENT,
327
- ) ;
328
- foreach ( $ids as $id ) {
329
- $new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
330
- }
331
-
332
- $ids = array(
333
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_HOST,
334
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PORT,
335
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_LIFE,
336
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_DB_ID,
337
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_USER,
338
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PSWD,
339
- );
340
- foreach ( $ids as $id ) {
341
- $new_options[ $id ] = $this->_input[ $id ] ;
342
- }
343
-
344
- $ids = array(
345
- LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS,
346
- LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
347
- );
348
- $item_options = array() ;
349
- foreach ( $ids as $id ) {
350
- $item_options[ $id ] = $this->_save_item( $id ) ;
351
- }
352
-
353
- /**
354
- * Check if object cache file existing or not
355
- */
356
- if ( ! defined( 'LITESPEED_DISABLE_OBJECT' ) ) {
357
- $id = LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ;
358
- if ( $new_options[ $id ] ) {
359
- $all_options = array_merge( $new_options, $item_options ) ;
360
- LiteSpeed_Cache_Log::debug( '[Settings] Update .object_cache.ini and flush object cache' ) ;
361
- LiteSpeed_Cache_Object::get_instance()->update_file( $all_options ) ;
362
- /**
363
- * Clear object cache
364
- */
365
- LiteSpeed_Cache_Object::get_instance()->reconnect( $all_options ) ;
366
- }
367
- else {
368
- if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
369
- LiteSpeed_Cache_Log::debug( '[Settings] Remove .object_cache.ini' ) ;
370
- LiteSpeed_Cache_Object::get_instance()->del_file() ;
371
- }
372
- }
373
- }
374
-
375
- return $new_options ;
376
-
377
- }
378
-
379
- /**
380
- * Validates the general settings.
381
- *
382
- * @since 1.0.12
383
- * @access private
384
- */
385
- private function _validate_general()
386
- {
387
- // Cache enabled setting
388
- $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO ;
389
- $this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
390
-
391
- $enabled = $this->_options[ $id ] ;
392
- // Use network setting
393
- if( $enabled === LiteSpeed_Cache_Config::VAL_ON2 ) {
394
- $enabled = is_multisite() ? defined( 'LITESPEED_NETWORK_ON' ) : true ; // Default to true
395
- }
396
-
397
- // Purge when disabled
398
- if ( ! $enabled ) {
399
- LiteSpeed_Cache_Purge::purge_all( 'Not enabled' ) ;
400
- ! defined( 'LITESPEED_NEW_OFF' ) && define( 'LITESPEED_NEW_OFF', true ) ; // Latest status is off
401
- }
402
-
403
- // TTL check
404
- $ids = array(
405
- LiteSpeed_Cache_Config::OPID_PUBLIC_TTL => array( 30, null ),
406
- LiteSpeed_Cache_Config::OPID_PRIVATE_TTL => array( 60, 3600 ),
407
- LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL => array( 30, null ),
408
- LiteSpeed_Cache_Config::OPID_FEED_TTL => array( 0, null, 30 ),
409
- LiteSpeed_Cache_Config::OPID_404_TTL => array( 0, null, 30 ),
410
- LiteSpeed_Cache_Config::OPID_403_TTL => array( 0, null, 30 ),
411
- LiteSpeed_Cache_Config::OPID_500_TTL => array( 0, null, 30 ),
412
- ) ;
413
- foreach ( $ids as $id => $v ) {
414
- list( $min, $max ) = $v ;
415
-
416
- $this->_options[ $id ] = $this->_check_ttl( $this->_input, $id, $min, $max ) ;
417
-
418
- if ( ! empty( $v[ 2 ] ) && $this->_options[ $id ] < $v[ 2 ] ) {
419
- $this->_options[ $id ] = 0 ;
420
- }
421
- }
422
-
423
- $id = LiteSpeed_Cache_Config::OPT_NEWS ;
424
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
425
- }
426
-
427
- /**
428
- * Validates the cache control settings.
429
- *
430
- * @since 1.1.6
431
- * @access private
432
- */
433
- private function _validate_cache()
434
- {
435
- $ids = array(
436
- LiteSpeed_Cache_Config::OPID_CACHE_PRIV,
437
- LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER,
438
- LiteSpeed_Cache_Config::OPID_CACHE_REST,
439
- );
440
- foreach ( $ids as $id ) {
441
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
442
- }
443
-
444
- $id = LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ;
445
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
446
- if( ! $this->_options[ $id ] ) {
447
- LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_LOGIN ) ;
448
- }
449
-
450
- $id = LiteSpeed_Cache_Config::ITEM_CACHE_URI_PRIV ;
451
- $this->_save_item( $id, 'relative' ) ;
452
-
453
- $ids = array(
454
- LiteSpeed_Cache_Config::ITEM_CACHE_DROP_QS, // Update Drop Query String @since 1.7
455
- );
456
- foreach ( $ids as $id ) {
457
- $this->_save_item( $id ) ;
458
- }
459
-
460
- }
461
-
462
- /**
463
- * Validates the purge settings.
464
- *
465
- * @since 1.0.12
466
- * @access private
467
- */
468
- private function _validate_purge()
469
- {
470
- $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
471
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
472
-
473
- // get auto purge rules options
474
- $pvals = array(
475
- LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
476
- LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
477
- LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
478
- LiteSpeed_Cache_Config::PURGE_PAGES,
479
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS,
480
- LiteSpeed_Cache_Config::PURGE_AUTHOR,
481
- LiteSpeed_Cache_Config::PURGE_YEAR,
482
- LiteSpeed_Cache_Config::PURGE_MONTH,
483
- LiteSpeed_Cache_Config::PURGE_DATE,
484
- LiteSpeed_Cache_Config::PURGE_TERM,
485
- LiteSpeed_Cache_Config::PURGE_POST_TYPE,
486
- ) ;
487
- $input_purge_options = array() ;
488
- foreach ( $pvals as $v) {
489
- $input_name = 'purge_' . $v ;
490
- if ( self::parse_onoff( $this->_input, $input_name ) ) {
491
- $input_purge_options[] = $v ;
492
- }
493
- }
494
- sort( $input_purge_options ) ;
495
- $purge_by_post = implode( '.', $input_purge_options ) ;
496
- if ( $purge_by_post !== $this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] ) {
497
- $this->_options[ LiteSpeed_Cache_Config::OPID_PURGE_BY_POST ] = $purge_by_post ;
498
- }
499
-
500
- // Filter scheduled purge URLs
501
- $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS ;
502
- if ( isset( $this->_input[ $id ] ) ) {
503
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'relative' ) ;
504
- }
505
-
506
- // Schduled Purge Time
507
- $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ;
508
- $this->_options[ $id ] = $this->_input[ $id ] ;
509
- }
510
-
511
- /**
512
- * Validates the exclude settings.
513
- *
514
- * @since 1.0.12
515
- * @access private
516
- */
517
- private function _validate_exclude()
518
- {
519
- $id = LiteSpeed_Cache_Config::ITEM_FORCE_CACHE_URI ;
520
- $this->_save_item( $id, 'relative' ) ;
521
-
522
- $id = LiteSpeed_Cache_Config::ITEM_EXCLUDES_URI ;
523
- $this->_save_item( $id, 'relative' ) ;
524
-
525
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ;
526
- if ( isset( $this->_input[ $id ] ) ) {
527
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
528
- }
529
-
530
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT ;
531
- $this->_options[ $id ] = '' ;
532
- if ( isset( $this->_input[ $id ] ) ) {
533
- $cat_ids = array() ;
534
- $cats = explode( "\n", $this->_input[ $id ] ) ;
535
- foreach ( $cats as $cat ) {
536
- $cat_name = trim( $cat ) ;
537
- if ( $cat_name == '' ) {
538
- continue ;
539
- }
540
- $cat_id = get_cat_ID( $cat_name ) ;
541
- if ( $cat_id == 0 ) {
542
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_CAT, $cat_name ) ;
543
- }
544
- else {
545
- $cat_ids[] = $cat_id ;
546
- }
547
- }
548
- if ( ! empty( $cat_ids ) ) {
549
- $this->_options[ $id ] = implode( ',', $cat_ids ) ;
550
- }
551
- }
552
-
553
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG ;
554
- $this->_options[ $id ] = '' ;
555
- if ( isset( $this->_input[ $id ] ) ) {
556
- $tag_ids = array() ;
557
- $tags = explode( "\n", $this->_input[ $id ] ) ;
558
- foreach ( $tags as $tag ) {
559
- $tag_name = trim( $tag ) ;
560
- if ( $tag_name == '' ) {
561
- continue ;
562
- }
563
- $term = get_term_by( 'name', $tag_name, 'post_tag' ) ;
564
- if ( $term == 0 ) {
565
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_TAG, $tag_name ) ;
566
- }
567
- else {
568
- $tag_ids[] = $term->term_id ;
569
- }
570
- }
571
- if ( ! empty( $tag_ids ) ) {
572
- $this->_options[ $id ] = implode( ',', $tag_ids ) ;
573
- }
574
- }
575
-
576
- /**
577
- * Update Role Excludes
578
- * @since 1.6.2
579
- */
580
- $id = LiteSpeed_Cache_Config::EXCLUDE_CACHE_ROLES ;
581
- update_option( $id, ! empty( $this->_input[ $id ] ) ? $this->_input[ $id ] : array() ) ;
582
-
583
- }
584
-
585
- /**
586
- * Validates the CDN settings.
587
- *
588
- * @since 1.2.2
589
- * @access private
590
- */
591
- private function _validate_cdn()
592
- {
593
- $cdn_cloudflare_changed = false ;
594
- $ids = array(
595
- LiteSpeed_Cache_Config::OPID_CDN,
596
- LiteSpeed_Cache_Config::OPT_CDN_QUIC,
597
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE,
598
- ) ;
599
- foreach ( $ids as $id ) {
600
- $v = self::parse_onoff( $this->_input, $id ) ;
601
- if ( $this->_options[ $id ] === $v ) {
602
- continue ;
603
- }
604
-
605
- $this->_options[ $id ] = $v ;
606
-
607
- // Cloudflare setting is changed
608
- if ( $id == LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ) {
609
- $cdn_cloudflare_changed = true ;
610
- }
611
-
612
- }
613
-
614
- $id = LiteSpeed_Cache_Config::OPID_CDN_ORI ;
615
- $this->_options[ $id ] = $this->_input[ $id ] ;
616
- if ( $this->_options[ $id ] ) {
617
- $ori_list = explode( ',', $this->_options[ $id ] ) ;
618
- foreach ( $ori_list as $k => $v ) {
619
- $tmp = parse_url( $v ) ;
620
- if ( ! empty( $tmp[ 'scheme' ] ) ) {
621
- $v = str_replace( $tmp[ 'scheme' ] . ':', '', $v ) ;
622
- }
623
- $ori_list[ $k ] = trim( $v ) ;
624
- }
625
- $this->_options[ $id ] = implode( ',', $ori_list ) ;
626
- }
627
-
628
- $ids = array(
629
- LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE,
630
- ) ;
631
- foreach ( $ids as $id ) {
632
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) ;
633
- }
634
-
635
- $ids = array(
636
- LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR,
637
- ) ;
638
- foreach ( $ids as $id ) {
639
- $this->_save_item( $id ) ;
640
- }
641
-
642
- /**
643
- * Handle multiple CDN setting
644
- * @since 1.7
645
- */
646
- $cdn_mapping = array() ;
647
- $mapping_fields = array(
648
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL,
649
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
650
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
651
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
652
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE
653
- ) ;
654
- $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ;
655
- foreach ( $this->_input[ $id ][ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL ] as $k => $v ) {
656
- $this_mapping = array() ;
657
- foreach ( $mapping_fields as $f ) {
658
- $this_mapping[ $f ] = ! empty( $this->_input[ $id ][ $f ][ $k ] ) ? $this->_input[ $id ][ $f ][ $k ] : false ;
659
- if ( $f === LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE ) {
660
- $this_mapping[ $f ] = LiteSpeed_Cache_Utility::sanitize_lines( $this_mapping[ $f ] ) ;
661
- }
662
- }
663
-
664
- $cdn_mapping[] = $this_mapping ;
665
- }
666
- update_option( $id, $cdn_mapping ) ;
667
-
668
- /**
669
- * Load jQuery from cdn
670
- * @since 1.5
671
- */
672
- $id = LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY ;
673
- $this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
674
-
675
- /**
676
- * Quic API
677
- * @since 2.4.1
678
- */
679
- $ids = array(
680
- LiteSpeed_Cache_Config::OPT_CDN_QUIC_EMAIL,
681
- LiteSpeed_Cache_Config::OPT_CDN_QUIC_KEY,
682
- ) ;
683
- foreach ( $ids as $id ) {
684
- if ( $this->_options[ $id ] === $this->_input[ $id ] ) {
685
- continue ;
686
- }
687
- $this->_options[ $id ] = $this->_input[ $id ] ;
688
- }
689
-
690
- /**
691
- * CLoudflare API
692
- * @since 1.7.2
693
- */
694
- $ids = array(
695
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL,
696
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY,
697
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME,
698
- ) ;
699
- foreach ( $ids as $id ) {
700
- if ( $this->_options[ $id ] === $this->_input[ $id ] ) {
701
- continue ;
702
- }
703
- $cdn_cloudflare_changed = true ;
704
- $this->_options[ $id ] = $this->_input[ $id ] ;
705
- }
706
-
707
- // If cloudflare API is on, refresh the zone
708
- if ( $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ] && $cdn_cloudflare_changed ) {
709
- $zone = LiteSpeed_Cache_CDN_Cloudflare::get_instance()->fetch_zone( $this->_options ) ;
710
- if ( $zone ) {
711
- $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME ] = $zone[ 'name' ] ;
712
- $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = $zone[ 'id' ] ;
713
-
714
- LiteSpeed_Cache_Log::debug( "Settings: Get zone successfully \t\t[ID] $zone[id]" ) ;
715
- }
716
- else {
717
- $this->_options[ LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ] = '' ;
718
- LiteSpeed_Cache_Log::debug( '[Settings] Get zone failed, clean zone' ) ;
719
- }
720
- }
721
- }
722
-
723
- /**
724
- * Validates the media settings.
725
- *
726
- * @since 1.4
727
- * @access private
728
- */
729
- private function _validate_media()
730
- {
731
- $ids = array(
732
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY,
733
- LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP,
734
- LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_ASYNC,
735
- LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY,
736
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZYJS_INLINE,
737
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_AUTO,
738
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON,
739
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI,
740
- LiteSpeed_Cache_Config::OPT_MEDIA_RM_ORI_BKUP,
741
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP,
742
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS,
743
- LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF,
744
- LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET,
745
- ) ;
746
- foreach ( $ids as $id ) {
747
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
748
- }
749
-
750
- $ids = array(
751
- LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY_PLACEHOLDER,
752
- LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_COLOR,
753
- ) ;
754
- foreach ( $ids as $id ) {
755
- $this->_options[ $id ] = $this->_input[ $id ] ;
756
- }
757
-
758
- // Update lazyload image excludes
759
- $id = LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ;
760
- $this->_save_item( $id, 'uri' ) ;
761
-
762
- // Update lazyload image classname excludes
763
- $id = LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_CLS_EXC ;
764
- $this->_save_item( $id ) ;
765
-
766
- $id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ;
767
- $this->_save_item( $id ) ;
768
- }
769
-
770
- /**
771
- * Validates the optimize settings.
772
- *
773
- * @since 1.2.2
774
- * @access private
775
- */
776
- private function _validate_optimize()
777
- {
778
- $ids = array(
779
- LiteSpeed_Cache_Config::OPID_CSS_MINIFY,
780
- LiteSpeed_Cache_Config::OPID_CSS_INLINE_MINIFY,
781
- LiteSpeed_Cache_Config::OPID_CSS_COMBINE,
782
- LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY,
783
- LiteSpeed_Cache_Config::OPID_CSS_HTTP2,
784
- LiteSpeed_Cache_Config::OPID_JS_MINIFY,
785
- LiteSpeed_Cache_Config::OPID_JS_INLINE_MINIFY,
786
- LiteSpeed_Cache_Config::OPID_JS_COMBINE,
787
- LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY,
788
- LiteSpeed_Cache_Config::OPID_JS_HTTP2,
789
- LiteSpeed_Cache_Config::OPID_HTML_MINIFY,
790
- LiteSpeed_Cache_Config::OPID_OPTM_QS_RM,
791
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM,
792
- LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC,
793
- LiteSpeed_Cache_Config::OPT_OPTM_CCSS_GEN,
794
- LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC,
795
- LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE,
796
- LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER,
797
- LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM,
798
- LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY,
799
- LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC,
800
- LiteSpeed_Cache_Config::OPID_OPTM_RM_COMMENT,
801
- ) ;
802
- foreach ( $ids as $id ) {
803
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
804
- }
805
-
806
- $ids = array(
807
- LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES,
808
- LiteSpeed_Cache_Config::OPID_JS_EXCLUDES,
809
- ) ;
810
- foreach ( $ids as $id ) {
811
- $this->_options[ $id ] = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], 'uri' ) ;
812
- }
813
-
814
- $id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ;
815
- $this->_options[ $id ] = $this->_check_ttl( $this->_input, $id, 3600 ) ;
816
-
817
- // Update critical css
818
- update_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, $this->_input[ LiteSpeed_Cache_Config::ITEM_OPTM_CSS ] ) ;
819
-
820
- // prevent URI from optimization
821
- $id = LiteSpeed_Cache_Config::ITEM_OPTM_EXCLUDES ;
822
- $this->_save_item( $id, 'relative' ) ;
823
-
824
- // Update js deferred excludes
825
- $id = LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ;
826
- $this->_save_item( $id, 'uri' ) ;
827
-
828
- // Update Role Excludes
829
- $id = LiteSpeed_Cache_Config::EXCLUDE_OPTIMIZATION_ROLES ;
830
- update_option( $id, ! empty( $this->_input[ $id ] ) ? $this->_input[ $id ] : array() ) ;
831
-
832
- /**
833
- * DNS prefetch
834
- * @since 1.7.1
835
- */
836
- $id = LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ;
837
- $this->_save_item( $id, 'domain' ) ;
838
-
839
- /**
840
- * Combined file max size
841
- * @since 1.7.1
842
- */
843
- $id = LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ;
844
- $this->_options[ $id ] = $this->_input[ $id ] ;
845
-
846
- /**
847
- * Separate CCSS File Types & URI
848
- * @since 2.6.1
849
- */
850
- $id = LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_POSTTYPE ;
851
- $this->_save_item( $id ) ;
852
- $id = LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_URI ;
853
- $this->_save_item( $id, 'uri' ) ;
854
-
855
- }
856
-
857
- /**
858
- * Validate advanced setting
859
- *
860
- * @since 1.7.1
861
- * @access private
862
- */
863
- private function _validate_adv()
864
- {
865
- $ids = array(
866
- LiteSpeed_Cache_Config::OPID_USE_HTTP_FOR_HTTPS_VARY,
867
- // LiteSpeed_Cache_Config::OPID_ADV_FAVICON,
868
- LiteSpeed_Cache_Config::OPID_ADV_INSTANT_CLICK,
869
- ) ;
870
- foreach ( $ids as $id ) {
871
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
872
- }
873
-
874
- $ids = array(
875
- LiteSpeed_Cache_Config::ITEM_ADV_PURGE_ALL_HOOKS,
876
- ) ;
877
- foreach ( $ids as $id ) {
878
- $this->_save_item( $id ) ;
879
- }
880
-
881
- /**
882
- * Added Favicon
883
- * @since 1.7.2
884
- */
885
- // $fav_file_arr = array( 'frontend', 'backend' ) ;
886
- // $new_favicons = array() ;
887
- // foreach ( $fav_file_arr as $v ) {
888
- // if ( ! empty( $_FILES[ 'litespeed-file-favicon_' . $v ][ 'name' ] ) ) {
889
- // $file = wp_handle_upload( $_FILES[ 'litespeed-file-favicon_' . $v ], array( 'action' => 'update' ) ) ;
890
- // if ( ! empty( $file[ 'url' ] ) ) {
891
- // LiteSpeed_Cache_Log::debug( '[Settings] Updated favicon [' . $v . '] ' . $file[ 'url' ] ) ;
892
-
893
- // $new_favicons[ $v ] = $file[ 'url' ] ;
894
-
895
- // }
896
- // elseif ( isset( $file[ 'error' ] ) ) {
897
- // LiteSpeed_Cache_Log::debug( '[Settings] Failed to update favicon: [' . $v . '] ' . $file[ 'error' ] ) ;
898
- // }
899
- // else {
900
- // LiteSpeed_Cache_Log::debug( '[Settings] Failed to update favicon: Unkown err [' . $v . ']' ) ;
901
- // }
902
- // }
903
- // }
904
-
905
- // if ( $new_favicons ) {
906
- // $cfg_favicon = get_option( LiteSpeed_Cache_Config::ITEM_FAVICON, array() ) ;
907
- // update_option( LiteSpeed_Cache_Config::ITEM_FAVICON, array_merge( $cfg_favicon, $new_favicons ) ) ;
908
- // }
909
- }
910
-
911
- /**
912
- * Validates the debug settings.
913
- *
914
- * @since 1.0.12
915
- * @access private
916
- */
917
- private function _validate_debug()
918
- {
919
- $id = LiteSpeed_Cache_Config::OPID_ADMIN_IPS ;
920
- if ( isset( $this->_input[ $id ] ) ) {
921
- $admin_ips = array_map( 'trim', explode( "\n", trim( $this->_input[ $id ] ) ) ) ;
922
- $admin_ips = array_filter( $admin_ips ) ;
923
- $has_err = false ;
924
- if ( $admin_ips ) {
925
- foreach ( $admin_ips as $ip ) {
926
- if ( ! WP_Http::is_ip_address( $ip ) ) {
927
- $has_err = true ;
928
- break ;
929
- }
930
- }
931
- }
932
- $admin_ips = implode( "\n", $admin_ips ) ;
933
-
934
- if ( $has_err ) {
935
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_ADMIN_IP_INV ) ;
936
- }
937
- else {
938
- $this->_options[ $id ] = $admin_ips ;
939
- }
940
- }
941
-
942
- $id = LiteSpeed_Cache_Config::OPID_DEBUG ;
943
- $this->_options[ $id ] = self::is_checked_radio( $this->_input[ $id ] ) ;
944
-
945
- $id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ;
946
- $this->_options[ $id ] = $this->_check_ttl( $this->_input, $id, 3, 3000 ) ;
947
-
948
- $ids = array(
949
- LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL,
950
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
951
- LiteSpeed_Cache_Config::OPID_HEARTBEAT,
952
- LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE,
953
- LiteSpeed_Cache_Config::OPID_COLLAPS_QS,
954
- LiteSpeed_Cache_Config::OPID_LOG_FILTERS,
955
- ) ;
956
- foreach ( $ids as $id ) {
957
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
958
- }
959
-
960
- // Remove Object Cache
961
- if ( $this->_options[ LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ] ) {
962
- // Do a purge all (This is before oc file removal, can purge oc too)
963
- LiteSpeed_Cache_Purge::purge_all( '[Settings] Debug Disabled ALL' ) ;
964
-
965
- LiteSpeed_Cache_Log::debug( '[Settings] Remove .object_cache.ini due to debug_disable_all' ) ;
966
- LiteSpeed_Cache_Object::get_instance()->del_file() ;
967
-
968
- // Set a const to avoid regenerating again
969
- define( 'LITESPEED_DISABLE_OBJECT', true ) ;
970
- }
971
-
972
- // Filters ignored
973
- $ids = array(
974
- LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_FILTERS,
975
- LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_PART_FILTERS,
976
- ) ;
977
- foreach ( $ids as $id ) {
978
- $this->_save_item( $id ) ;
979
- }
980
- }
981
-
982
- /**
983
- * Validates the crawler settings.
984
- *
985
- * @since 1.0.12
986
- * @access private
987
- */
988
- private function _validate_crawler()
989
- {
990
- $ids = array(
991
- LiteSpeed_Cache_Config::CRWL_POSTS,
992
- LiteSpeed_Cache_Config::CRWL_PAGES,
993
- LiteSpeed_Cache_Config::CRWL_CATS,
994
- LiteSpeed_Cache_Config::CRWL_TAGS,
995
- ) ;
996
- foreach ( $ids as $id ) {
997
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
998
- }
999
-
1000
- $id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
1001
- if ( isset( $this->_input[ $id ] ) ) {
1002
- $arr = array_map( 'trim', explode( "\n", $this->_input[ $id ] ) ) ;
1003
- $arr = array_filter( $arr ) ;
1004
- $ori = array_diff( get_post_types( '', 'names' ), array( 'post', 'page' ) ) ;
1005
- $this->_options[ $id ] = implode( "\n", array_intersect( $arr, $ori ) ) ;
1006
- }
1007
-
1008
- $id = LiteSpeed_Cache_Config::CRWL_ORDER_LINKS ;
1009
- if( ! isset( $this->_input[ $id ] ) || ! in_array( $this->_input[ $id ], array(
1010
- LiteSpeed_Cache_Config::CRWL_DATE_DESC,
1011
- LiteSpeed_Cache_Config::CRWL_DATE_ASC,
1012
- LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
1013
- LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
1014
- ) )
1015
- ) {
1016
- $this->_input[ $id ] = LiteSpeed_Cache_Config::CRWL_DATE_DESC ;
1017
- }
1018
- $this->_options[ $id ] = $this->_input[ $id ] ;
1019
-
1020
- $usleep_min = 0 ;
1021
- $usleep_max = 30000 ;
1022
- if ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ) ) {
1023
- $usleep_min = $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ;
1024
- $usleep_max = null ;
1025
- }
1026
- $ids = array(
1027
- LiteSpeed_Cache_Config::CRWL_USLEEP => array( $usleep_min, $usleep_max ),
1028
- LiteSpeed_Cache_Config::CRWL_RUN_DURATION => array( 0, null ),
1029
- LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL => array( 60, null ),
1030
- LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL => array( 0, null ),
1031
- LiteSpeed_Cache_Config::CRWL_THREADS => array( 1, 16 ),
1032
- ) ;
1033
- foreach ( $ids as $id => $v ) {
1034
- list( $min, $max ) = $v ;
1035
-
1036
- $this->_options[ $id ] = $this->_check_ttl( $this->_input, $id, $min, $max ) ;
1037
- }
1038
-
1039
-
1040
- $id = LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ;
1041
- $this->_options[ $id ] = $this->_input[ $id ] ;
1042
-
1043
- $id = LiteSpeed_Cache_Config::CRWL_DOMAIN_IP ;
1044
- if ( ! empty( $this->_input[ $id ] ) && ! WP_Http::is_ip_address( $this->_input[ $id ] ) ) {
1045
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_SITE_IP, $this->_input[ $id ] ) ;
1046
- }
1047
- else {
1048
- $this->_options[ $id ] = $this->_input[ $id ] ;
1049
- }
1050
-
1051
- $id = LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ;
1052
- if ( ! empty( $this->_input[ $id ] ) && ( $err = $this->_validate_custom_sitemap( $this->_input[ $id ] ) ) !== true ) {
1053
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( $err, $this->_input[ $id ] ) ;
1054
- }
1055
- else {
1056
- $this->_options[ $id ] = $this->_input[ $id ] ;
1057
- }
1058
-
1059
- $id = LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ;
1060
- $this->_save_item( $id ) ;
1061
-
1062
- /**
1063
- * Save cookie crawler
1064
- * @since 2.8
1065
- */
1066
- $id = LiteSpeed_Cache_Config::ITEM_CRWL_COOKIES ;
1067
- $cookie_crawlers = array() ;
1068
- if ( ! empty( $this->_input[ $id ][ 'name' ] ) ) {
1069
- foreach ( $this->_input[ $id ][ 'name' ] as $k => $v ) {
1070
- if ( ! $v ) {
1071
- continue ;
1072
- }
1073
-
1074
- $cookie_crawlers[ $v ] = $this->_input[ $id ][ 'vals' ][ $k ] ;
1075
- }
1076
- }
1077
- update_option( $id, $cookie_crawlers ) ;
1078
-
1079
- }
1080
-
1081
- /**
1082
- * Validates the custom sitemap settings.
1083
- *
1084
- * @since 1.1.1
1085
- * @access private
1086
- * @param string $url The sitemap url
1087
- */
1088
- private function _validate_custom_sitemap( $url )
1089
- {
1090
- return LiteSpeed_Cache_Crawler::get_instance()->parse_custom_sitemap( $url, false ) ;
1091
- }
1092
-
1093
- /**
1094
- * Validates settings related to rewrite rules
1095
- *
1096
- * @since 1.3
1097
- * @access private
1098
- * @return array New options related to rewrite rule
1099
- */
1100
- private function _validate_rewrite_settings()
1101
- {
1102
- $new_options = array() ;
1103
-
1104
- $ids = array(
1105
- LiteSpeed_Cache_Config::OPID_CACHE_MOBILE,
1106
- LiteSpeed_Cache_Config::OPID_CACHE_FAVICON,
1107
- LiteSpeed_Cache_Config::OPID_CACHE_RES,
1108
- LiteSpeed_Cache_Config::OPID_CACHE_BROWSER,
1109
- LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE,
1110
- ) ;
1111
- foreach ( $ids as $id ) {
1112
- $new_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
1113
- }
1114
-
1115
- // TTL check
1116
- $id = LiteSpeed_Cache_Config::OPID_CACHE_BROWSER_TTL ;
1117
- $new_options[ $id ] = $this->_check_ttl( $this->_input, $id, 30 ) ;
1118
-
1119
- // check mobile agents
1120
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
1121
- if ( ! $this->_input[ $id ] && $new_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
1122
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, 'EMPTY' ) ) ;
1123
- }
1124
- elseif ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
1125
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
1126
- }
1127
- else {
1128
- $new_options[ $id ] = $this->_input[ $id ] ;
1129
- }
1130
-
1131
- // No cache cookie settings
1132
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES ;
1133
- $this->_input[ $id ] = preg_replace( "/[\r\n]+/", '|', $this->_input[ $id ] ) ;
1134
- if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
1135
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
1136
- }
1137
- else {
1138
- $new_options[ $id ] = $this->_input[ $id ] ;
1139
- }
1140
-
1141
- // No cache user agent settings
1142
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS ;
1143
- if ( $this->_input[ $id ] && ! $this->_syntax_checker( $this->_input[ $id ] ) ) {
1144
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_REWRITE, array( $id, esc_html( $this->_input[ $id ] ) ) ) ;
1145
- }
1146
- else {
1147
- $new_options[ $id ] = $this->_input[ $id ] ;
1148
- }
1149
-
1150
- // Login cookie
1151
- $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
1152
- if ( $this->_input[ $id ] && preg_match( '#[^\w\-]#', $this->_input[ $id ] ) ) {
1153
- $this->_err[] = LiteSpeed_Cache_Admin_Display::get_error( LiteSpeed_Cache_Admin_Error::E_SETTING_LC, esc_html( $this->_input[ $id ] ) ) ;
1154
- }
1155
- else {
1156
- $new_options[ $id ] = $this->_input[ $id ] ;
1157
- }
1158
-
1159
- return $new_options ;
1160
- }
1161
-
1162
- /**
1163
- * Validates the third party settings.
1164
- *
1165
- * @since 1.0.12
1166
- * @access private
1167
- */
1168
- private function _validate_thirdparty()
1169
- {
1170
- $tp_default_options = LiteSpeed_Cache_Config::get_instance()->get_thirdparty_options() ;
1171
- if ( empty( $tp_default_options ) ) {
1172
- return ;
1173
- }
1174
-
1175
- $tp_input = array_intersect_key( $this->_input, $tp_default_options ) ;
1176
- if ( empty( $tp_input ) ) {
1177
- return ;
1178
- }
1179
-
1180
- $tp_options = apply_filters( 'litespeed_cache_save_options', array_intersect_key( $this->_options, $tp_default_options ), $tp_input ) ;
1181
- if ( ! empty( $tp_options ) && is_array( $tp_options ) ) {
1182
- $this->_options = array_merge( $this->_options, $tp_options ) ;
1183
- }
1184
- }
1185
-
1186
- /**
1187
- * Validates the esi settings.
1188
- *
1189
- * @since 1.1.3
1190
- * @access private
1191
- */
1192
- private function _validate_esi()
1193
- {
1194
- $ids = array(
1195
- LiteSpeed_Cache_Config::OPID_ESI_ENABLE,
1196
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR,
1197
- LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM,
1198
- ) ;
1199
- foreach ( $ids as $id ) {
1200
- $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
1201
- }
1202
-
1203
- // Save vary group settings
1204
- $id = LiteSpeed_Cache_Config::VARY_GROUP;
1205
- update_option( $id, ! empty( $this->_input[ $id ] ) ? $this->_input[ $id ] : array() ) ;
1206
- }
1207
-
1208
- /**
1209
- * Hooked to the wp_redirect filter.
1210
- * This will only hook if there was a problem when saving the widget.
1211
- *
1212
- * @since 1.1.3
1213
- * @access public
1214
- * @param string $location The location string.
1215
- * @return string the updated location string.
1216
- */
1217
- public static function widget_save_err( $location )
1218
- {
1219
- return str_replace( '?message=0', '?error=0', $location ) ;
1220
- }
1221
-
1222
- /**
1223
- * Hooked to the widget_update_callback filter.
1224
- * Validate the LiteSpeed Cache settings on edit widget save.
1225
- *
1226
- * @since 1.1.3
1227
- * @access public
1228
- * @param array $instance The new settings.
1229
- * @param array $new_instance
1230
- * @param array $old_instance The original settings.
1231
- * @param WP_Widget $widget The widget
1232
- * @return mixed Updated settings on success, false on error.
1233
- */
1234
- public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget )
1235
- {
1236
- if ( empty( $new_instance ) ) {
1237
- return $instance ;
1238
- }
1239
- if ( ! isset( $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) ) {
1240
- return $instance ;
1241
- }
1242
- if ( ! isset( $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) ) {
1243
- return $instance ;
1244
- }
1245
- $esistr = $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
1246
- $ttlstr = $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
1247
-
1248
- if ( ! is_numeric( $ttlstr ) || ! is_numeric( $esistr ) ) {
1249
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
1250
- return false ;
1251
- }
1252
-
1253
- $esi = self::is_checked_radio( $esistr ) ;
1254
- $ttl = intval( $ttlstr ) ;
1255
-
1256
- if ( $ttl != 0 && $ttl < 30 ) {
1257
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
1258
- return false ; // invalid ttl.
1259
- }
1260
-
1261
- if ( empty( $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
1262
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] = array() ;
1263
- }
1264
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
1265
- $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
1266
-
1267
- $current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
1268
- if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
1269
- LiteSpeed_Cache_Purge::purge_all( 'Wdiget ESI_enable changed' ) ;
1270
- }
1271
- elseif ( $ttl != 0 && $ttl != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) {
1272
- LiteSpeed_Cache_Purge::add( LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget->id ) ;
1273
- }
1274
-
1275
- LiteSpeed_Cache_Purge::purge_all( 'Wdiget saved' ) ;
1276
- return $instance ;
1277
- }
1278
-
1279
- /**
1280
- * Parse rewrite input to check for possible issues (e.g. unescaped spaces).
1281
- *
1282
- * Issues tracked:
1283
- * Starts with |
1284
- * Ends with |
1285
- * Double |
1286
- * Unescaped space
1287
- * Invalid character (NOT \w, -, \, |, \s, /, ., +, *, (, ))
1288
- *
1289
- * @since 1.0.9
1290
- * @access private
1291
- * @param String $rule Input rewrite rule.
1292
- * @return bool True for valid rules, false otherwise.
1293
- */
1294
- private function _syntax_checker( $rule )
1295
- {
1296
- $escaped = str_replace( '@', '\@', $rule ) ;
1297
-
1298
- $success = true ;
1299
-
1300
- set_error_handler( 'litespeed_exception_handler' ) ;
1301
-
1302
- try {
1303
- preg_match( '@' . $escaped . '@', null ) ;
1304
- } catch ( ErrorException $e ) {
1305
- $success = false ;
1306
- }
1307
-
1308
- restore_error_handler() ;
1309
-
1310
- return $success ;
1311
- }
1312
-
1313
- /**
1314
- * Helper function to validate TTL settings. Will check if it's set, is an integer, and is greater than 0 and less than INT_MAX.
1315
- *
1316
- * @since 1.0.12
1317
- * @since 2.6.2 Automatically correct number
1318
- * @access private
1319
- * @param array $input Input array
1320
- * @param string $id Option ID
1321
- * @param number $min Minimum number
1322
- * @param number $max Maximum number
1323
- * @return bool True if valid, false otherwise.
1324
- */
1325
- private function _check_ttl( $input, $id, $min = false, $max = null )
1326
- {
1327
- $v = isset( $input[ $id ] ) ? (int) $input[ $id ] : 0 ;
1328
-
1329
- if ( $min && $v < $min ) {
1330
- return $min ;
1331
- }
1332
-
1333
- if ( $v < 0 ) {
1334
- return 0 ;
1335
- }
1336
-
1337
- if ( $max === null ) {
1338
- $max = $this->_max_int ;
1339
- }
1340
-
1341
- if ( $v > $max ) {
1342
- return $max ;
1343
- }
1344
-
1345
- return $v ;
1346
- }
1347
-
1348
- /**
1349
- * Filter the value for checkbox via input and id (enabled/disabled)
1350
- *
1351
- * @since 1.1.6
1352
- * @access public
1353
- * @param int $input The whole input array
1354
- * @param string $id The ID of the option
1355
- * @return bool Filtered value
1356
- */
1357
- public static function parse_onoff( $input, $id )
1358
- {
1359
- return isset( $input[ $id ] ) && self::is_checked( $input[ $id ] ) ;
1360
- }
1361
-
1362
- /**
1363
- * Filter the value for checkbox (enabled/disabled)
1364
- *
1365
- * @since 1.1.0
1366
- * @access public
1367
- * @param int $val The checkbox value
1368
- * @return bool Filtered value
1369
- */
1370
- public static function is_checked( $val )
1371
- {
1372
- $val = intval( $val ) ;
1373
-
1374
- if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
1375
- return true ;
1376
- }
1377
-
1378
- return false ;
1379
- }
1380
-
1381
- /**
1382
- * Filter the value for radio (enabled/disabled/notset)
1383
- *
1384
- * @since 1.1.0
1385
- * @access public
1386
- * @param int $val The radio value
1387
- * @return int Filtered value
1388
- */
1389
- public static function is_checked_radio( $val )
1390
- {
1391
- $val = intval( $val ) ;
1392
-
1393
- if( $val === LiteSpeed_Cache_Config::VAL_ON ) {
1394
- return LiteSpeed_Cache_Config::VAL_ON ;
1395
- }
1396
-
1397
- if( $val === LiteSpeed_Cache_Config::VAL_ON2 ) {
1398
- return LiteSpeed_Cache_Config::VAL_ON2 ;
1399
- }
1400
-
1401
- return LiteSpeed_Cache_Config::VAL_OFF ;
1402
- }
1403
-
1404
- /**
1405
- * To save item in options
1406
- *
1407
- * @since 2.2.1
1408
- * @access private
1409
- */
1410
- private function _save_item( $id, $sanitize_filter = false )
1411
- {
1412
- $val = '' ;
1413
-
1414
- if ( ! empty( $this->_input[ $id ] ) ) {
1415
- $val = LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ], $sanitize_filter ) ;
1416
- }
1417
-
1418
- update_option( $id, $val ) ;
1419
-
1420
- return $val ;
1421
- }
1422
-
1423
- /**
1424
- * Get the current instance object.
1425
- *
1426
- * @since 1.1.0
1427
- * @access public
1428
- * @return Current class instance.
1429
- */
1430
- public static function get_instance()
1431
- {
1432
- if ( ! isset( self::$_instance ) ) {
1433
- self::$_instance = new self() ;
1434
- }
1435
-
1436
- return self::$_instance ;
1437
- }
1438
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/litespeed-cache-admin.class.php DELETED
@@ -1,302 +0,0 @@
1
- <?php
2
- /**
3
- * The admin-panel specific functionality of the plugin.
4
- *
5
- *
6
- * @since 1.0.0
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/admin
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Admin
17
- {
18
- private static $_instance ;
19
- private $config ;
20
- private $display ;
21
-
22
- /**
23
- * Initialize the class and set its properties.
24
- * Run in hook `after_setup_theme` when is_admin()
25
- *
26
- * @since 1.0.0
27
- */
28
- private function __construct()
29
- {
30
- // Define LSCWP_MU_PLUGIN if is mu-plugins
31
- if ( defined( 'WPMU_PLUGIN_DIR' ) && dirname( LSCWP_DIR ) == WPMU_PLUGIN_DIR ) {
32
- define( 'LSCWP_MU_PLUGIN', true ) ;
33
- }
34
-
35
- // Additional litespeed assets on admin display
36
- // Also register menu
37
- $this->display = LiteSpeed_Cache_Admin_Display::get_instance() ;
38
-
39
- $this->config = LiteSpeed_Cache_Config::get_instance() ;
40
-
41
- // initialize admin actions
42
- add_action( 'admin_init', array( $this, 'admin_init' ) ) ;
43
- // add link to plugin list page
44
- add_filter( 'plugin_action_links_' . LSCWP_BASENAME, array( $this->display, 'add_plugin_links' ) ) ;
45
-
46
- if ( defined( 'LITESPEED_ON' ) ) {
47
- // register purge_all actions
48
- $purge_all_events = $this->config->get_item( LiteSpeed_Cache_Config::ITEM_ADV_PURGE_ALL_HOOKS ) ;
49
-
50
- // purge all on upgrade
51
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ) ) {
52
- $purge_all_events[] = 'upgrader_process_complete' ;
53
- $purge_all_events[] = 'admin_action_do-plugin-upgrade' ;
54
- }
55
- foreach ( $purge_all_events as $event ) {
56
- // Don't allow hook to update_option bcos purge_all will cause infinite loop of update_option
57
- if ( in_array( $event, array( 'update_option' ) ) ) {
58
- continue ;
59
- }
60
- add_action( $event, 'LiteSpeed_Cache_Purge::purge_all' ) ;
61
- }
62
- // add_filter( 'upgrader_pre_download', 'LiteSpeed_Cache_Purge::filter_with_purge_all' ) ;
63
- }
64
- }
65
-
66
- /**
67
- * Callback that initializes the admin options for LiteSpeed Cache.
68
- *
69
- * @since 1.0.0
70
- * @access public
71
- */
72
- public function admin_init()
73
- {
74
- // check for upgrade
75
- // NOTE: upgrade checking needs to be before `register_setting` to avoid update_options() be checked by our filter
76
- $this->config->plugin_upgrade() ;
77
- if ( is_network_admin() && current_user_can( 'manage_network_options' ) ) {
78
- $this->config->plugin_site_upgrade() ;
79
- }
80
-
81
- load_plugin_textdomain(LiteSpeed_Cache::PLUGIN_NAME, false, 'litespeed-cache/languages/') ;
82
-
83
- $this->proceed_admin_action() ;
84
-
85
- // Terminate if user doesn't have the access to settings
86
- if( is_network_admin() ) {
87
- $capability = 'manage_network_options' ;
88
- }
89
- else {
90
- $capability = 'manage_options' ;
91
- }
92
- if ( ! current_user_can($capability) ) {
93
- return ;
94
- }
95
-
96
- // Save setting from admin settings page
97
- // NOTE: cli will call `validate_plugin_settings` manually. Cron activation doesn't need to validate
98
- global $pagenow ;
99
- if ( ! is_network_admin() && $pagenow === 'options.php' ) {
100
- register_setting(LiteSpeed_Cache_Config::OPTION_NAME, LiteSpeed_Cache_Config::OPTION_NAME, array(LiteSpeed_Cache_Admin_Settings::get_instance(), 'validate_plugin_settings')) ;
101
- }
102
-
103
- // Add privacy policy
104
- // @since 2.2.6
105
- if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
106
- wp_add_privacy_policy_content( LiteSpeed_Cache::PLUGIN_NAME, LiteSpeed_Cache_Doc::privacy_policy() ) ;
107
- }
108
-
109
- do_action( 'litspeed_after_admin_init' ) ;
110
-
111
- // If setting is set to on, try to activate cache func
112
- if ( defined( 'LITESPEED_ON_IN_SETTING' ) ) {
113
- // check if WP_CACHE is defined and true in the wp-config.php file.
114
- if ( ! defined('WP_CACHE') || ! WP_CACHE ) {
115
- $add_var = LiteSpeed_Cache_Config::wp_cache_var_setter(true) ;
116
- if ( $add_var !== true ) {
117
- LiteSpeed_Cache_Admin_Display::add_error($add_var) ;
118
- }
119
- }
120
-
121
- // check management action
122
- if ( defined('WP_CACHE') && WP_CACHE ) {
123
- $this->check_advanced_cache() ;
124
- }
125
-
126
- // step out if adv_cache can't write
127
- if ( ! defined( 'LITESPEED_ON' ) ) {
128
- return ;
129
- }
130
-
131
- }
132
-
133
-
134
- LiteSpeed_Cache_Control::set_nocache( 'Admin page' ) ;
135
-
136
- if ( LiteSpeed_Cache_Router::esi_enabled() ) {
137
- add_action( 'in_widget_form', array( $this->display, 'show_widget_edit' ), 100, 3 ) ;
138
- add_filter( 'widget_update_callback', 'LiteSpeed_Cache_Admin_Settings::validate_widget_save', 10, 4 ) ;
139
- }
140
-
141
- if ( ! is_multisite() ) {
142
- if( ! current_user_can('manage_options') ){
143
- return ;
144
- }
145
- }
146
- elseif ( ! is_network_admin() ) {
147
- if ( ! current_user_can('manage_options') ) {
148
- return ;
149
- }
150
- if ( get_current_blog_id() !== BLOG_ID_CURRENT_SITE ) {
151
- $use_primary = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
152
- $site_options = $this->config->get_site_options() ;
153
- if ( isset($site_options[$use_primary]) && $site_options[$use_primary] ) {
154
- $this->display->set_disable_all() ;
155
- }
156
- }
157
- return ;
158
- }
159
- elseif ( ! current_user_can('manage_network_options') ) {
160
- return ;
161
- }
162
-
163
- if ( LiteSpeed_Cache_GUI::has_whm_msg() ) {
164
- $this->display->show_display_installed() ;
165
- }
166
- }
167
-
168
- /**
169
- * Run litespeed admin actions
170
- *
171
- * @since 1.1.0
172
- */
173
- public function proceed_admin_action()
174
- {
175
- // handle actions
176
- switch (LiteSpeed_Cache_Router::get_action()) {
177
-
178
- // Save htaccess
179
- case LiteSpeed_Cache::ACTION_SAVE_HTACCESS:
180
- LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_editor_save() ;
181
- break ;
182
-
183
- // Save network settings
184
- case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
185
- LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ;// todo: use wp network setting saving
186
- break ;
187
-
188
- default:
189
- break ;
190
- }
191
-
192
- }
193
-
194
- /**
195
- * Check to make sure that the advanced-cache.php file is ours.
196
- * If it doesn't exist, try to make it ours.
197
- *
198
- * If it is not ours and the config is set to check, output an error.
199
- *
200
- * @since 1.0.11
201
- * @access private
202
- */
203
- private function check_advanced_cache()
204
- {
205
- $capability = is_network_admin() ? 'manage_network_options' : 'manage_options' ;
206
- if ( defined( 'LSCACHE_ADV_CACHE' ) || ! current_user_can( $capability ) ) {
207
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ) ) {
208
- // If it exists because I added it at runtime, try to create the file anyway.
209
- // Result does not matter.
210
- LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;// not sure why do this but doesn't matter
211
- }
212
- return ;
213
- }
214
-
215
- if ( LiteSpeed_Cache_Activation::try_copy_advanced_cache() ) {
216
- return ;
217
- }
218
-
219
- if ( is_multisite() && ( ! is_network_admin() || ! current_user_can('manage_network_options')) ) {
220
- $third = __('If this is the case, the network admin may uncheck "Check Advanced Cache" in LiteSpeed Cache Advanced settings.', 'litespeed-cache') ;
221
- }else {
222
- $third = __('If this is the case, please uncheck "Check Advanced Cache" in LiteSpeed Cache Advanced settings.', 'litespeed-cache') ;
223
- }
224
- $msg = __('LiteSpeed has detected another plugin using the "Advanced Cache" file.', 'litespeed-cache') . ' '
225
- . __('LiteSpeed Cache does work with other optimization plugins, but only if functionality is not duplicated. Only one full-page cache may be activated.', 'litespeed-cache') . ' '
226
- . $third
227
- . ' <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:customizations:multi-cache-plugins" target="_blank">'
228
- . __( 'Learn More', 'litespeed-cache' )
229
- . '</a>' ;
230
-
231
- $this->display->add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_YELLOW, $msg) ;
232
- }
233
-
234
- /**
235
- * Clean up the input string of any extra slashes/spaces.
236
- *
237
- * @since 1.0.4
238
- * @access public
239
- * @param string $input The input string to clean.
240
- * @return string The cleaned up input.
241
- */
242
- public static function cleanup_text( $input )
243
- {
244
- if ( is_array( $input ) ) {
245
- return array_map( 'LiteSpeed_Cache_Admin::cleanup_text', $input ) ;
246
- }
247
-
248
- return stripslashes( trim( $input ) ) ;
249
- }
250
-
251
- /**
252
- * After a LSCWP_CTRL action, need to redirect back to the same page
253
- * without the nonce and action in the query string.
254
- *
255
- * @since 1.0.12
256
- * @access public
257
- * @global string $pagenow
258
- */
259
- public static function redirect( $url = false )
260
- {
261
- global $pagenow ;
262
- $qs = '' ;
263
- if ( ! $url ) {
264
- if ( ! empty( $_GET ) ) {
265
- if ( isset( $_GET[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
266
- unset( $_GET[ LiteSpeed_Cache::ACTION_KEY ] ) ;
267
- }
268
- if ( isset( $_GET[ LiteSpeed_Cache::NONCE_NAME ] ) ) {
269
- unset( $_GET[ LiteSpeed_Cache::NONCE_NAME ] ) ;
270
- }
271
- if ( ! empty( $_GET ) ) {
272
- $qs = '?' . http_build_query( $_GET ) ;
273
- }
274
- }
275
- if ( is_network_admin() ) {
276
- $url = network_admin_url( $pagenow . $qs ) ;
277
- }
278
- else {
279
- $url = admin_url( $pagenow . $qs ) ;
280
- }
281
- }
282
-
283
- wp_redirect( $url ) ;
284
- exit() ;
285
- }
286
-
287
- /**
288
- * Get the current instance object.
289
- *
290
- * @since 1.1.0
291
- * @access public
292
- * @return Current class instance.
293
- */
294
- public static function get_instance()
295
- {
296
- if ( ! isset(self::$_instance) ) {
297
- self::$_instance = new self() ;
298
- }
299
-
300
- return self::$_instance ;
301
- }
302
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/api/quic.login.php DELETED
@@ -1,37 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
- ?>
6
-
7
- <h1 class="litespeed-title"><?php echo __('Quic Cloud User Panel', 'litespeed-cache') ; ?></h1>
8
-
9
- <form method="post" action="admin.php" id="litespeed_form_quic" class="litespeed-relative">
10
- <input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_CDN_QUIC ; ?>" />
11
- <input type="hidden" name="step" value="login" />
12
- <input type="hidden" name="email" value="<?php echo $data[ 'email' ] ; ?>" />
13
- <?php wp_nonce_field( LiteSpeed_Cache::ACTION_CDN_QUIC, LiteSpeed_Cache::NONCE_NAME ) ; ?>
14
-
15
- <?php if ( ! empty( $data[ '_err' ] ) ) : ?>
16
- <div class="litespeed-callout-danger">
17
- <h4><?php echo __( 'ERROR', 'litespeed-cache' ) ; ?>:</h4>
18
- <ol>
19
- <li><?php echo $data[ '_err' ] ; ?></li>
20
- </ol>
21
- </div>
22
- <?php endif ; ?>
23
-
24
- <div class="litespeed-row">
25
- <h4><?php echo __( 'Email', 'litespeed-cache' ) ; ?>:</h4>
26
- <?php echo $data[ 'email' ] ; ?>
27
- </div>
28
-
29
- <div class="litespeed-row">
30
- <h4><?php echo __( 'Password', 'litespeed-cache' ) ; ?> <?php echo __( 'Or', 'litespeed-cache' ) ; ?> <?php echo __( 'User API Key', 'litespeed-cache' ) ; ?> :</h4>
31
- <input type="password" name="pswd_or_key" class="litespeed-regular-text" value="<?php echo LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_CDN_QUIC_KEY ) ; ?>" />
32
- </div>
33
-
34
- <input type="submit" class="button litespeed-btn-success" value="<?php echo __( 'Login', 'litespeed-cache' ) ; ?>" />
35
-
36
- <a href="javascript:;" onclick="window.history.back();" class="button litespeed-btn-primary litespeed-right"><?php echo __( 'Back', 'litespeed-cache' ) ; ?></a>
37
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/api/quic.register.php DELETED
@@ -1,41 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
- ?>
6
-
7
- <h1 class="litespeed-title"><?php echo __('Quic Cloud User Panel', 'litespeed-cache') ; ?></h1>
8
-
9
- <form method="post" action="admin.php" id="litespeed_form_quic" class="litespeed-relative">
10
- <input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_CDN_QUIC ; ?>" />
11
- <input type="hidden" name="step" value="register" />
12
- <input type="hidden" name="email" value="<?php echo $data[ 'email' ] ; ?>" />
13
- <?php wp_nonce_field( LiteSpeed_Cache::ACTION_CDN_QUIC, LiteSpeed_Cache::NONCE_NAME ) ; ?>
14
-
15
- <?php if ( ! empty( $data[ '_err' ] ) ) : ?>
16
- <div class="litespeed-callout-danger">
17
- <h4><?php echo __( 'ERROR', 'litespeed-cache' ) ; ?>:</h4>
18
- <ol>
19
- <li><?php echo $data[ '_err' ] ; ?></li>
20
- </ol>
21
- </div>
22
- <?php endif ; ?>
23
-
24
- <div class="litespeed-row">
25
- <h4><?php echo __( 'Email', 'litespeed-cache' ) ; ?>:</h4>
26
- <?php echo $data[ 'email' ] ; ?>
27
- </div>
28
-
29
- <div class="litespeed-row">
30
- <h4><?php echo __( 'Password', 'litespeed-cache' ) ; ?>:</h4>
31
- <input type="password" name="pswd" class="litespeed-regular-text" required />
32
- </div>
33
-
34
- <input type="checkbox" class="form-check-input" id="exampleCheck1" required />
35
- <label class="form-check-label" for="exampleCheck1">I agree to <a href="https://quic.cloud/agreement" target="_blank">QuicCloud's terms and conditions</a></label><br />
36
-
37
- <input type="submit" class="button litespeed-btn-success" value="<?php echo __( 'Register', 'litespeed-cache' ) ; ?>" />
38
-
39
- <a href="javascript:;" onclick="window.history.back();" class="button litespeed-btn-primary litespeed-right"><?php echo __( 'Back', 'litespeed-cache' ) ; ?></a>
40
-
41
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/api/quic.user_welcome.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
- ?>
6
-
7
- <h1 class="litespeed-title"><?php echo __('Quic Cloud User Panel', 'litespeed-cache') ; ?></h1>
8
-
9
- <form method="post" action="admin.php" id="litespeed_form_quic" class="litespeed-relative">
10
- <input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_CDN_QUIC ; ?>" />
11
- <input type="hidden" name="step" value="check_email" />
12
- <?php wp_nonce_field( LiteSpeed_Cache::ACTION_CDN_QUIC, LiteSpeed_Cache::NONCE_NAME ) ; ?>
13
-
14
- <div class="litespeed-row">
15
- <h4><?php echo __( 'Email', 'litespeed-cache' ) ; ?>:</h4>
16
- <input type="text" name="email" value="<?php echo LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_CDN_QUIC_EMAIL ) ; ?>" class="litespeed-regular-text litespeed-input-large" required placeholder="<?php echo __( 'Email', 'litespeed-cache' ) ; ?>" />
17
- </div>
18
-
19
- <input type="submit" class="button litespeed-btn-success" value="<?php echo __( 'Next', 'litespeed-cache' ) ; ?>" />
20
-
21
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/crawler.php DELETED
@@ -1,257 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die ;
3
-
4
- $_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
5
-
6
- $_crawler_instance = LiteSpeed_Cache_Crawler::get_instance() ;
7
-
8
- $sitemap_time = $_crawler_instance->sitemap_time() ;
9
-
10
- $crawler_list = $_crawler_instance->list_crawlers() ;
11
-
12
- $meta = $_crawler_instance->read_meta() ;
13
- if ( $meta[ 'curr_crawler' ] >= count( $crawler_list ) ) {
14
- $meta[ 'curr_crawler' ] = 0 ;
15
- }
16
-
17
- $is_running = time() - $meta[ 'is_running' ] <= $_options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION] ;
18
-
19
- $disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
20
-
21
- ?>
22
-
23
- <div class="wrap">
24
- <h1 class="litespeed-h1">
25
- <?php echo __('LiteSpeed Cache Crawler', 'litespeed-cache') ; ?>
26
- </h1>
27
- <span class="litespeed-desc">
28
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
29
- </span>
30
- <hr class="wp-header-end">
31
-
32
- </div>
33
-
34
- <div class="litespeed-wrap">
35
- <div class="litespeed-body">
36
- <h3 class="litespeed-title"><?php echo __('Crawler File', 'litespeed-cache') ; ?></h3>
37
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE) ; ?>" class="litespeed-btn-success">
38
- <?php echo __('Generate Crawler File', 'litespeed-cache') ; ?>
39
- </a>
40
-
41
- <?php
42
- if ( $sitemap_time ) {
43
- echo sprintf(__('Generated at %s', 'litespeed-cache'), $sitemap_time) ;
44
- }
45
- ?>
46
- <div class="litespeed-desc">
47
- <?php echo sprintf(__('On click, this will create a crawler sitemap file in plugin directory %s.', 'litespeed-cache'), '`./var`') ; ?>
48
- </div>
49
-
50
- <?php
51
- $seconds = $_options[LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL] ;
52
- if($seconds > 0):
53
- $recurrence = '' ;
54
- $hours = (int)floor($seconds / 3600) ;
55
- if ( $hours ) {
56
- if ( $hours > 1) {
57
- $recurrence .= sprintf(__('%d hours', 'litespeed-cache'), $hours);
58
- }
59
- else {
60
- $recurrence .= sprintf(__('%d hour', 'litespeed-cache'), $hours);
61
- }
62
- }
63
- $minutes = (int)floor( ($seconds % 3600 ) / 60 ) ;
64
- if ( $minutes ) {
65
- $recurrence .= ' ' ;
66
- if ( $minutes > 1) {
67
- $recurrence .= sprintf(__('%d minutes', 'litespeed-cache'), $minutes);
68
- }
69
- else {
70
- $recurrence .= sprintf(__('%d minute', 'litespeed-cache'), $minutes);
71
- }
72
- }
73
- ?>
74
-
75
- <h3 class="litespeed-title litespeed-relative">
76
- <?php echo __('Crawler Cron', 'litespeed-cache') ; ?>
77
- <span class="litespeed-switch-drag litespeed-cron-onoff-btn">
78
- <input type="checkbox" name="litespeed_crawler_cron_enable" id="litespeed_crawler_cron_enable" value="1"
79
- data-url="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE, false, true ) ; ?>"
80
- <?php if( $_options[LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE] && LiteSpeed_Cache_Router::can_crawl() ) echo "checked"; ?>
81
- <?php echo $disabled ; ?>
82
- />
83
- <label class="litespeed-switch-drag-label" for="litespeed_crawler_cron_enable">
84
- <span class="litespeed-switch-drag-inner" data-on="<?php echo __('Enable', 'litespeed-cache'); ?>" data-off="<?php echo __('Disable', 'litespeed-cache'); ?>"></span>
85
- <span class="litespeed-switch-drag-switch"></span>
86
- </label>
87
- </span>
88
- </h3>
89
- <?php if ( ! LiteSpeed_Cache_Router::can_crawl() ): ?>
90
- <div class="litespeed-callout-danger">
91
- <h4><?php echo __('WARNING', 'litespeed-cache'); ?></h4>
92
- <p><?php echo __('The crawler feature is not enabled on the LiteSpeed server. Please consult your server admin.', 'litespeed-cache'); ?></p>
93
- <p><?php echo sprintf(__('See <a %s>Introduction for Enabling the Crawler</a> for detailed information.', 'litespeed-cache'), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:enabling_the_crawler" target="_blank"') ; ?></p>
94
- </div>
95
- <?php endif; ?>
96
-
97
-
98
- <?php if ( $meta[ 'this_full_beginning_time' ] ) : ?>
99
- <p>
100
- <b><?php echo __( 'Current sitemap crawl started at', 'litespeed-cache' ) ; ?>:</b>
101
- <?php echo LiteSpeed_Cache_Utility::readable_time( $meta[ 'this_full_beginning_time' ] ) ; ?>
102
- </p>
103
-
104
- <?php if ( ! $is_running ) : ?>
105
- <p>
106
- <b><?php echo __( 'The next complete sitemap crawl will start at', 'litespeed-cache' ) ; ?>:</b>
107
- <?php echo date('m/d/Y H:i:s',$meta[ 'this_full_beginning_time' ] + LITESPEED_TIME_OFFSET + $meta[ 'last_full_time_cost' ] + $_options[LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL]) ; ?>
108
- <?php endif ; ?>
109
- </p>
110
-
111
- <?php endif ; ?>
112
- <?php if ( $meta[ 'last_full_time_cost' ] ) : ?>
113
- <p>
114
- <b><?php echo __( 'Last complete run time for all crawlers', 'litespeed-cache' ) ; ?>:</b>
115
- <?php echo sprintf( __( '%d seconds', 'litespeed-cache' ), $meta[ 'last_full_time_cost' ] ) ; ?>
116
- </p>
117
- <?php endif ; ?>
118
-
119
- <?php if ( $meta[ 'last_crawler_total_cost' ] ) : ?>
120
- <p>
121
- <b><?php echo __('Run time for previous crawler', 'litespeed-cache') ; ?>:</b>
122
- <?php echo sprintf( __( '%d seconds', 'litespeed-cache' ), $meta[ 'last_crawler_total_cost' ] ) ; ?>
123
- </p>
124
- <?php endif ; ?>
125
-
126
- <?php if ( $meta[ 'curr_crawler_beginning_time' ] ) : ?>
127
- <p>
128
- <b><?php echo __('Current crawler started at', 'litespeed-cache') ; ?>:</b>
129
- <?php echo LiteSpeed_Cache_Utility::readable_time( $meta[ 'curr_crawler_beginning_time' ] ) ; ?>
130
- </p>
131
- <?php endif ; ?>
132
-
133
- <?php if ( $meta[ 'last_start_time' ] ) : ?>
134
- <p class='litespeed-desc'>
135
- <b><?php echo __('Last interval', 'litespeed-cache') ; ?>:</b>
136
- <?php echo LiteSpeed_Cache_Utility::readable_time( $meta[ 'last_start_time' ] ) ; ?>
137
- </p>
138
- <?php endif ; ?>
139
-
140
- <?php if ( $meta[ 'end_reason' ] ) : ?>
141
- <p class='litespeed-desc'>
142
- <b><?php echo __( 'Ended reason', 'litespeed-cache' ) ; ?>:</b>
143
- <?php echo $meta[ 'end_reason' ] ; ?>
144
- </p>
145
- <?php endif ; ?>
146
-
147
- <?php if ( $meta[ 'last_crawled' ] ) : ?>
148
- <p class='litespeed-desc'>
149
- <?php echo sprintf(__('<b>Last crawled:</b> %s item(s)', 'litespeed-cache'), $meta[ 'last_crawled' ] ) ; ?>
150
- </p>
151
- <?php endif ; ?>
152
-
153
- <?php echo " <a href='" . LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS) . "' class='litespeed-btn-warning litespeed-btn-xs'>" . __('Reset position', 'litespeed-cache') . "</a>" ;
154
-
155
- $href = LiteSpeed_Cache_Router::can_crawl() ? LiteSpeed_Cache_Utility::build_url(LiteSpeed_Cache::ACTION_DO_CRAWL) : 'javascript:;' ;
156
- echo " <a href='$href' id='litespeed_manual_trigger' target='litespeedHiddenIframe' class='litespeed-btn-success litespeed-btn-xs' $disabled>" . __('Manually run', 'litespeed-cache') . "</a>" ;
157
- ?>
158
-
159
-
160
- <table class="litespeed-table">
161
- <thead><tr >
162
- <th scope="col">#</th>
163
- <th scope="col"><?php echo __('Cron Name', 'litespeed-cache') ; ?></th>
164
- <th scope="col"><?php echo __('Run Frequency', 'litespeed-cache') ; ?></th>
165
- <th scope="col"><?php echo __('Size', 'litespeed-cache') ; ?></th>
166
- <th scope="col"><?php echo __('Status', 'litespeed-cache') ; ?></th>
167
- </tr></thead>
168
- <tbody>
169
- <?php foreach ( $crawler_list as $i => $v ) : ?>
170
- <tr>
171
- <td>
172
- <?php
173
- echo $i + 1 ;
174
- if ( $i == $meta[ 'curr_crawler' ] ) {
175
- echo "<img class='litespeed-crawler-curr' src='" . LSWCP_PLUGIN_URL . "img/Litespeed.icon.svg' />" ;
176
- }
177
- ?>
178
- </td>
179
- <td>
180
- <?php echo $v[ 'title' ] ; ?>
181
- </td>
182
- <td><?php echo $recurrence ; ?></td>
183
- <td><?php echo "Size: $meta[list_size]" ; ?></td>
184
- <td>
185
- <?php
186
- if ( $i == $meta[ 'curr_crawler' ] ) {
187
- echo "Position: " . ( $meta[ 'last_pos' ] + 1 ) ;
188
- if ( $is_running ) {
189
- echo " <span class='litespeed-label-success'>" . __( 'running', 'litespeed-cache' ) . "</span>" ;
190
- }
191
- }
192
- ?>
193
- </td>
194
- </tr>
195
- <?php endforeach ; ?>
196
- </tbody>
197
- </table>
198
- <div class="litespeed-desc">
199
- <div><?php echo __('Run frequency is set by the Interval Between Runs setting.','litespeed-cache') ; ?></div>
200
- <div><?php echo __('Only one crawler can run concurrently.', 'litespeed-cache')
201
- . __('If both the cron and manual run start at a similar time, the first one to start will run.','litespeed-cache') ; ?></div>
202
- <div><?php echo sprintf(__('Please follow <a %s>Hooking WP-Cron Into the System Task Scheduler</a> to create the system cron task.','litespeed-cache'), ' href="https://developer.wordpress.org/plugins/cron/hooking-into-the-system-task-scheduler/" target="_blank" ') ; ?></div>
203
- </div>
204
- <?php endif ; ?>
205
-
206
-
207
- <h3 class="litespeed-title"><?php echo __('Watch Crawler Status', 'litespeed-cache') ; ?></h3>
208
-
209
- <?php
210
- $ajaxUrl = $_crawler_instance->get_crawler_json_path() ;
211
- if ( $ajaxUrl ):
212
- ?>
213
-
214
- <input type="button" id="litespeed-crawl-url-btn" value="<?php echo __('Show crawler status', 'litespeed-cache') ; ?>" class="litespeed-btn-primary" data-url="<?php echo $ajaxUrl ; ?>" />
215
-
216
- <div class="litespeed-shell litespeed-hide">
217
- <div class="litespeed-shell-header-bar"></div>
218
- <div class="litespeed-shell-header">
219
- <div class="litespeed-shell-header-bg"></div>
220
- <div class="litespeed-shell-header-icon-container">
221
- <img id="litespeed-shell-icon" src="<?php echo LSWCP_PLUGIN_URL . 'img/Litespeed.icon.svg' ; ?>" />
222
- </div>
223
- </div>
224
- <ul class="litespeed-shell-body">
225
- <li>Start watching...</li>
226
- <li id="litespeed-loading-dot"></li>
227
- </ul>
228
- </div>
229
-
230
- <?php else: ?>
231
- <p>
232
- <?php echo __('No crawler meta file generated yet', 'litespeed-cache') ; ?>
233
- </p>
234
- <?php endif ; ?>
235
-
236
-
237
- <h3 class="litespeed-title"><?php echo __('Sitemap Generation Blacklist', 'litespeed-cache') ; ?></h3>
238
-
239
- <form method="post" action="admin.php?page=lscache-crawler">
240
- <?php $this->form_action(LiteSpeed_Cache::ACTION_BLACKLIST_SAVE); ?>
241
- <p>
242
- <textarea name="<?php echo LiteSpeed_Cache_Crawler::CRWL_BLACKLIST; ?>" rows="10" class="litespeed-textarea"><?php echo $_crawler_instance->get_blacklist(); ?></textarea>
243
- </p>
244
-
245
- <p>
246
- <button type="submit" class="litespeed-btn-success"><?php echo __('Save', 'litespeed-cache'); ?></button>
247
- </p>
248
- </form>
249
- <div class="litespeed-desc">
250
- <p><?php echo sprintf(__('Current blacklist has %s item(s).', 'litespeed-cache'), $_crawler_instance->count_blacklist()); ?></p>
251
- <p><?php echo __('All Urls which returned no-cache tags will be added here, after the initial crawling.', 'litespeed-cache'); ?></p>
252
- </div>
253
-
254
- </div>
255
- </div>
256
-
257
- <iframe name="litespeedHiddenIframe" src="" width="0" height="0" frameborder="0"></iframe>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/debug_log.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
-
6
- <div class="wrap">
7
- <h1 class="litespeed-h1">
8
- <?php echo __( 'LiteSpeed Cache Debug Log Viewer', 'litespeed-cache' ) ; ?>
9
- </h1>
10
- <span class="litespeed-desc">
11
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
12
- </span>
13
- <hr class="wp-header-end">
14
- </div>
15
-
16
- <div class="wrap">
17
- <form method="post" action="admin.php?page=lscache-debug">
18
- <?php $this->form_action( LiteSpeed_Cache::ACTION_LOG, LiteSpeed_Cache_Log::TYPE_BETA_TEST ) ; ?>
19
-
20
- <h3 class="litespeed-title"><?php echo __( 'Try GitHub Version', 'litespeed-cache' ) ; ?></h3>
21
-
22
- <input type="text" name="<?php echo LiteSpeed_Cache_Log::BETA_TEST_URL; ?>" class="litespeed-input-long">
23
-
24
- <div class="litespeed-desc">Example: https://github.com/litespeedtech/lscache_wp/commit/253715525b1708c25f73460635f7eaf152448821</div>
25
-
26
- <button type="submit" class="litespeed-btn-primary"><?php echo __('Upgrade', 'litespeed-cache'); ?></button>
27
- </form>
28
-
29
- <?php
30
-
31
- $file = LSCWP_CONTENT_DIR . '/debug.log' ;
32
- $lines = Litespeed_File::count_lines( $file ) ;
33
- $start = $lines > 1000 ? $lines - 1000 : 0 ;
34
- $logs = Litespeed_File::read( $file, $start ) ;
35
- $logs = implode( "\n", $logs ) ;
36
-
37
- echo nl2br( htmlspecialchars( $logs ) ) ;
38
-
39
- ?>
40
-
41
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_LOG, LiteSpeed_Cache_Log::TYPE_CLEAR_LOG ) ; ?>" class="litespeed-btn-success">
42
- <?php echo __( 'Clear Log', 'litespeed-cache' ) ; ?>
43
- </a>
44
-
45
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/edit_htaccess.php DELETED
@@ -1,79 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $readonly = LiteSpeed_Cache_Admin_Rules::writable() ? '' : 'readonly';
5
-
6
- $content = null ;
7
- try {
8
- $content = LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_read();
9
- } catch( \Exception $e ) {
10
- echo '<div class="notice notice-error is-dismissible"><p>'. $e->getMessage() . '</p></div>' ;
11
- }
12
-
13
-
14
- $htaccess_path = LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ;
15
-
16
- // Check if there is `ExpiresDefault` in .htaccess
17
- if ( defined( 'LITESPEED_ON' ) ) {
18
- if ( $content && stripos( $content, "\nExpiresDefault" ) !== false ) {
19
- $is_dismissed = get_option( self::DISMISS_MSG ) ;
20
- if ( $is_dismissed !== self::RULECONFLICT_DISMISSED ) {
21
- // Need to add a notice for browser cache compatibility
22
- if ( $is_dismissed !== self::RULECONFLICT_ON ) {
23
- update_option( self::DISMISS_MSG, self::RULECONFLICT_ON ) ;
24
- }
25
- require_once LSCWP_DIR . 'admin/tpl/inc/show_rule_conflict.php' ;
26
- }
27
- }
28
- // don't dismiss the msg automatically
29
- // elseif ( $is_dismissed === LiteSpeed_Cache_Admin_Display::RULECONFLICT_ON ) {
30
- // update_option( self::DISMISS_MSG, LiteSpeed_Cache_Admin_Display::RULECONFLICT_DISMISSED ) ;
31
- // }
32
- }
33
-
34
-
35
- ?>
36
-
37
- <div class="wrap">
38
- <h1 class="litespeed-h1">
39
- <?php echo __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache'); ?>
40
- </h1>
41
- <span class="litespeed-desc">
42
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
43
- </span>
44
- <hr class="wp-header-end">
45
- </div>
46
- <div class="litespeed-wrap">
47
- <div class="litespeed-body">
48
- <div class="litespeed-callout-danger">
49
- <h4>🚨 <?php echo __('This page is meant for advanced users.', 'litespeed-cache'); ?></h4>
50
- <p>
51
- <?php echo __('Any changes made to the .htaccess file may break the site.', 'litespeed-cache'); ?>
52
- <?php echo __('Please consult the host/server admin before making any changes.', 'litespeed-cache'); ?>
53
- </p>
54
- </div>
55
-
56
- <?php if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT): ?>
57
- <div class="litespeed-h3"><?php echo __('File editing is disabled in configuration.', 'litespeed-cache'); ?></div>
58
-
59
- <?php elseif( $content !== null ) : ?>
60
-
61
- <form method="post" action="admin.php?page=<?php echo LiteSpeed_Cache::PAGE_EDIT_HTACCESS; ?>">
62
- <?php $this->form_action(LiteSpeed_Cache::ACTION_SAVE_HTACCESS); ?>
63
-
64
- <div class="litespeed-title"><?php echo sprintf(__('Current %s Contents', 'litespeed-cache'), '.htaccess'); ?></div>
65
-
66
- <p><span class="attention"><?php echo sprintf(__('DO NOT EDIT ANYTHING WITHIN %s', 'litespeed-cache'), '<code>' . LiteSpeed_Cache_Admin_Rules::LS_MODULE_DONOTEDIT . '</code>' ); ?></span></p>
67
-
68
- <h4><?php echo $htaccess_path ; ?></h4>
69
-
70
- <textarea name="<?php echo LiteSpeed_Cache_Admin_Rules::EDITOR_TEXTAREA_NAME; ?>" wrap="off" rows="50" class="litespeed-input-long"
71
- <?php echo $readonly; ?>
72
- ><?php echo esc_textarea($content); ?></textarea>
73
-
74
- <button type="submit" class="litespeed-btn-primary"><?php echo __('Save', 'litespeed-cache'); ?></button>
75
- </form>
76
-
77
- <?php endif; ?>
78
- </div>
79
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/image_optimization.php DELETED
@@ -1,45 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- // Update table data for upgrading
5
- LiteSpeed_Cache_Data::get_instance() ;
6
-
7
- $img_optm = LiteSpeed_Cache_Img_Optm::get_instance() ;
8
-
9
- $img_count = $img_optm->img_count() ;
10
- $optm_summary = $img_optm->summary_info() ;
11
- list( $storage_data, $rm_log ) = $img_optm->storage_data() ;
12
-
13
- list( $last_run, $is_running ) = $img_optm->cron_running( false ) ;
14
-
15
- if ( ! empty( $img_count[ 'total_img' ] ) ) {
16
- $finished_percentage = 100 - floor( $img_count[ 'total_not_requested' ] * 100 / $img_count[ 'total_img' ] ) ;
17
- }
18
- else {
19
- $finished_percentage = 0 ;
20
- }
21
-
22
- ?>
23
-
24
- <div class="wrap">
25
- <h1 class="litespeed-h1">
26
- <?php echo __('LiteSpeed Cache Image Optimization', 'litespeed-cache') ; ?>
27
- </h1>
28
- <span class="litespeed-desc">
29
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
30
- </span>
31
- <hr class="wp-header-end">
32
- </div>
33
-
34
- <div class="litespeed-wrap">
35
- <div class="litespeed-body">
36
- <div class="litespeed-flex-container">
37
- <?php if ( ! $optm_summary ) : ?>
38
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.initialize.php" ; ?>
39
- <?php else : ?>
40
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.summary.php" ; ?>
41
- <?php endif ; ?>
42
- </div>
43
- </div>
44
-
45
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/import_export.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $log = get_option( LiteSpeed_Cache_Import::DB_IMPORT_LOG, array() ) ;
5
- ?>
6
-
7
- <div class="wrap">
8
- <h1 class="litespeed-h1">
9
- <?php echo __('LiteSpeed Cache Import / Export', 'litespeed-cache') ; ?>
10
- </h1>
11
- <span class="litespeed-desc">
12
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
13
- </span>
14
- <hr class="wp-header-end">
15
- </div>
16
-
17
- <div class="litespeed-wrap">
18
- <div class="litespeed-body">
19
- <h3 class="litespeed-title"><?php echo __('Export Settings', 'litespeed-cache') ; ?></h3>
20
-
21
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMPORT, LiteSpeed_Cache_Import::TYPE_EXPORT ) ; ?>" class="litespeed-btn-success">
22
- <?php echo __( 'Export', 'litespeed-cache' ) ; ?>
23
- </a>
24
-
25
- <?php if ( ! empty( $log[ 'export' ] ) ) : ?>
26
- <div class="litespeed-desc">
27
- <?php echo __( 'Last exported', 'litespeed-cache' ) ; ?>: <code><?php echo $log[ 'export' ][ 'file' ] ; ?></code> <?php echo LiteSpeed_Cache_Utility::readable_time( $log[ 'export' ][ 'time' ]) ; ?>
28
- </div>
29
- <?php endif ; ?>
30
-
31
- <div class="litespeed-desc">
32
- <?php echo __( 'This will export all current LiteSpeed Cache settings and save as a file.', 'litespeed-cache' ) ; ?>
33
- </div>
34
-
35
- <h3 class="litespeed-title"><?php echo __('Import Settings', 'litespeed-cache') ; ?></h3>
36
-
37
- <form method="post" action="admin.php?page=lscache-import" id="litespeed_form_import" enctype="multipart/form-data" class="">
38
- <?php $this->form_action( LiteSpeed_Cache::ACTION_IMPORT, LiteSpeed_Cache_Import::TYPE_IMPORT ) ; ?>
39
-
40
- <div class="litespeed-div litespeed-left20">
41
- <input type="file" name="ls_file" class="litespeed-input" />
42
- </div>
43
- <div class="litespeed-div">
44
- <?php submit_button(__('Import', 'litespeed-cache'), 'litespeed-btn-success', 'litespeed-submit') ; ?>
45
- </div>
46
- </form>
47
-
48
- <?php if ( ! empty( $log[ 'import' ] ) ) : ?>
49
- <div class="litespeed-desc">
50
- <?php echo __( 'Last imported', 'litespeed-cache' ) ; ?>: <code><?php echo $log[ 'import' ][ 'file' ] ; ?></code> <?php echo LiteSpeed_Cache_Utility::readable_time( $log[ 'import' ][ 'time' ]) ; ?>
51
- </div>
52
- <?php endif ; ?>
53
-
54
- <div class="litespeed-desc">
55
- <?php echo __( 'This will import settings from a file and override all current LiteSpeed Cache settings.', 'litespeed-cache' ) ; ?>
56
- </div>
57
-
58
- <h3 class="litespeed-title"><?php echo __('Reset All Settings', 'litespeed-cache') ; ?></h3>
59
-
60
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMPORT, LiteSpeed_Cache_Import::TYPE_RESET ) ; ?>" data-litespeed-cfm="<?php echo __( 'Are you sure to reset all settings to default settings?', 'litespeed-cache' ) ; ?>" class="litespeed-btn-danger">
61
- <?php echo __( 'Reset', 'litespeed-cache' ) ; ?>
62
- </a>
63
-
64
- <div class="litespeed-desc">
65
- 🚨
66
- <?php echo __( 'This will reset all settings to default settings.', 'litespeed-cache' ) ; ?>
67
- </div>
68
-
69
- </div>
70
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/inc/img_optm.communicate_notify.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
-
6
- ?>
7
-
8
- <span class="litespeed-desc">
9
- <?php echo __( 'This will communicate with LiteSpeed\'s Image Optimization Server and retrieve the most recent status.', 'litespeed-cache' ) ; ?>
10
- </span>
 
 
 
 
 
 
 
 
 
 
admin/tpl/inc/img_optm.initialize.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
-
6
- ?>
7
-
8
- <div class="litespeed-width-7-10">
9
- <div class="litespeed-empty-space-large"></div>
10
- <div class="litespeed-text-center">
11
- <div>
12
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_SYNC_DATA ) ; ?>" class="litespeed-text-malibu litespeed-btn-success litespeed-btn-large">
13
- <span class="dashicons dashicons-performance">
14
- </span>&nbsp;
15
- <?php echo __( 'Initialize Optimization', 'litespeed-cache' ) ; ?>
16
- </a>
17
- </div>
18
- </div>
19
- <div class="litespeed-empty-space-medium"></div>
20
- <div>
21
- <h2 Class="litespeed-title">
22
- <?php echo __( 'Notes', 'litespeed-cache' ) ; ?>:
23
- </h2>
24
-
25
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.communicate_notify.php" ; ?>
26
-
27
- <?php include_once LSCWP_DIR . "admin/tpl/inc/api_key.php" ; ?>
28
-
29
- <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>
30
-
31
- <hr class="litespeed-hr-dotted">
32
-
33
- </div>
34
- </div>
35
-
36
- <div class="litespeed-width-3-10 litespeed-column-java">
37
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.percentage_summary.php" ; ?>
38
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/inc/img_optm.level_info.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
-
6
- if ( empty( $optm_summary[ 'level' ] ) ) {
7
- return ;
8
- }
9
- ?>
10
-
11
-
12
-
13
-
14
-
15
- <?php
16
- if ( $optm_summary[ 'level' ] >= 5 || empty( $optm_summary[ '_level_data' ] ) ) {
17
- return ;
18
- }
19
-
20
- $next_level = $optm_summary[ 'level' ] + 1 ;
21
- $next_level_data = $optm_summary[ '_level_data' ][ $next_level ] ;
22
-
23
- $_progress = floor( $optm_summary[ 'credit_recovered' ] * 100 / $next_level_data[ 0 ] ) ;
24
- ?>
25
-
26
- <div class="litespeed-progress">
27
- <div class="litespeed-progress-bar litespeed-progress-bar-blue" role="progressbar" style="width: <?php echo $_progress ; ?>%" aria-valuenow="<?php echo $_progress ; ?>" aria-valuemin="0" aria-valuemax="100"></div>
28
- </div>
29
- <div class="litespeed-flex-container" style="margin-top:none;">
30
- <div class="litespeed-width-1-2">
31
- <span class="litespeed-text-malibu" style="font-weight: 600;">
32
- <?php echo __( 'Level', 'litespeed-cache' ) ; ?>: <font><?php echo $optm_summary[ 'level' ] ; ?></font>
33
- <span class="litespeed-left20"></span>
34
- <?php echo __( 'Credit', 'litespeed-cache' ) ; ?>: <font><?php echo $optm_summary[ 'credit' ] ; ?></font>
35
- <span class="litespeed-left20"></span>
36
- </span>
37
- <span class="litespeed-desc"><?php echo __( 'Credit recovers with each successful pull.', 'litespeed-cache' ) ; ?></span>
38
- </div>
39
- <div class="litespeed-width-1-2">
40
- <span class="litespeed-silence">
41
- <?php echo __( 'Next Level', 'litespeed-cache' ) ; ?>: <?php echo $next_level ; ?>
42
- <span class="litespeed-left20 litespeed-empty-space-small"></span>
43
- <?php echo __( 'Next Level Credit', 'litespeed-cache' ) ; ?>: <?php echo $next_level_data[ 1 ] ; ?>
44
- </span>
45
- </div>
46
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/inc/img_optm.percentage_summary.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
-
6
- ?>
7
-
8
- <h3 class="litespeed-title">
9
- <?php echo __( 'Image Information', 'litespeed-cache' ) ; ?>
10
- </h3>
11
-
12
- <div class="litespeed-flex-container">
13
- <div class="litespeed-icon-vertical-middle">
14
- <?php echo LiteSpeed_Cache_GUI::pie( $finished_percentage, 100, true ) ; ?>
15
- </div>
16
- <div>
17
- <p>
18
- <?php echo __( 'Images total', 'litespeed-cache') ; ?>:
19
-
20
- <code><?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'total_img' ] ) ; ?></code>
21
-
22
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization:image-groups" target="_blank" class="litespeed-desc litespeed-left20" title="<?php echo __( 'What is a group?', 'litespeed-cache') ; ?>">?</a>
23
- </p>
24
- <p>
25
- <?php if ( ! empty( $img_count[ 'total_not_requested' ] ) ) : ?>
26
- <?php echo __('Images not yet requested', 'litespeed-cache') ; ?>:
27
- <code><?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'total_not_requested' ] ) ; ?></code>
28
- <?php else : ?>
29
- <font class="litespeed-congratulate"><?php echo __('Congratulations, all done!', 'litespeed-cache') ; ?></font>
30
- <?php endif ; ?>
31
- </p>
32
- </div>
33
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/inc/img_optm.summary.php DELETED
@@ -1,312 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) {
3
- die ;
4
- }
5
-
6
- $closet_server = get_option( LiteSpeed_Cache_Admin_API::DB_API_CLOUD ) ;
7
- ?>
8
-
9
- <div class="litespeed-width-7-10">
10
- <div class="litespeed-empty-space-small"></div>
11
-
12
- <?php if ( $img_count[ 'total_not_requested' ] ) : ?>
13
- <div class="litespeed-text-center">
14
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_OPTIMIZE ) ; ?>" class="litespeed-btn-success litespeed-btn-large">
15
- <span class="dashicons dashicons-images-alt2"></span>&nbsp;<?php echo __( 'Send Optimization Request', 'litespeed-cache' ) ; ?>
16
- </a>
17
-
18
- </div>
19
-
20
- <div class="litespeed-empty-space-small"></div>
21
-
22
- <div class="litespeed-desc">
23
- <?php if ( $closet_server ) : ?>
24
- <font title="<?php echo $closet_server ; ?>">☁️</font>
25
- <?php endif ; ?>
26
- <?php echo __( 'This will send the optimization request and the images to LiteSpeed\'s Image Optimization Server.', 'litespeed-cache' ) ; ?>
27
- <?php echo sprintf( __( 'You can send at most %s images at once.', 'litespeed-cache' ), '<code>' . $optm_summary[ 'credit' ] . '</code>' ) ; ?>
28
- </div>
29
- <?php endif ; ?>
30
-
31
- <?php if ( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ] && ! $is_running ) : ?>
32
- <div>
33
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_PULL ) ; ?>" class="litespeed-btn-success" title="<?php echo __( 'Only press the button if the pull cron job is disabled.', 'litespeed-cache' ) ; ?> <?php echo __( 'Images will be pulled automatically if the cron job is running.', 'litespeed-cache' ) ; ?>">
34
- <?php echo __( 'Pull Images', 'litespeed-cache' ) ; ?>
35
- </a>
36
- </div>
37
- <?php endif ; ?>
38
-
39
- <div class="litespeed-empty-space-medium"></div>
40
-
41
- <div>
42
- <h2 Class="litespeed-title">
43
- <?php echo __( 'Current Stage Status', 'litespeed-cache' ) ; ?>
44
- </h2>
45
- <div class="litespeed-empty-space-medium"></div>
46
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.level_info.php" ; ?>
47
-
48
- <hr class="litespeed-hr-dotted">
49
-
50
- <div class="litespeed-empty-space-small"></div>
51
-
52
- <div class="litespeed-light-code">
53
-
54
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_REQUESTED ] ) ) : ?>
55
- <p class="litespeed-success">
56
- <?php echo __('Images requested', 'litespeed-cache') ; ?>:
57
- <code>
58
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_REQUESTED ] ) ; ?>
59
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_REQUESTED ], 'image' ) ; ?>)
60
- </code>
61
- </p>
62
- <p class="litespeed-desc">
63
- <?php echo __( 'After LiteSpeed\'s Image Optimization Server finishes optimization, it will notify your site to pull the optimized images.', 'litespeed-cache' ) ; ?>
64
- <?php echo __( 'This process is automatic.', 'litespeed-cache' ) ; ?>
65
- </p>
66
- <?php endif ; ?>
67
-
68
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ] ) ) : ?>
69
- <p class="litespeed-success">
70
- <?php echo __('Images notified to pull', 'litespeed-cache') ; ?>:
71
- <code>
72
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ] ) ; ?>
73
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ], 'image' ) ; ?>)
74
- </code>
75
-
76
- </p>
77
- <?php if ( $last_run ) : ?>
78
- <p class="litespeed-desc">
79
- <?php echo sprintf( __( 'Last pull initiated by cron at %s.', 'litespeed-cache' ), '<code>' . LiteSpeed_Cache_Utility::readable_time( $last_run ) . '</code>' ) ; ?>
80
- </p>
81
- <?php endif ; ?>
82
- <?php endif ; ?>
83
-
84
- <div class="litespeed-empty-space-small"></div>
85
-
86
- <div class="litespeed-flex-container">
87
-
88
- <div class="litespeed-width-1-2">
89
-
90
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_PULLED ] ) ) : ?>
91
- <p class="litespeed-success">
92
- <?php echo __('Images optimized and pulled', 'litespeed-cache') ; ?>:
93
- <code>
94
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_PULLED ] ) ; ?>
95
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_PULLED ], 'image' ) ; ?>)
96
- </code>
97
- </p>
98
- <?php endif ; ?>
99
-
100
- <div class="litespeed-silence">
101
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_FETCH ] ) ) : ?>
102
- <p>
103
- <?php echo __('Images failed to fetch', 'litespeed-cache') ; ?>:
104
- <code>
105
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_FETCH ] ) ; ?>
106
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_FETCH ], 'image' ) ; ?>)
107
- </code>
108
- </p>
109
- <?php endif ; ?>
110
-
111
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_OPTM ] ) ) : ?>
112
- <p>
113
- <?php echo __('Images previously optimized', 'litespeed-cache') ; ?>:
114
- <code>
115
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_OPTM ] ) ; ?>
116
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR_OPTM ], 'image' ) ; ?>)
117
- </code>
118
- </p>
119
- <?php endif ; ?>
120
-
121
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR ] ) ) : ?>
122
- <p>
123
- <?php echo __('Images failed with other errors', 'litespeed-cache') ; ?>:
124
- <code>
125
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR ] ) ; ?>
126
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_ERR ], 'image' ) ; ?>)
127
- </code>
128
- </p>
129
- <?php endif ; ?>
130
-
131
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_MISS ] ) ) : ?>
132
- <p>
133
- <?php echo __('Image files missing', 'litespeed-cache') ; ?>:
134
- <code>
135
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_MISS ] ) ; ?>
136
- (<?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_MISS ], 'image' ) ; ?>)
137
- </code>
138
- </p>
139
- <?php endif ; ?>
140
-
141
- <?php if ( ! empty( $img_count[ 'group.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_XMETA ] ) ) : ?>
142
- <p>
143
- <?php echo __('Images with wrong meta', 'litespeed-cache') ; ?>:
144
- <code>
145
- <?php echo LiteSpeed_Cache_Admin_Display::print_plural( $img_count[ 'img.' . LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS_XMETA ] ) ; ?>
146
- </code>
147
- </p>
148
- <?php endif ; ?>
149
-
150
- <?php if ( ! empty( $optm_summary[ 'fetch_failed' ] ) ) : ?>
151
- <p>
152
- <?php echo __( 'Images failed to fetch', 'litespeed-cache' ) ; ?>: <code><?php echo $optm_summary[ 'fetch_failed' ] ; ?></code>
153
- </p>
154
- <?php endif ; ?>
155
-
156
- <?php if ( ! empty( $optm_summary[ 'notify_failed' ] ) ) : ?>
157
- <p>
158
- <?php echo __( 'Images failed to notify', 'litespeed-cache' ) ; ?>: <code><?php echo $optm_summary[ 'notify_failed' ] ; ?></code>
159
- </p>
160
- <?php endif ; ?>
161
-
162
- </div>
163
-
164
- <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>
165
-
166
- </div>
167
-
168
- <div class="litespeed-width-1-2">
169
- <?php echo LiteSpeed_Cache_GUI::img_optm_clean_up_unfinished() ; ?>
170
- </div>
171
-
172
- </div>
173
-
174
- <hr />
175
-
176
- <div class="litespeed-empty-space-small"></div>
177
-
178
- <h3 class="litespeed-title">
179
- <?php echo __( 'Storage Optimization', 'litespeed-cache' ) ; ?>
180
-
181
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_CALC_BKUP ) ; ?>" class="dashicons dashicons-update litepseed-dash-icon-success" title="<?php echo __( 'Calculate Original Image Storage', 'litespeed-cache' ) ; ?>">
182
- </a>
183
-
184
- </h3>
185
-
186
- <?php if ( $storage_data ) : ?>
187
- <div class="">
188
- <p>
189
- <?php echo __( 'Last calculated', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::readable_time( $storage_data[ 'date' ] ) . '</code>' ; ?>
190
- </p>
191
- <?php if ( $storage_data[ 'count' ] ) : ?>
192
- <p>
193
- <?php echo __( 'Files', 'litespeed-cache' ) . ': <code>' . $storage_data[ 'count' ] . '</code>' ; ?>
194
- </p>
195
- <p>
196
- <?php echo __( 'Total', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::real_size( $storage_data[ 'sum' ] ) . '</code>' ; ?>
197
- </p>
198
- <?php endif ; ?>
199
- </div>
200
- <?php endif ; ?>
201
-
202
- <br />
203
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_RM_BKUP ) ; ?>" data-litespeed-cfm="<?php echo __( 'Are you sure to remove all image backups?', 'litespeed-cache' ) ; ?>" class="litespeed-btn-danger">
204
- <span class="dashicons dashicons-trash"></span>&nbsp;<?php echo __( 'Remove Original Image Backups', 'litespeed-cache' ) ; ?>
205
- </a>
206
- <div class="litespeed-desc">
207
- <?php echo __( 'This will delete all of the backups of the original images.', 'litespeed-cache' ) ; ?>
208
- <div class="litespeed-danger">
209
- 🚨
210
- <?php echo __( 'This is irreversible.', 'litespeed-cache' ) ; ?>
211
- <?php echo __( 'You will be unable to Revert Optimization once the backups are deleted!', 'litespeed-cache' ) ; ?>
212
- </div>
213
- </div>
214
- <?php if ( $rm_log ) : ?>
215
- <div class="">
216
- <p>
217
- <?php echo __( 'Last ran', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::readable_time( $rm_log[ 'date' ] ) . '</code>' ; ?>
218
- </p>
219
- <p>
220
- <?php echo __( 'Files', 'litespeed-cache' ) . ': <code>' . $rm_log[ 'count' ] . '</code>' ; ?>
221
- </p>
222
- <p>
223
- <?php echo __( 'Saved', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::real_size( $rm_log[ 'sum' ] ) . '</code>' ; ?>
224
- </p>
225
- </div>
226
- <?php endif ; ?>
227
-
228
- <div class="litespeed-desc">
229
- <?php echo __( 'A backup of each image is saved before it is optimized.', 'litespeed-cache' ) ; ?>
230
- <?php echo __( 'The refresh button will calculate the total amount of disk space used by these backups.', 'litespeed-cache' ) ; ?>
231
- </div>
232
-
233
-
234
- </div>
235
- </div>
236
- </div>
237
-
238
- <div class="litespeed-width-3-10 litespeed-column-java litespeed-contrast" style="display: flex; flex-direction: column;">
239
- <div class="litespeed-hr">
240
- <?php include_once LSCWP_DIR . "admin/tpl/inc/img_optm.percentage_summary.php" ; ?>
241
- </div>
242
-
243
- <div class="litespeed-hr">
244
- <h3 class="litespeed-title">
245
- <?php echo __( 'Optimization Summary', 'litespeed-cache' ) ; ?>
246
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_SYNC_DATA ) ; ?>" class="dashicons dashicons-update litepseed-dash-icon-success" title="<?php echo __( 'Update Status', 'litespeed-cache' ) ; ?>">
247
- </a>
248
- </h3>
249
- <p>
250
- <?php echo __( 'Total Reduction', 'litespeed-cache' ) ; ?>: <code><?php echo LiteSpeed_Cache_Utility::real_size( $optm_summary[ 'reduced' ] ) ; ?></code>
251
- </p>
252
- <p>
253
- <?php echo __( 'Images Pulled', 'litespeed-cache' ) ; ?>: <code><?php echo $optm_summary[ 'img_taken' ] ; ?></code>
254
- </p>
255
- <p>
256
- <?php echo __( 'Last Request', 'litespeed-cache' ) ; ?>: <code><?php echo LiteSpeed_Cache_Utility::readable_time( $optm_summary[ 'last_requested' ] ) ; ?></code>
257
- </p>
258
- </div>
259
-
260
- <div class="litespeed-hr">
261
- <h3 class="litespeed-title"><?php echo __('Revert Optimization', 'litespeed-cache') ; ?></h3>
262
-
263
- <div class="litespeed-desc">
264
- <?php echo __( 'Switch all images in the media library back to their original unoptimized versions.', 'litespeed-cache' ) ; ?>
265
- </div>
266
-
267
- <div>
268
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IAPI, LiteSpeed_Cache_Admin_API::TYPE_RESET_KEY ) ; ?>" class="litespeed-btn-warning" title="<?php echo __( 'The current IAPI key must be reset after changing home URL or domain before making any further optimization requests.', 'litespeed-cache' ) ; ?>">
269
- <span class="dashicons dashicons-image-rotate"></span>&nbsp;<?php echo __( 'Reset IAPI Key', 'litespeed-cache' ) ; ?>
270
- </a>
271
- <br />
272
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_ORI ) ; ?>" class="litespeed-btn-success" title="<?php echo __( 'Revert all optimized images back to their original versions.', 'litespeed-cache' ) ; ?>">
273
- <span class="dashicons dashicons-undo"></span>&nbsp;<?php echo __( 'Undo Optimization', 'litespeed-cache' ) ; ?>
274
- </a>
275
-
276
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_BATCH_SWITCH_OPTM ) ; ?>" class="litespeed-btn-success" title="<?php echo __( 'Switch back to using optimized images.', 'litespeed-cache' ) ; ?>">
277
- <span class="dashicons dashicons-redo"></span>&nbsp;<?php echo __( 'Re-do Optimization', 'litespeed-cache' ) ; ?>
278
- </a>
279
-
280
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_OPTIMIZE_RESCAN ) ; ?>" class="litespeed-btn-success litespeed-hide" title="<?php echo __( 'Scan for any new unoptimized image thumbnail sizes and resend necessary image optimization requests.', 'litespeed-cache' ) ; ?>">
281
- <?php echo __( 'Send New Thumbnail Requests', 'litespeed-cache' ) ; ?>
282
- </a>
283
-
284
- <p>
285
- <?php echo sprintf( __( 'Results can be checked in <a %s>Media Library</a>.', 'litespeed-cache' ), 'href="upload.php?mode=list"' ) ; ?>
286
- </p>
287
-
288
- </div>
289
-
290
- </div>
291
-
292
- <div style="flex-grow: 1;"></div>
293
-
294
- <!-- <div class="litespeed-empty-space-xlarge">
295
- </div>-->
296
- <div class="">
297
-
298
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_OPTM_DESTROY ) ; ?>" class="litespeed-btn-danger">
299
- <span class="dashicons dashicons-dismiss"></span>&nbsp;<?php echo __( 'Destroy All Optimization Data!', 'litespeed-cache' ) ; ?>
300
- </a>
301
-
302
- <div class="litespeed-desc">
303
- <?php echo __( 'Remove all previous image optimization requests/results, revert completed optimizations, and delete all optimization files.', 'litespeed-cache' ) ; ?>
304
- <div class="litespeed-warning">
305
- ⚠️
306
- <?php echo __( 'This will also reset the credit level.', 'litespeed-cache' ) ; ?>
307
- </div>
308
- </div>
309
-
310
-
311
-
312
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage.php DELETED
@@ -1,56 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $menu_list = array(
5
- 'purge' => __('Purge', 'litespeed-cache'),
6
- 'db' => __('DB Optimizer', 'litespeed-cache'),
7
- ) ;
8
-
9
- if ( ! is_network_admin() ) {
10
- $menu_list[ 'cdn' ] = __( 'CDN', 'litespeed-cache' ) ;
11
- }
12
-
13
- ?>
14
-
15
- <div class="wrap">
16
- <h1 class="litespeed-h1">
17
- <?php
18
- if ( is_network_admin() ) {
19
- echo __('LiteSpeed Cache Network Management', 'litespeed-cache');
20
- }
21
- else {
22
- echo __('LiteSpeed Cache Management', 'litespeed-cache');
23
- }
24
- ?>
25
- </h1>
26
- <span class="litespeed-desc">
27
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
28
- </span>
29
- <hr class="wp-header-end">
30
- </div>
31
-
32
- <div class="litespeed-wrap">
33
- <h2 class="litespeed-header">
34
- <?php
35
- $i = 1 ;
36
- foreach ($menu_list as $tab => $val){
37
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
38
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>" ;
39
- $i ++ ;
40
- }
41
- ?>
42
- </h2>
43
-
44
- <div class="litespeed-body">
45
- <?php
46
-
47
- // include all tpl for faster UE
48
- foreach ($menu_list as $tab => $val) {
49
- echo "<div data-litespeed-layout='$tab'>" ;
50
- require LSCWP_DIR . "admin/tpl/manage/manage_$tab.php" ;
51
- echo "</div>" ;
52
- }
53
-
54
- ?>
55
- </div>
56
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/manage/manage_db.php DELETED
@@ -1,93 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $_panels = array(
5
- 'all' => array(
6
- 'title' => __( 'Clean All', 'litespeed-cache' ),
7
- 'desc' => '',
8
- ),
9
- 'revision' => array(
10
- 'title' => __( 'Post Revisions', 'litespeed-cache' ),
11
- 'desc' => __( 'Clean all post revisions', 'litespeed-cache' ),
12
- ),
13
- 'auto_draft' => array(
14
- 'title' => __( 'Auto Drafts', 'litespeed-cache' ),
15
- 'desc' => __( 'Clean all auto saved drafts', 'litespeed-cache' ),
16
- ),
17
- 'trash_post' => array(
18
- 'title' => __( 'Trashed Posts', 'litespeed-cache' ),
19
- 'desc' => __( 'Clean all trashed posts and pages', 'litespeed-cache' ),
20
- ),
21
- 'spam_comment' => array(
22
- 'title' => __( 'Spam Comments', 'litespeed-cache' ),
23
- 'desc' => __( 'Clean all spam comments', 'litespeed-cache' ),
24
- ),
25
- 'trash_comment' => array(
26
- 'title' => __( 'Trashed Comments', 'litespeed-cache' ),
27
- 'desc' => __( 'Clean all trashed comments', 'litespeed-cache' ),
28
- ),
29
- 'trackback-pingback' => array(
30
- 'title' => __( 'Trackbacks/Pingbacks', 'litespeed-cache' ),
31
- 'desc' => __( 'Clean all trackbacks and pingbacks', 'litespeed-cache' ),
32
- ),
33
- 'expired_transient' => array(
34
- 'title' => __( 'Expired Transients', 'litespeed-cache' ),
35
- 'desc' => __( 'Clean expired transient options', 'litespeed-cache' ),
36
- ),
37
- 'all_transients' => array(
38
- 'title' => __( 'All Transients', 'litespeed-cache' ),
39
- 'desc' => __( 'Clean all transient options', 'litespeed-cache' ),
40
- ),
41
- 'optimize_tables' => array(
42
- 'title' => __( 'Optimize Tables', 'litespeed-cache' ),
43
- 'desc' => __( 'Optimize all tables in your database', 'litespeed-cache' ),
44
- ),
45
- 'all_cssjs' => array(
46
- 'title' => __( 'Clean CSS/JS Optimizer', 'litespeed-cache' ),
47
- 'desc' => __( 'Purge all and clean all minified/combined CSS/JS data', 'litespeed-cache' ),
48
- 'dismiss_count_icon' => true,
49
- 'title_cls' => 'litespeed-warning',
50
- ),
51
- ) ;
52
-
53
- $total = 0 ;
54
- foreach ( $_panels as $tag => $v ) {
55
- if ( $tag != 'all' ) {
56
- $_panels[ $tag ][ 'count' ] = LiteSpeed_Cache_Admin_Optimize::db_count( $tag ) ;
57
- if ( ! in_array( $tag, array( 'all_cssjs', 'optimize_tables' ) ) ) {
58
- $total += $_panels[ $tag ][ 'count' ] ;
59
- }
60
- }
61
- $_panels[ $tag ][ 'link' ] = LiteSpeed_Cache_Admin_Optimize::generate_url( $tag ) ;
62
- }
63
-
64
- $_panels[ 'all' ][ 'count' ] = $total ;
65
-
66
- ?>
67
-
68
- <h3 class="litespeed-title"><?php echo __('Database Optimizer', 'litespeed-cache'); ?></h3>
69
-
70
- <div class="litespeed-panel-wrapper">
71
-
72
- <?php foreach ( $_panels as $tag => $v ): ?>
73
-
74
- <a href="<?php echo $v[ 'link' ] ; ?>" class="litespeed-panel">
75
- <section class="litespeed-panel-wrapper-icon">
76
- <span class="litespeed-panel-icon-<?php echo $tag ; ?>"></span>
77
- </section>
78
- <section class="litespeed-panel-content">
79
- <div class="litespeed-h3 <?php if ( ! empty( $v[ 'title_cls' ] ) ) echo $v[ 'title_cls' ] ; ?>">
80
- <?php echo $v[ 'title' ] ; ?>
81
- <span class="litespeed-panel-counter<?php if ( $v[ 'count' ] > 0 && empty( $v[ 'dismiss_count_icon' ] ) ) echo '-red' ; ?>">(<?php echo $v[ 'count' ] ; ?>)</span>
82
- </div>
83
- <span class="litespeed-panel-para"><?php echo $v[ 'desc' ] ; ?></span>
84
- </section>
85
- <?php if ( empty( $v[ 'dismiss_count_icon' ] ) ) : ?>
86
- <section class="litespeed-panel-wrapper-top-right">
87
- <span class="litespeed-panel-top-right-icon<?php echo $v[ 'count' ] > 0 ? '-cross' : '-tick' ; ?>"></span>
88
- </section>
89
- <?php endif; ?>
90
- </a>
91
- <?php endforeach; ?>
92
-
93
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/network_settings.php DELETED
@@ -1,60 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- $menuArr = array(
5
- 'general' => __('General', 'litespeed-cache'),
6
- 'cache' => __('Cache', 'litespeed-cache'),
7
- 'purge' => __('Purge', 'litespeed-cache'),
8
- 'excludes' => __('Excludes', 'litespeed-cache'),
9
- 'media' => __('Media', 'litespeed-cache'),
10
- 'advanced' => __('Advanced', 'litespeed-cache'),
11
- );
12
-
13
- global $_options;
14
- $_options = LiteSpeed_Cache_Config::get_instance()->get_site_options();
15
-
16
- $_hide_in_basic_mode = '' ;
17
-
18
- ?>
19
-
20
- <div class="wrap">
21
- <h1 class="litespeed-h1">
22
- <?php echo __('LiteSpeed Cache Network Settings', 'litespeed-cache'); ?>
23
- </h1>
24
- <span class="litespeed-desc">
25
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
26
- </span>
27
- <hr class="wp-header-end">
28
-
29
- </div>
30
- <div class="litespeed-wrap">
31
- <h2 class="litespeed-header">
32
- <?php
33
- $i = 1 ;
34
- foreach ($menuArr as $tab => $val){
35
- $accesskey = $i <= 9 ? "litespeed-accesskey='$i'" : '' ;
36
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>";
37
- $i ++ ;
38
- }
39
- ?>
40
- </h2>
41
- <div class="litespeed-body">
42
- <form method="post" action="admin.php?page=lscache-settings" id="litespeed_form_options" class="litespeed-relative">
43
- <?php
44
- $this->form_action(LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK);
45
-
46
- // include all tpl for faster UE
47
- foreach ($menuArr as $tab => $val) {
48
- echo "<div data-litespeed-layout='$tab'>";
49
- require LSCWP_DIR . "admin/tpl/setting/network_settings_$tab.php" ;
50
- echo "</div>";
51
- }
52
-
53
- echo "<div class='litespeed-top20'></div>";
54
-
55
- submit_button();
56
-
57
- ?>
58
- </form>
59
- </div>
60
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/report.php DELETED
@@ -1,92 +0,0 @@
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
- // Detect password less plugin
10
- $link = '';
11
- $has_pswdless_plugin = false;
12
- if ( function_exists( 'dologin_gen_link' ) ) {
13
- $has_pswdless_plugin = true;
14
- if ( ! empty( $_GET[ 'dologin_gen_link' ] ) ) {
15
- unset( $_GET[ 'dologin_gen_link' ] );
16
- $link = dologin_gen_link( 'Litespeed Report' );
17
- ?>
18
- <script>window.history.pushState( 'remove_gen_link', document.title, window.location.href.replace( '&dologin_gen_link=1', '' ) );</script>
19
- <?php
20
- }
21
- }
22
-
23
- $install_link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_INSTALL_3RD, false, null, array( 'plugin' => 'dologin' ) );
24
- ?>
25
-
26
- <div class="wrap">
27
- <h1 class="litespeed-h1">
28
- <?php echo __('LiteSpeed Cache Report', 'litespeed-cache'); ?>
29
- </h1>
30
- <span class="litespeed-desc">
31
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION; ?>
32
- </span>
33
- <hr class="wp-header-end">
34
- </div>
35
-
36
- <div class="litespeed-wrap">
37
- <div class="litespeed-body">
38
- <?php if ( ! $has_pswdless_plugin ) : ?>
39
- <div class="litespeed-callout-danger">
40
- <h4><?php echo __('NOTICE:', 'litespeed-cache'); ?></h4>
41
- <?php echo sprintf( __('To generate a passwordless link for LiteSpeed Support Team access, you must install %s.', 'litespeed-cache'), '<a href="https://wordpress.org/plugins/dologin/" target="_blank">DoLogin Security</a>' ); ?>
42
- <a href="<?php echo $install_link; ?>" class="litespeed-btn-success"><?php echo __('Automatically Install', 'litespeed-cache'); ?></a>
43
- <a href="plugin-install.php?s=dologin+security&tab=search&type=term" target="_blank"><?php echo __('Manually Install', 'litespeed-cache'); ?></a>
44
- </div>
45
- <?php endif; ?>
46
-
47
- <h3 class="litespeed-title"><?php echo __('LiteSpeed Report Number', 'litespeed-cache') ; ?></h3>
48
-
49
- <p><?php echo __('Report number', 'litespeed-cache') ; ?>: <b><?php echo $env_ref[ 'num' ] ; ?></b></p>
50
- <p><?php echo __('Report date', 'litespeed-cache') ; ?>: <b><?php echo $env_ref[ 'dateline' ] ; ?></b></p>
51
-
52
- <?php include_once LSCWP_DIR . "admin/tpl/inc/api_key.php" ; ?>
53
-
54
- <h3 class="litespeed-title"><?php echo __('Report Summary', 'litespeed-cache') ; ?></h3>
55
- <div class="litespeed-desc">
56
- <?php echo __('The environment report contains detailed information about the WordPress configuration.', 'litespeed-cache'); ?>
57
- <br />
58
- <?php echo __('If you run into any issues, please refer to the report number in your support message.', 'litespeed-cache'); ?>
59
- </div>
60
-
61
- <form action="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_REPORT, LiteSpeed_Cache_Admin_Report::TYPE_SEND_REPORT ) ; ?>" method="post">
62
-
63
- <textarea id="litespeed-report" rows="20" cols="100" readonly><?php echo $report; ?></textarea>
64
-
65
- <p>
66
- Link: <input type="text" class="litespeed-regular-text" id="litespeed-report-link" name="link" value="<?php echo $link; ?>" />
67
- <?php if ( $has_pswdless_plugin ) : ?>
68
- <a href="<?php echo admin_url( 'admin.php?page=lscache-report&dologin_gen_link=1' ); ?>"><?php echo __( 'Generate Passwordless Link for Current User', 'litespeed-cache' ) ; ?></a>
69
- <?php else: ?>
70
- <a href="<?php echo $install_link; ?>" class="litespeed-btn-success"><?php echo __( 'Install DoLogin Security to Generate Passwordless Link', 'litespeed-cache' ) ; ?></a>
71
- <?php endif; ?>
72
- </p>
73
- <p>
74
- <?php if ( $link ) : ?>
75
- <strong><?php echo __('Please do NOT share the above passwordless link with anyone.', 'litespeed-cache'); ?></strong>
76
- <strong><?php echo sprintf( __('Generated links may be managed under <a %s>Settings</a>.', 'litespeed-cache'), 'href="' . menu_page_url( 'dologin', 0 ) . '"' ); ?></strong>
77
- <?php endif; ?>
78
- </p>
79
-
80
- <p class="litespeed-desc"><?php echo __( 'To grant wp-admin access to the LiteSpeed Support Team, please generate a passwordless link for the current logged-in user to be sent with the report.', 'litespeed-cache' ) ; ?></p>
81
-
82
- <button class="litespeed-btn-warning" type="submit">
83
- <?php echo __( 'Send To LiteSpeed', 'litespeed-cache' ) ; ?>
84
- </button>
85
- <span class="litespeed-desc">
86
- <?php echo __( 'Send this report to LiteSpeed. Refer to this report number when posting in the WordPress support forum.', 'litespeed-cache' ) ; ?>
87
- </span>
88
- </form>
89
-
90
- </div>
91
- </div>
92
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/network_settings_advanced.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Advanced Network', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <table><tbody>
7
-
8
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_object.php' ; ?>
9
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_browser.php' ; ?>
10
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.check_adv_file.php' ; ?>
11
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.login_cookie.php' ; ?>
12
-
13
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/network_settings_cache.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Cache Control Network Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <p>
7
- <?php echo __( 'Separate Mobile Views should be enabled if any of the network enabled themes require a different view for mobile devices.', 'litespeed-cache' ) ; ?>
8
- <?php echo __( 'Responsive themes can handle this part automatically.', 'litespeed-cache' ) ; ?>
9
- </p>
10
-
11
- <table><tbody>
12
-
13
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_favicon.php' ; ?>
14
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_resources.php' ; ?>
15
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_mobile.php' ; ?>
16
-
17
- </tbody></table>
18
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/network_settings_excludes.php DELETED
@@ -1,15 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <h3 class="litespeed-title"><?php echo __('Network Do Not Cache Rules', 'litespeed-cache'); ?></h3>
6
-
7
- <table><tbody>
8
-
9
- <!-- User Agent List -->
10
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.exclude_useragent.php'; ?>
11
-
12
- <!-- Cookie List -->
13
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.exclude_cookies.php'; ?>
14
-
15
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/network_settings_media.php DELETED
@@ -1,10 +0,0 @@
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 LSCWP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ; ?>
9
-
10
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/network_settings_purge.php DELETED
@@ -1,10 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
- <h3 class="litespeed-title"><?php echo __( 'Purge Network Settings', 'litespeed-cache' ) ; ?></h3>
5
-
6
- <table><tbody>
7
-
8
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.purge_on_upgrade.php' ; ?>
9
-
10
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_advanced.php DELETED
@@ -1,121 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- // $current_favicon = get_option( LiteSpeed_Cache_Config::ITEM_FAVICON, array() ) ;
5
-
6
- ?>
7
-
8
- <h3 class="litespeed-title-short">
9
- <?php echo __('Advanced Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:advanced', false, 'litespeed-learn-more' ) ; ?>
11
- </h3>
12
-
13
- <div class="litespeed-callout-danger">
14
- <h4><?php echo __('NOTICE:', 'litespeed-cache'); ?></h4>
15
- <?php echo __('These settings are meant for ADVANCED USERS ONLY.', 'litespeed-cache'); ?>
16
- </div>
17
-
18
- <table><tbody>
19
-
20
- <?php
21
- if ( ! is_multisite() ) :
22
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_object.php' ;
23
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_browser.php' ;
24
-
25
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.check_adv_file.php' ;
26
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.login_cookie.php' ;
27
- endif ;
28
- ?>
29
-
30
- <tr>
31
- <th><?php echo __( 'Purge All Hooks', 'litespeed-cache' ) ; ?></th>
32
- <td>
33
- <?php $id = LiteSpeed_Cache_Config::ITEM_ADV_PURGE_ALL_HOOKS ; ?>
34
- <?php $this->build_textarea2( $id, 50 ) ; ?>
35
- <?php $this->recommended( $id, true ) ; ?>
36
-
37
- <div class="litespeed-desc">
38
- <?php echo __( 'A Purge All will be executed when WordPress runs these hooks.', 'litespeed-cache' ) ; ?>
39
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:advanced#hooks_to_purge_all' ) ; ?>
40
- </div>
41
- </td>
42
- </tr>
43
-
44
- <tr>
45
- <th><?php echo __( 'Improve HTTP/HTTPS Compatibility', 'litespeed-cache' ) ; ?></th>
46
- <td>
47
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_USE_HTTP_FOR_HTTPS_VARY ) ; ?>
48
- <div class="litespeed-desc">
49
- <?php echo __( 'Enable this option if you are using both HTTP and HTTPS in the same domain and are noticing cache irregularities.', 'litespeed-cache' ) ; ?>
50
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:advanced#improve_http_https_compatibility' ) ; ?>
51
- </div>
52
- </td>
53
- </tr>
54
-
55
- <tr>
56
- <th><?php echo __( 'Instant Click', 'litespeed-cache' ) ; ?></th>
57
- <td>
58
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_ADV_INSTANT_CLICK ) ; ?>
59
- <div class="litespeed-desc">
60
- <?php echo __( 'When a vistor hovers over a page link, preload that page. This will speed up the visit to that link.', 'litespeed-cache' ) ; ?>
61
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:advanced#instant_click' ) ; ?>
62
- <br /><font class="litespeed-danger">
63
- ⚠️
64
- <?php echo __('This will generate extra requests to the server, which will increase server load.', 'litespeed-cache'); ?>
65
- </font>
66
-
67
- </div>
68
- </td>
69
- </tr>
70
-
71
- <?php /*
72
- <tr>
73
- <th><?php echo __( 'Favicon', 'litespeed-cache' ) ; ?></th>
74
- <td>
75
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_ADV_FAVICON ) ; ?>
76
- <div class="litespeed-desc">
77
- <?php echo __( 'Enable this option to use uploaded image as favicon.ico.', 'litespeed-cache' ) ; ?>
78
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:advanced#favicon" target="_blank"><?php echo __('Learn More', 'litespeed-cache') ; ?></a>
79
-
80
- </div>
81
- <div class="litespeed-block">
82
- <div class='litespeed-cdn-mapping-col1'>
83
- <h4><?php echo __( 'Frontend Favicon File', 'litespeed-cache' ) ; ?></h4>
84
-
85
- <input type="file" name="litespeed-file-favicon_frontend" class="litespeed-input-long">
86
- <div class="litespeed-desc">
87
- <a href="https://favicon.io/converter?hello=litespeed" target="_blank"><?php echo __( 'A sample online favicon generator.', 'litespeed-cache' ) ; ?></a>
88
- </div>
89
- </div>
90
-
91
- <div class='litespeed-cdn-mapping-col litespeed-abs-center'>
92
- <?php
93
- if ( ! empty( $current_favicon[ 'frontend' ] ) ) {
94
- echo "
95
- <img src='$current_favicon[frontend]' style='max-height:200px;max-width:200px;' />
96
- ";
97
- }
98
- ?>
99
- </div>
100
- <div class='litespeed-cdn-mapping-col1'>
101
- <h4><?php echo __( 'Backend Favicon File', 'litespeed-cache' ) ; ?></h4>
102
-
103
- <input type="file" name="litespeed-file-favicon_backend" class="litespeed-input-long">
104
- </div>
105
-
106
- <div class='litespeed-cdn-mapping-col litespeed-abs-center'>
107
- <?php
108
- if ( ! empty( $current_favicon[ 'backend' ] ) ) {
109
- echo "
110
- <img src='$current_favicon[backend]' style='max-height:200px;max-width:200px;' />
111
- ";
112
- }
113
- ?>
114
- </div>
115
- </div>
116
-
117
- </td>
118
- </tr>
119
- */ ?>
120
-
121
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_cache.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
-
5
- <h3 class="litespeed-title-short">
6
- <?php echo __('Cache Control Settings', 'litespeed-cache'); ?>
7
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache', false, 'litespeed-learn-more' ) ; ?>
8
- </h3>
9
-
10
- <?php $this->cache_disabled_warning() ; ?>
11
-
12
- <table><tbody>
13
- <tr>
14
- <th><?php echo __( 'Cache Logged-in Users', 'litespeed-cache' ) ; ?></th>
15
- <td>
16
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_PRIV ) ; ?>
17
- <div class="litespeed-desc">
18
- <?php echo sprintf( __( 'Privately cache frontend pages for logged-in users. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.1+' ) ; ?>
19
- </div>
20
- </td>
21
- </tr>
22
-
23
- <tr>
24
- <th><?php echo __( 'Cache Commenters', 'litespeed-cache' ) ; ?></th>
25
- <td>
26
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_COMMENTER ) ; ?>
27
- <div class="litespeed-desc">
28
- <?php echo sprintf( __( 'Privately cache commenters that have pending comments. Disabling this option will serve non-cacheable pages to commenters. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.1+' ) ; ?>
29
- </div>
30
- </td>
31
- </tr>
32
-
33
- <tr>
34
- <th><?php echo __( 'Cache REST API', 'litespeed-cache' ) ; ?></th>
35
- <td>
36
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ; ?>
37
- <div class="litespeed-desc">
38
- <?php echo __( 'Cache requests made by WordPress REST API calls.', 'litespeed-cache' ) ; ?>
39
- </div>
40
- </td>
41
- </tr>
42
-
43
- <tr>
44
- <th><?php echo __( 'Cache Login Page', 'litespeed-cache' ) ; ?></th>
45
- <td>
46
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_PAGE_LOGIN ) ; ?>
47
- <div class="litespeed-desc">
48
- <?php echo __( 'Disabling this option may negatively affect performance.', 'litespeed-cache' ) ; ?>
49
- </div>
50
- </td>
51
- </tr>
52
-
53
- <?php
54
- if ( ! is_multisite() ) :
55
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_favicon.php' ;
56
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_resources.php' ;
57
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.cache_mobile.php' ;
58
- endif ;
59
- ?>
60
-
61
- <tr <?php echo $_hide_in_basic_mode ; ?>>
62
- <th><?php echo __( 'Private Cached URIs', 'litespeed-cache' ) ; ?></th>
63
- <td>
64
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_CACHE_URI_PRIV ) ; ?>
65
- <div class="litespeed-desc">
66
- <?php echo __('URI Paths containing these strings will NOT be cached as public.', 'litespeed-cache'); ?>
67
- <?php $this->_uri_usage_example() ; ?>
68
- </div>
69
- </td>
70
- </tr>
71
-
72
- <tr <?php echo $_hide_in_basic_mode ; ?>>
73
- <th><?php echo __( 'Drop Query String', 'litespeed-cache' ) ; ?></th>
74
- <td>
75
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_CACHE_DROP_QS, 40 ) ; ?>
76
- <div class="litespeed-desc">
77
- <?php echo __('Ignore certain query strings when caching.', 'litespeed-cache'); ?>
78
- <?php echo sprintf( __( 'For example, to drop parameters beginning with %s, %s can be used here.', 'litespeed-cache' ), '<code>utm</code>', '<code>utm*</code>' ) ; ?>
79
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:drop_query_string' ) ; ?>
80
-
81
- <br />
82
- <i>
83
- <?php echo __('One per line.', 'litespeed-cache'); ?>
84
- </i>
85
- </div>
86
- </td>
87
- </tr>
88
-
89
- </tbody></table>
90
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_cdn.php DELETED
@@ -1,273 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $home_url = home_url( '/' ) ;
5
- $parsed = parse_url( $home_url ) ;
6
- $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url ) ;
7
- $cdn_url = 'https://cdn.' . substr( $home_url, 2 ) ;
8
-
9
- $cdn_mapping = $this->config->get_item( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) ;
10
-
11
- ?>
12
-
13
- <h3 class="litespeed-title-short">
14
- <?php echo __('CDN Settings', 'litespeed-cache'); ?>
15
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cdn', false, 'litespeed-learn-more' ) ; ?>
16
- </h3>
17
-
18
- <table><tbody>
19
- <tr>
20
- <th><?php echo __( 'Enable CDN', 'litespeed-cache' ) ; ?></th>
21
- <td>
22
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN ) ; ?>
23
- <div class="litespeed-desc">
24
- <?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ) ; ?>
25
- <?php echo sprintf( __( 'If using Cloudflare, leave this setting %s and use Cloudflare API setting below.', 'litespeed-cache' ), '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?>
26
- </div>
27
- </td>
28
- </tr>
29
-
30
- <tr>
31
- <th class="litespeed-padding-left"><?php echo __( 'CDN Mapping', 'litespeed-cache' ) ; ?></th>
32
- <td>
33
- <?php foreach ( $cdn_mapping as $v ) : ?>
34
-
35
- <div class="litespeed-block" data-litespeed-cdn-mapping="1">
36
- <div class='litespeed-cdn-mapping-col1'>
37
- <h4><?php echo __( 'CDN URL', 'litespeed-cache' ) ; ?>
38
- <button type="button" class="litespeed-btn-danger" data-litespeed-cdn-mapping-del="1">X</button>
39
- </h4>
40
-
41
- <?php
42
- $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL ;
43
- $this->build_input( "[" . LiteSpeed_Cache_Config::ITEM_CDN_MAPPING . "][$id][]", 'litespeed-input-long', $v[ $id ] ) ;
44
- ?>
45
- <div class="litespeed-desc">
46
- <?php echo sprintf( __( 'CDN URL to be used. For example, %s', 'litespeed-cache' ), '<code>' . $cdn_url . '</code>' ) ; ?>
47
- </div>
48
- </div>
49
-
50
- <div class='litespeed-cdn-mapping-col2'>
51
- <div class="litespeed-row">
52
- <div class="litespeed-cdn-mapping-inc"><?php echo __( 'Include Images', 'litespeed-cache' ) ; ?></div>
53
- <?php
54
- $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG ;
55
- $this->build_toggle( "[" . LiteSpeed_Cache_Config::ITEM_CDN_MAPPING . "][$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
56
- ?>
57
- </div>
58
- <div class="litespeed-row">
59
- <div class="litespeed-cdn-mapping-inc"><?php echo __( 'Include CSS', 'litespeed-cache' ) ; ?></div>
60
- <?php
61
- $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS ;
62
- $this->build_toggle( "[" . LiteSpeed_Cache_Config::ITEM_CDN_MAPPING . "][$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
63
- ?>
64
- </div>
65
- <div class="litespeed-row">
66
- <div class="litespeed-cdn-mapping-inc"><?php echo __( 'Include JS', 'litespeed-cache' ) ; ?></div>
67
- <?php
68
- $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS ;
69
- $this->build_toggle( "[" . LiteSpeed_Cache_Config::ITEM_CDN_MAPPING . "][$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
70
- ?>
71
- </div>
72
- </div>
73
-
74
- <div class='litespeed-cdn-mapping-col3'>
75
- <div class="litespeed-row">
76
- <div class="litespeed-cdn-mapping-col3-title"><?php echo __( 'Include File Types', 'litespeed-cache' ) ; ?></div>
77
- <?php $id = LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE ; ?>
78
- <?php $this->build_textarea( "[" . LiteSpeed_Cache_Config::ITEM_CDN_MAPPING . "][$id][]", 17, $v[ $id ] ) ; ?>
79
- </div>
80
- </div>
81
- </div>
82
-
83
- <?php endforeach ; ?>
84
-
85
- <p><button type="button" class="litespeed-btn-success litespeed-btn-tiny" id="litespeed-cdn-mapping-add">+</button></p>
86
-
87
- <div class="litespeed-warning">
88
- <?php echo __('NOTE', 'litespeed-cache'); ?>:
89
- <?php echo __( 'To randomize CDN hostname, define multiple hostnames for the same resources.', 'litespeed-cache' ) ; ?>
90
- </div>
91
-
92
- <div class="litespeed-desc">
93
- <b><?php echo __( 'Include Images', 'litespeed-cache' ) ; ?></b>:
94
- <?php echo sprintf( __( 'Serve all image files through the CDN. This will affect all attachments, HTML %s tags, and CSS %s attributes.', 'litespeed-cache' ), '<code>&lt;img</code>', '<code>url()</code>' ) ; ?>
95
-
96
- <br />
97
- <b><?php echo __( 'Include CSS', 'litespeed-cache' ) ; ?></b>:
98
- <?php echo __( 'Serve all CSS files through the CDN. This will affect all enqueued WP CSS files.', 'litespeed-cache' ) ; ?>
99
-
100
- <br />
101
- <b><?php echo __( 'Include JS', 'litespeed-cache' ) ; ?></b>:
102
- <?php echo __( 'Serve all JavaScript files through the CDN. This will affect all enqueued WP JavaScript files.', 'litespeed-cache' ) ; ?>
103
-
104
- <br />
105
- <b><?php echo __( 'Include File Types', 'litespeed-cache' ) ; ?></b>:
106
- <?php echo __( 'Static file type links to be replaced by CDN links.', 'litespeed-cache' ) ; ?>
107
- <?php echo __('One per line.', 'litespeed-cache'); ?>
108
- <?php echo sprintf( __( 'This will affect all tags containing attributes: %s %s %s.', 'litespeed-cache' ), '<code>src=""</code>', '<code>data-src=""</code>', '<code>href=""</code>' ) ; ?>
109
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cdn#include_file_types', __( 'Default value', 'litespeed-cache' ) ) ; ?>
110
-
111
- <br />
112
- <?php echo sprintf( __( 'If you turn any of the above settings OFF, please remove the related file types from the %s box.' ), '<b>' . __( 'Include File Types', 'litespeed-cache' ) . '</b>' ) ; ?>
113
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cdn#include_file_types' ) ; ?>
114
- </div>
115
-
116
- </td>
117
- </tr>
118
-
119
- <tr>
120
- <th class="litespeed-padding-left"><?php echo __( 'Original URLs', 'litespeed-cache' ) ; ?></th>
121
- <td>
122
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_ORI, 'litespeed-input-long' ) ; ?>
123
- <div class="litespeed-desc">
124
- <?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s.', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ) ; ?>
125
- <br /><?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>//www.aa.com</code>', '<code>//aa.com</code>', '<code>//*aa.com</code>' ) ; ?>
126
- <br /><?php echo sprintf( __( 'Separate multiple original URLs with a %s.', 'litespeed-cache' ), '<code>,</code>' ) ; ?>
127
- </div>
128
- </td>
129
- </tr>
130
-
131
- <tr>
132
- <th class="litespeed-padding-left"><?php echo __( 'Included Directories', 'litespeed-cache' ) ; ?></th>
133
- <td>
134
- <?php $id = LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR ; ?>
135
- <?php $this->build_textarea2( $id, 40 ) ; ?>
136
- <?php $this->recommended( $id, true ) ; ?>
137
- <div class="litespeed-desc">
138
- <?php echo __( 'Only files within these directories will be pointed to the CDN.', 'litespeed-cache' ) ; ?>
139
- <?php echo __('One per line.', 'litespeed-cache'); ?>
140
- </div>
141
- </td>
142
- </tr>
143
-
144
- <tr>
145
- <th class="litespeed-padding-left"><?php echo __( 'Exclude Path', 'litespeed-cache' ) ; ?></th>
146
- <td>
147
- <?php $id = LiteSpeed_Cache_Config::OPID_CDN_EXCLUDE ; ?>
148
- <?php $this->build_textarea( $id ) ; ?>
149
- <div class="litespeed-desc">
150
- <?php echo __( 'Paths containing these strings will not be served from the CDN.', 'litespeed-cache' ) ; ?>
151
- <?php echo __('One per line.', 'litespeed-cache'); ?>
152
- </div>
153
- </td>
154
- </tr>
155
-
156
- <tr>
157
- <th><?php echo __( 'Load JQuery Remotely', 'litespeed-cache' ) ; ?></th>
158
- <td>
159
- <div class="litespeed-switch">
160
- <?php echo $this->build_radio(
161
- LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY,
162
- LiteSpeed_Cache_Config::VAL_OFF,
163
- __( 'OFF', 'litespeed-cache' )
164
- ) ; ?>
165
-
166
- <?php echo $this->build_radio(
167
- LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY,
168
- LiteSpeed_Cache_Config::VAL_ON,
169
- 'Google'
170
- ) ; ?>
171
-
172
- <?php echo $this->build_radio(
173
- LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY,
174
- LiteSpeed_Cache_Config::VAL_ON2,
175
- 'Cdnjs'
176
- ) ; ?>
177
- </div>
178
- <div class="litespeed-desc">
179
- <?php echo __( 'Improve page load time by loading jQuery from a remote CDN service instead of locally.', 'litespeed-cache' ) ; ?>
180
- </div>
181
- </td>
182
- </tr>
183
-
184
- <tr>
185
- <th><?php echo __( 'Quic Cloud API', 'litespeed-cache' ) ; ?></th>
186
- <td>
187
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_CDN_QUIC ) ; ?>
188
- <div class="litespeed-desc">
189
- <?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Quic Cloud' ) ; ?>
190
-
191
- <a id='litespeed_modal_href' href="https://quic.cloud" target="_blank">Register for free at QUIC.cloud</a>
192
-
193
- <!-- <link rel="stylesheet" href="<?php echo LSWCP_PLUGIN_URL ; ?>css/iziModal.min.css"> -->
194
- <!-- <script src="<?php echo LSWCP_PLUGIN_URL ; ?>js/iziModal.min.js"></script> -->
195
- <!-- <div id="litespeed_modal"></div> -->
196
- <script>
197
- // var litespeed_modal = jQuery("#litespeed_modal").iziModal({iframe: true});
198
- // jQuery("#litespeed_modal_href").click(function(event) {
199
- // event.preventDefault();
200
- // litespeed_modal.iziModal('open', event);
201
- // });;
202
- </script>
203
- </div>
204
- <div class="litespeed-block">
205
- <div class='litespeed-col'>
206
- <h4><?php echo __( 'Email Address', 'litespeed-cache' ) ; ?></h4>
207
-
208
- <?php $this->build_input( LiteSpeed_Cache_Config::OPT_CDN_QUIC_EMAIL ) ; ?>
209
- <div class="litespeed-desc">
210
- <?php echo sprintf( __( 'Your Email address on %s.', 'litespeed-cache' ), 'Quic Cloud' ) ; ?>
211
- </div>
212
- </div>
213
-
214
- <div class='litespeed-col'>
215
- <h4><?php echo __( 'User API Key', 'litespeed-cache' ) ; ?></h4>
216
-
217
- <?php $this->build_input( LiteSpeed_Cache_Config::OPT_CDN_QUIC_KEY ) ; ?>
218
- <div class="litespeed-desc">
219
- <?php echo sprintf( __( 'Your API key is used to access %s APIs.', 'litespeed-cache' ), 'Quic Cloud' ) ; ?>
220
- <?php echo sprintf( __( 'Get it from <a %1$s>%2$s</a>.', 'litespeed-cache' ), 'href="https://my.quic.cloud/dashboard" target="_blank"', 'Quic Cloud' ) ; ?>
221
- </div>
222
- </div>
223
-
224
- </div>
225
- </td>
226
- </tr>
227
-
228
- <tr>
229
- <th><?php echo __( 'Cloudflare API', 'litespeed-cache' ) ; ?></th>
230
- <td>
231
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE ) ; ?>
232
- <div class="litespeed-desc">
233
- <?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
234
- <?php echo sprintf( __( 'This can be managed from <a %2$s>%1$s</a>.', 'litespeed-cache' ), '<b>' . __( 'Manage', 'litespeed-cache' ) . '</b> -&gt; <b>' . __( 'CDN', 'litespeed-cache' ) . '</b>', 'href="admin.php?page=lscache-dash#cdn"' ) ; ?>
235
- </div>
236
- <div class="litespeed-block">
237
- <div class='litespeed-col'>
238
- <h4><?php echo __( 'Email Address', 'litespeed-cache' ) ; ?></h4>
239
-
240
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_EMAIL ) ; ?>
241
- <div class="litespeed-desc">
242
- <?php echo sprintf( __( 'Your Email address on %s.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
243
- </div>
244
- </div>
245
-
246
- <div class='litespeed-col'>
247
- <h4><?php echo __( 'Global API Key', 'litespeed-cache' ) ; ?></h4>
248
-
249
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY ) ; ?>
250
- <div class="litespeed-desc">
251
- <?php echo sprintf( __( 'Your API key is used to access %s APIs.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
252
- <?php echo sprintf( __( 'Get it from <a %1$s>%2$s</a>.', 'litespeed-cache' ), 'href="https://www.cloudflare.com/a/profile" target="_blank"', 'Cloudflare' ) ; ?>
253
- </div>
254
- </div>
255
-
256
- <div class='litespeed-col'>
257
- <h4><?php echo __( 'Domain', 'litespeed-cache' ) ; ?></h4>
258
-
259
- <?php
260
- $cf_zone = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_ZONE ) ;
261
- $cls = $cf_zone ? ' litespeed-input-success' : ' litespeed-input-warning' ;
262
- $this->build_input( LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_NAME, $cls ) ;
263
- ?>
264
- <div class="litespeed-desc">
265
- <?php echo __( 'You can just type part of the domain.', 'litespeed-cache' ) ; ?>
266
- <?php echo __( 'Once saved, it will be matched with the current list and completed automatically.', 'litespeed-cache' ) ; ?>
267
- </div>
268
- </div>
269
- </div>
270
- </td>
271
- </tr>
272
-
273
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_compatibilities.php DELETED
@@ -1,38 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- if (!LiteSpeed_Cache_Admin_Display::get_instance()->show_compatibility_tab()) return;
5
- ?>
6
-
7
- <h3 class="litespeed-title"><?php echo __('Compatibility with WP-PostViews', 'litespeed-cache'); ?></h3>
8
-
9
- <p><?php echo __('To make LiteSpeed Cache compatible with WP-PostViews:', 'litespeed-cache'); ?></p>
10
-
11
- <ol>
12
- <li>
13
- <p><?php echo __('Replace the following calls in the active theme\'s template files with a div or span with a unique ID.', 'litespeed-cache'); ?></p>
14
- <p><?php echo sprintf(__('e.g. Replace <br> <pre>%1$s</pre> with<br> <pre>%2$s</pre>', 'litespeed-cache'),
15
- htmlspecialchars('<?php if(function_exists(\'the_views\' )) { the_views(); } ?>'),
16
- htmlspecialchars('<div id="postviews_lscwp" > </div>')
17
- ); ?>
18
- </p>
19
- </li>
20
- <li>
21
- <p><?php echo __('Update the ajax request to output the results to that div.', 'litespeed-cache'); ?></p>
22
- <p><?php echo __('Example:', 'litespeed-cache'); ?></p>
23
- <pre>jQuery.ajax({
24
- type:"GET",
25
- url:viewsCacheL10n.admin_ajax_url,
26
- data:"postviews_id="+viewsCacheL10n.post_id+"&action=postviews",
27
- cache:!1,
28
- success:function(data) {
29
- if(data) {
30
- jQuery('#postviews_lscwp').html(data+' views');
31
- }
32
- }
33
- });</pre>
34
- <p><?php echo __('The ajax code can be found at', 'litespeed-cache'); ?></p>
35
- <pre>/wp-content/plugins/wp-postviews/postviews-cache.js</pre>
36
- </li>
37
- <li><?php echo __('After purging the cache, the view count should be updating.', 'litespeed-cache'); ?></li>
38
- </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_crawler.php DELETED
@@ -1,305 +0,0 @@
1
- <?php
2
- if ( !defined('WPINC') ) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('Crawler Settings', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:crawler', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
-
11
- <table><tbody>
12
- <tr>
13
- <th><?php echo __('Delay', 'litespeed-cache'); ?></th>
14
- <td>
15
- <?php $id = LiteSpeed_Cache_Config::CRWL_USLEEP ; ?>
16
- <?php $this->build_input($id); ?> <?php echo __('microseconds', 'litespeed-cache'); ?>
17
- <div class="litespeed-desc">
18
- <?php echo __('Specify time in microseconds for the delay between requests during a crawl.', 'litespeed-cache'); ?>
19
-
20
- <?php if ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ) ) : ?>
21
- <font class="litespeed-warning">
22
- <?php echo __('NOTE', 'litespeed-cache'); ?>:
23
- <?php echo __( 'Server allowed min value', 'litespeed-cache') ; ?>: <code><?php echo $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ; ?></code>
24
- </font>
25
- <?php else : ?>
26
- <?php $this->recommended($id) ; ?>
27
- <?php endif ; ?>
28
-
29
-
30
- <br />
31
- <?php $this->_api_env_var( LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ) ; ?>
32
- </div>
33
- </td>
34
- </tr>
35
-
36
- <tr>
37
- <th><?php echo __('Run Duration', 'litespeed-cache'); ?></th>
38
- <td>
39
- <?php $id = LiteSpeed_Cache_Config::CRWL_RUN_DURATION ; ?>
40
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
41
- <div class="litespeed-desc">
42
- <?php echo __('Specify time in seconds for the duration of the crawl interval.', 'litespeed-cache'); ?>
43
- <?php $this->recommended($id) ; ?>
44
- </div>
45
- </td>
46
- </tr>
47
-
48
- <tr>
49
- <th><?php echo __('Interval Between Runs', 'litespeed-cache'); ?></th>
50
- <td>
51
- <?php $id = LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ; ?>
52
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
53
- <div class="litespeed-desc">
54
- <?php echo __('Specify time in seconds for the time between each run interval. Must be greater than 60.', 'litespeed-cache'); ?>
55
- <?php $this->recommended($id) ; ?>
56
- </div>
57
- </td>
58
- </tr>
59
-
60
- <tr>
61
- <th><?php echo __('Crawl Interval', 'litespeed-cache'); ?></th>
62
- <td>
63
- <?php $id = LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL ; ?>
64
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
65
- <div class="litespeed-desc">
66
- <?php echo __('Specify how long in seconds before the crawler should initiate crawling the entire sitemap again.', 'litespeed-cache'); ?>
67
- <?php $this->recommended($id) ; ?>
68
- </div>
69
- </td>
70
- </tr>
71
-
72
- <tr>
73
- <th><?php echo __('Threads', 'litespeed-cache'); ?></th>
74
- <td>
75
- <?php $id = LiteSpeed_Cache_Config::CRWL_THREADS ; ?>
76
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?>
77
- <div class="litespeed-desc">
78
- <?php echo __('Specify Number of Threads to use while crawling.', 'litespeed-cache'); ?>
79
- <?php $this->recommended($id) ; ?>
80
- </div>
81
- </td>
82
- </tr>
83
-
84
- <tr>
85
- <th><?php echo __('Server Load Limit', 'litespeed-cache'); ?></th>
86
- <td>
87
- <?php $id = LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ; ?>
88
- <?php $this->build_input($id); ?>
89
- <div class="litespeed-desc">
90
- <?php echo __( 'The maximum average server load allowed while crawling. The number of crawler threads in use will be actively reduced until average server load falls under this limit. If this cannot be achieved with a single thread, the current crawler run will be terminated.', 'litespeed-cache' ) ;
91
- ?>
92
-
93
- <?php if ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ) ) : ?>
94
- <font class="litespeed-warning">
95
- <?php echo __('NOTE', 'litespeed-cache'); ?>:
96
- <?php echo __( 'Server enforced value', 'litespeed-cache') ; ?>: <code><?php echo $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ; ?></code>
97
- </font>
98
- <?php elseif ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT ] ) ) : ?>
99
- <font class="litespeed-warning">
100
- <?php echo __('NOTE', 'litespeed-cache'); ?>:
101
- <?php echo __( 'Server allowed max value', 'litespeed-cache') ; ?>: <code><?php echo $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT ] ; ?></code>
102
- </font>
103
- <?php else : ?>
104
- <?php $this->recommended($id) ; ?>
105
-
106
- <?php endif ; ?>
107
-
108
- <br />
109
- <?php $this->_api_env_var( LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT, LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ) ; ?>
110
- </div>
111
- </td>
112
- </tr>
113
-
114
- <tr>
115
- <th><?php echo __('Site IP', 'litespeed-cache'); ?></th>
116
- <td>
117
- <?php $id = LiteSpeed_Cache_Config::CRWL_DOMAIN_IP ; ?>
118
- <?php $this->build_input($id); ?>
119
- <div class="litespeed-desc">
120
- <?php echo __('Enter this site\'s IP address to crawl by IP instead of domain name. This eliminates the overhead of DNS and CDN lookups. (optional)', 'litespeed-cache'); ?>
121
- </div>
122
- </td>
123
- </tr>
124
-
125
- <tr>
126
- <th><?php echo __('Role Simulation', 'litespeed-cache'); ?></th>
127
- <td>
128
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS, 20 ) ; ?>
129
-
130
- <div class="litespeed-desc">
131
- <?php echo __('To crawl the site as a logged-in user, enter the user ids to be simulated.', 'litespeed-cache'); ?>
132
- <?php echo __('One per line.', 'litespeed-cache'); ?>
133
- </div>
134
-
135
- </td>
136
- </tr>
137
-
138
- <tr>
139
- <th><?php echo __('Cookie Simulation', 'litespeed-cache'); ?></th>
140
- <td>
141
- <?php $id = LiteSpeed_Cache_Config::ITEM_CRWL_COOKIES ; ?>
142
- <div id="cookie_crawler">
143
- <div class="litespeed-block" v-for="( item, key ) in items">
144
- <div class='litespeed-col-auto'>
145
- <h4><?php echo __( 'Cookie Name', 'litespeed-cache' ) ; ?></h4>
146
- </div>
147
- <div class='litespeed-col-auto'>
148
- <input type="text" v-model="item.name" name="litespeed-cache-conf[<?php echo $id ; ?>][name][]" class="litespeed-regular-text" style="margin-top:1.33em;" >
149
- </div>
150
- <div class='litespeed-col-auto'>
151
- <h4><?php echo __( 'Cookie Values', 'litespeed-cache' ) ; ?></h4>
152
- </div>
153
- <div class='litespeed-col-auto'>
154
- <textarea v-model="item.vals" rows="5" cols="40" class="litespeed-textarea-success" name="litespeed-cache-conf[<?php echo $id ; ?>][vals][]" placeholder="<?php echo __( 'One per line.', 'litespeed-cache' ) ; ?>"></textarea>
155
- </div>
156
- <div class='litespeed-col-auto'>
157
- <button type="button" class="litespeed-btn-danger litespeed-btn-tiny" @click="$delete( items, key )">X</button>
158
- </div>
159
- </div>
160
-
161
- <button type="button" @click='add_row' class="litespeed-btn-success litespeed-btn-tiny">+</button>
162
- </div>
163
-
164
- <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
165
- <script>
166
- var cookie_crawler = new Vue( {
167
- el: '#cookie_crawler',
168
- data: {
169
- counter: 0,
170
- items : [
171
- <?php
172
- // Build the cookie crawler Vue data
173
- $cookies = $this->config->get_item( $id ) ;
174
- /**
175
- * Data Src Structure: [ nameA => vals, nameB => vals ]
176
- */
177
- $list = array() ;
178
- foreach ( $cookies as $k => $v ) {
179
- $list[] = "{ name: '$k', vals: `$v` }" ;// $v contains line break
180
- }
181
- echo implode( ',', $list ) ;
182
- ?>
183
- ]
184
- },
185
- methods: {
186
- add_row() {
187
- this.items.push( {
188
- id: ++ this.counter
189
- } ) ;
190
- }
191
- }
192
- } ) ;
193
- </script>
194
-
195
- <div class="litespeed-desc">
196
- <?php echo __('To crawl for a particular cookie, enter the cookie name, and the values you wish to crawl for. Values should be one per line, and can include a blank line. There will be one crawler created per cookie value, per simulated role.', 'litespeed-cache'); ?>
197
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:crawler#cookie_simulation' ) ; ?>
198
- </div>
199
-
200
- </td>
201
- </tr>
202
-
203
- <tr>
204
- <th><?php echo __('Custom Sitemap', 'litespeed-cache'); ?></th>
205
- <td>
206
- <?php $id = LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ; ?>
207
- <?php $this->build_input( $id, 'litespeed-input-long' ) ; ?>
208
- <div class="litespeed-desc">
209
- <?php echo __('The crawler can use your Google XML Sitemap instead of its own. Enter the full URL to your sitemap here.', 'litespeed-cache'); ?>
210
- </div>
211
- </td>
212
- </tr>
213
-
214
- <tr>
215
- <th><?php echo __('Sitemap Generation', 'litespeed-cache'); ?></th>
216
- <td>
217
- <div class="litespeed-block">
218
- <div class='litespeed-cdn-mapping-col2'>
219
- <div class="litespeed-row">
220
- <div class="litespeed-col-inc"><?php echo __( 'Include Posts', 'litespeed-cache' ) ; ?></div>
221
- <?php
222
- $this->build_toggle( LiteSpeed_Cache_Config::CRWL_POSTS ) ;
223
- ?>
224
- </div>
225
-
226
- <div class="litespeed-row">
227
- <div class="litespeed-col-inc"><?php echo __( 'Include Pages', 'litespeed-cache' ) ; ?></div>
228
- <?php
229
- $this->build_toggle( LiteSpeed_Cache_Config::CRWL_PAGES ) ;
230
- ?>
231
- </div>
232
-
233
- <div class="litespeed-row">
234
- <div class="litespeed-col-inc"><?php echo __( 'Include Categories', 'litespeed-cache' ) ; ?></div>
235
- <?php
236
- $this->build_toggle( LiteSpeed_Cache_Config::CRWL_CATS ) ;
237
- ?>
238
- </div>
239
-
240
- <div class="litespeed-row">
241
- <div class="litespeed-col-inc"><?php echo __( 'Include Tags', 'litespeed-cache' ) ; ?></div>
242
- <?php
243
- $this->build_toggle( LiteSpeed_Cache_Config::CRWL_TAGS ) ;
244
- ?>
245
- </div>
246
-
247
- </div>
248
-
249
- <div class='litespeed-col-auto'>
250
- <h4><?php echo __('Exclude Custom Post Types', 'litespeed-cache'); ?></h4>
251
-
252
- <?php $this->build_textarea( LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT, 40 ) ; ?>
253
-
254
- <div class="litespeed-desc">
255
- <?php echo __('Exclude certain Custom Post Types in sitemap.', 'litespeed-cache'); ?>
256
- </div>
257
- </div>
258
-
259
- <div class='litespeed-col-auto'>
260
- <div class="litespeed-callout-warning">
261
- <h4><?php echo __('Available Custom Post Type','litespeed-cache'); ?></h4>
262
- <p>
263
- <?php echo implode('<br />', array_diff(get_post_types( '', 'names' ), array('post', 'page'))); ?>
264
- </p>
265
- </div>
266
- </div>
267
-
268
- <div class='litespeed-col-auto'>
269
- <h4><?php echo __('Order links by', 'litespeed-cache'); ?></h4>
270
-
271
- <div class="litespeed-switch">
272
- <?php echo $this->build_radio(
273
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
274
- LiteSpeed_Cache_Config::CRWL_DATE_DESC,
275
- __('Date, descending (Default)', 'litespeed-cache')
276
- ); ?>
277
-
278
- <?php echo $this->build_radio(
279
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
280
- LiteSpeed_Cache_Config::CRWL_DATE_ASC,
281
- __('Date, ascending', 'litespeed-cache')
282
- ); ?>
283
-
284
- <?php echo $this->build_radio(
285
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
286
- LiteSpeed_Cache_Config::CRWL_ALPHA_DESC,
287
- __('Alphabetical, descending', 'litespeed-cache')
288
- ); ?>
289
-
290
- <?php echo $this->build_radio(
291
- LiteSpeed_Cache_Config::CRWL_ORDER_LINKS,
292
- LiteSpeed_Cache_Config::CRWL_ALPHA_ASC,
293
- __('Alphabetical, ascending', 'litespeed-cache')
294
- ); ?>
295
- </div>
296
- <div class="litespeed-desc">
297
- <?php echo sprintf( __( 'These options will be invalid when using %s.', 'litespeed-cache' ), '<code>' . __( 'Custom Sitemap', 'litespeed-cache' ) . '</code>' ) ; ?>
298
- </div>
299
- </div>
300
- </div>
301
-
302
- </td>
303
- </tr>
304
-
305
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_debug.php DELETED
@@ -1,173 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('Developer Testing', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:debug', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
-
11
- <table><tbody>
12
- <tr>
13
- <th><?php echo __( 'Disable All Features', 'litespeed-cache' ) ; ?></th>
14
- <td>
15
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ) ; ?>
16
- <div class="litespeed-desc">
17
- <?php echo __( 'This will disable LSCache and all optimization features for debug purpose.', 'litespeed-cache' ) ; ?>
18
- </div>
19
- </td>
20
- </tr>
21
-
22
- <tr>
23
- <th><?php echo __( 'Debug Log', 'litespeed-cache' ) ; ?></th>
24
- <td>
25
- <div class="litespeed-switch">
26
- <?php echo $this->build_radio(
27
- LiteSpeed_Cache_Config::OPID_DEBUG,
28
- LiteSpeed_Cache_Config::VAL_OFF,
29
- __( 'OFF', 'litespeed-cache' )
30
- ) ; ?>
31
-
32
- <?php echo $this->build_radio(
33
- LiteSpeed_Cache_Config::OPID_DEBUG,
34
- LiteSpeed_Cache_Config::VAL_ON,
35
- __( 'ON', 'litespeed-cache' )
36
- ) ; ?>
37
-
38
- <?php echo $this->build_radio(
39
- LiteSpeed_Cache_Config::OPID_DEBUG,
40
- LiteSpeed_Cache_Config::VAL_ON2,
41
- __( 'Admin IP only', 'litespeed-cache' )
42
- ) ; ?>
43
- </div>
44
- <div class="litespeed-desc">
45
- <?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ) ; ?>
46
- <?php echo __( 'This should be set to off once everything is working to prevent filling the disk.', 'litespeed-cache' ) ; ?>
47
- <?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ) ; ?>
48
- <?php echo sprintf( __( 'The logs will be outputted to %s.', 'litespeed-cache' ), '<code>wp-content/debug.log</code>' ) ; ?>
49
- </div>
50
- </td>
51
- </tr>
52
-
53
- <tr>
54
- <th><?php echo __( 'Admin IPs', 'litespeed-cache' ) ; ?></th>
55
- <td>
56
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_ADMIN_IPS, 30 ) ; ?>
57
- <div class="litespeed-desc">
58
- <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ) ; ?>
59
- <?php echo __( 'Your IP', 'litespeed-cache' ) ; ?>: <code><?php echo LiteSpeed_Cache_Router::get_ip() ; ?></code>
60
- <br />
61
- <?php $this->learn_more(
62
- 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:admin-ip-commands',
63
- __( 'More information about the available commands can be found here.', 'litespeed-cache' )
64
- ) ; ?>
65
- </div>
66
- </td>
67
- </tr>
68
-
69
- <tr>
70
- <th><?php echo __( 'Debug Level', 'litespeed-cache' ) ; ?></th>
71
- <td>
72
- <div class="litespeed-switch">
73
- <?php echo $this->build_radio(
74
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
75
- LiteSpeed_Cache_Config::VAL_OFF,
76
- __( 'Basic', 'litespeed-cache' )
77
- ) ; ?>
78
-
79
- <?php echo $this->build_radio(
80
- LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL,
81
- LiteSpeed_Cache_Config::VAL_ON,
82
- __( 'Advanced', 'litespeed-cache' )
83
- ) ; ?>
84
- </div>
85
- <div class="litespeed-desc">
86
- <?php echo __( 'Advanced level will log more details.', 'litespeed-cache' ) ; ?>
87
- </div>
88
- </td>
89
- </tr>
90
-
91
- <tr>
92
- <th><?php echo __( 'Log File Size Limit', 'litespeed-cache' ) ; ?></th>
93
- <td>
94
- <?php $id = LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ; ?>
95
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?> <?php echo __( 'MB', 'litespeed-cache' ) ; ?>
96
- <div class="litespeed-desc">
97
- <?php echo __( 'Specify the maximum size of the log file. Minimum is 3MB. Maximum is 3000MB.', 'litespeed-cache' ) ; ?>
98
- <?php $this->recommended( $id ) ; ?>
99
- </div>
100
- </td>
101
- </tr>
102
-
103
- <tr>
104
- <th><?php echo __( 'Heartbeat', 'litespeed-cache' ) ; ?></th>
105
- <td>
106
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ; ?>
107
- <div class="litespeed-desc">
108
- <?php echo __( 'Disable WordPress heartbeat to prevent AJAX calls from breaking debug logging.', 'litespeed-cache' ) ; ?>
109
- <font class="litespeed-warning">
110
- 🚨
111
- <?php echo __( 'Disabling this may cause WordPress tasks triggered by AJAX to stop working.', 'litespeed-cache' ) ; ?>
112
- </font>
113
- </div>
114
- </td>
115
- </tr>
116
-
117
- <tr>
118
- <th><?php echo __( 'Log Cookies', 'litespeed-cache' ) ; ?></th>
119
- <td>
120
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE ) ; ?>
121
- <div class="litespeed-desc">
122
- <?php echo __( 'Log request cookie values.', 'litespeed-cache' ) ; ?>
123
- </div>
124
- </td>
125
- </tr>
126
-
127
- <tr>
128
- <th><?php echo __( 'Collapse Query Strings', 'litespeed-cache' ) ; ?></th>
129
- <td>
130
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ; ?>
131
- <div class="litespeed-desc">
132
- <?php echo __( 'Shorten query strings in the debug log to improve readability.', 'litespeed-cache' ) ; ?>
133
- </div>
134
- </td>
135
- </tr>
136
-
137
- <tr>
138
- <th><?php echo __( 'Log Filters', 'litespeed-cache' ) ; ?></th>
139
- <td>
140
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_LOG_FILTERS ) ; ?>
141
- <div class="litespeed-desc">
142
- <?php echo __( 'Log all WordPress filter hooks.', 'litespeed-cache' ) ; ?>
143
- <font class="litespeed-warning">
144
- 🚨
145
- <?php echo __( 'Enabling this option will cause log file size to grow quickly.', 'litespeed-cache' ) ; ?>
146
- </font>
147
- </div>
148
- </td>
149
- </tr>
150
-
151
- <tr>
152
- <th><?php echo __( 'Exclude Filters', 'litespeed-cache' ) ; ?></th>
153
- <td>
154
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_FILTERS, 30 ) ; ?>
155
- <div class="litespeed-desc">
156
- <?php echo __( 'Listed filters (one per line) will not be logged.', 'litespeed-cache' ) ; ?>
157
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:debug#exclude_filters', __( 'Recommended default value', 'litespeed-cache' ) ) ; ?>
158
- </div>
159
- </td>
160
- </tr>
161
-
162
- <tr>
163
- <th><?php echo __( 'Exclude Part Filters', 'litespeed-cache' ) ; ?></th>
164
- <td>
165
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_PART_FILTERS, 30 ) ; ?>
166
- <div class="litespeed-desc">
167
- <?php echo __( 'Filters containing these strings (one per line) will not be logged.', 'litespeed-cache' ) ; ?>
168
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:debug#exclude_part_filters', __( 'Recommended default value', 'litespeed-cache' ) ) ; ?>
169
- </div>
170
- </td>
171
- </tr>
172
-
173
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_esi.php DELETED
@@ -1,99 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('ESI Settings', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:esi', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
-
11
- <?php $this->cache_disabled_warning() ; ?>
12
-
13
- <div class="litespeed-desc">
14
- <p><?php echo __('With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache'); ?></p>
15
- <p><?php echo __('ESI allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. In other words, ESI lets you “punch holes” in a page, and then fill those holes with content that may be cached privately, cached publicly with its own TTL, or not cached at all.', 'litespeed-cache'); ?>
16
- <?php $this->learn_more( 'https://blog.litespeedtech.com/2017/08/30/wpw-private-cache-vs-public-cache/', __( 'WpW: Private Cache vs. Public Cache', 'litespeed-cache' ) ) ; ?>
17
- </p>
18
- <p>
19
- 💡:
20
- <?php echo __( 'You can turn shortcodes into ESI blocks.', 'litespeed-cache' ) ; ?>
21
- <?php echo sprintf(
22
- __( 'Replace %1$s with %2$s.', 'litespeed-cache' ),
23
- '<code>[shortcodeA att1="val1" att2="val2"]</code>',
24
- '<code>[esi shortcodeA att1="val1" att2="val2"]</code>'
25
- ) ; ?>
26
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:esi:shortcode' ) ; ?>
27
- </p>
28
- <p>
29
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:esi_sample', __( 'ESI sample for developers', 'litespeed-cache' ) ) ; ?>
30
- </p>
31
- </div>
32
-
33
- <div class="litespeed-relative">
34
-
35
- <?php if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' && ! $_options[ LiteSpeed_Cache_Config::OPT_CDN_QUIC ] ) : ?>
36
- <div class="litespeed-callout-danger">
37
- <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
38
- <h4><?php echo __('These options are only available with LiteSpeed Enterprise Web Server or QUIC.cloud CDN.', 'litespeed-cache'); ?></h4>
39
- </div>
40
- <?php endif; ?>
41
-
42
- <table><tbody>
43
- <tr>
44
- <th><?php echo __('Enable ESI', 'litespeed-cache'); ?></th>
45
- <td>
46
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_ENABLE); ?>
47
- <div class="litespeed-desc">
48
- <?php echo __('Enable caches public pages for logged in users and serves the Admin Bar and Comment Form via ESI blocks. These two blocks will be uncached unless enabled below.', 'litespeed-cache'); ?>
49
- </div>
50
- </td>
51
- </tr>
52
-
53
- <tr>
54
- <th><?php echo __('Cache Admin Bar', 'litespeed-cache'); ?></th>
55
- <td>
56
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_CACHE_ADMBAR); ?>
57
- <div class="litespeed-desc">
58
- <?php echo __('Cache the build-in Admin Bar ESI block.', 'litespeed-cache'); ?>
59
- </div>
60
- </td>
61
- </tr>
62
-
63
- <tr>
64
- <th><?php echo __('Cache Comment Form', 'litespeed-cache'); ?></th>
65
- <td>
66
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_ESI_CACHE_COMMFORM); ?>
67
- <div class="litespeed-desc">
68
- <?php echo __('Cache the build-in Comment Form ESI block.', 'litespeed-cache'); ?>
69
- </div>
70
- </td>
71
- </tr>
72
-
73
- <tr>
74
- <th><?php echo __('Vary Group', 'litespeed-cache'); ?></th>
75
- <td>
76
- <table class="litespeed-vary-table"><tbody>
77
- <?php foreach ( $roles as $role => $title ): ?>
78
- <tr>
79
- <td class='litespeed-vary-title'><?php echo $title ; ?></td>
80
- <td class='litespeed-vary-val'>
81
- <input type="text" class="litespeed-input-short"
82
- name="<?php echo LiteSpeed_Cache_Config::OPTION_NAME ; ?>[<?php echo LiteSpeed_Cache_Config::VARY_GROUP ; ?>][<?php echo $role ; ?>]"
83
- value="<?php echo $this->config->in_vary_group( $role ) ; ?>" />
84
- </td>
85
- </tr>
86
- <?php endforeach; ?>
87
- </tbody></table>
88
- <div class="litespeed-desc">
89
- <?php echo __( 'If your site contains public content that certain user roles can see but other roles cannot, you can specify a Vary Group for those user roles. For example, specifying an administrator vary group allows there to be a separate publicly-cached page tailored to administrators (with “edit” links, etc), while all other user roles see the default public page.', 'litespeed-cache' ) ; ?>
90
- </div>
91
- </td>
92
- </tr>
93
-
94
-
95
-
96
-
97
- </tbody></table>
98
-
99
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_excludes.php DELETED
@@ -1,146 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
-
5
- <h3 class="litespeed-title-short">
6
- <?php echo __('Exclude Settings', 'litespeed-cache'); ?>
7
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:excludes', false, 'litespeed-learn-more' ) ; ?>
8
- </h3>
9
-
10
- <?php $this->cache_disabled_warning() ; ?>
11
-
12
- <table><tbody>
13
- <tr>
14
- <th><?php echo __( 'Force Cache URIs', 'litespeed-cache' ) ; ?></th>
15
- <td>
16
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_FORCE_CACHE_URI ) ; ?>
17
- <div class="litespeed-desc">
18
- <?php echo __('Paths containing these strings will be cached regardless of no-cacheable settings.', 'litespeed-cache'); ?>
19
- <?php $this->_uri_usage_example() ; ?>
20
- <br /><?php echo __( 'To define a custom TTL for a URI, add a space followed by the TTL value to the end of the URI.', 'litespeed-cache' ) ; ?>
21
- <?php echo sprintf( __( 'For example, %1$s defines a TTL of %2$s seconds for %3$s.', 'litespeed-cache' ), '<code>/mypath/mypage 300</code>', 300, '<code>/mypath/mypage</code>' ) ; ?>
22
- </div>
23
- </td>
24
- </tr>
25
-
26
- <tr>
27
- <th><?php echo __( 'Do Not Cache URIs', 'litespeed-cache' ) ; ?></th>
28
- <td>
29
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_EXCLUDES_URI ) ; ?>
30
- <div class="litespeed-desc">
31
- <?php echo __('Paths containing these strings will not be cached.', 'litespeed-cache'); ?>
32
- <?php $this->_uri_usage_example() ; ?>
33
- </div>
34
- </td>
35
- </tr>
36
-
37
- <tr>
38
- <th><?php echo __( 'Do Not Cache Query Strings', 'litespeed-cache' ) ; ?></th>
39
- <td>
40
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_EXCLUDES_QS); ?>
41
- <div class="litespeed-desc">
42
- <?php echo __('Query string containing these parameters will not be cached.', 'litespeed-cache'); ?>
43
- <?php echo sprintf( __( 'For example, for %s, %s and %s can be used here.', 'litespeed-cache' ), '<code>?aa=bb&cc=dd</code>', '<code>aa</code>', '<code>cc</code>' ) ; ?>
44
- <i>
45
- <?php echo __('One per line.', 'litespeed-cache'); ?>
46
- </i>
47
- </div>
48
- </td>
49
- </tr>
50
-
51
- <tr>
52
- <th><?php echo __( 'Do Not Cache Categories', 'litespeed-cache' ) ; ?></th>
53
- <td>
54
- <?php
55
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
56
- $excludes_buf = '';
57
- $cat_ids = $_options[$id];
58
- if ($cat_ids != '') {
59
- $id_list = explode(',', $cat_ids);
60
- $excludes_buf = implode("\n", array_map('get_cat_name', $id_list));
61
- }
62
- $this->build_textarea($id, false, $excludes_buf);
63
- ?>
64
- <div class="litespeed-desc">
65
- <b><?php echo __('All categories are cached by default.', 'litespeed-cache'); ?></b>
66
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'categories', 'litespeed-cache') ) ; ?>
67
- <i>
68
- <?php echo __('One per line.', 'litespeed-cache'); ?>
69
- </i>
70
- </div>
71
- <div class="litespeed-callout-warning">
72
- <h4><?php echo __('NOTE', 'litespeed-cache'); ?>:</h4>
73
- <ol>
74
- <li><?php echo __('If the category slug is not found, the category will be removed from the list on save.', 'litespeed-cache'); ?></li>
75
- <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
76
- '<code>http://www.example.com/category/category-slug/</code>', '<code>category-slug</code>'); ?></li>
77
- </ol>
78
- </div>
79
- </td>
80
- </tr>
81
-
82
- <tr>
83
- <th><?php echo __( 'Do Not Cache Tags', 'litespeed-cache' ) ; ?></th>
84
- <td>
85
- <?php
86
- $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
87
- $excludes_buf = '';
88
- $ids = $_options[$id];
89
- if ($ids != '') {
90
- $id_list = explode(',', $ids);
91
- $tags_list = array_map('get_tag', $id_list);
92
- $tag_names = array();
93
- foreach ($tags_list as $tag) {
94
- $tag_names[] = $tag->name;
95
- }
96
- if (!empty($tag_names)) {
97
- $excludes_buf = implode("\n", $tag_names);
98
- }
99
- }
100
- $this->build_textarea($id, false, $excludes_buf);
101
- ?>
102
- <div class="litespeed-desc">
103
- <b><?php echo __('All tags are cached by default.', 'litespeed-cache'); ?></b>
104
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'tags', 'litespeed-cache') ) ; ?>
105
- <i>
106
- <?php echo __('One per line.', 'litespeed-cache'); ?>
107
- </i>
108
- </div>
109
- <div class="litespeed-callout-warning">
110
- <h4><?php echo __('NOTE', 'litespeed-cache'); ?>:</h4>
111
- <ol>
112
- <li><?php echo __('If the tag slug is not found, the tag will be removed from the list on save.', 'litespeed-cache'); ?></li>
113
- <li><?php echo sprintf(__('To exclude %1$s, insert %2$s.', 'litespeed-cache'),
114
- '<code>http://www.example.com/tag/category/tag-slug/</code>', '<code>tag-slug</code>'); ?></li>
115
- </ol>
116
- </div>
117
- </td>
118
- </tr>
119
-
120
- <?php
121
- if ( ! is_multisite() ) :
122
- // Cookie
123
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.exclude_cookies.php' ;
124
-
125
- // User Agent
126
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.exclude_useragent.php' ;
127
-
128
- endif ;
129
- ?>
130
-
131
-
132
- <tr>
133
- <th><?php echo __('Do Not Cache Roles', 'litespeed-cache'); ?></th>
134
- <td>
135
- <?php foreach ( $roles as $role => $title ): ?>
136
- <?php $this->build_checkbox( LiteSpeed_Cache_Config::EXCLUDE_CACHE_ROLES . "][", $title, $this->config->in_exclude_cache_roles( $role ), $role ) ; ?>
137
- <?php endforeach; ?>
138
- <div class="litespeed-desc">
139
- <?php echo __( 'Selected roles will be excluded from cache.', 'litespeed-cache' ) ; ?>
140
- </div>
141
- </td>
142
- </tr>
143
-
144
-
145
-
146
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_general.php DELETED
@@ -1,164 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('General', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:general', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
-
11
- <?php $this->cache_disabled_warning() ; ?>
12
-
13
- <table><tbody>
14
- <tr>
15
- <th><?php echo __('Enable LiteSpeed Cache', 'litespeed-cache'); ?></th>
16
- <td>
17
- <?php
18
- $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO;
19
- //IF multisite: Add 'Use Network Admin' option,
20
- //ELSE: Change 'Enable LiteSpeed Cache' selection to 'Enabled' if the 'Use Network Admin' option was previously selected.
21
- // Selection will not actually be changed unless settings are saved.
22
- if(!is_multisite() && intval($_options[$id]) === 2){
23
- $_options[$id] = 1;
24
- }
25
- ?>
26
- <div class="litespeed-switch">
27
- <?php echo $this->build_radio(
28
- $id,
29
- LiteSpeed_Cache_Config::VAL_OFF,
30
- __('Disable', 'litespeed-cache')
31
- ); ?>
32
-
33
- <?php echo $this->build_radio(
34
- $id,
35
- LiteSpeed_Cache_Config::VAL_ON,
36
- __('Enable', 'litespeed-cache')
37
- ); ?>
38
-
39
- <?php
40
- if ( is_multisite() ){
41
- echo $this->build_radio(
42
- $id,
43
- LiteSpeed_Cache_Config::VAL_ON2,
44
- __('Use Network Admin Setting', 'litespeed-cache')
45
- );
46
- }
47
- ?>
48
- </div>
49
- <div class="litespeed-desc">
50
- <?php echo sprintf(__('Please visit the <a %s>Information</a> page on how to test the cache.', 'litespeed-cache'),
51
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:configuration" target="_blank"'); ?>
52
-
53
- <strong><?php echo __('NOTICE', 'litespeed-cache'); ?>: </strong><?php echo __('When disabling the cache, all cached entries for this blog will be purged.', 'litespeed-cache'); ?>
54
- <?php if ( is_multisite() ): ?>
55
- <br><?php echo __('The network admin setting can be overridden here.', 'litespeed-cache'); ?>
56
- <?php endif; ?>
57
- </div>
58
- </td>
59
- </tr>
60
-
61
- <tr>
62
- <th><?php echo __('Default Public Cache TTL', 'litespeed-cache'); ?></th>
63
- <td>
64
- <?php $id = LiteSpeed_Cache_Config::OPID_PUBLIC_TTL ; ?>
65
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
66
- <div class="litespeed-desc">
67
- <?php echo __('Specify how long, in seconds, public pages are cached. Minimum is 30 seconds.', 'litespeed-cache'); ?>
68
- <?php $this->recommended($id) ; ?>
69
- </div>
70
- </td>
71
- </tr>
72
-
73
- <tr>
74
- <th><?php echo __('Default Private Cache TTL', 'litespeed-cache'); ?></th>
75
- <td>
76
- <?php $id = LiteSpeed_Cache_Config::OPID_PRIVATE_TTL ; ?>
77
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
78
- <div class="litespeed-desc">
79
- <?php echo sprintf( __( 'Specify how long, in seconds, private pages are cached. Minimum is %1$s seconds. Maximum is %2$s seconds.', 'litespeed-cache' ), 60, 3600 ) ; ?>
80
- <?php $this->recommended($id) ; ?>
81
- </div>
82
- </td>
83
- </tr>
84
-
85
- <tr>
86
- <th><?php echo __('Default Front Page TTL', 'litespeed-cache'); ?></th>
87
- <td>
88
- <?php $id = LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL ; ?>
89
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
90
- <div class="litespeed-desc">
91
- <?php echo __('Specify how long, in seconds, the front page is cached. Minimum is 30 seconds.', 'litespeed-cache'); ?>
92
- <?php $this->recommended($id) ; ?>
93
- </div>
94
- </td>
95
- </tr>
96
-
97
- <tr>
98
- <th><?php echo __('Default Feed TTL', 'litespeed-cache'); ?></th>
99
- <td>
100
- <?php $id = LiteSpeed_Cache_Config::OPID_FEED_TTL ; ?>
101
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
102
- <div class="litespeed-desc">
103
- <?php echo __('Specify how long, in seconds, feeds are cached.', 'litespeed-cache'); ?>
104
- <?php echo __('If this is set to a number less than 30, feeds will not be cached.', 'litespeed-cache'); ?>
105
- <?php $this->recommended($id) ; ?>
106
- </div>
107
- </td>
108
- </tr>
109
-
110
- <tr>
111
- <th><?php echo __('Default 404 Page TTL', 'litespeed-cache'); ?></th>
112
- <td>
113
- <?php $id = LiteSpeed_Cache_Config::OPID_404_TTL ; ?>
114
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
115
- <div class="litespeed-desc">
116
- <?php echo __('Specify how long, in seconds, 404 pages are cached.', 'litespeed-cache'); ?>
117
- <?php echo __('If this is set to a number less than 30, 404 pages will not be cached.', 'litespeed-cache'); ?>
118
- <?php $this->recommended($id) ; ?>
119
- </div>
120
- </td>
121
- </tr>
122
-
123
- <tr>
124
- <th><?php echo __('Default 403 Page TTL', 'litespeed-cache'); ?></th>
125
- <td>
126
- <?php $id = LiteSpeed_Cache_Config::OPID_403_TTL ; ?>
127
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
128
- <div class="litespeed-desc">
129
- <?php echo __('Specify how long, in seconds, 403 pages are cached.', 'litespeed-cache'); ?>
130
- <?php echo __('If this is set to a number less than 30, 403 pages will not be cached.', 'litespeed-cache'); ?>
131
- <?php $this->recommended($id) ; ?>
132
- </div>
133
- </td>
134
- </tr>
135
-
136
- <tr>
137
- <th><?php echo __('Default 500 Page TTL', 'litespeed-cache'); ?></th>
138
- <td>
139
- <?php $id = LiteSpeed_Cache_Config::OPID_500_TTL ; ?>
140
- <?php $this->build_input($id); ?> <?php echo __('seconds', 'litespeed-cache'); ?>
141
- <div class="litespeed-desc">
142
- <?php echo __('Specify how long, in seconds, 500 pages are cached.', 'litespeed-cache'); ?>
143
- <?php echo __('If this is set to a number less than 30, 500 pages will not be cached.', 'litespeed-cache'); ?>
144
- <?php $this->recommended($id) ; ?>
145
- </div>
146
- </td>
147
- </tr>
148
-
149
- <?php if ( ! is_multisite() ) : ?>
150
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.auto_upgrade.php'; ?>
151
- <?php endif ; ?>
152
-
153
- <tr>
154
- <th><?php echo __( 'Automatically Feed News', 'litespeed-cache' ) ; ?></th>
155
- <td>
156
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_NEWS ) ; ?>
157
- <div class="litespeed-desc">
158
- <?php echo __( 'Turn this option ON to show latest news automatically, including hotfixes, new releases, available beta versions, promotions.', 'litespeed-cache' ) ; ?>
159
- </div>
160
- </td>
161
- </tr>
162
-
163
- </tbody></table>
164
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.cache_browser.php DELETED
@@ -1,31 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
- <tr <?php echo $_hide_in_basic_mode ; ?>>
6
- <th><?php echo __( 'Browser Cache', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_BROWSER ) ; ?>
9
- <div class="litespeed-desc">
10
- <?php echo __( 'Browser caching stores static files locally in the user\'s browser. Turn on this setting to reduce repeated requests for static files.', 'litespeed-cache' ) ; ?>
11
- <br /><font class="litespeed-warning">
12
- ⚠️
13
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
14
- </font>
15
- <br /><?php echo sprintf( __( 'You can turn on browser caching in server admin too. <a %s>Learn more about LiteSpeed browser cache setting</a>.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:browser_cache" target="_blank"' ) ; ?>
16
- </div>
17
- </td>
18
- </tr>
19
-
20
- <tr <?php echo $_hide_in_basic_mode ; ?>>
21
- <th class="litespeed-padding-left"><?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.cache_favicon.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <tr>
6
- <th><?php echo __('Cache favicon.ico', 'litespeed-cache'); ?></th>
7
- <td>
8
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_FAVICON); ?>
9
- <div class="litespeed-desc">
10
- <?php echo __('favicon.ico is requested on most pages.', 'litespeed-cache'); ?>
11
- <?php echo __('Caching this resource may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
12
- <br /><font class="litespeed-warning">
13
- ⚠️
14
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
15
- </font>
16
- </div>
17
- </td>
18
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.cache_mobile.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <!-- build_setting_mobile_view start -->
7
- <tr>
8
- <th><?php echo __('Cache Mobile', 'litespeed-cache'); ?></th>
9
- <td>
10
- <?php
11
- $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE);
12
- ?>
13
- <div class="litespeed-desc">
14
- <?php echo __('Cache mobile views separately.', 'litespeed-cache'); ?>
15
- <?php echo __('Only enable for AMP or mobile-specific design/content, not for responsive sites.', 'litespeed-cache'); ?>
16
- <br /><font class="litespeed-warning">
17
- ⚠️
18
- <?php echo __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ; ?>
19
- </font>
20
- </div>
21
- </td>
22
- </tr>
23
-
24
- <tr>
25
- <th><?php echo __('List of Mobile User Agents', 'litespeed-cache'); ?></th>
26
- <td>
27
- <?php
28
- $id = LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ;
29
- $wp_default_mobile = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
30
-
31
- // if set, use value as input value
32
- if ( $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
33
-
34
- // if enabled, check the setting in file
35
- if ( defined( 'LITESPEED_ON' ) ) {
36
-
37
- $mobile_agents = LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_mobile_agents() ;
38
- if ( $mobile_agents !== $_options[ $id ] ) {
39
- echo '<div class="litespeed-callout-danger">'
40
- . __( 'Htaccess did not match configuration option.', 'litespeed-cache' )
41
- . ' ' . __( 'Please re-enter the mobile view setting.', 'litespeed-cache' )
42
- . ' ' . sprintf( __( 'List in WordPress database is: %s', 'litespeed-cache' ), '<b>' . $_options[ $id ] . '</b>' )
43
- . '</div>' ;
44
- }
45
- }
46
- }
47
-
48
- $this->build_input( $id, 'litespeed-input-long', null, 'litespeed-mobileview-rules', '', 'text', ! $_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) ;
49
- ?>
50
-
51
- <input type="hidden" name="<?php echo LiteSpeed_Cache_Config::OPTION_NAME; ?>[<?php echo $id; ?>__default]"
52
- id="litespeed-mobileview-rules-default"
53
- value="<?php echo esc_textarea( $wp_default_mobile ) ; ?>"
54
- />
55
-
56
- <div class="litespeed-desc">
57
- <i>
58
- <?php echo sprintf( __( 'SYNTAX: Each entry should be separated with a bar, %s.', 'litespeed-cache'), "<code>|</code>" ) ; ?>
59
- <?php echo sprintf( __( 'Any spaces should be escaped with a backslash before the space, %s.', 'litespeed-cache' ), "<code>\\</code>" ) ; ?>
60
- </i>
61
- <br />
62
- <?php echo sprintf( __( 'The default list WordPress uses is %s', 'litespeed-cache' ), "<code>$wp_default_mobile</code>" ) ; ?>
63
- <br /><font class="litespeed-warning">
64
- ⚠️
65
- <?php echo sprintf( __( 'If %1$s is %2$s, then %3$s must be populated!', 'litespeed-cache' ), '<code>' . __('Cache Mobile', 'litespeed-cache') . '</code>', '<code>' . __('ON', 'litespeed-cache') . '</code>', '<code>' . __('List of Mobile User Agents', 'litespeed-cache') . '</code>' ) ; ?>
66
- </font>
67
- </div>
68
- </td>
69
- </tr>
70
- <!-- build_setting_mobile_view end -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.cache_object.php DELETED
@@ -1,157 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $lang_enabled = '<font class="litespeed-success">' . __( 'Enabled', 'litespeed-cache' ) . '</font>' ;
5
- $lang_disabled = '<font class="litespeed-warning">' . __( 'Disabled', 'litespeed-cache' ) . '</font>' ;
6
-
7
- $mem_enabled = class_exists( 'Memcached' ) ? $lang_enabled : $lang_disabled ;
8
- $redis_enabled = class_exists( 'Redis' ) ? $lang_enabled : $lang_disabled ;
9
-
10
- $mem_conn = LiteSpeed_Cache_Object::get_instance()->test_connection() ;
11
- if ( $mem_conn === null ) {
12
- $mem_conn_desc = '<font class="litespeed-desc">' . __( 'Not Available', 'litespeed-cache' ) . '</font>' ;
13
- }
14
- elseif ( $mem_conn ) {
15
- $mem_conn_desc = '<font class="litespeed-success">' . __( 'Passed', 'litespeed-cache' ) . '</font>' ;
16
- }
17
- else {
18
- $mem_conn_desc = '<font class="litespeed-warning">' . __( 'Failed', 'litespeed-cache' ) . '</font>' ;
19
- }
20
-
21
- $hide_mem_options = ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND ) ? '' : ' litespeed-hide' ;
22
- $hide_redis_options = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND ) ? '' : ' litespeed-hide' ;
23
-
24
- ?>
25
-
26
-
27
- <tr <?php echo $_hide_in_basic_mode ; ?>>
28
- <th><?php echo __( 'Object Cache', 'litespeed-cache' ) ; ?></th>
29
- <td>
30
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT ) ; ?>
31
- <div class="litespeed-desc">
32
- <?php echo __( 'Use object cache functionality.', 'litespeed-cache' ) ; ?>
33
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache:object_cache' ) ; ?>
34
- </div>
35
- <div class="litespeed-block">
36
- <div class='litespeed-col-auto'>
37
- <h4><?php echo __( 'Method', 'litespeed-cache' ) ; ?></h4>
38
-
39
- <div class="litespeed-switch">
40
- <?php echo $this->build_radio( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND, LiteSpeed_Cache_Config::VAL_OFF, 'Memcached', null, 'litespeed-oc-mem' ) ; ?>
41
- <?php echo $this->build_radio( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_KIND, LiteSpeed_Cache_Config::VAL_ON, 'Redis', null, 'litespeed-oc-redis' ) ; ?>
42
- </div>
43
- </div>
44
-
45
- <div class='litespeed-col-auto'>
46
- <h4><?php echo __( 'Host', 'litespeed-cache' ) ; ?></h4>
47
-
48
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_HOST ) ; ?>
49
- <div class="litespeed-desc">
50
- <?php echo sprintf( __( 'Your %s Hostname or IP address.', 'litespeed-cache' ), 'Memcached/<a href="https://www.litespeedtech.com/open-source/litespeed-memcached" target="_blank">LSMCD</a>/Redis' ) ; ?>
51
- </div>
52
- </div>
53
-
54
- <div class='litespeed-col-auto'>
55
- <h4><?php echo __( 'Port', 'litespeed-cache' ) ; ?></h4>
56
-
57
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PORT, 'litespeed-input-short2' ) ; ?>
58
- </div>
59
-
60
- <div class='litespeed-col-auto'>
61
- <h4><?php echo __( 'Default Object Lifetime', 'litespeed-cache' ) ; ?></h4>
62
-
63
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_LIFE, 'litespeed-input-short2' ) ; ?> <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
64
- <div class="litespeed-desc">
65
- <?php echo __( 'Default TTL for cached objects.', 'litespeed-cache' ) ; ?>
66
- </div>
67
- </div>
68
-
69
- <div class='litespeed-col-auto'>
70
- <h4><?php echo __( 'Status', 'litespeed-cache' ) ; ?></h4>
71
-
72
- <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Memcached' ) ; ?>: <?php echo $mem_enabled ; ?><br />
73
- <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Redis' ) ; ?>: <?php echo $redis_enabled ; ?><br />
74
- <?php echo __( 'Connection Test', 'litespeed-cache' ) ; ?>: <?php echo $mem_conn_desc ; ?>
75
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache:object_cache#how_to_debug' ) ; ?>
76
- </div>
77
-
78
- <div class='litespeed-col-br'></div>
79
-
80
- <div class='litespeed-col-auto <?php echo $hide_mem_options ; ?>' data="litespeed-mem-divs">
81
- <h4><?php echo __( 'Username', 'litespeed-cache' ) ; ?></h4>
82
-
83
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_USER ) ; ?>
84
- <div class="litespeed-desc">
85
- <?php echo sprintf( __( 'Only available when %s is installed.', 'litespeed-cache' ), 'SASL' ) ; ?>
86
- </div>
87
- </div>
88
-
89
- <div class='litespeed-col-auto'>
90
- <h4><?php echo __( 'Password', 'litespeed-cache' ) ; ?></h4>
91
-
92
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PSWD ) ; ?>
93
- <div class="litespeed-desc">
94
- <?php echo __( 'Specify the password used when connecting.', 'litespeed-cache' ) ; ?>
95
- </div>
96
- </div>
97
-
98
- <div class='litespeed-col-auto <?php echo $hide_redis_options ; ?>' data="litespeed-redis-divs">
99
- <h4><?php echo __( 'Redis Database ID', 'litespeed-cache' ) ; ?></h4>
100
-
101
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_DB_ID, 'litespeed-input-short' ) ; ?>
102
- <div class="litespeed-desc">
103
- <?php echo __( 'Database to be used', 'litespeed-cache' ) ; ?>
104
- </div>
105
- </div>
106
-
107
- <div class='litespeed-col-br'></div>
108
-
109
- <div class='litespeed-col-auto'>
110
- <h4><?php echo __( 'Global Groups', 'litespeed-cache' ) ; ?></h4>
111
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS, 30 ) ; ?>
112
- <div class="litespeed-desc">
113
- <?php echo __( 'Groups cached at the network level.', 'litespeed-cache' ) ; ?>
114
- <?php echo __('One per line.', 'litespeed-cache'); ?>
115
- </div>
116
- </div>
117
-
118
- <div class='litespeed-col-auto'>
119
- <h4><?php echo __( 'Do Not Cache Groups', 'litespeed-cache' ) ; ?></h4>
120
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS, 30 ) ; ?>
121
- <div class="litespeed-desc">
122
- <?php echo __('One per line.', 'litespeed-cache'); ?>
123
- </div>
124
- </div>
125
-
126
- <div class='litespeed-col-auto'>
127
- <div class="litespeed-row">
128
- <div class="litespeed-col-inc"><?php echo __( 'Persistent Connection', 'litespeed-cache' ) ; ?></div>
129
- <?php $this->build_toggle( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PERSISTENT ) ; ?>
130
- </div>
131
- <div class="litespeed-desc">
132
- <?php echo __( 'Use keep-alive connections to speed up cache operations.', 'litespeed-cache' ) ; ?>
133
- </div>
134
- <div class="litespeed-row litespeed-top30">
135
- <div class="litespeed-col-inc"><?php echo __( 'Cache Wp-Admin', 'litespeed-cache' ) ; ?></div>
136
- <?php $this->build_toggle( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_ADMIN ) ; ?>
137
- </div>
138
- <div class="litespeed-desc">
139
- <?php echo __( 'Improve wp-admin speed through caching. (May encounter expired data)', 'litespeed-cache' ) ; ?>
140
- </div>
141
- </div>
142
-
143
- <div class='litespeed-col-auto'>
144
- <div class="litespeed-row">
145
- <div class="litespeed-col-inc"><?php echo __( 'Store Transients', 'litespeed-cache' ) ; ?></div>
146
- <?php $this->build_toggle( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_TRANSIENTS ) ; ?>
147
- </div>
148
- <div class="litespeed-desc">
149
- <?php echo sprintf( __( 'Save transients in database when %1$s is %2$s.', 'litespeed-cache' ), '<code>' . __( 'Cache Wp-Admin', 'litespeed-cache' ) . '</code>', '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?>
150
- <br />
151
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:cache:object_cache#store_transients' ) ; ?>
152
- </div>
153
- </div>
154
-
155
- </div>
156
- </td>
157
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.cache_resources.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <!-- build_setting_cache_resources -->
6
- <tr>
7
- <th><?php echo __('Cache PHP Resources', 'litespeed-cache'); ?></th>
8
- <td>
9
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_RES); ?>
10
- <div class="litespeed-desc">
11
- <?php echo __('Some themes and plugins add resources via a PHP request.', 'litespeed-cache'); ?>
12
- <?php echo __('Caching these pages may improve server performance by avoiding unnecessary PHP calls.', 'litespeed-cache'); ?>
13
- <br /><font class="litespeed-warning">
14
- ⚠️
15
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
16
- </font>
17
- </div>
18
- </td>
19
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.check_adv_file.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
- <tr>
6
- <th><?php echo __( 'Check Advanced Cache', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php
9
- $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE;
10
- $this->build_checkbox($id, __('Include advanced-cache.php', 'litespeed-cache'), $_options[$id]);
11
- ?>
12
- <div class="litespeed-desc">
13
- <?php echo __( 'The advanced-cache.php file is used by many caching plugins to signal that a cache is active.', 'litespeed-cache' ) ; ?>
14
- <?php echo __( 'When this option is checked and this file is detected as belonging to another plugin, LiteSpeed\'s caching functionality will not work.', 'litespeed-cache' ) ; ?>
15
- </div>
16
- <p>
17
- <i><?php echo __( 'You may need to uncheck this option if you are using multiple optimization plugins.', 'litespeed-cache' ) ; ?></i>
18
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:customizations:multi-cache-plugins' ) ; ?>
19
- </p>
20
-
21
- </td>
22
- </tr>
23
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.exclude_cookies.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
- ?>
4
-
5
- <tr>
6
- <th><?php echo __( 'Do Not Cache Cookies', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php
9
- $id = LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES;
10
-
11
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
12
-
13
- $this->build_textarea($id, false, str_replace('|', "\n", $_options[$id]));//, !$file_writable
14
- ?>
15
- <div class="litespeed-desc">
16
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'cookies', 'litespeed-cache') ) ; ?>
17
- <i>
18
- <?php echo sprintf(__('Spaces should have a backslash in front of them, %s.', 'litespeed-cache'), '<code>\ </code>'); ?>
19
- <?php echo __('One per line.', 'litespeed-cache'); ?>
20
- </i>
21
- <br /><font class="litespeed-warning">
22
- ⚠️
23
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
24
- </font>
25
- </div>
26
- </td>
27
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.exclude_useragent.php DELETED
@@ -1,26 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <tr>
7
- <th><?php echo __( 'Do Not Cache User Agents', 'litespeed-cache' ) ; ?></th>
8
- <td>
9
- <?php
10
- $file_writable = LiteSpeed_Cache_Admin_Rules::writable();
11
-
12
- $this->build_input(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS, 'litespeed-input-long');//, !$file_writable
13
- ?>
14
- <div class="litespeed-desc">
15
- <?php echo sprintf( __( 'To prevent %s from being cached, enter it here.', 'litespeed-cache' ), __( 'user agents', 'litespeed-cache') ) ; ?>
16
- <i>
17
- <?php echo sprintf( __( 'SYNTAX: Separate each user agent with a bar, %s.', 'litespeed-cache' ), '<code>|</code>' ) ; ?>
18
- <?php echo sprintf( __( 'Spaces should have a backslash in front of them, %s.', 'litespeed-cache' ), '<code>\</code>' ) ; ?>
19
- </i>
20
- <br /><font class="litespeed-warning">
21
- ⚠️
22
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
23
- </font>
24
- </div>
25
- </td>
26
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.media_webp.php DELETED
@@ -1,17 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
- <tr>
6
- <th class="litespeed-padding-left"><?php echo __( 'Image WebP Replacement', 'litespeed-cache' ) ; ?></th>
7
- <td>
8
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ) ; ?>
9
- <div class="litespeed-desc">
10
- <?php echo sprintf( __( 'Significantly improve load time by replacing images with their optimized %s versions.', 'litespeed-cache' ), '.webp' ) ; ?>
11
- <br /><font class="litespeed-warning">
12
- ⚠️
13
- <?php echo __('This setting will edit the .htaccess file.', 'litespeed-cache'); ?>
14
- </font>
15
- </div>
16
- </td>
17
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_inc.purge_on_upgrade.php DELETED
@@ -1,14 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
- <!-- build_setting_purge_on_upgrade -->
6
- <tr>
7
- <th><?php echo __('Purge All On Upgrade', 'litespeed-cache'); ?></th>
8
- <td>
9
- <?php $this->build_switch(LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE); ?>
10
- <div class="litespeed-desc">
11
- <?php echo __('When enabled, the cache will automatically purge when any plugins, themes, or WordPress core is upgraded.', 'litespeed-cache'); ?>
12
- </div>
13
- </td>
14
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_media.php DELETED
@@ -1,269 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $last_responsive_placeholder_generated = LiteSpeed_Cache_Media::get_summary() ;
5
-
6
- ?>
7
-
8
- <h3 class="litespeed-title-short">
9
- <?php echo __('Media Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media', false, 'litespeed-learn-more' ) ; ?>
11
- </h3>
12
-
13
- <table><tbody>
14
- <tr>
15
- <th><?php echo __( 'Lazy Load Images', 'litespeed-cache' ) ; ?></th>
16
- <td>
17
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY ) ; ?>
18
- <div class="litespeed-desc">
19
- <?php echo __( 'Load images only when they enter the viewport.', 'litespeed-cache' ) ; ?>
20
- <?php echo __( 'This can improve page loading time by reducing initial HTTP requests.', 'litespeed-cache' ) ; ?>
21
- <br /><font class="litespeed-success">
22
- 💡:
23
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media:lazy-load-style" target="_blank"><?php echo __('Adding Style to Your Lazy-Loaded Images', 'litespeed-cache') ; ?></a>
24
- </font>
25
- </div>
26
- </td>
27
- </tr>
28
-
29
- <tr>
30
- <th><?php echo __( 'Lazy Load Image Excludes', 'litespeed-cache' ) ; ?></th>
31
- <td>
32
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ) ; ?>
33
- <div class="litespeed-desc">
34
- <?php echo __( 'Listed images will not be lazy loaded.', '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_media_lazy_img_excludes</code>' ) ; ?>
40
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-lazy="1"</code>' ) ; ?>
41
- </font>
42
- </div>
43
- </td>
44
- </tr>
45
-
46
- <tr>
47
- <th><?php echo __( 'Lazy Load Image Class Name Excludes', 'litespeed-cache' ) ; ?></th>
48
- <td>
49
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_CLS_EXC ) ; ?>
50
- <div class="litespeed-desc">
51
- <?php echo __( 'Images containing these class names will not be lazy loaded.', 'litespeed-cache' ) ; ?>
52
- <?php echo __( 'Both full and partial strings can be used.', 'litespeed-cache' ) ; ?>
53
- <?php echo __('One per line.', 'litespeed-cache'); ?>
54
- </div>
55
- </td>
56
- </tr>
57
-
58
- <tr>
59
- <th><?php echo __( 'Lazy Load Image Placeholder', 'litespeed-cache' ) ; ?></th>
60
- <td>
61
- <?php $this->build_input( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY_PLACEHOLDER, 'litespeed-input-long' ) ; ?>
62
- <div class="litespeed-desc">
63
- <?php echo __( 'Specify a base64 image to be used as a placeholder while other images finish loading.', 'litespeed-cache' ) ; ?>
64
- <br /><?php echo sprintf( __( 'This can be predefined in %2$s as well using constant %1$s, with this setting taking priority.', 'litespeed-cache' ), '<code>LITESPEED_PLACEHOLDER</code>', '<code>wp-config.php</code>' ) ; ?>
65
- <br /><?php echo sprintf( __( 'By default a gray image placeholder %s will be used.', 'litespeed-cache' ), '<code>data:image/gif;base64,R0lGODdhAQABAPAAAMPDwwAAACwAAAAAAQABAAACAkQBADs=</code>' ) ; ?>
66
- <br /><?php echo sprintf( __( 'For example, %s can be used for a transparent placeholder.', 'litespeed-cache' ), '<code>data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7</code>' ) ; ?>
67
- </div>
68
- </td>
69
- </tr>
70
-
71
- <tr>
72
- <th class="litespeed-padding-left"><?php echo __( 'Responsive Placeholder', 'litespeed-cache' ) ; ?></th>
73
- <td>
74
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP ) ; ?>
75
- <div class="litespeed-desc">
76
- <?php echo __( 'Responsive image placeholders can help to reduce layout reshuffle when images are loaded.', 'litespeed-cache' ) ; ?>
77
- <?php echo __( 'This will generate the placeholder with same dimensions as the image if it has the width and height attributes.', 'litespeed-cache' ) ; ?>
78
- </div>
79
- </td>
80
- </tr>
81
-
82
- <tr>
83
- <th class="litespeed-padding-left"><?php echo __( 'Responsive Placeholder Background Color', 'litespeed-cache' ) ; ?></th>
84
- <td>
85
- <?php $id = LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_COLOR ; ?>
86
- <?php $this->build_input( $id, false, null, null, '', 'color' ) ; ?>
87
- <div class="litespeed-desc">
88
- <?php echo __( 'Specify the placeholder color you want to use.', 'litespeed-cache' ) ; ?>
89
- <?php $this->recommended( $id ) ; ?>
90
- </div>
91
- </td>
92
- </tr>
93
-
94
- <tr>
95
- <th class="litespeed-padding-left"><?php echo __( 'Generate Reponsive Placeholder In Background', 'litespeed-cache' ) ; ?></th>
96
- <td>
97
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_ASYNC ) ; ?>
98
- <div class="litespeed-desc">
99
- <?php echo sprintf( __( 'Automatically generate %s in the background via a cron-based queue.', 'litespeed-cache' ), __( 'Responsive Placeholder', 'litespeed-cache' ) ) ; ?>
100
- <?php echo sprintf(
101
- __( 'If set to %1$s, before the placeholder is localized, the %2$s configuration will be used.', 'litespeed-cache' ),
102
- '<code>' . __('ON', 'litespeed-cache') . '</code>',
103
- __( 'Lazy Load Image Placeholder', 'litespeed-cache' )
104
- ) ; ?>
105
- <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ) ; ?>
106
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#generate_responsive_placeholder' ) ; ?>
107
- </div>
108
-
109
- <?php if ( $last_responsive_placeholder_generated ) : ?>
110
- <div class="litespeed-desc litespeed-left20">
111
- <?php if ( ! empty( $last_responsive_placeholder_generated[ 'last_request' ] ) ) : ?>
112
- <p>
113
- <?php echo __( 'Last generated', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::readable_time( $last_responsive_placeholder_generated[ 'last_request' ] ) . '</code>' ; ?>
114
- </p>
115
- <?php endif ; ?>
116
- <?php if ( ! empty( $last_responsive_placeholder_generated[ 'queue' ] ) ) : ?>
117
- <div class="litespeed-callout-warning">
118
- <h4><?php echo __( 'Size list in queue waiting for cron','litespeed-cache' ) ; ?></h4>
119
- <p>
120
- <?php echo implode( ' ', $last_responsive_placeholder_generated[ 'queue' ] ) ; ?>
121
- </p>
122
- </p>
123
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_MEDIA, LiteSpeed_Cache_Media::TYPE_GENERATE_PLACEHOLDER ) ; ?>" class="litespeed-btn-success">
124
- <?php echo __( 'Run Queue Manually', 'litespeed-cache' ) ; ?>
125
- </a>
126
- <?php endif ; ?>
127
- </div>
128
- <?php endif ; ?>
129
- </td>
130
- </tr>
131
-
132
- <tr>
133
- <th><?php echo __( 'Lazy Load Iframes', 'litespeed-cache' ) ; ?></th>
134
- <td>
135
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY ) ; ?>
136
- <div class="litespeed-desc">
137
- <?php echo __( 'Load iframes only when they enter the viewport.', 'litespeed-cache' ) ; ?>
138
- <?php echo __( 'This can improve page loading time by reducing initial HTTP requests.', 'litespeed-cache' ) ; ?>
139
- </div>
140
- </td>
141
- </tr>
142
-
143
- <tr>
144
- <th><?php echo __( 'Inline Lazy Load Images Library', 'litespeed-cache' ) ; ?></th>
145
- <td>
146
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZYJS_INLINE ) ; ?>
147
- <div class="litespeed-desc">
148
- <?php echo __( 'Include the lazy load image Javascript library inline.', 'litespeed-cache' ) ; ?>
149
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
150
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#inline_lazy_load_images_library' ) ; ?>
151
- </div>
152
- </td>
153
- </tr>
154
-
155
- <tr>
156
- <th><?php echo __( 'Optimize Automatically', 'litespeed-cache' ) ; ?></th>
157
- <td>
158
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_AUTO ) ; ?>
159
- <div class="litespeed-desc">
160
- <?php echo __( 'Automatically request optimization via cron job.', 'litespeed-cache' ) ; ?>
161
- <?php echo sprintf( __( 'Requests can only be sent when recovered credits is %s or more.', 'litespeed-cache' ), '<code>' . LiteSpeed_Cache_Img_Optm::NUM_THRESHOLD_AUTO_REQUEST . '</code>' ) ; ?>
162
- </div>
163
- </td>
164
- </tr>
165
-
166
- <tr>
167
- <th class="litespeed-padding-left"><?php echo __( 'Optimization Cron', 'litespeed-cache' ) ; ?></th>
168
- <td>
169
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON ) ; ?>
170
- <div class="litespeed-desc">
171
- <?php echo __( 'Disabling this will stop the cron job responsible for fetching optimized images from LiteSpeed\'s Image Server.', 'litespeed-cache' ) ; ?>
172
- </div>
173
- </td>
174
- </tr>
175
-
176
- <tr>
177
- <th class="litespeed-padding-left"><?php echo __( 'Optimize Original Images', 'litespeed-cache' ) ; ?></th>
178
- <td>
179
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ; ?>
180
- <div class="litespeed-desc">
181
- <?php echo __( 'Optimize images and save backups of the originals in the same folder.', 'litespeed-cache' ) ; ?>
182
- </div>
183
- </td>
184
- </tr>
185
-
186
- <tr>
187
- <th class="litespeed-padding-left"><?php echo __( 'Remove Original Backups', 'litespeed-cache' ) ; ?></th>
188
- <td>
189
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_RM_ORI_BKUP ) ; ?>
190
- <div class="litespeed-desc">
191
- <?php echo __( 'Automatically remove the original image backups after fetching optimized images.', 'litespeed-cache' ) ; ?>
192
-
193
- <br /><font class="litespeed-danger">
194
- 🚨
195
- <?php echo __( 'This is irreversible.', 'litespeed-cache' ) ; ?>
196
- <?php echo __( 'You will be unable to Revert Optimization once the backups are deleted!', 'litespeed-cache' ) ; ?>
197
- </font>
198
- </div>
199
- </td>
200
- </tr>
201
-
202
- <tr>
203
- <th class="litespeed-padding-left"><?php echo __( 'Optimize WebP Versions', 'litespeed-cache' ) ; ?></th>
204
- <td>
205
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ; ?>
206
- <div class="litespeed-desc">
207
- <?php echo __( 'Request WebP versions of original images when doing optimization.', 'litespeed-cache' ) ; ?>
208
- </div>
209
- </td>
210
- </tr>
211
-
212
- <tr>
213
- <th class="litespeed-padding-left"><?php echo __( 'Optimize Losslessly', 'litespeed-cache' ) ; ?></th>
214
- <td>
215
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS ) ; ?>
216
- <div class="litespeed-desc">
217
- <?php echo __( 'Optimize images using lossless compression.', 'litespeed-cache' ) ; ?>
218
- <?php echo __( 'This can improve quality but may result in larger images than lossy compression will.', 'litespeed-cache' ) ; ?>
219
- </div>
220
- </td>
221
- </tr>
222
-
223
- <tr>
224
- <th class="litespeed-padding-left"><?php echo __( 'Preserve EXIF/XMP data', 'litespeed-cache' ) ; ?></th>
225
- <td>
226
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF ) ; ?>
227
- <div class="litespeed-desc">
228
- <?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ) ; ?>
229
- <?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ) ; ?>
230
- </div>
231
- </td>
232
- </tr>
233
-
234
- <?php
235
- if ( ! is_multisite() ) :
236
- // webp
237
- require LSCWP_DIR . 'admin/tpl/setting/settings_inc.media_webp.php' ;
238
-
239
- endif ;
240
- ?>
241
-
242
- <tr>
243
- <th class="litespeed-padding-left"><?php echo __( 'WebP Attribute To Replace', 'litespeed-cache' ) ; ?></th>
244
- <td>
245
- <?php $id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ; ?>
246
- <?php $this->build_textarea2( $id, 40 ) ; ?>
247
- <?php $this->recommended( $id, true ) ; ?>
248
- <div class="litespeed-desc">
249
- <?php echo __( 'Specify which element attributes will be replaced with WebP.', 'litespeed-cache' ) ; ?>
250
- <?php echo __( 'Only attributes listed here will be replaced.', 'litespeed-cache' ) ; ?>
251
- <br /><?php echo sprintf( __( 'Use the format %1$s or %2$s (element is optional).', 'litespeed-cache' ), '<code>element.attribute</code>', '<code>.attribute</code>' ) ; ?>
252
- <?php echo __('One per line.', 'litespeed-cache'); ?>
253
- </div>
254
- </td>
255
- </tr>
256
-
257
- <tr>
258
- <th class="litespeed-padding-left"><?php echo __( 'WebP For Extra srcset', 'litespeed-cache' ) ; ?></th>
259
- <td>
260
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET ) ; ?>
261
- <div class="litespeed-desc">
262
- <?php echo sprintf( __( 'Enable replacement of WebP in %s elements that were generated outside of WordPress logic.', 'litespeed-cache' ), '<code>srcset</code>' ) ; ?>
263
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#webp_for_extra_srcset' ) ; ?>
264
- </div>
265
- </td>
266
- </tr>
267
-
268
-
269
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_optimize.php DELETED
@@ -1,281 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- $last_critical_css_generated = LiteSpeed_Cache_CSS::get_summary() ;
5
-
6
- ?>
7
-
8
- <h3 class="litespeed-title-short">
9
- <?php echo __('Optimization Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:optimize', false, 'litespeed-learn-more' ) ; ?>
11
- </h3>
12
-
13
- <?php if ( ! LiteSpeed_Cache_Data::optm_available() ) : ?>
14
- <div class="litespeed-callout-danger">
15
- <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
16
- <p><?php echo sprintf( __( 'Failed to create Optimizer table. Please follow <a %s>Table Creation guidance from LiteSpeed Wiki</a> to finish setup.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation" target="_blank"' ) ; ?></p>
17
- </div>
18
- <?php endif; ?>
19
-
20
- <div class="litespeed-callout-warning">
21
- <h4><?php echo __( 'NOTICE', 'litespeed-cache' ) ; ?></h4>
22
- <p><?php echo __( 'Please test thoroughly when enabling any option in this list. After changing Minify/Combine settings, please do a Purge All action.', 'litespeed-cache' ) ; ?></p>
23
- </div>
24
-
25
-
26
- <table><tbody>
27
- <tr>
28
- <th><?php echo __( 'CSS Minify', 'litespeed-cache' ) ; ?></th>
29
- <td>
30
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ; ?>
31
- <div class="litespeed-desc">
32
- <?php echo __( 'Minify CSS files.', 'litespeed-cache' ) ; ?>
33
- </div>
34
- </td>
35
- </tr>
36
-
37
- <tr>
38
- <th><?php echo __( 'CSS Combine', 'litespeed-cache' ) ; ?></th>
39
- <td>
40
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ; ?>
41
- <div class="litespeed-desc">
42
- <?php echo __( 'Combine CSS files.', 'litespeed-cache' ) ; ?>
43
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:optimize-issue" target="_blank"><?php echo __( 'How to Fix Problems Caused by CSS/JS Optimization.', 'litespeed-cache' ) ; ?></a>
44
- </div>
45
- </td>
46
- </tr>
47
-
48
- <tr>
49
- <th><?php echo __( 'CSS HTTP/2 Push', 'litespeed-cache' ) ; ?></th>
50
- <td>
51
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ; ?>
52
- <div class="litespeed-desc">
53
- <?php echo __( 'Pre-send internal CSS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ) ; ?>
54
- </div>
55
- </td>
56
- </tr>
57
-
58
- <tr>
59
- <th><?php echo __( 'JS Minify', 'litespeed-cache' ) ; ?></th>
60
- <td>
61
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ; ?>
62
- <div class="litespeed-desc">
63
- <?php echo __( 'Minify JS files.', 'litespeed-cache' ) ; ?>
64
- </div>
65
- </td>
66
- </tr>
67
-
68
- <tr>
69
- <th><?php echo __( 'JS Combine', 'litespeed-cache' ) ; ?></th>
70
- <td>
71
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ; ?>
72
- <div class="litespeed-desc">
73
- <?php echo __( 'Combine JS files.', 'litespeed-cache' ) ; ?>
74
- <a href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:optimize-issue" target="_blank"><?php echo __( 'How to Fix Problems Caused by CSS/JS Optimization.', 'litespeed-cache' ) ; ?></a>
75
- </div>
76
- </td>
77
- </tr>
78
-
79
- <tr>
80
- <th><?php echo __( 'JS HTTP/2 Push', 'litespeed-cache' ) ; ?></th>
81
- <td>
82
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ; ?>
83
- <div class="litespeed-desc">
84
- <?php echo __( 'Pre-send internal JS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ) ; ?>
85
- </div>
86
- </td>
87
- </tr>
88
-
89
- <tr>
90
- <th><?php echo __( 'CSS/JS Cache TTL', 'litespeed-cache' ) ; ?></th>
91
- <td>
92
- <?php $id = LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ; ?>
93
- <?php $this->build_input( $id ) ; ?> <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
94
- <div class="litespeed-desc">
95
- <?php echo sprintf( __( 'Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s seconds.', 'litespeed-cache' ), 3600 ) ; ?>
96
- <?php $this->recommended( $id ) ; ?>
97
- </div>
98
- </td>
99
- </tr>
100
-
101
- <tr>
102
- <th><?php echo __( 'HTML Minify', 'litespeed-cache' ) ; ?></th>
103
- <td>
104
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ; ?>
105
- <div class="litespeed-desc">
106
- <?php echo __( 'Minify HTML content.', 'litespeed-cache' ) ; ?>
107
- </div>
108
- </td>
109
- </tr>
110
-
111
- <tr>
112
- <th class="litespeed-padding-left"><?php echo __( 'Inline CSS Minify', 'litespeed-cache' ) ; ?></th>
113
- <td>
114
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_INLINE_MINIFY ) ; ?>
115
- <div class="litespeed-desc">
116
- <?php echo __( 'Minify inline CSS code.', 'litespeed-cache' ) ; ?>
117
- </div>
118
- </td>
119
- </tr>
120
-
121
- <tr>
122
- <th class="litespeed-padding-left"><?php echo __( 'Inline JS Minify', 'litespeed-cache' ) ; ?></th>
123
- <td>
124
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_INLINE_MINIFY ) ; ?>
125
- <div class="litespeed-desc">
126
- <?php echo __( 'Minify inline JS code.', 'litespeed-cache' ) ; ?>
127
- </div>
128
- </td>
129
- </tr>
130
-
131
- <tr>
132
- <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
133
- <td>
134
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ; ?>
135
- <div class="litespeed-desc">
136
- <?php echo __( 'Optimize CSS delivery.', 'litespeed-cache' ) ; ?>
137
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?><br />
138
- <?php echo sprintf( __( 'When this option is turned %s, it will also load Google Fonts asynchronously.', 'litespeed-cache' ), '<code>' . __( 'ON', 'litespeed-cache' ) . '</code>' ) ; ?>
139
- <br /><font class="litespeed-success">
140
- <?php echo __('API', 'litespeed-cache'); ?>:
141
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-async="1"</code>' ) ; ?>
142
- </font>
143
- </div>
144
- </td>
145
- </tr>
146
-
147
- <tr>
148
- <th class="litespeed-padding-left"><?php echo __( 'Generate Critical CSS', 'litespeed-cache' ) ; ?></th>
149
- <td>
150
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_OPTM_CCSS_GEN ) ; ?>
151
- <div class="litespeed-desc">
152
- <?php echo sprintf( __( 'Leave this option %1$s to allow communication with LiteSpeed CCSS server. If set to %2$s, Critical CSS will not be generated.', 'litespeed-cache' ), '<code>' . __( 'ON', 'litespeed-cache' ) . '</code>', '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?><br />
153
- <?php echo sprintf( __( 'This option only works if %1$s is %2$s.', 'litespeed-cache' ), '<code>' . __( 'Load CSS Asynchronously', 'litespeed-cache' ) . '</code>', '<code>' . __( 'ON', 'litespeed-cache' ) . '</code>' ) ; ?>
154
- </div>
155
- </td>
156
- </tr>
157
-
158
- <tr>
159
- <th class="litespeed-padding-left"><?php echo __( 'Generate Critical CSS In Background', 'litespeed-cache' ) ; ?></th>
160
- <td>
161
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC ) ; ?>
162
- <div class="litespeed-desc">
163
- <?php echo __( 'Automatically generate critical CSS in the background via a cron-based queue.', 'litespeed-cache' ) ; ?>
164
- <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ) ; ?>
165
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:optimize#generate_critical_css' ) ; ?>
166
- </div>
167
-
168
- <?php if ( $last_critical_css_generated ) : ?>
169
- <div class="litespeed-desc litespeed-left20">
170
- <?php if ( ! empty( $last_critical_css_generated[ 'last_request' ] ) ) : ?>
171
- <p>
172
- <?php echo __( 'Last generated', 'litespeed-cache' ) . ': <code>' . LiteSpeed_Cache_Utility::readable_time( $last_critical_css_generated[ 'last_request' ] ) . '</code>' ; ?>
173
- </p>
174
- <p>
175
- <?php echo __( 'Last requested cost', 'litespeed-cache' ) . ': <code>' . $last_critical_css_generated[ 'last_spent' ] . 's</code>' ; ?>
176
- </p>
177
- <?php endif ; ?>
178
- <?php if ( ! empty( $last_critical_css_generated[ 'queue' ] ) ) : ?>
179
- <div class="litespeed-callout-warning">
180
- <h4><?php echo __( 'URL list in queue waiting for cron','litespeed-cache' ) ; ?></h4>
181
- <p>
182
- <?php foreach ( $last_critical_css_generated[ 'queue' ] as $k => $v ) : ?>
183
- <?php if ( ! is_array( $v ) ) continue ; ?>
184
- <?php echo $v[ 'url' ] ; ?>
185
- <?php if ( $v[ 'is_mobile' ] ) echo ' <span title="mobile">📱</span>' ; ?>
186
- <br />
187
- <?php endforeach ; ?>
188
- </p>
189
- </p>
190
- <a href="<?php echo LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CSS, LiteSpeed_Cache_CSS::TYPE_GENERATE_CRITICAL ) ; ?>" class="litespeed-btn-success">
191
- <?php echo __( 'Run Queue Manually', 'litespeed-cache' ) ; ?>
192
- </a>
193
- <?php endif ; ?>
194
- </div>
195
- <?php endif ; ?>
196
- </td>
197
- </tr>
198
-
199
- <tr>
200
- <th class="litespeed-padding-left"><?php echo __( 'Separate CCSS Cache Post Types', 'litespeed-cache' ) ; ?></th>
201
- <td>
202
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_POSTTYPE ) ; ?>
203
- <div class="litespeed-desc">
204
- <?php echo __('List post types where each item of that type should have its own CCSS generated.', 'litespeed-cache'); ?>
205
- <?php echo sprintf( __( 'For example, if every Page on the site has different formatting, enter %s in the box. Separate critical CSS files will be stored for every Page on the site.', 'litespeed-cache' ), '<code>page</code>' ) ; ?>
206
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:optimize#separate_ccss_cache_post_types' ) ; ?>
207
- </div>
208
- </td>
209
- </tr>
210
-
211
- <tr>
212
- <th class="litespeed-padding-left"><?php echo __( 'Separate CCSS Cache URIs', 'litespeed-cache' ) ; ?></th>
213
- <td>
214
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_URI ) ; ?>
215
- <div class="litespeed-desc">
216
- <?php echo __( 'Separate critical CSS files will be generated for paths containing these strings.', 'litespeed-cache' ) ; ?>
217
- <?php $this->_uri_usage_example() ; ?>
218
- </div>
219
- </td>
220
- </tr>
221
-
222
- <tr>
223
- <th class="litespeed-padding-left"><?php echo __( 'Inline CSS Async Lib', 'litespeed-cache' ) ; ?></th>
224
- <td>
225
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE ) ; ?>
226
- <div class="litespeed-desc">
227
- <?php echo __( 'This will inline the asynchronous CSS library to avoid render blocking.', 'litespeed-cache' ) ; ?>
228
- </div>
229
- </td>
230
- </tr>
231
-
232
- <tr>
233
- <th><?php echo __( 'Load JS Deferred', 'litespeed-cache' ) ; ?></th>
234
- <td>
235
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ; ?>
236
- <div class="litespeed-desc">
237
- <?php echo __( 'Doing so can help reduce resource contention and improve performance.', 'litespeed-cache' ) ; ?>
238
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
239
- </div>
240
- </td>
241
- </tr>
242
-
243
- <tr>
244
- <th><?php echo __( 'Exclude JQuery', 'litespeed-cache' ) ; ?></th>
245
- <td>
246
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ; ?>
247
- <div class="litespeed-desc">
248
- <?php echo sprintf( __( 'Improve compatibility with inline JS by preventing jQuery optimization. (Recommended Setting: %s)', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ) ) ; ?>
249
- <br /><font class="litespeed-warning">
250
- ⚠️
251
- <?php echo sprintf( __( 'If there is any JS error related to %1$s when enabled %2$s, please turn on this option.', 'litespeed-cache' ), 'jQuery', __( 'JS Combine', 'litespeed-cache' ) ) ; ?>
252
- </font>
253
- </div>
254
- </td>
255
- </tr>
256
-
257
- <tr>
258
- <th><?php echo __( 'DNS Prefetch', 'litespeed-cache' ) ; ?></th>
259
- <td>
260
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ) ; ?>
261
- <div class="litespeed-desc">
262
- <?php echo __( 'Prefetching DNS can reduce latency for visiters.', 'litespeed-cache' ) ; ?>
263
- <?php echo __( 'For example', 'litespeed-cache' ) ; ?>: <code>//www.example.com</code>
264
- <?php echo __( 'One per line.', 'litespeed-cache' ) ; ?>
265
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:optimize#dns_prefetch' ) ; ?>
266
- </div>
267
- </td>
268
- </tr>
269
-
270
- <tr>
271
- <th><?php echo __( 'Remove Comments', 'litespeed-cache' ) ; ?></th>
272
- <td>
273
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_RM_COMMENT ) ; ?>
274
- <div class="litespeed-desc">
275
- <?php echo __( 'Remove the comments inside of JS/CSS files when minifying.', 'litespeed-cache' ) ; ?>
276
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
277
- </div>
278
- </td>
279
- </tr>
280
-
281
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_purge.php DELETED
@@ -1,102 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('Purge Settings', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:purge', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
-
11
- <?php $this->cache_disabled_warning() ; ?>
12
-
13
- <?php
14
- $purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options();
15
- $optionArr = array(
16
- LiteSpeed_Cache_Config::PURGE_ALL_PAGES => __('All pages', 'litespeed-cache'),
17
- LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => __('Front page', 'litespeed-cache'),
18
- LiteSpeed_Cache_Config::PURGE_HOME_PAGE => __('Home page', 'litespeed-cache'),
19
- LiteSpeed_Cache_Config::PURGE_PAGES => __('Pages', 'litespeed-cache'),
20
-
21
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS => __('All pages with Recent Posts Widget', 'litespeed-cache'),
22
-
23
- LiteSpeed_Cache_Config::PURGE_AUTHOR => __('Author archive', 'litespeed-cache'),
24
- LiteSpeed_Cache_Config::PURGE_POST_TYPE => __('Post type archive', 'litespeed-cache'),
25
-
26
- LiteSpeed_Cache_Config::PURGE_YEAR => __('Yearly archive', 'litespeed-cache'),
27
- LiteSpeed_Cache_Config::PURGE_MONTH => __('Monthly archive', 'litespeed-cache'),
28
- LiteSpeed_Cache_Config::PURGE_DATE => __('Daily archive', 'litespeed-cache'),
29
-
30
- LiteSpeed_Cache_Config::PURGE_TERM => __('Term archive (include category, tag, and tax)', 'litespeed-cache'),
31
- );
32
-
33
- // break line at these ids
34
- $breakArr = array(
35
- LiteSpeed_Cache_Config::PURGE_PAGES,
36
- LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS,
37
- LiteSpeed_Cache_Config::PURGE_POST_TYPE,
38
- LiteSpeed_Cache_Config::PURGE_DATE,
39
- );
40
-
41
- ?>
42
-
43
- <table><tbody>
44
-
45
- <?php if (!is_multisite()): ?>
46
- <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.purge_on_upgrade.php'; ?>
47
- <?php endif; ?>
48
-
49
- <tr>
50
- <th><?php echo __('Auto Purge Rules For Publish/Update', 'litespeed-cache'); ?></th>
51
- <td>
52
- <div class="litespeed-callout-warning">
53
- <h4><?php echo __('Note', 'litespeed-cache'); ?></h4>:
54
- <i>
55
- <?php echo __('Select "All" if there are dynamic widgets linked to posts on pages other than the front or home pages.', 'litespeed-cache'); ?><br />
56
- <?php echo __('Other checkboxes will be ignored.', 'litespeed-cache'); ?><br />
57
- <?php echo __('Select only the archive types that are currently used, the others can be left unchecked.', 'litespeed-cache'); ?>
58
- </i>
59
- </div>
60
- <div class="litespeed-top20">
61
- <?php
62
- foreach ($optionArr as $id => $title){
63
-
64
- $this->build_checkbox("purge_$id", $title, in_array($id, $purge_options));
65
-
66
- if ( in_array($id, $breakArr) ){
67
- echo '</div><div class="litespeed-top20">';
68
- }
69
- }
70
- ?>
71
- </div>
72
- <div class="litespeed-desc">
73
- <?php echo __('Select which pages will be automatically purged when posts are published/updated.', 'litespeed-cache'); ?>
74
- </div>
75
- </td>
76
- </tr>
77
-
78
- <tr>
79
- <th><?php echo __( 'Scheduled Purge URLs', 'litespeed-cache' ) ; ?></th>
80
- <td>
81
- <?php $this->build_textarea( LiteSpeed_Cache_Config::OPID_TIMED_URLS, 80 ) ; ?>
82
- <div class="litespeed-desc">
83
- <?php echo sprintf( __( 'The URLs here (one per line) will be purged automatically at the time set in the option "%s".', 'litespeed-cache' ), __( 'Scheduled Purge Time', 'litespeed-cache' ) ) ; ?><br />
84
- <?php echo sprintf( __( 'Both %1$s and %2$s are acceptable.', 'litespeed-cache' ), '<code>http://www.example.com/path/url.php</code>', '<code>/path/url.php</code>' ) ; ?>
85
- <?php echo __('One per line.', 'litespeed-cache'); ?>
86
- </div>
87
- </td>
88
- </tr>
89
-
90
- <tr>
91
- <th><?php echo __( 'Scheduled Purge Time', 'litespeed-cache' ) ; ?></th>
92
- <td>
93
- <?php $id = LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ; ?>
94
- <?php $this->build_input( $id, false, null, null, '', 'time' ) ; ?>
95
- <div class="litespeed-desc">
96
- <?php echo sprintf( __( 'Specify the time to purge the "%s" list.', 'litespeed-cache' ), __( 'Scheduled Purge URLs', 'litespeed-cache' ) ) ; ?>
97
- <?php echo sprintf( __( 'Current server time is %s.', 'litespeed-cache' ), '<code>' . date( 'H:i:s' ) . '</code>' ) ; ?>
98
- </div>
99
- </td>
100
- </tr>
101
- </tbody></table>
102
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/setting/settings_tuning.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
- if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- ?>
5
-
6
- <h3 class="litespeed-title-short">
7
- <?php echo __('Tuning Settings', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:tuning', false, 'litespeed-learn-more' ) ; ?>
9
- </h3>
10
- <table><tbody>
11
-
12
- <tr>
13
- <th><?php echo __( 'Combined CSS Priority', 'litespeed-cache' ) ; ?></th>
14
- <td>
15
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_COMBINED_PRIORITY ) ; ?>
16
- <div class="litespeed-desc">
17
- <?php echo __( 'Load combined CSS files before other CSS files.', 'litespeed-cache' ) ; ?>
18
- <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
19
- <br /><font class="litespeed-warning">
20
- ⚠️
21
- <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined CSS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
22
- </font>
23
- <br /><font class="litespeed-success">
24
- <?php echo __('API', 'litespeed-cache'); ?>:
25
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ) ; ?>
26
- </font>
27
- </div>
28
- </td>
29
- </tr>
30
-
31
- <tr>
32
- <th><?php echo __( 'CSS Excludes', 'litespeed-cache' ) ; ?></th>
33
- <td>
34
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_CSS_EXCLUDES); ?>
35
- <div class="litespeed-desc">
36
- <?php echo __( 'Listed CSS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
37
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
38
- <?php echo __('One per line.', 'litespeed-cache'); ?>
39
- <br /><font class="litespeed-success">
40
- <?php echo __('API', 'litespeed-cache'); ?>:
41
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_css_excludes</code>' ) ; ?>
42
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
43
- </font>
44
- </div>
45
- </td>
46
- </tr>
47
-
48
- <tr>
49
- <th><?php echo __( 'Combined JS Priority', 'litespeed-cache' ) ; ?></th>
50
- <td>
51
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_COMBINED_PRIORITY ) ; ?>
52
- <div class="litespeed-desc">
53
- <?php echo __( 'Load combined JS files before other JS files.', 'litespeed-cache' ) ; ?>
54
- <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
55
- <br /><font class="litespeed-warning">
56
- ⚠️
57
- <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined JS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
58
- </font>
59
- <br /><font class="litespeed-success">
60
- <?php echo __('API', 'litespeed-cache'); ?>:
61
- <?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>' ) ; ?>
62
- </font>
63
- </div>
64
- </td>
65
- </tr>
66
-
67
- <tr>
68
- <th><?php echo __( 'JS Excludes', 'litespeed-cache' ) ; ?></th>
69
- <td>
70
- <?php $this->build_textarea(LiteSpeed_Cache_Config::OPID_JS_EXCLUDES); ?>
71
- <div class="litespeed-desc">
72
- <?php echo __( 'Listed JS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
73
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
74
- <?php echo __('One per line.', 'litespeed-cache'); ?>
75
- <br /><font class="litespeed-success">
76
- <?php echo __('API', 'litespeed-cache'); ?>:
77
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_cache_optimize_js_excludes</code>' ) ; ?>
78
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
79
- </font>
80
- </div>
81
- </td>
82
- </tr>
83
-
84
- <tr>
85
- <th><?php echo __( 'Max Combined File Size', 'litespeed-cache' ) ; ?></th>
86
- <td>
87
- <?php $id = LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ; ?>
88
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?> <?php echo __( 'MB', 'litespeed-cache' ) ; ?>
89
- <div class="litespeed-desc">
90
- <?php echo __( 'Specify the maximum size in megabytes for combined files.', 'litespeed-cache' ) ; ?>
91
- <?php echo __( 'Larger numbers will generate fewer files, which is better for achieving higher page scores, but can cause heavy memory usage.', 'litespeed-cache' ) ; ?>
92
- <?php $this->recommended( $id ) ; ?>
93
- </div>
94
- </td>
95
- </tr>
96
-
97
- <tr>
98
- <th><?php echo __( 'Remove Query Strings', 'litespeed-cache' ) ; ?></th>
99
- <td>
100
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ; ?>
101
- <div class="litespeed-desc">
102
- <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
103
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
104
- <br /><font class="litespeed-warning">
105
- ⚠️
106
- <?php echo __( 'Google reCAPTCHA will be bypassed automatically.', 'litespeed-cache' ) ; ?>
107
- </font>
108
- <br /><font class="litespeed-success">
109
- <?php echo __('API', 'litespeed-cache'); ?>:
110
- <?php echo sprintf( __( 'Append query string %s to the resources to bypass this action.', 'litespeed-cache' ), '<code>&_litespeed_rm_qs=0</code>' ) ; ?>
111
- </font>
112
- </div>
113
- </td>
114
- </tr>
115
-
116
- <tr>
117
- <th><?php echo __( 'Load Google Fonts Asynchronously', 'litespeed-cache' ) ; ?></th>
118
- <td>
119
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ; ?>
120
- <div class="litespeed-desc">
121
- <?php echo __( 'Use Web Font Loader library to load Google Fonts asynchronously while leave other CSS intact.', 'litespeed-cache' ) ; ?>
122
- <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ) ; ?>
123
- <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:tuning:google-fonts' ) ; ?>
124
- </div>
125
- </td>
126
- </tr>
127
-
128
- <tr>
129
- <th><?php echo __( 'Remove Google Fonts', 'litespeed-cache' ) ; ?></th>
130
- <td>
131
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ; ?>
132
- <div class="litespeed-desc">
133
- <?php echo __( 'Prevent google fonts from loading on all your pages.', 'litespeed-cache' ) ; ?>
134
- </div>
135
- </td>
136
- </tr>
137
-
138
- <tr>
139
- <th><?php echo __( 'Critical CSS Rules', 'litespeed-cache' ) ; ?></th>
140
- <td>
141
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ; ?>
142
- <div class="litespeed-desc">
143
- <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
144
- </div>
145
- </td>
146
- </tr>
147
-
148
- <tr>
149
- <th><?php echo __( 'JS Deferred Excludes', 'litespeed-cache' ) ; ?></th>
150
- <td>
151
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ; ?>
152
- <div class="litespeed-desc">
153
- <?php echo __( 'Listed JS files will not be deferred.', 'litespeed-cache' ) ; ?>
154
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
155
- <?php echo __('One per line.', 'litespeed-cache'); ?>
156
- <br /><font class="litespeed-success">
157
- <?php echo __('API', 'litespeed-cache'); ?>:
158
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optm_js_defer_exc</code>' ) ; ?>
159
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-defer="1"</code>' ) ; ?>
160
- </font>
161
- </div>
162
- </td>
163
- </tr>
164
-
165
- <tr>
166
- <th><?php echo __( 'Remove WordPress Emoji', 'litespeed-cache' ) ; ?></th>
167
- <td>
168
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ; ?>
169
- <div class="litespeed-desc">
170
- <?php echo __( 'Stop loading wordpress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
171
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
172
- </div>
173
- </td>
174
- </tr>
175
-
176
- <tr>
177
- <th><?php echo __( 'URI Excludes', 'litespeed-cache' ) ; ?></th>
178
- <td>
179
- <?php $this->build_textarea2( LiteSpeed_Cache_Config::ITEM_OPTM_EXCLUDES ) ; ?>
180
- <div class="litespeed-desc">
181
- <?php echo __( 'Prevent any optimization of listed pages.', 'litespeed-cache' ) ; ?>
182
- <?php $this->_uri_usage_example() ; ?>
183
- </div>
184
- </td>
185
- </tr>
186
-
187
- <tr>
188
- <th><?php echo __('Role Excludes', 'litespeed-cache'); ?></th>
189
- <td>
190
- <?php foreach ( $roles as $role => $title ): ?>
191
- <?php $this->build_checkbox( LiteSpeed_Cache_Config::EXCLUDE_OPTIMIZATION_ROLES . "][", $title, $this->config->in_exclude_optimization_roles( $role ), $role ) ; ?>
192
- <?php endforeach; ?>
193
- <div class="litespeed-desc">
194
- <?php echo __( 'Selected roles will be excluded from all optimizations.', 'litespeed-cache' ) ; ?>
195
- </div>
196
- </td>
197
- </tr>
198
-
199
-
200
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/tpl/settings.php DELETED
@@ -1,220 +0,0 @@
1
- <?php
2
- if (!defined('WPINC')) die ;
3
-
4
- $menu_list = array(
5
- 'general' => __('General', 'litespeed-cache'),
6
- 'cache' => __('Cache', 'litespeed-cache'),
7
- 'purge' => __('Purge', 'litespeed-cache'),
8
- 'excludes' => __('Excludes', 'litespeed-cache'),
9
- 'optimize' => __('Optimize', 'litespeed-cache'),
10
- 'tuning' => __('Tuning', 'litespeed-cache'),
11
- 'media' => __('Media', 'litespeed-cache'),
12
- 'cdn' => __('CDN', 'litespeed-cache'),
13
- 'esi' => __('ESI', 'litespeed-cache'),
14
- 'advanced' => __('Advanced', 'litespeed-cache'),
15
- 'debug' => __('Debug', 'litespeed-cache'),
16
- ) ;
17
-
18
- if ($this->show_compatibility_tab()){
19
- $menu_list['compatibilities'] = __('Compatibilities', 'litespeed-cache') ;
20
- }
21
-
22
- $menu_list['crawler'] = __('Crawler', 'litespeed-cache') ;
23
-
24
- global $_options ;
25
- $_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
26
-
27
-
28
- /**
29
- * This hook allows third party plugins to create litespeed cache
30
- * specific configuration.
31
- *
32
- * Each config should append an array containing the following:
33
- * 'title' (required) - The tab's title.
34
- * 'slug' (required) - The slug used for the tab. [a-z][A-Z], [0-9], -, _ permitted.
35
- * 'content' (required) - The tab's content.
36
- *
37
- * Upon saving, only the options with the option group in the input's
38
- * name will be retrieved.
39
- * For example, name="litespeed-cache-conf[my-opt]".
40
- *
41
- * @see TODO: add option save filter.
42
- * @since 1.0.9
43
- * @param array $tabs An array of third party configuration.
44
- * @param array $options The current configuration options.
45
- * @param string $option_group The option group to use for options.
46
- * @param boolean $disableall Whether to disable the settings or not.
47
- * @return mixed An array of third party configs else false on failure.
48
- */
49
- $tp_tabs = apply_filters('litespeed_cache_add_config_tab',
50
- array(),
51
- $_options,
52
- LiteSpeed_Cache_Config::OPTION_NAME,
53
- $this->get_disable_all()
54
- ) ;
55
- if ( !empty($tp_tabs) && is_array($tp_tabs) ) {
56
- foreach ($tp_tabs as $key => $tab) {
57
- if ( !is_array($tab) || !isset($tab['title']) || !isset($tab['slug']) || !isset($tab['content']) ) {
58
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'WARNING: Third party tab input invalid' ) ;
59
- unset($tp_tabs[$key]) ;
60
- continue ;
61
- }
62
- if ( preg_match('/[^-\w]/', $tab['slug']) ) {
63
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'WARNING: Third party config slug contains invalid characters' ) ;
64
- unset($tp_tabs[$key]) ;
65
- continue ;
66
- }
67
- }
68
- }
69
- else {
70
- $tp_tabs = array() ;
71
- }
72
-
73
- /**
74
- * Generate rules for setting usage
75
- * @since 1.6.2
76
- */
77
- global $wp_roles ;
78
- if ( !isset( $wp_roles ) ) {
79
- $wp_roles = new WP_Roles() ;
80
- }
81
-
82
- $roles = array() ;
83
- foreach ( $wp_roles->roles as $k => $v ) {
84
- $roles[ $k ] = $v[ 'name' ] ;
85
- }
86
- ksort( $roles ) ;
87
-
88
- /**
89
- * Switch basic/advanced mode
90
- * @since 1.8.2
91
- */
92
- if ( ! empty( $_GET[ 'mode' ] ) ) {
93
- $adv_mode = $_GET[ 'mode' ] == 'advanced' ? true : false ;
94
- update_option( LiteSpeed_Cache_Config::ITEM_SETTING_MODE, $adv_mode ) ;
95
- }
96
- else {
97
- $adv_mode = get_option( LiteSpeed_Cache_Config::ITEM_SETTING_MODE ) ;
98
- }
99
-
100
- $hide_tabs = array() ;
101
- $_hide_in_basic_mode = '' ;
102
-
103
- if ( ! $adv_mode ) {
104
- $hide_tabs = array(
105
- 'optimize',
106
- 'tuning',
107
- 'media',
108
- 'cdn',
109
- 'esi',
110
- 'advanced',
111
- 'debug',
112
- 'crawler',
113
- ) ;
114
-
115
- $_hide_in_basic_mode = 'class="litespeed-hide"' ;
116
- }
117
-
118
- ?>
119
-
120
- <div class="wrap">
121
- <h1 class="litespeed-h1">
122
- <?php echo __('LiteSpeed Cache Settings', 'litespeed-cache') ; ?>
123
- </h1>
124
- <span class="litespeed-desc">
125
- v<?php echo LiteSpeed_Cache::PLUGIN_VERSION ; ?>
126
- </span>
127
- <hr class="wp-header-end">
128
- </div>
129
- <div class="litespeed-wrap">
130
- <h2 class="litespeed-header">
131
- <?php
132
- $i = 1 ;
133
- $accesskey_set = array() ;
134
- foreach ($menu_list as $tab => $val){
135
- if ( in_array( $tab, $hide_tabs ) ) {
136
- continue ;
137
- }
138
-
139
- $accesskey = '' ;
140
- if ( $i <= 9 ) {
141
- $accesskey = "litespeed-accesskey='$i'" ;
142
- }
143
- else {
144
- $tmp = strtoupper( substr( $tab, 0, 1 ) ) ;
145
- if ( ! in_array( $tmp, $accesskey_set ) ) {
146
- $accesskey_set[] = $tmp ;
147
- $accesskey = "litespeed-accesskey='$tmp'" ;
148
- }
149
- }
150
-
151
- echo "<a class='litespeed-tab' href='#$tab' data-litespeed-tab='$tab' $accesskey>$val</a>" ;
152
- $i ++ ;
153
- }
154
- foreach ($tp_tabs as $val){
155
- $accesskey = '' ;
156
- if ( $i <= 9 ) {
157
- $accesskey = "litespeed-accesskey='$i'" ;
158
- }
159
- else {
160
- $tmp = strtoupper( substr( $val[ 'slug' ], 0, 1 ) ) ;
161
- if ( ! in_array( $tmp, $accesskey_set ) ) {
162
- $accesskey_set[] = $tmp ;
163
- $accesskey = "litespeed-accesskey='$tmp'" ;
164
- }
165
- }
166
-
167
- echo "<a class='litespeed-tab' href='#$val[slug]' data-litespeed-tab='$val[slug]' $accesskey>$val[title]</a>" ;
168
- $i ++ ;
169
- }
170
- ?>
171
- <?php if ( $adv_mode ) : ?>
172
- <a href="admin.php?page=lscache-settings&mode=basic" class="litespeed-tab litespeed-advanced-tab-hide litespeed-right"><?php echo __( 'Hide Advanced Options', 'litespeed-cache' ) ; ?></a>
173
- <?php else : ?>
174
- <a href="admin.php?page=lscache-settings&mode=advanced" class="litespeed-tab litespeed-advanced-tab-show litespeed-right"><?php echo __( 'Show Advanced Options', 'litespeed-cache' ) ; ?></a>
175
- <?php endif ; ?>
176
- </h2>
177
- <div class="litespeed-body">
178
- <form method="post" action="options.php" id="litespeed_form_options" class="litespeed-relative">
179
- <!--input type="hidden" name="<?php echo LiteSpeed_Cache::ACTION_KEY ; ?>" value="<?php echo LiteSpeed_Cache::ACTION_SAVE_SETTINGS ; ?>" /-->
180
-
181
- <?php if ($this->get_disable_all()): ?>
182
- <div class="litespeed-callout-danger">
183
- <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
184
- <p>
185
- <?php echo __('The network admin selected use primary site configs for all subsites.', 'litespeed-cache') ; ?>
186
- <?php echo __('The following options are selected, but are not editable in this settings page.', 'litespeed-cache') ; ?>
187
- </p>
188
- </div>
189
- <?php endif ; ?>
190
-
191
- <?php
192
- settings_fields(LiteSpeed_Cache_Config::OPTION_NAME) ;
193
-
194
- // include all tpl for faster UE
195
- foreach ($menu_list as $tab => $val) {
196
- echo "<div data-litespeed-layout='$tab'>" ;
197
- require LSCWP_DIR . "admin/tpl/setting/settings_$tab.php" ;
198
- echo "</div>" ;
199
- }
200
-
201
- foreach ($tp_tabs as $val) {
202
- echo "<div data-litespeed-layout='$val[slug]'>$val[content]</div>" ;
203
- }
204
-
205
- echo "<div class='litespeed-top20'></div>" ;
206
-
207
- if ( $this->get_disable_all() ) {
208
- submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-success', 'litespeed-submit', true, array('disabled' => true)) ;
209
- }
210
- else {
211
- submit_button(__('Save Changes', 'litespeed-cache'), 'litespeed-btn-success', 'litespeed-submit') ;
212
- }
213
-
214
- ?>
215
-
216
- <a href="admin.php?page=lscache-import" class="litespeed-btn-danger litespeed-float-resetbtn"><?php echo __( 'Reset All Settings', 'litespeed-cache' ) ; ?></a>
217
-
218
- </form>
219
- </div>
220
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
{css → assets/css}/fonts/litespeedfont.eot RENAMED
File without changes
{css → assets/css}/fonts/litespeedfont.svg RENAMED
File without changes
{css → assets/css}/fonts/litespeedfont.ttf RENAMED
File without changes
{css → assets/css}/fonts/litespeedfont.woff RENAMED
File without changes
{css → assets/css}/iziModal.min.css RENAMED
File without changes
assets/css/litespeed-legacy.css ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .litespeed-wrap h2.nav-tab-wrapper, .litespeed-wrap h3.nav-tab-wrapper{
2
+ margin-bottom:0;
3
+ }
4
+
5
+ .litespeed-wrap h2 .nav-tab{
6
+ font-size:14px;
7
+ }
8
+
9
+
10
+ .litespeed-wrap .striped > tbody > :nth-child(odd),
11
+ .litespeed-wrap ul.striped > :nth-child(odd),
12
+ .litespeed-wrap .alternate {
13
+ background-color: #f9f9f9;
14
+ }
15
+
16
+
17
+
18
+ .litespeed-wrap .notice,
19
+ .litespeed-wrap div.updated,
20
+ .litespeed-wrap div.error {
21
+ border-left: 4px solid #fff;
22
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.1);
23
+ padding: 1px 12px;
24
+ }
25
+
26
+ .litespeed-wrap .notice-success,
27
+ .litespeed-wrap div.updated {
28
+ border-left-color: #46b450;
29
+ }
30
+
31
+ .litespeed-wrap .notice-success.notice-alt {
32
+ background-color: #ecf7ed;
33
+ }
34
+
35
+ .litespeed-wrap .notice-warning {
36
+ border-left-color: #ffb900;
37
+ }
38
+
39
+ .litespeed-wrap .notice-warning.notice-alt {
40
+ background-color: #fff8e5;
41
+ }
42
+
43
+ .litespeed-wrap .notice-error,
44
+ .litespeed-wrap div.error {
45
+ border-left-color: #dc3232;
46
+ }
47
+
48
+ .litespeed-wrap .notice-error.notice-alt {
49
+ background-color: #fbeaea;
50
+ }
51
+
52
+ .litespeed-wrap .notice-info {
53
+ border-left-color: #00a0d2;
54
+ }
55
+
56
+ .litespeed-wrap .notice-info.notice-alt {
57
+ background-color: #e5f5fa;
58
+ }
assets/css/litespeed.css ADDED
@@ -0,0 +1,3545 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @font-face {
2
+ font-family: 'litespeedfont';
3
+ src: url('fonts/litespeedfont.eot?rs8ttq');
4
+ src: url('fonts/litespeedfont.eot?rs8ttq#iefix') format('embedded-opentype'),
5
+ url('fonts/litespeedfont.ttf?rs8ttq') format('truetype'),
6
+ url('fonts/litespeedfont.woff?rs8ttq') format('woff'),
7
+ url('fonts/litespeedfont.svg?rs8ttq#litespeedfont') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ #adminmenu #toplevel_page_lscache-settings .menu-icon-generic div.wp-menu-image:before,
13
+ #adminmenu #toplevel_page_litespeed .menu-icon-generic div.wp-menu-image:before,
14
+ .litespeed-top-toolbar .ab-icon::before {
15
+ content: "\e900";
16
+ font-family: 'litespeedfont' !important;
17
+ speak: none;
18
+ font-style: normal;
19
+ font-weight: normal;
20
+ font-variant: normal;
21
+ text-transform: none;
22
+ line-height: 1;
23
+
24
+ /* Better Font Rendering =========== */
25
+ -webkit-font-smoothing: antialiased;
26
+ -moz-osx-font-smoothing: grayscale;
27
+
28
+ }
29
+
30
+ *[litespeed-accesskey]:before {
31
+ content: '['attr(litespeed-accesskey) '] ';
32
+ }
33
+
34
+
35
+ /* =======================================
36
+ UTILITIES - structure
37
+ ======================================= */
38
+
39
+ .litespeed-quic-icon {
40
+ background-image: url('../img/quic-cloud-icon-16x16.svg');
41
+ background-repeat: no-repeat;
42
+ width: 16px;
43
+ height: 16px;
44
+ vertical-align: middle;
45
+ display: inline-block;
46
+ }
47
+
48
+
49
+ .litespeed-row {
50
+ margin-top: 5px;
51
+ }
52
+
53
+ .litespeed-reset {
54
+ width: initial;
55
+ }
56
+
57
+ .litespeed-inline {
58
+ display: inline-block;
59
+ }
60
+
61
+ .litespeed-flex-container {
62
+ display: flex;
63
+ flex-wrap: wrap;
64
+ width: 100%;
65
+ height: auto;
66
+ }
67
+
68
+ .litespeed-flex-container>* {
69
+ box-sizing: border-box;
70
+ }
71
+
72
+ .litespeed-flex-container .litespeed-icon-vertical-middle {
73
+ margin-left: 0;
74
+ }
75
+
76
+ .litespeed-row-flex {
77
+ display: inline-flex;
78
+ }
79
+
80
+ .litespeed-flex-wrap {
81
+ flex-wrap: wrap;
82
+ }
83
+
84
+ .litespeed-width-1-2 {
85
+ width: 45%;
86
+ padding: 20px;
87
+ }
88
+
89
+ .litespeed-width-1-3 {
90
+ width: 30%;
91
+ padding: 25px;
92
+ }
93
+
94
+ .litespeed-width-7-10 {
95
+ width: 65%;
96
+ padding: 20px;
97
+ }
98
+
99
+ .litespeed-width-3-10 {
100
+ width: 35%;
101
+ padding: 20px;
102
+ }
103
+
104
+ @media screen and (max-width: 814px) {
105
+ .litespeed-width-7-10 {
106
+ width: 100%;
107
+ }
108
+
109
+ .litespeed-width-3-10 {
110
+ width: 100%;
111
+ }
112
+ }
113
+
114
+ .litespeed-hide {
115
+ display: none !important;
116
+ }
117
+
118
+ .litespeed-right {
119
+ float: right !important;
120
+ }
121
+
122
+ .litespeed-relative {
123
+ position: relative;
124
+ }
125
+
126
+ .litespeed-align-center {
127
+ margin-left: auto;
128
+ margin-right: auto;
129
+ }
130
+
131
+ /* =======================================
132
+ UTILITIES - spacing
133
+ ======================================= */
134
+
135
+ .litespeed-left10 {
136
+ margin-left: 10px !important;
137
+ }
138
+
139
+ .litespeed-left20 {
140
+ margin-left: 20px !important;
141
+ }
142
+
143
+ .litespeed-right10 {
144
+ margin-right: 10px !important;
145
+ }
146
+
147
+ .litespeed-right20 {
148
+ margin-right: 20px !important;
149
+ }
150
+
151
+ .litespeed-right30 {
152
+ margin-right: 30px !important;
153
+ }
154
+
155
+ .litespeed-right50 {
156
+ margin-right: 50px !important;
157
+ }
158
+
159
+ .litespeed-top10 {
160
+ margin-top: 10px !important;
161
+ }
162
+
163
+ .litespeed-top15 {
164
+ margin-top: 15px !important;
165
+ }
166
+
167
+ .litespeed-top20 {
168
+ margin-top: 20px !important;
169
+ }
170
+
171
+ .litespeed-top30 {
172
+ margin-top: 30px !important;
173
+ }
174
+
175
+ .litespeed-margin-y5 {
176
+ margin-top: 5px !important;
177
+ margin-bottom: 5px !important;
178
+ }
179
+
180
+ .litespeed-margin-x5 {
181
+ margin-left: 5px !important;
182
+ margin-right: 5px !important;
183
+ }
184
+
185
+ .litespeed-wrap .litespeed-left20,
186
+ .litespeed-left20 {
187
+ margin-left: 20px;
188
+ }
189
+
190
+ .litespeed-left50 {
191
+ margin-left: 50px;
192
+ }
193
+
194
+ .litespeed-padding-space {
195
+ padding: 5px 10px;
196
+ }
197
+
198
+ .litespeed-margin-bottom10 {
199
+ margin-bottom: 10px !important;
200
+ }
201
+
202
+ .litespeed-margin-bottom20 {
203
+ margin-bottom: 20px;
204
+ }
205
+
206
+ .litespeed-margin-bottom-remove {
207
+ margin-bottom: 0px !important;
208
+ }
209
+
210
+ .litespeed-margin-top-remove {
211
+ margin-top: 0px !important;
212
+ }
213
+
214
+ .litespeed-margin-left-remove {
215
+ margin-left: 0px !important;
216
+ }
217
+
218
+ .litespeed-margin-y-remove {
219
+ margin-top: 0px !important;
220
+ margin-bottom: 0px !important;
221
+ }
222
+
223
+
224
+ .litespeed-empty-space-xlarge {
225
+ margin-top: 8em;
226
+ }
227
+
228
+ .litespeed-empty-space-large {
229
+ margin-top: 6em;
230
+ }
231
+
232
+ .litespeed-empty-space-medium {
233
+ margin-top: 3em;
234
+ }
235
+
236
+ .litespeed-empty-space-small {
237
+ margin-top: 2em;
238
+ }
239
+
240
+ .litespeed-empty-space-tiny {
241
+ margin-top: 1em;
242
+ }
243
+
244
+
245
+ /* =======================================
246
+ UTILITIES - typography
247
+ ======================================= */
248
+
249
+ .litespeed-text-jumbo {
250
+ font-size: 3em !important;
251
+ }
252
+
253
+ .litespeed-text-large {
254
+ font-size: .75em !important;
255
+ }
256
+
257
+ .litespeed-text-md {
258
+ font-size: 1.2em;
259
+ }
260
+
261
+ .litespeed-text-right {
262
+ text-align: right;
263
+ }
264
+
265
+ .litespeed-text-center {
266
+ text-align: center;
267
+ }
268
+
269
+ .litespeed-text-bold {
270
+ font-weight: 600;
271
+ }
272
+
273
+ /* =======================================
274
+ COLORS
275
+ ======================================= */
276
+
277
+ .litespeed-default {
278
+ color: #a7a7a7 !important;
279
+ }
280
+
281
+ .litespeed-primary {
282
+ color: #3366CC !important;
283
+ }
284
+
285
+ .litespeed-success {
286
+ color: #73b38d !important;
287
+ }
288
+
289
+ .litespeed-warning {
290
+ color: #FF8C00 !important;
291
+ }
292
+
293
+ .litespeed-danger {
294
+ color: #dc3545 !important;
295
+ }
296
+
297
+ a.litespeed-danger:hover,
298
+ button.litespeed-danger:hover {
299
+ color: #a00 !important;
300
+ }
301
+
302
+ .litespeed-text-success {
303
+ color: #34b15d;
304
+ }
305
+
306
+ .litespeed-form-action {
307
+ color: #1a9292 !important;
308
+ }
309
+
310
+ a.litespeed-form-action:hover,
311
+ button.litespeed-form-action:hover {
312
+ color: #36b0af !important;
313
+ }
314
+
315
+ .litespeed-bg-default {
316
+ background-color: #a7a7a7 !important;
317
+ }
318
+
319
+ .litespeed-bg-primary {
320
+ background-color: #3366CC !important;
321
+ }
322
+
323
+ .litespeed-bg-success {
324
+ background-color: #73b38d !important;
325
+ }
326
+
327
+ .litespeed-bg-warning {
328
+ background-color: #FF8C00 !important;
329
+ }
330
+
331
+ .litespeed-bg-danger {
332
+ background-color: #dc3545 !important;
333
+ }
334
+
335
+ .litespeed-bg-text-success {
336
+ background-color: #34b15d;
337
+ }
338
+
339
+ /* =======================================
340
+ LAYOUT
341
+ ======================================= */
342
+
343
+ .litespeed-wrap {
344
+ margin: 10px 20px 0 2px;
345
+ }
346
+
347
+ .litespeed-wrap .nav-tab-active {
348
+ background: #fff;
349
+ border-bottom-color: #fff;
350
+ }
351
+
352
+ .litespeed-wrap .nav-tab:focus:not(.nav-tab-active),
353
+ .litespeed-wrap .nav-tab:hover:not(.nav-tab-active) {
354
+ background-color: #f1f1f1;
355
+ color: #444;
356
+ }
357
+
358
+ .litespeed-body {
359
+ background: #fff;
360
+ border: 1px solid #e5e5e5;
361
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
362
+ padding: 1px 20px 20px 20px;
363
+ }
364
+
365
+ .litespeed-header+.litespeed-body {
366
+ border-top: none;
367
+ }
368
+
369
+ .litespeed-body table {
370
+ border-collapse: collapse;
371
+ width: 100%;
372
+ }
373
+
374
+ .litespeed-body .litespeed-width-auto {
375
+ width: auto;
376
+ }
377
+
378
+ /* outside stripped table */
379
+ .litespeed-description {
380
+ color: #666;
381
+ font-size: 13px;
382
+ margin: 1.5rem 0;
383
+ max-width: 960px;
384
+ }
385
+
386
+ /* inside stripped table */
387
+ .litespeed-desc {
388
+ font-size: 12px;
389
+ font-weight: normal;
390
+ color: #7a919e;
391
+ margin: 10px 0;
392
+ line-height: 1.7;
393
+ max-width: 840px;
394
+ }
395
+
396
+ .litespeed-desc+.litespeed-desc {
397
+ margin-top: -5px
398
+ }
399
+
400
+ td>.litespeed-desc:first-child {
401
+ margin-top: 0px;
402
+ line-height: 2.24;
403
+ }
404
+
405
+ .litespeed-h3 {
406
+ line-height: 18px;
407
+ color: #264d73;
408
+ font-size: 18px;
409
+ font-weight: 600;
410
+ margin: 2px 0;
411
+ }
412
+
413
+ .litespeed-div {
414
+ display: inline-block;
415
+ min-width: 100px;
416
+ }
417
+
418
+ .litespeed-div .submit {
419
+ margin: 5px;
420
+ padding: 5px;
421
+ }
422
+
423
+ .litespeed-h1 {
424
+ display: inline-block;
425
+ }
426
+
427
+ h3 .litespeed-learn-more {
428
+ font-size: 12px;
429
+ font-weight: normal;
430
+ color: #7a919e;
431
+ margin-left: 30px;
432
+ }
433
+
434
+ .litespeed-wrap code {
435
+ color: #666;
436
+ background-color: #dde9f5;
437
+ border-radius: 3px;
438
+ font-size: 11px;
439
+ font-style: normal;
440
+ }
441
+
442
+ .litespeed-wrap ul {
443
+ margin-left: 2em;
444
+ }
445
+
446
+ .litespeed-wrap i {
447
+ font-size: 13px;
448
+ line-height: 16px;
449
+ }
450
+
451
+ .litespeed-wrap .litespeed-desc i {
452
+ font-size: 12px;
453
+ }
454
+
455
+ .litespeed-wrap p {
456
+ margin: 1em 0;
457
+ }
458
+
459
+ .litespeed-wrap p.submit {
460
+ margin-bottom: 0;
461
+ }
462
+
463
+ .litespeed-desc p {
464
+ margin-left: 0;
465
+ }
466
+
467
+ .litespeed-title,
468
+ .litespeed-title-short {
469
+ font-size: 18px;
470
+ border-bottom: 1px solid #cccccc;
471
+ margin: 2.5em 0px 1.5em 0;
472
+ display: table;
473
+ padding-right: 50px;
474
+ padding-left: 3px;
475
+ padding-bottom: 3px;
476
+
477
+ }
478
+
479
+ .litespeed-title .button {
480
+ margin-left: 1rem;
481
+ margin-bottom: 5px;
482
+ vertical-align: middle;
483
+ }
484
+
485
+ .litespeed-title a .dashicons {
486
+ /* vertical-align: text-bottom; */
487
+ }
488
+
489
+ .litespeed-title a,
490
+ .litespeed-title-short a {
491
+ text-decoration: none;
492
+ }
493
+
494
+ .litespeed-title-short {
495
+ padding-right: 20px;
496
+ }
497
+
498
+ .litespeed-title-section {
499
+ margin: 2em -20px 12px -20px;
500
+ padding: 12px 20px 12px 20px;
501
+ border-bottom: 1px solid #eee;
502
+ font-size: 1.2em;
503
+ display: block;
504
+ border-top: 1px solid #f1f1f1;
505
+ }
506
+
507
+ .litespeed-list li:before {
508
+ content: '>';
509
+ color: #cc3d6a;
510
+ }
511
+
512
+ .litespeed-wrap a.disabled {
513
+ cursor: not-allowed;
514
+ opacity: 0.5;
515
+ text-decoration: none;
516
+ color: #72777c;
517
+ }
518
+
519
+
520
+ /* =======================================
521
+ LAYOUT - table
522
+ ======================================= */
523
+
524
+ .litespeed-table {
525
+ font-size: 14px;
526
+ }
527
+
528
+ .litespeed-body tbody>tr>th {
529
+ padding-left: 20px;
530
+ }
531
+
532
+ .litespeed-body tbody th {
533
+ vertical-align: top;
534
+ text-align: left;
535
+ padding: 18px 10px 20px 0;
536
+ width: 200px;
537
+ font-weight: 600;
538
+ }
539
+
540
+ .litespeed-body td {
541
+ padding: 15px 10px;
542
+ line-height: 1.3;
543
+ vertical-align: middle;
544
+ }
545
+
546
+ .litespeed-body .widefat td input+p {
547
+ margin-top: .8em;
548
+ }
549
+
550
+ .litespeed-body .striped>tbody>:nth-child(even) .notice {
551
+ background-color: #f9f9f9;
552
+ box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .05);
553
+ border-top: 1px solid #e5e5e5;
554
+ border-bottom: 1px solid #e5e5e5;
555
+ border-right: 1px solid #e5e5e5;
556
+
557
+ }
558
+
559
+ .litespeed-body .striped>tbody>:nth-child(even) .notice:first-child {
560
+ margin-top: 0;
561
+ }
562
+
563
+ /* small table inside */
564
+ .litespeed-body .litespeed-vary-table {
565
+ margin-top: -5px;
566
+ width: 250px;
567
+ margin-bottom: 20px;
568
+ }
569
+
570
+ .litespeed-body .litespeed-vary-table td {
571
+ width: 50%;
572
+ padding: 5px 0px;
573
+ }
574
+
575
+ .litespeed-table-compact td,
576
+ .litespeed-table-compact th {
577
+ padding: 0.5rem 0.75rem;
578
+ }
579
+
580
+ /* =======================================
581
+ LAYOUT - block
582
+ ======================================= */
583
+
584
+ .litespeed-block,
585
+ .litespeed-block-tiny {
586
+ border: 1px dotted #cccccc;
587
+ border-radius: 5px;
588
+ display: flex;
589
+ flex-wrap: wrap;
590
+ padding: 0.75rem 1.25rem;
591
+ margin-bottom: 5px;
592
+ }
593
+
594
+ .litespeed-block-tiny {
595
+ max-width: 670px;
596
+ }
597
+
598
+ .litespeed-col {
599
+ flex: 0 0 30%;
600
+ padding-right: 2rem;
601
+ }
602
+
603
+ .litespeed-col:last-child,
604
+ .litespeed-col-auto:last-child {
605
+ padding-right: 0;
606
+ }
607
+
608
+ .litespeed-col-auto {
609
+ padding-right: 2rem;
610
+ }
611
+
612
+ .litespeed-col-br {
613
+ flex: 0 0 100%;
614
+ border-top: 1px dotted #cccccc;
615
+ }
616
+
617
+ .litespeed-col-inc {
618
+ display: inline-block;
619
+ margin-top: 16px;
620
+ min-width: 150px;
621
+ font-weight: bold;
622
+ }
623
+
624
+ .litespeed-block h4:first-child,
625
+ .litespeed-block .litespeed-form-label:not(.litespeed-form-label--toggle):first-child {
626
+ margin-top: 0.5rem;
627
+ }
628
+
629
+ .litespeed-block .litespeed-callout:last-child {
630
+ margin-bottom: 0;
631
+ }
632
+
633
+ /* =======================================
634
+ CARDS LINKS
635
+ ======================================= */
636
+
637
+ .litespeed-cards-wrapper,
638
+ .litespeed-panel-wrapper {
639
+ display: flex;
640
+ width: 100%;
641
+ flex-flow: row wrap;
642
+ justify-content: flex-start;
643
+ }
644
+
645
+ .litespeed-cards-wrapper {
646
+ margin: -10px -15px -10px -15px;
647
+ }
648
+
649
+ .litespeed-panel {
650
+ text-decoration: none;
651
+ display: flex;
652
+ justify-content: space-between;
653
+ padding: 6px 8px 4px 5px;
654
+ width: 322px;
655
+ margin: 15px 5px 15px 15px;
656
+ min-height: 75px;
657
+ box-sizing: border-box;
658
+ background: #f9fafc;
659
+ transition: .25s;
660
+ }
661
+
662
+ .litespeed-panel:hover {
663
+ border: 1px solid #6699cc;
664
+ box-shadow: none;
665
+ }
666
+
667
+ .litespeed-panel-wrapper-icon {
668
+ width: 25%;
669
+ height: 100%;
670
+ }
671
+
672
+ [class*="litespeed-panel-icon-"] {
673
+ background-size: contain;
674
+ width: 60px;
675
+ height: 60px;
676
+ margin: 5px;
677
+ background-repeat: no-repeat;
678
+ display: inline-block;
679
+ }
680
+
681
+ .litespeed-panel-icon-all {
682
+ background-image: url("../img/icons/all.svg");
683
+ }
684
+
685
+ .litespeed-panel-icon-revision {
686
+ background-image: url("../img/icons/revision.svg");
687
+ }
688
+
689
+ .litespeed-panel-icon-auto_draft {
690
+ background-image: url("../img/icons/auto_draft.svg");
691
+ }
692
+
693
+ .litespeed-panel-icon-trash_post {
694
+ background-image: url("../img/icons/trash_post.svg");
695
+ }
696
+
697
+ .litespeed-panel-icon-spam_comment {
698
+ background-image: url("../img/icons/spam_comment.svg");
699
+ }
700
+
701
+ .litespeed-panel-icon-trash_comment {
702
+ background-image: url("../img/icons/trash_comment.svg");
703
+ }
704
+
705
+ .litespeed-panel-icon-trackback-pingback {
706
+ background-image: url("../img/icons/trackback-pingback.svg");
707
+ }
708
+
709
+ .litespeed-panel-icon-expired_transient {
710
+ background-image: url("../img/icons/expired_transient.svg");
711
+ }
712
+
713
+ .litespeed-panel-icon-all_transients {
714
+ background-image: url("../img/icons/all_transients.svg");
715
+ }
716
+
717
+ .litespeed-panel-icon-all_cssjs {
718
+ background-image: url("../img/icons/purge-cssjs.svg");
719
+ }
720
+
721
+ .litespeed-panel-icon-optimize_tables {
722
+ background-image: url("../img/icons/optimize_tables.svg");
723
+ }
724
+
725
+ .litespeed-panel-icon-purge-front {
726
+ background-image: url("../img/icons/purge-front.svg");
727
+ }
728
+
729
+ .litespeed-panel-icon-purge-pages {
730
+ background-image: url("../img/icons/purge-pages.svg");
731
+ }
732
+
733
+ .litespeed-panel-icon-purge-cssjs {
734
+ background-image: url("../img/icons/purge-cssjs.svg");
735
+ }
736
+
737
+ .litespeed-panel-icon-purge-object {
738
+ background-image: url("../img/icons/purge-object.svg");
739
+ }
740
+
741
+ .litespeed-panel-icon-purge-opcache {
742
+ background-image: url("../img/icons/purge-opcache.svg");
743
+ }
744
+
745
+ .litespeed-panel-icon-purge-all {
746
+ background-image: url("../img/icons/purge-all.svg");
747
+ }
748
+
749
+ .litespeed-panel-icon-empty-cache {
750
+ background-image: url("../img/icons/empty-cache.svg");
751
+ }
752
+
753
+ .litespeed-panel-icon-purge-403 {
754
+ background-image: url("../img/icons/purge-403.svg");
755
+ }
756
+
757
+ .litespeed-panel-icon-purge-404 {
758
+ background-image: url("../img/icons/purge-404.svg");
759
+ }
760
+
761
+ .litespeed-panel-icon-purge-500 {
762
+ background-image: url("../img/icons/purge-500.svg");
763
+ }
764
+
765
+ .litespeed-panel-top-right-icon-cross {
766
+ background-image: url("../img/icons/cross_icon.svg");
767
+ }
768
+
769
+ .litespeed-panel-top-right-icon-tick {
770
+ background-image: url("../img/icons/success_icon.svg");
771
+ }
772
+
773
+ .litespeed-panel-content {
774
+ width: 75%;
775
+ height: 100%;
776
+ margin-top: 7px;
777
+ }
778
+
779
+ .litespeed-panel-para {
780
+ color: #264d73;
781
+ font-size: 12px;
782
+ line-height: 1.45;
783
+ }
784
+
785
+ .litespeed-panel .litespeed-h3 {
786
+ font-size: 14px;
787
+ }
788
+
789
+ .litespeed-panel-counter {
790
+ color: #3abfbf;
791
+ }
792
+
793
+ .litespeed-panel-counter-red {
794
+ color: #cc3d6a;
795
+ }
796
+
797
+ .litespeed-panel-wrapper-top-right {
798
+ width: 10%;
799
+ height: 100%;
800
+ text-align: right;
801
+ }
802
+
803
+ .litespeed-panel-top-right-icon-tick,
804
+ .litespeed-panel-top-right-icon-cross {
805
+ background-size: contain;
806
+ width: 20px;
807
+ height: 20px;
808
+ background-repeat: no-repeat;
809
+ display: inline-block;
810
+ }
811
+
812
+ /* =======================================
813
+ BUTTONS
814
+ ======================================= */
815
+
816
+ /* .litespeed-wrap .button{
817
+ background:#fff;
818
+ } */
819
+
820
+ .litespeed-wrap .button-link {
821
+ height: auto;
822
+ line-height: inherit;
823
+ font-size: inherit;
824
+ box-shadow: none;
825
+ }
826
+
827
+ .litespeed-wrap .button-link:hover,
828
+ .litespeed-wrap .button-link:focus {
829
+ box-shadow: none;
830
+ background: none;
831
+ }
832
+
833
+ .litespeed .litespeed-btn-danger-bg,
834
+ .litespeed-wrap .litespeed-btn-danger-bg,
835
+ .litespeed-btn-danger-bg {
836
+ background: #dc3545;
837
+ color: #fff;
838
+ border: 1px solid #cc3d6a;
839
+ box-shadow: 0 1px 0 rgba(177, 93, 93, 0.5);
840
+ }
841
+
842
+ .litespeed .litespeed-btn-danger,
843
+ .litespeed-wrap .litespeed-btn-danger,
844
+ .litespeed-btn-danger {
845
+ background: #fff;
846
+ color: #cc3d6a;
847
+ border: 1px solid #cc3d6a;
848
+ box-shadow: 0 1px 0 rgba(177, 93, 93, 0.5);
849
+ }
850
+
851
+ .litespeed .litespeed-btn-danger:hover,
852
+ .litespeed-wrap .litespeed-btn-danger:hover,
853
+ .litespeed-btn-danger:hover {
854
+ border-color: #ab244e;
855
+ background: #cc3d6a;
856
+ color: #fff;
857
+ }
858
+
859
+ .litespeed .litespeed-btn-warning,
860
+ .litespeed-wrap .litespeed-btn-warning,
861
+ .litespeed-btn-warning {
862
+ background: #fff;
863
+ color: #e59544;
864
+ border: 1px solid #e59544;
865
+ box-shadow: 0 1px 0 rgba(249, 166, 82, 0.55);
866
+ }
867
+
868
+ .litespeed .litespeed-btn-warning:hover,
869
+ .litespeed-wrap .litespeed-btn-warning:hover,
870
+ .litespeed-btn-warning:hover {
871
+ border-color: #e59544;
872
+ background: #e59544;
873
+ color: #fff;
874
+ }
875
+
876
+ .litespeed .litespeed-btn-success,
877
+ .litespeed-wrap .litespeed-btn-success,
878
+ .litespeed-btn-success {
879
+ background: #fff;
880
+ color: #36b0b0;
881
+ border: 1px solid #36b0b0;
882
+ box-shadow: 0 1px 0 rgba(73, 160, 160, 0.55);
883
+ }
884
+
885
+ .litespeed .litespeed-btn-success:hover,
886
+ .litespeed-wrap .litespeed-btn-success:hover,
887
+ .litespeed-btn-success:hover {
888
+ border-color: #36b0b0;
889
+ background: #36b0b0;
890
+ color: #fff;
891
+ }
892
+
893
+ .litespeed-wrap .button-primary {
894
+ background: #528ac6;
895
+ border-color: #538ac6 #2264ad #2264ad;
896
+ color: #fff;
897
+ box-shadow: 0 1px 0 #2264ad;
898
+ text-shadow: 0 -1px 1px #2264ad, 1px 0 1px #2264ad, 0 1px 1px #2264ad, -1px 0 1px #2264ad;
899
+ }
900
+
901
+ .litespeed-wrap .button-primary:focus,
902
+ .litespeed-wrap .button-primary:hover {
903
+ background: #5891ce;
904
+ border-color: #2264ad;
905
+ color: #fff;
906
+ }
907
+
908
+ .litespeed-wrap .button-primary:hover {
909
+ box-shadow: 0 1px 0 #2264ad;
910
+ }
911
+
912
+ .litespeed-wrap .button-primary:focus {
913
+ background: #5891ce;
914
+ border-color: #2264ad;
915
+ color: #fff;
916
+ box-shadow: 0 1px 0 #0073aa, 0 0 2px 1px #33b3db;
917
+ }
918
+
919
+ .litespeed .litespeed-btn-primary,
920
+ .litespeed-wrap .litespeed-btn-primary,
921
+ .litespeed-btn-primary {
922
+ color: #538ac6;
923
+ border: 1px solid #538ac6;
924
+ -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
925
+ -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
926
+ box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
927
+ }
928
+
929
+ .litespeed .litespeed-btn-primary:hover,
930
+ .litespeed-wrap .litespeed-btn-primary:hover,
931
+ .litespeed-btn-primary:hover {
932
+ background: #538ac6;
933
+ border-color: #538ac6;
934
+ color: #fff;
935
+ }
936
+
937
+ .litespeed-wrap .button:not(.litespeed-btn-large) .dashicons {
938
+ position: relative;
939
+ top: 0.125em;
940
+ }
941
+
942
+ .litespeed-wrap .button:not(:first-child) {
943
+ margin-left: 5px;
944
+ }
945
+
946
+ .litespeed-wrap .button+.button {
947
+ margin-left: 10px;
948
+ }
949
+
950
+ .litespeed-info-button {
951
+ color: #c8c8c8;
952
+ padding: 0;
953
+ -webkit-appearance: none;
954
+ border: none;
955
+ background: none;
956
+ vertical-align: middle;
957
+ line-height: inherit;
958
+ text-decoration: none;
959
+ }
960
+
961
+ .litespeed-info-button .dashicons {
962
+ font-size: 16px;
963
+ vertical-align: middle;
964
+ }
965
+
966
+ .litespeed-btn-pie {
967
+ -webkit-appearance: none;
968
+ background: none;
969
+ border: none;
970
+ border-radius: 0;
971
+ box-shadow: none;
972
+ padding: 0;
973
+ margin: 0;
974
+ top: -0.125em;
975
+ }
976
+
977
+ /* =======================================
978
+ BUTTONS - sizes
979
+ ======================================= */
980
+
981
+ .litespeed-wrap .litespeed-btn-tiny {
982
+ padding: 2px 8px;
983
+ line-height: 1.5;
984
+ height: auto;
985
+ }
986
+
987
+ .litespeed-wrap .litespeed-btn-mini {
988
+ padding: 0 8px 1px;
989
+ font-size: 12px;
990
+ font-weight: 600;
991
+ margin: 5px 0;
992
+ }
993
+
994
+ .litespeed-wrap .litespeed-btn-mini .dashicons.dashicons-image-rotate {
995
+ padding-top: 3px;
996
+ font-size: 18px;
997
+ }
998
+
999
+ .litespeed-wrap .litespeed-btn-mini .dashicons {
1000
+ padding-top: 2px;
1001
+ }
1002
+
1003
+ .litespeed-wrap .litespeed-btn-large {
1004
+ font-size: 1.5em;
1005
+ padding: .75em 1.5em;
1006
+ margin: 0 .25em;
1007
+ height: auto;
1008
+ }
1009
+
1010
+ .litespeed-wrap .litespeed-btn-large .dashicons {
1011
+ font-size: 1.25em;
1012
+ width: auto;
1013
+ }
1014
+
1015
+
1016
+ /* =======================================
1017
+ SWITCH
1018
+ ======================================= */
1019
+
1020
+ .litespeed-switch {
1021
+ font-size: 14px;
1022
+ font-weight: 600;
1023
+ margin: 0 0 0;
1024
+ display: inline-flex;
1025
+ position: relative;
1026
+ }
1027
+
1028
+ .litespeed-switch input:checked:active+label {
1029
+ box-shadow: 0 2px 0 rgba(27, 146, 146, 0.7), inset 0 2px 5px -3px rgba(0, 0, 0, .5);
1030
+ }
1031
+
1032
+ .litespeed-switch input:checked+label {
1033
+ background-color: #36b0b0;
1034
+ color: #fff;
1035
+ border: 1px solid #36b0b0;
1036
+ box-shadow: 0 2px 0 #1b9292;
1037
+ z-index: 2;
1038
+ text-shadow: 0 -1px 1px #1b9292, 1px 0 1px #1b9292, 0 1px 1px #1b9292, -1px 0 1px #1b9292;
1039
+ }
1040
+
1041
+ .litespeed-switch label {
1042
+ font-size: 14px;
1043
+ display: inline-block;
1044
+ min-width: 72px;
1045
+ background-color: #f9fafc;
1046
+ font-weight: 400;
1047
+ text-align: center;
1048
+ padding: 6px 12px 5px 12px;
1049
+ cursor: pointer;
1050
+ border: 1px solid #ccc;
1051
+ border-bottom: none;
1052
+ box-shadow: 0 2px 0 #ccc;
1053
+ position: relative;
1054
+ }
1055
+
1056
+ .litespeed-switch label:not(:last-child) {
1057
+ margin-right: -1px;
1058
+ }
1059
+
1060
+ .litespeed-switch label:last-child {
1061
+ border-top-right-radius: 3px;
1062
+ border-bottom-right-radius: 3px;
1063
+ }
1064
+
1065
+ .litespeed-switch label:first-of-type {
1066
+ border-top-left-radius: 3px;
1067
+ border-bottom-left-radius: 3px;
1068
+ }
1069
+
1070
+ .litespeed-switch input:hover+label {
1071
+ border-color: #1a9292;
1072
+ box-shadow: 0 2px 0 #1a9292;
1073
+ z-index: 2;
1074
+ color: #117171;
1075
+
1076
+ }
1077
+
1078
+ .litespeed-switch input:focus+label {
1079
+ color: #117171;
1080
+ box-shadow: 0 0px 0px 2px rgba(28, 138, 128, 0.85);
1081
+ border-color: transparent;
1082
+ z-index: 2;
1083
+
1084
+ }
1085
+
1086
+ .litespeed-switch input:focus+label+input+input:hover+label,
1087
+ .litespeed-switch input:focus+label+input:hover+label {
1088
+ z-index: 1;
1089
+ }
1090
+
1091
+ .litespeed-switch input:active+label {
1092
+ box-shadow: 0 2px 0 #1b9292, inset 0 2px 5px -3px rgba(0, 0, 0, .5);
1093
+ }
1094
+
1095
+ .litespeed-switch input:checked:hover+label,
1096
+ .litespeed-switch input:checked:focus+label {
1097
+ background-color: #36b0b0;
1098
+ color: #fff;
1099
+
1100
+
1101
+ }
1102
+
1103
+ .litespeed-switch input {
1104
+ display: inline-block;
1105
+ position: absolute;
1106
+ z-index: -1;
1107
+ margin: 0;
1108
+ }
1109
+
1110
+ .litespeed-cache-purgeby-text {
1111
+ margin: 0;
1112
+ display: inline-block;
1113
+ }
1114
+
1115
+ /* =======================================
1116
+ TOGGLE
1117
+ ======================================= */
1118
+
1119
+ .litespeed-toggle-stack {
1120
+ display: flex;
1121
+ flex-direction: column;
1122
+ }
1123
+
1124
+ .litespeed-toggle-stack .litespeed-toggle-wrapper {
1125
+ justify-content: space-between;
1126
+ }
1127
+
1128
+ .litespeed-toggle-wrapper {
1129
+ display: flex;
1130
+ align-items: center;
1131
+ }
1132
+
1133
+ .litespeed-toggle-wrapper+.litespeed-toggle-wrapper {
1134
+ margin-top: 0.75rem;
1135
+ }
1136
+
1137
+ .litespeed-toggle {
1138
+ position: relative;
1139
+ overflow: hidden;
1140
+ min-width: 58px;
1141
+ height: 21px;
1142
+ margin-left: 1.2rem;
1143
+ }
1144
+
1145
+ .litespeed-toggle-group {
1146
+ position: absolute;
1147
+ width: 200%;
1148
+ top: 0;
1149
+ bottom: 0;
1150
+ left: 0;
1151
+ transition: left 0.35s;
1152
+ -webkit-transition: left 0.35s;
1153
+ -moz-user-select: none;
1154
+ -webkit-user-select: none;
1155
+ }
1156
+
1157
+ .litespeed-toggle-on {
1158
+ position: absolute;
1159
+ top: 0;
1160
+ bottom: 0;
1161
+ left: 0;
1162
+ right: 50%;
1163
+ margin: 0;
1164
+ border: 0;
1165
+ border-radius: 0;
1166
+ }
1167
+
1168
+ .litespeed-toggle-on.litespeed-toggle-btn {
1169
+ padding-right: 24px;
1170
+ }
1171
+
1172
+ .litespeed-toggle-off.litespeed-toggle-btn {
1173
+ padding-left: 24px;
1174
+ }
1175
+
1176
+ .litespeed-toggle-handle {
1177
+ position: relative;
1178
+ margin: 0 auto;
1179
+ padding-top: 0px;
1180
+ padding-bottom: 0px;
1181
+ height: 100%;
1182
+ width: 0px;
1183
+ border-width: 0 1px;
1184
+ }
1185
+
1186
+ .litespeed-toggle-off {
1187
+ position: absolute;
1188
+ top: 0;
1189
+ bottom: 0;
1190
+ left: 50%;
1191
+ right: 0;
1192
+ margin: 0;
1193
+ border: 0;
1194
+ border-radius: 0;
1195
+ }
1196
+
1197
+ .litespeed-toggleoff .litespeed-toggle-group {
1198
+ left: -100%;
1199
+ }
1200
+
1201
+ .litespeed-toggle-btn {
1202
+ display: inline-block;
1203
+ padding: 5px 10px;
1204
+ margin-bottom: 0;
1205
+ font-size: 14px;
1206
+ font-weight: 400;
1207
+ line-height: 1.42857143;
1208
+ text-align: center;
1209
+ white-space: nowrap;
1210
+ vertical-align: middle;
1211
+ cursor: pointer;
1212
+ -webkit-user-select: none;
1213
+ -moz-user-select: none;
1214
+ -ms-user-select: none;
1215
+ user-select: none;
1216
+ background-image: none;
1217
+ border: 1px solid transparent;
1218
+ border-radius: 4px;
1219
+ }
1220
+
1221
+ .litespeed-toggle-btn-primary {
1222
+ color: #fff;
1223
+ background-color: #36b0b0;
1224
+ border-color: #36b0b0;
1225
+ }
1226
+
1227
+ .litespeed-toggle-btn-default {
1228
+ color: #333;
1229
+ background-color: #fff;
1230
+ border-color: #ccc;
1231
+ }
1232
+
1233
+ .litespeed-toggle-btn-success:hover,
1234
+ .litespeed-toggle-btn-success:focus,
1235
+ .litespeed-toggle-btn-success:active,
1236
+ .litespeed-toggle-btn-success.litespeed-toggle-active {
1237
+ color: #fff;
1238
+ background-color: #00bfbf;
1239
+ border-color: #6699cc;
1240
+ }
1241
+
1242
+ .litespeed-toggle-btn-default:hover,
1243
+ .litespeed-toggle-btn-default:focus,
1244
+ .litespeed-toggle-btn-default:active,
1245
+ .litespeed-toggle-btn-default.litespeed-toggle-active {
1246
+ color: #333;
1247
+ background-color: #e6e6e6;
1248
+ border-color: #adadad;
1249
+ }
1250
+
1251
+ .litespeed-toggle-btn:active,
1252
+ .litespeed-toggle-btn.litespeed-toggle-active {
1253
+ background-image: none;
1254
+ outline: 0;
1255
+ -webkit-box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
1256
+ box-shadow: inset 0 3px 5px rgba(0, 0, 0, .125);
1257
+ }
1258
+
1259
+ .litespeed-toggle-btn-default:active,
1260
+ .litespeed-toggle-btn-default.litespeed-toggle-active {
1261
+ background-image: none;
1262
+ }
1263
+
1264
+ /* =======================================
1265
+ LABEL/TAG
1266
+ ======================================= */
1267
+ [class*="litespeed-label-"] {
1268
+ display: inline;
1269
+ padding: .2em .6em .3em;
1270
+ font-size: 75%;
1271
+ font-weight: bold;
1272
+ line-height: 1;
1273
+ color: #fff;
1274
+ text-align: center;
1275
+ white-space: nowrap;
1276
+ vertical-align: baseline;
1277
+ border-radius: .25em;
1278
+ }
1279
+
1280
+ [class*="litespeed-label-"]:hover,
1281
+ [class*="litespeed-label-"]:focus {
1282
+ color: #fff;
1283
+ text-decoration: none;
1284
+ cursor: pointer;
1285
+ }
1286
+
1287
+ [class*="litespeed-label-"]:empty {
1288
+ display: none;
1289
+ }
1290
+
1291
+ .litespeed-label-regular {
1292
+ font-size: 1em;
1293
+ }
1294
+
1295
+ .litespeed-label-default {
1296
+ background-color: #777;
1297
+ }
1298
+
1299
+ .litespeed-label-default[href]:hover,
1300
+ .litespeed-label-default[href]:focus {
1301
+ background-color: #5e5e5e;
1302
+ }
1303
+
1304
+ .litespeed-label-primary {
1305
+ background-color: #337ab7;
1306
+ }
1307
+
1308
+ .litespeed-label-primary[href]:hover,
1309
+ .litespeed-label-primary[href]:focus {
1310
+ background-color: #286090;
1311
+ }
1312
+
1313
+ .litespeed-label-success {
1314
+ background-color: #5cb85c;
1315
+ }
1316
+
1317
+ .litespeed-label-success[href]:hover,
1318
+ .litespeed-label-success[href]:focus {
1319
+ background-color: #449d44;
1320
+ }
1321
+
1322
+ .litespeed-label-info {
1323
+ background-color: #5bc0de;
1324
+ }
1325
+
1326
+ .litespeed-label-info[href]:hover,
1327
+ .litespeed-label-info[href]:focus {
1328
+ background-color: #31b0d5;
1329
+ }
1330
+
1331
+ .litespeed-label-warning {
1332
+ background-color: #f0ad4e;
1333
+ }
1334
+
1335
+ .litespeed-label-warning[href]:hover,
1336
+ .litespeed-label-warning[href]:focus {
1337
+ background-color: #ec971f;
1338
+ }
1339
+
1340
+ .litespeed-label-danger {
1341
+ background-color: #d9534f;
1342
+ }
1343
+
1344
+ .litespeed-label-danger[href]:hover,
1345
+ .litespeed-label-danger[href]:focus {
1346
+ background-color: #c9302c;
1347
+ }
1348
+
1349
+ /* =======================================
1350
+ SHELL
1351
+ ======================================= */
1352
+ .litespeed-shell {
1353
+ width: 98%;
1354
+ background: #141414;
1355
+ margin: 20px auto 0 10px;
1356
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
1357
+ -webkit-border-radius: 3px;
1358
+ -moz-border-radius: 3px;
1359
+ border-radius: 3px;
1360
+ position: relative;
1361
+ height: 224px;
1362
+ }
1363
+
1364
+ .litespeed-shell-header {
1365
+ z-index: 999;
1366
+ position: absolute;
1367
+ top: 0;
1368
+ right: 0;
1369
+ width: 50px;
1370
+ height: 34px;
1371
+ padding: 5px 0;
1372
+ }
1373
+
1374
+ .litespeed-shell-header-bg {
1375
+ opacity: 0.4;
1376
+ background-color: #CCCCCC;
1377
+ position: absolute;
1378
+ top: 0;
1379
+ bottom: 0;
1380
+ right: 0;
1381
+ left: 0;
1382
+ z-index: 4;
1383
+ -webkit-border-radius: 3px;
1384
+ -moz-border-radius: 3px;
1385
+ border-top-radius: 3px;
1386
+ }
1387
+
1388
+ .litespeed-shell-header-bar {
1389
+ position: absolute;
1390
+ top: 0;
1391
+ left: 0;
1392
+ z-index: 10;
1393
+ height: 2px;
1394
+ background-color: #F48024;
1395
+ }
1396
+
1397
+ .litespeed-shell-header-icon-container {
1398
+ position: absolute;
1399
+ top: 10px;
1400
+ right: 10px;
1401
+ width: 29px;
1402
+ height: 34px;
1403
+ z-index: 6;
1404
+ }
1405
+
1406
+ ul.litespeed-shell-body {
1407
+ position: absolute;
1408
+ top: 0;
1409
+ left: 0;
1410
+ right: 0;
1411
+ bottom: 0;
1412
+ overflow-y: scroll;
1413
+ margin: 0;
1414
+ padding: 5px;
1415
+ list-style: none;
1416
+ background: #141414;
1417
+ color: #45D40C;
1418
+ font: 0.8em 'Andale Mono', Consolas, 'Courier New';
1419
+ line-height: 1.6em;
1420
+
1421
+ -webkit-border-bottom-right-radius: 3px;
1422
+ -webkit-border-bottom-left-radius: 3px;
1423
+ -moz-border-radius-bottomright: 3px;
1424
+ -moz-border-radius-bottomleft: 3px;
1425
+ border-bottom-right-radius: 3px;
1426
+ border-bottom-left-radius: 3px;
1427
+
1428
+ }
1429
+
1430
+ .litespeed-shell-body li:before {
1431
+ content: '>';
1432
+ position: absolute;
1433
+ left: 0;
1434
+ top: 0;
1435
+ }
1436
+
1437
+ .litespeed-shell-body li {
1438
+ word-wrap: break-word;
1439
+ position: relative;
1440
+ padding: 0 0 0 15px;
1441
+ margin: 0;
1442
+ }
1443
+
1444
+ .litespeed-widget-setting {
1445
+ background-color: #ecebdc;
1446
+ padding: 5px 14px;
1447
+ margin: 5px -15px;
1448
+ }
1449
+
1450
+
1451
+ /* =======================================
1452
+ CALLOUT / NOTICE
1453
+ ======================================= */
1454
+
1455
+ .litespeed-callout {
1456
+ margin: 1.5rem 0;
1457
+
1458
+ border-right: 1px solid #e5e5e5;
1459
+ border-top: 1px solid #e5e5e5;
1460
+ border-bottom: 1px solid #e5e5e5;
1461
+ background: #f9f9f9;
1462
+ }
1463
+
1464
+ .litespeed-callout h4:not(:last-child) {
1465
+ margin-bottom: 0.5rem;
1466
+ margin-top: 1em;
1467
+ }
1468
+
1469
+ .litespeed-callout p {
1470
+ margin-left: 0;
1471
+ }
1472
+
1473
+ .litespeed-callout ol,
1474
+ .litespeed-callout ul {
1475
+ margin-left: 1em;
1476
+ }
1477
+
1478
+ .litespeed-callout.notice-warning h4 {
1479
+ color: #e59544;
1480
+ }
1481
+
1482
+ .litespeed-callout.notice-error h4 {
1483
+ color: #dc3232;
1484
+ }
1485
+
1486
+ .litespeed-callout-bg {
1487
+ margin: 1.5rem 0;
1488
+ background: #f9f9f9;
1489
+ border-top: none;
1490
+ border-bottom: none;
1491
+ border-right: none;
1492
+ }
1493
+
1494
+ /* =======================================
1495
+ TICK / CHECKBOX
1496
+ ======================================= */
1497
+
1498
+ .litespeed-tick-wrapper {
1499
+ margin-left: -5px;
1500
+ }
1501
+
1502
+ .litespeed-tick {
1503
+ display: inline-block;
1504
+ /* min-width: 125px; */
1505
+ background: #f2f9ff;
1506
+ padding: 5px 0 5px 0px;
1507
+ border-radius: 3px;
1508
+ cursor: pointer;
1509
+ margin: 5px 5px 5px 0;
1510
+ }
1511
+
1512
+ .litespeed-tick-list .litespeed-tick {
1513
+ display: block;
1514
+ margin-bottom: 3px;
1515
+ margin-top: 0;
1516
+ background: none;
1517
+ }
1518
+
1519
+ .litespeed-tick-list .litespeed-tick input[type="checkbox"] {
1520
+ margin-left: 0;
1521
+ }
1522
+
1523
+ .litespeed-tick-list .litespeed-tick label {
1524
+ color: inherit;
1525
+ }
1526
+
1527
+
1528
+ .litespeed-tick input[type="checkbox"] {
1529
+ height: 18px;
1530
+ width: 18px;
1531
+ vertical-align: middle;
1532
+ margin: 0 10px;
1533
+ -webkit-appearance: none;
1534
+ -moz-appearance: none;
1535
+ appearance: none;
1536
+ -webkit-border-radius: 3px;
1537
+ border-radius: 3px;
1538
+
1539
+ cursor: pointer;
1540
+ }
1541
+
1542
+ .litespeed-tick input[type="checkbox"]:not(:disabled):hover {
1543
+ border-color: #538ac6;
1544
+
1545
+ }
1546
+
1547
+ .litespeed-tick input[type="checkbox"]:active:not(:disabled) {
1548
+ border-color: #538ac6;
1549
+ }
1550
+
1551
+ .litespeed-tick input[type="checkbox"]:focus {
1552
+ outline: none;
1553
+ }
1554
+
1555
+ .litespeed-tick input[type="checkbox"]:checked {
1556
+ border-color: #538ac6;
1557
+ background-color: #538ac6;
1558
+ -moz-box-shadow: none;
1559
+ -webkit-box-shadow: none;
1560
+ box-shadow: none;
1561
+ }
1562
+
1563
+ .litespeed-tick input[type="checkbox"]:checked:before {
1564
+ content: '';
1565
+ display: block;
1566
+ width: 5px;
1567
+ height: 11px;
1568
+ border: solid #fff;
1569
+ border-width: 0 2px 2px 0;
1570
+ -webkit-transform: rotate(45deg);
1571
+ transform: rotate(45deg);
1572
+ margin-left: 5px;
1573
+ margin-top: -1px;
1574
+ cursor: pointer;
1575
+ }
1576
+
1577
+ .litespeed-tick label {
1578
+ padding: 2px 0px 2px 0;
1579
+ font-size: 14px;
1580
+ color: #264d73;
1581
+ }
1582
+
1583
+ .litespeed-tick label:hover {
1584
+ min-width: 115px;
1585
+ color: #6699cc;
1586
+ }
1587
+
1588
+ /* =======================================
1589
+ RADIO - vertical
1590
+ ======================================= */
1591
+
1592
+ .litespeed-radio-row {
1593
+ margin-bottom: 12px;
1594
+ position: relative;
1595
+ padding-left: 1.5rem;
1596
+ }
1597
+
1598
+ .litespeed-radio-row input[type=radio] {
1599
+ margin-top: 0;
1600
+ margin-bottom: 0;
1601
+ position: absolute;
1602
+ line-height: 1;
1603
+ left: 0;
1604
+ top: 0.7em;
1605
+ transform: translateY(-50%);
1606
+ }
1607
+
1608
+ .litespeed-radio-row label {
1609
+ vertical-align: text-bottom;
1610
+ line-height: 1.4;
1611
+ }
1612
+
1613
+ /* =======================================
1614
+ FORM - layout
1615
+ ======================================= */
1616
+
1617
+ .litespeed-wrap .litespeed-float-submit {
1618
+ position: absolute;
1619
+ right: 0;
1620
+ top: -5px;
1621
+ margin-top: 0;
1622
+ }
1623
+
1624
+ .rtl .litespeed-wrap .litespeed-float-submit {
1625
+ left: 10px;
1626
+ right: unset;
1627
+ }
1628
+
1629
+ .litespeed-wrap .litespeed-float-resetbtn {
1630
+ position: absolute;
1631
+ right: 0;
1632
+ bottom: 20px;
1633
+ }
1634
+
1635
+ .rtl .litespeed-wrap .litespeed-float-resetbtn {
1636
+ left: 10px;
1637
+ right: unset;
1638
+ }
1639
+
1640
+ /* =======================================
1641
+ FORM - utilities
1642
+ ======================================= */
1643
+
1644
+ .litespeed .litespeed-input-large {
1645
+ font-size: 20px;
1646
+ }
1647
+
1648
+ .litespeed-input-long {
1649
+ width: 87%;
1650
+ }
1651
+
1652
+ .litespeed-input-short2 {
1653
+ width: 150px;
1654
+ }
1655
+
1656
+ .litespeed-input-short {
1657
+ width: 45px;
1658
+ }
1659
+
1660
+ /* =======================================
1661
+ FORM - elements
1662
+ ======================================= */
1663
+
1664
+ .litespeed-form-label {
1665
+ font-size: 1em;
1666
+ margin: 0.65rem 0;
1667
+ display: block;
1668
+ font-weight: 600;
1669
+ }
1670
+
1671
+ .litespeed-form-label--toggle {
1672
+ margin: 0;
1673
+ display: inline-block;
1674
+ min-width: 110px;
1675
+ }
1676
+
1677
+ input.litespeed-input[type="file"] {
1678
+ padding: 9px;
1679
+ min-width: 500px;
1680
+ border: 1px solid #ddd;
1681
+ box-shadow: inset 0 1px 2px rgba(0, 0, 0, .07);
1682
+ background-color: #fff;
1683
+ color: #32373c;
1684
+ outline: 0;
1685
+ transition: 50ms border-color ease-in-out;
1686
+ }
1687
+
1688
+ .litespeed-body .litespeed-textarea-success {
1689
+ border-color: #6699cc;
1690
+ }
1691
+
1692
+ input.litespeed-input-success {
1693
+ border-color: #28a745;
1694
+ }
1695
+
1696
+ input.litespeed-input-warning {
1697
+ border-color: #e59544;
1698
+ }
1699
+
1700
+ .litespeed-textarea {
1701
+ width: 60%;
1702
+ }
1703
+
1704
+ .litespeed-textarea-recommended {
1705
+ display: flex;
1706
+ margin-top: -5px;
1707
+ }
1708
+
1709
+ .litespeed-textarea-recommended .litespeed-desc {
1710
+ margin: 0;
1711
+ }
1712
+
1713
+ .litespeed-textarea-recommended>div:first-child {
1714
+ margin-top: 1.7em;
1715
+ font-size: 12px;
1716
+ margin-right: 25px;
1717
+ }
1718
+
1719
+ .litespeed-wrap .litespeed-collection-button {
1720
+ text-decoration: none;
1721
+ min-width: 30px;
1722
+ text-align: center;
1723
+ }
1724
+
1725
+ .litespeed-collection-button[data-action="add"] {
1726
+ margin-top: -5px;
1727
+ margin-left: -5px;
1728
+ }
1729
+
1730
+ .litespeed-collection-button .dashicons {
1731
+ vertical-align: baseline;
1732
+ }
1733
+
1734
+ .litespeed-wrap .button:not(.litespeed-btn-large).litespeed-form-action .dashicons {
1735
+ font-size: 1.2em;
1736
+ vertical-align: middle;
1737
+ top: 0;
1738
+ }
1739
+
1740
+ @media screen and (max-width: 1023px) and (min-width: 681px) {}
1741
+
1742
+ @media screen and (max-width: 680px) {
1743
+
1744
+ .litespeed-body tbody>tr>th {
1745
+ display: block;
1746
+ padding: 18px 0 5px 12px;
1747
+ }
1748
+
1749
+ .litespeed-wrap .litespeed-float-submit {
1750
+ display: none;
1751
+ }
1752
+
1753
+ .litespeed-body {
1754
+ padding: 1px 10px 20px 15px;
1755
+ }
1756
+
1757
+ .litespeed-body .regular-text {
1758
+ width: 100%;
1759
+ }
1760
+
1761
+ .litespeed-textarea-recommended {
1762
+ flex-direction: column;
1763
+ }
1764
+
1765
+ .litespeed-textarea-recommended>div:first-child {
1766
+ margin-bottom: 1.7em;
1767
+ margin-top: 0;
1768
+ }
1769
+ }
1770
+
1771
+ /* =======================================
1772
+ ENTERPRISE NOTICE
1773
+ ======================================= */
1774
+
1775
+ .litespeed-ent-notice {
1776
+ position: absolute;
1777
+ left: 0;
1778
+ top: 0;
1779
+ right: 0;
1780
+ bottom: 0;
1781
+ background-color: #333;
1782
+ z-index: 999;
1783
+ opacity: 0.8;
1784
+ text-align: center;
1785
+ font-size: 3rem;
1786
+ color: #1865c5;
1787
+ }
1788
+
1789
+ .litespeed-ent-notice-desc {
1790
+ position: relative;
1791
+ top: 30%;
1792
+ transform: rotate(-20deg);
1793
+ text-shadow: 2px 2px 4px #000000;
1794
+ }
1795
+
1796
+ /* =======================================
1797
+ PROMO BANNER
1798
+ ======================================= */
1799
+
1800
+ .litespeed-banner-promo,
1801
+ .litespeed-banner-promo-full {
1802
+ display: flex;
1803
+ padding: 0px;
1804
+ }
1805
+
1806
+ .litespeed-banner-promo-full {
1807
+ margin: 0px;
1808
+ padding: 0px;
1809
+ }
1810
+
1811
+ .litespeed-banner-promo-logo {
1812
+ background-image: url(../img/lscwp-logo_90x90.png);
1813
+ background-size: contain;
1814
+ width: 90px;
1815
+ background-repeat: no-repeat;
1816
+ display: inline-block;
1817
+ }
1818
+
1819
+ .litespeed-banner-promo-full .litespeed-banner-promo-logo {
1820
+ margin: 0px;
1821
+ width: 90px;
1822
+ height: 90px;
1823
+ }
1824
+
1825
+ .litespeed-banner-promo-content {
1826
+ margin-left: 25px;
1827
+ }
1828
+
1829
+ .litespeed-banner-promo-full .litespeed-banner-promo-content {
1830
+ width: 75%;
1831
+ }
1832
+
1833
+ .litespeed-banner-promo-content h1 {
1834
+ font-weight: 600;
1835
+ color: #538ac6;
1836
+ margin-top: 10px;
1837
+ }
1838
+
1839
+ .litespeed-banner-title {
1840
+ font-size: 1.3em;
1841
+ margin: 8px 0px 5px 0px;
1842
+ }
1843
+
1844
+ .litespeed-banner-promo-slacklogo {
1845
+ background-image: url("../img/slack-logo.png");
1846
+ background-size: contain;
1847
+ width: 75px;
1848
+ height: 75px;
1849
+ background-repeat: no-repeat;
1850
+ display: inline-block;
1851
+ padding: 0px;
1852
+ flex: 0 0 5%;
1853
+ }
1854
+
1855
+ .litespeed-banner-promo .litespeed-banner-promo-slack-line1 {
1856
+ font-size: 18px;
1857
+ margin-top: 0px;
1858
+ line-height: 21px;
1859
+ }
1860
+
1861
+ .litespeed-banner-promo .litespeed-banner-promo-slack-textlink {
1862
+ color: #e59544;
1863
+ text-decoration: none;
1864
+ }
1865
+
1866
+ .litespeed-banner-promo .litespeed-banner-promo-slack-textlink:hover {
1867
+ opacity: 0.8;
1868
+ }
1869
+
1870
+ .litespeed-banner-promo-slack-line2 {
1871
+ font-size: 15px;
1872
+ margin: 0px;
1873
+ line-height: .75em;
1874
+ }
1875
+
1876
+ .litespeed-banner-promo-slack-link {
1877
+ color: #888888;
1878
+ }
1879
+
1880
+ a.litespeed-btn-xs.litespeed-banner-promo-slack-btn {
1881
+ margin: 0px 5px;
1882
+ }
1883
+
1884
+ /* =======================================
1885
+ PROMO BANNER - QC
1886
+ ======================================= */
1887
+
1888
+ .litespeed-banner-promo-qc {
1889
+ display: flex;
1890
+ }
1891
+
1892
+ .litespeed-banner-promo-qc h2 {
1893
+ line-height: 1.4;
1894
+ }
1895
+
1896
+ .litespeed-banner-promo-qc-content {
1897
+ display: flex;
1898
+ align-items: center;
1899
+ }
1900
+
1901
+ .litespeed-banner-promo-qc-description {
1902
+ flex-basis: 50%;
1903
+ padding-right: 2rem;
1904
+ }
1905
+
1906
+ .litespeed-banner-promo-qc-description p {
1907
+ font-size: 14px;
1908
+ }
1909
+
1910
+ .litespeed-banner-promo-qc-description .button {
1911
+ margin-right: 1.5rem;
1912
+ }
1913
+
1914
+ .litespeed-tweet-preview {
1915
+ border-radius: 5px;
1916
+ line-height: 1.3125;
1917
+ box-shadow: 1px 1px 0.5em rgba(0, 0, 0, 0.3);
1918
+ margin: 0.5em 1em 1em 0;
1919
+ padding: 1em;
1920
+ max-width: 480px;
1921
+ display: flex;
1922
+ }
1923
+
1924
+ .litespeed-tweet-preview:after {
1925
+ content: '';
1926
+ display: block;
1927
+ clear: both;
1928
+ }
1929
+
1930
+ .litespeed-tweet-preview p:first-child {
1931
+ margin-top: 0;
1932
+ }
1933
+
1934
+ .litespeed-tweet-preview-title {
1935
+ color: #777;
1936
+ margin-top: 0.9em;
1937
+ font-weight: normal;
1938
+ font-size: 12px;
1939
+ margin-bottom: 0;
1940
+ margin-top: 0.9em;
1941
+ }
1942
+
1943
+ .litespeed-tweet-text {
1944
+ font: 14px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", sans-serif;
1945
+ line-height: 1.3125;
1946
+ }
1947
+
1948
+ .litespeed-tweet-cta {
1949
+ text-align: right;
1950
+ margin-top: 1em;
1951
+ }
1952
+
1953
+
1954
+ .litespeed-tweet-cta a {
1955
+ background-color: #1DA1F2;
1956
+ line-height: 1.3125;
1957
+ color: #fff;
1958
+ font-weight: bold;
1959
+ display: inline-flex;
1960
+ padding: 0.55em 1em;
1961
+ font-size: 14px;
1962
+ border-radius: 99em;
1963
+ text-decoration: none;
1964
+ }
1965
+
1966
+ .litespeed-tweet-cta a:hover {
1967
+ background-color: #1E98E1;
1968
+ }
1969
+
1970
+ .litespeed-tweet-cta a svg {
1971
+ width: 16px;
1972
+ height: 18px;
1973
+ margin-right: 0.5em;
1974
+ }
1975
+
1976
+ .litespeed-tweet-cta a svg path {
1977
+ fill: currentColor;
1978
+ }
1979
+
1980
+ .litespeed-tweet-img {
1981
+ width: calc(240px + 1rem);
1982
+ padding-right: 1rem;
1983
+ box-sizing: border-box;
1984
+ }
1985
+
1986
+ .litespeed-tweet-img img {
1987
+ max-width: 100%;
1988
+ vertical-align: middle;
1989
+ }
1990
+
1991
+ .litespeed-tweet-img+p {
1992
+ margin-top: 0;
1993
+ }
1994
+
1995
+ /* =======================================
1996
+ admin -> media lib icon
1997
+ ======================================= */
1998
+
1999
+ .litespeed-media-href {
2000
+ display: inline-table;
2001
+ }
2002
+
2003
+ [class*="litespeed-icon-media-"] {
2004
+ background-size: contain;
2005
+ width: 25px;
2006
+ height: 25px;
2007
+ vertical-align: middle;
2008
+ margin: 0;
2009
+ background-repeat: no-repeat;
2010
+ display: inline-block;
2011
+ }
2012
+
2013
+ [class*="litespeed-icon-media-"]:hover {
2014
+ opacity: 0.7;
2015
+ }
2016
+
2017
+ .litespeed-icon-media-webp {
2018
+ background-image: url("../img/icons/img_webp.svg");
2019
+ }
2020
+
2021
+ .litespeed-icon-media-webp-disabled {
2022
+ background-image: url("../img/icons/img_webp_disabled.svg");
2023
+ }
2024
+
2025
+ .litespeed-icon-media-optm {
2026
+ background-image: url("../img/icons/img_optm.svg");
2027
+ }
2028
+
2029
+ .litespeed-icon-media-optm-disabled {
2030
+ background-image: url("../img/icons/img_optm_disabled.svg");
2031
+ }
2032
+
2033
+ p.litespeed-media-p {
2034
+ margin-bottom: 1px !important;
2035
+ }
2036
+
2037
+ p.litespeed-txt-webp {
2038
+ color: #83b04a;
2039
+ }
2040
+
2041
+ p.litespeed-txt-ori {
2042
+ color: #5967b3;
2043
+ }
2044
+
2045
+ p.litespeed-txt-disabled {
2046
+ color: #ced2d9;
2047
+ }
2048
+
2049
+ .litespeed-media-svg {
2050
+ vertical-align: middle;
2051
+ margin: 5px;
2052
+ width: 25px;
2053
+ height: auto;
2054
+ }
2055
+
2056
+ @keyframes litespeed-circle-chart-fill {
2057
+ to {
2058
+ stroke-dasharray: 0 100;
2059
+ }
2060
+ }
2061
+
2062
+ /* =======================================
2063
+ PIE chart
2064
+ ======================================= */
2065
+
2066
+ .litespeed-pie {
2067
+ vertical-align: middle;
2068
+ margin: 5px 5px 5px 0;
2069
+ }
2070
+
2071
+
2072
+ circle.litespeed-pie_bg {
2073
+ stroke: #efefef;
2074
+ stroke-width: 2;
2075
+ fill: none;
2076
+ }
2077
+
2078
+ circle.litespeed-pie_circle {
2079
+ animation: litespeed-circle-chart-fill 2s reverse;
2080
+ transform: rotate(-90deg);
2081
+ transform-origin: center;
2082
+
2083
+ animation: litespeed-pie-fill 2s reverse;
2084
+ /* 1 */
2085
+ stroke: #28a745;
2086
+ stroke-width: 2;
2087
+ stroke-linecap: round;
2088
+ fill: none;
2089
+ }
2090
+
2091
+
2092
+ .litespeed-pie.litespeed-pie-tiny {
2093
+ margin: 0 2px 0 0;
2094
+ }
2095
+
2096
+ .litespeed-pie.litespeed-pie-tiny text {
2097
+ font-weight: bold;
2098
+ fill: #828282;
2099
+
2100
+ }
2101
+
2102
+ .litespeed-pie.litespeed-pie-tiny circle {
2103
+ stroke-linecap: initial;
2104
+ }
2105
+
2106
+ .litespeed-pie-tiny circle.litespeed-pie_bg,
2107
+ .litespeed-pie-tiny circle.litespeed-pie_circle {
2108
+ stroke-width: 3;
2109
+ }
2110
+
2111
+ .litespeed-pie-tiny circle.litespeed-pie_bg {
2112
+ stroke: #eee;
2113
+ }
2114
+
2115
+ .litespeed-pie-success circle.litespeed-pie_circle {
2116
+ stroke: #28a745;
2117
+ }
2118
+
2119
+ .litespeed-pie-warning circle.litespeed-pie_circle {
2120
+ stroke: #e67700;
2121
+ }
2122
+
2123
+ .litespeed-pie-danger circle.litespeed-pie_circle {
2124
+ stroke: #c7221f;
2125
+ }
2126
+
2127
+ g.litespeed-pie_info text {
2128
+ dominant-baseline: central;
2129
+ text-anchor: middle;
2130
+ font-size: 11px;
2131
+ }
2132
+
2133
+ .litespeed-promo-score g.litespeed-pie_info text {
2134
+ font-size: 14px;
2135
+ font-weight: 600;
2136
+ }
2137
+
2138
+ .litespeed-pie-success g.litespeed-pie_info text {
2139
+ fill: #28a745;
2140
+ }
2141
+
2142
+ .litespeed-pie-warning g.litespeed-pie_info text {
2143
+ fill: #e67700;
2144
+ }
2145
+
2146
+ .litespeed-pie-danger g.litespeed-pie_info text {
2147
+ fill: #c7221f;
2148
+ }
2149
+
2150
+ g.litespeed-pie_info .litespeed-pie-done {
2151
+ fill: #28a745;
2152
+ font-size: 15px;
2153
+ }
2154
+
2155
+ /* =======================================
2156
+ VIEW - multiple cdn mapping
2157
+ ======================================= */
2158
+
2159
+ [data-litespeed-cdn-mapping]:first-child [data-litespeed-cdn-mapping-del] {
2160
+ display: none;
2161
+ }
2162
+
2163
+ .litespeed-cdn-mapping-col1 {
2164
+ padding-right: 2rem;
2165
+ max-width: 35%;
2166
+ }
2167
+
2168
+ .litespeed-cdn-mapping-col1 .litespeed-input-long {
2169
+ width: 100%;
2170
+ }
2171
+
2172
+ .litespeed-cdn-mapping-col2 {
2173
+ padding-top: 0.25rem;
2174
+ }
2175
+
2176
+ .litespeed-cdn-mapping-col1 label {
2177
+ position: relative;
2178
+ }
2179
+
2180
+ [data-litespeed-cdn-mapping-del] {
2181
+ position: absolute;
2182
+ right: -6px;
2183
+ top: -6px;
2184
+ }
2185
+
2186
+ /* =======================================
2187
+ VIEW - crawler
2188
+ ======================================= */
2189
+
2190
+ .litespeed-crawler-curr {
2191
+ vertical-align: middle;
2192
+ height: 20px;
2193
+ margin-left: 10px;
2194
+ }
2195
+
2196
+ #cookie_crawler>p:first-child {
2197
+ margin-top: 5px;
2198
+ }
2199
+
2200
+ /* =======================================
2201
+ PROGRESS BAR
2202
+ ======================================= */
2203
+
2204
+ .litespeed-progress-bar {
2205
+ display: -webkit-box;
2206
+ display: -ms-flexbox;
2207
+ display: flex;
2208
+ -webkit-box-orient: vertical;
2209
+ -webkit-box-direction: normal;
2210
+ -ms-flex-direction: column;
2211
+ flex-direction: column;
2212
+ -webkit-box-pack: center;
2213
+ -ms-flex-pack: center;
2214
+ justify-content: center;
2215
+ color: #fff;
2216
+ text-align: center;
2217
+ background-color: #007bff;
2218
+ transition: width .6s ease;
2219
+ }
2220
+
2221
+ .litespeed-progress-bar-yellow {
2222
+ background-color: #fbe100;
2223
+ }
2224
+
2225
+ .litespeed-progress {
2226
+ display: -webkit-box;
2227
+ display: -ms-flexbox;
2228
+ display: flex;
2229
+ height: 12px;
2230
+ overflow: hidden;
2231
+ font-size: .75rem;
2232
+ background-color: #e9ecef;
2233
+ border: 1px solid #dddddd;
2234
+ border-radius: 8px;
2235
+ width: 75%;
2236
+ margin: 5em 1em 1.5em 1em !important;
2237
+ }
2238
+
2239
+ /* =======================================
2240
+ PROGRESS BAR - modal
2241
+ ======================================= */
2242
+
2243
+ .litespeed-modal {
2244
+ margin-top: -8px;
2245
+ }
2246
+
2247
+ .litespeed-modal .litespeed-progress {
2248
+ margin-left: -8px;
2249
+ margin-right: -8px;
2250
+ }
2251
+
2252
+ /* =======================================
2253
+ GUIDANCE
2254
+ ======================================= */
2255
+
2256
+ .litespeed-guide {
2257
+ border: 1px solid #73b38d;
2258
+ max-width: 50%;
2259
+ padding: 20px;
2260
+ }
2261
+
2262
+ .litespeed-guide h2 {
2263
+ color: #73b38d;
2264
+ border-bottom: 1px solid #73b38d;
2265
+ display: table;
2266
+ padding-right: 50px;
2267
+ padding-left: 3px;
2268
+ padding-bottom: 3px;
2269
+ }
2270
+
2271
+ .litespeed-guide li {
2272
+ font-size: 15px;
2273
+ line-height: 30px;
2274
+ margin: 10px 10px 10px 16px;
2275
+ }
2276
+
2277
+ .litespeed-guide li.litespeed-guide-done:before {
2278
+ content: '\2713';
2279
+ font-size: 26px;
2280
+ color: #73b38d;
2281
+ margin-left: -37px;
2282
+ margin-right: 18px;
2283
+ opacity: 1;
2284
+ }
2285
+
2286
+ .litespeed-guide li.litespeed-guide-done {
2287
+ opacity: .9;
2288
+ }
2289
+
2290
+
2291
+ /* =======================================
2292
+ VIEW - image optimization
2293
+ ======================================= */
2294
+
2295
+ .litespeed-image-optim-summary-wrapper {
2296
+ padding: 0;
2297
+ }
2298
+
2299
+
2300
+ .litespeed-cache_page_litespeed-img_optm .nav-tab-wrapper {
2301
+ border-bottom: none;
2302
+ position: relative;
2303
+ z-index: 2;
2304
+ }
2305
+
2306
+ .litespeed-cache_page_litespeed-img_optm .litespeed-body {
2307
+ box-shadow: none;
2308
+ border: none;
2309
+ background: none;
2310
+ padding: 0;
2311
+ }
2312
+
2313
+ .litespeed-cache_page_litespeed-img_optm [data-litespeed-layout]:not([data-litespeed-layout='summary']) {
2314
+ background: #fff;
2315
+ border: 1px solid #e5e5e5;
2316
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
2317
+ padding: 1px 20px 20px 20px;
2318
+ }
2319
+
2320
+ .litespeed-column-secondary {
2321
+ background: #f9fafc;
2322
+ }
2323
+
2324
+ .litespeed-column-with-boxes>div:first-child {
2325
+ padding-right: 25px;
2326
+ }
2327
+
2328
+ .litespeed-column-with-boxes>div:last-child {
2329
+ background: #f1f1f1;
2330
+ padding-top: 0;
2331
+ padding-right: 0;
2332
+ padding-left: 0;
2333
+ }
2334
+
2335
+ .litespeed-column-with-boxes>div:last-child .litespeed-postbox:last-child {
2336
+ margin-bottom: 0;
2337
+ }
2338
+
2339
+ .litespeed-image-optim-summary {
2340
+ box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
2341
+ position: relative;
2342
+ padding: 1px 20px 20px 20px;
2343
+ background: #fff;
2344
+ border: 1px solid #e5e5e5;
2345
+ }
2346
+
2347
+ .litespeed-image-optim-summary-footer {
2348
+ border-top: 1px solid #efefef;
2349
+ background: #f9f9f9;
2350
+ padding: 20px;
2351
+ margin: 20px -20px -20px;
2352
+ }
2353
+
2354
+ .litespeed-help-btn-icon {
2355
+ text-decoration: none;
2356
+ margin-left: 10px;
2357
+ color: #c8c8c8;
2358
+ }
2359
+
2360
+ .litespeed-postbox-imgopt-info .litespeed-flex-container {
2361
+ align-items: center;
2362
+ }
2363
+
2364
+ .litespeed-postbox-imgopt-info .litespeed-flex-container:not(:last-child) {
2365
+ margin-bottom: 0.65em;
2366
+ }
2367
+
2368
+ .litespeed-postbox-imgopt-info .litespeed-flex-container p:first-child {
2369
+ margin-top: 0;
2370
+ }
2371
+
2372
+ .litespeed-image-optim-summary>h3:first-child {
2373
+ margin-top: 1.6em;
2374
+ font-size: 1.2em;
2375
+ }
2376
+
2377
+ .litespeed-image-optim-summary>h3:first-child .litespeed-quic-icon {
2378
+ width: 1.2em;
2379
+ height: 1.4em;
2380
+ background-size: contain;
2381
+ margin-right: 0.2rem;
2382
+ }
2383
+
2384
+ .litespeed-img-optim-actions {
2385
+ margin-top: 1.65em;
2386
+ display: flex;
2387
+ align-items: flex-end;
2388
+ }
2389
+
2390
+ .litespeed-img-optim-actions .button-primary {
2391
+ font-size: 1.2em;
2392
+ margin-right: 1em;
2393
+ padding: 0.35em 0.85em;
2394
+ min-width: 210px;
2395
+ text-align: center;
2396
+ }
2397
+
2398
+ @media screen and (max-width: 1079px) {
2399
+ .litespeed-postbox-imgopt-info svg {
2400
+ height: 50px;
2401
+ width: 50px;
2402
+ }
2403
+ }
2404
+
2405
+ @media screen and (max-width: 814px) {
2406
+ .litespeed-column-with-boxes>div:first-child {
2407
+ padding-right: 0;
2408
+ margin-bottom: 1rem;
2409
+ }
2410
+ }
2411
+
2412
+ /* =======================================
2413
+ VIEW - image optm media row
2414
+ ======================================= */
2415
+
2416
+ .imgoptm.column-imgoptm a[data-balloon-pos] {
2417
+ border-bottom: 1px dashed;
2418
+ }
2419
+
2420
+ .imgoptm.column-imgoptm p {
2421
+ margin-bottom: 0.25em;
2422
+ margin-top: 0;
2423
+ }
2424
+
2425
+ .imgoptm.column-imgoptm p+.row-actions {
2426
+ margin-top: 0.5em;
2427
+ }
2428
+
2429
+ .fixed .column-lqip {
2430
+ width: 6rem;
2431
+ }
2432
+
2433
+ .litespeed-media-lqip img {
2434
+ max-width: 62px;
2435
+ max-height: 62px;
2436
+ }
2437
+
2438
+ .litespeed-media-href {
2439
+ font-size: 12px;
2440
+ }
2441
+
2442
+ /* =======================================
2443
+ VIEW - dashboard
2444
+ ======================================= */
2445
+
2446
+ .litespeed-dashboard-group {
2447
+ margin-bottom: 1rem;
2448
+ }
2449
+
2450
+ .litespeed-dashboard-group>.litespeed-flex-container {
2451
+ margin: 0 -10px;
2452
+ min-width: 100%;
2453
+ width: auto;
2454
+ }
2455
+
2456
+ .litespeed-dashboard .litespeed-postbox {
2457
+ margin: 10px;
2458
+
2459
+ }
2460
+
2461
+ .litespeed-dashboard-title a {
2462
+ text-decoration: none;
2463
+ margin-left: 0.25rem;
2464
+ }
2465
+
2466
+ .litespeed-dashboard-header {
2467
+ display: flex;
2468
+ align-items: center;
2469
+ }
2470
+
2471
+ .litespeed-dashboard-header:first-child {
2472
+ margin-top: 1.5rem;
2473
+ }
2474
+
2475
+ .litespeed-dashboard-header hr {
2476
+ align-self: center;
2477
+ flex-grow: 1;
2478
+ margin-left: 15px;
2479
+ margin-right: 15px;
2480
+ }
2481
+
2482
+ .litespeed-dashboard-header hr:last-child {
2483
+ margin-right: 0;
2484
+ }
2485
+
2486
+ .litespeed-dashboard-header .litespeed-learn-more {
2487
+ font-weight: normal;
2488
+ text-decoration: none;
2489
+ margin-top: -2px;
2490
+ color: #5e7380;
2491
+ }
2492
+
2493
+ .litespeed-dashboard-stats h3 {
2494
+ text-transform: uppercase;
2495
+ font-size: 12px;
2496
+ font-weight: normal;
2497
+ margin-bottom: 0;
2498
+ margin-top: 1.2em;
2499
+ color: #777;
2500
+ }
2501
+
2502
+ .litespeed-dashboard-stats h3+p {
2503
+ margin-top: 0;
2504
+ margin-bottom: 0;
2505
+ }
2506
+
2507
+ .litespeed-dashboard-stats .litespeed-desc {
2508
+ color: #777;
2509
+ }
2510
+
2511
+ .litespeed-dashboard-stats p strong {
2512
+ font-size: 2em;
2513
+ font-weight: normal;
2514
+ margin-right: 5px;
2515
+ }
2516
+
2517
+ .litespeed-dashboard-stats-wrapper {
2518
+ display: flex;
2519
+ }
2520
+
2521
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox {
2522
+ margin: 0;
2523
+ min-width: 20%;
2524
+ }
2525
+
2526
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox .inside .litespeed-title,
2527
+ .litespeed-dashboard-group .litespeed-postbox .inside .litespeed-title {
2528
+ font-size: 14px;
2529
+ }
2530
+
2531
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox:not(:last-child) {
2532
+ margin-right: -1px;
2533
+ }
2534
+
2535
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox:not(:first-child) {
2536
+ border-left-color: #f9f9f9;
2537
+ }
2538
+
2539
+ .litespeed-dashboard-stats-wrapper .litespeed-dashboard-stats p strong {
2540
+ font-size: 1.4rem;
2541
+ }
2542
+
2543
+ .litespeed-dashboard-stats-wrapper .litespeed-pie {
2544
+ width: 60px;
2545
+ height: 60px;
2546
+ }
2547
+
2548
+ .litespeed-dashboard-stats-wrapper .litespeed-flex-container+p:not(:last-child) {
2549
+ margin-bottom: 0.55em;
2550
+ }
2551
+
2552
+ .litespeed-dashboard-stats-payg {
2553
+ color: #777;
2554
+ }
2555
+
2556
+ .litespeed-dashboard-stats-payg strong {
2557
+ color: #444;
2558
+ }
2559
+
2560
+ .postbox .inside>p.litespeed-dashboard-stats-payg {
2561
+ margin-top: 1.35em;
2562
+ }
2563
+
2564
+ .postbox .inside>p.litespeed-dashboard-stats-payg:last-child {
2565
+
2566
+ margin-bottom: -5px !important;
2567
+ }
2568
+
2569
+ .litespeed-postbox p.litespeed-dashboard-stats-total {
2570
+ padding: 0.75em 20px 0 20px;
2571
+ border-top: 1px dashed #eee;
2572
+ margin-top: 0.55em;
2573
+ margin-left: -20px;
2574
+ margin-right: -20px;
2575
+ margin-bottom: -0.55em !important;
2576
+ }
2577
+
2578
+ .litespeed-dashboard-group .litespeed-postbox {
2579
+ width: calc(25% - 20px);
2580
+ display: flex;
2581
+ flex-direction: column;
2582
+ justify-content: space-between;
2583
+ }
2584
+
2585
+ .litespeed-dashboard-group .litespeed-postbox-double {
2586
+ min-width: calc(50% - 20px);
2587
+ display: flex;
2588
+ justify-content: space-between;
2589
+ }
2590
+
2591
+ .litespeed-postbox-double-content {
2592
+ display: flex;
2593
+ align-items: flex-start;
2594
+ justify-content: space-between;
2595
+ }
2596
+
2597
+ .litespeed-postbox-double-content .litespeed-postbox-double-col {
2598
+ width: 50%;
2599
+ }
2600
+
2601
+ .litespeed-postbox-double-content .litespeed-postbox-double-col:nth-child(2) {
2602
+ padding-left: 10px;
2603
+ }
2604
+
2605
+ .litespeed-dashboard-group hr {
2606
+ margin: 1.5rem 0 0.75rem 0;
2607
+ }
2608
+
2609
+ .litespeed-postbox .litespeed-postbox-refresh {
2610
+ text-decoration: none;
2611
+ color: #36b0b0;
2612
+ line-height: 1;
2613
+ vertical-align: top;
2614
+ margin-left: 0.5rem;
2615
+ margin-bottom: 0;
2616
+ }
2617
+
2618
+ .litespeed-postbox .litespeed-postbox-refresh.button .dashicons {
2619
+ font-size: 22px;
2620
+ top: 0.05em;
2621
+ }
2622
+
2623
+ .litespeed-postbox p:last-child {
2624
+ margin-bottom: 0;
2625
+ }
2626
+
2627
+ .litespeed-label-dashboard {
2628
+ font-size: 0.92em;
2629
+ padding: .3em .6em .35em .6em;
2630
+ font-weight: normal;
2631
+ display: inline-block;
2632
+ margin-left: .2em;
2633
+ min-width: 2em;
2634
+ }
2635
+
2636
+ .litespeed-label-dashboard:first-child {
2637
+ margin-left: 0;
2638
+ margin-right: .35em;
2639
+ }
2640
+
2641
+ .litespeed-postbox .inside {
2642
+ padding: 0 20px 5px;
2643
+ }
2644
+
2645
+ .litespeed-postbox .inside .litespeed-title {
2646
+ margin: 0 -20px 12px -20px;
2647
+ padding: 0px 20px 7px 20px;
2648
+ border-bottom: 1px solid #eee;
2649
+ font-size: 1.2em;
2650
+ display: block;
2651
+ }
2652
+
2653
+ .litespeed-postbox .inside.litespeed-postbox-footer {
2654
+ border-top: 1px solid #efefef;
2655
+ background: #f9f9f9;
2656
+ padding: 20px;
2657
+ margin-bottom: 0px;
2658
+ margin-top: 0;
2659
+ }
2660
+
2661
+ .litespeed-postbox .inside.litespeed-postbox-footer--compact {
2662
+ padding: 7px 20px 8px 20px;
2663
+ font-size: 12px;
2664
+ }
2665
+
2666
+
2667
+ .litespeed-postbox-imgopt .litespeed-pie {
2668
+ width: 55px;
2669
+ height: 55px;
2670
+ }
2671
+
2672
+ .litespeed-postbox-imgopt .litespeed-flex-container {
2673
+ align-items: center;
2674
+ margin-bottom: 10px;
2675
+ }
2676
+
2677
+ .litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle+div h3 {
2678
+ margin-top: 0;
2679
+ }
2680
+
2681
+ .litespeed-postbox-imgopt .litespeed-flex-container .litespeed-icon-vertical-middle+div p {
2682
+ line-height: 1.2;
2683
+ }
2684
+
2685
+ .litespeed-postbox-imgopt .litespeed-postbox-double-col:last-child>*:first-child {
2686
+ margin-top: 7px;
2687
+ }
2688
+
2689
+ .litespeed-postbox-pagespeed p:first-child {
2690
+ margin-top: 0;
2691
+ margin-bottom: 0;
2692
+ }
2693
+
2694
+ .litespeed-postbox-score-improve {
2695
+ line-height: 45px;
2696
+ margin-top: 7px;
2697
+ font-size: 42px;
2698
+ }
2699
+
2700
+ .litespeed-postbox-pagespeed .litespeed-padding-space:first-child {
2701
+ padding-left: 5px;
2702
+ padding-right: 5px;
2703
+ }
2704
+
2705
+ .litespeed-link-with-icon {
2706
+ text-decoration: underline;
2707
+ margin-right: 0.25em;
2708
+ }
2709
+
2710
+ .litespeed-link-with-icon .dashicons {
2711
+ vertical-align: baseline;
2712
+ position: relative;
2713
+ top: 0.1em;
2714
+ font-size: 1em;
2715
+ text-decoration: none;
2716
+ width: auto;
2717
+ margin-right: 0.5em;
2718
+ }
2719
+
2720
+ .litespeed-link-with-icon.litespeed-icon-right .dashicons {
2721
+ margin-left: 0.5em;
2722
+ margin-right: 0;
2723
+ }
2724
+
2725
+ .litespeed-links-group:not(:last-child) {
2726
+ margin-bottom: 1em;
2727
+ }
2728
+
2729
+ .litespeed-links-group>span:not(:last-child):after {
2730
+ content: '|';
2731
+ margin: 0 10px;
2732
+ color: #ddd;
2733
+ font-size: 13px;
2734
+ }
2735
+
2736
+ .litespeed-wrap p.litespeed-qc-dashboard-link {
2737
+ margin-left: 1rem;
2738
+ }
2739
+
2740
+ .litespeed-right.litespeed-qc-dashboard-link .dashicons {
2741
+ margin-left: 0.5em;
2742
+ margin-right: 0;
2743
+ }
2744
+
2745
+ .litespeed-score-col {
2746
+ flex-grow: 1;
2747
+ padding-right: 15px;
2748
+ }
2749
+
2750
+ .litespeed-score-col .litespeed-text-md {
2751
+ font-size: 1.35rem;
2752
+ }
2753
+
2754
+ .litespeed-score-col.litespeed-score-col--imp {
2755
+ text-align: right;
2756
+ padding-right: 0;
2757
+ }
2758
+
2759
+ .litespeed-score-col--imp .litespeed-text-jumbo {
2760
+ line-height: 1;
2761
+ }
2762
+
2763
+ span[data-balloon-pos] {
2764
+ border-bottom: 1px dashed;
2765
+ }
2766
+
2767
+ span[aria-label][data-balloon-pos] {
2768
+ cursor: default;
2769
+ }
2770
+
2771
+ @media screen and (max-width: 1400px) and (min-width: 1024px) {
2772
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox {
2773
+ flex-grow: 1;
2774
+ }
2775
+
2776
+ .litespeed-postbox .inside {
2777
+ padding: 0 15px 5px;
2778
+ }
2779
+
2780
+ .litespeed-dashboard-group .litespeed-postbox {
2781
+ width: calc(33.3333% - 20px);
2782
+ }
2783
+
2784
+ .litespeed-dashboard-group .litespeed-postbox-double {
2785
+ min-width: calc(66.6666% - 20px);
2786
+ }
2787
+ }
2788
+
2789
+ @media screen and (max-width: 1023px) {
2790
+
2791
+ .litespeed-dashboard-stats-wrapper {
2792
+ flex-wrap: wrap;
2793
+ }
2794
+
2795
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox:not(:first-child) {
2796
+ border-left-color: #ccd0d4;
2797
+ }
2798
+
2799
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox {
2800
+ margin-top: -1px;
2801
+ min-width: calc(33.3333% - 1px);
2802
+ }
2803
+
2804
+ .litespeed-postbox .inside {
2805
+ padding: 0 15px 5px;
2806
+ }
2807
+
2808
+ .litespeed-dashboard-group .litespeed-postbox {
2809
+ width: calc(50% - 20px);
2810
+ }
2811
+
2812
+ .litespeed-dashboard-group .litespeed-postbox-double {
2813
+ min-width: calc(100% - 20px);
2814
+ }
2815
+ }
2816
+
2817
+ @media screen and (max-width: 719px) and (min-width: 480px) {
2818
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox {
2819
+ margin-top: -1px;
2820
+ min-width: calc(50% - 2px);
2821
+ }
2822
+ }
2823
+
2824
+ @media screen and (max-width: 569px) {
2825
+ .litespeed-dashboard-stats-wrapper .litespeed-postbox {
2826
+ min-width: 100%;
2827
+ }
2828
+
2829
+ .litespeed-dashboard-group .litespeed-postbox {
2830
+ width: 100%;
2831
+ }
2832
+
2833
+ .litespeed-postbox-double-content .litespeed-postbox-double-col {
2834
+ width: 100%;
2835
+ }
2836
+
2837
+ .litespeed-postbox-double-content {
2838
+ flex-wrap: wrap;
2839
+ }
2840
+ }
2841
+
2842
+ /********************************* todo *******************************/
2843
+
2844
+
2845
+ /* image optimize page */
2846
+
2847
+
2848
+ .litespeed-column-java {
2849
+ background: #5CADAD !important;
2850
+ }
2851
+
2852
+ .litespeed-text-shipgrey {
2853
+ color: #535342 !important;
2854
+ }
2855
+
2856
+ .litespeed-text-dimgray {
2857
+ color: #666666 !important;
2858
+ }
2859
+
2860
+ .litespeed-text-grey {
2861
+ color: #999999 !important;
2862
+ }
2863
+
2864
+ .litespeed-text-whisper {
2865
+ color: #E6E6E6 !important;
2866
+ }
2867
+
2868
+ .litespeed-text-malibu {
2869
+ color: #5CBDDE !important;
2870
+ }
2871
+
2872
+ .litespeed-text-morningglory {
2873
+ color: #99CCCC !important;
2874
+ }
2875
+
2876
+ .litespeed-text-fern {
2877
+ color: #66CC66 !important;
2878
+ }
2879
+
2880
+ .litespeed-text-persiangreen {
2881
+ color: #009999 !important;
2882
+ }
2883
+
2884
+ .litespeed-text-lead {
2885
+ font-size: 16px;
2886
+ }
2887
+
2888
+ .litespeed-text-small {
2889
+ font-size: 12px;
2890
+ line-height: 14px;
2891
+ }
2892
+
2893
+ .litespeed-text-thin {
2894
+ font-weight: 100;
2895
+ }
2896
+
2897
+ .litespeed-contrast {
2898
+ color: white;
2899
+ }
2900
+
2901
+ .litespeed-hr-dotted {
2902
+ border: 1px dotted #eeeeee;
2903
+ }
2904
+
2905
+ .litespeed-hr {
2906
+ padding-bottom: 1.5em;
2907
+ border-bottom: .5px solid #97CACA;
2908
+ }
2909
+
2910
+ .litespeed-hr-with-space {
2911
+ border-top: 1px solid #eeeeee;
2912
+ margin: 2em 0;
2913
+ border-bottom: none;
2914
+ }
2915
+
2916
+ .litespeed-icon-vertical-middle {
2917
+ vertical-align: middle;
2918
+ display: inline-block;
2919
+ margin: 0px 10px 0px 10px;
2920
+ }
2921
+
2922
+
2923
+ .litespeed-column-java .litespeed-danger {
2924
+ color: #c1c53a !important;
2925
+ }
2926
+
2927
+ .litespeed-column-java .litespeed-desc {
2928
+ color: #bfbfbf;
2929
+ }
2930
+
2931
+ .litespeed-column-java code {
2932
+ color: #c2f5bf;
2933
+ background-color: #238888;
2934
+ }
2935
+
2936
+ .litespeed-column-java .litespeed-title {
2937
+ color: white;
2938
+ }
2939
+
2940
+ .litespeed-width-7-10 .litespeed-progress {
2941
+ margin: 1em;
2942
+ }
2943
+
2944
+ .litespeed-refresh:after {
2945
+ content: "⟳";
2946
+ width: 20px;
2947
+ height: 20px;
2948
+ color: #40ad3a;
2949
+ }
2950
+
2951
+ .litespeed-column-java .litespeed-refresh:after {
2952
+ color: #23ec17;
2953
+ }
2954
+
2955
+ .litespeed-refresh:hover:after,
2956
+ .litespeed-refresh:focus:after,
2957
+ .litespeed-refresh:focus:active:after {
2958
+ color: #7ffbfb;
2959
+ }
2960
+
2961
+ .litespeed-width-3-10 .litespeed-title {
2962
+ margin: 18px 0;
2963
+ }
2964
+
2965
+ .litespeed-silence {
2966
+ color: #B1B1B1;
2967
+ }
2968
+
2969
+ .litespeed-column-java .litespeed-congratulate {
2970
+ color: #c2f5bf;
2971
+ font-size: 20px;
2972
+ }
2973
+
2974
+ .litespeed-light-code .litespeed-silence code {
2975
+ background-color: #f0f5fb;
2976
+ }
2977
+
2978
+ .litespeed-column-java .litespeed-btn-danger {
2979
+ color: #f194a8;
2980
+ border-color: #f194a8;
2981
+ }
2982
+
2983
+ .litespeed-column-java .litespeed-btn-danger:hover {
2984
+ background: #f194a8;
2985
+ }
2986
+
2987
+ .litespeed-column-java svg.litespeed-pie circle.litespeed-pie_bg {
2988
+ stroke: #e8efe7;
2989
+ }
2990
+
2991
+ .litespeed-column-java svg.litespeed-pie circle.litespeed-pie_circle {
2992
+ stroke: #97CACA;
2993
+ }
2994
+
2995
+ .litespeed-column-java svg .litespeed-pie_info text {
2996
+ fill: #F5FFEB;
2997
+ }
2998
+
2999
+ .litespeed-column-java svg g.litespeed-pie_info .litespeed-pie-done {
3000
+ fill: #a5ffa0;
3001
+ }
3002
+
3003
+ .litespeed-column-java a {
3004
+ color: #eaf8ff;
3005
+ }
3006
+
3007
+ .litespeed-column-java a:hover {
3008
+ color: #ffffff;
3009
+ }
3010
+
3011
+ .litespeed-progress-bar-blue {
3012
+ background-color: #33ADFF;
3013
+ }
3014
+
3015
+ .litespeed-status-current {
3016
+ font-size: 3.5em;
3017
+ margin: 1.25em 0em .75em 0em;
3018
+ }
3019
+
3020
+ /* .litespeed-title, .litespeed-title-short {
3021
+ margin: 18px 0;
3022
+ border-bottom: 1px solid #C1D5EA;
3023
+ margin: 2.5em 0px 1.5em 0 !important;
3024
+ } */
3025
+
3026
+ .litespeed-column-java .litespeed-desc {
3027
+ color: #CAE4E4;
3028
+ }
3029
+
3030
+ .litespeed-column-java .litespeed-warning {
3031
+ color: #FFD597 !important;
3032
+ }
3033
+
3034
+ .litespeed-column-java .litespeed-btn-success {
3035
+ color: #DDF1E4;
3036
+ border: 1px solid #33AD5C;
3037
+ background: #33AD5C;
3038
+ }
3039
+
3040
+ .litespeed-column-java .litespeed-btn-success:hover {
3041
+ color: #FFFFFF;
3042
+ border: 1px solid #7DCA97;
3043
+ background: #009933;
3044
+ }
3045
+
3046
+ .litespeed-column-java .litespeed-btn-warning {
3047
+ color: #FFF1DD;
3048
+ border: 1px solid #FF9933;
3049
+ background-color: #FF9933;
3050
+ }
3051
+
3052
+ .litespeed-column-java .litespeed-btn-warning:hover {
3053
+ color: #FFFFFF;
3054
+ border-color: #FFCA7D;
3055
+ background: #FF9900;
3056
+ }
3057
+
3058
+ .litespeed-column-java .litespeed-btn-danger {
3059
+ color: #FFEADD !important;
3060
+ border: 1px solid #FF6600 !important;
3061
+ background: #FF5C5C;
3062
+ }
3063
+
3064
+ .litespeed-column-java .litespeed-btn-danger:hover {
3065
+ color: #FFFFFF;
3066
+ border: 1px solid #FF9797 !important;
3067
+ background: #FF0000;
3068
+ }
3069
+
3070
+ .litespeed-column-java .litepseed-dash-icon-success,
3071
+ .litepseed-dash-icon-success {
3072
+ color: #5CDEDE;
3073
+ font-size: 2em;
3074
+ margin-top: -.25em;
3075
+ }
3076
+
3077
+ .litespeed-column-java .litepseed-dash-icon-success:hover,
3078
+ .litepseed-dash-icon-success:hover {
3079
+ color: #7DE5E5;
3080
+ }
3081
+
3082
+ .litespeed-dashicons-large {
3083
+ font-size: 2em;
3084
+ }
3085
+
3086
+
3087
+ .litespeed-column-java p {
3088
+ color: #FFFFFF;
3089
+ }
3090
+
3091
+ .litespeed-body tbody>tr>th.litespeed-padding-left {
3092
+ padding-left: 3em;
3093
+ }
3094
+
3095
+ .litespeed-txt-small {
3096
+ font-size: 12px;
3097
+ }
3098
+
3099
+ .litespeed-txt-disabled .litespeed-text-dimgray {
3100
+ color: #aaaaaa;
3101
+ }
3102
+
3103
+ .litespeed-txt-disabled svg {
3104
+ fill: #aaaaaa;
3105
+ }
3106
+
3107
+ .litespeed-txt-disabled circle.litespeed-pie_circle {
3108
+ stroke: #cccccc;
3109
+ }
3110
+
3111
+ .litespeed-txt-disabled g.litespeed-pie_info text {
3112
+ color: #cccccc;
3113
+ }
3114
+
3115
+ a.litespeed-media-href svg:hover {
3116
+ border-radius: 50%;
3117
+ background: #F1FCFF;
3118
+ fill: #5CCAD7;
3119
+ box-shadow: 0 0 5px 1px #7DD5DF;
3120
+ transition: all 0.2s ease-out;
3121
+ transform: scale(1.05);
3122
+ }
3123
+
3124
+ .litespeed-media-p a .dashicons-trash {
3125
+ font-size: 2.25em;
3126
+ vertical-align: middle;
3127
+ display: inline;
3128
+ border-radius: 50%;
3129
+ line-height: 1.5em;
3130
+ }
3131
+
3132
+ .litespeed-media-p a .dashicons-trash:hover {
3133
+ transition: all .2s ease-out;
3134
+ color: #FFA500 !important;
3135
+ background: #FFF5E6;
3136
+ box-shadow: 0 0 10px 1px #FF8C00;
3137
+ }
3138
+
3139
+ .litespeed-media-p div>svg circle.litespeed-pie_bg {
3140
+ stroke: #ecf2f9;
3141
+ }
3142
+
3143
+ .litespeed-media-p div>svg circle.litespeed-pie_circle {
3144
+ stroke: #9fbfdf;
3145
+ }
3146
+
3147
+ .litespeed-media-p div>svg {
3148
+ fill: #538cc6;
3149
+ background: rgba(236, 242, 249, 0.1);
3150
+ border-radius: 50%;
3151
+ }
3152
+
3153
+ .litespeed-banner-description-padding-right-15 {
3154
+ padding-right: 15px;
3155
+ }
3156
+
3157
+ .litespeed-banner-description {
3158
+ display: inline-flex;
3159
+ flex-wrap: wrap;
3160
+ }
3161
+
3162
+ .litespeed-banner-desciption-content {
3163
+ margin: 0px;
3164
+ line-height: 1.25em;
3165
+ }
3166
+
3167
+ .litespeed-banner-button-link {
3168
+ white-space: nowrap;
3169
+ margin: 0px;
3170
+ line-height: 1.5em;
3171
+ padding-bottom: 5px;
3172
+ }
3173
+
3174
+ .litespeed-notice-dismiss {
3175
+ position: absolute;
3176
+ right: 25px;
3177
+ border: none;
3178
+ margin: 0;
3179
+ padding: 10px;
3180
+ background: none;
3181
+ cursor: pointer;
3182
+ color: #888888;
3183
+ display: block;
3184
+ height: 20px;
3185
+ text-align: center;
3186
+ -webkit-font-smoothing: antialiased;
3187
+ -moz-osx-font-smoothing: grayscale;
3188
+ font-weight: 600;
3189
+ text-decoration: none;
3190
+ }
3191
+
3192
+ .litespeed-notice-dismiss:hover,
3193
+ .litespeed-notice-dismiss:active,
3194
+ .litespeed-notice-dismiss:focus {
3195
+ color: #CC2929;
3196
+ }
3197
+
3198
+
3199
+
3200
+
3201
+
3202
+
3203
+
3204
+
3205
+ .litespeed-dot {
3206
+ display: inline-block;
3207
+ border-radius: 50%;
3208
+ width: 20px;
3209
+ height: 20px;
3210
+ color: white;
3211
+ text-align: center;
3212
+ }
3213
+
3214
+ .litespeed-badge {
3215
+ display: inline-block;
3216
+ border-radius: 20%;
3217
+ min-width: 50px;
3218
+ height: 20px;
3219
+ color: white;
3220
+ text-align: center;
3221
+ }
3222
+
3223
+
3224
+ /* =======================================
3225
+ BALLOON PURE CSS TOOLTIPS
3226
+ ======================================= */
3227
+
3228
+ :root {
3229
+ --balloon-color: rgba(16, 16, 16, 0.95);
3230
+ --balloon-font-size: 12px;
3231
+ --balloon-move: 4px;
3232
+ }
3233
+
3234
+ button[aria-label][data-balloon-pos] {
3235
+ overflow: visible;
3236
+ }
3237
+
3238
+ [aria-label][data-balloon-pos] {
3239
+ position: relative;
3240
+ cursor: pointer;
3241
+ }
3242
+
3243
+ [aria-label][data-balloon-pos]:after {
3244
+ opacity: 0;
3245
+ pointer-events: none;
3246
+ transition: all .2s ease .05s;
3247
+ text-indent: 0;
3248
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
3249
+ font-weight: normal;
3250
+ font-style: normal;
3251
+ text-shadow: none;
3252
+ font-size: var(--balloon-font-size);
3253
+ background: var(--balloon-color);
3254
+ border-radius: 2px;
3255
+ color: #fff;
3256
+ content: attr(aria-label);
3257
+ padding: .5em 1em;
3258
+ position: absolute;
3259
+ white-space: nowrap;
3260
+ z-index: 10;
3261
+ line-height: 1.4;
3262
+ }
3263
+
3264
+ [aria-label][data-balloon-pos]:before {
3265
+ width: 0;
3266
+ height: 0;
3267
+ border: 5px solid transparent;
3268
+ border-top-color: var(--balloon-color);
3269
+ opacity: 0;
3270
+ pointer-events: none;
3271
+ transition: all .2s ease .05s;
3272
+ content: "";
3273
+ position: absolute;
3274
+ z-index: 10;
3275
+ }
3276
+
3277
+ [aria-label][data-balloon-pos]:hover:before,
3278
+ [aria-label][data-balloon-pos]:hover:after,
3279
+ [aria-label][data-balloon-pos][data-balloon-visible]:before,
3280
+ [aria-label][data-balloon-pos][data-balloon-visible]:after,
3281
+ [aria-label][data-balloon-pos]:not([data-balloon-nofocus]):focus:before,
3282
+ [aria-label][data-balloon-pos]:not([data-balloon-nofocus]):focus:after {
3283
+ opacity: 1;
3284
+ pointer-events: none;
3285
+ }
3286
+
3287
+ [aria-label][data-balloon-pos].font-awesome:after {
3288
+ font-family: FontAwesome, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
3289
+ }
3290
+
3291
+ [aria-label][data-balloon-pos][data-balloon-break]:after {
3292
+ white-space: pre;
3293
+ }
3294
+
3295
+ [aria-label][data-balloon-pos][data-balloon-break][data-balloon-length]:after {
3296
+ white-space: pre-line;
3297
+ word-break: break-word;
3298
+ }
3299
+
3300
+ [aria-label][data-balloon-pos][data-balloon-blunt]:before,
3301
+ [aria-label][data-balloon-pos][data-balloon-blunt]:after {
3302
+ transition: none;
3303
+ }
3304
+
3305
+ [aria-label][data-balloon-pos][data-balloon-pos="up"]:after {
3306
+ bottom: 100%;
3307
+ left: 50%;
3308
+ margin-bottom: 10px;
3309
+ transform: translate(-50%, var(--balloon-move));
3310
+ transform-origin: top;
3311
+ }
3312
+
3313
+ [aria-label][data-balloon-pos][data-balloon-pos="up"]:before {
3314
+ bottom: 100%;
3315
+ left: 50%;
3316
+ transform: translate(-50%, var(--balloon-move));
3317
+ transform-origin: top;
3318
+ }
3319
+
3320
+ [aria-label][data-balloon-pos][data-balloon-pos="up"]:hover:after,
3321
+ [aria-label][data-balloon-pos][data-balloon-pos="up"][data-balloon-visible]:after {
3322
+ transform: translate(-50%, 0);
3323
+ }
3324
+
3325
+ [aria-label][data-balloon-pos][data-balloon-pos="up"]:hover:before,
3326
+ [aria-label][data-balloon-pos][data-balloon-pos="up"][data-balloon-visible]:before {
3327
+ transform: translate(-50%, 0);
3328
+ }
3329
+
3330
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:after {
3331
+ bottom: 100%;
3332
+ left: 0;
3333
+ margin-bottom: 10px;
3334
+ transform: translate(0, var(--balloon-move));
3335
+ transform-origin: top;
3336
+ }
3337
+
3338
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:before {
3339
+ bottom: 100%;
3340
+ left: 5px;
3341
+ transform: translate(0, var(--balloon-move));
3342
+ transform-origin: top;
3343
+ }
3344
+
3345
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:hover:after,
3346
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"][data-balloon-visible]:after {
3347
+ transform: translate(0, 0);
3348
+ }
3349
+
3350
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"]:hover:before,
3351
+ [aria-label][data-balloon-pos][data-balloon-pos="up-left"][data-balloon-visible]:before {
3352
+ transform: translate(0, 0);
3353
+ }
3354
+
3355
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:after {
3356
+ bottom: 100%;
3357
+ right: 0;
3358
+ margin-bottom: 10px;
3359
+ transform: translate(0, var(--balloon-move));
3360
+ transform-origin: top;
3361
+ }
3362
+
3363
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:before {
3364
+ bottom: 100%;
3365
+ right: 5px;
3366
+ transform: translate(0, var(--balloon-move));
3367
+ transform-origin: top;
3368
+ }
3369
+
3370
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:hover:after,
3371
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"][data-balloon-visible]:after {
3372
+ transform: translate(0, 0);
3373
+ }
3374
+
3375
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"]:hover:before,
3376
+ [aria-label][data-balloon-pos][data-balloon-pos="up-right"][data-balloon-visible]:before {
3377
+ transform: translate(0, 0);
3378
+ }
3379
+
3380
+ [aria-label][data-balloon-pos][data-balloon-pos="down"]:after {
3381
+ left: 50%;
3382
+ margin-top: 10px;
3383
+ top: 100%;
3384
+ transform: translate(-50%, calc(var(--balloon-move) * -1));
3385
+ }
3386
+
3387
+ [aria-label][data-balloon-pos][data-balloon-pos="down"]:before {
3388
+ width: 0;
3389
+ height: 0;
3390
+ border: 5px solid transparent;
3391
+ border-bottom-color: var(--balloon-color);
3392
+ left: 50%;
3393
+ top: 100%;
3394
+ transform: translate(-50%, calc(var(--balloon-move) * -1));
3395
+ }
3396
+
3397
+ [aria-label][data-balloon-pos][data-balloon-pos="down"]:hover:after,
3398
+ [aria-label][data-balloon-pos][data-balloon-pos="down"][data-balloon-visible]:after {
3399
+ transform: translate(-50%, 0);
3400
+ }
3401
+
3402
+ [aria-label][data-balloon-pos][data-balloon-pos="down"]:hover:before,
3403
+ [aria-label][data-balloon-pos][data-balloon-pos="down"][data-balloon-visible]:before {
3404
+ transform: translate(-50%, 0);
3405
+ }
3406
+
3407
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:after {
3408
+ left: 0;
3409
+ margin-top: 10px;
3410
+ top: 100%;
3411
+ transform: translate(0, calc(var(--balloon-move) * -1));
3412
+ }
3413
+
3414
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:before {
3415
+ width: 0;
3416
+ height: 0;
3417
+ border: 5px solid transparent;
3418
+ border-bottom-color: var(--balloon-color);
3419
+ left: 5px;
3420
+ top: 100%;
3421
+ transform: translate(0, calc(var(--balloon-move) * -1));
3422
+ }
3423
+
3424
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:hover:after,
3425
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"][data-balloon-visible]:after {
3426
+ transform: translate(0, 0);
3427
+ }
3428
+
3429
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"]:hover:before,
3430
+ [aria-label][data-balloon-pos][data-balloon-pos="down-left"][data-balloon-visible]:before {
3431
+ transform: translate(0, 0);
3432
+ }
3433
+
3434
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:after {
3435
+ right: 0;
3436
+ margin-top: 10px;
3437
+ top: 100%;
3438
+ transform: translate(0, calc(var(--balloon-move) * -1));
3439
+ }
3440
+
3441
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:before {
3442
+ width: 0;
3443
+ height: 0;
3444
+ border: 5px solid transparent;
3445
+ border-bottom-color: var(--balloon-color);
3446
+ right: 5px;
3447
+ top: 100%;
3448
+ transform: translate(0, calc(var(--balloon-move) * -1));
3449
+ }
3450
+
3451
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:hover:after,
3452
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"][data-balloon-visible]:after {
3453
+ transform: translate(0, 0);
3454
+ }
3455
+
3456
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"]:hover:before,
3457
+ [aria-label][data-balloon-pos][data-balloon-pos="down-right"][data-balloon-visible]:before {
3458
+ transform: translate(0, 0);
3459
+ }
3460
+
3461
+ [aria-label][data-balloon-pos][data-balloon-pos="left"]:after {
3462
+ margin-right: 10px;
3463
+ right: 100%;
3464
+ top: 50%;
3465
+ transform: translate(var(--balloon-move), -50%);
3466
+ }
3467
+
3468
+ [aria-label][data-balloon-pos][data-balloon-pos="left"]:before {
3469
+ width: 0;
3470
+ height: 0;
3471
+ border: 5px solid transparent;
3472
+ border-left-color: var(--balloon-color);
3473
+ right: 100%;
3474
+ top: 50%;
3475
+ transform: translate(var(--balloon-move), -50%);
3476
+ }
3477
+
3478
+ [aria-label][data-balloon-pos][data-balloon-pos="left"]:hover:after,
3479
+ [aria-label][data-balloon-pos][data-balloon-pos="left"][data-balloon-visible]:after {
3480
+ transform: translate(0, -50%);
3481
+ }
3482
+
3483
+ [aria-label][data-balloon-pos][data-balloon-pos="left"]:hover:before,
3484
+ [aria-label][data-balloon-pos][data-balloon-pos="left"][data-balloon-visible]:before {
3485
+ transform: translate(0, -50%);
3486
+ }
3487
+
3488
+ [aria-label][data-balloon-pos][data-balloon-pos="right"]:after {
3489
+ left: 100%;
3490
+ margin-left: 10px;
3491
+ top: 50%;
3492
+ transform: translate(calc(var(--balloon-move) * -1), -50%);
3493
+ }
3494
+
3495
+ [aria-label][data-balloon-pos][data-balloon-pos="right"]:before {
3496
+ width: 0;
3497
+ height: 0;
3498
+ border: 5px solid transparent;
3499
+ border-right-color: var(--balloon-color);
3500
+ left: 100%;
3501
+ top: 50%;
3502
+ transform: translate(calc(var(--balloon-move) * -1), -50%);
3503
+ }
3504
+
3505
+ [aria-label][data-balloon-pos][data-balloon-pos="right"]:hover:after,
3506
+ [aria-label][data-balloon-pos][data-balloon-pos="right"][data-balloon-visible]:after {
3507
+ transform: translate(0, -50%);
3508
+ }
3509
+
3510
+ [aria-label][data-balloon-pos][data-balloon-pos="right"]:hover:before,
3511
+ [aria-label][data-balloon-pos][data-balloon-pos="right"][data-balloon-visible]:before {
3512
+ transform: translate(0, -50%);
3513
+ }
3514
+
3515
+ [aria-label][data-balloon-pos][data-balloon-length="small"]:after {
3516
+ white-space: normal;
3517
+ width: 80px;
3518
+ }
3519
+
3520
+ [aria-label][data-balloon-pos][data-balloon-length="medium"]:after {
3521
+ white-space: normal;
3522
+ width: 150px;
3523
+ }
3524
+
3525
+ [aria-label][data-balloon-pos][data-balloon-length="large"]:after {
3526
+ white-space: normal;
3527
+ width: 260px;
3528
+ }
3529
+
3530
+ [aria-label][data-balloon-pos][data-balloon-length="xlarge"]:after {
3531
+ white-space: normal;
3532
+ width: 380px;
3533
+ }
3534
+
3535
+ @media screen and (max-width: 768px) {
3536
+ [aria-label][data-balloon-pos][data-balloon-length="xlarge"]:after {
3537
+ white-space: normal;
3538
+ width: 90vw;
3539
+ }
3540
+ }
3541
+
3542
+ [aria-label][data-balloon-pos][data-balloon-length="fit"]:after {
3543
+ white-space: normal;
3544
+ width: 100%;
3545
+ }
{img → assets/img}/Litespeed.icon.svg RENAMED
File without changes
{img → assets/img}/icons/all.svg RENAMED
File without changes
{img → assets/img}/icons/all_transients.svg RENAMED
File without changes
{img → assets/img}/icons/auto_draft.svg RENAMED
File without changes
{img → assets/img}/icons/cross_icon.svg RENAMED
File without changes
{img → assets/img}/icons/db.svg RENAMED
File without changes
{img → assets/img}/icons/empty-cache.svg RENAMED
File without changes
{img → assets/img}/icons/expired_transient.svg RENAMED
File without changes
{img → assets/img}/icons/img_optm.svg RENAMED
File without changes
{img → assets/img}/icons/img_optm_disabled.svg RENAMED
File without changes
{img → assets/img}/icons/img_webp.svg RENAMED
File without changes
{img → assets/img}/icons/img_webp_disabled.svg RENAMED
File without changes
{img → assets/img}/icons/optimize_tables.svg RENAMED
File without changes
{img → assets/img}/icons/purge-403.svg RENAMED
File without changes
{img → assets/img}/icons/purge-404.svg RENAMED
File without changes
{img → assets/img}/icons/purge-500.svg RENAMED
File without changes
{img → assets/img}/icons/purge-all.svg RENAMED
File without changes
{img → assets/img}/icons/purge-cssjs.svg RENAMED
File without changes
{img → assets/img}/icons/purge-front.svg RENAMED
File without changes
{img → assets/img}/icons/purge-object.svg RENAMED
File without changes
{img → assets/img}/icons/purge-opcache.svg RENAMED
File without changes
{img → assets/img}/icons/purge-pages.svg RENAMED
File without changes
{img → assets/img}/icons/revision.svg RENAMED
File without changes
{img → assets/img}/icons/spam_comment.svg RENAMED
File without changes
{img → assets/img}/icons/success_icon.svg RENAMED
File without changes
{img → assets/img}/icons/trackback-pingback.svg RENAMED
File without changes
{img → assets/img}/icons/trash_comment.svg RENAMED
File without changes
{img → assets/img}/icons/trash_post.svg RENAMED
File without changes
{img → assets/img}/lscwp-logo_90x90.png RENAMED
File without changes
assets/img/quic-cloud-icon-16x16.svg ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Generator: Adobe Illustrator 16.0.0, 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="16px" height="16px" viewBox="0 0 16 16" enable-background="new 0 0 16 16" xml:space="preserve">
6
+ <g>
7
+ <path fill="#889EAA" d="M15.222,5.874c-0.616-0.81-1.511-1.331-2.52-1.468c-0.793-0.108-1.584,0.033-2.29,0.406
8
+ c-0.095,0.05-0.188,0.103-0.276,0.161L9.819,5.211l0.819,1.077l0.25-0.189c0.05-0.032,0.103-0.062,0.155-0.09
9
+ c0.455-0.24,0.965-0.331,1.476-0.262c0.65,0.088,1.228,0.425,1.625,0.947c0.397,0.522,0.567,1.168,0.479,1.818
10
+ c-0.183,1.343-1.424,2.286-2.765,2.104c-0.511-0.069-0.979-0.294-1.354-0.646c-0.044-0.042-0.087-0.086-0.126-0.128L7.292,5.785
11
+ L7.292,5.798L6.967,5.371L6.931,5.328C6.857,5.246,6.779,5.165,6.699,5.09C6.093,4.518,5.335,4.157,4.51,4.045
12
+ C2.338,3.75,0.331,5.277,0.036,7.449c-0.295,2.171,1.232,4.178,3.404,4.473c0.827,0.113,1.652-0.034,2.39-0.423
13
+ c0.03-0.017,0.058-0.033,0.088-0.05l-0.833-1.093c-0.457,0.214-0.959,0.294-1.463,0.225c-1.432-0.194-2.439-1.518-2.245-2.95
14
+ c0.195-1.433,1.517-2.439,2.95-2.245c0.545,0.074,1.044,0.312,1.444,0.69c0.047,0.043,0.092,0.09,0.136,0.137l2.426,3.189
15
+ l0.001-0.014l0.985,1.295l0.034,0.042c0.069,0.077,0.145,0.154,0.224,0.229c0.581,0.549,1.307,0.895,2.099,1.002
16
+ c0.173,0.023,0.345,0.035,0.515,0.035c1.876,0,3.514-1.39,3.773-3.298C16.103,7.685,15.838,6.684,15.222,5.874z"/>
17
+ <path fill="#00CCCC" d="M8.614,11.234c-0.013-0.014-0.026-0.026-0.038-0.039L7.012,9.143C6.944,9.066,6.87,8.99,6.792,8.916
18
+ C6.211,8.368,5.485,8.023,4.693,7.915c-0.076-0.01-0.151-0.017-0.227-0.023H4.351l0.577,0.755C4.94,8.659,4.954,8.673,4.966,8.686
19
+ l1.563,2.053c0.068,0.076,0.142,0.152,0.22,0.225c0.581,0.549,1.306,0.896,2.099,1.003c0.075,0.01,0.15,0.018,0.227,0.023H9.19
20
+ L8.614,11.234z"/>
21
+ </g>
22
+ </svg>
{img → assets/img}/slack-logo.png RENAMED
File without changes
{js → assets/js}/css_async.js RENAMED
File without changes
{js → assets/js}/css_async.min.js RENAMED
File without changes
{js → assets/js}/instant_click.min.js RENAMED
File without changes
{js → assets/js}/instant_click.ori.js RENAMED
File without changes
{js → assets/js}/iziModal.min.js RENAMED
File without changes
{js → assets/js}/lazyload.init.js RENAMED
@@ -9,11 +9,15 @@
9
  (function( window, document ){
10
  'use strict' ;
11
 
12
- var instance ;
13
- var update_lazyload ;
 
 
 
 
14
 
15
  var init = function(){
16
- instance = new LazyLoad( { elements_selector : "[data-lazyloaded]" } ) ;
17
 
18
  update_lazyload = function(){
19
  instance.update() ;
9
  (function( window, document ){
10
  'use strict' ;
11
 
12
+ var instance;
13
+ var update_lazyload;
14
+
15
+ var litespeed_finish_callback = function(){
16
+ document.body.classList.add( 'litespeed_lazyloaded' );
17
+ }
18
 
19
  var init = function(){
20
+ instance = new LazyLoad( { elements_selector: "[data-lazyloaded]", callback_finish: litespeed_finish_callback } );
21
 
22
  update_lazyload = function(){
23
  instance.update() ;
{js → assets/js}/lazyload.lib.js RENAMED
File without changes
{js → assets/js}/lazyload.min.js RENAMED
@@ -1 +1 @@
1
- var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.LazyLoad=e()}(this,function(){"use strict";var n={elements_selector:"img",container:document,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"litespeed-loading",class_loaded:"litespeed-loaded",class_error:"error",load_delay:0,callback_load:null,callback_error:null,callback_set:null,callback_enter:null,callback_finish:null,to_webp:!1},s="data-",r="was-processed",o="ll-timeout",a="true",c=function(t,e){return t.getAttribute(s+e)},i=function(t,e,n){var o=s+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},l=function(t){return c(t,r)===a},u=function(t,e){return i(t,o,e)},d=function(t){return c(t,o)},f=function(t,e){var n,o="LazyLoad::Initialized",s=new t(e);try{n=new CustomEvent(o,{detail:{instance:s}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent(o,!1,!1,{instance:s})}window.dispatchEvent(n)};var _=function(t,e){return e?t.replace(/\.(jpe?g|png)/gi,".webp"):t},t="undefined"!=typeof window,v=t&&!("onscroll"in window)||/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),e=t&&"IntersectionObserver"in window,h=t&&"classList"in document.createElement("p"),b=t&&!1,g=function(t,e,n,o){for(var s,r=0;s=t.children[r];r+=1)if("SOURCE"===s.tagName){var a=c(s,n);m(s,e,a,o)}},m=function(t,e,n,o){n&&t.setAttribute(e,_(n,o))},p={IMG:function(t,e){var n=b&&e.to_webp,o=e.data_srcset,s=t.parentNode;s&&"PICTURE"===s.tagName&&g(s,"srcset",o,n);var r=c(t,e.data_sizes);m(t,"sizes",r);var a=c(t,o);m(t,"srcset",a,n);var i=c(t,e.data_src);m(t,"src",i,n)},IFRAME:function(t,e){var n=c(t,e.data_src);m(t,"src",n)},VIDEO:function(t,e){var n=e.data_src,o=c(t,n);g(t,"src",n),m(t,"src",o),t.load()}},y=function(t,e){var n,o,s=e._settings,r=t.tagName,a=p[r];if(a)return a(t,s),e._updateLoadingCount(1),void(e._elements=(n=e._elements,o=t,n.filter(function(t){return t!==o})));!function(t,e){var n=b&&e.to_webp,o=c(t,e.data_src),s=c(t,e.data_bg);if(o){var r=_(o,n);t.style.backgroundImage='url("'+r+'")'}if(s){var a=_(s,n);t.style.backgroundImage=a}}(t,s)},w=function(t,e){h?t.classList.add(e):t.className+=(t.className?" ":"")+e},E=function(t,e){t&&t(e)},L="load",I="loadeddata",O="error",k=function(t,e,n){t.addEventListener(e,n)},A=function(t,e,n){t.removeEventListener(e,n)},C=function(t,e,n){A(t,L,e),A(t,I,e),A(t,O,n)},z=function(t,e,n){var o,s,r=n._settings,a=e?r.class_loaded:r.class_error,i=e?r.callback_load:r.callback_error,c=t.target;o=c,s=r.class_loading,h?o.classList.remove(s):o.className=o.className.replace(new RegExp("(^|\\s+)"+s+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,""),w(c,a),E(i,c),n._updateLoadingCount(-1)},N=function(n,o){var t,e,s,r=function t(e){z(e,!0,o),C(n,t,a)},a=function t(e){z(e,!1,o),C(n,r,t)};s=a,k(t=n,L,e=r),k(t,I,e),k(t,O,s)},x=["IMG","IFRAME","VIDEO"],M=function(t,e,n){R(t,n),e.unobserve(t)},S=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))};function R(t,e,n){var o=e._settings;!n&&l(t)||(E(o.callback_enter,t),-1<x.indexOf(t.tagName)&&(N(t,e),w(t,o.class_loading)),y(t,e),i(t,r,a),E(o.callback_set,t))}var j=function(t){return t.isIntersecting||0<t.intersectionRatio},T=function(t,e){this._settings=_extends({},n,t),this._setObserver(),this._loadingCount=0,this.update(e)};return T.prototype={_manageIntersection:function(t){var e,n,o,s,r,a=this._observer,i=this._settings.load_delay,c=t.target;i?j(t)?(e=c,n=a,s=(o=this)._settings.load_delay,(r=d(e))||(r=setTimeout(function(){M(e,n,o),S(e)},s),u(e,r))):S(c):j(t)&&M(c,a,this)},_onIntersection:function(t){t.forEach(this._manageIntersection.bind(this))},_setObserver:function(){var t;e&&(this._observer=new IntersectionObserver(this._onIntersection.bind(this),{root:(t=this._settings).container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}))},_updateLoadingCount:function(t){this._loadingCount+=t,0===this._elements.length&&0===this._loadingCount&&E(this._settings.callback_finish)},update:function(t){var e=this,n=this._settings,o=t||n.container.querySelectorAll(n.elements_selector);this._elements=Array.prototype.slice.call(o).filter(function(t){return!l(t)}),!v&&this._observer?this._elements.forEach(function(t){e._observer.observe(t)}):this.loadAll()},destroy:function(){var e=this;this._observer&&(this._elements.forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){R(t,this,e)},loadAll:function(){var e=this;this._elements.forEach(function(t){e.load(t)})}},t&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)f(t,n);else f(t,e)}(T,window.lazyLoadOptions),T}),function(t,e){"use strict";var n,o,s=function(){n=new LazyLoad({elements_selector:"[data-lazyloaded]"}),o=function(){n.update()},t.MutationObserver&&new MutationObserver(o).observe(e.documentElement,{childList:!0,subtree:!0,attributes:!0})};t.addEventListener?t.addEventListener("load",s,!1):t.attachEvent("onload",s)}(window,document);
1
+ var _extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.LazyLoad=e()}(this,function(){"use strict";var n={elements_selector:"img",container:document,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",class_loading:"litespeed-loading",class_loaded:"litespeed-loaded",class_error:"error",load_delay:0,callback_load:null,callback_error:null,callback_set:null,callback_enter:null,callback_finish:null,to_webp:!1},s="data-",r="was-processed",o="ll-timeout",a="true",c=function(t,e){return t.getAttribute(s+e)},i=function(t,e,n){var o=s+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},l=function(t){return c(t,r)===a},u=function(t,e){return i(t,o,e)},d=function(t){return c(t,o)},f=function(t,e){var n,o="LazyLoad::Initialized",s=new t(e);try{n=new CustomEvent(o,{detail:{instance:s}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent(o,!1,!1,{instance:s})}window.dispatchEvent(n)};var _=function(t,e){return e?t.replace(/\.(jpe?g|png)/gi,".webp"):t},t="undefined"!=typeof window,v=t&&!("onscroll"in window)||/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),e=t&&"IntersectionObserver"in window,h=t&&"classList"in document.createElement("p"),b=t&&!1,g=function(t,e,n,o){for(var s,r=0;s=t.children[r];r+=1)if("SOURCE"===s.tagName){var a=c(s,n);m(s,e,a,o)}},m=function(t,e,n,o){n&&t.setAttribute(e,_(n,o))},p={IMG:function(t,e){var n=b&&e.to_webp,o=e.data_srcset,s=t.parentNode;s&&"PICTURE"===s.tagName&&g(s,"srcset",o,n);var r=c(t,e.data_sizes);m(t,"sizes",r);var a=c(t,o);m(t,"srcset",a,n);var i=c(t,e.data_src);m(t,"src",i,n)},IFRAME:function(t,e){var n=c(t,e.data_src);m(t,"src",n)},VIDEO:function(t,e){var n=e.data_src,o=c(t,n);g(t,"src",n),m(t,"src",o),t.load()}},y=function(t,e){var n,o,s=e._settings,r=t.tagName,a=p[r];if(a)return a(t,s),e._updateLoadingCount(1),void(e._elements=(n=e._elements,o=t,n.filter(function(t){return t!==o})));!function(t,e){var n=b&&e.to_webp,o=c(t,e.data_src),s=c(t,e.data_bg);if(o){var r=_(o,n);t.style.backgroundImage='url("'+r+'")'}if(s){var a=_(s,n);t.style.backgroundImage=a}}(t,s)},w=function(t,e){h?t.classList.add(e):t.className+=(t.className?" ":"")+e},E=function(t,e){t&&t(e)},L="load",I="loadeddata",O="error",k=function(t,e,n){t.addEventListener(e,n)},A=function(t,e,n){t.removeEventListener(e,n)},C=function(t,e,n){A(t,L,e),A(t,I,e),A(t,O,n)},z=function(t,e,n){var o,s,r=n._settings,a=e?r.class_loaded:r.class_error,i=e?r.callback_load:r.callback_error,c=t.target;o=c,s=r.class_loading,h?o.classList.remove(s):o.className=o.className.replace(new RegExp("(^|\\s+)"+s+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,""),w(c,a),E(i,c),n._updateLoadingCount(-1)},N=function(n,o){var t,e,s,r=function t(e){z(e,!0,o),C(n,t,a)},a=function t(e){z(e,!1,o),C(n,r,t)};s=a,k(t=n,L,e=r),k(t,I,e),k(t,O,s)},x=["IMG","IFRAME","VIDEO"],M=function(t,e,n){R(t,n),e.unobserve(t)},S=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))};function R(t,e,n){var o=e._settings;!n&&l(t)||(E(o.callback_enter,t),-1<x.indexOf(t.tagName)&&(N(t,e),w(t,o.class_loading)),y(t,e),i(t,r,a),E(o.callback_set,t))}var j=function(t){return t.isIntersecting||0<t.intersectionRatio},T=function(t,e){this._settings=_extends({},n,t),this._setObserver(),this._loadingCount=0,this.update(e)};return T.prototype={_manageIntersection:function(t){var e,n,o,s,r,a=this._observer,i=this._settings.load_delay,c=t.target;i?j(t)?(e=c,n=a,s=(o=this)._settings.load_delay,(r=d(e))||(r=setTimeout(function(){M(e,n,o),S(e)},s),u(e,r))):S(c):j(t)&&M(c,a,this)},_onIntersection:function(t){t.forEach(this._manageIntersection.bind(this))},_setObserver:function(){var t;e&&(this._observer=new IntersectionObserver(this._onIntersection.bind(this),{root:(t=this._settings).container===document?null:t.container,rootMargin:t.thresholds||t.threshold+"px"}))},_updateLoadingCount:function(t){this._loadingCount+=t,0===this._elements.length&&0===this._loadingCount&&E(this._settings.callback_finish)},update:function(t){var e=this,n=this._settings,o=t||n.container.querySelectorAll(n.elements_selector);this._elements=Array.prototype.slice.call(o).filter(function(t){return!l(t)}),!v&&this._observer?this._elements.forEach(function(t){e._observer.observe(t)}):this.loadAll()},destroy:function(){var e=this;this._observer&&(this._elements.forEach(function(t){e._observer.unobserve(t)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){R(t,this,e)},loadAll:function(){var e=this;this._elements.forEach(function(t){e.load(t)})}},t&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)f(t,n);else f(t,e)}(T,window.lazyLoadOptions),T}),function(e,t){"use strict";function n(){t.body.classList.add("litespeed_lazyloaded")}function a(){d=new LazyLoad({elements_selector:"[data-lazyloaded]",callback_finish:n}),o=function(){d.update()},e.MutationObserver&&new MutationObserver(o).observe(t.documentElement,{childList:!0,subtree:!0,attributes:!0})}var d,o;e.addEventListener?e.addEventListener("load",a,!1):e.attachEvent("onload",a)}(window,document);
{js → assets/js}/litespeed-cache-admin.js RENAMED
@@ -75,22 +75,6 @@ var _litespeed_dots ;
75
  $('[data-purgeby='+this.value+']').show() ;
76
  }) ;
77
 
78
- // Settings->General->Enable mobile view
79
- $('[name="litespeed-cache-conf[mobileview_enabled]"][value=1]').click(function() {
80
- if($(this).is(':checked')){
81
- if(!$('#litespeed-mobileview-rules').val()){
82
- $('#litespeed-mobileview-rules').val($('#litespeed-mobileview-rules-default').val()) ;
83
- }
84
- $('#litespeed-mobileview-rules').prop('readonly', false) ;
85
- }
86
- }) ;
87
- $('[name="litespeed-cache-conf[mobileview_enabled]"][value=0]').click(function() {
88
- if($(this).is(':checked')){
89
- // $('#litespeed-mobileview-rules').val('') ;
90
- $('#litespeed-mobileview-rules').prop('readonly', true) ;
91
- }
92
- }) ;
93
-
94
  /*************** crawler ******************/
95
  $('#litespeed-crawl-url-btn').click(function () {
96
  if( ! $(this).data('url') ){
@@ -109,13 +93,6 @@ var _litespeed_dots ;
109
  litespeed_fetch_meta() ;
110
  }) ;
111
 
112
- $('#litespeed_crawler_cron_enable').click(function(event) {
113
- var that = this ;
114
- $.getJSON( $(that).data('url'), function(json){
115
- $(that).prop('checked', json.enable) ;
116
- } ) ;
117
- }) ;
118
-
119
  /******************** Clear whm msg ********************/
120
  $(document).on('click', '.lscwp-whm-notice .notice-dismiss', function () {
121
  $.get(litespeed_data.ajax_url_dismiss_whm) ;
@@ -141,8 +118,9 @@ var _litespeed_dots ;
141
  });
142
 
143
  /** Lets copy one more submit button **/
144
- if ( $( '#litespeed_form_options' ).length > 0 ) {
145
- $( '#litespeed_form_options [type="submit"]' ).clone().addClass( 'litespeed-float-submit' ).prependTo( '#litespeed_form_options' ) ;
 
146
  }
147
 
148
  /** Promo banner **/
@@ -179,18 +157,6 @@ var _litespeed_dots ;
179
  litespeed_toggle() ;
180
  litespeed_cdn_mapping_del_init() ;
181
 
182
- /** Object Cache switching */
183
- $( '#litespeed-oc-mem' ).click( function( event ) {
184
- $( '[name="litespeed-cache-conf[cache_object_port]"]' ).val( 11211 ) ;
185
- $( '[data="litespeed-mem-divs"]' ).removeClass( 'litespeed-hide' ) ;
186
- $( '[data="litespeed-redis-divs"]' ).addClass( 'litespeed-hide' ) ;
187
- } ) ;
188
- $( '#litespeed-oc-redis' ).click( function( event ) {
189
- $( '[name="litespeed-cache-conf[cache_object_port]"]' ).val( 6379 ) ;
190
- $( '[data="litespeed-mem-divs"]' ).addClass( 'litespeed-hide' ) ;
191
- $( '[data="litespeed-redis-divs"]' ).removeClass( 'litespeed-hide' ) ;
192
- } ) ;
193
-
194
  function litespeed_cdn_mapping_del_init() {
195
  $( '[data-litespeed-cdn-mapping-del]' ).off().click(function(event) {
196
  if ( ! confirm( 'Are you sure?' ) ) {
@@ -218,10 +184,91 @@ var _litespeed_dots ;
218
  });
219
  }
220
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
 
 
 
 
 
 
 
 
 
 
 
 
222
  }) ;
223
  })(jQuery) ;
224
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  /**
226
  * Trigger a click event on an element
227
  * @since 1.8
@@ -243,8 +290,8 @@ function litespeed_display_tab(tab) {
243
  if ( jQuery('#litespeed-submit').length > 0 ){
244
  jQuery('#litespeed-submit').toggle(tab != 'compatibilities') ;
245
  }
246
- jQuery('[data-litespeed-tab]').removeClass('litespeed-tab-active') ;
247
- jQuery('[data-litespeed-tab="'+tab+'"]').addClass('litespeed-tab-active') ;
248
  jQuery('[data-litespeed-layout]').hide() ;
249
  jQuery('[data-litespeed-layout="'+tab+'"]').show() ;
250
  }
75
  $('[data-purgeby='+this.value+']').show() ;
76
  }) ;
77
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
  /*************** crawler ******************/
79
  $('#litespeed-crawl-url-btn').click(function () {
80
  if( ! $(this).data('url') ){
93
  litespeed_fetch_meta() ;
94
  }) ;
95
 
 
 
 
 
 
 
 
96
  /******************** Clear whm msg ********************/
97
  $(document).on('click', '.lscwp-whm-notice .notice-dismiss', function () {
98
  $.get(litespeed_data.ajax_url_dismiss_whm) ;
118
  });
119
 
120
  /** Lets copy one more submit button **/
121
+ if ( $( 'input[name="LSCWP_CTRL"]' ).length > 0 ) {
122
+ var btn = $( 'input.litespeed-duplicate-float' ) ;
123
+ btn.clone().addClass( 'litespeed-float-submit' ).insertAfter( btn ) ;
124
  }
125
 
126
  /** Promo banner **/
157
  litespeed_toggle() ;
158
  litespeed_cdn_mapping_del_init() ;
159
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  function litespeed_cdn_mapping_del_init() {
161
  $( '[data-litespeed-cdn-mapping-del]' ).off().click(function(event) {
162
  if ( ! confirm( 'Are you sure?' ) ) {
184
  });
185
  }
186
 
187
+ /**
188
+ * Human readable time conversation
189
+ * @since 3.0
190
+ */
191
+ if ( $( '[data-litespeed-readable]' ).length > 0 ) {
192
+ $( '[data-litespeed-readable]' ).each(function(index, el) {
193
+ var that = this ;
194
+ var $input = $( this ).siblings( 'input[type="text"]' ) ;
195
+
196
+ var txt = litespeed_readable_time( $input.val() ) ;
197
+ $( that ).html( txt ? '= ' + txt : '' ) ;
198
+
199
+ $input.keyup(function(event) {
200
+ var txt = litespeed_readable_time( $( this ).val() ) ;
201
+ $( that ).html( txt ? '= ' + txt : '' ) ;
202
+ });
203
+ });
204
+ }
205
+
206
+ /**
207
+ * Get server IP
208
+ * @since 3.0
209
+ */
210
+ $( '#litespeed_get_ip' ).click( function( e ) {
211
+ $.ajax( {
212
+ url: litespeed_data.ajax_url_getIP,
213
+ dataType: 'json',
214
+ beforeSend: function ( xhr ) {
215
+ xhr.setRequestHeader( 'X-WP-Nonce', litespeed_data.nonce ) ;
216
+ },
217
+ success: function( data ) {
218
+ $( '#litespeed_server_ip' ).html( data ) ;
219
+ }
220
+ } ) ;
221
+ } ) ;
222
 
223
+ /**
224
+ * Click only once
225
+ */
226
+ if ( $( '[data-litespeed-onlyonce]' ).length > 0 ) {
227
+ $( '[data-litespeed-onlyonce]' ).click( function ( e ) {
228
+ if ( $( this ).hasClass( 'disabled' ) ) {
229
+ e.preventDefault();
230
+ }
231
+ $( this ).addClass( 'disabled' );
232
+ } );
233
+ }
234
  }) ;
235
  })(jQuery) ;
236
 
237
+ /**
238
+ * Plural handler
239
+ */
240
+ function litespeed_plural( $num, $txt )
241
+ {
242
+ if ( $num > 1 ) return $num + ' ' + $txt + 's' ;
243
+
244
+ return $num + ' ' + $txt ;
245
+ }
246
+
247
+ /**
248
+ * Convert seconds to readable time
249
+ */
250
+ function litespeed_readable_time( seconds )
251
+ {
252
+ if ( seconds < 60 ) {
253
+ return '' ;
254
+ }
255
+
256
+ var second = Math.floor( seconds % 60 ) ;
257
+ var minute = Math.floor( ( seconds / 60 ) % 60 ) ;
258
+ var hour = Math.floor( ( seconds / 3600 ) % 24 ) ;
259
+ var day = Math.floor( ( seconds / 3600 / 24 ) % 7 ) ;
260
+ var week = Math.floor( seconds / 3600 / 24 / 7 ) ;
261
+
262
+ var str = '' ;
263
+ if ( week ) str += ' ' + litespeed_plural( week, 'week' ) ;
264
+ if ( day ) str += ' ' + litespeed_plural( day, 'day' ) ;
265
+ if ( hour ) str += ' ' + litespeed_plural( hour, 'hour' ) ;
266
+ if ( minute ) str += ' ' + litespeed_plural( minute, 'minute' ) ;
267
+ if ( second ) str += ' ' + litespeed_plural( second, 'second' ) ;
268
+
269
+ return str ;
270
+ }
271
+
272
  /**
273
  * Trigger a click event on an element
274
  * @since 1.8
290
  if ( jQuery('#litespeed-submit').length > 0 ){
291
  jQuery('#litespeed-submit').toggle(tab != 'compatibilities') ;
292
  }
293
+ jQuery('[data-litespeed-tab]').removeClass('nav-tab-active') ;
294
+ jQuery('[data-litespeed-tab="'+tab+'"]').addClass('nav-tab-active') ;
295
  jQuery('[data-litespeed-layout]').hide() ;
296
  jQuery('[data-litespeed-layout="'+tab+'"]').show() ;
297
  }
assets/js/vue.min.js ADDED
@@ -0,0 +1 @@
 
1
+ /* Vue.js v2.6.10 * (c) 2014-2019 Evan You * Released under the MIT License. */!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Vue=t()}(this,function(){"use strict";var e=Object.freeze({});function t(e){return null==e}function n(e){return null!=e}function r(e){return!0===e}function i(e){return"string"==typeof e||"number"==typeof e||"symbol"==typeof e||"boolean"==typeof e}function o(e){return null!==e&&"object"==typeof e}var a=Object.prototype.toString;function s(e){return"[object Object]"===a.call(e)}function c(e){var t=parseFloat(String(e));return t>=0&&Math.floor(t)===t&&isFinite(e)}function u(e){return n(e)&&"function"==typeof e.then&&"function"==typeof e.catch}function l(e){return null==e?"":Array.isArray(e)||s(e)&&e.toString===a?JSON.stringify(e,null,2):String(e)}function f(e){var t=parseFloat(e);return isNaN(t)?e:t}function p(e,t){for(var n=Object.create(null),r=e.split(","),i=0;i<r.length;i++)n[r[i]]=!0;return t?function(e){return n[e.toLowerCase()]}:function(e){return n[e]}}var d=p("slot,component",!0),v=p("key,ref,slot,slot-scope,is");function h(e,t){if(e.length){var n=e.indexOf(t);if(n>-1)return e.splice(n,1)}}var m=Object.prototype.hasOwnProperty;function y(e,t){return m.call(e,t)}function g(e){var t=Object.create(null);return function(n){return t[n]||(t[n]=e(n))}}var _=/-(\w)/g,b=g(function(e){return e.replace(_,function(e,t){return t?t.toUpperCase():""})}),$=g(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}),w=/\B([A-Z])/g,C=g(function(e){return e.replace(w,"-$1").toLowerCase()});var x=Function.prototype.bind?function(e,t){return e.bind(t)}:function(e,t){function n(n){var r=arguments.length;return r?r>1?e.apply(t,arguments):e.call(t,n):e.call(t)}return n._length=e.length,n};function k(e,t){t=t||0;for(var n=e.length-t,r=new Array(n);n--;)r[n]=e[n+t];return r}function A(e,t){for(var n in t)e[n]=t[n];return e}function O(e){for(var t={},n=0;n<e.length;n++)e[n]&&A(t,e[n]);return t}function S(e,t,n){}var T=function(e,t,n){return!1},E=function(e){return e};function N(e,t){if(e===t)return!0;var n=o(e),r=o(t);if(!n||!r)return!n&&!r&&String(e)===String(t);try{var i=Array.isArray(e),a=Array.isArray(t);if(i&&a)return e.length===t.length&&e.every(function(e,n){return N(e,t[n])});if(e instanceof Date&&t instanceof Date)return e.getTime()===t.getTime();if(i||a)return!1;var s=Object.keys(e),c=Object.keys(t);return s.length===c.length&&s.every(function(n){return N(e[n],t[n])})}catch(e){return!1}}function j(e,t){for(var n=0;n<e.length;n++)if(N(e[n],t))return n;return-1}function D(e){var t=!1;return function(){t||(t=!0,e.apply(this,arguments))}}var L="data-server-rendered",M=["component","directive","filter"],I=["beforeCreate","created","beforeMount","mounted","beforeUpdate","updated","beforeDestroy","destroyed","activated","deactivated","errorCaptured","serverPrefetch"],F={optionMergeStrategies:Object.create(null),silent:!1,productionTip:!1,devtools:!1,performance:!1,errorHandler:null,warnHandler:null,ignoredElements:[],keyCodes:Object.create(null),isReservedTag:T,isReservedAttr:T,isUnknownElement:T,getTagNamespace:S,parsePlatformTagName:E,mustUseProp:T,async:!0,_lifecycleHooks:I},P=/a-zA-Z\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD/;function R(e,t,n,r){Object.defineProperty(e,t,{value:n,enumerable:!!r,writable:!0,configurable:!0})}var H=new RegExp("[^"+P.source+".$_\\d]");var B,U="__proto__"in{},z="undefined"!=typeof window,V="undefined"!=typeof WXEnvironment&&!!WXEnvironment.platform,K=V&&WXEnvironment.platform.toLowerCase(),J=z&&window.navigator.userAgent.toLowerCase(),q=J&&/msie|trident/.test(J),W=J&&J.indexOf("msie 9.0")>0,Z=J&&J.indexOf("edge/")>0,G=(J&&J.indexOf("android"),J&&/iphone|ipad|ipod|ios/.test(J)||"ios"===K),X=(J&&/chrome\/\d+/.test(J),J&&/phantomjs/.test(J),J&&J.match(/firefox\/(\d+)/)),Y={}.watch,Q=!1;if(z)try{var ee={};Object.defineProperty(ee,"passive",{get:function(){Q=!0}}),window.addEventListener("test-passive",null,ee)}catch(e){}var te=function(){return void 0===B&&(B=!z&&!V&&"undefined"!=typeof global&&(global.process&&"server"===global.process.env.VUE_ENV)),B},ne=z&&window.__VUE_DEVTOOLS_GLOBAL_HOOK__;function re(e){return"function"==typeof e&&/native code/.test(e.toString())}var ie,oe="undefined"!=typeof Symbol&&re(Symbol)&&"undefined"!=typeof Reflect&&re(Reflect.ownKeys);ie="undefined"!=typeof Set&&re(Set)?Set:function(){function e(){this.set=Object.create(null)}return e.prototype.has=function(e){return!0===this.set[e]},e.prototype.add=function(e){this.set[e]=!0},e.prototype.clear=function(){this.set=Object.create(null)},e}();var ae=S,se=0,ce=function(){this.id=se++,this.subs=[]};ce.prototype.addSub=function(e){this.subs.push(e)},ce.prototype.removeSub=function(e){h(this.subs,e)},ce.prototype.depend=function(){ce.target&&ce.target.addDep(this)},ce.prototype.notify=function(){for(var e=this.subs.slice(),t=0,n=e.length;t<n;t++)e[t].update()},ce.target=null;var ue=[];function le(e){ue.push(e),ce.target=e}function fe(){ue.pop(),ce.target=ue[ue.length-1]}var pe=function(e,t,n,r,i,o,a,s){this.tag=e,this.data=t,this.children=n,this.text=r,this.elm=i,this.ns=void 0,this.context=o,this.fnContext=void 0,this.fnOptions=void 0,this.fnScopeId=void 0,this.key=t&&t.key,this.componentOptions=a,this.componentInstance=void 0,this.parent=void 0,this.raw=!1,this.isStatic=!1,this.isRootInsert=!0,this.isComment=!1,this.isCloned=!1,this.isOnce=!1,this.asyncFactory=s,this.asyncMeta=void 0,this.isAsyncPlaceholder=!1},de={child:{configurable:!0}};de.child.get=function(){return this.componentInstance},Object.defineProperties(pe.prototype,de);var ve=function(e){void 0===e&&(e="");var t=new pe;return t.text=e,t.isComment=!0,t};function he(e){return new pe(void 0,void 0,void 0,String(e))}function me(e){var t=new pe(e.tag,e.data,e.children&&e.children.slice(),e.text,e.elm,e.context,e.componentOptions,e.asyncFactory);return t.ns=e.ns,t.isStatic=e.isStatic,t.key=e.key,t.isComment=e.isComment,t.fnContext=e.fnContext,t.fnOptions=e.fnOptions,t.fnScopeId=e.fnScopeId,t.asyncMeta=e.asyncMeta,t.isCloned=!0,t}var ye=Array.prototype,ge=Object.create(ye);["push","pop","shift","unshift","splice","sort","reverse"].forEach(function(e){var t=ye[e];R(ge,e,function(){for(var n=[],r=arguments.length;r--;)n[r]=arguments[r];var i,o=t.apply(this,n),a=this.__ob__;switch(e){case"push":case"unshift":i=n;break;case"splice":i=n.slice(2)}return i&&a.observeArray(i),a.dep.notify(),o})});var _e=Object.getOwnPropertyNames(ge),be=!0;function $e(e){be=e}var we=function(e){var t;this.value=e,this.dep=new ce,this.vmCount=0,R(e,"__ob__",this),Array.isArray(e)?(U?(t=ge,e.__proto__=t):function(e,t,n){for(var r=0,i=n.length;r<i;r++){var o=n[r];R(e,o,t[o])}}(e,ge,_e),this.observeArray(e)):this.walk(e)};function Ce(e,t){var n;if(o(e)&&!(e instanceof pe))return y(e,"__ob__")&&e.__ob__ instanceof we?n=e.__ob__:be&&!te()&&(Array.isArray(e)||s(e))&&Object.isExtensible(e)&&!e._isVue&&(n=new we(e)),t&&n&&n.vmCount++,n}function xe(e,t,n,r,i){var o=new ce,a=Object.getOwnPropertyDescriptor(e,t);if(!a||!1!==a.configurable){var s=a&&a.get,c=a&&a.set;s&&!c||2!==arguments.length||(n=e[t]);var u=!i&&Ce(n);Object.defineProperty(e,t,{enumerable:!0,configurable:!0,get:function(){var t=s?s.call(e):n;return ce.target&&(o.depend(),u&&(u.dep.depend(),Array.isArray(t)&&function e(t){for(var n=void 0,r=0,i=t.length;r<i;r++)(n=t[r])&&n.__ob__&&n.__ob__.dep.depend(),Array.isArray(n)&&e(n)}(t))),t},set:function(t){var r=s?s.call(e):n;t===r||t!=t&&r!=r||s&&!c||(c?c.call(e,t):n=t,u=!i&&Ce(t),o.notify())}})}}function ke(e,t,n){if(Array.isArray(e)&&c(t))return e.length=Math.max(e.length,t),e.splice(t,1,n),n;if(t in e&&!(t in Object.prototype))return e[t]=n,n;var r=e.__ob__;return e._isVue||r&&r.vmCount?n:r?(xe(r.value,t,n),r.dep.notify(),n):(e[t]=n,n)}function Ae(e,t){if(Array.isArray(e)&&c(t))e.splice(t,1);else{var n=e.__ob__;e._isVue||n&&n.vmCount||y(e,t)&&(delete e[t],n&&n.dep.notify())}}we.prototype.walk=function(e){for(var t=Object.keys(e),n=0;n<t.length;n++)xe(e,t[n])},we.prototype.observeArray=function(e){for(var t=0,n=e.length;t<n;t++)Ce(e[t])};var Oe=F.optionMergeStrategies;function Se(e,t){if(!t)return e;for(var n,r,i,o=oe?Reflect.ownKeys(t):Object.keys(t),a=0;a<o.length;a++)"__ob__"!==(n=o[a])&&(r=e[n],i=t[n],y(e,n)?r!==i&&s(r)&&s(i)&&Se(r,i):ke(e,n,i));return e}function Te(e,t,n){return n?function(){var r="function"==typeof t?t.call(n,n):t,i="function"==typeof e?e.call(n,n):e;return r?Se(r,i):i}:t?e?function(){return Se("function"==typeof t?t.call(this,this):t,"function"==typeof e?e.call(this,this):e)}:t:e}function Ee(e,t){var n=t?e?e.concat(t):Array.isArray(t)?t:[t]:e;return n?function(e){for(var t=[],n=0;n<e.length;n++)-1===t.indexOf(e[n])&&t.push(e[n]);return t}(n):n}function Ne(e,t,n,r){var i=Object.create(e||null);return t?A(i,t):i}Oe.data=function(e,t,n){return n?Te(e,t,n):t&&"function"!=typeof t?e:Te(e,t)},I.forEach(function(e){Oe[e]=Ee}),M.forEach(function(e){Oe[e+"s"]=Ne}),Oe.watch=function(e,t,n,r){if(e===Y&&(e=void 0),t===Y&&(t=void 0),!t)return Object.create(e||null);if(!e)return t;var i={};for(var o in A(i,e),t){var a=i[o],s=t[o];a&&!Array.isArray(a)&&(a=[a]),i[o]=a?a.concat(s):Array.isArray(s)?s:[s]}return i},Oe.props=Oe.methods=Oe.inject=Oe.computed=function(e,t,n,r){if(!e)return t;var i=Object.create(null);return A(i,e),t&&A(i,t),i},Oe.provide=Te;var je=function(e,t){return void 0===t?e:t};function De(e,t,n){if("function"==typeof t&&(t=t.options),function(e,t){var n=e.props;if(n){var r,i,o={};if(Array.isArray(n))for(r=n.length;r--;)"string"==typeof(i=n[r])&&(o[b(i)]={type:null});else if(s(n))for(var a in n)i=n[a],o[b(a)]=s(i)?i:{type:i};e.props=o}}(t),function(e,t){var n=e.inject;if(n){var r=e.inject={};if(Array.isArray(n))for(var i=0;i<n.length;i++)r[n[i]]={from:n[i]};else if(s(n))for(var o in n){var a=n[o];r[o]=s(a)?A({from:o},a):{from:a}}}}(t),function(e){var t=e.directives;if(t)for(var n in t){var r=t[n];"function"==typeof r&&(t[n]={bind:r,update:r})}}(t),!t._base&&(t.extends&&(e=De(e,t.extends,n)),t.mixins))for(var r=0,i=t.mixins.length;r<i;r++)e=De(e,t.mixins[r],n);var o,a={};for(o in e)c(o);for(o in t)y(e,o)||c(o);function c(r){var i=Oe[r]||je;a[r]=i(e[r],t[r],n,r)}return a}function Le(e,t,n,r){if("string"==typeof n){var i=e[t];if(y(i,n))return i[n];var o=b(n);if(y(i,o))return i[o];var a=$(o);return y(i,a)?i[a]:i[n]||i[o]||i[a]}}function Me(e,t,n,r){var i=t[e],o=!y(n,e),a=n[e],s=Pe(Boolean,i.type);if(s>-1)if(o&&!y(i,"default"))a=!1;else if(""===a||a===C(e)){var c=Pe(String,i.type);(c<0||s<c)&&(a=!0)}if(void 0===a){a=function(e,t,n){if(!y(t,"default"))return;var r=t.default;if(e&&e.$options.propsData&&void 0===e.$options.propsData[n]&&void 0!==e._props[n])return e._props[n];return"function"==typeof r&&"Function"!==Ie(t.type)?r.call(e):r}(r,i,e);var u=be;$e(!0),Ce(a),$e(u)}return a}function Ie(e){var t=e&&e.toString().match(/^\s*function (\w+)/);return t?t[1]:""}function Fe(e,t){return Ie(e)===Ie(t)}function Pe(e,t){if(!Array.isArray(t))return Fe(t,e)?0:-1;for(var n=0,r=t.length;n<r;n++)if(Fe(t[n],e))return n;return-1}function Re(e,t,n){le();try{if(t)for(var r=t;r=r.$parent;){var i=r.$options.errorCaptured;if(i)for(var o=0;o<i.length;o++)try{if(!1===i[o].call(r,e,t,n))return}catch(e){Be(e,r,"errorCaptured hook")}}Be(e,t,n)}finally{fe()}}function He(e,t,n,r,i){var o;try{(o=n?e.apply(t,n):e.call(t))&&!o._isVue&&u(o)&&!o._handled&&(o.catch(function(e){return Re(e,r,i+" (Promise/async)")}),o._handled=!0)}catch(e){Re(e,r,i)}return o}function Be(e,t,n){if(F.errorHandler)try{return F.errorHandler.call(null,e,t,n)}catch(t){t!==e&&Ue(t,null,"config.errorHandler")}Ue(e,t,n)}function Ue(e,t,n){if(!z&&!V||"undefined"==typeof console)throw e;console.error(e)}var ze,Ve=!1,Ke=[],Je=!1;function qe(){Je=!1;var e=Ke.slice(0);Ke.length=0;for(var t=0;t<e.length;t++)e[t]()}if("undefined"!=typeof Promise&&re(Promise)){var We=Promise.resolve();ze=function(){We.then(qe),G&&setTimeout(S)},Ve=!0}else if(q||"undefined"==typeof MutationObserver||!re(MutationObserver)&&"[object MutationObserverConstructor]"!==MutationObserver.toString())ze="undefined"!=typeof setImmediate&&re(setImmediate)?function(){setImmediate(qe)}:function(){setTimeout(qe,0)};else{var Ze=1,Ge=new MutationObserver(qe),Xe=document.createTextNode(String(Ze));Ge.observe(Xe,{characterData:!0}),ze=function(){Ze=(Ze+1)%2,Xe.data=String(Ze)},Ve=!0}function Ye(e,t){var n;if(Ke.push(function(){if(e)try{e.call(t)}catch(e){Re(e,t,"nextTick")}else n&&n(t)}),Je||(Je=!0,ze()),!e&&"undefined"!=typeof Promise)return new Promise(function(e){n=e})}var Qe=new ie;function et(e){!function e(t,n){var r,i;var a=Array.isArray(t);if(!a&&!o(t)||Object.isFrozen(t)||t instanceof pe)return;if(t.__ob__){var s=t.__ob__.dep.id;if(n.has(s))return;n.add(s)}if(a)for(r=t.length;r--;)e(t[r],n);else for(i=Object.keys(t),r=i.length;r--;)e(t[i[r]],n)}(e,Qe),Qe.clear()}var tt=g(function(e){var t="&"===e.charAt(0),n="~"===(e=t?e.slice(1):e).charAt(0),r="!"===(e=n?e.slice(1):e).charAt(0);return{name:e=r?e.slice(1):e,once:n,capture:r,passive:t}});function nt(e,t){function n(){var e=arguments,r=n.fns;if(!Array.isArray(r))return He(r,null,arguments,t,"v-on handler");for(var i=r.slice(),o=0;o<i.length;o++)He(i[o],null,e,t,"v-on handler")}return n.fns=e,n}function rt(e,n,i,o,a,s){var c,u,l,f;for(c in e)u=e[c],l=n[c],f=tt(c),t(u)||(t(l)?(t(u.fns)&&(u=e[c]=nt(u,s)),r(f.once)&&(u=e[c]=a(f.name,u,f.capture)),i(f.name,u,f.capture,f.passive,f.params)):u!==l&&(l.fns=u,e[c]=l));for(c in n)t(e[c])&&o((f=tt(c)).name,n[c],f.capture)}function it(e,i,o){var a;e instanceof pe&&(e=e.data.hook||(e.data.hook={}));var s=e[i];function c(){o.apply(this,arguments),h(a.fns,c)}t(s)?a=nt([c]):n(s.fns)&&r(s.merged)?(a=s).fns.push(c):a=nt([s,c]),a.merged=!0,e[i]=a}function ot(e,t,r,i,o){if(n(t)){if(y(t,r))return e[r]=t[r],o||delete t[r],!0;if(y(t,i))return e[r]=t[i],o||delete t[i],!0}return!1}function at(e){return i(e)?[he(e)]:Array.isArray(e)?function e(o,a){var s=[];var c,u,l,f;for(c=0;c<o.length;c++)t(u=o[c])||"boolean"==typeof u||(l=s.length-1,f=s[l],Array.isArray(u)?u.length>0&&(st((u=e(u,(a||"")+"_"+c))[0])&&st(f)&&(s[l]=he(f.text+u[0].text),u.shift()),s.push.apply(s,u)):i(u)?st(f)?s[l]=he(f.text+u):""!==u&&s.push(he(u)):st(u)&&st(f)?s[l]=he(f.text+u.text):(r(o._isVList)&&n(u.tag)&&t(u.key)&&n(a)&&(u.key="__vlist"+a+"_"+c+"__"),s.push(u)));return s}(e):void 0}function st(e){return n(e)&&n(e.text)&&!1===e.isComment}function ct(e,t){if(e){for(var n=Object.create(null),r=oe?Reflect.ownKeys(e):Object.keys(e),i=0;i<r.length;i++){var o=r[i];if("__ob__"!==o){for(var a=e[o].from,s=t;s;){if(s._provided&&y(s._provided,a)){n[o]=s._provided[a];break}s=s.$parent}if(!s&&"default"in e[o]){var c=e[o].default;n[o]="function"==typeof c?c.call(t):c}}}return n}}function ut(e,t){if(!e||!e.length)return{};for(var n={},r=0,i=e.length;r<i;r++){var o=e[r],a=o.data;if(a&&a.attrs&&a.attrs.slot&&delete a.attrs.slot,o.context!==t&&o.fnContext!==t||!a||null==a.slot)(n.default||(n.default=[])).push(o);else{var s=a.slot,c=n[s]||(n[s]=[]);"template"===o.tag?c.push.apply(c,o.children||[]):c.push(o)}}for(var u in n)n[u].every(lt)&&delete n[u];return n}function lt(e){return e.isComment&&!e.asyncFactory||" "===e.text}function ft(t,n,r){var i,o=Object.keys(n).length>0,a=t?!!t.$stable:!o,s=t&&t.$key;if(t){if(t._normalized)return t._normalized;if(a&&r&&r!==e&&s===r.$key&&!o&&!r.$hasNormal)return r;for(var c in i={},t)t[c]&&"$"!==c[0]&&(i[c]=pt(n,c,t[c]))}else i={};for(var u in n)u in i||(i[u]=dt(n,u));return t&&Object.isExtensible(t)&&(t._normalized=i),R(i,"$stable",a),R(i,"$key",s),R(i,"$hasNormal",o),i}function pt(e,t,n){var r=function(){var e=arguments.length?n.apply(null,arguments):n({});return(e=e&&"object"==typeof e&&!Array.isArray(e)?[e]:at(e))&&(0===e.length||1===e.length&&e[0].isComment)?void 0:e};return n.proxy&&Object.defineProperty(e,t,{get:r,enumerable:!0,configurable:!0}),r}function dt(e,t){return function(){return e[t]}}function vt(e,t){var r,i,a,s,c;if(Array.isArray(e)||"string"==typeof e)for(r=new Array(e.length),i=0,a=e.length;i<a;i++)r[i]=t(e[i],i);else if("number"==typeof e)for(r=new Array(e),i=0;i<e;i++)r[i]=t(i+1,i);else if(o(e))if(oe&&e[Symbol.iterator]){r=[];for(var u=e[Symbol.iterator](),l=u.next();!l.done;)r.push(t(l.value,r.length)),l=u.next()}else for(s=Object.keys(e),r=new Array(s.length),i=0,a=s.length;i<a;i++)c=s[i],r[i]=t(e[c],c,i);return n(r)||(r=[]),r._isVList=!0,r}function ht(e,t,n,r){var i,o=this.$scopedSlots[e];o?(n=n||{},r&&(n=A(A({},r),n)),i=o(n)||t):i=this.$slots[e]||t;var a=n&&n.slot;return a?this.$createElement("template",{slot:a},i):i}function mt(e){return Le(this.$options,"filters",e)||E}function yt(e,t){return Array.isArray(e)?-1===e.indexOf(t):e!==t}function gt(e,t,n,r,i){var o=F.keyCodes[t]||n;return i&&r&&!F.keyCodes[t]?yt(i,r):o?yt(o,e):r?C(r)!==t:void 0}function _t(e,t,n,r,i){if(n)if(o(n)){var a;Array.isArray(n)&&(n=O(n));var s=function(o){if("class"===o||"style"===o||v(o))a=e;else{var s=e.attrs&&e.attrs.type;a=r||F.mustUseProp(t,s,o)?e.domProps||(e.domProps={}):e.attrs||(e.attrs={})}var c=b(o),u=C(o);c in a||u in a||(a[o]=n[o],i&&((e.on||(e.on={}))["update:"+o]=function(e){n[o]=e}))};for(var c in n)s(c)}else;return e}function bt(e,t){var n=this._staticTrees||(this._staticTrees=[]),r=n[e];return r&&!t?r:(wt(r=n[e]=this.$options.staticRenderFns[e].call(this._renderProxy,null,this),"__static__"+e,!1),r)}function $t(e,t,n){return wt(e,"__once__"+t+(n?"_"+n:""),!0),e}function wt(e,t,n){if(Array.isArray(e))for(var r=0;r<e.length;r++)e[r]&&"string"!=typeof e[r]&&Ct(e[r],t+"_"+r,n);else Ct(e,t,n)}function Ct(e,t,n){e.isStatic=!0,e.key=t,e.isOnce=n}function xt(e,t){if(t)if(s(t)){var n=e.on=e.on?A({},e.on):{};for(var r in t){var i=n[r],o=t[r];n[r]=i?[].concat(i,o):o}}else;return e}function kt(e,t,n,r){t=t||{$stable:!n};for(var i=0;i<e.length;i++){var o=e[i];Array.isArray(o)?kt(o,t,n):o&&(o.proxy&&(o.fn.proxy=!0),t[o.key]=o.fn)}return r&&(t.$key=r),t}function At(e,t){for(var n=0;n<t.length;n+=2){var r=t[n];"string"==typeof r&&r&&(e[t[n]]=t[n+1])}return e}function Ot(e,t){return"string"==typeof e?t+e:e}function St(e){e._o=$t,e._n=f,e._s=l,e._l=vt,e._t=ht,e._q=N,e._i=j,e._m=bt,e._f=mt,e._k=gt,e._b=_t,e._v=he,e._e=ve,e._u=kt,e._g=xt,e._d=At,e._p=Ot}function Tt(t,n,i,o,a){var s,c=this,u=a.options;y(o,"_uid")?(s=Object.create(o))._original=o:(s=o,o=o._original);var l=r(u._compiled),f=!l;this.data=t,this.props=n,this.children=i,this.parent=o,this.listeners=t.on||e,this.injections=ct(u.inject,o),this.slots=function(){return c.$slots||ft(t.scopedSlots,c.$slots=ut(i,o)),c.$slots},Object.defineProperty(this,"scopedSlots",{enumerable:!0,get:function(){return ft(t.scopedSlots,this.slots())}}),l&&(this.$options=u,this.$slots=this.slots(),this.$scopedSlots=ft(t.scopedSlots,this.$slots)),u._scopeId?this._c=function(e,t,n,r){var i=Pt(s,e,t,n,r,f);return i&&!Array.isArray(i)&&(i.fnScopeId=u._scopeId,i.fnContext=o),i}:this._c=function(e,t,n,r){return Pt(s,e,t,n,r,f)}}function Et(e,t,n,r,i){var o=me(e);return o.fnContext=n,o.fnOptions=r,t.slot&&((o.data||(o.data={})).slot=t.slot),o}function Nt(e,t){for(var n in t)e[b(n)]=t[n]}St(Tt.prototype);var jt={init:function(e,t){if(e.componentInstance&&!e.componentInstance._isDestroyed&&e.data.keepAlive){var r=e;jt.prepatch(r,r)}else{(e.componentInstance=function(e,t){var r={_isComponent:!0,_parentVnode:e,parent:t},i=e.data.inlineTemplate;n(i)&&(r.render=i.render,r.staticRenderFns=i.staticRenderFns);return new e.componentOptions.Ctor(r)}(e,Wt)).$mount(t?e.elm:void 0,t)}},prepatch:function(t,n){var r=n.componentOptions;!function(t,n,r,i,o){var a=i.data.scopedSlots,s=t.$scopedSlots,c=!!(a&&!a.$stable||s!==e&&!s.$stable||a&&t.$scopedSlots.$key!==a.$key),u=!!(o||t.$options._renderChildren||c);t.$options._parentVnode=i,t.$vnode=i,t._vnode&&(t._vnode.parent=i);if(t.$options._renderChildren=o,t.$attrs=i.data.attrs||e,t.$listeners=r||e,n&&t.$options.props){$e(!1);for(var l=t._props,f=t.$options._propKeys||[],p=0;p<f.length;p++){var d=f[p],v=t.$options.props;l[d]=Me(d,v,n,t)}$e(!0),t.$options.propsData=n}r=r||e;var h=t.$options._parentListeners;t.$options._parentListeners=r,qt(t,r,h),u&&(t.$slots=ut(o,i.context),t.$forceUpdate())}(n.componentInstance=t.componentInstance,r.propsData,r.listeners,n,r.children)},insert:function(e){var t,n=e.context,r=e.componentInstance;r._isMounted||(r._isMounted=!0,Yt(r,"mounted")),e.data.keepAlive&&(n._isMounted?((t=r)._inactive=!1,en.push(t)):Xt(r,!0))},destroy:function(e){var t=e.componentInstance;t._isDestroyed||(e.data.keepAlive?function e(t,n){if(n&&(t._directInactive=!0,Gt(t)))return;if(!t._inactive){t._inactive=!0;for(var r=0;r<t.$children.length;r++)e(t.$children[r]);Yt(t,"deactivated")}}(t,!0):t.$destroy())}},Dt=Object.keys(jt);function Lt(i,a,s,c,l){if(!t(i)){var f=s.$options._base;if(o(i)&&(i=f.extend(i)),"function"==typeof i){var p;if(t(i.cid)&&void 0===(i=function(e,i){if(r(e.error)&&n(e.errorComp))return e.errorComp;if(n(e.resolved))return e.resolved;var a=Ht;a&&n(e.owners)&&-1===e.owners.indexOf(a)&&e.owners.push(a);if(r(e.loading)&&n(e.loadingComp))return e.loadingComp;if(a&&!n(e.owners)){var s=e.owners=[a],c=!0,l=null,f=null;a.$on("hook:destroyed",function(){return h(s,a)});var p=function(e){for(var t=0,n=s.length;t<n;t++)s[t].$forceUpdate();e&&(s.length=0,null!==l&&(clearTimeout(l),l=null),null!==f&&(clearTimeout(f),f=null))},d=D(function(t){e.resolved=Bt(t,i),c?s.length=0:p(!0)}),v=D(function(t){n(e.errorComp)&&(e.error=!0,p(!0))}),m=e(d,v);return o(m)&&(u(m)?t(e.resolved)&&m.then(d,v):u(m.component)&&(m.component.then(d,v),n(m.error)&&(e.errorComp=Bt(m.error,i)),n(m.loading)&&(e.loadingComp=Bt(m.loading,i),0===m.delay?e.loading=!0:l=setTimeout(function(){l=null,t(e.resolved)&&t(e.error)&&(e.loading=!0,p(!1))},m.delay||200)),n(m.timeout)&&(f=setTimeout(function(){f=null,t(e.resolved)&&v(null)},m.timeout)))),c=!1,e.loading?e.loadingComp:e.resolved}}(p=i,f)))return function(e,t,n,r,i){var o=ve();return o.asyncFactory=e,o.asyncMeta={data:t,context:n,children:r,tag:i},o}(p,a,s,c,l);a=a||{},$n(i),n(a.model)&&function(e,t){var r=e.model&&e.model.prop||"value",i=e.model&&e.model.event||"input";(t.attrs||(t.attrs={}))[r]=t.model.value;var o=t.on||(t.on={}),a=o[i],s=t.model.callback;n(a)?(Array.isArray(a)?-1===a.indexOf(s):a!==s)&&(o[i]=[s].concat(a)):o[i]=s}(i.options,a);var d=function(e,r,i){var o=r.options.props;if(!t(o)){var a={},s=e.attrs,c=e.props;if(n(s)||n(c))for(var u in o){var l=C(u);ot(a,c,u,l,!0)||ot(a,s,u,l,!1)}return a}}(a,i);if(r(i.options.functional))return function(t,r,i,o,a){var s=t.options,c={},u=s.props;if(n(u))for(var l in u)c[l]=Me(l,u,r||e);else n(i.attrs)&&Nt(c,i.attrs),n(i.props)&&Nt(c,i.props);var f=new Tt(i,c,a,o,t),p=s.render.call(null,f._c,f);if(p instanceof pe)return Et(p,i,f.parent,s);if(Array.isArray(p)){for(var d=at(p)||[],v=new Array(d.length),h=0;h<d.length;h++)v[h]=Et(d[h],i,f.parent,s);return v}}(i,d,a,s,c);var v=a.on;if(a.on=a.nativeOn,r(i.options.abstract)){var m=a.slot;a={},m&&(a.slot=m)}!function(e){for(var t=e.hook||(e.hook={}),n=0;n<Dt.length;n++){var r=Dt[n],i=t[r],o=jt[r];i===o||i&&i._merged||(t[r]=i?Mt(o,i):o)}}(a);var y=i.options.name||l;return new pe("vue-component-"+i.cid+(y?"-"+y:""),a,void 0,void 0,void 0,s,{Ctor:i,propsData:d,listeners:v,tag:l,children:c},p)}}}function Mt(e,t){var n=function(n,r){e(n,r),t(n,r)};return n._merged=!0,n}var It=1,Ft=2;function Pt(e,a,s,c,u,l){return(Array.isArray(s)||i(s))&&(u=c,c=s,s=void 0),r(l)&&(u=Ft),function(e,i,a,s,c){if(n(a)&&n(a.__ob__))return ve();n(a)&&n(a.is)&&(i=a.is);if(!i)return ve();Array.isArray(s)&&"function"==typeof s[0]&&((a=a||{}).scopedSlots={default:s[0]},s.length=0);c===Ft?s=at(s):c===It&&(s=function(e){for(var t=0;t<e.length;t++)if(Array.isArray(e[t]))return Array.prototype.concat.apply([],e);return e}(s));var u,l;if("string"==typeof i){var f;l=e.$vnode&&e.$vnode.ns||F.getTagNamespace(i),u=F.isReservedTag(i)?new pe(F.parsePlatformTagName(i),a,s,void 0,void 0,e):a&&a.pre||!n(f=Le(e.$options,"components",i))?new pe(i,a,s,void 0,void 0,e):Lt(f,a,e,s,i)}else u=Lt(i,a,e,s);return Array.isArray(u)?u:n(u)?(n(l)&&function e(i,o,a){i.ns=o;"foreignObject"===i.tag&&(o=void 0,a=!0);if(n(i.children))for(var s=0,c=i.children.length;s<c;s++){var u=i.children[s];n(u.tag)&&(t(u.ns)||r(a)&&"svg"!==u.tag)&&e(u,o,a)}}(u,l),n(a)&&function(e){o(e.style)&&et(e.style);o(e.class)&&et(e.class)}(a),u):ve()}(e,a,s,c,u)}var Rt,Ht=null;function Bt(e,t){return(e.__esModule||oe&&"Module"===e[Symbol.toStringTag])&&(e=e.default),o(e)?t.extend(e):e}function Ut(e){return e.isComment&&e.asyncFactory}function zt(e){if(Array.isArray(e))for(var t=0;t<e.length;t++){var r=e[t];if(n(r)&&(n(r.componentOptions)||Ut(r)))return r}}function Vt(e,t){Rt.$on(e,t)}function Kt(e,t){Rt.$off(e,t)}function Jt(e,t){var n=Rt;return function r(){null!==t.apply(null,arguments)&&n.$off(e,r)}}function qt(e,t,n){Rt=e,rt(t,n||{},Vt,Kt,Jt,e),Rt=void 0}var Wt=null;function Zt(e){var t=Wt;return Wt=e,function(){Wt=t}}function Gt(e){for(;e&&(e=e.$parent);)if(e._inactive)return!0;return!1}function Xt(e,t){if(t){if(e._directInactive=!1,Gt(e))return}else if(e._directInactive)return;if(e._inactive||null===e._inactive){e._inactive=!1;for(var n=0;n<e.$children.length;n++)Xt(e.$children[n]);Yt(e,"activated")}}function Yt(e,t){le();var n=e.$options[t],r=t+" hook";if(n)for(var i=0,o=n.length;i<o;i++)He(n[i],e,null,e,r);e._hasHookEvent&&e.$emit("hook:"+t),fe()}var Qt=[],en=[],tn={},nn=!1,rn=!1,on=0;var an=0,sn=Date.now;if(z&&!q){var cn=window.performance;cn&&"function"==typeof cn.now&&sn()>document.createEvent("Event").timeStamp&&(sn=function(){return cn.now()})}function un(){var e,t;for(an=sn(),rn=!0,Qt.sort(function(e,t){return e.id-t.id}),on=0;on<Qt.length;on++)(e=Qt[on]).before&&e.before(),t=e.id,tn[t]=null,e.run();var n=en.slice(),r=Qt.slice();on=Qt.length=en.length=0,tn={},nn=rn=!1,function(e){for(var t=0;t<e.length;t++)e[t]._inactive=!0,Xt(e[t],!0)}(n),function(e){var t=e.length;for(;t--;){var n=e[t],r=n.vm;r._watcher===n&&r._isMounted&&!r._isDestroyed&&Yt(r,"updated")}}(r),ne&&F.devtools&&ne.emit("flush")}var ln=0,fn=function(e,t,n,r,i){this.vm=e,i&&(e._watcher=this),e._watchers.push(this),r?(this.deep=!!r.deep,this.user=!!r.user,this.lazy=!!r.lazy,this.sync=!!r.sync,this.before=r.before):this.deep=this.user=this.lazy=this.sync=!1,this.cb=n,this.id=++ln,this.active=!0,this.dirty=this.lazy,this.deps=[],this.newDeps=[],this.depIds=new ie,this.newDepIds=new ie,this.expression="","function"==typeof t?this.getter=t:(this.getter=function(e){if(!H.test(e)){var t=e.split(".");return function(e){for(var n=0;n<t.length;n++){if(!e)return;e=e[t[n]]}return e}}}(t),this.getter||(this.getter=S)),this.value=this.lazy?void 0:this.get()};fn.prototype.get=function(){var e;le(this);var t=this.vm;try{e=this.getter.call(t,t)}catch(e){if(!this.user)throw e;Re(e,t,'getter for watcher "'+this.expression+'"')}finally{this.deep&&et(e),fe(),this.cleanupDeps()}return e},fn.prototype.addDep=function(e){var t=e.id;this.newDepIds.has(t)||(this.newDepIds.add(t),this.newDeps.push(e),this.depIds.has(t)||e.addSub(this))},fn.prototype.cleanupDeps=function(){for(var e=this.deps.length;e--;){var t=this.deps[e];this.newDepIds.has(t.id)||t.removeSub(this)}var n=this.depIds;this.depIds=this.newDepIds,this.newDepIds=n,this.newDepIds.clear(),n=this.deps,this.deps=this.newDeps,this.newDeps=n,this.newDeps.length=0},fn.prototype.update=function(){this.lazy?this.dirty=!0:this.sync?this.run():function(e){var t=e.id;if(null==tn[t]){if(tn[t]=!0,rn){for(var n=Qt.length-1;n>on&&Qt[n].id>e.id;)n--;Qt.splice(n+1,0,e)}else Qt.push(e);nn||(nn=!0,Ye(un))}}(this)},fn.prototype.run=function(){if(this.active){var e=this.get();if(e!==this.value||o(e)||this.deep){var t=this.value;if(this.value=e,this.user)try{this.cb.call(this.vm,e,t)}catch(e){Re(e,this.vm,'callback for watcher "'+this.expression+'"')}else this.cb.call(this.vm,e,t)}}},fn.prototype.evaluate=function(){this.value=this.get(),this.dirty=!1},fn.prototype.depend=function(){for(var e=this.deps.length;e--;)this.deps[e].depend()},fn.prototype.teardown=function(){if(this.active){this.vm._isBeingDestroyed||h(this.vm._watchers,this);for(var e=this.deps.length;e--;)this.deps[e].removeSub(this);this.active=!1}};var pn={enumerable:!0,configurable:!0,get:S,set:S};function dn(e,t,n){pn.get=function(){return this[t][n]},pn.set=function(e){this[t][n]=e},Object.defineProperty(e,n,pn)}function vn(e){e._watchers=[];var t=e.$options;t.props&&function(e,t){var n=e.$options.propsData||{},r=e._props={},i=e.$options._propKeys=[];e.$parent&&$e(!1);var o=function(o){i.push(o);var a=Me(o,t,n,e);xe(r,o,a),o in e||dn(e,"_props",o)};for(var a in t)o(a);$e(!0)}(e,t.props),t.methods&&function(e,t){e.$options.props;for(var n in t)e[n]="function"!=typeof t[n]?S:x(t[n],e)}(e,t.methods),t.data?function(e){var t=e.$options.data;s(t=e._data="function"==typeof t?function(e,t){le();try{return e.call(t,t)}catch(e){return Re(e,t,"data()"),{}}finally{fe()}}(t,e):t||{})||(t={});var n=Object.keys(t),r=e.$options.props,i=(e.$options.methods,n.length);for(;i--;){var o=n[i];r&&y(r,o)||(a=void 0,36!==(a=(o+"").charCodeAt(0))&&95!==a&&dn(e,"_data",o))}var a;Ce(t,!0)}(e):Ce(e._data={},!0),t.computed&&function(e,t){var n=e._computedWatchers=Object.create(null),r=te();for(var i in t){var o=t[i],a="function"==typeof o?o:o.get;r||(n[i]=new fn(e,a||S,S,hn)),i in e||mn(e,i,o)}}(e,t.computed),t.watch&&t.watch!==Y&&function(e,t){for(var n in t){var r=t[n];if(Array.isArray(r))for(var i=0;i<r.length;i++)_n(e,n,r[i]);else _n(e,n,r)}}(e,t.watch)}var hn={lazy:!0};function mn(e,t,n){var r=!te();"function"==typeof n?(pn.get=r?yn(t):gn(n),pn.set=S):(pn.get=n.get?r&&!1!==n.cache?yn(t):gn(n.get):S,pn.set=n.set||S),Object.defineProperty(e,t,pn)}function yn(e){return function(){var t=this._computedWatchers&&this._computedWatchers[e];if(t)return t.dirty&&t.evaluate(),ce.target&&t.depend(),t.value}}function gn(e){return function(){return e.call(this,this)}}function _n(e,t,n,r){return s(n)&&(r=n,n=n.handler),"string"==typeof n&&(n=e[n]),e.$watch(t,n,r)}var bn=0;function $n(e){var t=e.options;if(e.super){var n=$n(e.super);if(n!==e.superOptions){e.superOptions=n;var r=function(e){var t,n=e.options,r=e.sealedOptions;for(var i in n)n[i]!==r[i]&&(t||(t={}),t[i]=n[i]);return t}(e);r&&A(e.extendOptions,r),(t=e.options=De(n,e.extendOptions)).name&&(t.components[t.name]=e)}}return t}function wn(e){this._init(e)}function Cn(e){e.cid=0;var t=1;e.extend=function(e){e=e||{};var n=this,r=n.cid,i=e._Ctor||(e._Ctor={});if(i[r])return i[r];var o=e.name||n.options.name,a=function(e){this._init(e)};return(a.prototype=Object.create(n.prototype)).constructor=a,a.cid=t++,a.options=De(n.options,e),a.super=n,a.options.props&&function(e){var t=e.options.props;for(var n in t)dn(e.prototype,"_props",n)}(a),a.options.computed&&function(e){var t=e.options.computed;for(var n in t)mn(e.prototype,n,t[n])}(a),a.extend=n.extend,a.mixin=n.mixin,a.use=n.use,M.forEach(function(e){a[e]=n[e]}),o&&(a.options.components[o]=a),a.superOptions=n.options,a.extendOptions=e,a.sealedOptions=A({},a.options),i[r]=a,a}}function xn(e){return e&&(e.Ctor.options.name||e.tag)}function kn(e,t){return Array.isArray(e)?e.indexOf(t)>-1:"string"==typeof e?e.split(",").indexOf(t)>-1:(n=e,"[object RegExp]"===a.call(n)&&e.test(t));var n}function An(e,t){var n=e.cache,r=e.keys,i=e._vnode;for(var o in n){var a=n[o];if(a){var s=xn(a.componentOptions);s&&!t(s)&&On(n,o,r,i)}}}function On(e,t,n,r){var i=e[t];!i||r&&i.tag===r.tag||i.componentInstance.$destroy(),e[t]=null,h(n,t)}!function(t){t.prototype._init=function(t){var n=this;n._uid=bn++,n._isVue=!0,t&&t._isComponent?function(e,t){var n=e.$options=Object.create(e.constructor.options),r=t._parentVnode;n.parent=t.parent,n._parentVnode=r;var i=r.componentOptions;n.propsData=i.propsData,n._parentListeners=i.listeners,n._renderChildren=i.children,n._componentTag=i.tag,t.render&&(n.render=t.render,n.staticRenderFns=t.staticRenderFns)}(n,t):n.$options=De($n(n.constructor),t||{},n),n._renderProxy=n,n._self=n,function(e){var t=e.$options,n=t.parent;if(n&&!t.abstract){for(;n.$options.abstract&&n.$parent;)n=n.$parent;n.$children.push(e)}e.$parent=n,e.$root=n?n.$root:e,e.$children=[],e.$refs={},e._watcher=null,e._inactive=null,e._directInactive=!1,e._isMounted=!1,e._isDestroyed=!1,e._isBeingDestroyed=!1}(n),function(e){e._events=Object.create(null),e._hasHookEvent=!1;var t=e.$options._parentListeners;t&&qt(e,t)}(n),function(t){t._vnode=null,t._staticTrees=null;var n=t.$options,r=t.$vnode=n._parentVnode,i=r&&r.context;t.$slots=ut(n._renderChildren,i),t.$scopedSlots=e,t._c=function(e,n,r,i){return Pt(t,e,n,r,i,!1)},t.$createElement=function(e,n,r,i){return Pt(t,e,n,r,i,!0)};var o=r&&r.data;xe(t,"$attrs",o&&o.attrs||e,null,!0),xe(t,"$listeners",n._parentListeners||e,null,!0)}(n),Yt(n,"beforeCreate"),function(e){var t=ct(e.$options.inject,e);t&&($e(!1),Object.keys(t).forEach(function(n){xe(e,n,t[n])}),$e(!0))}(n),vn(n),function(e){var t=e.$options.provide;t&&(e._provided="function"==typeof t?t.call(e):t)}(n),Yt(n,"created"),n.$options.el&&n.$mount(n.$options.el)}}(wn),function(e){var t={get:function(){return this._data}},n={get:function(){return this._props}};Object.defineProperty(e.prototype,"$data",t),Object.defineProperty(e.prototype,"$props",n),e.prototype.$set=ke,e.prototype.$delete=Ae,e.prototype.$watch=function(e,t,n){if(s(t))return _n(this,e,t,n);(n=n||{}).user=!0;var r=new fn(this,e,t,n);if(n.immediate)try{t.call(this,r.value)}catch(e){Re(e,this,'callback for immediate watcher "'+r.expression+'"')}return function(){r.teardown()}}}(wn),function(e){var t=/^hook:/;e.prototype.$on=function(e,n){var r=this;if(Array.isArray(e))for(var i=0,o=e.length;i<o;i++)r.$on(e[i],n);else(r._events[e]||(r._events[e]=[])).push(n),t.test(e)&&(r._hasHookEvent=!0);return r},e.prototype.$once=function(e,t){var n=this;function r(){n.$off(e,r),t.apply(n,arguments)}return r.fn=t,n.$on(e,r),n},e.prototype.$off=function(e,t){var n=this;if(!arguments.length)return n._events=Object.create(null),n;if(Array.isArray(e)){for(var r=0,i=e.length;r<i;r++)n.$off(e[r],t);return n}var o,a=n._events[e];if(!a)return n;if(!t)return n._events[e]=null,n;for(var s=a.length;s--;)if((o=a[s])===t||o.fn===t){a.splice(s,1);break}return n},e.prototype.$emit=function(e){var t=this._events[e];if(t){t=t.length>1?k(t):t;for(var n=k(arguments,1),r='event handler for "'+e+'"',i=0,o=t.length;i<o;i++)He(t[i],this,n,this,r)}return this}}(wn),function(e){e.prototype._update=function(e,t){var n=this,r=n.$el,i=n._vnode,o=Zt(n);n._vnode=e,n.$el=i?n.__patch__(i,e):n.__patch__(n.$el,e,t,!1),o(),r&&(r.__vue__=null),n.$el&&(n.$el.__vue__=n),n.$vnode&&n.$parent&&n.$vnode===n.$parent._vnode&&(n.$parent.$el=n.$el)},e.prototype.$forceUpdate=function(){this._watcher&&this._watcher.update()},e.prototype.$destroy=function(){var e=this;if(!e._isBeingDestroyed){Yt(e,"beforeDestroy"),e._isBeingDestroyed=!0;var t=e.$parent;!t||t._isBeingDestroyed||e.$options.abstract||h(t.$children,e),e._watcher&&e._watcher.teardown();for(var n=e._watchers.length;n--;)e._watchers[n].teardown();e._data.__ob__&&e._data.__ob__.vmCount--,e._isDestroyed=!0,e.__patch__(e._vnode,null),Yt(e,"destroyed"),e.$off(),e.$el&&(e.$el.__vue__=null),e.$vnode&&(e.$vnode.parent=null)}}}(wn),function(e){St(e.prototype),e.prototype.$nextTick=function(e){return Ye(e,this)},e.prototype._render=function(){var e,t=this,n=t.$options,r=n.render,i=n._parentVnode;i&&(t.$scopedSlots=ft(i.data.scopedSlots,t.$slots,t.$scopedSlots)),t.$vnode=i;try{Ht=t,e=r.call(t._renderProxy,t.$createElement)}catch(n){Re(n,t,"render"),e=t._vnode}finally{Ht=null}return Array.isArray(e)&&1===e.length&&(e=e[0]),e instanceof pe||(e=ve()),e.parent=i,e}}(wn);var Sn=[String,RegExp,Array],Tn={KeepAlive:{name:"keep-alive",abstract:!0,props:{include:Sn,exclude:Sn,max:[String,Number]},created:function(){this.cache=Object.create(null),this.keys=[]},destroyed:function(){for(var e in this.cache)On(this.cache,e,this.keys)},mounted:function(){var e=this;this.$watch("include",function(t){An(e,function(e){return kn(t,e)})}),this.$watch("exclude",function(t){An(e,function(e){return!kn(t,e)})})},render:function(){var e=this.$slots.default,t=zt(e),n=t&&t.componentOptions;if(n){var r=xn(n),i=this.include,o=this.exclude;if(i&&(!r||!kn(i,r))||o&&r&&kn(o,r))return t;var a=this.cache,s=this.keys,c=null==t.key?n.Ctor.cid+(n.tag?"::"+n.tag:""):t.key;a[c]?(t.componentInstance=a[c].componentInstance,h(s,c),s.push(c)):(a[c]=t,s.push(c),this.max&&s.length>parseInt(this.max)&&On(a,s[0],s,this._vnode)),t.data.keepAlive=!0}return t||e&&e[0]}}};!function(e){var t={get:function(){return F}};Object.defineProperty(e,"config",t),e.util={warn:ae,extend:A,mergeOptions:De,defineReactive:xe},e.set=ke,e.delete=Ae,e.nextTick=Ye,e.observable=function(e){return Ce(e),e},e.options=Object.create(null),M.forEach(function(t){e.options[t+"s"]=Object.create(null)}),e.options._base=e,A(e.options.components,Tn),function(e){e.use=function(e){var t=this._installedPlugins||(this._installedPlugins=[]);if(t.indexOf(e)>-1)return this;var n=k(arguments,1);return n.unshift(this),"function"==typeof e.install?e.install.apply(e,n):"function"==typeof e&&e.apply(null,n),t.push(e),this}}(e),function(e){e.mixin=function(e){return this.options=De(this.options,e),this}}(e),Cn(e),function(e){M.forEach(function(t){e[t]=function(e,n){return n?("component"===t&&s(n)&&(n.name=n.name||e,n=this.options._base.extend(n)),"directive"===t&&"function"==typeof n&&(n={bind:n,update:n}),this.options[t+"s"][e]=n,n):this.options[t+"s"][e]}})}(e)}(wn),Object.defineProperty(wn.prototype,"$isServer",{get:te}),Object.defineProperty(wn.prototype,"$ssrContext",{get:function(){return this.$vnode&&this.$vnode.ssrContext}}),Object.defineProperty(wn,"FunctionalRenderContext",{value:Tt}),wn.version="2.6.10";var En=p("style,class"),Nn=p("input,textarea,option,select,progress"),jn=function(e,t,n){return"value"===n&&Nn(e)&&"button"!==t||"selected"===n&&"option"===e||"checked"===n&&"input"===e||"muted"===n&&"video"===e},Dn=p("contenteditable,draggable,spellcheck"),Ln=p("events,caret,typing,plaintext-only"),Mn=function(e,t){return Hn(t)||"false"===t?"false":"contenteditable"===e&&Ln(t)?t:"true"},In=p("allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,default,defaultchecked,defaultmuted,defaultselected,defer,disabled,enabled,formnovalidate,hidden,indeterminate,inert,ismap,itemscope,loop,multiple,muted,nohref,noresize,noshade,novalidate,nowrap,open,pauseonexit,readonly,required,reversed,scoped,seamless,selected,sortable,translate,truespeed,typemustmatch,visible"),Fn="http://www.w3.org/1999/xlink",Pn=function(e){return":"===e.charAt(5)&&"xlink"===e.slice(0,5)},Rn=function(e){return Pn(e)?e.slice(6,e.length):""},Hn=function(e){return null==e||!1===e};function Bn(e){for(var t=e.data,r=e,i=e;n(i.componentInstance);)(i=i.componentInstance._vnode)&&i.data&&(t=Un(i.data,t));for(;n(r=r.parent);)r&&r.data&&(t=Un(t,r.data));return function(e,t){if(n(e)||n(t))return zn(e,Vn(t));return""}(t.staticClass,t.class)}function Un(e,t){return{staticClass:zn(e.staticClass,t.staticClass),class:n(e.class)?[e.class,t.class]:t.class}}function zn(e,t){return e?t?e+" "+t:e:t||""}function Vn(e){return Array.isArray(e)?function(e){for(var t,r="",i=0,o=e.length;i<o;i++)n(t=Vn(e[i]))&&""!==t&&(r&&(r+=" "),r+=t);return r}(e):o(e)?function(e){var t="";for(var n in e)e[n]&&(t&&(t+=" "),t+=n);return t}(e):"string"==typeof e?e:""}var Kn={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},Jn=p("html,body,base,head,link,meta,style,title,address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,menuitem,summary,content,element,shadow,template,blockquote,iframe,tfoot"),qn=p("svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view",!0),Wn=function(e){return Jn(e)||qn(e)};function Zn(e){return qn(e)?"svg":"math"===e?"math":void 0}var Gn=Object.create(null);var Xn=p("text,number,password,search,email,tel,url");function Yn(e){if("string"==typeof e){var t=document.querySelector(e);return t||document.createElement("div")}return e}var Qn=Object.freeze({createElement:function(e,t){var n=document.createElement(e);return"select"!==e?n:(t.data&&t.data.attrs&&void 0!==t.data.attrs.multiple&&n.setAttribute("multiple","multiple"),n)},createElementNS:function(e,t){return document.createElementNS(Kn[e],t)},createTextNode:function(e){return document.createTextNode(e)},createComment:function(e){return document.createComment(e)},insertBefore:function(e,t,n){e.insertBefore(t,n)},removeChild:function(e,t){e.removeChild(t)},appendChild:function(e,t){e.appendChild(t)},parentNode:function(e){return e.parentNode},nextSibling:function(e){return e.nextSibling},tagName:function(e){return e.tagName},setTextContent:function(e,t){e.textContent=t},setStyleScope:function(e,t){e.setAttribute(t,"")}}),er={create:function(e,t){tr(t)},update:function(e,t){e.data.ref!==t.data.ref&&(tr(e,!0),tr(t))},destroy:function(e){tr(e,!0)}};function tr(e,t){var r=e.data.ref;if(n(r)){var i=e.context,o=e.componentInstance||e.elm,a=i.$refs;t?Array.isArray(a[r])?h(a[r],o):a[r]===o&&(a[r]=void 0):e.data.refInFor?Array.isArray(a[r])?a[r].indexOf(o)<0&&a[r].push(o):a[r]=[o]:a[r]=o}}var nr=new pe("",{},[]),rr=["create","activate","update","remove","destroy"];function ir(e,i){return e.key===i.key&&(e.tag===i.tag&&e.isComment===i.isComment&&n(e.data)===n(i.data)&&function(e,t){if("input"!==e.tag)return!0;var r,i=n(r=e.data)&&n(r=r.attrs)&&r.type,o=n(r=t.data)&&n(r=r.attrs)&&r.type;return i===o||Xn(i)&&Xn(o)}(e,i)||r(e.isAsyncPlaceholder)&&e.asyncFactory===i.asyncFactory&&t(i.asyncFactory.error))}function or(e,t,r){var i,o,a={};for(i=t;i<=r;++i)n(o=e[i].key)&&(a[o]=i);return a}var ar={create:sr,update:sr,destroy:function(e){sr(e,nr)}};function sr(e,t){(e.data.directives||t.data.directives)&&function(e,t){var n,r,i,o=e===nr,a=t===nr,s=ur(e.data.directives,e.context),c=ur(t.data.directives,t.context),u=[],l=[];for(n in c)r=s[n],i=c[n],r?(i.oldValue=r.value,i.oldArg=r.arg,fr(i,"update",t,e),i.def&&i.def.componentUpdated&&l.push(i)):(fr(i,"bind",t,e),i.def&&i.def.inserted&&u.push(i));if(u.length){var f=function(){for(var n=0;n<u.length;n++)fr(u[n],"inserted",t,e)};o?it(t,"insert",f):f()}l.length&&it(t,"postpatch",function(){for(var n=0;n<l.length;n++)fr(l[n],"componentUpdated",t,e)});if(!o)for(n in s)c[n]||fr(s[n],"unbind",e,e,a)}(e,t)}var cr=Object.create(null);function ur(e,t){var n,r,i=Object.create(null);if(!e)return i;for(n=0;n<e.length;n++)(r=e[n]).modifiers||(r.modifiers=cr),i[lr(r)]=r,r.def=Le(t.$options,"directives",r.name);return i}function lr(e){return e.rawName||e.name+"."+Object.keys(e.modifiers||{}).join(".")}function fr(e,t,n,r,i){var o=e.def&&e.def[t];if(o)try{o(n.elm,e,n,r,i)}catch(r){Re(r,n.context,"directive "+e.name+" "+t+" hook")}}var pr=[er,ar];function dr(e,r){var i=r.componentOptions;if(!(n(i)&&!1===i.Ctor.options.inheritAttrs||t(e.data.attrs)&&t(r.data.attrs))){var o,a,s=r.elm,c=e.data.attrs||{},u=r.data.attrs||{};for(o in n(u.__ob__)&&(u=r.data.attrs=A({},u)),u)a=u[o],c[o]!==a&&vr(s,o,a);for(o in(q||Z)&&u.value!==c.value&&vr(s,"value",u.value),c)t(u[o])&&(Pn(o)?s.removeAttributeNS(Fn,Rn(o)):Dn(o)||s.removeAttribute(o))}}function vr(e,t,n){e.tagName.indexOf("-")>-1?hr(e,t,n):In(t)?Hn(n)?e.removeAttribute(t):(n="allowfullscreen"===t&&"EMBED"===e.tagName?"true":t,e.setAttribute(t,n)):Dn(t)?e.setAttribute(t,Mn(t,n)):Pn(t)?Hn(n)?e.removeAttributeNS(Fn,Rn(t)):e.setAttributeNS(Fn,t,n):hr(e,t,n)}function hr(e,t,n){if(Hn(n))e.removeAttribute(t);else{if(q&&!W&&"TEXTAREA"===e.tagName&&"placeholder"===t&&""!==n&&!e.__ieph){var r=function(t){t.stopImmediatePropagation(),e.removeEventListener("input",r)};e.addEventListener("input",r),e.__ieph=!0}e.setAttribute(t,n)}}var mr={create:dr,update:dr};function yr(e,r){var i=r.elm,o=r.data,a=e.data;if(!(t(o.staticClass)&&t(o.class)&&(t(a)||t(a.staticClass)&&t(a.class)))){var s=Bn(r),c=i._transitionClasses;n(c)&&(s=zn(s,Vn(c))),s!==i._prevClass&&(i.setAttribute("class",s),i._prevClass=s)}}var gr,_r,br,$r,wr,Cr,xr={create:yr,update:yr},kr=/[\w).+\-_$\]]/;function Ar(e){var t,n,r,i,o,a=!1,s=!1,c=!1,u=!1,l=0,f=0,p=0,d=0;for(r=0;r<e.length;r++)if(n=t,t=e.charCodeAt(r),a)39===t&&92!==n&&(a=!1);else if(s)34===t&&92!==n&&(s=!1);else if(c)96===t&&92!==n&&(c=!1);else if(u)47===t&&92!==n&&(u=!1);else if(124!==t||124===e.charCodeAt(r+1)||124===e.charCodeAt(r-1)||l||f||p){switch(t){case 34:s=!0;break;case 39:a=!0;break;case 96:c=!0;break;case 40:p++;break;case 41:p--;break;case 91:f++;break;case 93:f--;break;case 123:l++;break;case 125:l--}if(47===t){for(var v=r-1,h=void 0;v>=0&&" "===(h=e.charAt(v));v--);h&&kr.test(h)||(u=!0)}}else void 0===i?(d=r+1,i=e.slice(0,r).trim()):m();function m(){(o||(o=[])).push(e.slice(d,r).trim()),d=r+1}if(void 0===i?i=e.slice(0,r).trim():0!==d&&m(),o)for(r=0;r<o.length;r++)i=Or(i,o[r]);return i}function Or(e,t){var n=t.indexOf("(");if(n<0)return'_f("'+t+'")('+e+")";var r=t.slice(0,n),i=t.slice(n+1);return'_f("'+r+'")('+e+(")"!==i?","+i:i)}function Sr(e,t){console.error("[Vue compiler]: "+e)}function Tr(e,t){return e?e.map(function(e){return e[t]}).filter(function(e){return e}):[]}function Er(e,t,n,r,i){(e.props||(e.props=[])).push(Rr({name:t,value:n,dynamic:i},r)),e.plain=!1}function Nr(e,t,n,r,i){(i?e.dynamicAttrs||(e.dynamicAttrs=[]):e.attrs||(e.attrs=[])).push(Rr({name:t,value:n,dynamic:i},r)),e.plain=!1}function jr(e,t,n,r){e.attrsMap[t]=n,e.attrsList.push(Rr({name:t,value:n},r))}function Dr(e,t,n,r,i,o,a,s){(e.directives||(e.directives=[])).push(Rr({name:t,rawName:n,value:r,arg:i,isDynamicArg:o,modifiers:a},s)),e.plain=!1}function Lr(e,t,n){return n?"_p("+t+',"'+e+'")':e+t}function Mr(t,n,r,i,o,a,s,c){var u;(i=i||e).right?c?n="("+n+")==='click'?'contextmenu':("+n+")":"click"===n&&(n="contextmenu",delete i.right):i.middle&&(c?n="("+n+")==='click'?'mouseup':("+n+")":"click"===n&&(n="mouseup")),i.capture&&(delete i.capture,n=Lr("!",n,c)),i.once&&(delete i.once,n=Lr("~",n,c)),i.passive&&(delete i.passive,n=Lr("&",n,c)),i.native?(delete i.native,u=t.nativeEvents||(t.nativeEvents={})):u=t.events||(t.events={});var l=Rr({value:r.trim(),dynamic:c},s);i!==e&&(l.modifiers=i);var f=u[n];Array.isArray(f)?o?f.unshift(l):f.push(l):u[n]=f?o?[l,f]:[f,l]:l,t.plain=!1}function Ir(e,t,n){var r=Fr(e,":"+t)||Fr(e,"v-bind:"+t);if(null!=r)return Ar(r);if(!1!==n){var i=Fr(e,t);if(null!=i)return JSON.stringify(i)}}function Fr(e,t,n){var r;if(null!=(r=e.attrsMap[t]))for(var i=e.attrsList,o=0,a=i.length;o<a;o++)if(i[o].name===t){i.splice(o,1);break}return n&&delete e.attrsMap[t],r}function Pr(e,t){for(var n=e.attrsList,r=0,i=n.length;r<i;r++){var o=n[r];if(t.test(o.name))return n.splice(r,1),o}}function Rr(e,t){return t&&(null!=t.start&&(e.start=t.start),null!=t.end&&(e.end=t.end)),e}function Hr(e,t,n){var r=n||{},i=r.number,o="$$v";r.trim&&(o="(typeof $$v === 'string'? $$v.trim(): $$v)"),i&&(o="_n("+o+")");var a=Br(t,o);e.model={value:"("+t+")",expression:JSON.stringify(t),callback:"function ($$v) {"+a+"}"}}function Br(e,t){var n=function(e){if(e=e.trim(),gr=e.length,e.indexOf("[")<0||e.lastIndexOf("]")<gr-1)return($r=e.lastIndexOf("."))>-1?{exp:e.slice(0,$r),key:'"'+e.slice($r+1)+'"'}:{exp:e,key:null};_r=e,$r=wr=Cr=0;for(;!zr();)Vr(br=Ur())?Jr(br):91===br&&Kr(br);return{exp:e.slice(0,wr),key:e.slice(wr+1,Cr)}}(e);return null===n.key?e+"="+t:"$set("+n.exp+", "+n.key+", "+t+")"}function Ur(){return _r.charCodeAt(++$r)}function zr(){return $r>=gr}function Vr(e){return 34===e||39===e}function Kr(e){var t=1;for(wr=$r;!zr();)if(Vr(e=Ur()))Jr(e);else if(91===e&&t++,93===e&&t--,0===t){Cr=$r;break}}function Jr(e){for(var t=e;!zr()&&(e=Ur())!==t;);}var qr,Wr="__r",Zr="__c";function Gr(e,t,n){var r=qr;return function i(){null!==t.apply(null,arguments)&&Qr(e,i,n,r)}}var Xr=Ve&&!(X&&Number(X[1])<=53);function Yr(e,t,n,r){if(Xr){var i=an,o=t;t=o._wrapper=function(e){if(e.target===e.currentTarget||e.timeStamp>=i||e.timeStamp<=0||e.target.ownerDocument!==document)return o.apply(this,arguments)}}qr.addEventListener(e,t,Q?{capture:n,passive:r}:n)}function Qr(e,t,n,r){(r||qr).removeEventListener(e,t._wrapper||t,n)}function ei(e,r){if(!t(e.data.on)||!t(r.data.on)){var i=r.data.on||{},o=e.data.on||{};qr=r.elm,function(e){if(n(e[Wr])){var t=q?"change":"input";e[t]=[].concat(e[Wr],e[t]||[]),delete e[Wr]}n(e[Zr])&&(e.change=[].concat(e[Zr],e.change||[]),delete e[Zr])}(i),rt(i,o,Yr,Qr,Gr,r.context),qr=void 0}}var ti,ni={create:ei,update:ei};function ri(e,r){if(!t(e.data.domProps)||!t(r.data.domProps)){var i,o,a=r.elm,s=e.data.domProps||{},c=r.data.domProps||{};for(i in n(c.__ob__)&&(c=r.data.domProps=A({},c)),s)i in c||(a[i]="");for(i in c){if(o=c[i],"textContent"===i||"innerHTML"===i){if(r.children&&(r.children.length=0),o===s[i])continue;1===a.childNodes.length&&a.removeChild(a.childNodes[0])}if("value"===i&&"PROGRESS"!==a.tagName){a._value=o;var u=t(o)?"":String(o);ii(a,u)&&(a.value=u)}else if("innerHTML"===i&&qn(a.tagName)&&t(a.innerHTML)){(ti=ti||document.createElement("div")).innerHTML="<svg>"+o+"</svg>";for(var l=ti.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;l.firstChild;)a.appendChild(l.firstChild)}else if(o!==s[i])try{a[i]=o}catch(e){}}}}function ii(e,t){return!e.composing&&("OPTION"===e.tagName||function(e,t){var n=!0;try{n=document.activeElement!==e}catch(e){}return n&&e.value!==t}(e,t)||function(e,t){var r=e.value,i=e._vModifiers;if(n(i)){if(i.number)return f(r)!==f(t);if(i.trim)return r.trim()!==t.trim()}return r!==t}(e,t))}var oi={create:ri,update:ri},ai=g(function(e){var t={},n=/:(.+)/;return e.split(/;(?![^(]*\))/g).forEach(function(e){if(e){var r=e.split(n);r.length>1&&(t[r[0].trim()]=r[1].trim())}}),t});function si(e){var t=ci(e.style);return e.staticStyle?A(e.staticStyle,t):t}function ci(e){return Array.isArray(e)?O(e):"string"==typeof e?ai(e):e}var ui,li=/^--/,fi=/\s*!important$/,pi=function(e,t,n){if(li.test(t))e.style.setProperty(t,n);else if(fi.test(n))e.style.setProperty(C(t),n.replace(fi,""),"important");else{var r=vi(t);if(Array.isArray(n))for(var i=0,o=n.length;i<o;i++)e.style[r]=n[i];else e.style[r]=n}},di=["Webkit","Moz","ms"],vi=g(function(e){if(ui=ui||document.createElement("div").style,"filter"!==(e=b(e))&&e in ui)return e;for(var t=e.charAt(0).toUpperCase()+e.slice(1),n=0;n<di.length;n++){var r=di[n]+t;if(r in ui)return r}});function hi(e,r){var i=r.data,o=e.data;if(!(t(i.staticStyle)&&t(i.style)&&t(o.staticStyle)&&t(o.style))){var a,s,c=r.elm,u=o.staticStyle,l=o.normalizedStyle||o.style||{},f=u||l,p=ci(r.data.style)||{};r.data.normalizedStyle=n(p.__ob__)?A({},p):p;var d=function(e,t){var n,r={};if(t)for(var i=e;i.componentInstance;)(i=i.componentInstance._vnode)&&i.data&&(n=si(i.data))&&A(r,n);(n=si(e.data))&&A(r,n);for(var o=e;o=o.parent;)o.data&&(n=si(o.data))&&A(r,n);return r}(r,!0);for(s in f)t(d[s])&&pi(c,s,"");for(s in d)(a=d[s])!==f[s]&&pi(c,s,null==a?"":a)}}var mi={create:hi,update:hi},yi=/\s+/;function gi(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(yi).forEach(function(t){return e.classList.add(t)}):e.classList.add(t);else{var n=" "+(e.getAttribute("class")||"")+" ";n.indexOf(" "+t+" ")<0&&e.setAttribute("class",(n+t).trim())}}function _i(e,t){if(t&&(t=t.trim()))if(e.classList)t.indexOf(" ")>-1?t.split(yi).forEach(function(t){return e.classList.remove(t)}):e.classList.remove(t),e.classList.length||e.removeAttribute("class");else{for(var n=" "+(e.getAttribute("class")||"")+" ",r=" "+t+" ";n.indexOf(r)>=0;)n=n.replace(r," ");(n=n.trim())?e.setAttribute("class",n):e.removeAttribute("class")}}function bi(e){if(e){if("object"==typeof e){var t={};return!1!==e.css&&A(t,$i(e.name||"v")),A(t,e),t}return"string"==typeof e?$i(e):void 0}}var $i=g(function(e){return{enterClass:e+"-enter",enterToClass:e+"-enter-to",enterActiveClass:e+"-enter-active",leaveClass:e+"-leave",leaveToClass:e+"-leave-to",leaveActiveClass:e+"-leave-active"}}),wi=z&&!W,Ci="transition",xi="animation",ki="transition",Ai="transitionend",Oi="animation",Si="animationend";wi&&(void 0===window.ontransitionend&&void 0!==window.onwebkittransitionend&&(ki="WebkitTransition",Ai="webkitTransitionEnd"),void 0===window.onanimationend&&void 0!==window.onwebkitanimationend&&(Oi="WebkitAnimation",Si="webkitAnimationEnd"));var Ti=z?window.requestAnimationFrame?window.requestAnimationFrame.bind(window):setTimeout:function(e){return e()};function Ei(e){Ti(function(){Ti(e)})}function Ni(e,t){var n=e._transitionClasses||(e._transitionClasses=[]);n.indexOf(t)<0&&(n.push(t),gi(e,t))}function ji(e,t){e._transitionClasses&&h(e._transitionClasses,t),_i(e,t)}function Di(e,t,n){var r=Mi(e,t),i=r.type,o=r.timeout,a=r.propCount;if(!i)return n();var s=i===Ci?Ai:Si,c=0,u=function(){e.removeEventListener(s,l),n()},l=function(t){t.target===e&&++c>=a&&u()};setTimeout(function(){c<a&&u()},o+1),e.addEventListener(s,l)}var Li=/\b(transform|all)(,|$)/;function Mi(e,t){var n,r=window.getComputedStyle(e),i=(r[ki+"Delay"]||"").split(", "),o=(r[ki+"Duration"]||"").split(", "),a=Ii(i,o),s=(r[Oi+"Delay"]||"").split(", "),c=(r[Oi+"Duration"]||"").split(", "),u=Ii(s,c),l=0,f=0;return t===Ci?a>0&&(n=Ci,l=a,f=o.length):t===xi?u>0&&(n=xi,l=u,f=c.length):f=(n=(l=Math.max(a,u))>0?a>u?Ci:xi:null)?n===Ci?o.length:c.length:0,{type:n,timeout:l,propCount:f,hasTransform:n===Ci&&Li.test(r[ki+"Property"])}}function Ii(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max.apply(null,t.map(function(t,n){return Fi(t)+Fi(e[n])}))}function Fi(e){return 1e3*Number(e.slice(0,-1).replace(",","."))}function Pi(e,r){var i=e.elm;n(i._leaveCb)&&(i._leaveCb.cancelled=!0,i._leaveCb());var a=bi(e.data.transition);if(!t(a)&&!n(i._enterCb)&&1===i.nodeType){for(var s=a.css,c=a.type,u=a.enterClass,l=a.enterToClass,p=a.enterActiveClass,d=a.appearClass,v=a.appearToClass,h=a.appearActiveClass,m=a.beforeEnter,y=a.enter,g=a.afterEnter,_=a.enterCancelled,b=a.beforeAppear,$=a.appear,w=a.afterAppear,C=a.appearCancelled,x=a.duration,k=Wt,A=Wt.$vnode;A&&A.parent;)k=A.context,A=A.parent;var O=!k._isMounted||!e.isRootInsert;if(!O||$||""===$){var S=O&&d?d:u,T=O&&h?h:p,E=O&&v?v:l,N=O&&b||m,j=O&&"function"==typeof $?$:y,L=O&&w||g,M=O&&C||_,I=f(o(x)?x.enter:x),F=!1!==s&&!W,P=Bi(j),R=i._enterCb=D(function(){F&&(ji(i,E),ji(i,T)),R.cancelled?(F&&ji(i,S),M&&M(i)):L&&L(i),i._enterCb=null});e.data.show||it(e,"insert",function(){var t=i.parentNode,n=t&&t._pending&&t._pending[e.key];n&&n.tag===e.tag&&n.elm._leaveCb&&n.elm._leaveCb(),j&&j(i,R)}),N&&N(i),F&&(Ni(i,S),Ni(i,T),Ei(function(){ji(i,S),R.cancelled||(Ni(i,E),P||(Hi(I)?setTimeout(R,I):Di(i,c,R)))})),e.data.show&&(r&&r(),j&&j(i,R)),F||P||R()}}}function Ri(e,r){var i=e.elm;n(i._enterCb)&&(i._enterCb.cancelled=!0,i._enterCb());var a=bi(e.data.transition);if(t(a)||1!==i.nodeType)return r();if(!n(i._leaveCb)){var s=a.css,c=a.type,u=a.leaveClass,l=a.leaveToClass,p=a.leaveActiveClass,d=a.beforeLeave,v=a.leave,h=a.afterLeave,m=a.leaveCancelled,y=a.delayLeave,g=a.duration,_=!1!==s&&!W,b=Bi(v),$=f(o(g)?g.leave:g),w=i._leaveCb=D(function(){i.parentNode&&i.parentNode._pending&&(i.parentNode._pending[e.key]=null),_&&(ji(i,l),ji(i,p)),w.cancelled?(_&&ji(i,u),m&&m(i)):(r(),h&&h(i)),i._leaveCb=null});y?y(C):C()}function C(){w.cancelled||(!e.data.show&&i.parentNode&&((i.parentNode._pending||(i.parentNode._pending={}))[e.key]=e),d&&d(i),_&&(Ni(i,u),Ni(i,p),Ei(function(){ji(i,u),w.cancelled||(Ni(i,l),b||(Hi($)?setTimeout(w,$):Di(i,c,w)))})),v&&v(i,w),_||b||w())}}function Hi(e){return"number"==typeof e&&!isNaN(e)}function Bi(e){if(t(e))return!1;var r=e.fns;return n(r)?Bi(Array.isArray(r)?r[0]:r):(e._length||e.length)>1}function Ui(e,t){!0!==t.data.show&&Pi(t)}var zi=function(e){var o,a,s={},c=e.modules,u=e.nodeOps;for(o=0;o<rr.length;++o)for(s[rr[o]]=[],a=0;a<c.length;++a)n(c[a][rr[o]])&&s[rr[o]].push(c[a][rr[o]]);function l(e){var t=u.parentNode(e);n(t)&&u.removeChild(t,e)}function f(e,t,i,o,a,c,l){if(n(e.elm)&&n(c)&&(e=c[l]=me(e)),e.isRootInsert=!a,!function(e,t,i,o){var a=e.data;if(n(a)){var c=n(e.componentInstance)&&a.keepAlive;if(n(a=a.hook)&&n(a=a.init)&&a(e,!1),n(e.componentInstance))return d(e,t),v(i,e.elm,o),r(c)&&function(e,t,r,i){for(var o,a=e;a.componentInstance;)if(a=a.componentInstance._vnode,n(o=a.data)&&n(o=o.transition)){for(o=0;o<s.activate.length;++o)s.activate[o](nr,a);t.push(a);break}v(r,e.elm,i)}(e,t,i,o),!0}}(e,t,i,o)){var f=e.data,p=e.children,m=e.tag;n(m)?(e.elm=e.ns?u.createElementNS(e.ns,m):u.createElement(m,e),g(e),h(e,p,t),n(f)&&y(e,t),v(i,e.elm,o)):r(e.isComment)?(e.elm=u.createComment(e.text),v(i,e.elm,o)):(e.elm=u.createTextNode(e.text),v(i,e.elm,o))}}function d(e,t){n(e.data.pendingInsert)&&(t.push.apply(t,e.data.pendingInsert),e.data.pendingInsert=null),e.elm=e.componentInstance.$el,m(e)?(y(e,t),g(e)):(tr(e),t.push(e))}function v(e,t,r){n(e)&&(n(r)?u.parentNode(r)===e&&u.insertBefore(e,t,r):u.appendChild(e,t))}function h(e,t,n){if(Array.isArray(t))for(var r=0;r<t.length;++r)f(t[r],n,e.elm,null,!0,t,r);else i(e.text)&&u.appendChild(e.elm,u.createTextNode(String(e.text)))}function m(e){for(;e.componentInstance;)e=e.componentInstance._vnode;return n(e.tag)}function y(e,t){for(var r=0;r<s.create.length;++r)s.create[r](nr,e);n(o=e.data.hook)&&(n(o.create)&&o.create(nr,e),n(o.insert)&&t.push(e))}function g(e){var t;if(n(t=e.fnScopeId))u.setStyleScope(e.elm,t);else for(var r=e;r;)n(t=r.context)&&n(t=t.$options._scopeId)&&u.setStyleScope(e.elm,t),r=r.parent;n(t=Wt)&&t!==e.context&&t!==e.fnContext&&n(t=t.$options._scopeId)&&u.setStyleScope(e.elm,t)}function _(e,t,n,r,i,o){for(;r<=i;++r)f(n[r],o,e,t,!1,n,r)}function b(e){var t,r,i=e.data;if(n(i))for(n(t=i.hook)&&n(t=t.destroy)&&t(e),t=0;t<s.destroy.length;++t)s.destroy[t](e);if(n(t=e.children))for(r=0;r<e.children.length;++r)b(e.children[r])}function $(e,t,r,i){for(;r<=i;++r){var o=t[r];n(o)&&(n(o.tag)?(w(o),b(o)):l(o.elm))}}function w(e,t){if(n(t)||n(e.data)){var r,i=s.remove.length+1;for(n(t)?t.listeners+=i:t=function(e,t){function n(){0==--n.listeners&&l(e)}return n.listeners=t,n}(e.elm,i),n(r=e.componentInstance)&&n(r=r._vnode)&&n(r.data)&&w(r,t),r=0;r<s.remove.length;++r)s.remove[r](e,t);n(r=e.data.hook)&&n(r=r.remove)?r(e,t):t()}else l(e.elm)}function C(e,t,r,i){for(var o=r;o<i;o++){var a=t[o];if(n(a)&&ir(e,a))return o}}function x(e,i,o,a,c,l){if(e!==i){n(i.elm)&&n(a)&&(i=a[c]=me(i));var p=i.elm=e.elm;if(r(e.isAsyncPlaceholder))n(i.asyncFactory.resolved)?O(e.elm,i,o):i.isAsyncPlaceholder=!0;else if(r(i.isStatic)&&r(e.isStatic)&&i.key===e.key&&(r(i.isCloned)||r(i.isOnce)))i.componentInstance=e.componentInstance;else{var d,v=i.data;n(v)&&n(d=v.hook)&&n(d=d.prepatch)&&d(e,i);var h=e.children,y=i.children;if(n(v)&&m(i)){for(d=0;d<s.update.length;++d)s.update[d](e,i);n(d=v.hook)&&n(d=d.update)&&d(e,i)}t(i.text)?n(h)&&n(y)?h!==y&&function(e,r,i,o,a){for(var s,c,l,p=0,d=0,v=r.length-1,h=r[0],m=r[v],y=i.length-1,g=i[0],b=i[y],w=!a;p<=v&&d<=y;)t(h)?h=r[++p]:t(m)?m=r[--v]:ir(h,g)?(x(h,g,o,i,d),h=r[++p],g=i[++d]):ir(m,b)?(x(m,b,o,i,y),m=r[--v],b=i[--y]):ir(h,b)?(x(h,b,o,i,y),w&&u.insertBefore(e,h.elm,u.nextSibling(m.elm)),h=r[++p],b=i[--y]):ir(m,g)?(x(m,g,o,i,d),w&&u.insertBefore(e,m.elm,h.elm),m=r[--v],g=i[++d]):(t(s)&&(s=or(r,p,v)),t(c=n(g.key)?s[g.key]:C(g,r,p,v))?f(g,o,e,h.elm,!1,i,d):ir(l=r[c],g)?(x(l,g,o,i,d),r[c]=void 0,w&&u.insertBefore(e,l.elm,h.elm)):f(g,o,e,h.elm,!1,i,d),g=i[++d]);p>v?_(e,t(i[y+1])?null:i[y+1].elm,i,d,y,o):d>y&&$(0,r,p,v)}(p,h,y,o,l):n(y)?(n(e.text)&&u.setTextContent(p,""),_(p,null,y,0,y.length-1,o)):n(h)?$(0,h,0,h.length-1):n(e.text)&&u.setTextContent(p,""):e.text!==i.text&&u.setTextContent(p,i.text),n(v)&&n(d=v.hook)&&n(d=d.postpatch)&&d(e,i)}}}function k(e,t,i){if(r(i)&&n(e.parent))e.parent.data.pendingInsert=t;else for(var o=0;o<t.length;++o)t[o].data.hook.insert(t[o])}var A=p("attrs,class,staticClass,staticStyle,key");function O(e,t,i,o){var a,s=t.tag,c=t.data,u=t.children;if(o=o||c&&c.pre,t.elm=e,r(t.isComment)&&n(t.asyncFactory))return t.isAsyncPlaceholder=!0,!0;if(n(c)&&(n(a=c.hook)&&n(a=a.init)&&a(t,!0),n(a=t.componentInstance)))return d(t,i),!0;if(n(s)){if(n(u))if(e.hasChildNodes())if(n(a=c)&&n(a=a.domProps)&&n(a=a.innerHTML)){if(a!==e.innerHTML)return!1}else{for(var l=!0,f=e.firstChild,p=0;p<u.length;p++){if(!f||!O(f,u[p],i,o)){l=!1;break}f=f.nextSibling}if(!l||f)return!1}else h(t,u,i);if(n(c)){var v=!1;for(var m in c)if(!A(m)){v=!0,y(t,i);break}!v&&c.class&&et(c.class)}}else e.data!==t.text&&(e.data=t.text);return!0}return function(e,i,o,a){if(!t(i)){var c,l=!1,p=[];if(t(e))l=!0,f(i,p);else{var d=n(e.nodeType);if(!d&&ir(e,i))x(e,i,p,null,null,a);else{if(d){if(1===e.nodeType&&e.hasAttribute(L)&&(e.removeAttribute(L),o=!0),r(o)&&O(e,i,p))return k(i,p,!0),e;c=e,e=new pe(u.tagName(c).toLowerCase(),{},[],void 0,c)}var v=e.elm,h=u.parentNode(v);if(f(i,p,v._leaveCb?null:h,u.nextSibling(v)),n(i.parent))for(var y=i.parent,g=m(i);y;){for(var _=0;_<s.destroy.length;++_)s.destroy[_](y);if(y.elm=i.elm,g){for(var w=0;w<s.create.length;++w)s.create[w](nr,y);var C=y.data.hook.insert;if(C.merged)for(var A=1;A<C.fns.length;A++)C.fns[A]()}else tr(y);y=y.parent}n(h)?$(0,[e],0,0):n(e.tag)&&b(e)}}return k(i,p,l),i.elm}n(e)&&b(e)}}({nodeOps:Qn,modules:[mr,xr,ni,oi,mi,z?{create:Ui,activate:Ui,remove:function(e,t){!0!==e.data.show?Ri(e,t):t()}}:{}].concat(pr)});W&&document.addEventListener("selectionchange",function(){var e=document.activeElement;e&&e.vmodel&&Xi(e,"input")});var Vi={inserted:function(e,t,n,r){"select"===n.tag?(r.elm&&!r.elm._vOptions?it(n,"postpatch",function(){Vi.componentUpdated(e,t,n)}):Ki(e,t,n.context),e._vOptions=[].map.call(e.options,Wi)):("textarea"===n.tag||Xn(e.type))&&(e._vModifiers=t.modifiers,t.modifiers.lazy||(e.addEventListener("compositionstart",Zi),e.addEventListener("compositionend",Gi),e.addEventListener("change",Gi),W&&(e.vmodel=!0)))},componentUpdated:function(e,t,n){if("select"===n.tag){Ki(e,t,n.context);var r=e._vOptions,i=e._vOptions=[].map.call(e.options,Wi);if(i.some(function(e,t){return!N(e,r[t])}))(e.multiple?t.value.some(function(e){return qi(e,i)}):t.value!==t.oldValue&&qi(t.value,i))&&Xi(e,"change")}}};function Ki(e,t,n){Ji(e,t,n),(q||Z)&&setTimeout(function(){Ji(e,t,n)},0)}function Ji(e,t,n){var r=t.value,i=e.multiple;if(!i||Array.isArray(r)){for(var o,a,s=0,c=e.options.length;s<c;s++)if(a=e.options[s],i)o=j(r,Wi(a))>-1,a.selected!==o&&(a.selected=o);else if(N(Wi(a),r))return void(e.selectedIndex!==s&&(e.selectedIndex=s));i||(e.selectedIndex=-1)}}function qi(e,t){return t.every(function(t){return!N(t,e)})}function Wi(e){return"_value"in e?e._value:e.value}function Zi(e){e.target.composing=!0}function Gi(e){e.target.composing&&(e.target.composing=!1,Xi(e.target,"input"))}function Xi(e,t){var n=document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),e.dispatchEvent(n)}function Yi(e){return!e.componentInstance||e.data&&e.data.transition?e:Yi(e.componentInstance._vnode)}var Qi={model:Vi,show:{bind:function(e,t,n){var r=t.value,i=(n=Yi(n)).data&&n.data.transition,o=e.__vOriginalDisplay="none"===e.style.display?"":e.style.display;r&&i?(n.data.show=!0,Pi(n,function(){e.style.display=o})):e.style.display=r?o:"none"},update:function(e,t,n){var r=t.value;!r!=!t.oldValue&&((n=Yi(n)).data&&n.data.transition?(n.data.show=!0,r?Pi(n,function(){e.style.display=e.__vOriginalDisplay}):Ri(n,function(){e.style.display="none"})):e.style.display=r?e.__vOriginalDisplay:"none")},unbind:function(e,t,n,r,i){i||(e.style.display=e.__vOriginalDisplay)}}},eo={name:String,appear:Boolean,css:Boolean,mode:String,type:String,enterClass:String,leaveClass:String,enterToClass:String,leaveToClass:String,enterActiveClass:String,leaveActiveClass:String,appearClass:String,appearActiveClass:String,appearToClass:String,duration:[Number,String,Object]};function to(e){var t=e&&e.componentOptions;return t&&t.Ctor.options.abstract?to(zt(t.children)):e}function no(e){var t={},n=e.$options;for(var r in n.propsData)t[r]=e[r];var i=n._parentListeners;for(var o in i)t[b(o)]=i[o];return t}function ro(e,t){if(/\d-keep-alive$/.test(t.tag))return e("keep-alive",{props:t.componentOptions.propsData})}var io=function(e){return e.tag||Ut(e)},oo=function(e){return"show"===e.name},ao={name:"transition",props:eo,abstract:!0,render:function(e){var t=this,n=this.$slots.default;if(n&&(n=n.filter(io)).length){var r=this.mode,o=n[0];if(function(e){for(;e=e.parent;)if(e.data.transition)return!0}(this.$vnode))return o;var a=to(o);if(!a)return o;if(this._leaving)return ro(e,o);var s="__transition-"+this._uid+"-";a.key=null==a.key?a.isComment?s+"comment":s+a.tag:i(a.key)?0===String(a.key).indexOf(s)?a.key:s+a.key:a.key;var c=(a.data||(a.data={})).transition=no(this),u=this._vnode,l=to(u);if(a.data.directives&&a.data.directives.some(oo)&&(a.data.show=!0),l&&l.data&&!function(e,t){return t.key===e.key&&t.tag===e.tag}(a,l)&&!Ut(l)&&(!l.componentInstance||!l.componentInstance._vnode.isComment)){var f=l.data.transition=A({},c);if("out-in"===r)return this._leaving=!0,it(f,"afterLeave",function(){t._leaving=!1,t.$forceUpdate()}),ro(e,o);if("in-out"===r){if(Ut(a))return u;var p,d=function(){p()};it(c,"afterEnter",d),it(c,"enterCancelled",d),it(f,"delayLeave",function(e){p=e})}}return o}}},so=A({tag:String,moveClass:String},eo);function co(e){e.elm._moveCb&&e.elm._moveCb(),e.elm._enterCb&&e.elm._enterCb()}function uo(e){e.data.newPos=e.elm.getBoundingClientRect()}function lo(e){var t=e.data.pos,n=e.data.newPos,r=t.left-n.left,i=t.top-n.top;if(r||i){e.data.moved=!0;var o=e.elm.style;o.transform=o.WebkitTransform="translate("+r+"px,"+i+"px)",o.transitionDuration="0s"}}delete so.mode;var fo={Transition:ao,TransitionGroup:{props:so,beforeMount:function(){var e=this,t=this._update;this._update=function(n,r){var i=Zt(e);e.__patch__(e._vnode,e.kept,!1,!0),e._vnode=e.kept,i(),t.call(e,n,r)}},render:function(e){for(var t=this.tag||this.$vnode.data.tag||"span",n=Object.create(null),r=this.prevChildren=this.children,i=this.$slots.default||[],o=this.children=[],a=no(this),s=0;s<i.length;s++){var c=i[s];c.tag&&null!=c.key&&0!==String(c.key).indexOf("__vlist")&&(o.push(c),n[c.key]=c,(c.data||(c.data={})).transition=a)}if(r){for(var u=[],l=[],f=0;f<r.length;f++){var p=r[f];p.data.transition=a,p.data.pos=p.elm.getBoundingClientRect(),n[p.key]?u.push(p):l.push(p)}this.kept=e(t,null,u),this.removed=l}return e(t,null,o)},updated:function(){var e=this.prevChildren,t=this.moveClass||(this.name||"v")+"-move";e.length&&this.hasMove(e[0].elm,t)&&(e.forEach(co),e.forEach(uo),e.forEach(lo),this._reflow=document.body.offsetHeight,e.forEach(function(e){if(e.data.moved){var n=e.elm,r=n.style;Ni(n,t),r.transform=r.WebkitTransform=r.transitionDuration="",n.addEventListener(Ai,n._moveCb=function e(r){r&&r.target!==n||r&&!/transform$/.test(r.propertyName)||(n.removeEventListener(Ai,e),n._moveCb=null,ji(n,t))})}}))},methods:{hasMove:function(e,t){if(!wi)return!1;if(this._hasMove)return this._hasMove;var n=e.cloneNode();e._transitionClasses&&e._transitionClasses.forEach(function(e){_i(n,e)}),gi(n,t),n.style.display="none",this.$el.appendChild(n);var r=Mi(n);return this.$el.removeChild(n),this._hasMove=r.hasTransform}}}};wn.config.mustUseProp=jn,wn.config.isReservedTag=Wn,wn.config.isReservedAttr=En,wn.config.getTagNamespace=Zn,wn.config.isUnknownElement=function(e){if(!z)return!0;if(Wn(e))return!1;if(e=e.toLowerCase(),null!=Gn[e])return Gn[e];var t=document.createElement(e);return e.indexOf("-")>-1?Gn[e]=t.constructor===window.HTMLUnknownElement||t.constructor===window.HTMLElement:Gn[e]=/HTMLUnknownElement/.test(t.toString())},A(wn.options.directives,Qi),A(wn.options.components,fo),wn.prototype.__patch__=z?zi:S,wn.prototype.$mount=function(e,t){return function(e,t,n){var r;return e.$el=t,e.$options.render||(e.$options.render=ve),Yt(e,"beforeMount"),r=function(){e._update(e._render(),n)},new fn(e,r,S,{before:function(){e._isMounted&&!e._isDestroyed&&Yt(e,"beforeUpdate")}},!0),n=!1,null==e.$vnode&&(e._isMounted=!0,Yt(e,"mounted")),e}(this,e=e&&z?Yn(e):void 0,t)},z&&setTimeout(function(){F.devtools&&ne&&ne.emit("init",wn)},0);var po=/\{\{((?:.|\r?\n)+?)\}\}/g,vo=/[-.*+?^${}()|[\]\/\\]/g,ho=g(function(e){var t=e[0].replace(vo,"\\$&"),n=e[1].replace(vo,"\\$&");return new RegExp(t+"((?:.|\\n)+?)"+n,"g")});var mo={staticKeys:["staticClass"],transformNode:function(e,t){t.warn;var n=Fr(e,"class");n&&(e.staticClass=JSON.stringify(n));var r=Ir(e,"class",!1);r&&(e.classBinding=r)},genData:function(e){var t="";return e.staticClass&&(t+="staticClass:"+e.staticClass+","),e.classBinding&&(t+="class:"+e.classBinding+","),t}};var yo,go={staticKeys:["staticStyle"],transformNode:function(e,t){t.warn;var n=Fr(e,"style");n&&(e.staticStyle=JSON.stringify(ai(n)));var r=Ir(e,"style",!1);r&&(e.styleBinding=r)},genData:function(e){var t="";return e.staticStyle&&(t+="staticStyle:"+e.staticStyle+","),e.styleBinding&&(t+="style:("+e.styleBinding+"),"),t}},_o=function(e){return(yo=yo||document.createElement("div")).innerHTML=e,yo.textContent},bo=p("area,base,br,col,embed,frame,hr,img,input,isindex,keygen,link,meta,param,source,track,wbr"),$o=p("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source"),wo=p("address,article,aside,base,blockquote,body,caption,col,colgroup,dd,details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,title,tr,track"),Co=/^\s*([^\s"'<>\/=]+)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,xo=/^\s*((?:v-[\w-]+:|@|:|#)\[[^=]+\][^\s"'<>\/=]*)(?:\s*(=)\s*(?:"([^"]*)"+|'([^']*)'+|([^\s"'=<>`]+)))?/,ko="[a-zA-Z_][\\-\\.0-9_a-zA-Z"+P.source+"]*",Ao="((?:"+ko+"\\:)?"+ko+")",Oo=new RegExp("^<"+Ao),So=/^\s*(\/?)>/,To=new RegExp("^<\\/"+Ao+"[^>]*>"),Eo=/^<!DOCTYPE [^>]+>/i,No=/^<!\--/,jo=/^<!\[/,Do=p("script,style,textarea",!0),Lo={},Mo={"&lt;":"<","&gt;":">","&quot;":'"',"&amp;":"&","&#10;":"\n","&#9;":"\t","&#39;":"'"},Io=/&(?:lt|gt|quot|amp|#39);/g,Fo=/&(?:lt|gt|quot|amp|#39|#10|#9);/g,Po=p("pre,textarea",!0),Ro=function(e,t){return e&&Po(e)&&"\n"===t[0]};function Ho(e,t){var n=t?Fo:Io;return e.replace(n,function(e){return Mo[e]})}var Bo,Uo,zo,Vo,Ko,Jo,qo,Wo,Zo=/^@|^v-on:/,Go=/^v-|^@|^:/,Xo=/([\s\S]*?)\s+(?:in|of)\s+([\s\S]*)/,Yo=/,([^,\}\]]*)(?:,([^,\}\]]*))?$/,Qo=/^\(|\)$/g,ea=/^\[.*\]$/,ta=/:(.*)$/,na=/^:|^\.|^v-bind:/,ra=/\.[^.\]]+(?=[^\]]*$)/g,ia=/^v-slot(:|$)|^#/,oa=/[\r\n]/,aa=/\s+/g,sa=g(_o),ca="_empty_";function ua(e,t,n){return{type:1,tag:e,attrsList:t,attrsMap:ma(t),rawAttrsMap:{},parent:n,children:[]}}function la(e,t){Bo=t.warn||Sr,Jo=t.isPreTag||T,qo=t.mustUseProp||T,Wo=t.getTagNamespace||T;t.isReservedTag;zo=Tr(t.modules,"transformNode"),Vo=Tr(t.modules,"preTransformNode"),Ko=Tr(t.modules,"postTransformNode"),Uo=t.delimiters;var n,r,i=[],o=!1!==t.preserveWhitespace,a=t.whitespace,s=!1,c=!1;function u(e){if(l(e),s||e.processed||(e=fa(e,t)),i.length||e===n||n.if&&(e.elseif||e.else)&&da(n,{exp:e.elseif,block:e}),r&&!e.forbidden)if(e.elseif||e.else)a=e,(u=function(e){var t=e.length;for(;t--;){if(1===e[t].type)return e[t];e.pop()}}(r.children))&&u.if&&da(u,{exp:a.elseif,block:a});else{if(e.slotScope){var o=e.slotTarget||'"default"';(r.scopedSlots||(r.scopedSlots={}))[o]=e}r.children.push(e),e.parent=r}var a,u;e.children=e.children.filter(function(e){return!e.slotScope}),l(e),e.pre&&(s=!1),Jo(e.tag)&&(c=!1);for(var f=0;f<Ko.length;f++)Ko[f](e,t)}function l(e){if(!c)for(var t;(t=e.children[e.children.length-1])&&3===t.type&&" "===t.text;)e.children.pop()}return function(e,t){for(var n,r,i=[],o=t.expectHTML,a=t.isUnaryTag||T,s=t.canBeLeftOpenTag||T,c=0;e;){if(n=e,r&&Do(r)){var u=0,l=r.toLowerCase(),f=Lo[l]||(Lo[l]=new RegExp("([\\s\\S]*?)(</"+l+"[^>]*>)","i")),p=e.replace(f,function(e,n,r){return u=r.length,Do(l)||"noscript"===l||(n=n.replace(/<!\--([\s\S]*?)-->/g,"$1").replace(/<!\[CDATA\[([\s\S]*?)]]>/g,"$1")),Ro(l,n)&&(n=n.slice(1)),t.chars&&t.chars(n),""});c+=e.length-p.length,e=p,A(l,c-u,c)}else{var d=e.indexOf("<");if(0===d){if(No.test(e)){var v=e.indexOf("--\x3e");if(v>=0){t.shouldKeepComment&&t.comment(e.substring(4,v),c,c+v+3),C(v+3);continue}}if(jo.test(e)){var h=e.indexOf("]>");if(h>=0){C(h+2);continue}}var m=e.match(Eo);if(m){C(m[0].length);continue}var y=e.match(To);if(y){var g=c;C(y[0].length),A(y[1],g,c);continue}var _=x();if(_){k(_),Ro(_.tagName,e)&&C(1);continue}}var b=void 0,$=void 0,w=void 0;if(d>=0){for($=e.slice(d);!(To.test($)||Oo.test($)||No.test($)||jo.test($)||(w=$.indexOf("<",1))<0);)d+=w,$=e.slice(d);b=e.substring(0,d)}d<0&&(b=e),b&&C(b.length),t.chars&&b&&t.chars(b,c-b.length,c)}if(e===n){t.chars&&t.chars(e);break}}function C(t){c+=t,e=e.substring(t)}function x(){var t=e.match(Oo);if(t){var n,r,i={tagName:t[1],attrs:[],start:c};for(C(t[0].length);!(n=e.match(So))&&(r=e.match(xo)||e.match(Co));)r.start=c,C(r[0].length),r.end=c,i.attrs.push(r);if(n)return i.unarySlash=n[1],C(n[0].length),i.end=c,i}}function k(e){var n=e.tagName,c=e.unarySlash;o&&("p"===r&&wo(n)&&A(r),s(n)&&r===n&&A(n));for(var u=a(n)||!!c,l=e.attrs.length,f=new Array(l),p=0;p<l;p++){var d=e.attrs[p],v=d[3]||d[4]||d[5]||"",h="a"===n&&"href"===d[1]?t.shouldDecodeNewlinesForHref:t.shouldDecodeNewlines;f[p]={name:d[1],value:Ho(v,h)}}u||(i.push({tag:n,lowerCasedTag:n.toLowerCase(),attrs:f,start:e.start,end:e.end}),r=n),t.start&&t.start(n,f,u,e.start,e.end)}function A(e,n,o){var a,s;if(null==n&&(n=c),null==o&&(o=c),e)for(s=e.toLowerCase(),a=i.length-1;a>=0&&i[a].lowerCasedTag!==s;a--);else a=0;if(a>=0){for(var u=i.length-1;u>=a;u--)t.end&&t.end(i[u].tag,n,o);i.length=a,r=a&&i[a-1].tag}else"br"===s?t.start&&t.start(e,[],!0,n,o):"p"===s&&(t.start&&t.start(e,[],!1,n,o),t.end&&t.end(e,n,o))}A()}(e,{warn:Bo,expectHTML:t.expectHTML,isUnaryTag:t.isUnaryTag,canBeLeftOpenTag:t.canBeLeftOpenTag,shouldDecodeNewlines:t.shouldDecodeNewlines,shouldDecodeNewlinesForHref:t.shouldDecodeNewlinesForHref,shouldKeepComment:t.comments,outputSourceRange:t.outputSourceRange,start:function(e,o,a,l,f){var p=r&&r.ns||Wo(e);q&&"svg"===p&&(o=function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];ya.test(r.name)||(r.name=r.name.replace(ga,""),t.push(r))}return t}(o));var d,v=ua(e,o,r);p&&(v.ns=p),"style"!==(d=v).tag&&("script"!==d.tag||d.attrsMap.type&&"text/javascript"!==d.attrsMap.type)||te()||(v.forbidden=!0);for(var h=0;h<Vo.length;h++)v=Vo[h](v,t)||v;s||(!function(e){null!=Fr(e,"v-pre")&&(e.pre=!0)}(v),v.pre&&(s=!0)),Jo(v.tag)&&(c=!0),s?function(e){var t=e.attrsList,n=t.length;if(n)for(var r=e.attrs=new Array(n),i=0;i<n;i++)r[i]={name:t[i].name,value:JSON.stringify(t[i].value)},null!=t[i].start&&(r[i].start=t[i].start,r[i].end=t[i].end);else e.pre||(e.plain=!0)}(v):v.processed||(pa(v),function(e){var t=Fr(e,"v-if");if(t)e.if=t,da(e,{exp:t,block:e});else{null!=Fr(e,"v-else")&&(e.else=!0);var n=Fr(e,"v-else-if");n&&(e.elseif=n)}}(v),function(e){null!=Fr(e,"v-once")&&(e.once=!0)}(v)),n||(n=v),a?u(v):(r=v,i.push(v))},end:function(e,t,n){var o=i[i.length-1];i.length-=1,r=i[i.length-1],u(o)},chars:function(e,t,n){if(r&&(!q||"textarea"!==r.tag||r.attrsMap.placeholder!==e)){var i,u,l,f=r.children;if(e=c||e.trim()?"script"===(i=r).tag||"style"===i.tag?e:sa(e):f.length?a?"condense"===a&&oa.test(e)?"":" ":o?" ":"":"")c||"condense"!==a||(e=e.replace(aa," ")),!s&&" "!==e&&(u=function(e,t){var n=t?ho(t):po;if(n.test(e)){for(var r,i,o,a=[],s=[],c=n.lastIndex=0;r=n.exec(e);){(i=r.index)>c&&(s.push(o=e.slice(c,i)),a.push(JSON.stringify(o)));var u=Ar(r[1].trim());a.push("_s("+u+")"),s.push({"@binding":u}),c=i+r[0].length}return c<e.length&&(s.push(o=e.slice(c)),a.push(JSON.stringify(o))),{expression:a.join("+"),tokens:s}}}(e,Uo))?l={type:2,expression:u.expression,tokens:u.tokens,text:e}:" "===e&&f.length&&" "===f[f.length-1].text||(l={type:3,text:e}),l&&f.push(l)}},comment:function(e,t,n){if(r){var i={type:3,text:e,isComment:!0};r.children.push(i)}}}),n}function fa(e,t){var n,r;(r=Ir(n=e,"key"))&&(n.key=r),e.plain=!e.key&&!e.scopedSlots&&!e.attrsList.length,function(e){var t=Ir(e,"ref");t&&(e.ref=t,e.refInFor=function(e){var t=e;for(;t;){if(void 0!==t.for)return!0;t=t.parent}return!1}(e))}(e),function(e){var t;"template"===e.tag?(t=Fr(e,"scope"),e.slotScope=t||Fr(e,"slot-scope")):(t=Fr(e,"slot-scope"))&&(e.slotScope=t);var n=Ir(e,"slot");n&&(e.slotTarget='""'===n?'"default"':n,e.slotTargetDynamic=!(!e.attrsMap[":slot"]&&!e.attrsMap["v-bind:slot"]),"template"===e.tag||e.slotScope||Nr(e,"slot",n,function(e,t){return e.rawAttrsMap[":"+t]||e.rawAttrsMap["v-bind:"+t]||e.rawAttrsMap[t]}(e,"slot")));if("template"===e.tag){var r=Pr(e,ia);if(r){var i=va(r),o=i.name,a=i.dynamic;e.slotTarget=o,e.slotTargetDynamic=a,e.slotScope=r.value||ca}}else{var s=Pr(e,ia);if(s){var c=e.scopedSlots||(e.scopedSlots={}),u=va(s),l=u.name,f=u.dynamic,p=c[l]=ua("template",[],e);p.slotTarget=l,p.slotTargetDynamic=f,p.children=e.children.filter(function(e){if(!e.slotScope)return e.parent=p,!0}),p.slotScope=s.value||ca,e.children=[],e.plain=!1}}}(e),function(e){"slot"===e.tag&&(e.slotName=Ir(e,"name"))}(e),function(e){var t;(t=Ir(e,"is"))&&(e.component=t);null!=Fr(e,"inline-template")&&(e.inlineTemplate=!0)}(e);for(var i=0;i<zo.length;i++)e=zo[i](e,t)||e;return function(e){var t,n,r,i,o,a,s,c,u=e.attrsList;for(t=0,n=u.length;t<n;t++)if(r=i=u[t].name,o=u[t].value,Go.test(r))if(e.hasBindings=!0,(a=ha(r.replace(Go,"")))&&(r=r.replace(ra,"")),na.test(r))r=r.replace(na,""),o=Ar(o),(c=ea.test(r))&&(r=r.slice(1,-1)),a&&(a.prop&&!c&&"innerHtml"===(r=b(r))&&(r="innerHTML"),a.camel&&!c&&(r=b(r)),a.sync&&(s=Br(o,"$event"),c?Mr(e,'"update:"+('+r+")",s,null,!1,0,u[t],!0):(Mr(e,"update:"+b(r),s,null,!1,0,u[t]),C(r)!==b(r)&&Mr(e,"update:"+C(r),s,null,!1,0,u[t])))),a&&a.prop||!e.component&&qo(e.tag,e.attrsMap.type,r)?Er(e,r,o,u[t],c):Nr(e,r,o,u[t],c);else if(Zo.test(r))r=r.replace(Zo,""),(c=ea.test(r))&&(r=r.slice(1,-1)),Mr(e,r,o,a,!1,0,u[t],c);else{var l=(r=r.replace(Go,"")).match(ta),f=l&&l[1];c=!1,f&&(r=r.slice(0,-(f.length+1)),ea.test(f)&&(f=f.slice(1,-1),c=!0)),Dr(e,r,i,o,f,c,a,u[t])}else Nr(e,r,JSON.stringify(o),u[t]),!e.component&&"muted"===r&&qo(e.tag,e.attrsMap.type,r)&&Er(e,r,"true",u[t])}(e),e}function pa(e){var t;if(t=Fr(e,"v-for")){var n=function(e){var t=e.match(Xo);if(!t)return;var n={};n.for=t[2].trim();var r=t[1].trim().replace(Qo,""),i=r.match(Yo);i?(n.alias=r.replace(Yo,"").trim(),n.iterator1=i[1].trim(),i[2]&&(n.iterator2=i[2].trim())):n.alias=r;return n}(t);n&&A(e,n)}}function da(e,t){e.ifConditions||(e.ifConditions=[]),e.ifConditions.push(t)}function va(e){var t=e.name.replace(ia,"");return t||"#"!==e.name[0]&&(t="default"),ea.test(t)?{name:t.slice(1,-1),dynamic:!0}:{name:'"'+t+'"',dynamic:!1}}function ha(e){var t=e.match(ra);if(t){var n={};return t.forEach(function(e){n[e.slice(1)]=!0}),n}}function ma(e){for(var t={},n=0,r=e.length;n<r;n++)t[e[n].name]=e[n].value;return t}var ya=/^xmlns:NS\d+/,ga=/^NS\d+:/;function _a(e){return ua(e.tag,e.attrsList.slice(),e.parent)}var ba=[mo,go,{preTransformNode:function(e,t){if("input"===e.tag){var n,r=e.attrsMap;if(!r["v-model"])return;if((r[":type"]||r["v-bind:type"])&&(n=Ir(e,"type")),r.type||n||!r["v-bind"]||(n="("+r["v-bind"]+").type"),n){var i=Fr(e,"v-if",!0),o=i?"&&("+i+")":"",a=null!=Fr(e,"v-else",!0),s=Fr(e,"v-else-if",!0),c=_a(e);pa(c),jr(c,"type","checkbox"),fa(c,t),c.processed=!0,c.if="("+n+")==='checkbox'"+o,da(c,{exp:c.if,block:c});var u=_a(e);Fr(u,"v-for",!0),jr(u,"type","radio"),fa(u,t),da(c,{exp:"("+n+")==='radio'"+o,block:u});var l=_a(e);return Fr(l,"v-for",!0),jr(l,":type",n),fa(l,t),da(c,{exp:i,block:l}),a?c.else=!0:s&&(c.elseif=s),c}}}}];var $a,wa,Ca={expectHTML:!0,modules:ba,directives:{model:function(e,t,n){var r=t.value,i=t.modifiers,o=e.tag,a=e.attrsMap.type;if(e.component)return Hr(e,r,i),!1;if("select"===o)!function(e,t,n){var r='var $$selectedVal = Array.prototype.filter.call($event.target.options,function(o){return o.selected}).map(function(o){var val = "_value" in o ? o._value : o.value;return '+(n&&n.number?"_n(val)":"val")+"});";r=r+" "+Br(t,"$event.target.multiple ? $$selectedVal : $$selectedVal[0]"),Mr(e,"change",r,null,!0)}(e,r,i);else if("input"===o&&"checkbox"===a)!function(e,t,n){var r=n&&n.number,i=Ir(e,"value")||"null",o=Ir(e,"true-value")||"true",a=Ir(e,"false-value")||"false";Er(e,"checked","Array.isArray("+t+")?_i("+t+","+i+")>-1"+("true"===o?":("+t+")":":_q("+t+","+o+")")),Mr(e,"change","var $$a="+t+",$$el=$event.target,$$c=$$el.checked?("+o+"):("+a+");if(Array.isArray($$a)){var $$v="+(r?"_n("+i+")":i)+",$$i=_i($$a,$$v);if($$el.checked){$$i<0&&("+Br(t,"$$a.concat([$$v])")+")}else{$$i>-1&&("+Br(t,"$$a.slice(0,$$i).concat($$a.slice($$i+1))")+")}}else{"+Br(t,"$$c")+"}",null,!0)}(e,r,i);else if("input"===o&&"radio"===a)!function(e,t,n){var r=n&&n.number,i=Ir(e,"value")||"null";Er(e,"checked","_q("+t+","+(i=r?"_n("+i+")":i)+")"),Mr(e,"change",Br(t,i),null,!0)}(e,r,i);else if("input"===o||"textarea"===o)!function(e,t,n){var r=e.attrsMap.type,i=n||{},o=i.lazy,a=i.number,s=i.trim,c=!o&&"range"!==r,u=o?"change":"range"===r?Wr:"input",l="$event.target.value";s&&(l="$event.target.value.trim()"),a&&(l="_n("+l+")");var f=Br(t,l);c&&(f="if($event.target.composing)return;"+f),Er(e,"value","("+t+")"),Mr(e,u,f,null,!0),(s||a)&&Mr(e,"blur","$forceUpdate()")}(e,r,i);else if(!F.isReservedTag(o))return Hr(e,r,i),!1;return!0},text:function(e,t){t.value&&Er(e,"textContent","_s("+t.value+")",t)},html:function(e,t){t.value&&Er(e,"innerHTML","_s("+t.value+")",t)}},isPreTag:function(e){return"pre"===e},isUnaryTag:bo,mustUseProp:jn,canBeLeftOpenTag:$o,isReservedTag:Wn,getTagNamespace:Zn,staticKeys:function(e){return e.reduce(function(e,t){return e.concat(t.staticKeys||[])},[]).join(",")}(ba)},xa=g(function(e){return p("type,tag,attrsList,attrsMap,plain,parent,children,attrs,start,end,rawAttrsMap"+(e?","+e:""))});function ka(e,t){e&&($a=xa(t.staticKeys||""),wa=t.isReservedTag||T,function e(t){t.static=function(e){if(2===e.type)return!1;if(3===e.type)return!0;return!(!e.pre&&(e.hasBindings||e.if||e.for||d(e.tag)||!wa(e.tag)||function(e){for(;e.parent;){if("template"!==(e=e.parent).tag)return!1;if(e.for)return!0}return!1}(e)||!Object.keys(e).every($a)))}(t);if(1===t.type){if(!wa(t.tag)&&"slot"!==t.tag&&null==t.attrsMap["inline-template"])return;for(var n=0,r=t.children.length;n<r;n++){var i=t.children[n];e(i),i.static||(t.static=!1)}if(t.ifConditions)for(var o=1,a=t.ifConditions.length;o<a;o++){var s=t.ifConditions[o].block;e(s),s.static||(t.static=!1)}}}(e),function e(t,n){if(1===t.type){if((t.static||t.once)&&(t.staticInFor=n),t.static&&t.children.length&&(1!==t.children.length||3!==t.children[0].type))return void(t.staticRoot=!0);if(t.staticRoot=!1,t.children)for(var r=0,i=t.children.length;r<i;r++)e(t.children[r],n||!!t.for);if(t.ifConditions)for(var o=1,a=t.ifConditions.length;o<a;o++)e(t.ifConditions[o].block,n)}}(e,!1))}var Aa=/^([\w$_]+|\([^)]*?\))\s*=>|^function\s*(?:[\w$]+)?\s*\(/,Oa=/\([^)]*?\);*$/,Sa=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['[^']*?']|\["[^"]*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*$/,Ta={esc:27,tab:9,enter:13,space:32,up:38,left:37,right:39,down:40,delete:[8,46]},Ea={esc:["Esc","Escape"],tab:"Tab",enter:"Enter",space:[" ","Spacebar"],up:["Up","ArrowUp"],left:["Left","ArrowLeft"],right:["Right","ArrowRight"],down:["Down","ArrowDown"],delete:["Backspace","Delete","Del"]},Na=function(e){return"if("+e+")return null;"},ja={stop:"$event.stopPropagation();",prevent:"$event.preventDefault();",self:Na("$event.target !== $event.currentTarget"),ctrl:Na("!$event.ctrlKey"),shift:Na("!$event.shiftKey"),alt:Na("!$event.altKey"),meta:Na("!$event.metaKey"),left:Na("'button' in $event && $event.button !== 0"),middle:Na("'button' in $event && $event.button !== 1"),right:Na("'button' in $event && $event.button !== 2")};function Da(e,t){var n=t?"nativeOn:":"on:",r="",i="";for(var o in e){var a=La(e[o]);e[o]&&e[o].dynamic?i+=o+","+a+",":r+='"'+o+'":'+a+","}return r="{"+r.slice(0,-1)+"}",i?n+"_d("+r+",["+i.slice(0,-1)+"])":n+r}function La(e){if(!e)return"function(){}";if(Array.isArray(e))return"["+e.map(function(e){return La(e)}).join(",")+"]";var t=Sa.test(e.value),n=Aa.test(e.value),r=Sa.test(e.value.replace(Oa,""));if(e.modifiers){var i="",o="",a=[];for(var s in e.modifiers)if(ja[s])o+=ja[s],Ta[s]&&a.push(s);else if("exact"===s){var c=e.modifiers;o+=Na(["ctrl","shift","alt","meta"].filter(function(e){return!c[e]}).map(function(e){return"$event."+e+"Key"}).join("||"))}else a.push(s);return a.length&&(i+=function(e){return"if(!$event.type.indexOf('key')&&"+e.map(Ma).join("&&")+")return null;"}(a)),o&&(i+=o),"function($event){"+i+(t?"return "+e.value+"($event)":n?"return ("+e.value+")($event)":r?"return "+e.value:e.value)+"}"}return t||n?e.value:"function($event){"+(r?"return "+e.value:e.value)+"}"}function Ma(e){var t=parseInt(e,10);if(t)return"$event.keyCode!=="+t;var n=Ta[e],r=Ea[e];return"_k($event.keyCode,"+JSON.stringify(e)+","+JSON.stringify(n)+",$event.key,"+JSON.stringify(r)+")"}var Ia={on:function(e,t){e.wrapListeners=function(e){return"_g("+e+","+t.value+")"}},bind:function(e,t){e.wrapData=function(n){return"_b("+n+",'"+e.tag+"',"+t.value+","+(t.modifiers&&t.modifiers.prop?"true":"false")+(t.modifiers&&t.modifiers.sync?",true":"")+")"}},cloak:S},Fa=function(e){this.options=e,this.warn=e.warn||Sr,this.transforms=Tr(e.modules,"transformCode"),this.dataGenFns=Tr(e.modules,"genData"),this.directives=A(A({},Ia),e.directives);var t=e.isReservedTag||T;this.maybeComponent=function(e){return!!e.component||!t(e.tag)},this.onceId=0,this.staticRenderFns=[],this.pre=!1};function Pa(e,t){var n=new Fa(t);return{render:"with(this){return "+(e?Ra(e,n):'_c("div")')+"}",staticRenderFns:n.staticRenderFns}}function Ra(e,t){if(e.parent&&(e.pre=e.pre||e.parent.pre),e.staticRoot&&!e.staticProcessed)return Ha(e,t);if(e.once&&!e.onceProcessed)return Ba(e,t);if(e.for&&!e.forProcessed)return za(e,t);if(e.if&&!e.ifProcessed)return Ua(e,t);if("template"!==e.tag||e.slotTarget||t.pre){if("slot"===e.tag)return function(e,t){var n=e.slotName||'"default"',r=qa(e,t),i="_t("+n+(r?","+r:""),o=e.attrs||e.dynamicAttrs?Ga((e.attrs||[]).concat(e.dynamicAttrs||[]).map(function(e){return{name:b(e.name),value:e.value,dynamic:e.dynamic}})):null,a=e.attrsMap["v-bind"];!o&&!a||r||(i+=",null");o&&(i+=","+o);a&&(i+=(o?"":",null")+","+a);return i+")"}(e,t);var n;if(e.component)n=function(e,t,n){var r=t.inlineTemplate?null:qa(t,n,!0);return"_c("+e+","+Va(t,n)+(r?","+r:"")+")"}(e.component,e,t);else{var r;(!e.plain||e.pre&&t.maybeComponent(e))&&(r=Va(e,t));var i=e.inlineTemplate?null:qa(e,t,!0);n="_c('"+e.tag+"'"+(r?","+r:"")+(i?","+i:"")+")"}for(var o=0;o<t.transforms.length;o++)n=t.transforms[o](e,n);return n}return qa(e,t)||"void 0"}function Ha(e,t){e.staticProcessed=!0;var n=t.pre;return e.pre&&(t.pre=e.pre),t.staticRenderFns.push("with(this){return "+Ra(e,t)+"}"),t.pre=n,"_m("+(t.staticRenderFns.length-1)+(e.staticInFor?",true":"")+")"}function Ba(e,t){if(e.onceProcessed=!0,e.if&&!e.ifProcessed)return Ua(e,t);if(e.staticInFor){for(var n="",r=e.parent;r;){if(r.for){n=r.key;break}r=r.parent}return n?"_o("+Ra(e,t)+","+t.onceId+++","+n+")":Ra(e,t)}return Ha(e,t)}function Ua(e,t,n,r){return e.ifProcessed=!0,function e(t,n,r,i){if(!t.length)return i||"_e()";var o=t.shift();return o.exp?"("+o.exp+")?"+a(o.block)+":"+e(t,n,r,i):""+a(o.block);function a(e){return r?r(e,n):e.once?Ba(e,n):Ra(e,n)}}(e.ifConditions.slice(),t,n,r)}function za(e,t,n,r){var i=e.for,o=e.alias,a=e.iterator1?","+e.iterator1:"",s=e.iterator2?","+e.iterator2:"";return e.forProcessed=!0,(r||"_l")+"(("+i+"),function("+o+a+s+"){return "+(n||Ra)(e,t)+"})"}function Va(e,t){var n="{",r=function(e,t){var n=e.directives;if(!n)return;var r,i,o,a,s="directives:[",c=!1;for(r=0,i=n.length;r<i;r++){o=n[r],a=!0;var u=t.directives[o.name];u&&(a=!!u(e,o,t.warn)),a&&(c=!0,s+='{name:"'+o.name+'",rawName:"'+o.rawName+'"'+(o.value?",value:("+o.value+"),expression:"+JSON.stringify(o.value):"")+(o.arg?",arg:"+(o.isDynamicArg?o.arg:'"'+o.arg+'"'):"")+(o.modifiers?",modifiers:"+JSON.stringify(o.modifiers):"")+"},")}if(c)return s.slice(0,-1)+"]"}(e,t);r&&(n+=r+","),e.key&&(n+="key:"+e.key+","),e.ref&&(n+="ref:"+e.ref+","),e.refInFor&&(n+="refInFor:true,"),e.pre&&(n+="pre:true,"),e.component&&(n+='tag:"'+e.tag+'",');for(var i=0;i<t.dataGenFns.length;i++)n+=t.dataGenFns[i](e);if(e.attrs&&(n+="attrs:"+Ga(e.attrs)+","),e.props&&(n+="domProps:"+Ga(e.props)+","),e.events&&(n+=Da(e.events,!1)+","),e.nativeEvents&&(n+=Da(e.nativeEvents,!0)+","),e.slotTarget&&!e.slotScope&&(n+="slot:"+e.slotTarget+","),e.scopedSlots&&(n+=function(e,t,n){var r=e.for||Object.keys(t).some(function(e){var n=t[e];return n.slotTargetDynamic||n.if||n.for||Ka(n)}),i=!!e.if;if(!r)for(var o=e.parent;o;){if(o.slotScope&&o.slotScope!==ca||o.for){r=!0;break}o.if&&(i=!0),o=o.parent}var a=Object.keys(t).map(function(e){return Ja(t[e],n)}).join(",");return"scopedSlots:_u(["+a+"]"+(r?",null,true":"")+(!r&&i?",null,false,"+function(e){var t=5381,n=e.length;for(;n;)t=33*t^e.charCodeAt(--n);return t>>>0}(a):"")+")"}(e,e.scopedSlots,t)+","),e.model&&(n+="model:{value:"+e.model.value+",callback:"+e.model.callback+",expression:"+e.model.expression+"},"),e.inlineTemplate){var o=function(e,t){var n=e.children[0];if(n&&1===n.type){var r=Pa(n,t.options);return"inlineTemplate:{render:function(){"+r.render+"},staticRenderFns:["+r.staticRenderFns.map(function(e){return"function(){"+e+"}"}).join(",")+"]}"}}(e,t);o&&(n+=o+",")}return n=n.replace(/,$/,"")+"}",e.dynamicAttrs&&(n="_b("+n+',"'+e.tag+'",'+Ga(e.dynamicAttrs)+")"),e.wrapData&&(n=e.wrapData(n)),e.wrapListeners&&(n=e.wrapListeners(n)),n}function Ka(e){return 1===e.type&&("slot"===e.tag||e.children.some(Ka))}function Ja(e,t){var n=e.attrsMap["slot-scope"];if(e.if&&!e.ifProcessed&&!n)return Ua(e,t,Ja,"null");if(e.for&&!e.forProcessed)return za(e,t,Ja);var r=e.slotScope===ca?"":String(e.slotScope),i="function("+r+"){return "+("template"===e.tag?e.if&&n?"("+e.if+")?"+(qa(e,t)||"undefined")+":undefined":qa(e,t)||"undefined":Ra(e,t))+"}",o=r?"":",proxy:true";return"{key:"+(e.slotTarget||'"default"')+",fn:"+i+o+"}"}function qa(e,t,n,r,i){var o=e.children;if(o.length){var a=o[0];if(1===o.length&&a.for&&"template"!==a.tag&&"slot"!==a.tag){var s=n?t.maybeComponent(a)?",1":",0":"";return""+(r||Ra)(a,t)+s}var c=n?function(e,t){for(var n=0,r=0;r<e.length;r++){var i=e[r];if(1===i.type){if(Wa(i)||i.ifConditions&&i.ifConditions.some(function(e){return Wa(e.block)})){n=2;break}(t(i)||i.ifConditions&&i.ifConditions.some(function(e){return t(e.block)}))&&(n=1)}}return n}(o,t.maybeComponent):0,u=i||Za;return"["+o.map(function(e){return u(e,t)}).join(",")+"]"+(c?","+c:"")}}function Wa(e){return void 0!==e.for||"template"===e.tag||"slot"===e.tag}function Za(e,t){return 1===e.type?Ra(e,t):3===e.type&&e.isComment?(r=e,"_e("+JSON.stringify(r.text)+")"):"_v("+(2===(n=e).type?n.expression:Xa(JSON.stringify(n.text)))+")";var n,r}function Ga(e){for(var t="",n="",r=0;r<e.length;r++){var i=e[r],o=Xa(i.value);i.dynamic?n+=i.name+","+o+",":t+='"'+i.name+'":'+o+","}return t="{"+t.slice(0,-1)+"}",n?"_d("+t+",["+n.slice(0,-1)+"])":t}function Xa(e){return e.replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}new RegExp("\\b"+"do,if,for,let,new,try,var,case,else,with,await,break,catch,class,const,super,throw,while,yield,delete,export,import,return,switch,default,extends,finally,continue,debugger,function,arguments".split(",").join("\\b|\\b")+"\\b");function Ya(e,t){try{return new Function(e)}catch(n){return t.push({err:n,code:e}),S}}function Qa(e){var t=Object.create(null);return function(n,r,i){(r=A({},r)).warn;delete r.warn;var o=r.delimiters?String(r.delimiters)+n:n;if(t[o])return t[o];var a=e(n,r),s={},c=[];return s.render=Ya(a.render,c),s.staticRenderFns=a.staticRenderFns.map(function(e){return Ya(e,c)}),t[o]=s}}var es,ts,ns=(es=function(e,t){var n=la(e.trim(),t);!1!==t.optimize&&ka(n,t);var r=Pa(n,t);return{ast:n,render:r.render,staticRenderFns:r.staticRenderFns}},function(e){function t(t,n){var r=Object.create(e),i=[],o=[];if(n)for(var a in n.modules&&(r.modules=(e.modules||[]).concat(n.modules)),n.directives&&(r.directives=A(Object.create(e.directives||null),n.directives)),n)"modules"!==a&&"directives"!==a&&(r[a]=n[a]);r.warn=function(e,t,n){(n?o:i).push(e)};var s=es(t.trim(),r);return s.errors=i,s.tips=o,s}return{compile:t,compileToFunctions:Qa(t)}})(Ca),rs=(ns.compile,ns.compileToFunctions);function is(e){return(ts=ts||document.createElement("div")).innerHTML=e?'<a href="\n"/>':'<div a="\n"/>',ts.innerHTML.indexOf("&#10;")>0}var os=!!z&&is(!1),as=!!z&&is(!0),ss=g(function(e){var t=Yn(e);return t&&t.innerHTML}),cs=wn.prototype.$mount;return wn.prototype.$mount=function(e,t){if((e=e&&Yn(e))===document.body||e===document.documentElement)return this;var n=this.$options;if(!n.render){var r=n.template;if(r)if("string"==typeof r)"#"===r.charAt(0)&&(r=ss(r));else{if(!r.nodeType)return this;r=r.innerHTML}else e&&(r=function(e){if(e.outerHTML)return e.outerHTML;var t=document.createElement("div");return t.appendChild(e.cloneNode(!0)),t.innerHTML}(e));if(r){var i=rs(r,{outputSourceRange:!1,shouldDecodeNewlines:os,shouldDecodeNewlinesForHref:as,delimiters:n.delimiters,comments:n.comments},this),o=i.render,a=i.staticRenderFns;n.render=o,n.staticRenderFns=a}}return cs.call(this,e,t)},wn.compile=rs,wn});
{js → assets/js}/webfontloader.js RENAMED
File without changes
{js → assets/js}/webfontloader.min.js RENAMED
File without changes
autoload.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Auto registration for LiteSpeed classes
4
+ *
5
+ * @since 1.1.0
6
+ * @since 3.0 Moved into /
7
+ * @package LiteSpeed
8
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
9
+ */
10
+ defined( 'WPINC' ) || exit;
11
+
12
+ if ( ! function_exists( 'litespeed_autoload' ) ) {
13
+ function litespeed_autoload( $cls )
14
+ {
15
+ if ( strpos( $cls, '.' ) !== false ) {
16
+ return;
17
+ }
18
+
19
+ if ( strpos( $cls, 'LiteSpeed' ) !== 0 ) {
20
+ return;
21
+ }
22
+
23
+ $file = explode( '\\', $cls );
24
+ array_shift( $file );
25
+ $file = implode( '/', $file );
26
+ $file = str_replace( '_', '-', strtolower( $file ) );
27
+
28
+ if ( strpos( $file, 'lib/' ) === 0 || strpos( $file, 'cli/' ) === 0 || strpos( $file, 'thirdparty/' ) === 0 ) {
29
+ $file = LSCWP_DIR . $file . '.cls.php';
30
+ }
31
+ else {
32
+ $file = LSCWP_DIR . 'src/' . $file . '.cls.php';
33
+ }
34
+
35
+ if ( file_exists( $file ) ) {
36
+ require_once $file;
37
+ }
38
+ }
39
+ }
40
+
41
+ spl_autoload_register( 'litespeed_autoload' );
42
+
cli/debug.cls.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed\CLI;
3
+ defined( 'WPINC' ) || exit;
4
+
5
+ use LiteSpeed\Debug2;
6
+ use LiteSpeed\Report;
7
+ use WP_CLI;
8
+
9
+ /**
10
+ * Debug API CLI
11
+ */
12
+ class Debug
13
+ {
14
+ private $__report;
15
+
16
+ public function __construct()
17
+ {
18
+ Debug2::debug( 'CLI_Debug init' );
19
+
20
+ $this->__report = Report::get_instance();
21
+ }
22
+
23
+ /**
24
+ * Send report
25
+ *
26
+ * ## OPTIONS
27
+ *
28
+ * ## EXAMPLES
29
+ *
30
+ * # Send env report to LiteSpeed
31
+ * $ wp litespeed-debug send
32
+ *
33
+ */
34
+ public function send()
35
+ {
36
+ $num = $this->__report->post_env();
37
+ WP_CLI::success( 'Report Number = ' . $num );
38
+ }
39
+
40
+ }
cli/image.cls.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed\CLI;
3
+
4
+ defined( 'WPINC' ) || exit;
5
+
6
+ use LiteSpeed\Lang;
7
+ use LiteSpeed\Debug2;
8
+ use LiteSpeed\Img_Optm;
9
+ use LiteSpeed\Utility;
10
+ use WP_CLI;
11
+
12
+ /**
13
+ * Image Optm API CLI
14
+ */
15
+ class Image
16
+ {
17
+ private $__img_optm;
18
+
19
+ public function __construct()
20
+ {
21
+ Debug2::debug( 'CLI_Cloud init' );
22
+
23
+ $this->__img_optm = Img_Optm::get_instance();
24
+ }
25
+
26
+ /**
27
+ * Send image optimization request to cloud server
28
+ *
29
+ * ## OPTIONS
30
+ *
31
+ * ## EXAMPLES
32
+ *
33
+ * # Send image optimization request
34
+ * $ wp litespeed-image push
35
+ *
36
+ */
37
+ public function push()
38
+ {
39
+ $this->__img_optm->new_req();
40
+ }
41
+
42
+ /**
43
+ * Pull optimized images from cloud server
44
+ *
45
+ * ## OPTIONS
46
+ *
47
+ * ## EXAMPLES
48
+ *
49
+ * # Pull images back from cloud
50
+ * $ wp litespeed-image pull
51
+ *
52
+ */
53
+ public function pull()
54
+ {
55
+ $this->__img_optm->pull( true );
56
+ }
57
+
58
+ /**
59
+ * Show optimization status based on local data
60
+ *
61
+ * ## OPTIONS
62
+ *
63
+ * ## EXAMPLES
64
+ *
65
+ * # Show optimization status
66
+ * $ wp litespeed-image s
67
+ *
68
+ */
69
+ public function s()
70
+ {
71
+ $this->status();
72
+ }
73
+
74
+ /**
75
+ * Show optimization status based on local data
76
+ *
77
+ * ## OPTIONS
78
+ *
79
+ * ## EXAMPLES
80
+ *
81
+ * # Show optimization status
82
+ * $ wp litespeed-image status
83
+ *
84
+ */
85
+ public function status()
86
+ {
87
+ $summary = Img_Optm::get_summary();
88
+ $img_count = $this->__img_optm->img_count();
89
+ foreach ( Lang::img_status() as $k => $v ) {
90
+ if ( isset( $img_count[ "img.$k" ] )) {
91
+ $img_count[ "$v - images" ] = $img_count[ "img.$k" ];
92
+ unset( $img_count[ "img.$k" ] );
93
+ }
94
+ if ( isset( $img_count[ "group.$k" ] )) {
95
+ $img_count[ "$v - groups" ] = $img_count[ "group.$k" ];
96
+ unset( $img_count[ "group.$k" ] );
97
+ }
98
+ }
99
+
100
+ foreach ( array( 'reduced', 'reduced_webp' ) as $v ) {
101
+ if ( ! empty( $summary[ $v ] ) ) {
102
+ $summary[ $v ] = Utility::real_size( $summary[ $v ] );
103
+ }
104
+ }
105
+
106
+ if ( ! empty( $summary[ 'last_requested' ] ) ) {
107
+ $summary[ 'last_requested' ] = date( 'm/d/y H:i:s', $summary[ 'last_requested' ] );
108
+ }
109
+
110
+ $list = array();
111
+ foreach ( $summary as $k => $v ) {
112
+ $list[] = array( 'key' => $k, 'value' => $v );
113
+ }
114
+
115
+ $list2 = array();
116
+ foreach ( $img_count as $k => $v ) {
117
+ if ( ! $v ) {
118
+ continue;
119
+ }
120
+ $list2[] = array( 'key' => $k, 'value' => $v );
121
+ }
122
+
123
+ WP_CLI\Utils\format_items( 'table', $list, array( 'key', 'value' ) );
124
+
125
+ WP_CLI::line( WP_CLI::colorize( "%CImages in database summary:%n" ) );
126
+ WP_CLI\Utils\format_items( 'table', $list2, array( 'key', 'value' ) );
127
+ }
128
+
129
+ /**
130
+ * Clean up unfinished image data from cloud server
131
+ *
132
+ * ## OPTIONS
133
+ *
134
+ * ## EXAMPLES
135
+ *
136
+ * # Clean up unfinished requests
137
+ * $ wp litespeed-image clean
138
+ *
139
+ */
140
+ public function clean()
141
+ {
142
+ $this->__img_optm->clean();
143
+
144
+ WP_CLI::line( WP_CLI::colorize( "%CLatest status:%n" ) );
145
+
146
+ $this->status();
147
+ }
148
+
149
+ /**
150
+ * Remove original image backups
151
+ *
152
+ * ## OPTIONS
153
+ *
154
+ * ## EXAMPLES
155
+ *
156
+ * # Remove original image backups
157
+ * $ wp litespeed-image rm_bkup
158
+ *
159
+ */
160
+ public function rm_bkup()
161
+ {
162
+ $this->__img_optm->rm_bkup();
163
+ }
164
+
165
+
166
+ }
cli/litespeed-cache-cli-admin.class.php DELETED
@@ -1,341 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Admin Interface
5
- */
6
- class LiteSpeed_Cache_Cli_Admin
7
- {
8
-
9
- private static $checkboxes ;
10
- private static $purges ;
11
-
12
- public function __construct()
13
- {
14
- // Build on/off options
15
- self::$checkboxes = array() ;
16
- foreach ( LiteSpeed_Cache_Config::get_instance()->get_default_options() as $k => $v ) {
17
- if ( is_bool( $v ) ) {
18
- self::$checkboxes[] = $k ;
19
- }
20
- }
21
-
22
- self::$purges = array(
23
- 'purge_' . LiteSpeed_Cache_Config::PURGE_ALL_PAGES => LiteSpeed_Cache_Config::PURGE_ALL_PAGES,
24
- 'purge_' . LiteSpeed_Cache_Config::PURGE_FRONT_PAGE => LiteSpeed_Cache_Config::PURGE_FRONT_PAGE,
25
- 'purge_' . LiteSpeed_Cache_Config::PURGE_HOME_PAGE => LiteSpeed_Cache_Config::PURGE_HOME_PAGE,
26
- 'purge_' . LiteSpeed_Cache_Config::PURGE_AUTHOR => LiteSpeed_Cache_Config::PURGE_AUTHOR,
27
- 'purge_' . LiteSpeed_Cache_Config::PURGE_YEAR => LiteSpeed_Cache_Config::PURGE_YEAR,
28
- 'purge_' . LiteSpeed_Cache_Config::PURGE_MONTH => LiteSpeed_Cache_Config::PURGE_MONTH,
29
- 'purge_' . LiteSpeed_Cache_Config::PURGE_DATE => LiteSpeed_Cache_Config::PURGE_DATE,
30
- 'purge_' . LiteSpeed_Cache_Config::PURGE_TERM => LiteSpeed_Cache_Config::PURGE_TERM,
31
- 'purge_' . LiteSpeed_Cache_Config::PURGE_POST_TYPE => LiteSpeed_Cache_Config::PURGE_POST_TYPE,
32
- ) ;
33
- }
34
-
35
- /**
36
- * Set an individual LiteSpeed Cache option.
37
- *
38
- * ## OPTIONS
39
- *
40
- * <key>
41
- * : The option key to update.
42
- *
43
- * <newvalue>
44
- * : The new value to set the option to.
45
- *
46
- * ## EXAMPLES
47
- *
48
- * # Set to not cache the login page
49
- * $ wp lscache-admin set_option cache_login false
50
- *
51
- */
52
- public function set_option($args, $assoc_args)
53
- {
54
- /**
55
- * Note: If the value is multiple dimensions like cdn_mapping, need to specially handle it both here and in default.ini
56
- */
57
- $key = $args[0] ;
58
- $val = $args[1] ;
59
-
60
- $__cfg = LiteSpeed_Cache_Config::get_instance() ;
61
-
62
- $options = $__cfg->get_options() ;
63
- // Get items
64
- $cfg_items = $__cfg->stored_items() ;
65
- foreach ( $cfg_items as $v ) {
66
- $options[ $v ] = $__cfg->get_item( $v ) ;
67
- }
68
-
69
- /**
70
- * For CDN mapping, allow:
71
- * `set_option litespeed-cache-cdn_mapping[url][0] https://the1st_cdn_url`
72
- * `set_option litespeed-cache-cdn_mapping[inc_img][0] true`
73
- * @since 2.7.1
74
- */
75
- if ( ! isset($options) || ( ! isset($options[$key]) && ! isset(self::$purges[$key]) && strpos( $key, LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) !== 0 ) ) {
76
- WP_CLI::error('The options array is empty or the key is not valid.') ;
77
- return ;
78
- }
79
-
80
- $options = LiteSpeed_Cache_Config::convert_options_to_input($options) ;
81
-
82
- switch ($key) {
83
- case LiteSpeed_Cache_Config::OPID_VERSION:
84
- //do not allow
85
- WP_CLI::error('This option is not available for setting.') ;
86
- return ;
87
-
88
- case LiteSpeed_Cache_Config::OPID_CACHE_MOBILE:
89
- // set list then do checkbox
90
- if ( $val === 'true' && empty( $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] ) ) {
91
- $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] = 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi' ;
92
- }
93
- //fall through
94
- case in_array( $key, self::$checkboxes ) :
95
- //checkbox
96
- if ( $val === 'true' ) {
97
- $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
98
- }
99
- elseif ( $val === 'false' ) {
100
- unset($options[$key]) ;
101
- }
102
- else {
103
- WP_CLI::error('Checkbox value must be true or false.') ;
104
- return ;
105
- }
106
- break ;
107
-
108
- case LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST:
109
- $enable_key = LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ;
110
- if ( ! isset($options[$enable_key]) || ! $options[$enable_key] ) {
111
- $options[$enable_key] = LiteSpeed_Cache_Config::VAL_ON ;
112
- }
113
- $options[$key] = $val ;
114
- break ;
115
-
116
- /**
117
- * Special handler for cdn mapping settings
118
- *
119
- * $options is already converted to input format
120
- *
121
- * `set_option litespeed-cache-cdn_mapping[url][0] https://the1st_cdn_url`
122
- * `set_option litespeed-cache-cdn_mapping[inc_img][0] true`
123
- */
124
- case strpos( $key, LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) === 0 :
125
-
126
- preg_match( '|\[(\w+)\]\[(\d*)\]|U', $key, $child_key ) ;
127
-
128
- // Handle switch value
129
- if ( in_array( $child_key[ 1 ], array(
130
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
131
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
132
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
133
- ) ) ) {
134
- $val = $val === 'true' ? LiteSpeed_Cache_Config::VAL_ON : LiteSpeed_Cache_Config::VAL_OFF ;
135
- }
136
-
137
- $options[ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ][ $child_key[ 1 ] ][ $child_key[ 2 ] ] = $val ;
138
- break ;
139
-
140
- default:
141
- if ( substr($key, 0, 6) === 'purge_' ) {
142
- if ( $val === 'true' ) {
143
- WP_CLI::line('key is ' . $key . ', val is ' . $val) ;
144
- $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
145
- }
146
- elseif ( $val === 'false' ) {
147
- unset($options[$key]) ;
148
- }
149
- else {
150
- WP_CLI::error('Purge checkbox value must be true or false.') ;
151
- return ;
152
- }
153
- }
154
- else {
155
- // Everything else, just set the value
156
- $options[$key] = $val ;
157
- }
158
- break ;
159
- }
160
-
161
- $this->_update_options($options) ;
162
- }
163
-
164
- /**
165
- * Get the plugin options.
166
- *
167
- * ## OPTIONS
168
- *
169
- * ## EXAMPLES
170
- *
171
- * # Get all options
172
- * $ wp lscache-admin get_options
173
- *
174
- */
175
- public function get_options($args, $assoc_args)
176
- {
177
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
178
- $purge_options = LiteSpeed_Cache_Config::get_instance()->get_purge_options() ;
179
- unset($options[LiteSpeed_Cache_Config::OPID_PURGE_BY_POST]) ;
180
- $option_out = array() ;
181
- $purge_diff = array_diff(self::$purges, $purge_options) ;
182
- $purge_out = array() ;
183
-
184
- $buf = WP_CLI::colorize("%CThe list of options:%n\n") ;
185
- WP_CLI::line($buf) ;
186
-
187
- foreach($options as $key => $value) {
188
- if ( in_array($key, self::$checkboxes) ) {
189
- if ( $value ) {
190
- $value = 'true' ;
191
- }
192
- else {
193
- $value = 'false' ;
194
- }
195
- }
196
- elseif ( $value === '' ) {
197
- $value = "''" ;
198
- }
199
- $option_out[] = array('key' => $key, 'value' => $value) ;
200
- }
201
-
202
- foreach ($purge_options as $opt_name) {
203
- $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'true') ;
204
- }
205
-
206
- foreach ($purge_diff as $opt_name) {
207
- $purge_out[] = array('key' => 'purge_' . $opt_name, 'value' => 'false') ;
208
- }
209
-
210
- WP_CLI\Utils\format_items('table', $option_out, array('key', 'value')) ;
211
-
212
- $buf = WP_CLI::colorize("%CThe list of PURGE ON POST UPDATE options:%n\n") ;
213
- WP_CLI::line($buf) ;
214
- WP_CLI\Utils\format_items('table', $purge_out, array('key', 'value')) ;
215
- }
216
-
217
- /**
218
- * Export plugin options to a file.
219
- *
220
- * ## OPTIONS
221
- *
222
- * [--filename=<path>]
223
- * : The default path used is CURRENTDIR/lscache_wp_options_DATE-TIME.txt.
224
- * To select a different file, use this option.
225
- *
226
- * ## EXAMPLES
227
- *
228
- * # Export options to a file.
229
- * $ wp lscache-admin export_options
230
- *
231
- */
232
- public function export_options($args, $assoc_args)
233
- {
234
- if ( isset($assoc_args['filename']) ) {
235
- $file = $assoc_args['filename'] ;
236
- }
237
- else {
238
- $file = getcwd() . '/lscache_wp_options_' . date('d_m_Y-His') . '.data' ;
239
- }
240
-
241
- if ( ! is_writable(dirname($file)) ) {
242
- WP_CLI::error('Directory not writable.') ;
243
- return ;
244
- }
245
-
246
- $data = LiteSpeed_Cache_Import::get_instance()->export() ;
247
-
248
- if ( file_put_contents( $file, $data ) === false ) {
249
- WP_CLI::error( 'Failed to create file.' ) ;
250
- }
251
- else {
252
- WP_CLI::success('Created file ' . $file) ;
253
- }
254
- }
255
-
256
- /**
257
- * Import plugin options from a file.
258
- *
259
- * The file must be formatted as such:
260
- * option_key=option_value
261
- * One per line.
262
- * A Semicolon at the beginning of the line indicates a comment and will be skipped.
263
- *
264
- * ## OPTIONS
265
- *
266
- * <file>
267
- * : The file to import options from.
268
- *
269
- * ## EXAMPLES
270
- *
271
- * # Import options from CURRENTDIR/options.txt
272
- * $ wp lscache-admin import_options options.txt
273
- *
274
- */
275
- public function import_options($args, $assoc_args)
276
- {
277
- $file = $args[0] ;
278
- if ( ! file_exists($file) || ! is_readable($file) ) {
279
- WP_CLI::error('File does not exist or is not readable.') ;
280
- }
281
-
282
- $res = LiteSpeed_Cache_Import::get_instance()->import( $file ) ;
283
-
284
- if ( ! $res ) {
285
- WP_CLI::error( 'Failed to parse serialized data from file.' ) ;
286
- }
287
-
288
- WP_CLI::success( 'Options imported. [File] ' . $file ) ;
289
- }
290
-
291
- /**
292
- * Reset all options to default.
293
- *
294
- * ## EXAMPLES
295
- *
296
- * # Reset all options
297
- * $ wp lscache-admin reset_options
298
- *
299
- */
300
- public function reset_options()
301
- {
302
- $res = LiteSpeed_Cache_Import::get_instance()->reset( $file ) ;
303
-
304
- if ( ! $res ) {
305
- WP_CLI::error( 'Failed to reset options.' ) ;
306
- }
307
-
308
- WP_CLI::success( 'Options reset.' ) ;
309
- }
310
-
311
- /**
312
- * Update options
313
- *
314
- * @access private
315
- * @since 1.1.0
316
- * @param array $options The options array to store
317
- */
318
- private function _update_options($options)
319
- {
320
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings($options) ;
321
-
322
- global $wp_settings_errors ;
323
-
324
- if ( ! empty($wp_settings_errors) ) {
325
- foreach ($wp_settings_errors as $err) {
326
- WP_CLI::error($err['message']) ;
327
- }
328
- return ;
329
- }
330
-
331
- $ret = LiteSpeed_Cache_Config::get_instance()->update_options($output) ;
332
-
333
- WP_CLI::success('Options/Terms updated. Please purge the cache. New options: ' . var_export($options, true)) ;
334
- // if ( $ret ) {
335
- // }
336
- // else {
337
- // WP_CLI::error('No options updated.') ;
338
- // }
339
- }
340
- }
341
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cli/litespeed-cache-cli-iapi.class.php DELETED
@@ -1,200 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Image Optm Interface
5
- */
6
- class LiteSpeed_Cache_CLI_IAPI
7
- {
8
- private $_img_optm_instance ;
9
-
10
- public function __construct()
11
- {
12
- LiteSpeed_Cache_Log::debug( 'CLI_IAPI init' ) ;
13
-
14
- $this->_img_optm_instance = LiteSpeed_Cache_Img_Optm::get_instance() ;
15
- }
16
-
17
- /**
18
- * Sync data from IAPI server
19
- *
20
- * ## OPTIONS
21
- *
22
- * ## EXAMPLES
23
- *
24
- * # Sync or initialize image optimization service
25
- * $ wp lscache-iapi sync
26
- *
27
- */
28
- public function sync()
29
- {
30
- $optm_summary = $this->_img_optm_instance->summary_info() ;
31
-
32
- $json = $this->_img_optm_instance->sync_data() ;
33
-
34
- if ( ! $json || empty( $json[ 'level' ] ) ) {
35
- return ;
36
- }
37
-
38
- WP_CLI::success('[Level] ' . $json[ 'level' ] . ' [Credit] ' . $json[ 'credit' ] ) ;
39
-
40
- if ( empty( $optm_summary[ 'level' ] ) || empty( $optm_summary[ 'credit_recovered' ] ) || empty( $optm_summary[ '_level_data' ] ) ) {
41
- return ;
42
- }
43
-
44
- if ( $json[ 'level' ] > $optm_summary[ 'level' ] ) {
45
-
46
- LiteSpeed_Cache_Log::debug( "[Img_Optm] Upgraded to level $json[level] !" ) ;
47
-
48
- WP_CLI::success('Upgraded to level ' . $json[ 'level' ] ) ;
49
- }
50
- }
51
-
52
- /**
53
- * Send image optimization request to IAPI server
54
- *
55
- * ## OPTIONS
56
- *
57
- * ## EXAMPLES
58
- *
59
- * # Send image optimization request
60
- * $ wp lscache-iapi push
61
- *
62
- */
63
- public function push()
64
- {
65
- $msg = $this->_img_optm_instance->request_optm() ;
66
-
67
- if ( ! is_array( $msg ) ) {
68
- WP_CLI::error( $msg ) ;
69
- }
70
- else {
71
- WP_CLI::success( $msg[ 'ok' ] ) ;
72
- }
73
- }
74
-
75
- /**
76
- * Pull optimized images from IAPI server
77
- *
78
- * ## OPTIONS
79
- *
80
- * ## EXAMPLES
81
- *
82
- * # Pull images back from IAPI
83
- * $ wp lscache-iapi pull
84
- *
85
- */
86
- public function pull()
87
- {
88
- $msg = $this->_img_optm_instance->pull_img() ;
89
-
90
- if ( ! is_array( $msg ) ) {
91
- WP_CLI::error( $msg ) ;
92
- }
93
- else {
94
- WP_CLI::success( $msg[ 'ok' ] ) ;
95
- }
96
- }
97
-
98
- /**
99
- * Show optimization status based on local data
100
- *
101
- * ## OPTIONS
102
- *
103
- * ## EXAMPLES
104
- *
105
- * # Show optimization status
106
- * $ wp lscache-iapi status
107
- *
108
- */
109
- public function status()
110
- {
111
- $summary = $this->_img_optm_instance->summary_info() ;
112
- $img_count = $this->_img_optm_instance->img_count() ;
113
-
114
- if ( ! empty( $summary[ '_level_data' ] ) ) {
115
- unset( $summary[ '_level_data' ] ) ;
116
- }
117
-
118
- foreach ( array( 'reduced', 'reduced_webp' ) as $v ) {
119
- if ( ! empty( $summary[ $v ] ) ) {
120
- $summary[ $v ] = LiteSpeed_Cache_Utility::real_size( $summary[ $v ] ) ;
121
- }
122
- }
123
-
124
- if ( ! empty( $summary[ 'last_requested' ] ) ) {
125
- $summary[ 'last_requested' ] = date( 'm/d/y H:i:s', $summary[ 'last_requested' ] ) ;
126
- }
127
-
128
- $list = array() ;
129
- foreach ( $summary as $k => $v ) {
130
- $list[] = array( 'key' => $k, 'value' => $v ) ;
131
- }
132
-
133
- $list2 = array() ;
134
- foreach ( $img_count as $k => $v ) {
135
- $list2[] = array( 'key' => $k, 'value' => $v ) ;
136
- }
137
-
138
- WP_CLI\Utils\format_items( 'table', $list, array( 'key', 'value' ) ) ;
139
-
140
- WP_CLI::line( WP_CLI::colorize( "%CImages in database summary:%n" ) ) ;
141
- WP_CLI\Utils\format_items( 'table', $list2, array( 'key', 'value' ) ) ;
142
- }
143
-
144
- /**
145
- * Show optimization status based on local data
146
- *
147
- * ## OPTIONS
148
- *
149
- * ## EXAMPLES
150
- *
151
- * # Show optimization status
152
- * $ wp lscache-iapi s
153
- *
154
- */
155
- public function s()
156
- {
157
- $this->status() ;
158
- }
159
-
160
-
161
- /**
162
- * Clean up unfinished image data from IAPI server
163
- *
164
- * ## OPTIONS
165
- *
166
- * ## EXAMPLES
167
- *
168
- * # Clean up unfinished requests
169
- * $ wp lscache-iapi clean
170
- *
171
- */
172
- public function clean()
173
- {
174
- $msg = $this->_img_optm_instance->destroy_unfinished() ;
175
- WP_CLI::success( $msg ) ;
176
-
177
- WP_CLI::line( WP_CLI::colorize( "%CLatest status:%n" ) ) ;
178
-
179
- $this->status() ;
180
- }
181
-
182
- /**
183
- * Remove original image backups
184
- *
185
- * ## OPTIONS
186
- *
187
- * ## EXAMPLES
188
- *
189
- * # Remove original image backups
190
- * $ wp lscache-iapi rm_bkup
191
- *
192
- */
193
- public function rm_bkup()
194
- {
195
- $msg = $this->_img_optm_instance->rm_bkup() ;
196
- WP_CLI::success( $msg ) ;
197
- }
198
-
199
-
200
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cli/litespeed-cache-cli-purge.class.php DELETED
@@ -1,302 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Purge Interface
5
- */
6
- class LiteSpeed_Cache_Cli_Purge
7
- {
8
- /**
9
- * List all site domains and ids on the network.
10
- *
11
- * For use with the blog subcommand.
12
- *
13
- * ## EXAMPLES
14
- *
15
- * # List all the site domains and ids in a table.
16
- * $ wp lscache-purge network_list
17
- */
18
- public function network_list($args, $assoc_args)
19
- {
20
- if ( ! is_multisite() ) {
21
- WP_CLI::error('This is not a multisite installation!') ;
22
-
23
- return ;
24
- }
25
- $buf = WP_CLI::colorize("%CThe list of installs:%n\n") ;
26
-
27
- if ( version_compare($GLOBALS['wp_version'], '4.6', '<') ) {
28
- $sites = wp_get_sites() ;
29
- foreach ($sites as $site) {
30
- $buf .= WP_CLI::colorize('%Y' . $site['domain'] . $site['path'] . ':%n ID ' . $site['blog_id']) . "\n" ;
31
- }
32
- }
33
- else {
34
- $sites = get_sites() ;
35
- foreach ($sites as $site) {
36
- $buf .= WP_CLI::colorize('%Y' . $site->domain . $site->path . ':%n ID ' . $site->blog_id) . "\n" ;
37
- }
38
- }
39
-
40
- WP_CLI::line($buf) ;
41
- }
42
-
43
- /**
44
- * Sends an ajax request to the site. Takes an action and the nonce string
45
- * to perform.
46
- *
47
- * @since 1.0.14
48
- * @param string $action The action to perform
49
- * @param array $extra Any extra parameters needed to be sent.
50
- * @return mixed The http request return.
51
- */
52
- private function _send_request($action, $extra = array())
53
- {
54
- $data = array(
55
- LiteSpeed_Cache::ACTION_KEY => $action,
56
- LiteSpeed_Cache::NONCE_NAME => wp_create_nonce($action),
57
- ) ;
58
- if ( ! empty($extra) ) {
59
- $data = array_merge($data, $extra) ;
60
- }
61
-
62
- $url = admin_url('admin-ajax.php') ;
63
- WP_CLI::debug('url is ' . $url) ;
64
-
65
- $out = WP_CLI\Utils\http_request('GET', $url, $data) ;
66
- return $out ;
67
- }
68
-
69
- /**
70
- * Purges all cache entries for the blog (the entire network if multisite).
71
- *
72
- * ## EXAMPLES
73
- *
74
- * # Purge Everything associated with the WordPress install.
75
- * $ wp lscache-purge all
76
- *
77
- */
78
- public function all( $args, $assoc_args )
79
- {
80
- if ( is_multisite() ) {
81
- $action = LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE ;
82
- }
83
- else {
84
- $action = LiteSpeed_Cache::ACTION_QS_PURGE_ALL ;
85
- }
86
-
87
- $purge_ret = $this->_send_request( $action ) ;
88
-
89
- if ( $purge_ret->success ) {
90
- WP_CLI::success(__('Purged All!', 'litespeed-cache')) ;
91
- }
92
- else {
93
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
94
- }
95
- }
96
-
97
- /**
98
- * Purges all cache entries for the blog.
99
- *
100
- * ## OPTIONS
101
- *
102
- * <blogid>
103
- * : The blog id to purge
104
- *
105
- * ## EXAMPLES
106
- *
107
- * # In a multisite install, purge only the shop.example.com cache (stored as blog id 2).
108
- * $ wp lscache-purge blog 2
109
- *
110
- */
111
- public function blog($args, $assoc_args)
112
- {
113
- if ( ! is_multisite() ) {
114
- WP_CLI::error('Not a multisite installation.') ;
115
- return ;
116
- }
117
- $blogid = $args[0] ;
118
- if ( ! is_numeric($blogid) ) {
119
- $error = WP_CLI::colorize('%RError: invalid blog id entered.%n') ;
120
- WP_CLI::line($error) ;
121
- $this->network_list($args, $assoc_args) ;
122
- return ;
123
- }
124
- $site = get_blog_details($blogid) ;
125
- if ( $site === false ) {
126
- $error = WP_CLI::colorize('%RError: invalid blog id entered.%n') ;
127
- WP_CLI::line($error) ;
128
- $this->network_list($args, $assoc_args) ;
129
- return ;
130
- }
131
- switch_to_blog($blogid) ;
132
-
133
- $purge_ret = $this->_send_request(LiteSpeed_Cache::ACTION_QS_PURGE_ALL) ;
134
- if ( $purge_ret->success ) {
135
- WP_CLI::success(__('Purged the blog!', 'litespeed-cache')) ;
136
- }
137
- else {
138
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
139
- }
140
- }
141
-
142
- /**
143
- * Purges all cache tags related to a url.
144
- *
145
- * ## OPTIONS
146
- *
147
- * <url>
148
- * : The url to purge.
149
- *
150
- * ## EXAMPLES
151
- *
152
- * # Purge the front page.
153
- * $ wp lscache-purge url https://mysite.com/
154
- *
155
- */
156
- public function url($args, $assoc_args)
157
- {
158
- $data = array(
159
- LiteSpeed_Cache::ACTION_KEY => LiteSpeed_Cache::ACTION_QS_PURGE,
160
- ) ;
161
- $url = $args[0] ;
162
- $deconstructed = wp_parse_url($url) ;
163
- if ( empty($deconstructed) ) {
164
- WP_CLI::error('url passed in is invalid.') ;
165
- return ;
166
- }
167
-
168
- if ( is_multisite() ) {
169
- if ( get_blog_id_from_url($deconstructed['host'], '/') === 0 ) {
170
- WP_CLI::error('Multisite url passed in is invalid.') ;
171
- return ;
172
- }
173
- }
174
- else {
175
- $deconstructed_site = wp_parse_url( get_home_url() ) ;
176
- if ( $deconstructed['host'] !== $deconstructed_site['host'] ) {
177
- WP_CLI::error('Single site url passed in is invalid.') ;
178
- return ;
179
- }
180
- }
181
-
182
- WP_CLI::debug('url is ' . $url) ;
183
-
184
- $purge_ret = WP_CLI\Utils\http_request('GET', $url, $data) ;
185
- if ( $purge_ret->success ) {
186
- WP_CLI::success(__('Purged the url!', 'litespeed-cache')) ;
187
- }
188
- else {
189
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
190
- }
191
- }
192
-
193
- /**
194
- * Helper function for purging by ids.
195
- *
196
- * @access private
197
- * @since 1.0.15
198
- * @param array $args The id list to parse.
199
- * @param string $select The purge by kind
200
- * @param function(int $id) $callback The callback function to check the id.
201
- */
202
- private function _purgeby_helper($args, $select, $callback)
203
- {
204
- $filtered = array() ;
205
- foreach ($args as $val) {
206
- if ( ! ctype_digit($val) ) {
207
- WP_CLI::debug('[LSCACHE] Skip val, not a number. ' . $val) ;
208
- continue ;
209
- }
210
- $term = $callback($val) ;
211
- if ( ! empty($term) ) {WP_CLI::line($term->name);
212
- $filtered[] = in_array( $callback, array( 'get_tag', 'get_category' ) ) ? $term->name : $val ;
213
- }
214
- else {
215
- WP_CLI::debug('[LSCACHE] Skip val, not a valid term. ' . $val) ;
216
- }
217
- }
218
-
219
- if ( empty($filtered) ) {
220
- WP_CLI::error('Arguments must be integer ids.') ;
221
- return ;
222
- }
223
-
224
- $str = implode(',', $filtered) ;
225
-
226
- WP_CLI::line('Will purge the following cache tags: ' . $str) ;
227
-
228
- $data = array(
229
- LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT => $select,
230
- LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST => $str,
231
- ) ;
232
-
233
- $purge_ret = $this->_send_request(LiteSpeed_Cache::ACTION_PURGE_BY, $data) ;
234
- if ( $purge_ret->success ) {
235
- WP_CLI::success(__('Purged the tags!', 'litespeed-cache')) ;
236
- }
237
- else {
238
- WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code) ;
239
- }
240
-
241
- }
242
-
243
- /**
244
- * Purges cache tags for a WordPress tag
245
- *
246
- * ## OPTIONS
247
- *
248
- * <ids>...
249
- * : the Term IDs to purge.
250
- *
251
- * ## EXAMPLES
252
- *
253
- * # Purge the tag ids 1, 3, and 5
254
- * $ wp lscache-purge tag 1 3 5
255
- *
256
- */
257
- public function tag($args, $assoc_args)
258
- {
259
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_TAG, 'get_tag') ;
260
- }
261
-
262
- /**
263
- * Purges cache tags for a WordPress category
264
- *
265
- * ## OPTIONS
266
- *
267
- * <ids>...
268
- * : the Term IDs to purge.
269
- *
270
- * ## EXAMPLES
271
- *
272
- * # Purge the category ids 1, 3, and 5
273
- * $ wp lscache-purge category 1 3 5
274
- *
275
- */
276
- public function category($args, $assoc_args)
277
- {
278
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_CAT, 'get_category') ;
279
- }
280
-
281
- /**
282
- * Purges cache tags for a WordPress Post/Product
283
- *
284
- * @alias product
285
- *
286
- * ## OPTIONS
287
- *
288
- * <ids>...
289
- * : the Post IDs to purge.
290
- *
291
- * ## EXAMPLES
292
- *
293
- * # Purge the post ids 1, 3, and 5
294
- * $ wp lscache-purge post_id 1 3 5
295
- *
296
- */
297
- public function post_id($args, $assoc_args)
298
- {
299
- $this->_purgeby_helper($args, LiteSpeed_Cache_Admin_Display::PURGEBY_PID, 'get_post') ;
300
- }
301
-
302
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
cli/online.cls.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed\CLI;
3
+ defined( 'WPINC' ) || exit;
4
+
5
+ use LiteSpeed\Debug2;
6
+ use LiteSpeed\Cloud;
7
+ use WP_CLI;
8
+
9
+ /**
10
+ * QUIC.cloud API CLI
11
+ */
12
+ class Online
13
+ {
14
+ private $__cloud;
15
+
16
+ public function __construct()
17
+ {
18
+ Debug2::debug( 'CLI_Cloud init' );
19
+
20
+ $this->__cloud = Cloud::get_instance();
21
+ }
22
+
23
+ /**
24
+ * Gen key from cloud server
25
+ *
26
+ * ## OPTIONS
27
+ *
28
+ * ## EXAMPLES
29
+ *
30
+ * # Generate domain API key from Cloud server
31
+ * $ wp litespeed-online init
32
+ *
33
+ */
34
+ public function init()
35
+ {
36
+ $key = $this->__cloud->gen_key();
37
+ if ( $key ) {
38
+ WP_CLI::success( 'key = ' . $key );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Sync data from cloud server
44
+ *
45
+ * ## OPTIONS
46
+ *
47
+ * ## EXAMPLES
48
+ *
49
+ * # Sync online service usage info
50
+ * $ wp litespeed-online sync
51
+ *
52
+ */
53
+ public function sync()
54
+ {
55
+ $json = $this->__cloud->sync_usage();
56
+
57
+ WP_CLI::success( 'Sync successfully' );
58
+
59
+ $list = array();
60
+ foreach ( Cloud::$SERVICES as $v ) {
61
+ $list[] = array(
62
+ 'key' => $v,
63
+ 'used' => ! empty( $json[ 'usage.' . $v ][ 'used' ] ) ? $json[ 'usage.' . $v ][ 'used' ] : 0,
64
+ 'quota' => ! empty( $json[ 'usage.' . $v ][ 'quota' ] ) ? $json[ 'usage.' . $v ][ 'quota' ] : 0,
65
+ 'PayAsYouGo_Used' => ! empty( $json[ 'usage.' . $v ][ 'pag_used' ] ) ? $json[ 'usage.' . $v ][ 'pag_used' ] : 0,
66
+ 'PayAsYouGo_Balance' => ! empty( $json[ 'usage.' . $v ][ 'pag_bal' ] ) ? $json[ 'usage.' . $v ][ 'pag_bal' ] : 0,
67
+ );
68
+ }
69
+
70
+ WP_CLI\Utils\format_items( 'table', $list, array( 'key', 'used', 'quota', 'PayAsYouGo_Used', 'PayAsYouGo_Balance' ) );
71
+ }
72
+
73
+ /**
74
+ * List all services
75
+ *
76
+ * ## OPTIONS
77
+ *
78
+ * ## EXAMPLES
79
+ *
80
+ * # List all services tag
81
+ * $ wp litespeed-online services
82
+ *
83
+ */
84
+ public function services()
85
+ {
86
+ $list = array();
87
+ foreach ( Cloud::$SERVICES as $v ) {
88
+ $list[] = array(
89
+ 'service' => $v,
90
+ );
91
+ }
92
+
93
+ WP_CLI\Utils\format_items( 'table', $list, array( 'service' ) );
94
+ }
95
+
96
+ /**
97
+ * List all cloud servers in use
98
+ *
99
+ * ## OPTIONS
100
+ *
101
+ * ## EXAMPLES
102
+ *
103
+ * # List all cloud servers in use
104
+ * $ wp litespeed-online nodes
105
+ *
106
+ */
107
+ public function nodes()
108
+ {
109
+ $json = Cloud::get_summary();
110
+
111
+ $list = array();
112
+ foreach ( Cloud::$SERVICES as $v ) {
113
+ $list[] = array(
114
+ 'service' => $v,
115
+ 'server' => ! empty( $json[ 'server.' . $v ] ) ? $json[ 'server.' . $v ] : '',
116
+ );
117
+ }
118
+
119
+ WP_CLI\Utils\format_items( 'table', $list, array( 'service', 'server' ) );
120
+ }
121
+
122
+ /**
123
+ * Detect closest Node server for current service
124
+ *
125
+ * ## OPTIONS
126
+ *
127
+ * ## EXAMPLES
128
+ *
129
+ * # Detect closest Node for one service
130
+ * $ wp litespeed-online ping img_optm
131
+ *
132
+ */
133
+ public function ping( $param )
134
+ {
135
+ $svc = $param[ 0 ];
136
+ $json = $this->__cloud->detect_cloud( $svc );
137
+ WP_CLI::success( 'Updated closest server.' );
138
+ WP_CLI::log( 'svc = ' . $svc );
139
+ WP_CLI::log( 'node = ' . $json );
140
+ }
141
+
142
+ }
cli/option.cls.php ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed\CLI;
3
+
4
+ defined( 'WPINC' ) || exit;
5
+
6
+ use LiteSpeed\Core;
7
+ use LiteSpeed\Conf;
8
+ use LiteSpeed\Base;
9
+ use LiteSpeed\Admin_Settings;
10
+ use LiteSpeed\Import;
11
+ use LiteSpeed\Utility;
12
+ use WP_CLI;
13
+
14
+ /**
15
+ * LiteSpeed Cache option Interface
16
+ */
17
+ class Option extends Base
18
+ {
19
+ private $__cfg;
20
+
21
+ public function __construct()
22
+ {
23
+ $this->__cfg = Conf::get_instance();
24
+ }
25
+
26
+ /**
27
+ * Set an individual LiteSpeed Cache option.
28
+ *
29
+ * ## OPTIONS
30
+ *
31
+ * <key>
32
+ * : The option key to update.
33
+ *
34
+ * <newvalue>
35
+ * : The new value to set the option to.
36
+ *
37
+ * ## EXAMPLES
38
+ *
39
+ * # Set to not cache the login page
40
+ * $ wp litespeed-option set cache-priv false
41
+ * $ wp litespeed-option set 'cdn-mapping[url][0]' https://cdn.EXAMPLE.com
42
+ *
43
+ */
44
+ public function set( $args, $assoc_args )
45
+ {
46
+ /**
47
+ * Note: If the value is multiple dimensions like cdn-mapping, need to specially handle it both here and in `const.default.ini`
48
+ *
49
+ * For CDN/Crawler mutlti dimension settings, if all children are empty in one line, will delete that line. To delete one line, just set all to empty.
50
+ * E.g. to delete cdn-mapping[0], need to run below:
51
+ * `set cdn-mapping[url][0] ''`
52
+ * `set cdn-mapping[inc_img][0] ''`
53
+ * `set cdn-mapping[inc_css][0] ''`
54
+ * `set cdn-mapping[inc_js][0] ''`
55
+ * `set cdn-mapping[filetype][0] ''`
56
+ */
57
+ $key = $args[ 0 ] ;
58
+ $val = $args[ 1 ] ;
59
+
60
+ /**
61
+ * For CDN mapping, allow:
62
+ * `set 'cdn-mapping[url][0]' https://the1st_cdn_url`
63
+ * `set 'cdn-mapping[inc_img][0]' true`
64
+ * `set 'cdn-mapping[inc_img][0]' 1`
65
+ * @since 2.7.1
66
+ *
67
+ * For Crawler cookies:
68
+ * `set 'crawler-cookies[name][0]' my_currency`
69
+ * `set 'crawler-cookies[vals][0]' "USD\nTWD"`
70
+ */
71
+
72
+ // Build raw data
73
+ $raw_data = array(
74
+ Admin_Settings::ENROLL => array( $key ),
75
+ ) ;
76
+
77
+ // Contains child set
78
+ if ( strpos( $key, '[' ) ) {
79
+ parse_str( $key . '=' . $val , $key2 ) ;
80
+ $raw_data = array_merge( $raw_data, $key2 ) ;
81
+ }
82
+ else {
83
+ $raw_data[ $key ] = $val ;
84
+ }
85
+
86
+ Admin_Settings::get_instance()->save( $raw_data ) ;
87
+ WP_CLI::line( "$key:" ) ;
88
+ $this->get( $args, $assoc_args ) ;
89
+
90
+ }
91
+
92
+ /**
93
+ * Get the plugin options.
94
+ *
95
+ * ## OPTIONS
96
+ *
97
+ * ## EXAMPLES
98
+ *
99
+ * # Get all options
100
+ * $ wp litespeed-option all
101
+ *
102
+ */
103
+ public function all( $args, $assoc_args )
104
+ {
105
+ $options = $this->__cfg->get_options() ;
106
+ $option_out = array() ;
107
+
108
+ $buf = WP_CLI::colorize("%CThe list of options:%n") ;
109
+ WP_CLI::line($buf) ;
110
+
111
+ foreach( $options as $k => $v ) {
112
+ if ( $k == self::O_CDN_MAPPING || $k == self::O_CRAWLER_COOKIES ) {
113
+ foreach ( $v as $k2 => $v2 ) { // $k2 is numeric
114
+ if ( is_array( $v2 ) ) {
115
+ foreach ( $v2 as $k3 => $v3 ) { // $k3 = 'url/inc_img/name/vals'
116
+ if ( is_array( $v3 ) ) {
117
+ $option_out[] = array( 'key' => '', 'value' => '' ) ;
118
+ foreach ( $v3 as $k4 => $v4 ) {
119
+ $option_out[] = array( 'key' => $k4 == 0 ? "{$k}[$k3][$k2]" : '', 'value' => $v4 ) ;
120
+ }
121
+ $option_out[] = array( 'key' => '', 'value' => '' ) ;
122
+ }
123
+ else {
124
+ $option_out[] = array( 'key' => "{$k}[$k3][$k2]", 'value' => $v3 ) ;
125
+ }
126
+ }
127
+ }
128
+ }
129
+ continue ;
130
+ }
131
+ elseif ( is_array( $v ) && $v ) {
132
+ // $v = implode( PHP_EOL, $v ) ;
133
+ $option_out[] = array( 'key' => '', 'value' => '' ) ;
134
+ foreach ( $v as $k2 => $v2 ) {
135
+ $option_out[] = array( 'key' => $k2 == 0 ? $k : '', 'value' => $v2 ) ;
136
+ }
137
+ $option_out[] = array( 'key' => '', 'value' => '' ) ;
138
+ continue ;
139
+ }
140
+
141
+ if ( array_key_exists( $k, self::$_default_options ) && is_bool( self::$_default_options[ $k ] ) && ! $v ) {
142
+ $v = 0 ;
143
+ }
144
+
145
+ if ( $v === '' || $v === array() ) {
146
+ $v = "''" ;
147
+ }
148
+
149
+ $option_out[] = array( 'key' => $k, 'value' => $v ) ;
150
+ }
151
+
152
+ WP_CLI\Utils\format_items('table', $option_out, array('key', 'value')) ;
153
+ }
154
+
155
+ /**
156
+ * Get the plugin options.
157
+ *
158
+ * ## OPTIONS
159
+ *
160
+ * ## EXAMPLES
161
+ *
162
+ * # Get one option
163
+ * $ wp litespeed-option get cache-priv
164
+ * $ wp litespeed-option get 'cdn-mapping[url][0]'
165
+ *
166
+ */
167
+ public function get( $args, $assoc_args )
168
+ {
169
+ $id = $args[ 0 ] ;
170
+
171
+ $child = false ;
172
+ if ( strpos( $id, '[' ) ) {
173
+ parse_str( $id, $id2 ) ;
174
+ Utility::compatibility() ;
175
+ $id = array_key_first( $id2 ) ;
176
+
177
+ $child = array_key_first( $id2[ $id ] ) ; // `url`
178
+ if ( ! $child ) {
179
+ WP_CLI::error( 'Wrong child key' ) ;
180
+ return ;
181
+ }
182
+ $numeric = array_key_first( $id2[ $id ][ $child ] ) ; // `0`
183
+ if ( $numeric === null ) {
184
+ WP_CLI::error( 'Wrong 2nd level numeric key' ) ;
185
+ return ;
186
+ }
187
+ }
188
+
189
+ if ( ! isset( self::$_default_options[ $id ] ) ) {
190
+ WP_CLI::error( 'ID not exist [id] ' . $id );
191
+ return;
192
+ }
193
+
194
+ $v = Conf::val( $id ) ;
195
+ $default_v = self::$_default_options[ $id ];
196
+
197
+ /**
198
+ * For CDN_mapping and crawler_cookies
199
+ * Examples of option name:
200
+ * cdn-mapping[url][0]
201
+ * crawler-cookies[name][1]
202
+ */
203
+ if ( $id == self::O_CDN_MAPPING ) {
204
+ if ( ! in_array( $child, array(
205
+ self::CDN_MAPPING_URL,
206
+ self::CDN_MAPPING_INC_IMG,
207
+ self::CDN_MAPPING_INC_CSS,
208
+ self::CDN_MAPPING_INC_JS,
209
+ self::CDN_MAPPING_FILETYPE,
210
+ ) ) ) {
211
+ WP_CLI::error( 'Wrong child key' ) ;
212
+ return ;
213
+ }
214
+ }
215
+ if ( $id == self::O_CRAWLER_COOKIES ) {
216
+ if ( ! in_array( $child, array(
217
+ self::CRWL_COOKIE_NAME,
218
+ self::CRWL_COOKIE_VALS,
219
+ ) ) ) {
220
+ WP_CLI::error( 'Wrong child key' ) ;
221
+ return ;
222
+ }
223
+ }
224
+
225
+ if ( $id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES ) {
226
+ if ( ! empty( $v[ $numeric ][ $child ] ) ) {
227
+ $v = $v[ $numeric ][ $child ] ;
228
+ }
229
+ else {
230
+ if ( $id == self::O_CDN_MAPPING ) {
231
+ if ( in_array( $child, array(
232
+ self::CDN_MAPPING_INC_IMG,
233
+ self::CDN_MAPPING_INC_CSS,
234
+ self::CDN_MAPPING_INC_JS,
235
+ ) ) ) {
236
+ $v = 0 ;
237
+ }
238
+ else {
239
+ $v = "''" ;
240
+ }
241
+ }
242
+ else {
243
+ $v = "''" ;
244
+ }
245
+ }
246
+ }
247
+
248
+ if ( is_array( $v ) ) {
249
+ $v = implode( PHP_EOL , $v ) ;
250
+ }
251
+
252
+ if ( ! $v && $id != self::O_CDN_MAPPING && $id != self::O_CRAWLER_COOKIES ) { // empty array for CDN/crawler has been handled
253
+ if ( is_bool( $default_v ) ) {
254
+ $v = 0 ;
255
+ }
256
+ elseif ( ! is_array( $default_v ) ) {
257
+ $v = "''" ;
258
+ }
259
+ }
260
+
261
+ WP_CLI::line( $v ) ;
262
+ }
263
+
264
+ /**
265
+ * Export plugin options to a file.
266
+ *
267
+ * ## OPTIONS
268
+ *
269
+ * [--filename=<path>]
270
+ * : The default path used is CURRENTDIR/lscache_wp_options_DATE-TIME.txt.
271
+ * To select a different file, use this option.
272
+ *
273
+ * ## EXAMPLES
274
+ *
275
+ * # Export options to a file.
276
+ * $ wp litespeed-option export
277
+ *
278
+ */
279
+ public function export( $args, $assoc_args )
280
+ {
281
+ if ( isset($assoc_args['filename']) ) {
282
+ $file = $assoc_args['filename'] ;
283
+ }
284
+ else {
285
+ $file = getcwd() . '/litespeed_options_' . date('d_m_Y-His') . '.data' ;
286
+ }
287
+
288
+ if ( ! is_writable(dirname($file)) ) {
289
+ WP_CLI::error('Directory not writable.') ;
290
+ return ;
291
+ }
292
+
293
+ $data = Import::get_instance()->export( true );
294
+
295
+ if ( file_put_contents( $file, $data ) === false ) {
296
+ WP_CLI::error( 'Failed to create file.' ) ;
297
+ }
298
+ else {
299
+ WP_CLI::success('Created file ' . $file) ;
300
+ }
301
+ }
302
+
303
+ /**
304
+ * Import plugin options from a file.
305
+ *
306
+ * The file must be formatted as such:
307
+ * option_key=option_value
308
+ * One per line.
309
+ * A Semicolon at the beginning of the line indicates a comment and will be skipped.
310
+ *
311
+ * ## OPTIONS
312
+ *
313
+ * <file>
314
+ * : The file to import options from.
315
+ *
316
+ * ## EXAMPLES
317
+ *
318
+ * # Import options from CURRENTDIR/options.txt
319
+ * $ wp litespeed-option import options.txt
320
+ *
321
+ */
322
+ public function import( $args, $assoc_args )
323
+ {
324
+ $file = $args[0] ;
325
+ if ( ! file_exists($file) || ! is_readable($file) ) {
326
+ WP_CLI::error('File does not exist or is not readable.') ;
327
+ }
328
+
329
+ $res = Import::get_instance()->import( $file ) ;
330
+
331
+ if ( ! $res ) {
332
+ WP_CLI::error( 'Failed to parse serialized data from file.' ) ;
333
+ }
334
+
335
+ WP_CLI::success( 'Options imported. [File] ' . $file ) ;
336
+ }
337
+
338
+ /**
339
+ * Reset all options to default.
340
+ *
341
+ * ## EXAMPLES
342
+ *
343
+ * # Reset all options
344
+ * $ wp litespeed-option reset
345
+ *
346
+ */
347
+ public function reset()
348
+ {
349
+ Import::get_instance()->reset() ;
350
+ }
351
+
352
+ }
353
+
cli/purge.cls.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed\CLI;
3
+
4
+ defined( 'WPINC' ) || exit;
5
+
6
+ use LiteSpeed\Core;
7
+ use LiteSpeed\Router;
8
+ use LiteSpeed\Admin_Display;
9
+ use WP_CLI;
10
+
11
+
12
+ /**
13
+ * LiteSpeed Cache Purge Interface
14
+ */
15
+ class Purge
16
+ {
17
+ /**
18
+ * List all site domains and ids on the network.
19
+ *
20
+ * For use with the blog subcommand.
21
+ *
22
+ * ## EXAMPLES
23
+ *
24
+ * # List all the site domains and ids in a table.
25
+ * $ wp litespeed-purge network_list
26
+ */
27
+ public function network_list( $args )
28
+ {
29
+ if ( ! is_multisite() ) {
30
+ WP_CLI::error('This is not a multisite installation!');
31
+
32
+ return;
33
+ }
34
+ $buf = WP_CLI::colorize("%CThe list of installs:%n\n");
35
+
36
+ if ( version_compare($GLOBALS['wp_version'], '4.6', '<') ) {
37
+ $sites = wp_get_sites();
38
+ foreach ($sites as $site) {
39
+ $buf .= WP_CLI::colorize('%Y' . $site['domain'] . $site['path'] . ':%n ID ' . $site['blog_id']) . "\n";
40
+ }
41
+ }
42
+ else {
43
+ $sites = get_sites();
44
+ foreach ($sites as $site) {
45
+ $buf .= WP_CLI::colorize('%Y' . $site->domain . $site->path . ':%n ID ' . $site->blog_id) . "\n";
46
+ }
47
+ }
48
+
49
+ WP_CLI::line($buf);
50
+ }
51
+
52
+ /**
53
+ * Sends an ajax request to the site. Takes an action and the nonce string to perform.
54
+ *
55
+ * @since 1.0.14
56
+ */
57
+ private function _send_request( $action, $extra = array() )
58
+ {
59
+ $data = array(
60
+ Router::ACTION => $action,
61
+ Router::NONCE => wp_create_nonce($action),
62
+ );
63
+ if ( ! empty( $extra ) ) {
64
+ $data = array_merge( $data, $extra );
65
+ }
66
+
67
+ $url = admin_url( 'admin-ajax.php' );
68
+ WP_CLI::debug( 'URL is ' . $url );
69
+
70
+ $out = WP_CLI\Utils\http_request( 'GET', $url, $data );
71
+ return $out;
72
+ }
73
+
74
+ /**
75
+ * Purges all cache entries for the blog (the entire network if multisite).
76
+ *
77
+ * ## EXAMPLES
78
+ *
79
+ * # Purge Everything associated with the WordPress install.
80
+ * $ wp litespeed-purge all
81
+ *
82
+ */
83
+ public function all( $args )
84
+ {
85
+ if ( is_multisite() ) {
86
+ $action = Core::ACTION_QS_PURGE_EMPTYCACHE;
87
+ }
88
+ else {
89
+ $action = Core::ACTION_QS_PURGE_ALL;
90
+ }
91
+
92
+ $purge_ret = $this->_send_request( $action );
93
+
94
+ if ( $purge_ret->success ) {
95
+ WP_CLI::success(__('Purged All!', 'litespeed-cache'));
96
+ }
97
+ else {
98
+ WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Purges all cache entries for the blog.
104
+ *
105
+ * ## OPTIONS
106
+ *
107
+ * <blogid>
108
+ * : The blog id to purge
109
+ *
110
+ * ## EXAMPLES
111
+ *
112
+ * # In a multisite install, purge only the shop.example.com cache (stored as blog id 2).
113
+ * $ wp litespeed-purge blog 2
114
+ *
115
+ */
116
+ public function blog( $args )
117
+ {
118
+ if ( ! is_multisite() ) {
119
+ WP_CLI::error('Not a multisite installation.');
120
+ return;
121
+ }
122
+ $blogid = $args[0];
123
+ if ( ! is_numeric($blogid) ) {
124
+ $error = WP_CLI::colorize('%RError: invalid blog id entered.%n');
125
+ WP_CLI::line($error);
126
+ $this->network_list($args);
127
+ return;
128
+ }
129
+ $site = get_blog_details($blogid);
130
+ if ( $site === false ) {
131
+ $error = WP_CLI::colorize('%RError: invalid blog id entered.%n');
132
+ WP_CLI::line($error);
133
+ $this->network_list($args);
134
+ return;
135
+ }
136
+ switch_to_blog($blogid);
137
+
138
+ $purge_ret = $this->_send_request(Core::ACTION_QS_PURGE_ALL);
139
+ if ( $purge_ret->success ) {
140
+ WP_CLI::success(__('Purged the blog!', 'litespeed-cache'));
141
+ }
142
+ else {
143
+ WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code);
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Purges all cache tags related to a url.
149
+ *
150
+ * ## OPTIONS
151
+ *
152
+ * <url>
153
+ * : The url to purge.
154
+ *
155
+ * ## EXAMPLES
156
+ *
157
+ * # Purge the front page.
158
+ * $ wp litespeed-purge url https://mysite.com/
159
+ *
160
+ */
161
+ public function url( $args )
162
+ {
163
+ $data = array(
164
+ Router::ACTION => Core::ACTION_QS_PURGE,
165
+ );
166
+ $url = $args[0];
167
+ $deconstructed = wp_parse_url($url);
168
+ if ( empty($deconstructed) ) {
169
+ WP_CLI::error('url passed in is invalid.');
170
+ return;
171
+ }
172
+
173
+ if ( is_multisite() ) {
174
+ if ( get_blog_id_from_url($deconstructed['host'], '/') === 0 ) {
175
+ WP_CLI::error('Multisite url passed in is invalid.');
176
+ return;
177
+ }
178
+ }
179
+ else {
180
+ $deconstructed_site = wp_parse_url( get_home_url() );
181
+ if ( $deconstructed['host'] !== $deconstructed_site['host'] ) {
182
+ WP_CLI::error('Single site url passed in is invalid.');
183
+ return;
184
+ }
185
+ }
186
+
187
+ WP_CLI::debug('url is ' . $url);
188
+
189
+ $purge_ret = WP_CLI\Utils\http_request('GET', $url, $data);
190
+ if ( $purge_ret->success ) {
191
+ WP_CLI::success(__('Purged the url!', 'litespeed-cache'));
192
+ }
193
+ else {
194
+ WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code);
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Helper function for purging by ids.
200
+ *
201
+ * @access private
202
+ * @since 1.0.15
203
+ * @param array $args The id list to parse.
204
+ * @param string $select The purge by kind
205
+ * @param function(int $id) $callback The callback function to check the id.
206
+ */
207
+ private function _purgeby( $args, $select, $callback )
208
+ {
209
+ $filtered = array();
210
+ foreach ($args as $val) {
211
+ if ( ! ctype_digit($val) ) {
212
+ WP_CLI::debug('[LSCACHE] Skip val, not a number. ' . $val);
213
+ continue;
214
+ }
215
+ $term = $callback($val);
216
+ if ( ! empty($term) ) {WP_CLI::line($term->name);
217
+ $filtered[] = in_array( $callback, array( 'get_tag', 'get_category' ) ) ? $term->name : $val;
218
+ }
219
+ else {
220
+ WP_CLI::debug('[LSCACHE] Skip val, not a valid term. ' . $val);
221
+ }
222
+ }
223
+
224
+ if ( empty($filtered) ) {
225
+ WP_CLI::error('Arguments must be integer ids.');
226
+ return;
227
+ }
228
+
229
+ $str = implode(',', $filtered);
230
+
231
+ WP_CLI::line('Will purge the following cache tags: ' . $str);
232
+
233
+ $data = array(
234
+ Admin_Display::PURGEBYOPT_SELECT => $select,
235
+ Admin_Display::PURGEBYOPT_LIST => $str,
236
+ );
237
+
238
+ $purge_ret = $this->_send_request( Core::ACTION_PURGE_BY, $data );
239
+ if ( $purge_ret->success ) {
240
+ WP_CLI::success(__('Purged the tags!', 'litespeed-cache'));
241
+ }
242
+ else {
243
+ WP_CLI::error('Something went wrong! Got ' . $purge_ret->status_code);
244
+ }
245
+
246
+ }
247
+
248
+ /**
249
+ * Purges cache tags for a WordPress tag
250
+ *
251
+ * ## OPTIONS
252
+ *
253
+ * <ids>...
254
+ * : the Term IDs to purge.
255
+ *
256
+ * ## EXAMPLES
257
+ *
258
+ * # Purge the tag ids 1, 3, and 5
259
+ * $ wp litespeed-purge tag 1 3 5
260
+ *
261
+ */
262
+ public function tag($args)
263
+ {
264
+ $this->_purgeby($args, Admin_Display::PURGEBY_TAG, 'get_tag');
265
+ }
266
+
267
+ /**
268
+ * Purges cache tags for a WordPress category
269
+ *
270
+ * ## OPTIONS
271
+ *
272
+ * <ids>...
273
+ * : the Term IDs to purge.
274
+ *
275
+ * ## EXAMPLES
276
+ *
277
+ * # Purge the category ids 1, 3, and 5
278
+ * $ wp litespeed-purge category 1 3 5
279
+ *
280
+ */
281
+ public function category($args)
282
+ {
283
+ $this->_purgeby($args, Admin_Display::PURGEBY_CAT, 'get_category');
284
+ }
285
+
286
+ /**
287
+ * Purges cache tags for a WordPress Post/Product
288
+ *
289
+ * @alias product
290
+ *
291
+ * ## OPTIONS
292
+ *
293
+ * <ids>...
294
+ * : the Post IDs to purge.
295
+ *
296
+ * ## EXAMPLES
297
+ *
298
+ * # Purge the post ids 1, 3, and 5
299
+ * $ wp litespeed-purge post_id 1 3 5
300
+ *
301
+ */
302
+ public function post_id( $args )
303
+ {
304
+ $this->_purgeby($args, Admin_Display::PURGEBY_PID, 'get_post');
305
+ }
306
+
307
+ }
css/litespeed.css DELETED
@@ -1,2413 +0,0 @@
1
- /********************************* common *******************************/
2
- *[litespeed-accesskey]:before {
3
- content: '[' attr(litespeed-accesskey) '] ';
4
- }
5
-
6
- .litespeed-modal{
7
- margin-top: -8px;
8
- }
9
-
10
- .litespeed-modal .litespeed-progress{
11
- margin-left: -8px;
12
- margin-right: -8px;
13
- }
14
-
15
- .litespeed-row {
16
- display: block;
17
- margin-top: 5px;
18
- margin-left: 5px;
19
- }
20
-
21
- .litespeed-reset{
22
- width: initial;
23
- }
24
-
25
- .litespeed-inline{
26
- display: inline-block;
27
- }
28
-
29
- .litespeed-default {
30
- color: #a7a7a7!important;
31
- }
32
-
33
- .litespeed-primary {
34
- color: #3366CC!important;
35
- }
36
-
37
- .litespeed-success {
38
- color: #73b38d!important;
39
- }
40
-
41
- .litespeed-warning {
42
- color: #FF8C00!important;
43
- }
44
-
45
- .litespeed-danger {
46
- color: #dc3545!important;
47
- }
48
-
49
- .litespeed-left10 {
50
- margin-left: 10px !important;
51
- }
52
- .litespeed-left20 {
53
- margin-left: 20px !important;
54
- }
55
- .litespeed-right10 {
56
- margin-right: 10px !important;
57
- }
58
- .litespeed-right20 {
59
- margin-right: 20px !important;
60
- }
61
- .litespeed-right30 {
62
- margin-right: 30px !important;
63
- }
64
- .litespeed-right50 {
65
- margin-right: 50px !important;
66
- }
67
- .litespeed-top10 {
68
- margin-top: 10px !important;
69
- }
70
- .litespeed-top15 {
71
- margin-top: 15px !important;
72
- }
73
- .litespeed-top20 {
74
- margin-top: 20px !important;
75
- }
76
-
77
- .litespeed-top30 {
78
- margin-top: 30px !important;
79
- }
80
-
81
- .litespeed-margin-y5 {
82
- margin-top: 5px !important;
83
- margin-bottom: 5px !important;
84
- }
85
- .litespeed-margin-x5 {
86
- margin-left: 5px !important;
87
- margin-right: 5px !important;
88
- }
89
-
90
- .litespeed-wrap .litespeed-left20,
91
- .litespeed-left20 {
92
- margin-left: 20px;
93
- }
94
-
95
- .litespeed-left50 {
96
- margin-left: 50px;
97
- }
98
-
99
- .litespeed-desc {
100
- font-size: 12px;
101
- font-weight: normal;
102
- color: #9e9e9e;
103
- color: #7a919e;
104
- margin: 10px 5px;
105
- line-height: 1.7;
106
- }
107
-
108
- .litespeed-hide {
109
- display: none !important;
110
- }
111
-
112
- .litespeed-right{
113
- float:right!important;
114
- }
115
-
116
- .litespeed-relative {
117
- position: relative ;
118
- }
119
-
120
- .litespeed-wrap .litespeed-right,
121
- .litespeed-right {
122
- float: right ;
123
- }
124
-
125
- .litespeed-h3{
126
- font-family: "Open Sans", Arial, sans-serif;
127
- line-height: 18px;
128
- color: #264d73;
129
- font-size: 18px;
130
- font-weight: 600;
131
- margin: 2px 0;
132
- }
133
-
134
- .litespeed-abs-center{
135
- justify-content: center ;
136
- align-items: center ;
137
- display: flex ;
138
- flex-grow: 1 ;
139
- }
140
-
141
- .litespeed-div {
142
- display: inline-block;
143
- min-width: 100px ;
144
- }
145
-
146
- .litespeed-div .submit {
147
- margin: 5px;
148
- padding: 5px;
149
- }
150
-
151
- .litespeed-h1 {
152
- display: inline-block ;
153
- }
154
-
155
- h3 .litespeed-learn-more {
156
- font-size: 12px;
157
- font-weight: normal;
158
- color:#7a919e;
159
- margin-left: 30px;
160
- }
161
-
162
- /*show advanced options tab*/
163
-
164
- .litespeed-header .litespeed-advanced-tab-show {
165
- background: #00CC99;
166
- color: #DDF8F1 !important;
167
- font-weight: 600;
168
- border-right: 1px solid #00A37A;
169
- border-left: 1px solid #00A37A;
170
- border-top: 1px solid #00A37A;
171
- }
172
-
173
- .litespeed-header .litespeed-advanced-tab-show:hover,
174
- .litespeed-header .litespeed-advanced-tab-show:focus,
175
- .litespeed-header .litespeed-advanced-tab-show:focus:active {
176
- background: #00A37A;
177
- color: #FFFFFF !important;
178
- font-weight: 600;
179
- border-right: 1px solid #00A37A;
180
- border-left: 1px solid #00A37A;
181
- border-top: 1px solid #00A37A;
182
- border-bottom: 1px solid #00A37A;
183
- }
184
-
185
- /*hide advanced options tab*/
186
-
187
- .litespeed-header .litespeed-advanced-tab-hide {
188
- background: #99CCCC;
189
- color: #FDFDFD !important;
190
- font-weight: 600;
191
- border-left: 1px solid #7AA3A3;
192
- border-top: 1px solid #7AA3A3;
193
- border-right: 1px solid #7AA3A3;
194
- }
195
-
196
- .litespeed-header .litespeed-advanced-tab-hide:hover,
197
- .litespeed-header .litespeed-advanced-tab-hide:focus,
198
- .litespeed-header .litespeed-advanced-tab-hide:focus:active {
199
- background: #7AA3A3;
200
- color: #FFFFFF !important;
201
- font-weight: 600;
202
- border-right: 1px solid #7AA3A3;
203
- border-left: 1px solid #7AA3A3;
204
- border-top: 1px solid #7AA3A3;
205
- border-bottom: 1px solid #7AA3A3;
206
- }
207
-
208
- /********************************* logo *******************************/
209
- @font-face {
210
- font-family: 'litespeedfont';
211
- src: url('fonts/litespeedfont.eot?rs8ttq');
212
- src: url('fonts/litespeedfont.eot?rs8ttq#iefix') format('embedded-opentype'),
213
- url('fonts/litespeedfont.ttf?rs8ttq') format('truetype'),
214
- url('fonts/litespeedfont.woff?rs8ttq') format('woff'),
215
- url('fonts/litespeedfont.svg?rs8ttq#litespeedfont') format('svg');
216
- font-weight: normal;
217
- font-style: normal;
218
- }
219
-
220
- #adminmenu #toplevel_page_lscache-settings .menu-icon-generic div.wp-menu-image:before,
221
- .litespeed-top-toolbar .ab-icon::before{
222
- content: "\e900";
223
- font-family: 'litespeedfont' !important;
224
- speak: none;
225
- font-style: normal;
226
- font-weight: normal;
227
- font-variant: normal;
228
- text-transform: none;
229
- line-height: 1;
230
-
231
- /* Better Font Rendering =========== */
232
- -webkit-font-smoothing: antialiased;
233
- -moz-osx-font-smoothing: grayscale;
234
-
235
- }
236
-
237
- /********************************* layout *******************************/
238
- .litespeed-body{
239
- background: none repeat scroll 0 0 #fff;
240
- border: 1px solid #6699cc;
241
- box-shadow: 0 2px 2px rgba(0, 0, 0, 0.05);
242
- font-size: 14px;
243
- /*line-height: 2em;*/
244
- margin: 0px 0px 20px 0;
245
- overflow: auto;
246
- padding: 10px 15px 15px 15px;
247
- position: relative;
248
- color: #264d73;
249
- }
250
-
251
- .litespeed-header + .litespeed-body {
252
- border-top: none;
253
- }
254
-
255
- .litespeed-body code{
256
- color: #998c85 ;
257
- background-color: #dde9f5;
258
- border-radius: 3px;
259
- font-size: 11px;
260
- font-style: normal;
261
- }
262
-
263
- .litespeed-body ul{
264
- margin-left: 2em;
265
- }
266
-
267
- .litespeed-body i {
268
- font-size: 13px;
269
- line-height: 16px;
270
- }
271
-
272
- .litespeed-body .litespeed-desc i {
273
- font-size: 12px;
274
- }
275
-
276
- .litespeed-body p {
277
- margin: 1em ;
278
- }
279
-
280
- .litespeed-desc p {
281
- margin-left: 0;
282
- }
283
-
284
- .litespeed-title,
285
- .litespeed-title-short {
286
- font-size: 18px;
287
- font-weight: 600;
288
- color: #264d73;
289
- border-bottom: 1px solid #6699cc;
290
- margin: 35px 0px 20px 0;
291
- display: table;
292
- padding-right: 50px;
293
- padding-left: 3px;
294
- padding-bottom: 3px;
295
- }
296
-
297
- .litespeed-title a,
298
- .litespeed-title-short a {
299
- text-decoration: none;
300
- }
301
-
302
- .litespeed-title-short {
303
- padding-right: 20px;
304
- }
305
-
306
- .litespeed-text-jumbo {
307
- font-size: 3em !important;
308
- }
309
- .litespeed-text-large {
310
- font-size: .75em !important;
311
- }
312
- /********************************* nav tabs *******************************/
313
- .litespeed-wrap {
314
- margin: 10px 20px 0 2px;
315
- }
316
-
317
- .litespeed-header {
318
- border-bottom: 1px solid #6699cc;
319
- margin: 0;
320
- padding-top: 9px;
321
- padding-bottom: 0;
322
- line-height: 24px;
323
- font-size: 13px;
324
- font-weight: 600;
325
- color: #264d73;
326
- }
327
-
328
- .litespeed-header:not(.wp-clearfix):after {
329
- content: "";
330
- display: table;
331
- clear: both;
332
- }
333
-
334
- .litespeed-tab {
335
- text-decoration: none;
336
- float: left;
337
- border: 1px solid #6699cc;
338
- border-top-left-radius: 3px;
339
- border-top-right-radius: 3px;
340
- font-size: 13px;
341
- line-height: 24px;
342
- border-bottom: none;
343
- margin-left: .5em;
344
- padding: 2px 9px;
345
- min-width: 50px;
346
- background: #f9fafc;
347
- background: #f1f1f1;
348
- color: #6699cc;
349
- text-align: center;
350
- font-weight: 400;
351
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
352
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
353
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
354
- }
355
-
356
- .litespeed-tab-active {
357
- margin-bottom: -1px;
358
- color: #264d73;
359
- border-bottom: 1px solid #fff;
360
-
361
- }
362
-
363
- .litespeed-tab-active, .litespeed-tab-active:focus, .litespeed-tab-active:focus:active, .litespeed-tab-active:hover {
364
- border-bottom: 1px solid #fff;
365
- background: #fff;
366
- color: #264d73;
367
- }
368
-
369
- .litespeed-tab-active, .litespeed-tab:focus:active {
370
- -webkit-box-shadow: none;
371
- box-shadow: none;
372
- font-size: 13px;
373
- color: #264d73;
374
- }
375
-
376
- .litespeed-tab:focus, .litespeed-tab:hover {
377
- background-color: #fff;
378
- color: #264d73;
379
- -moz-box-shadow: none;
380
- -webkit-box-shadow: none;
381
- box-shadow: none;
382
- font-size: 13px;
383
- border-bottom: 1px solid #fff;
384
- margin-bottom: -1px;
385
- }
386
-
387
- /********************************* panel *******************************/
388
- .litespeed-panel-wrapper {
389
- display: flex;
390
- width: 100%;
391
- flex-flow: row wrap;
392
- justify-content: flex-start;
393
- }
394
-
395
- .litespeed-panel {
396
- text-decoration: none;
397
- display: flex;
398
- justify-content: space-between;
399
- border: 1px solid #6699cc;
400
- -moz-box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
401
- -webkit-box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
402
- box-shadow: 0 0 0 1px rgba(102, 153, 204, 0.25);
403
- border-radius: 3px;
404
- background: #f9fafc;
405
- padding: 6px 0px 4px 5px;
406
- width: 310px;
407
- margin: 15px 5px 15px 15px;
408
- min-height: 75px;
409
- }
410
-
411
- .litespeed-panel:hover {
412
- color: #538ac6;
413
- border: 1px solid #00a3cc;
414
- background: #fff;
415
- -moz-box-shadow: none;
416
- -webkit-box-shadow: none;
417
- box-shadow: none;
418
- }
419
-
420
- .litespeed-panel-wrapper-icon {
421
- width: 25%;
422
- height:100%;
423
- }
424
-
425
- [class*="litespeed-panel-icon-"] {
426
- background-size: contain;
427
- width: 60px;
428
- height: 60px;
429
- margin: 5px;
430
- background-repeat: no-repeat;
431
- display: inline-block;
432
- }
433
-
434
- .litespeed-panel-icon-all { background-image: url("../img/icons/all.svg") ; }
435
- .litespeed-panel-icon-revision { background-image: url("../img/icons/revision.svg") ; }
436
- .litespeed-panel-icon-auto_draft { background-image: url("../img/icons/auto_draft.svg") ; }
437
- .litespeed-panel-icon-trash_post { background-image: url("../img/icons/trash_post.svg") ; }
438
- .litespeed-panel-icon-spam_comment { background-image: url("../img/icons/spam_comment.svg") ; }
439
- .litespeed-panel-icon-trash_comment { background-image: url("../img/icons/trash_comment.svg") ; }
440
- .litespeed-panel-icon-trackback-pingback{ background-image: url("../img/icons/trackback-pingback.svg") ; }
441
- .litespeed-panel-icon-expired_transient { background-image: url("../img/icons/expired_transient.svg") ; }
442
- .litespeed-panel-icon-all_transients { background-image: url("../img/icons/all_transients.svg") ; }
443
- .litespeed-panel-icon-all_cssjs { background-image: url("../img/icons/purge-cssjs.svg") ; }
444
- .litespeed-panel-icon-optimize_tables { background-image: url("../img/icons/optimize_tables.svg") ; }
445
- .litespeed-panel-icon-purge-front { background-image: url("../img/icons/purge-front.svg") ; }
446
- .litespeed-panel-icon-purge-pages { background-image: url("../img/icons/purge-pages.svg") ; }
447
- .litespeed-panel-icon-purge-cssjs { background-image: url("../img/icons/purge-cssjs.svg") ; }
448
- .litespeed-panel-icon-purge-object { background-image: url("../img/icons/purge-object.svg") ; }
449
- .litespeed-panel-icon-purge-opcache { background-image: url("../img/icons/purge-opcache.svg") ; }
450
- .litespeed-panel-icon-purge-all { background-image: url("../img/icons/purge-all.svg") ; }
451
- .litespeed-panel-icon-empty-cache { background-image: url("../img/icons/empty-cache.svg") ; }
452
- .litespeed-panel-icon-purge-403 { background-image: url("../img/icons/purge-403.svg") ; }
453
- .litespeed-panel-icon-purge-404 { background-image: url("../img/icons/purge-404.svg") ; }
454
- .litespeed-panel-icon-purge-500 { background-image: url("../img/icons/purge-500.svg") ; }
455
- .litespeed-panel-top-right-icon-cross { background-image: url("../img/icons/cross_icon.svg") ; }
456
- .litespeed-panel-top-right-icon-tick { background-image: url("../img/icons/success_icon.svg") ; }
457
-
458
-
459
- .litespeed-panel-content {
460
- width: 75%;
461
- height:100%;
462
- margin-top: 10px;
463
- }
464
-
465
- .litespeed-panel-para {
466
- font-family: "Open Sans", Arial, sans-serif;
467
- line-height: 18px;
468
- color: #264d73;
469
- }
470
-
471
- .litespeed-panel .litespeed-h3{
472
- font-size: 14px;
473
- }
474
-
475
- .litespeed-panel-counter {
476
- color: #3abfbf;
477
- }
478
-
479
- .litespeed-panel-counter-red {
480
- color: #cc3d6a ;
481
- }
482
-
483
- .litespeed-panel-para {
484
- margin-top: -12px;
485
- font-size: 13px;
486
- }
487
-
488
- .litespeed-panel-wrapper-top-right {
489
- width: 10%;
490
- height:100%;
491
- }
492
-
493
- .litespeed-panel-top-right-icon-tick,
494
- .litespeed-panel-top-right-icon-cross {
495
- background-size: contain;
496
- width: 20px;
497
- height: 20px;
498
- background-repeat: no-repeat;
499
- display: inline-block;
500
- }
501
-
502
- /********************************* btn *******************************/
503
- .litespeed [class*="litespeed-btn-"],
504
- .litespeed-wrap [class*="litespeed-btn-"],
505
- [class*="litespeed-btn-"] {
506
- padding: 5px 10px;
507
- font-size: 14px !important;
508
- font-weight:400;
509
- border-radius: 3px;
510
- margin: 15px 5px;
511
- text-align: center;
512
- background: #fff;
513
- cursor: pointer;
514
- text-decoration: none;
515
- display: inline-block;
516
- height: initial;
517
- }
518
-
519
- .litespeed [class*="litespeed-btn-"]:hover,
520
- .litespeed-wrap [class*="litespeed-btn-"]:hover,
521
- [class*="litespeed-btn-"]:hover {
522
- font-weight: 400;
523
- color: #fff;
524
- -moz-box-shadow: none;
525
- -webkit-box-shadow: none;
526
- box-shadow: none;
527
- }
528
-
529
- .litespeed .litespeed-btn-danger,
530
- .litespeed-wrap .litespeed-btn-danger,
531
- .litespeed-btn-danger {
532
- color: #cc3d6a;
533
- border: 1px solid #cc3d6a;
534
- -moz-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
535
- -webkit-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
536
- box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
537
- }
538
-
539
- .litespeed .litespeed-btn-danger:hover,
540
- .litespeed-wrap .litespeed-btn-danger:hover,
541
- .litespeed-btn-danger:hover {
542
- background: #cc3d6a;
543
- }
544
-
545
- .litespeed .litespeed-btn-warning,
546
- .litespeed-wrap .litespeed-btn-warning,
547
- .litespeed-btn-warning {
548
- color: #e59544;
549
- border: 1px solid #e59544;
550
- -moz-box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
551
- -webkit-box-shadow: 00 0 0 1px rgba(230, 150, 69, 0.25);
552
- box-shadow: 0 0 0 1px rgba(230, 150, 69, 0.25);
553
- }
554
-
555
- .litespeed .litespeed-btn-warning:hover,
556
- .litespeed-wrap .litespeed-btn-warning:hover,
557
- .litespeed-btn-warning:hover {
558
- background: #e59544;
559
- }
560
-
561
- .litespeed .litespeed-btn-success,
562
- .litespeed-wrap .litespeed-btn-success,
563
- .litespeed-btn-success {
564
- color: #36b0b0;
565
- border: 1px solid #36b0b0;
566
- -moz-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
567
- -webkit-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
568
- box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
569
- }
570
-
571
- .litespeed .litespeed-btn-success:hover,
572
- .litespeed-wrap .litespeed-btn-success:hover,
573
- .litespeed-btn-success:hover {
574
- background: #36b0b0;
575
- }
576
-
577
- .litespeed .litespeed-btn-primary,
578
- .litespeed-wrap .litespeed-btn-primary,
579
- .litespeed-btn-primary {
580
- color: #538ac6;
581
- border: 1px solid #538ac6;
582
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
583
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
584
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
585
- }
586
-
587
- .litespeed .litespeed-btn-primary:hover,
588
- .litespeed-wrap .litespeed-btn-primary:hover,
589
- .litespeed-btn-primary:hover {
590
- background: #538ac6;
591
- border-color: #538ac6;
592
- }
593
-
594
- .litespeed .litespeed-btn-default,
595
- .litespeed-wrap .litespeed-btn-default,
596
- .litespeed-btn-default {
597
- color: #a7a7a7;
598
- border: 1px solid #a7a7a7;
599
- -moz-box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
600
- -webkit-box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
601
- box-shadow: 0 0 0 1px rgba(158, 158, 158, 0.25);
602
- }
603
-
604
- .litespeed .litespeed-btn-default:hover,
605
- .litespeed-wrap .litespeed-btn-default:hover,
606
- .litespeed-btn-default:hover {
607
- background: #a7a7a7;
608
- }
609
-
610
- .litespeed .litespeed-btn-default.disabled:hover,
611
- .litespeed-wrap .litespeed-btn-default.disabled:hover,
612
- .litespeed-btn-default.disabled:hover {
613
- color: #a7a7a7;
614
- background: #fff;
615
- }
616
-
617
- .litespeed-btn-default.active{
618
- color: #333;
619
- background-color: #e6e6e6;
620
- border-color: #adadad;
621
- }
622
-
623
- .litespeed .litespeed-btn-xs,
624
- .litespeed-wrap .litespeed-btn-xs,
625
- .litespeed-btn-xs {
626
- padding: 1px 8px;
627
- font-size: 13px;
628
- line-height: 1.5;
629
- border-radius: 2px;
630
- min-width: 100px;
631
- }
632
-
633
- .litespeed .litespeed-btn-tiny,
634
- .litespeed-wrap .litespeed-btn-tiny,
635
- .litespeed-btn-tiny {
636
- padding: 1px 8px;
637
- font-size: 13px;
638
- line-height: 1.5;
639
- border-radius: 2px;
640
- min-width: 14px ;
641
- }
642
-
643
- .litespeed-wrap .litespeed-btn-mini {
644
- padding: 2px 5px !important;
645
- font-size: 12px !important;
646
- font-weight: 600 !important;
647
- margin: 5px !important;
648
- }
649
-
650
-
651
- /********************************* switch *******************************/
652
- .litespeed-switch {
653
- border: 1px solid #538ac6;
654
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
655
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
656
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
657
- border-radius: 3px;
658
- font-size: 14px;
659
- font-weight: 600;
660
- margin: 0 0 0 ;
661
- background-color: #fff;
662
- padding: -1px;
663
- display: inline-block;
664
- position: relative;
665
- }
666
-
667
- .litespeed-switch input:checked + label {
668
- background-color: #36b0b0;
669
- color: #fff;
670
- font-weight: 600;
671
- border: 1px solid #36b0b0;
672
- }
673
-
674
- .litespeed-switch label {
675
- font-size: 14px;
676
- display: inline-block;
677
- min-width: 75px;
678
- background-color: #fff;
679
- color: #6699cc;
680
- font-weight: 400;
681
- text-align: center;
682
- padding: 5px 9px;
683
- cursor: pointer;
684
- border: 1px solid #f9fafc;
685
- position: relative;
686
- }
687
-
688
- .litespeed-switch input:hover + label,
689
- .litespeed-switch input:focus + label {
690
- background-color: #f9fafc;
691
- font-weight: 400;
692
- color: #538ac6;
693
- outline: 2px solid #538ac6;
694
- }
695
-
696
- .litespeed-switch input:checked:hover + label,
697
- .litespeed-switch input:checked:focus + label {
698
- background-color: #36b0b0;
699
- color: #fff;
700
- font-weight: 600;
701
- }
702
-
703
- .litespeed-switch input {
704
- display: inline-block;
705
- position: absolute;
706
- z-index: -1;
707
- }
708
-
709
- .litespeed-cache-purgeby-text {
710
- font-size: 13px;
711
- padding-left: 20px;
712
- display: inline-block;
713
- vertical-align: top;
714
- margin-top: 5px;
715
- }
716
-
717
-
718
- /********************************* switch drag *******************************/
719
- .litespeed-switch-drag {
720
- position: relative;
721
- width: 100px;
722
- -webkit-user-select:none;
723
- -moz-user-select:none;
724
- -ms-user-select: none;
725
- border: 1px solid #538ac6;
726
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
727
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
728
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
729
- border-radius: 3px;
730
- display: inline-block;
731
- }
732
-
733
- .litespeed-switch-drag input {
734
- display: none;
735
- }
736
-
737
- .litespeed-switch-drag-label {
738
- display: block;
739
- overflow: hidden;
740
- cursor: pointer;
741
- }
742
-
743
- .litespeed-switch-drag-inner {
744
- display: block;
745
- width: 200%;
746
- margin-left: -100%;
747
- transition: margin 0.1s ease-in 0s;
748
- }
749
-
750
- .litespeed-switch-drag-inner:before, .litespeed-switch-drag-inner:after {
751
- display: block;
752
- float: left;
753
- width: 50%;
754
- height: 25px;
755
- padding: 0;
756
- line-height: 25px;
757
- font-size: 13px;
758
- color: #fff;
759
- font-weight: 600;
760
- box-sizing: border-box;
761
- -moz-box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
762
- -webkit-box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
763
- box-shadow: inset 0 0 1px 2px rgba(38, 77, 115, .15);
764
- }
765
-
766
- .litespeed-switch-drag-inner:before {
767
- content: attr(data-on);
768
- padding-left: 10px;
769
- background-color: #36b0b0;
770
- color: #FFFFFF;
771
-
772
- }
773
-
774
- .litespeed-switch-drag-inner:after {
775
- content: attr(data-off);
776
- padding-right: 8px;
777
- background-color: #f9fafc;
778
- color: #6699cc;
779
- text-align: right;
780
- font-weight: 400;
781
- }
782
-
783
- .litespeed-switch-drag-switch {
784
- display: block;
785
- width: 25px;
786
- margin: 0px;
787
- background: #F9FAFC;
788
- position: absolute;
789
- top: 0;
790
- bottom: 0;
791
- right: 73px;
792
- border: 1px solid #6699CC;
793
- border-radius: 2px;
794
- -moz-box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
795
- -webkit-box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
796
- box-shadow: 0 0 1px 1px rgba(102, 153, 204, 0.5);
797
- transition: all 0.1s ease-in 0s;
798
- }
799
-
800
- .litespeed-switch-drag input:checked + .litespeed-switch-drag-label .litespeed-switch-drag-inner {
801
- margin-left: 0;
802
- }
803
-
804
- .litespeed-switch-drag input:checked + .litespeed-switch-drag-label .litespeed-switch-drag-switch {
805
- right: 0px;
806
- }
807
-
808
- .litespeed-list li:before {
809
- content: '>' ;
810
- color: #cc3d6a ;
811
- }
812
-
813
- /********************************* label *******************************/
814
- [class*="litespeed-label-"] {
815
- display: inline;
816
- padding: .2em .6em .3em;
817
- font-size: 75%;
818
- font-weight: bold;
819
- line-height: 1;
820
- color: #fff;
821
- text-align: center;
822
- white-space: nowrap;
823
- vertical-align: baseline;
824
- border-radius: .25em;
825
- }
826
- [class*="litespeed-label-"]:hover,
827
- [class*="litespeed-label-"]:focus {
828
- color: #fff;
829
- text-decoration: none;
830
- cursor: pointer;
831
- }
832
- [class*="litespeed-label-"]:empty {
833
- display: none;
834
- }
835
- .litespeed-label-default {
836
- background-color: #777;
837
- }
838
- .litespeed-label-default[href]:hover,
839
- .litespeed-label-default[href]:focus {
840
- background-color: #5e5e5e;
841
- }
842
- .litespeed-label-primary {
843
- background-color: #337ab7;
844
- }
845
- .litespeed-label-primary[href]:hover,
846
- .litespeed-label-primary[href]:focus {
847
- background-color: #286090;
848
- }
849
- .litespeed-label-success {
850
- background-color: #5cb85c;
851
- }
852
- .litespeed-label-success[href]:hover,
853
- .litespeed-label-success[href]:focus {
854
- background-color: #449d44;
855
- }
856
- .litespeed-label-info {
857
- background-color: #5bc0de;
858
- }
859
- .litespeed-label-info[href]:hover,
860
- .litespeed-label-info[href]:focus {
861
- background-color: #31b0d5;
862
- }
863
- .litespeed-label-warning {
864
- background-color: #f0ad4e;
865
- }
866
- .litespeed-label-warning[href]:hover,
867
- .litespeed-label-warning[href]:focus {
868
- background-color: #ec971f;
869
- }
870
- .litespeed-label-danger {
871
- background-color: #d9534f;
872
- }
873
- .litespeed-label-danger[href]:hover,
874
- .litespeed-label-danger[href]:focus {
875
- background-color: #c9302c;
876
- }
877
-
878
- /********************************* shell *******************************/
879
- .litespeed-shell {
880
- width: 98%;
881
- background: #141414;
882
- margin: 20px auto 0 10px;
883
- box-shadow: 0 0 5px rgba(0,0,0,0.4);
884
- -webkit-border-radius: 3px;
885
- -moz-border-radius: 3px;
886
- border-radius: 3px;
887
- position: relative;
888
- height: 224px;
889
- }
890
-
891
- .litespeed-shell-header {
892
- z-index: 999;
893
- position: absolute;
894
- top: 0;
895
- right: 0;
896
- width: 50px;
897
- height: 34px;
898
- padding: 5px 0;
899
- }
900
-
901
- .litespeed-shell-header-bg {
902
- opacity: 0.4;
903
- background-color: #CCCCCC;
904
- position: absolute;
905
- top: 0;
906
- bottom: 0;
907
- right: 0;
908
- left: 0;
909
- z-index: 4;
910
- -webkit-border-radius: 3px;
911
- -moz-border-radius: 3px;
912
- border-top-radius: 3px;
913
- }
914
-
915
- .litespeed-shell-header-bar {
916
- position: absolute;
917
- top: 0;
918
- left: 0;
919
- z-index: 10;
920
- height: 2px;
921
- background-color: #F48024;
922
- }
923
-
924
- /*.litespeed-shell-header-num{
925
- position: absolute;
926
- bottom: 2px;
927
- right: 2px;
928
- width: 14px;
929
- height: 14px;
930
- text-align: left;
931
- color: #808080;
932
- font-size: 0.85em;
933
- z-index: 5;
934
- display: none;
935
- }*/
936
-
937
- .litespeed-shell-header-icon-container{
938
- position: absolute;
939
- top: 10px;
940
- right: 10px;
941
- width: 29px;
942
- height: 34px;
943
- z-index: 6;
944
- }
945
-
946
- ul.litespeed-shell-body {
947
- position: absolute;
948
- top: 0;
949
- left: 0;
950
- right: 0;
951
- bottom: 0;
952
- overflow-y: scroll;
953
- margin: 0;
954
- padding: 5px;
955
- list-style: none;
956
- background: #141414;
957
- color: #45D40C;
958
- font: 0.8em 'Andale Mono', Consolas, 'Courier New';
959
- line-height: 1.6em;
960
-
961
- -webkit-border-bottom-right-radius: 3px;
962
- -webkit-border-bottom-left-radius: 3px;
963
- -moz-border-radius-bottomright: 3px;
964
- -moz-border-radius-bottomleft: 3px;
965
- border-bottom-right-radius: 3px;
966
- border-bottom-left-radius: 3px;
967
-
968
- }
969
-
970
- .litespeed-shell-body li:before {
971
- content: '>';
972
- position: absolute;
973
- left: 0;
974
- top: 0;
975
- }
976
-
977
- .litespeed-shell-body li {
978
- word-wrap: break-word;
979
- position: relative;
980
- padding: 0 0 0 15px;
981
- margin: 0;
982
- }
983
-
984
- .litespeed-widget-setting{
985
- background-color: #ecebdc;
986
- padding: 5px 14px;
987
- margin: 5px -15px;
988
- }
989
-
990
-
991
- /********************************* callout *******************************/
992
- [class*="litespeed-callout-"] {
993
- padding: 15px 25px 20px 20px;
994
- border: 1px solid #6699cc;
995
- border-radius: 3px;
996
- line-height: 18px;
997
- border-left-color: #6699cc;
998
- border-left-width: 5px;
999
- color: #538ac6;
1000
- margin: 13px 0;
1001
- background: #f2f9ff;
1002
- }
1003
-
1004
- [class*="litespeed-callout-"] h4 {
1005
- margin-top: 0;
1006
- margin-bottom: 8px;
1007
- font-size: 14px;
1008
- font-family: inherit;
1009
- font-weight: 500;
1010
- line-height: 1.1;
1011
- }
1012
-
1013
- [class*="litespeed-callout-"] p {
1014
- margin-bottom: 0;
1015
- }
1016
-
1017
- [class*="litespeed-callout-"] ol {
1018
- padding-left: 15px;
1019
- margin-left: 10px;
1020
- margin-bottom: 0;
1021
- }
1022
-
1023
- .litespeed-callout-warning h4 {
1024
- color: #e59544;
1025
- }
1026
-
1027
- .litespeed-callout-warning {
1028
- border-left-color: #e59544 !important;
1029
- border-left-width: 5px;
1030
- }
1031
-
1032
- .litespeed-callout-danger h4 {
1033
- color: #cc3d6a;
1034
- }
1035
-
1036
- .litespeed-callout-danger {
1037
- border-left-color: #cc3d6a !important;
1038
- border-left-width: 5px;
1039
- }
1040
-
1041
- /********************************* inline table *******************************/
1042
- .litespeed-body table {
1043
- background: #fff;
1044
- padding: 10px;
1045
- word-wrap: break-word;
1046
- -webkit-font-smoothing: subpixel-antialiased;
1047
- border-spacing: 0;
1048
- width: 100%;
1049
- clear: both;
1050
- }
1051
-
1052
- .litespeed-body table thead tr th{
1053
- color: #264d73;
1054
- padding-left: 10px;
1055
- }
1056
-
1057
- .litespeed-table {
1058
- border: 1px solid #538ac6;
1059
- border-radius: 3px;
1060
- }
1061
-
1062
- /********************************* small table *******************************/
1063
- .litespeed-body .litespeed-vary-table {
1064
- margin-top: -15px;
1065
- padding-left: 0;
1066
- width: 250px;
1067
- }
1068
-
1069
- .litespeed-body .litespeed-vary-table tr {
1070
- width: 200px;
1071
- }
1072
-
1073
- .litespeed-body .litespeed-vary-table tr:first-child td {
1074
- /* border-top: 1px solid #cccccc; */
1075
- }
1076
- .litespeed-body .litespeed-vary-table .litespeed-vary-title {
1077
- width: 50%;
1078
- /* border-bottom: 1px solid #cccccc;
1079
- border-right: 1px solid #cccccc;*/
1080
- }
1081
- .litespeed-body .litespeed-vary-table .litespeed-vary-val {
1082
- /* border-bottom: 1px solid #cccccc;*/
1083
- }
1084
-
1085
-
1086
- /********************************* tick checkbox *******************************/
1087
- .litespeed-tick {
1088
- display: inline-block;
1089
- min-width: 125px;
1090
- background: #f2f9ff;
1091
- padding: 5px 0 5px 0px;
1092
- border-radius: 3px;
1093
- cursor: pointer;
1094
- margin: 5px;
1095
- }
1096
-
1097
- .litespeed-tick input[type="checkbox"] {
1098
- height: 18px;
1099
- width: 18px;
1100
- vertical-align: middle;
1101
- margin: 0 10px 0 20px;
1102
- border: 1px solid #538ac6;
1103
- -webkit-appearance: none;
1104
- -moz-appearance: none;
1105
- appearance: none;
1106
- -webkit-border-radius: 3px;
1107
- border-radius: 3px;
1108
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1109
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1110
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1111
- cursor: pointer;
1112
- }
1113
-
1114
- .litespeed-tick input[type="checkbox"]:not(:disabled):hover {
1115
- border-color: #538ac6;
1116
-
1117
- }
1118
-
1119
- .litespeed-tick input[type="checkbox"]:active:not(:disabled) {
1120
- border-color: #538ac6;
1121
- }
1122
-
1123
- .litespeed-tick input[type="checkbox"]:focus {
1124
- outline:none;
1125
- }
1126
-
1127
- .litespeed-tick input[type="checkbox"]:checked {
1128
- border-color: #538ac6;
1129
- background-color: #538ac6;
1130
- -moz-box-shadow: none;
1131
- -webkit-box-shadow: none;
1132
- box-shadow: none;
1133
- }
1134
-
1135
- .litespeed-tick input[type="checkbox"]:checked:before {
1136
- content: '';
1137
- display: block;
1138
- width: 5px;
1139
- height: 11px;
1140
- border: solid #fff;
1141
- border-width: 0 2px 2px 0;
1142
- -webkit-transform: rotate(45deg);
1143
- transform: rotate(45deg);
1144
- margin-left: 5px;
1145
- margin-top: -1px;
1146
- cursor: pointer;
1147
- }
1148
-
1149
- .litespeed-tick label {
1150
- padding: 2px 5px 10px 15px;
1151
- font-size: 14px;
1152
- color: #264d73;
1153
- }
1154
-
1155
- .litespeed-tick label:hover {
1156
- min-width: 115px;
1157
- color: #6699cc;
1158
- }
1159
-
1160
-
1161
- /********************************* vertical radio *******************************/
1162
-
1163
- .litespeed-radio-vertical {
1164
- border-left: 1px solid #538ac6;
1165
- height: 100%;
1166
- margin-left: 8px;
1167
- display: inline-block;
1168
- min-width: 150px;
1169
- background: #f9fafc;
1170
- padding: 5px 0 5px 0px;
1171
- border-radius: 3px;
1172
- cursor: pointer;
1173
- }
1174
-
1175
- .litespeed-radio-vertical label {
1176
- min-width: 115px;
1177
- padding: 3px 10px 6px 8px;
1178
- }
1179
-
1180
- .litespeed-radio-vertical label:hover {
1181
- min-width: 115px;
1182
- color: #6699cc;
1183
- padding: 3px 10px 6px 8px;
1184
- }
1185
-
1186
-
1187
- .litespeed-radio-vertical-row {
1188
- margin: 20px 10px 25px 0px;
1189
- width: 100%;
1190
- }
1191
-
1192
- .litespeed-radio-vertical-row input {
1193
- height: 15.5px;
1194
- min-width: 15px;
1195
- vertical-align: middle;
1196
- margin: -2px 0 0 -8px;
1197
- border: 1px solid #538ac6;
1198
- -webkit-appearance: none;
1199
- -moz-appearance:none;
1200
- appearance: none;
1201
- background: #fff;
1202
- -moz-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1203
- -webkit-box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1204
- box-shadow: 0 0 0 1px rgba(83, 138, 198, 0.25);
1205
- -webkit-border-radius: 50% !important;
1206
- border-radius: 50% !important;
1207
- cursor: pointer;
1208
- }
1209
-
1210
- .litespeed-radio-vertical-row input:not(:disabled):hover {
1211
- border-color: #538ac6;
1212
- -moz-box-shadow: inset 0 0 1px 3px #36b0b0;
1213
- -webkit-box-shadow: inset 0 1px 3px #36b0b0;
1214
- box-shadow: inset 0 0 1px 3px #36b0b0;
1215
-
1216
- }
1217
-
1218
- .litespeed-radio-vertical-row input:active:not(:disabled) {
1219
- border-color: #538ac6;
1220
- }
1221
-
1222
- .litespeed-radio-vertical-row input:focus {
1223
- outline:none;
1224
- }
1225
-
1226
- .litespeed-radio-vertical-row input:checked {
1227
- border-color: #538ac6;
1228
- -moz-box-shadow: inset 0 0 0.5px 3px #fff;
1229
- -webkit-box-shadow: inset 0 0 0.5px 3px #fff;
1230
- box-shadow: inset 0 0 0.5px 3px #fff;
1231
- background: #36b0b0;
1232
- }
1233
-
1234
- .litespeed-radio-vertical-row input:checked:before {
1235
- /*content: '\25CF';
1236
- font-size: 16px;*/
1237
- text-indent: -9999px;
1238
- -webkit-border-radius: 50px;
1239
- border-radius: 50px;
1240
- font-size: 24px;
1241
- width: 6px;
1242
- height: 6px;
1243
- margin: 4px;
1244
- line-height: 16px;
1245
- }
1246
-
1247
- /********************************* enterprise notice *******************************/
1248
- .litespeed-ent-notice {
1249
- position: absolute ;
1250
- left: 0 ;
1251
- top: 0 ;
1252
- right: 0 ;
1253
- bottom: 0 ;
1254
- background-color: #333 ;
1255
- z-index: 999 ;
1256
- opacity: 0.8 ;
1257
- text-align: center ;
1258
- font-size: 3rem ;
1259
- color: #1865c5 ;
1260
- }
1261
-
1262
- .litespeed-ent-notice-desc {
1263
- position: relative ;
1264
- top: 30% ;
1265
- transform: rotate(-20deg) ;
1266
- text-shadow: 2px 2px 4px #000000 ;
1267
- }
1268
-
1269
- /********************************* promo banner *******************************/
1270
- .litespeed-banner-promo,
1271
- .litespeed-banner-promo-full{
1272
- display: flex;
1273
- padding: 0px;
1274
- }
1275
-
1276
- .litespeed-banner-promo-full{
1277
- margin:0px;
1278
- padding: 0px;
1279
- }
1280
-
1281
- .litespeed-banner-promo-logo {
1282
- background-image: url(../img/lscwp-logo_90x90.png);
1283
- background-size: contain;
1284
- width: 90px;
1285
- background-repeat: no-repeat;
1286
- display: inline-block;
1287
- }
1288
-
1289
- .litespeed-banner-promo-full .litespeed-banner-promo-logo {
1290
- margin: 0px;
1291
- width: 90px;
1292
- height: 90px;
1293
- }
1294
-
1295
- .litespeed-banner-promo-content{
1296
- margin-left: 25px;
1297
- }
1298
-
1299
- .litespeed-banner-promo-full .litespeed-banner-promo-content {
1300
- width: 75%;
1301
- }
1302
-
1303
- .litespeed-banner-promo-content h1{
1304
- font-weight: 600;
1305
- color:#538ac6;
1306
- margin-top: 10px;
1307
- }
1308
-
1309
- .litespeed-banner-title {
1310
- font-size: 1.3em;
1311
- margin: 8px 0px 5px 0px;
1312
- }
1313
-
1314
- .litespeed-banner-promo-slacklogo{
1315
- background-image: url("../img/slack-logo.png") ;
1316
- background-size: contain;
1317
- width: 75px;
1318
- height: 75px;
1319
- background-repeat: no-repeat;
1320
- display: inline-block;
1321
- padding:0px;
1322
- flex: 0 0 5%;
1323
- }
1324
-
1325
- .litespeed-banner-promo .litespeed-banner-promo-slack-line1{
1326
- font-size: 18px;
1327
- margin-top:0px;
1328
- line-height: 21px;
1329
- }
1330
-
1331
- .litespeed-banner-promo .litespeed-banner-promo-slack-textlink{
1332
- color: #e59544;
1333
- text-decoration: none;
1334
- }
1335
-
1336
- .litespeed-banner-promo .litespeed-banner-promo-slack-textlink:hover{
1337
- opacity: 0.8;
1338
- }
1339
-
1340
- .litespeed-banner-promo-slack-line2{
1341
- font-size: 15px;
1342
- margin: 0px;
1343
- line-height: .75em;
1344
- }
1345
-
1346
- .litespeed-banner-promo-slack-link{
1347
- color: #888888;
1348
- }
1349
-
1350
- a.litespeed-btn-xs.litespeed-banner-promo-slack-btn{
1351
- margin:0px 5px;
1352
- }
1353
-
1354
- /********************************* admin -> media lib icon *******************************/
1355
- .litespeed-media-href {
1356
- display: inline-table;
1357
- }
1358
-
1359
-
1360
- [class*="litespeed-icon-media-"] {
1361
- background-size: contain;
1362
- width: 25px;
1363
- height: 25px;
1364
- vertical-align: middle;
1365
- margin: 0;
1366
- background-repeat: no-repeat;
1367
- display: inline-block;
1368
- }
1369
-
1370
- [class*="litespeed-icon-media-"]:hover {
1371
- opacity: 0.7 ;
1372
- }
1373
-
1374
- .litespeed-icon-media-webp { background-image: url("../img/icons/img_webp.svg") ; }
1375
- .litespeed-icon-media-webp-disabled { background-image: url("../img/icons/img_webp_disabled.svg") ; }
1376
- .litespeed-icon-media-optm { background-image: url("../img/icons/img_optm.svg") ; }
1377
- .litespeed-icon-media-optm-disabled { background-image: url("../img/icons/img_optm_disabled.svg") ; }
1378
-
1379
- p.litespeed-media-p{
1380
- margin-bottom: 1px !important;
1381
- }
1382
-
1383
- p.litespeed-txt-webp {
1384
- color: #83b04a ;
1385
- }
1386
-
1387
- p.litespeed-txt-ori {
1388
- color: #5967b3 ;
1389
- }
1390
-
1391
- p.litespeed-txt-disabled {
1392
- color: #ced2d9 ;
1393
- }
1394
-
1395
- .litespeed-media-svg {
1396
- vertical-align: middle;
1397
- margin: 5px;
1398
- width: 25px;
1399
- height: auto;
1400
- }
1401
-
1402
- @keyframes litespeed-circle-chart-fill {
1403
- to { stroke-dasharray: 0 100; }
1404
- }
1405
-
1406
- .litespeed-pie{
1407
- vertical-align: middle;
1408
- margin: 5px;
1409
- }
1410
-
1411
-
1412
-
1413
- circle.litespeed-pie_bg {
1414
- stroke: #efefef;
1415
- stroke-width: 2;
1416
- fill: none;
1417
- cx: 16.91549431;
1418
- cy: 16.91549431;
1419
- r: 15.91549431;
1420
- }
1421
-
1422
- circle.litespeed-pie_circle {
1423
- animation: litespeed-circle-chart-fill 2s reverse;
1424
- transform: rotate(-90deg);
1425
- transform-origin: center;
1426
-
1427
- animation: litespeed-pie-fill 2s reverse; /* 1 */
1428
- stroke: #00acc1;
1429
- stroke-width: 2;
1430
- stroke-linecap: round;
1431
- fill: none;
1432
- cx: 16.91549431;
1433
- cy: 16.91549431;
1434
- r: 15.91549431;
1435
- }
1436
-
1437
- .litespeed-pie-success circle.litespeed-pie_circle {
1438
- stroke: #178239;
1439
- }
1440
-
1441
- .litespeed-pie-warning circle.litespeed-pie_circle {
1442
- stroke: #e67700;
1443
- }
1444
-
1445
- .litespeed-pie-danger circle.litespeed-pie_circle {
1446
- stroke: #c7221f;
1447
- }
1448
-
1449
- g.litespeed-pie_info text{
1450
- alignment-baseline: central;
1451
- text-anchor: middle;
1452
- font-size: 11px;
1453
- }
1454
-
1455
- .litespeed-promo-score g.litespeed-pie_info text{
1456
- font-size: 14px;
1457
- font-weight: 600;
1458
- }
1459
-
1460
- .litespeed-pie-success g.litespeed-pie_info text{
1461
- fill: #178239;
1462
- }
1463
-
1464
- .litespeed-pie-warning g.litespeed-pie_info text{
1465
- fill: #e67700;
1466
- }
1467
-
1468
- .litespeed-pie-danger g.litespeed-pie_info text{
1469
- fill: #c7221f;
1470
- }
1471
-
1472
- g.litespeed-pie_info .litespeed-pie-done {
1473
- fill: #73b38d;
1474
- }
1475
-
1476
-
1477
- /********************************* block and columns *******************************/
1478
- .litespeed-block,
1479
- .litespeed-block-tiny {
1480
- border: 1px dotted #6699cc;
1481
- border-radius:5px;
1482
- display: flex;
1483
- flex-wrap: wrap;
1484
- padding: 10px;
1485
- margin-bottom: 5px;
1486
- }
1487
-
1488
- .litespeed-block-tiny {
1489
- max-width: 670px ;
1490
- }
1491
-
1492
- .litespeed-col{
1493
- flex: 0 0 30%;
1494
- padding-left: 17px;
1495
- }
1496
-
1497
- .litespeed-col-auto{
1498
- padding-left: 17px;
1499
- }
1500
-
1501
- .litespeed-col-br{
1502
- flex: 0 0 100% ;
1503
- border-top: 1px dotted #6699cc;
1504
- }
1505
-
1506
- .litespeed-col-inc{
1507
- display: inline-block;
1508
- margin-top: 16px ;
1509
- min-width: 150px ;
1510
- font-weight: bold;
1511
- }
1512
-
1513
-
1514
- /********************************* multiple cdn mapping styling *******************************/
1515
- [data-litespeed-cdn-mapping]:first-child [data-litespeed-cdn-mapping-del]{
1516
- display: none;
1517
- }
1518
-
1519
- .litespeed-cdn-mapping-col1 {
1520
- flex: 0 0 35%;
1521
- padding-left: 17px;
1522
- }
1523
-
1524
- .litespeed-cdn-mapping-col2 {
1525
- flex: 0 0 22%;
1526
- }
1527
-
1528
- .litespeed-cdn-mapping-col3 {
1529
- display: flex;
1530
- }
1531
-
1532
- .litespeed-cdn-mapping-col1 h4 {
1533
- position:relative;
1534
- margin-top: 10px;
1535
- }
1536
-
1537
- .litespeed-btn-danger[data-litespeed-cdn-mapping-del] {
1538
- border-radius: 13px;
1539
- margin: 0 10px 0 0;
1540
- position: absolute;
1541
- right:10px;
1542
- top:0;
1543
- /*background: #cc3d6a;*/
1544
- color: #fff;
1545
- padding: 1px 8px;
1546
- font-size: 13px;
1547
- line-height: 1.5;
1548
- min-width: 14px;
1549
- }
1550
-
1551
- .litespeed-cdn-mapping-inc {
1552
- display: inline-block;
1553
- margin-left: 36px ;
1554
- min-width: 100px ;
1555
- font-weight: bold;
1556
- }
1557
-
1558
- .litespeed-cdn-mapping-col3-title {
1559
- display: inline-block;
1560
- vertical-align: top ;
1561
- font-weight: bold;
1562
- margin-left: 36px ;
1563
- margin-right: 10px;
1564
- }
1565
-
1566
- /********************************* toggle *******************************/
1567
-
1568
- .litespeed-toggle {
1569
- position: relative;
1570
- overflow: hidden;
1571
- min-width: 58px ;
1572
- height: 21px ;
1573
- margin-left: 30px ;
1574
- }
1575
-
1576
- .litespeed-toggle-group {
1577
- position: absolute;
1578
- width: 200%;
1579
- top: 0;
1580
- bottom: 0;
1581
- left: 0;
1582
- transition: left 0.35s;
1583
- -webkit-transition: left 0.35s;
1584
- -moz-user-select: none;
1585
- -webkit-user-select: none;
1586
- }
1587
-
1588
- .litespeed-toggle-on {
1589
- position: absolute;
1590
- top: 0;
1591
- bottom: 0;
1592
- left: 0;
1593
- right: 50%;
1594
- margin: 0;
1595
- border: 0;
1596
- border-radius: 0;
1597
- }
1598
-
1599
- .litespeed-toggle-on.litespeed-toggle-btn {
1600
- padding-right: 24px;
1601
- }
1602
-
1603
- .litespeed-toggle-off.litespeed-toggle-btn {
1604
- padding-left: 24px;
1605
- }
1606
-
1607
- .litespeed-toggle-handle {
1608
- position: relative;
1609
- margin: 0 auto;
1610
- padding-top: 0px;
1611
- padding-bottom: 0px;
1612
- height: 100%;
1613
- width: 0px;
1614
- border-width: 0 1px;
1615
- }
1616
-
1617
- .litespeed-toggle-off {
1618
- position: absolute;
1619
- top: 0;
1620
- bottom: 0;
1621
- left: 50%;
1622
- right: 0;
1623
- margin: 0;
1624
- border: 0;
1625
- border-radius: 0;
1626
- }
1627
-
1628
- .litespeed-toggleoff .litespeed-toggle-group {
1629
- left: -100%;
1630
- }
1631
-
1632
- .litespeed-toggle-btn {
1633
- display: inline-block;
1634
- padding: 6px 12px;
1635
- margin-bottom: 0;
1636
- font-size: 14px;
1637
- font-weight: 400;
1638
- line-height: 1.42857143;
1639
- text-align: center;
1640
- white-space: nowrap;
1641
- vertical-align: middle;
1642
- cursor: pointer;
1643
- -webkit-user-select: none;
1644
- -moz-user-select: none;
1645
- -ms-user-select: none;
1646
- user-select: none;
1647
- background-image: none;
1648
- border: 1px solid transparent;
1649
- border-radius: 4px;
1650
- }
1651
-
1652
- .litespeed-toggle-btn-primary {
1653
- color: #fff;
1654
- background-color: #36b0b0;
1655
- border-color: #6699cc;
1656
- }
1657
-
1658
- .litespeed-toggle-btn-default {
1659
- color: #333;
1660
- background-color: #fff;
1661
- border-color: #ccc;
1662
- }
1663
-
1664
- .litespeed-toggle-btn-success:hover, .litespeed-toggle-btn-success:focus, .litespeed-toggle-btn-success:active, .litespeed-toggle-btn-success.litespeed-toggle-active {
1665
- color: #fff;
1666
- background-color: #00bfbf;
1667
- border-color: #6699cc;
1668
- }
1669
-
1670
- .litespeed-toggle-btn-default:hover, .litespeed-toggle-btn-default:focus, .litespeed-toggle-btn-default:active, .litespeed-toggle-btn-default.litespeed-toggle-active {
1671
- color: #333;
1672
- background-color: #e6e6e6;
1673
- border-color: #adadad;
1674
- }
1675
-
1676
- .litespeed-toggle-btn:active, .litespeed-toggle-btn.litespeed-toggle-active {
1677
- background-image: none;
1678
- outline: 0;
1679
- -webkit-box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
1680
- box-shadow: inset 0 3px 5px rgba(0,0,0,.125);
1681
- }
1682
-
1683
- .litespeed-toggle-btn-default:active, .litespeed-toggle-btn-default.litespeed-toggle-active {
1684
- background-image: none;
1685
- }
1686
-
1687
-
1688
- /********************************* setting panel *******************************/
1689
- .litespeed-setting-basic{
1690
- margin-left: 50px;
1691
- }
1692
-
1693
- .litespeed-setting-advanced{
1694
- margin-left: 10px;
1695
- }
1696
-
1697
- .litespeed-setting-basic,
1698
- .litespeed-setting-advanced {
1699
- color: #264d73;
1700
- text-decoration: none;
1701
- }
1702
-
1703
- .litespeed-setting-curr{
1704
- border-bottom:1px solid #6699cc;
1705
- }
1706
-
1707
- /********************************* crawler *******************************/
1708
- .litespeed-crawler-curr{
1709
- vertical-align: middle;
1710
- height: 20px;
1711
- margin-left: 10px;
1712
- }
1713
-
1714
- .litespeed-cron-onoff-btn {
1715
- position: absolute ;
1716
- left: 180px ;
1717
- top: -7px ;
1718
- }
1719
-
1720
- /********************************* Progress bar *******************************/
1721
- .litespeed-progress-bar {
1722
- display: -webkit-box;
1723
- display: -ms-flexbox;
1724
- display: flex;
1725
- -webkit-box-orient: vertical;
1726
- -webkit-box-direction: normal;
1727
- -ms-flex-direction: column;
1728
- flex-direction: column;
1729
- -webkit-box-pack: center;
1730
- -ms-flex-pack: center;
1731
- justify-content: center;
1732
- color: #fff;
1733
- text-align: center;
1734
- background-color: #007bff;
1735
- transition: width .6s ease;
1736
- }
1737
-
1738
- .litespeed-progress-bar-yellow {
1739
- background-color: #fbe100;
1740
- }
1741
-
1742
- /*.litespeed-progress {
1743
- display: -webkit-box;
1744
- display: -ms-flexbox;
1745
- display: flex;
1746
- height: 2px;
1747
- overflow: hidden;
1748
- font-size: .75rem;
1749
- background-color: #e9ecef;
1750
- }*/
1751
- .litespeed-progress {
1752
- display: -webkit-box;
1753
- display: -ms-flexbox;
1754
- display: flex;
1755
- height: 12px;
1756
- overflow: hidden;
1757
- font-size: .75rem;
1758
- background-color: #e9ecef;
1759
- border: 1px solid #dddddd;
1760
- border-radius: 8px;
1761
- width: 75%;
1762
- margin: 5em 1em 1.5em 1em !important;
1763
- }
1764
-
1765
- /********************************* form input *******************************/
1766
- input.litespeed-input[type="file"]{
1767
- padding: 9px ;
1768
- min-width: 500px ;
1769
- }
1770
-
1771
- /********************************* guidance *******************************/
1772
- .litespeed-guide {
1773
- border:1px solid #73b38d;
1774
- max-width: 50%;
1775
- padding: 20px;
1776
- }
1777
-
1778
- .litespeed-guide h2 {
1779
- color: #73b38d;
1780
- border-bottom:1px solid #73b38d;
1781
- display: table;
1782
- padding-right: 50px;
1783
- padding-left: 3px;
1784
- padding-bottom: 3px;
1785
- }
1786
-
1787
- .litespeed-guide li {
1788
- font-size: 15px;
1789
- line-height: 30px;
1790
- margin: 10px 10px 10px 16px ;
1791
- }
1792
-
1793
- .litespeed-guide li.litespeed-guide-done:before{
1794
- content: '\2713' ;
1795
- font-size: 26px ;
1796
- color: #73b38d ;
1797
- margin-left: -37px ;
1798
- margin-right: 18px ;
1799
- opacity: 1 ;
1800
- }
1801
-
1802
- .litespeed-guide li.litespeed-guide-done {
1803
- opacity: .9 ;
1804
- }
1805
-
1806
- /********************************* todo *******************************/
1807
-
1808
- .litespeed-body .litespeed-textarea-success {
1809
- border-color: #6699cc ;
1810
- }
1811
-
1812
- /* input field */
1813
- .litespeed-textarea {
1814
- width: 60% ;
1815
- }
1816
-
1817
- .litespeed-body tbody > tr > th{
1818
- padding-left: 10px;
1819
- }
1820
-
1821
- .litespeed-body tbody > tr:nth-of-type(odd){
1822
- background-color: #f9f9f9;
1823
- background-color: #f9fafc;
1824
- }
1825
-
1826
- .litespeed-body input[type=radio] {/* todo: to be deleted */
1827
- margin-top: 0px;
1828
- margin-right: 4px;
1829
- float: none;
1830
- }
1831
-
1832
- .litespeed-body th {
1833
- vertical-align: top;
1834
- text-align: left;
1835
- padding: 18px 10px 20px 0;
1836
- width: 200px;
1837
- font-family: "Open Sans", Arial, sans-serif;
1838
- font-weight: 600;
1839
- font-size: 14px;
1840
- color: #264d73;
1841
- border-radius: 3px;
1842
- }
1843
-
1844
- .litespeed-body td {
1845
- margin-bottom: 9px;
1846
- padding: 15px 10px;
1847
- line-height: 1.3;
1848
- vertical-align: middle;
1849
- font-family: "Open Sans", Arial, sans-serif;
1850
- font-weight: 400;
1851
- font-size: 14px;
1852
- color: #264d73;
1853
- border-radius: 3px;
1854
- }
1855
-
1856
- .litespeed-wrap .litespeed-float-submit {
1857
- position: absolute;
1858
- right: 10px;
1859
- top: -20px;
1860
- margin-top: 0;
1861
- }
1862
-
1863
- .rtl .litespeed-wrap .litespeed-float-submit {
1864
- left: 10px;
1865
- right: unset;
1866
- }
1867
-
1868
- .litespeed-wrap .litespeed-float-resetbtn {
1869
- position: absolute;
1870
- right: 10px;
1871
- bottom: 20px;
1872
- }
1873
-
1874
- .rtl .litespeed-wrap .litespeed-float-resetbtn {
1875
- left: 10px;
1876
- right: unset;
1877
- }
1878
-
1879
- .litespeed input,
1880
- .litespeed-body input,
1881
- .litespeed-body textarea {
1882
- border: 1px solid #6699cc;
1883
- border-radius: 3px;
1884
- background: #fff;
1885
- color: #264d73;
1886
- margin-right: 8px;
1887
- font-size: 14px;
1888
- font-family: "Open Sans", Arial, sans-serif;
1889
- }
1890
-
1891
- .litespeed-body textarea {
1892
- border-color: #69B1FF ;
1893
- }
1894
-
1895
- .litespeed .litespeed-regular-text,
1896
- .litespeed-regular-text {
1897
- padding-left: 5px;
1898
- width: 25em;
1899
- font-size: 14px;
1900
- font-family: "Open Sans", Arial, sans-serif;
1901
- }
1902
-
1903
- .litespeed .litespeed-input-large {
1904
- font-size: 20px ;
1905
- }
1906
-
1907
- .litespeed-input-long {
1908
- width: 99%;
1909
- }
1910
-
1911
- .litespeed-input-short2 {
1912
- width: 150px;
1913
- }
1914
-
1915
- .litespeed-input-short {
1916
- width: 45px;
1917
- padding: 1px 6px;
1918
- }
1919
-
1920
- input.litespeed-input-success {
1921
- border-color: #28a745;
1922
- }
1923
-
1924
- input.litespeed-input-warning {
1925
- border-color: #e59544;
1926
- }
1927
- /*text area */
1928
-
1929
- .litespeed-body textarea {
1930
- margin-top: 0px;
1931
- margin-bottom: 0px;
1932
- z-index: auto;
1933
- position: relative;
1934
- line-height: 19.6px;
1935
- font-size: 14px;
1936
- transition: none;
1937
- background: transparent;
1938
- padding: 5px 10px;
1939
- box-sizing: border-box;
1940
- }
1941
-
1942
- /*text area read only */
1943
-
1944
- .litespeed-body input[readonly], .litespeed-body textarea[readonly] {
1945
- background-color: #eee;
1946
- background-color: #f2f9ff;
1947
- }
1948
-
1949
-
1950
- /* image optimize page */
1951
- .litespeed-width-1-2 {
1952
- width: 45%;
1953
- padding: 20px;
1954
-
1955
- }
1956
- .litespeed-width-1-3 {
1957
- width: 30%;
1958
- padding: 25px;
1959
- }
1960
- .litespeed-width-7-10 {
1961
- width: 65%;
1962
- padding: 20px;
1963
- }
1964
- .litespeed-width-3-10 {
1965
- width: 25%;
1966
- padding: 20px;
1967
- }
1968
-
1969
- .litespeed-column-java {
1970
- background: #5CADAD !important;
1971
- }
1972
-
1973
- .litespeed-text-shipgrey {
1974
- color: #535342 !important;
1975
- }
1976
-
1977
- .litespeed-text-dimgray {
1978
- color: #666666 !important;
1979
- }
1980
-
1981
- .litespeed-text-grey {
1982
- color: #999999 !important;
1983
- }
1984
-
1985
- .litespeed-text-whisper {
1986
- color: #E6E6E6 !important;
1987
- }
1988
-
1989
- .litespeed-text-malibu {
1990
- color: #5CBDDE !important;
1991
- }
1992
-
1993
- .litespeed-text-morningglory {
1994
- color: #99CCCC !important;
1995
- }
1996
-
1997
- .litespeed-text-fern {
1998
- color: #66CC66 !important;
1999
- }
2000
-
2001
- .litespeed-text-persiangreen {
2002
- color: #009999 !important;
2003
- }
2004
-
2005
- .litespeed-text-right {
2006
- text-align: right;
2007
- }
2008
-
2009
- .litespeed-text-center {
2010
- text-align: center;
2011
- }
2012
- .litespeed-text-bold {
2013
- font-weight: 600;
2014
- }
2015
-
2016
- .litespeed-text-lead {
2017
- font-size: 16px;
2018
- }
2019
-
2020
- .litespeed-text-small {
2021
- font-size: 12px;
2022
- line-height: 14px;
2023
- }
2024
- .litespeed-text-thin {
2025
- font-weight: 100;
2026
- }
2027
- .litespeed-align-center {
2028
- margin-left: auto;
2029
- margin-right: auto;
2030
- }
2031
-
2032
- .litespeed-contrast {
2033
- color: white;
2034
- }
2035
-
2036
- .litespeed-wrap .litespeed-btn-large {
2037
- min-height: 1em !important;
2038
- font-size: 1.5em !important;
2039
- padding: .5em 1em .5em 1em !important;
2040
- }
2041
-
2042
- .litespeed-wrap .litespeed-btn-xlarge {
2043
- line-height: 2.3em;
2044
- font-size: 2.3em !important;
2045
- padding: .25em .75em .25em .75em;
2046
- border-radius: 52px;
2047
-
2048
- }
2049
-
2050
- .litespeed-wrap .litespeed-btn-success, .litespeed-btn-success {
2051
- color: #36b0b0;
2052
- border: 1px solid #36b0b0;
2053
- -moz-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
2054
- -webkit-box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
2055
- box-shadow: 0 0 0 1px rgba(54, 176, 176, 0.25);
2056
- }
2057
-
2058
-
2059
-
2060
- .litespeed-empty-space-xlarge {
2061
- margin-top: 8em;
2062
- }
2063
-
2064
- .litespeed-empty-space-large {
2065
- margin-top: 6em;
2066
- }
2067
-
2068
- .litespeed-empty-space-medium {
2069
- margin-top: 3em;
2070
- }
2071
-
2072
- .litespeed-empty-space-small {
2073
- margin-top: 2em;
2074
- }
2075
-
2076
- .litespeed-empty-space-tiny {
2077
- margin-top: 1em;
2078
- }
2079
-
2080
- .litespeed-hr-dotted {
2081
- border: 1px dotted #eeeeee;
2082
- }
2083
-
2084
- .litespeed-flex-container {
2085
- display: flex;
2086
- flex-wrap: wrap;
2087
- width: 100%;
2088
- height: auto;
2089
- }
2090
-
2091
- .litespeed-hr {
2092
- padding-bottom: 1.5em;
2093
- border-bottom: .5px solid #97CACA;
2094
- }
2095
-
2096
- .litespeed-icon-vertical-middle {
2097
- vertical-align: middle;
2098
- display: inline-block;
2099
- margin:0px 10px 0px 10px;
2100
- }
2101
-
2102
- @media screen and (max-width: 814px) {
2103
- .litespeed-width-7-10 {
2104
- width:100%;
2105
- }
2106
- .litespeed-width-3-10 {
2107
- width:100%;
2108
- }
2109
- }
2110
-
2111
- .litespeed-column-java .litespeed-danger {
2112
- color: #c1c53a!important ;
2113
- }
2114
-
2115
- .litespeed-column-java .litespeed-desc {
2116
- color: #bfbfbf;
2117
- }
2118
-
2119
- .litespeed-column-java code {
2120
- color: #c2f5bf;
2121
- background-color: #238888 ;
2122
- }
2123
- .litespeed-column-java .litespeed-title {
2124
- color: white;
2125
- }
2126
-
2127
- .litespeed-width-7-10 .litespeed-progress {
2128
- margin: 1em;
2129
- }
2130
-
2131
- .litespeed-refresh:after {
2132
- content: "⟳";
2133
- width: 20px;
2134
- height: 20px;
2135
- color: #40ad3a ;
2136
- }
2137
-
2138
- .litespeed-column-java .litespeed-refresh:after{
2139
- color: #23ec17 ;
2140
- }
2141
-
2142
- .litespeed-refresh:hover:after,
2143
- .litespeed-refresh:focus:after,
2144
- .litespeed-refresh:focus:active:after {
2145
- color: #7ffbfb ;
2146
- }
2147
-
2148
- .litespeed-width-3-10 .litespeed-title {
2149
- margin: 18px 0;
2150
- }
2151
-
2152
- .litespeed-silence {
2153
- color: #B1B1B1;
2154
- }
2155
-
2156
- .litespeed-column-java .litespeed-congratulate {
2157
- color: #c2f5bf;
2158
- font-size: 20px;
2159
- }
2160
-
2161
- .litespeed-light-code .litespeed-silence code {
2162
- background-color: #f0f5fb ;
2163
- }
2164
-
2165
- .litespeed-column-java .litespeed-btn-danger {
2166
- color: #f194a8;
2167
- border-color: #f194a8 ;
2168
- }
2169
-
2170
- .litespeed-column-java .litespeed-btn-danger:hover {
2171
- background: #f194a8 ;
2172
- }
2173
-
2174
- .litespeed-column-java svg.litespeed-pie circle.litespeed-pie_bg {
2175
- stroke: #e8efe7;
2176
- }
2177
-
2178
- .litespeed-column-java svg.litespeed-pie circle.litespeed-pie_circle {
2179
- stroke: #97CACA;
2180
- }
2181
-
2182
- .litespeed-column-java svg .litespeed-pie_info text {
2183
- fill: #F5FFEB;
2184
- }
2185
-
2186
- .litespeed-column-java svg g.litespeed-pie_info .litespeed-pie-done {
2187
- fill: #a5ffa0;
2188
- }
2189
-
2190
- .litespeed-column-java a {
2191
- color: #eaf8ff;
2192
- }
2193
-
2194
- .litespeed-column-java a:hover {
2195
- color: #ffffff;
2196
- }
2197
-
2198
- .litespeed-progress-bar-blue {
2199
- background-color: #33ADFF;
2200
- }
2201
-
2202
- .litespeed-status-current {
2203
- font-size: 3.5em;
2204
- margin: 1.25em 0em .75em 0em;
2205
- }
2206
-
2207
- .litespeed-title, .litespeed-title-short {
2208
- margin: 18px 0;
2209
- border-bottom: 1px solid #C1D5EA;
2210
- margin: 2.5em 0px 1.5em 0 !important;
2211
- }
2212
-
2213
- .litespeed-column-java .litespeed-desc {
2214
- color: #CAE4E4;
2215
- }
2216
-
2217
- .litespeed-column-java .litespeed-warning {
2218
- color: #FFD597 !important;
2219
- }
2220
-
2221
- .litespeed-column-java .litespeed-btn-success {
2222
- color: #DDF1E4;
2223
- border: 1px solid #33AD5C;
2224
- background: #33AD5C;
2225
- }
2226
-
2227
- .litespeed-column-java .litespeed-btn-success:hover {
2228
- color: #FFFFFF;
2229
- border: 1px solid #7DCA97;
2230
- background: #009933;
2231
- }
2232
-
2233
- .litespeed-column-java .litespeed-btn-warning {
2234
- color: #FFF1DD;
2235
- border: 1px solid #FF9933;
2236
- background-color: #FF9933;
2237
- }
2238
-
2239
- .litespeed-column-java .litespeed-btn-warning:hover {
2240
- color: #FFFFFF;
2241
- border-color: #FFCA7D;
2242
- background: #FF9900;
2243
- }
2244
-
2245
- .litespeed-column-java .litespeed-btn-danger {
2246
- color: #FFEADD !important;
2247
- border: 1px solid #FF6600 !important;
2248
- background: #FF5C5C;
2249
- }
2250
-
2251
- .litespeed-column-java .litespeed-btn-danger:hover {
2252
- color: #FFFFFF;
2253
- border: 1px solid #FF9797 !important;
2254
- background: #FF0000;
2255
- }
2256
-
2257
- .litespeed .litespeed-btn-danger, .litespeed-wrap .litespeed-btn-danger, .litespeed-btn-danger {
2258
- color: #cc3d6a;
2259
- border: 1px solid #cc3d6a;
2260
- -moz-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
2261
- -webkit-box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
2262
- box-shadow: 0 0 0 1px rgba(204, 61, 106, 0.25);
2263
- }
2264
-
2265
- .litespeed-column-java .litepseed-dash-icon-success, .litepseed-dash-icon-success {
2266
- color: #5CDEDE;
2267
- font-size: 2em;
2268
- margin-top: -.25em;
2269
- }
2270
-
2271
- .litespeed-column-java .litepseed-dash-icon-success:hover, .litepseed-dash-icon-success:hover {
2272
- color: #7DE5E5;
2273
- }
2274
-
2275
- .litespeed-dashicons-large {
2276
- font-size: 2em;
2277
- }
2278
-
2279
-
2280
- .litespeed-column-java p {
2281
- color: #FFFFFF;
2282
- }
2283
-
2284
- .litespeed-body tbody > tr > th.litespeed-padding-left {
2285
- padding-left: 3em;
2286
- }
2287
-
2288
- .litespeed-txt-small {
2289
- font-size: 12px;
2290
- }
2291
-
2292
- .litespeed-txt-disabled .litespeed-text-dimgray{
2293
- color: #aaaaaa;
2294
- }
2295
-
2296
- .litespeed-txt-disabled svg {
2297
- fill: #aaaaaa;
2298
- }
2299
-
2300
- .litespeed-txt-disabled circle.litespeed-pie_circle {
2301
- stroke: #cccccc;
2302
- }
2303
- .litespeed-txt-disabled g.litespeed-pie_info text {
2304
- color: #cccccc;
2305
- }
2306
-
2307
- a.litespeed-media-href svg:hover {
2308
- border-radius: 50%;
2309
- background: #F1FCFF;
2310
- fill:#5CCAD7;
2311
- box-shadow: 0 0 5px 1px #7DD5DF;
2312
- transition: all 0.2s ease-out;
2313
- transform: scale(1.05);
2314
- }
2315
-
2316
- .litespeed-media-p a .dashicons-trash {
2317
- font-size: 2.25em;
2318
- vertical-align: middle;
2319
- display: inline;
2320
- border-radius: 50%;
2321
- line-height: 1.5em;
2322
- }
2323
-
2324
- .litespeed-media-p a .dashicons-trash:hover {
2325
- transition: all .2s ease-out;
2326
- color: #FFA500 !important;
2327
- background: #FFF5E6;
2328
- box-shadow: 0 0 10px 1px #FF8C00;
2329
- }
2330
- .litespeed-media-p div>svg circle.litespeed-pie_bg {
2331
- stroke: #ecf2f9;
2332
- }
2333
- .litespeed-media-p div>svg circle.litespeed-pie_circle {
2334
- stroke: #9fbfdf;
2335
- }
2336
- .litespeed-media-p div>svg {
2337
- fill: #538cc6;
2338
- background: rgba(236,242,249,0.1);
2339
- border-radius: 50%;
2340
- }
2341
-
2342
- .litespeed-banner-description-padding-right-15 {
2343
- padding-right: 15px;
2344
- }
2345
- .litespeed-banner-description {
2346
- display: inline-flex;
2347
- flex-wrap: wrap;
2348
- }
2349
- .litespeed-banner-desciption-content {
2350
- margin: 0px;
2351
- line-height: 1.25em;
2352
- padding: 0px !important;
2353
- }
2354
-
2355
- .litespeed-row-flex {
2356
- display: inline-flex;
2357
-
2358
- }
2359
- .litespeed-flex-wrap {
2360
- flex-wrap: wrap;
2361
- }
2362
-
2363
- .litespeed-padding-space {
2364
- padding: 5px 10px;
2365
- }
2366
- .litespeed-margin-bottom20 {
2367
- margin-bottom: 20px;
2368
- }
2369
- .litespeed-margin-bottom-remove {
2370
- margin-bottom: 0px !important;
2371
- }
2372
- .litespeed-margin-top-remove {
2373
- margin-top: 0px !important;
2374
- }
2375
- .litespeed-margin-left-remove {
2376
- margin-left: 0px !important;
2377
- }
2378
- .litespeed-margin-y-remove {
2379
- margin-top: 0px !important;
2380
- margin-bottom: 0px !important;
2381
- }
2382
-
2383
-
2384
- .litespeed-banner-button-link {
2385
- white-space: nowrap;
2386
- margin: 0px;
2387
- line-height: 1.5em;
2388
- padding-bottom: 5px;
2389
- }
2390
-
2391
-
2392
-
2393
- .litespeed-notice-dismiss{
2394
- position: absolute;
2395
- right: 25px;
2396
- border: none;
2397
- margin: 0;
2398
- padding: 10px;
2399
- background: none;
2400
- cursor: pointer;
2401
- color: #888888;
2402
- display: block;
2403
- height: 20px;
2404
- text-align: center;
2405
- -webkit-font-smoothing: antialiased;
2406
- -moz-osx-font-smoothing: grayscale;
2407
- font-weight: 600;
2408
- text-decoration: none;
2409
- }
2410
-
2411
- .litespeed-notice-dismiss:hover, .litespeed-notice-dismiss:active, .litespeed-notice-dismiss:focus {
2412
- color: #CC2929;
2413
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
data/.htaccess CHANGED
File without changes
data/const.default.ini CHANGED
@@ -1,37 +1,601 @@
1
- ; This is the default LSCWP configuration file
2
- ; All keys and values please refer const.cls.php
3
- ; Here just list some examples
 
 
4
  ; Comments start with `;`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- ; OPID_PURGE_ON_UPGRADE
7
- purge_upgrade = true
 
8
 
9
- ; OPID_CACHE_PRIV
10
- cache_priv = true
11
 
12
- ; OPID_CACHE_COMMENTER
13
- cache_commenter = true
14
 
15
- ; OPID_CACHE_OBJECT_HOST
16
- cache_object_host = 'localhost'
17
- ; OPID_CACHE_OBJECT_PORT
18
- cache_object_port = '11211'
19
 
20
- ; OPID_CACHE_BROWSER_TTL
21
- cache_browser_ttl = 2592000
22
 
23
- ; OPID_PUBLIC_TTL
24
- public_ttl = 604800
25
 
26
- ; ------------------------------CDN Mapping Example BEGIN-------------------------------
27
- ; Need to add the section mark `[litespeed-cache-cdn_mapping]` before list
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ;
29
- ; NOTE 1) Need to set all child options to make all resources to be replaced without missing
30
- ; NOTE 2) `url[n]` option must have to enable the row setting of `n`
 
31
  ;
32
- ; To enable the 2nd mapping record by default, please remove the `;;` in the related lines
 
 
33
 
34
- [litespeed-cache-cdn_mapping]
35
 
36
  url[0] = ''
37
 
@@ -63,4 +627,4 @@ filetype[0] = '.aac
63
 
64
  ;;filetype[1] = '.webm'
65
 
66
- ; ------------------------------CDN Mapping Example END-------------------------------
1
+ ;
2
+ ; This is the predefined default LSCWP configuration file
3
+ ;
4
+ ; All the keys and values please refer `src/const.cls.php`
5
+ ;
6
  ; Comments start with `;`
7
+ ;
8
+
9
+ ;; -------------------------------------------------- ;;
10
+ ;; -------------- General ----------------- ;;
11
+ ;; -------------------------------------------------- ;;
12
+
13
+ ; O_AUTO_UPGRADE
14
+ auto_upgrade = false
15
+
16
+ ; O_API_KEY
17
+ api_key = ''
18
+
19
+ ; O_SERVER_IP
20
+ server_ip = ''
21
+
22
+ ; O_NEWS
23
+ news = false
24
+
25
+
26
+ ;; -------------------------------------------------- ;;
27
+ ;; -------------- Cache ----------------- ;;
28
+ ;; -------------------------------------------------- ;;
29
+
30
+ cache-priv = true
31
+
32
+ cache-commenter = true
33
+
34
+ cache-rest = true
35
+
36
+ cache-page_login = true
37
+
38
+ cache-favicon = true
39
+
40
+ cache-resources = true
41
+
42
+ cache-browser = false
43
+
44
+ cache-mobile = false
45
+
46
+ cache-mobile_rules = 'Mobile
47
+ Android
48
+ Silk/
49
+ Kindle
50
+ BlackBerry
51
+ Opera Mini
52
+ Opera Mobi'
53
+
54
+ cache-exc_useragents = ''
55
+
56
+ cache-exc_cookies = ''
57
+
58
+ cache-exc_qs = ''
59
+
60
+ cache-exc_cat = ''
61
+
62
+ cache-exc_tag = ''
63
+
64
+ cache-force_uri = ''
65
+
66
+ cache-force_pub_uri = ''
67
+
68
+ cache-priv_uri = ''
69
+
70
+ cache-exc = ''
71
+
72
+ cache-exc_roles = ''
73
+
74
+ cache-drop_qs = 'fbclid
75
+ gclid
76
+ utm*
77
+ _ga'
78
+
79
+ cache-ttl_pub = 604800
80
+
81
+ cache-ttl_priv = 1800
82
+
83
+ cache-ttl_frontpage = 604800
84
+
85
+ cache-ttl_feed = 604800
86
+
87
+ ; O_CACHE_TTL_REST
88
+ cache-ttl_rest = 604800
89
+
90
+ cache-ttl_browser = 31557600
91
+
92
+ cache-login_cookie = ''
93
+
94
+ cache-vary_group = ''
95
+
96
+ cache-ttl_status = '403 3600
97
+ 404 3600
98
+ 500 3600'
99
+
100
+
101
+ ;; -------------------------------------------------- ;;
102
+ ;; -------------- Purge ----------------- ;;
103
+ ;; -------------------------------------------------- ;;
104
+
105
+ ; O_PURGE_ON_UPGRADE
106
+ purge-upgrade = true
107
+
108
+ ; O_PURGE_STALE
109
+ purge-stale = true
110
+
111
+ purge-post_all = false
112
+ purge-post_f = true
113
+ purge-post_h = true
114
+ purge-post_p = true
115
+ purge-post_pwrp = true
116
+ purge-post_a = true
117
+ purge-post_y = false
118
+ purge-post_m = true
119
+ purge-post_d = false
120
+ purge-post_t = true
121
+ purge-post_pt = true
122
+
123
+ purge-timed_urls = ''
124
+
125
+ purge-timed_urls_time = ''
126
+
127
+ purge-hook_all = 'switch_theme
128
+ wp_create_nav_menu
129
+ wp_update_nav_menu
130
+ wp_delete_nav_menu
131
+ create_term
132
+ edit_terms
133
+ delete_term
134
+ add_link
135
+ edit_link
136
+ delete_link'
137
+
138
+
139
+ ;; -------------------------------------------------- ;;
140
+ ;; -------------- ESI ----------------- ;;
141
+ ;; -------------------------------------------------- ;;
142
+
143
+ ; O_ESI
144
+ esi = false
145
+
146
+ ; O_ESI_CACHE_ADMBAR
147
+ esi-cache_admbar = true
148
+
149
+ ; O_ESI_CACHE_COMMFORM
150
+ esi-cache_commform = true
151
+
152
+ ; O_ESI_NONCE
153
+ esi-nonce = 'stats_nonce
154
+ subscribe_nonce'
155
+
156
+ ;; -------------------------------------------------- ;;
157
+ ;; -------------- Utilities ----------------- ;;
158
+ ;; -------------------------------------------------- ;;
159
+
160
+ util-heartbeat = true
161
+
162
+ util-instant_click = false
163
+
164
+ util-no_https_vary = false
165
+
166
+
167
+ ;; -------------------------------------------------- ;;
168
+ ;; -------------- Debug ----------------- ;;
169
+ ;; -------------------------------------------------- ;;
170
+
171
+ ; O_DEBUG_DISABLE_ALL
172
+ debug-disable_all = false
173
+
174
+ ; O_DEBUG
175
+ debug = false
176
+
177
+ ; O_DEBUG_IPS
178
+ debug-ips = '127.0.0.1'
179
+
180
+ ; O_DEBUG_LEVEL
181
+ debug-level = false
182
+
183
+ ; O_DEBUG_FILESIZE
184
+ debug-filesize = 3
185
+
186
+ ; O_DEBUG_COOKIE
187
+ debug-cookie = false
188
+
189
+ ; O_DEBUG_COLLAPS_QS
190
+ debug-collaps_qs = false
191
+
192
+ ; O_DEBUG_INC
193
+ debug-inc = ''
194
+
195
+ ; O_DEBUG_EXC
196
+ debug-exc = ''
197
+
198
+
199
+ ;; -------------------------------------------------- ;;
200
+ ;; -------------- DB Optm ----------------- ;;
201
+ ;; -------------------------------------------------- ;;
202
+
203
+ ; O_DB_OPTM_REVISIONS_MAX
204
+ db_optm-revisions_max = 0
205
+
206
+ ; O_DB_OPTM_REVISIONS_AGE
207
+ db_optm-revisions_age = 0
208
+
209
+
210
+ ;; -------------------------------------------------- ;;
211
+ ;; -------------- HTML Optm ----------------- ;;
212
+ ;; -------------------------------------------------- ;;
213
+
214
+ ; O_OPTM_CSS_MIN
215
+ optm-css_min = false
216
+
217
+ optm-css_inline_min = false
218
+
219
+ ; O_OPTM_CSS_COMB
220
+ optm-css_comb = false
221
+
222
+ optm-css_comb_priority = false
223
+
224
+ ; O_OPTM_CSS_HTTP2
225
+ optm-css_http2 = false
226
+
227
+ optm-css_exc = ''
228
+
229
+ ; O_OPTM_JS_MIN
230
+ optm-js_min = false
231
+
232
+ optm-js_inline_min = false
233
+
234
+ ; O_OPTM_JS_COMB
235
+ optm-js_comb = false
236
+
237
+ optm-js_comb_priority = false
238
+
239
+ ; O_OPTM_JS_HTTP2
240
+ optm-js_http2 = false
241
+
242
+ ; O_OPTM_EXC_JQ
243
+ optm-js_exc = ''
244
+
245
+ optm-ttl = 604800
246
+
247
+ optm-html_min = false
248
+
249
+ optm-qs_rm = false
250
+
251
+ optm-ggfonts_rm = false
252
+
253
+ ; O_OPTM_CSS_ASYNC
254
+ optm-css_async = false
255
+
256
+ ; O_OPTM_CCSS_GEN
257
+ optm-ccss_gen = true
258
+
259
+ ; O_OPTM_CCSS_ASYNC
260
+ optm-ccss_async = true
261
+
262
+ ; O_OPTM_CSS_ASYNC_INLINE
263
+ optm-css_async_inline = true
264
+
265
+ ; O_OPTM_CSS_FONT_DISPLAY
266
+ optm-css_font_display = false
267
+
268
+ ; O_OPTM_JS_DEFER
269
+ optm-js_defer = false
270
+
271
+ ; O_OPTM_JS_INLINE_DEFER
272
+ optm-js_inline_defer = false
273
+
274
+ optm-emoji_rm = false
275
+
276
+ optm-exc_jq = true
277
+
278
+ optm-ggfonts_async = false
279
+
280
+ optm-max_size = 2
281
+
282
+ optm-rm_comment = false
283
+
284
+ optm-exc_roles = ''
285
+
286
+ optm-ccss_con = ''
287
+
288
+ optm-js_defer_exc = ''
289
+
290
+ ; O_OPTM_DNS_PREFETCH
291
+ optm-dns_prefetch = ''
292
+
293
+ ; O_OPTM_DNS_PREFETCH_CTRL
294
+ optm-dns_prefetch_ctrl = false
295
+
296
+ optm-exc = ''
297
+
298
+ ; O_OPTM_CCSS_SEP_POSTTYPE
299
+ optm-ccss_sep_posttype = ''
300
+
301
+ ; O_OPTM_CCSS_SEP_URI
302
+ optm-ccss_sep_uri = ''
303
 
304
+ ;; -------------------------------------------------- ;;
305
+ ;; -------------- Object Cache ----------------- ;;
306
+ ;; -------------------------------------------------- ;;
307
 
308
+ object = false
 
309
 
310
+ object-kind = false
 
311
 
312
+ object-host = 'localhost'
 
 
 
313
 
314
+ object-port = 11211
 
315
 
316
+ object-life = 360
 
317
 
318
+ object-persistent = true
319
+
320
+ object-admin = true
321
+
322
+ object-transients = true
323
+
324
+ object-db_id = 0
325
+
326
+ object-user = ''
327
+
328
+ object-pswd = ''
329
+
330
+ object-global_groups = 'users
331
+ userlogins
332
+ usermeta
333
+ user_meta
334
+ site-transient
335
+ site-options
336
+ site-lookup
337
+ blog-lookup
338
+ blog-details
339
+ rss
340
+ global-posts
341
+ blog-id-cache'
342
+
343
+ object-non_persistent_groups = 'comment
344
+ counts
345
+ plugins
346
+ wc_session_id'
347
+
348
+
349
+
350
+ ;; -------------------------------------------------- ;;
351
+ ;; -------------- Discussion ----------------- ;;
352
+ ;; -------------------------------------------------- ;;
353
+
354
+ ; O_DISCUSS_AVATAR_CACHE
355
+ discuss-avatar_cache = false
356
+
357
+ ; O_DISCUSS_AVATAR_CRON
358
+ discuss-avatar_cron = false
359
+
360
+ ; O_DISCUSS_AVATAR_CACHE_TTL
361
+ discuss-avatar_cache_ttl = 604800
362
+
363
+
364
+
365
+
366
+ ;; -------------------------------------------------- ;;
367
+ ;; -------------- Media ----------------- ;;
368
+ ;; -------------------------------------------------- ;;
369
+
370
+ ; O_MEDIA_LAZY
371
+ media-lazy = false
372
+
373
+ ; O_MEDIA_LAZY_PLACEHOLDER
374
+ media-lazy_placeholder = ''
375
+
376
+ ; O_MEDIA_PLACEHOLDER_RESP
377
+ media-placeholder_resp = false
378
+
379
+ ; O_MEDIA_PLACEHOLDER_RESP_COLOR
380
+ media-placeholder_resp_color = '#cfd4db'
381
+
382
+ ; O_MEDIA_PLACEHOLDER_RESP_SVG
383
+ media-placeholder_resp_svg = '<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}"><rect width="100%" height="100%" fill="{color}"/></svg>'
384
+
385
+ ; O_MEDIA_LQIP
386
+ media-lqip = false
387
+
388
+ ; O_MEDIA_LQIP_QUAL
389
+ media-lqip_qual = 4
390
+
391
+ ; O_MEDIA_LQIP_MIN_W
392
+ media-lqip_min_w = 150
393
+
394
+ ; O_MEDIA_LQIP_MIN_H
395
+ media-lqip_min_h = 150
396
+
397
+ ; O_MEDIA_PLACEHOLDER_RESP_ASYNC
398
+ media-placeholder_resp_async = true
399
+
400
+ ; O_MEDIA_IFRAME_LAZY
401
+ media-iframe_lazy = false
402
+
403
+ ; O_MEDIA_LAZYJS_INLINE
404
+ media-lazyjs_inline = false
405
+
406
+ ; O_MEDIA_LAZY_EXC
407
+ media-lazy_exc = ''
408
+
409
+ ; O_MEDIA_LAZY_CLS_EXC
410
+ media-lazy_cls_exc = ''
411
+
412
+ ; O_MEDIA_LAZY_PARENT_CLS_EXC
413
+ media-lazy_parent_cls_exc = ''
414
+
415
+ ; O_MEDIA_IFRAME_LAZY_CLS_EXC
416
+ media-iframe_lazy_cls_exc = ''
417
+
418
+ ; O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC
419
+ media-iframe_lazy_parent_cls_exc = ''
420
+
421
+ ; O_MEDIA_LAZY_URI_EXC
422
+ media-lazy_uri_exc = ''
423
+
424
+
425
+
426
+
427
+ ;; -------------------------------------------------- ;;
428
+ ;; -------------- Image Optm ----------------- ;;
429
+ ;; -------------------------------------------------- ;;
430
+
431
+ img_optm-auto = false
432
+
433
+ img_optm-cron = true
434
+
435
+ img_optm-ori = true
436
+
437
+ img_optm-rm_bkup = false
438
+
439
+ img_optm-webp = false
440
+
441
+ img_optm-lossless = false
442
+
443
+ img_optm-exif = false
444
+
445
+ img_optm-webp_replace = false
446
+
447
+ img_optm-webp_attr = 'img.src
448
+ div.data-thumb
449
+ img.data-src
450
+ div.data-large_image
451
+ img.retina_logo_url
452
+ div.data-parallax-image
453
+ video.poster'
454
+
455
+ img_optm-webp_replace_srcset = false
456
+
457
+ img_optm-jpg_quality = 82
458
+
459
+
460
+
461
+
462
+ ;; -------------------------------------------------- ;;
463
+ ;; -------------- Crawler ----------------- ;;
464
+ ;; -------------------------------------------------- ;;
465
+
466
+ crawler = false
467
+
468
+ crawler-inc_posts = true
469
+
470
+ crawler-inc_pages = true
471
+
472
+ crawler-inc_cats = true
473
+
474
+ crawler-inc_tags = true
475
+
476
+ crawler-exc_cpt = ''
477
+
478
+ crawler-order_links = 0
479
+
480
+ crawler-usleep = 500
481
+
482
+ crawler-run_duration = 400
483
+
484
+ crawler-run_interval = 600
485
+
486
+ crawler-crawl_interval = 302400
487
+
488
+ crawler-threads = 3
489
+
490
+ ; O_CRAWLER_TIMEOUT
491
+ crawler-timeout = 30
492
+
493
+ crawler-load_limit = 1
494
+
495
+ ; O_CRAWLER_SITEMAP
496
+ crawler-sitemap = ''
497
+
498
+ ; O_CRAWLER_DROP_DOMAIN
499
+ crawler-drop_domain = true
500
+
501
+ ; O_CRAWLER_MAP_TIMEOUT
502
+ crawler-map_timeout = 120
503
+
504
+ crawler-roles = ''
505
+
506
+ crawler-cookies = ''
507
+
508
+
509
+
510
+
511
+ ;; -------------------------------------------------- ;;
512
+ ;; -------------- Misc ----------------- ;;
513
+ ;; -------------------------------------------------- ;;
514
+
515
+ ; O_MISC_HTACCESS_FRONT
516
+ misc-htaccess_front = ''
517
+
518
+ ; O_MISC_HTACCESS_BACK
519
+ misc-htaccess_back = ''
520
+
521
+ ; O_MISC_HEARTBEAT_FRONT
522
+ misc-heartbeat_front = false
523
+
524
+ ; O_MISC_HEARTBEAT_FRONT_TTL
525
+ misc-heartbeat_front_ttl = 60
526
+
527
+ ; O_MISC_HEARTBEAT_BACK
528
+ misc-heartbeat_back = false
529
+
530
+ ; O_MISC_HEARTBEAT_BACK_TTL
531
+ misc-heartbeat_back_ttl = 60
532
+
533
+ ; O_MISC_HEARTBEAT_EDITOR
534
+ misc-heartbeat_editor = false
535
+
536
+ ; O_MISC_HEARTBEAT_EDITOR_TTL
537
+ misc-heartbeat_editor_ttl = 15
538
+
539
+
540
+
541
+
542
+
543
+ ;; -------------------------------------------------- ;;
544
+ ;; -------------- CDN ----------------- ;;
545
+ ;; -------------------------------------------------- ;;
546
+
547
+ cdn = false
548
+
549
+ ; O_CDN_ATTR
550
+ cdn-attr = '.src
551
+ .data-src
552
+ .href
553
+ .poster
554
+ source.srcset'
555
+
556
+ cdn-ori = ''
557
+
558
+ cdn-ori_dir = ''
559
+
560
+ cdn-exc = ''
561
+
562
+ cdn-remote_jq = false
563
+
564
+ cdn-quic = false
565
+
566
+ cdn-quic_email = ''
567
+
568
+ cdn-quic_key = ''
569
+
570
+ cdn-cloudflare = false
571
+
572
+ cdn-cloudflare_email = ''
573
+
574
+ cdn-cloudflare_key = ''
575
+
576
+ cdn-cloudflare_name = ''
577
+
578
+ cdn-cloudflare_zone = ''
579
+
580
+ ; `cdn-mapping` needs to be put in the end with a section tag
581
+
582
+
583
+ ;; -------------------------------------------------- ;;
584
+ ;; -------------- CDN 2 ----------------- ;;
585
+ ;; -------------------------------------------------- ;;
586
+
587
+ ; <------------ CDN Mapping Example BEGIN -------------------->
588
+ ; Need to keep the section tag `[cdn-mapping]` before list.
589
  ;
590
+ ; NOTE 1) Need to set all child options to make all resources to be replaced without missing.
591
+ ; NOTE 2) `url[n]` option must have to enable the row setting of `n`.
592
+ ; NOTE 3) This section needs to be put in the end of this .ini file
593
  ;
594
+ ; To enable the 2nd mapping record by default, please remove the `;;` in the related lines.
595
+
596
+
597
 
598
+ [cdn-mapping]
599
 
600
  url[0] = ''
601
 
627
 
628
  ;;filetype[1] = '.webm'
629
 
630
+ ; <------------ CDN Mapping Example END ------------------>
data/const.network_default.ini ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ;
2
+ ; This is the predefined default LSCWP network configuration file
3
+ ;
4
+ ; All the keys and values please refer `src/const.cls.php`
5
+ ;
6
+ ; Comments start with `;`
7
+ ;
8
+
9
+
10
+ ;; -------------------------------------------------- ;;
11
+ ;; -------------- General ----------------- ;;
12
+ ;; -------------------------------------------------- ;;
13
+
14
+ cache = false
15
+
16
+ use_primary_settings = false
17
+
18
+ auto_upgrade = false
19
+
20
+
21
+ ;; -------------------------------------------------- ;;
22
+ ;; -------------- Cache ----------------- ;;
23
+ ;; -------------------------------------------------- ;;
24
+
25
+ cache-favicon = true
26
+
27
+ cache-resources = true
28
+
29
+ cache-browser = false
30
+
31
+ cache-mobile = false
32
+
33
+ cache-mobile_rules = 'Mobile
34
+ Android
35
+ Silk/
36
+ Kindle
37
+ BlackBerry
38
+ Opera Mini
39
+ Opera Mobi'
40
+
41
+ cache-login_cookie = ''
42
+
43
+ cache-exc_cookies = ''
44
+
45
+ cache-exc_useragents = ''
46
+
47
+ cache-ttl_browser = 31557600
48
+
49
+ ;; -------------------------------------------------- ;;
50
+ ;; -------------- Purge ----------------- ;;
51
+ ;; -------------------------------------------------- ;;
52
+
53
+ purge-upgrade = true
54
+
55
+
56
+ ;; -------------------------------------------------- ;;
57
+ ;; -------------- Object Cache ----------------- ;;
58
+ ;; -------------------------------------------------- ;;
59
+
60
+ object = false
61
+
62
+ object-kind = false
63
+
64
+ object-host = 'localhost'
65
+
66
+ object-port = 11211
67
+
68
+ object-life = 360
69
+
70
+ object-persistent = true
71
+
72
+ object-admin = true
73
+
74
+ object-transients = true
75
+
76
+ object-db_id = 0
77
+
78
+ object-user = ''
79
+
80
+ object-pswd = ''
81
+
82
+ object-global_groups = 'users
83
+ userlogins
84
+ usermeta
85
+ user_meta
86
+ site-transient
87
+ site-options
88
+ site-lookup
89
+ blog-lookup
90
+ blog-details
91
+ rss
92
+ global-posts
93
+ blog-id-cache'
94
+
95
+ object-non_persistent_groups = 'comment
96
+ counts
97
+ plugins'
98
+
99
+
100
+ ;; -------------------------------------------------- ;;
101
+ ;; -------------- Image Optm ----------------- ;;
102
+ ;; -------------------------------------------------- ;;
103
+
104
+ img_optm-webp_replace = false
inc/activation.class.php DELETED
@@ -1,554 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin activation class.
4
- *
5
- * @since 1.1.0
6
- * @since 1.5 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Activation
17
- {
18
- private static $_instance ;
19
-
20
- const TYPE_UPGRADE = 'upgrade' ;
21
- const TYPE_INSTALL_3RD = 'install_3rd' ;
22
- const TYPE_INSTALL_ZIP = 'install_zip' ;
23
- const TYPE_DISMISS_RECOMMENDED = 'dismiss_recommended' ;
24
-
25
- const NETWORK_TRANSIENT_COUNT = 'lscwp_network_count' ;
26
-
27
- /**
28
- * The activation hook callback.
29
- *
30
- * Attempts to set up the advanced cache file. If it fails for any reason,
31
- * the plugin will not activate.
32
- *
33
- * @since 1.0.0
34
- * @access public
35
- */
36
- public static function register_activation()
37
- {
38
- $count = 0 ;
39
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
40
-
41
- if ( is_multisite() ) {
42
- $count = self::get_network_count() ;
43
- if ( $count !== false ) {
44
- $count = intval( $count ) + 1 ;
45
- set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
46
- }
47
- }
48
-
49
- do_action( 'litespeed_cache_api_load_thirdparty' ) ;
50
-
51
- $__cfg = LiteSpeed_Cache_Config::get_instance() ;
52
-
53
- // Bcos we may ask clients to deactivate for debug temporarily, we need to keep the current cfg in deactivation, hence we need to only try adding default cfg when activating.
54
- $res = add_option( LiteSpeed_Cache_Config::OPTION_NAME, $__cfg->get_default_options() ) ;
55
-
56
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( "[Cfg] plugin_activation update option = " . var_export( $res, true ) ) ;
57
-
58
- // Check new version @since 2.9.3
59
- LiteSpeed_Cache_Utility::version_check( 'new' . ( defined( 'LSCWP_REF' ) ? '_' . LSCWP_REF : '' ) ) ;
60
-
61
- /**
62
- * Handle files:
63
- * 1) wp-config.php;
64
- * 2) adv-cache.php;
65
- * 3) object-cache.php;
66
- * 4) .htaccess;
67
- */
68
-
69
- /* Network file handler */
70
-
71
- if ( is_multisite() ) {
72
-
73
- if ( ! is_network_admin() ) {
74
- if ( $count === 1 ) {
75
- // Only itself is activated, set .htaccess with only CacheLookUp
76
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
77
- }
78
- return ;
79
- }
80
-
81
- // All .htaccess & OC related options are in site, so only need these options
82
- $options = $__cfg->get_site_options() ;
83
-
84
- $ids = array(
85
- LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS,
86
- LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
87
- );
88
- foreach ( $ids as $id ) {
89
- $options[ $id ] = $__cfg->get_item( $id ) ;
90
- }
91
-
92
- if ( ! empty($options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ]) ) {
93
- $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] =
94
- addslashes( $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] );
95
- }
96
-
97
- LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $options, true ) ;
98
- return ;
99
- }
100
-
101
- /* Single site file handler */
102
-
103
- $options = $__cfg->get_options() ;
104
-
105
- // Add items
106
- $cfg_items = $__cfg->stored_items() ;
107
- foreach ( $cfg_items as $v ) {
108
- $options[ $v ] = $__cfg->get_item( $v ) ;
109
- }
110
-
111
- /**
112
- * Go through all settings to generate related files
113
- * @since 2.7.1
114
- */
115
- LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
116
-
117
- if ( defined( 'LSCWP_REF' ) && LSCWP_REF == 'whm' ) {
118
- update_option( LiteSpeed_Cache::WHM_MSG, LiteSpeed_Cache::WHM_MSG_VAL ) ;
119
- }
120
-
121
- // Register crawler cron task
122
- LiteSpeed_Cache_Task::update() ;
123
- }
124
-
125
- /**
126
- * Uninstall plugin
127
- * @since 1.1.0
128
- */
129
- public static function uninstall_litespeed_cache()
130
- {
131
- LiteSpeed_Cache_Task::clear() ;
132
- LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules() ;
133
- delete_option( LiteSpeed_Cache_Config::OPTION_NAME ) ;
134
- if ( is_multisite() ) {
135
- delete_site_option( LiteSpeed_Cache_Config::OPTION_NAME ) ;
136
- }
137
-
138
- LiteSpeed_Cache_Utility::version_check( 'uninstall' ) ;
139
- }
140
-
141
- /**
142
- * Get the blog ids for the network. Accepts function arguments.
143
- *
144
- * Will use wp_get_sites for WP versions less than 4.6
145
- *
146
- * @since 1.0.12
147
- * @access public
148
- * @param array $args Arguments to pass into get_sites/wp_get_sites.
149
- * @return array The array of blog ids.
150
- */
151
- public static function get_network_ids( $args = array() )
152
- {
153
- global $wp_version ;
154
- if ( version_compare( $wp_version, '4.6', '<' ) ) {
155
- $blogs = wp_get_sites( $args ) ;
156
- if ( ! empty( $blogs ) ) {
157
- foreach ( $blogs as $key => $blog ) {
158
- $blogs[ $key ] = $blog[ 'blog_id' ] ;
159
- }
160
- }
161
- }
162
- else {
163
- $args[ 'fields' ] = 'ids' ;
164
- $blogs = get_sites( $args ) ;
165
- }
166
- return $blogs ;
167
- }
168
-
169
- /**
170
- * Gets the count of active litespeed cache plugins on multisite.
171
- *
172
- * @since 1.0.12
173
- * @access private
174
- * @return mixed The count on success, false on failure.
175
- */
176
- private static function get_network_count()
177
- {
178
- $count = get_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
179
- if ( $count !== false ) {
180
- return intval( $count ) ;
181
- }
182
- // need to update
183
- $default = array() ;
184
- $count = 0 ;
185
-
186
- $sites = self::get_network_ids( array( 'deleted' => 0 ) ) ;
187
- if ( empty( $sites ) ) {
188
- return false ;
189
- }
190
-
191
- foreach ( $sites as $site ) {
192
- $bid = is_object( $site ) && property_exists( $site, 'blog_id' ) ? $site->blog_id : $site ;
193
- $plugins = get_blog_option( $bid , 'active_plugins', $default ) ;
194
- if ( in_array( LSCWP_BASENAME, $plugins, true ) ) {
195
- $count++ ;
196
- }
197
- }
198
-
199
- /**
200
- * In case this is called outside the admin page
201
- * @see https://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
202
- * @since 2.0
203
- */
204
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
205
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;
206
- }
207
-
208
- if ( is_plugin_active_for_network( LSCWP_BASENAME ) ) {
209
- $count++ ;
210
- }
211
- return $count ;
212
- }
213
-
214
- /**
215
- * Is this deactivate call the last active installation on the multisite
216
- * network?
217
- *
218
- * @since 1.0.12
219
- * @access private
220
- * @return bool True if yes, false otherwise.
221
- */
222
- private static function is_deactivate_last()
223
- {
224
- $count = self::get_network_count() ;
225
- if ( $count === false ) {
226
- return false ;
227
- }
228
- if ( $count !== 1 ) {
229
- // Not deactivating the last one.
230
- $count-- ;
231
- set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
232
- return false ;
233
- }
234
-
235
- delete_site_transient( self::NETWORK_TRANSIENT_COUNT ) ;
236
- return true ;
237
- }
238
-
239
- /**
240
- * The deactivation hook callback.
241
- *
242
- * Initializes all clean up functionalities.
243
- *
244
- * @since 1.0.0
245
- * @access public
246
- */
247
- public static function register_deactivation()
248
- {
249
- LiteSpeed_Cache_Task::clear() ;
250
-
251
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Deactivate_' . get_current_blog_id() ) ;
252
-
253
- LiteSpeed_Cache_Purge::purge_all() ;
254
-
255
- if ( is_multisite() ) {
256
-
257
- if ( ! self::is_deactivate_last() ) {
258
- if ( is_network_admin() ) {
259
- // Still other activated subsite left, set .htaccess with only CacheLookUp
260
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
261
- }
262
- return ;
263
- }
264
- }
265
-
266
- $adv_cache_path = LSCWP_CONTENT_DIR . '/advanced-cache.php' ;
267
- // this file can be generated by other cache plugin like w3tc, we only delete our own file
268
- if ( file_exists( $adv_cache_path ) && is_writable( $adv_cache_path ) ) {
269
- if ( strpos( file_get_contents( $adv_cache_path ), 'LSCACHE_ADV_CACHE' ) !== false ) {
270
- unlink( $adv_cache_path ) ;
271
- }
272
- else {
273
- error_log(' Keep advanced-cache.php as it belongs to other plugins' ) ;
274
- }
275
- }
276
- else {
277
- error_log( 'Failed to remove advanced-cache.php, file does not exist or is not writable!' ) ;
278
- }
279
-
280
- /**
281
- * Remove object cache file if is us
282
- * @since 1.8.2
283
- */
284
- LiteSpeed_Cache_Object::get_instance()->del_file() ;
285
-
286
- if ( ! LiteSpeed_Cache_Config::wp_cache_var_setter( false ) ) {
287
- error_log('In wp-config.php: WP_CACHE could not be set to false during deactivation!') ;
288
- }
289
-
290
- LiteSpeed_Cache_Admin_Rules::get_instance()->clear_rules() ;
291
-
292
- // delete in case it's not deleted prior to deactivation.
293
- self::dismiss_whm() ;
294
- }
295
-
296
- /**
297
- * Try to copy our advanced-cache.php file to the wordpress directory.
298
- *
299
- * @since 1.0.11
300
- * @access public
301
- * @return boolean True on success, false on failure.
302
- */
303
- public static function try_copy_advanced_cache()
304
- {
305
- $adv_cache_path = LSCWP_CONTENT_DIR . '/advanced-cache.php' ;
306
- if ( file_exists( $adv_cache_path ) && ( filesize( $adv_cache_path ) !== 0 || ! is_writable( $adv_cache_path ) ) ) {
307
- return false ;
308
- }
309
-
310
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Activation] Copying advanced_cache file' ) ;
311
-
312
- copy( LSCWP_DIR . 'includes/advanced-cache.php', $adv_cache_path ) ;
313
-
314
- include $adv_cache_path ;
315
-
316
- $ret = defined( 'LSCACHE_ADV_CACHE' ) ;
317
-
318
- // Try to enable `LITESPEED_ON`
319
- LiteSpeed_Cache_Config::get_instance()->define_cache_on() ;
320
-
321
- return $ret ;
322
- }
323
-
324
- /**
325
- * Delete whm msg tag
326
- *
327
- * @since 1.1.1
328
- * @access public
329
- */
330
- public static function dismiss_whm()
331
- {
332
- delete_option( LiteSpeed_Cache::WHM_MSG ) ;
333
- }
334
-
335
- /**
336
- * Handle auto update
337
- *
338
- * @since 2.7.2
339
- * @since 2.9.8 Moved here from ls.cls
340
- * @access public
341
- */
342
- public static function auto_update()
343
- {
344
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
345
- return ;
346
- }
347
-
348
- add_filter( 'auto_update_plugin', function( $update, $item ) {
349
- if ( $item->slug == 'litespeed-cache' ) {
350
- $auto_v = LiteSpeed_Cache_Utility::version_check( 'auto_update_plugin' ) ;
351
-
352
- if ( $auto_v && ! empty( $item->new_version ) && $auto_v === $item->new_version ) {
353
- return true ;
354
- }
355
- }
356
-
357
- return $update; // Else, use the normal API response to decide whether to update or not
358
- }, 10, 2 ) ;
359
- }
360
-
361
- /**
362
- * Upgrade LSCWP
363
- *
364
- * @since 2.9
365
- * @access public
366
- */
367
- public function upgrade()
368
- {
369
- $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
370
-
371
- /**
372
- * @see wp-admin/update.php
373
- */
374
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ;
375
- include_once ABSPATH . 'wp-admin/includes/file.php' ;
376
- include_once ABSPATH . 'wp-admin/includes/misc.php' ;
377
-
378
- try {
379
- ob_start() ;
380
- $skin = new \WP_Ajax_Upgrader_Skin() ;
381
- $upgrader = new \Plugin_Upgrader( $skin ) ;
382
- $result = $upgrader->upgrade( $plugin ) ;
383
- if ( ! is_plugin_active( $plugin ) ) {// todo: upgrade should reactivate the plugin again by WP. Need to check why disabled after upgraded.
384
- activate_plugin( $plugin ) ;
385
- }
386
- ob_end_clean() ;
387
- } catch ( \Exception $e ) {
388
- LiteSpeed_Cache_Admin_Display::error( __( 'Failed to upgrade.', 'litespeed-cache' ) ) ;
389
- return ;
390
- }
391
-
392
- if ( is_wp_error( $result ) ) {
393
- LiteSpeed_Cache_Admin_Display::error( __( 'Failed to upgrade.', 'litespeed-cache' ) ) ;
394
- return ;
395
- }
396
-
397
- LiteSpeed_Cache_Admin_Display::succeed( __( 'Upgraded successfully.', 'litespeed-cache' ) ) ;
398
- }
399
-
400
- /**
401
- * Detect if the plugin is active or not
402
- *
403
- * @since 1.0
404
- */
405
- public function dash_notifier_is_plugin_active( $plugin )
406
- {
407
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' ) ;
408
-
409
- $plugin_path = $plugin . '/' . $plugin . '.php' ;
410
-
411
- return is_plugin_active( $plugin_path ) ;
412
- }
413
-
414
- /**
415
- * Detect if the plugin is installed or not
416
- *
417
- * @since 1.0
418
- */
419
- public function dash_notifier_is_plugin_installed( $plugin )
420
- {
421
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' ) ;
422
-
423
- $plugin_path = $plugin . '/' . $plugin . '.php' ;
424
-
425
- $valid = validate_plugin( $plugin_path ) ;
426
-
427
- return ! is_wp_error( $valid ) ;
428
- }
429
-
430
- /**
431
- * Grab a plugin info from WordPress
432
- *
433
- * @since 1.0
434
- */
435
- public function dash_notifier_get_plugin_info( $slug )
436
- {
437
- include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ) ;
438
- $result = plugins_api( 'plugin_information', array( 'slug' => $slug ) ) ;
439
-
440
- if ( is_wp_error( $result ) ) {
441
- return false ;
442
- }
443
-
444
- return $result ;
445
- }
446
-
447
- /**
448
- * Install the 3rd party plugin
449
- *
450
- * @since 1.0
451
- */
452
- public function dash_notifier_install_3rd()
453
- {
454
- ! defined( 'SILENCE_INSTALL' ) && define( 'SILENCE_INSTALL', true );
455
-
456
- $slug = ! empty( $_GET[ 'plugin' ] ) ? $_GET[ 'plugin' ] : false;
457
-
458
- // Check if plugin is installed already
459
- if ( ! $slug || $this->dash_notifier_is_plugin_active( $slug ) ) {
460
- return ;
461
- }
462
-
463
- /**
464
- * @see wp-admin/update.php
465
- */
466
- include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ;
467
- include_once ABSPATH . 'wp-admin/includes/file.php' ;
468
- include_once ABSPATH . 'wp-admin/includes/misc.php' ;
469
-
470
- $plugin_path = $slug . '/' . $slug . '.php' ;
471
-
472
- if ( ! $this->dash_notifier_is_plugin_installed( $slug ) ) {
473
- $plugin_info = $this->dash_notifier_get_plugin_info( $slug ) ;
474
- if ( ! $plugin_info ) {
475
- return ;
476
- }
477
- // Try to install plugin
478
- try {
479
- ob_start() ;
480
- $skin = new \Automatic_Upgrader_Skin() ;
481
- $upgrader = new \Plugin_Upgrader( $skin ) ;
482
- $result = $upgrader->install( $plugin_info->download_link ) ;
483
- ob_end_clean() ;
484
- } catch ( \Exception $e ) {
485
- return ;
486
- }
487
- }
488
-
489
- if ( ! is_plugin_active( $plugin_path ) ) {
490
- activate_plugin( $plugin_path ) ;
491
- }
492
-
493
- }
494
-
495
- /**
496
- * Handle all request actions from main cls
497
- *
498
- * @since 2.9
499
- * @access public
500
- */
501
- public static function handler()
502
- {
503
- $instance = self::get_instance() ;
504
-
505
- $type = LiteSpeed_Cache_Router::verify_type() ;
506
-
507
- switch ( $type ) {
508
- case self::TYPE_UPGRADE :
509
- $instance->upgrade() ;
510
- break ;
511
-
512
- case self::TYPE_INSTALL_3RD :
513
- $instance->dash_notifier_install_3rd() ;
514
- break ;
515
-
516
- case self::TYPE_DISMISS_RECOMMENDED :
517
- $news = get_option( 'litespeed-recommended', array() );
518
- $news[ 'new' ] = 0;
519
- update_option( 'litespeed-recommended', $news );
520
- break ;
521
-
522
- case self::TYPE_INSTALL_ZIP :
523
- $news = get_option( 'litespeed-recommended', array() );
524
- if ( ! empty( $news[ 'zip' ] ) ) {
525
- $news[ 'new' ] = 0;
526
- update_option( 'litespeed-recommended', $news );
527
- LiteSpeed_Cache_Log::get_instance()->beta_test( $news[ 'zip' ] );
528
- }
529
- break ;
530
-
531
- default:
532
- break ;
533
- }
534
-
535
- LiteSpeed_Cache_Admin::redirect() ;
536
- }
537
-
538
- /**
539
- * Get the current instance object.
540
- *
541
- * @since 2.9
542
- * @access public
543
- * @return Current class instance.
544
- */
545
- public static function get_instance()
546
- {
547
- if ( ! isset( self::$_instance ) ) {
548
- self::$_instance = new self() ;
549
- }
550
-
551
- return self::$_instance ;
552
- }
553
-
554
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/api.class.php DELETED
@@ -1,658 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin API class.
4
- *
5
- * @since 1.1.3
6
- * @since 1.4 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
17
- {
18
- const VERSION = LiteSpeed_Cache::PLUGIN_VERSION ;
19
-
20
- const TYPE_FEED = LiteSpeed_Cache_Tag::TYPE_FEED ;
21
- const TYPE_FRONTPAGE = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
22
- const TYPE_HOME = LiteSpeed_Cache_Tag::TYPE_HOME ;
23
- const TYPE_PAGES = LiteSpeed_Cache_Tag::TYPE_PAGES ;
24
- const TYPE_PAGES_WITH_RECENT_POSTS = LiteSpeed_Cache_Tag::TYPE_PAGES_WITH_RECENT_POSTS ;
25
- const TYPE_ERROR = LiteSpeed_Cache_Tag::TYPE_ERROR ;
26
- const TYPE_POST = LiteSpeed_Cache_Tag::TYPE_POST ;
27
- const TYPE_ARCHIVE_POSTTYPE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_POSTTYPE ;
28
- const TYPE_ARCHIVE_TERM = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM ;
29
- const TYPE_AUTHOR = LiteSpeed_Cache_Tag::TYPE_AUTHOR ;
30
- const TYPE_ARCHIVE_DATE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE ;
31
- const TYPE_BLOG = LiteSpeed_Cache_Tag::TYPE_BLOG ;
32
- const TYPE_LOGIN = LiteSpeed_Cache_Tag::TYPE_LOGIN ;
33
- const TYPE_URL = LiteSpeed_Cache_Tag::TYPE_URL ;
34
- const TYPE_WIDGET = LiteSpeed_Cache_Tag::TYPE_WIDGET ;
35
-
36
- const PARAM_NAME = LiteSpeed_Cache_ESI::PARAM_NAME ;
37
- const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
- const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
-
40
- /**
41
- * Disable All
42
- *
43
- * @since 2.9.7.2
44
- * @access public
45
- */
46
- public static function disable_all( $reason )
47
- {
48
- self::debug( '[API] Disabled_all due to ' . $reason ) ;
49
-
50
- ! defined( 'LITESPEED_DISABLE_ALL' ) && define( 'LITESPEED_DISABLE_ALL', true ) ;
51
- }
52
-
53
- /**
54
- * Force to set an option
55
- * Note: it will only affect the AFTER usage of that option
56
- *
57
- * @since 2.6
58
- * @access public
59
- */
60
- public static function force_option( $k, $v )
61
- {
62
- LiteSpeed_Cache_Config::get_instance()->force_option( $k, $v ) ;
63
- }
64
-
65
- /**
66
- * Start a to-be-removed html wrapper
67
- *
68
- * @since 1.4
69
- * @access public
70
- */
71
- public static function clean_wrapper_begin( $counter = false )
72
- {
73
- return LiteSpeed_Cache_GUI::clean_wrapper_begin( $counter ) ;
74
- }
75
-
76
- /**
77
- * End a to-be-removed html wrapper
78
- *
79
- * @since 1.4
80
- * @access public
81
- */
82
- public static function clean_wrapper_end( $counter = false )
83
- {
84
- return LiteSpeed_Cache_GUI::clean_wrapper_end( $counter ) ;
85
- }
86
-
87
- /**
88
- * Compare version
89
- *
90
- * @since 1.3
91
- * @access public
92
- */
93
- public static function v( $v )
94
- {
95
- return version_compare( self::VERSION, $v, '>=' ) ;
96
- }
97
-
98
- /**
99
- * Set mobile
100
- *
101
- * @since 1.1.3
102
- * @access public
103
- */
104
- public static function set_mobile()
105
- {
106
- LiteSpeed_Cache_Control::set_mobile() ;
107
- }
108
-
109
- /**
110
- * Set cache status to not cacheable
111
- *
112
- * @since 1.1.3
113
- * @access public
114
- */
115
- public static function set_cache_private()
116
- {
117
- LiteSpeed_Cache_Control::set_private() ;
118
- }
119
-
120
- /**
121
- * Set cache status to no vary
122
- *
123
- * @since 1.2.0
124
- * @access public
125
- */
126
- public static function set_cache_no_vary()
127
- {
128
- LiteSpeed_Cache_Control::set_no_vary() ;
129
- }
130
-
131
- /**
132
- * Set cache status to not cacheable
133
- *
134
- * @since 1.1.3
135
- * @access public
136
- */
137
- public static function set_nocache( $reason = false )
138
- {
139
- LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
140
- }
141
-
142
- /**
143
- * Set cache status to cacheable ( By default cacheable status will be set when called WP hook `wp` )
144
- *
145
- * @since 2.2
146
- * @access public
147
- */
148
- public static function set_cacheable( $reason )
149
- {
150
- LiteSpeed_Cache_Control::set_cacheable( $reason ) ;
151
- }
152
-
153
- /**
154
- * Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions )
155
- *
156
- * @since 2.2
157
- * @access public
158
- */
159
- public static function set_force_cacheable( $reason )
160
- {
161
- LiteSpeed_Cache_Control::force_cacheable( $reason ) ;
162
- }
163
-
164
- /**
165
- * Set cache to force public cache if cacheable ( Will ignore most kinds of non-cacheable conditions )
166
- *
167
- * @since 2.9.7.2
168
- * @access public
169
- */
170
- public static function set_force_public( $reason )
171
- {
172
- LiteSpeed_Cache_Control::set_public_forced( $reason ) ;
173
- }
174
-
175
- /**
176
- * Get current not cacheable status
177
- *
178
- * @since 1.1.3
179
- * @access public
180
- */
181
- public static function not_cacheable()
182
- {
183
- return ! LiteSpeed_Cache_Control::is_cacheable() ;
184
- }
185
-
186
- /**
187
- * Set cache control ttl to use frontpage ttl
188
- *
189
- * @since 1.1.3
190
- * @access public
191
- */
192
- public static function set_use_frontpage_ttl()
193
- {
194
- LiteSpeed_Cache_Control::set_custom_ttl( self::config( self::OPID_FRONT_PAGE_TTL ) ) ;
195
- }
196
-
197
- /**
198
- * Set cache control ttl
199
- *
200
- * @since 1.1.5
201
- * @access public
202
- */
203
- public static function set_ttl( $val )
204
- {
205
- LiteSpeed_Cache_Control::set_custom_ttl( $val ) ;
206
- }
207
-
208
- /**
209
- * Get current cache control ttl
210
- *
211
- * @since 1.1.5
212
- * @access public
213
- */
214
- public static function get_ttl()
215
- {
216
- return LiteSpeed_Cache_Control::get_ttl() ;
217
- }
218
-
219
- /**
220
- * Add public tag to cache
221
- *
222
- * @since 1.1.3
223
- * @access public
224
- */
225
- public static function tag_add($tags)
226
- {
227
- LiteSpeed_Cache_Tag::add($tags) ;
228
- }
229
-
230
- /**
231
- * Add public tag to cache
232
- *
233
- * @since 1.6.3
234
- * @access public
235
- */
236
- public static function add_private( $tags )
237
- {
238
- LiteSpeed_Cache_Tag::add_private( $tags ) ;
239
- }
240
-
241
- /**
242
- * Hook new vary cookies to vary finialization
243
- *
244
- * @since 2.6
245
- * @access public
246
- */
247
- public static function hook_vary_add( $hook )
248
- {
249
- add_action( 'litespeed_vary_add', $hook ) ;
250
- }
251
-
252
- /**
253
- * Add a new vary cookie
254
- *
255
- * @since 1.1.3
256
- * @since 2.7.1 Changed to filter hook instead of `LiteSpeed_Cache_Vary::add()`
257
- * @access public
258
- */
259
- public static function vary_add( $vary, $priority = 10 )
260
- {
261
- add_filter( 'litespeed_vary_cookies', function( $cookies ) use( $vary ) {
262
- if ( ! is_array( $vary ) ) {
263
- $vary = array( $vary ) ;
264
- }
265
- $cookies = array_merge( $cookies, $vary ) ;
266
- return $cookies ;
267
- }, $priority ) ;
268
- }
269
-
270
- /**
271
- * Hook vary cookies to vary finialization
272
- *
273
- * @since 2.7.1
274
- * @access public
275
- */
276
- public static function filter_vary_cookies( $hook, $priority = 10 )
277
- {
278
- add_filter( 'litespeed_vary_cookies', $hook, $priority ) ;
279
- }
280
-
281
- /**
282
- * Alter default vary cookie value
283
- *
284
- * Default vary cookie is an array before finalization, after that it will be combined to a string and store as default vary cookie name
285
- *
286
- * @since 2.6
287
- * @access public
288
- */
289
- public static function vary( $k, $v, $default = null )
290
- {
291
- if ( $v === $default ) {
292
- return ;
293
- }
294
- LiteSpeed_Cache_Vary::append( $k, $v ) ;
295
- }
296
-
297
- /**
298
- * Hook vary tags to default vary finialization
299
- *
300
- * @since 1.7.2
301
- * @access public
302
- */
303
- public static function hook_vary_finalize( $hook )
304
- {
305
- add_filter( 'litespeed_vary', $hook ) ;
306
- }
307
-
308
- /**
309
- * Force finalize vary even if its in an AJAX call
310
- *
311
- * @since 2.6
312
- * @access public
313
- */
314
- public static function force_vary()
315
- {
316
- LiteSpeed_Cache_Vary::can_ajax_vary() ;
317
- }
318
-
319
- /**
320
- * Hook vary appending to vary
321
- *
322
- * NOTE: This will add vary to rewrite rule
323
- *
324
- * @since 1.1.3
325
- * @since 2.7.1 This didn't work in 2.7- due to used add_action not filter
326
- * @access public
327
- */
328
- public static function hook_vary( $hook )
329
- {
330
- add_filter( 'litespeed_cache_api_vary', $hook ) ;
331
- }
332
-
333
- /**
334
- * Purge all action
335
- *
336
- * @since 1.1.3
337
- * @access public
338
- */
339
- public static function purge_all()
340
- {
341
- LiteSpeed_Cache_Purge::purge_all() ;
342
- }
343
-
344
- /**
345
- * Purge all private
346
- *
347
- * @since 1.6.3
348
- * @access public
349
- */
350
- public static function purge_private_all()
351
- {
352
- LiteSpeed_Cache_Purge::add_private( '*' ) ;
353
- }
354
-
355
- /**
356
- * Purge private tag
357
- *
358
- * @since 1.6.3
359
- * @access public
360
- */
361
- public static function purge_private( $tags )
362
- {
363
- LiteSpeed_Cache_Purge::add_private( $tags ) ;
364
- }
365
-
366
- /**
367
- * Purge single action
368
- *
369
- * @since 1.3
370
- * @access public
371
- * @param int $pid The ID of a post
372
- */
373
- public static function purge_post( $pid )
374
- {
375
- LiteSpeed_Cache_Purge::purge_post( $pid ) ;
376
- }
377
-
378
- /**
379
- * Add purge tags
380
- *
381
- * @since 1.1.3
382
- * @access public
383
- */
384
- public static function purge($tags)
385
- {
386
- LiteSpeed_Cache_Purge::add($tags) ;
387
- }
388
-
389
- /**
390
- * Build a switch div html snippet
391
- *
392
- * @since 1.1.3
393
- * @access public
394
- * @param string $id
395
- * @param boolean $return Return the html or echo it
396
- */
397
- public static function build_switch( $id, $checked = null, $return = false )
398
- {
399
- return LiteSpeed_Cache_Admin_Display::get_instance()->build_switch( $id, $checked, $return ) ;
400
- }
401
-
402
- /**
403
- * Filter the value for checkbox via input and id (enabled/disabled)
404
- *
405
- * @since 1.1.6
406
- * @access public
407
- * @param int $input The whole input array
408
- * @param string $id The ID of the option
409
- * @return bool Filtered value
410
- */
411
- public static function parse_onoff( $input, $id )
412
- {
413
- return LiteSpeed_Cache_Admin_Settings::parse_onoff( $input, $id ) ;
414
- }
415
-
416
-
417
- /**
418
- * Hook cacheable check to cache control
419
- *
420
- * @since 1.1.3
421
- * @access public
422
- */
423
- public static function hook_control($hook)
424
- {
425
- add_action('litespeed_cache_api_control', $hook) ;
426
- }
427
-
428
- /**
429
- * Hook tag appending to tag
430
- *
431
- * @since 1.1.3
432
- * @access public
433
- */
434
- public static function hook_tag($hook)
435
- {
436
- add_action('litespeed_cache_api_tag', $hook) ;
437
- }
438
-
439
- /**
440
- * Hook purge tags appending to purge
441
- *
442
- * @since 1.1.3
443
- * @access public
444
- */
445
- public static function hook_purge($hook)
446
- {
447
- add_action('litespeed_cache_api_purge', $hook) ;
448
- }
449
-
450
- /**
451
- * Hook purge post action to purge
452
- *
453
- * @since 1.1.3
454
- * @access public
455
- */
456
- public static function hook_purge_post($hook)
457
- {
458
- add_action('litespeed_cache_api_purge_post', $hook) ;
459
- }
460
-
461
- /**
462
- * Hook not ESI template
463
- *
464
- * @since 1.1.3
465
- * @access public
466
- */
467
- public static function hook_tpl_not_esi($hook)
468
- {
469
- add_action('litespeed_cache_is_not_esi_template', $hook) ;
470
- }
471
-
472
- /**
473
- * Hook ESI template block
474
- *
475
- * @since 1.1.3
476
- * @access public
477
- */
478
- public static function hook_tpl_esi($block, $hook)
479
- {
480
- add_action('litespeed_cache_load_esi_block-' . $block, $hook) ;
481
- }
482
-
483
- /**
484
- * Hook ESI params
485
- *
486
- * @since 1.1.3
487
- * @since 2.9.8.1 Changed hook name and params
488
- * @access public
489
- */
490
- public static function hook_esi_param( $hook, $priority = 10, $args = 2 )
491
- {
492
- add_filter( 'litespeed_esi_params', $hook, $priority, $args ) ;
493
- }
494
-
495
- /**
496
- * Hook setting tab
497
- *
498
- * @since 1.1.3
499
- * @access public
500
- */
501
- public static function hook_setting_tab($hook, $priority = 10, $args = 1)
502
- {
503
- add_filter('litespeed_cache_add_config_tab', $hook, $priority, $args) ;
504
- }
505
-
506
- /**
507
- * Hook setting saving
508
- *
509
- * @since 1.1.3
510
- * @access public
511
- */
512
- public static function hook_setting_save($hook, $priority = 10, $args = 1)
513
- {
514
- add_filter('litespeed_cache_save_options', $hook, $priority, $args) ;
515
- }
516
-
517
- /**
518
- * Hook widget default settings value
519
- *
520
- * @since 1.1.3
521
- * @access public
522
- */
523
- public static function hook_widget_default_options($hook, $priority = 10, $args = 1)
524
- {
525
- add_filter('litespeed_cache_widget_default_options', $hook, $priority, $args) ;
526
- }
527
-
528
- /**
529
- * Hook get options value
530
- *
531
- * @since 1.1.3
532
- * @access public
533
- */
534
- public static function hook_get_options($hook)
535
- {
536
- add_filter('litespeed_cache_get_options', $hook) ;
537
- }
538
-
539
- /**
540
- * Generate ESI block url
541
- *
542
- * @since 1.1.3
543
- * @access public
544
- * @param string $control Cache control tag
545
- */
546
- public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false, $preserved = false, $svar = false, $inline_val = false )
547
- {
548
- if ( $control === 'default' ) {
549
- $control = 'private,no-vary' ;
550
- }
551
- return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence, $preserved, $svar, $inline_val ) ;
552
- }
553
-
554
- /**
555
- * Easiest way to replace WP nonce to an ESI widget
556
- *
557
- * @since 2.6
558
- * @deprecated 2.9.5 Dropped-in wp_create_nonce replacement
559
- * @access public
560
- */
561
- public static function nonce( $action = -1, $defence_for_html_filter = true )
562
- {
563
- if ( ! self::esi_enabled() ) {
564
- return wp_create_nonce( $action ) ;
565
- }
566
-
567
- // Replace it to ESI
568
- return self::esi_url( 'nonce', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
569
- }
570
-
571
- /**
572
- * Append an action to nonce to convert it to ESI
573
- *
574
- * @since 2.9.5
575
- */
576
- public static function nonce_action( $action )
577
- {
578
- LiteSpeed_Cache_ESI::get_instance()->nonce_action( $action ) ;
579
- }
580
-
581
- /**
582
- * Log debug info
583
- *
584
- * @since 1.1.3
585
- * @access public
586
- */
587
- public static function debug( $info, $backtrace_limit = false )
588
- {
589
- LiteSpeed_Cache_Log::debug( $info, $backtrace_limit ) ;
590
- }
591
-
592
- /**
593
- * Log debug info ( advanced mode )
594
- *
595
- * @since 1.6.6.1
596
- * @access public
597
- */
598
- public static function debug2( $info, $backtrace_limit = false )
599
- {
600
- LiteSpeed_Cache_Log::debug2( $info, $backtrace_limit ) ;
601
- }
602
-
603
- /**
604
- * Get ESI enable setting value
605
- *
606
- * @since 1.2.0
607
- * @access public
608
- */
609
- public static function esi_enabled()
610
- {
611
- return LiteSpeed_Cache_Router::esi_enabled() ;
612
- }
613
-
614
- /**
615
- * Get cache enable setting value
616
- *
617
- * @since 1.3
618
- * @access public
619
- */
620
- public static function cache_enabled()
621
- {
622
- return defined( 'LITESPEED_ON' ) ;
623
- }
624
-
625
- /**
626
- * Get cfg setting value
627
- *
628
- * @since 1.1.3
629
- * @access public
630
- */
631
- public static function config($id)
632
- {
633
- return LiteSpeed_Cache::config($id) ;
634
- }
635
-
636
- /**
637
- * register 3rd party detect hooks
638
- *
639
- * @since 1.1.3
640
- * @access public
641
- */
642
- public static function register($cls)
643
- {
644
- add_action('litespeed_cache_api_load_thirdparty', $cls . '::detect') ;
645
- }
646
-
647
- /**
648
- * Hook to litespeed init
649
- *
650
- * @since 1.6.6
651
- * @access public
652
- */
653
- public static function hook_init( $hook )
654
- {
655
- add_action( 'litespeed_init', $hook ) ;
656
- }
657
-
658
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/cdn/quic.class.php DELETED
@@ -1,257 +0,0 @@
1
- <?php
2
- /**
3
- * The quic.cloud class.
4
- *
5
- * @since 2.4.1
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_CDN_Quic
11
- {
12
- private static $_instance ;
13
-
14
- private $_api_key ;
15
-
16
- const TYPE_REG = 'reg' ;
17
-
18
- const DB_API_HASH = 'litespeed_cdn_quic_hash' ;
19
-
20
- /**
21
- * Notify CDN new config updated
22
- *
23
- * @access public
24
- */
25
- public static function sync_config( $options )
26
- {
27
- if ( empty( $options[ LiteSpeed_Cache_Config::OPT_CDN_QUIC_EMAIL ] ) || empty( $options[ LiteSpeed_Cache_Config::OPT_CDN_QUIC_KEY ] ) ) {
28
- return false ;
29
- }
30
-
31
- // Security: Remove cf key in report
32
- $secure_fields = array(
33
- LiteSpeed_Cache_Config::OPID_CDN_CLOUDFLARE_KEY,
34
- LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PSWD,
35
- ) ;
36
- foreach ( $secure_fields as $v ) {
37
- if ( ! empty( $options[ $v ] ) ) {
38
- $options[ $v ] = str_repeat( '*', strlen( $options[ $v ] ) ) ;
39
- }
40
- }
41
-
42
- // Also read data from items
43
- $item_options = LiteSpeed_Cache_Config::get_instance()->stored_items() ;
44
- foreach ( $item_options as $v ) {
45
- // bypass main conf
46
- if ( $v == LiteSpeed_Cache_Config::OPTION_NAME ) {
47
- continue ;
48
- }
49
- $options[ $v ] = get_option( $v ) ;
50
- }
51
-
52
- $instance = self::get_instance() ;
53
-
54
- // Get site domain
55
- $options[ '_domain' ] = home_url() ;
56
-
57
- // Add server env vars
58
- $options[ '_server' ] = LiteSpeed_Cache_Config::get_instance()->server_vars() ;
59
-
60
- // Append hooks
61
- $options[ '_tp_cookies' ] = apply_filters( 'litespeed_cache_api_vary', array() ) ;
62
-
63
- $res = $instance->_api( '/sync_config', $options ) ;
64
- if ( $res != 'ok' ) {
65
- LiteSpeed_Cache_Log::debug( '[QUIC] sync config failed [err] ' . $res ) ;
66
- }
67
- return $res ;
68
- }
69
-
70
- private function _show_user_guide()
71
- {
72
- if ( ! empty( $_POST[ 'step' ] ) ) {
73
- if ( empty( $_POST[ 'email' ] ) ) {
74
- exit( 'No email' ) ;
75
- }
76
-
77
- if ( $_POST[ 'step' ] == 'register' ) {
78
- $this->_register() ;
79
- }
80
-
81
- if ( $_POST[ 'step' ] == 'login' ) {
82
- $this->_login() ;
83
- }
84
-
85
- if ( $_POST[ 'step' ] == 'check_email' ) {
86
- $this->_check_email() ;
87
- }
88
- }
89
-
90
- // Show user panel welcome page
91
- $this->_tpl( 'quic.user_welcome', 25 ) ;
92
- exit;
93
- }
94
-
95
-
96
- private function _check_email()
97
- {
98
- $_email = $_POST[ 'email' ] ;
99
-
100
- // Get email status
101
- $response = $this->_api( '/u/email_status', array( 'email' => $_email ) ) ;
102
- if ( empty( $response[ 'result' ] ) ) {
103
-
104
- LiteSpeed_Cache_Log::debug( '[QUIC] Query email failed' ) ;
105
-
106
- exit( "QUIC: Query email failed" ) ;
107
- }
108
-
109
- $data = array( 'email' => $_email ) ;
110
-
111
- if ( $response[ 'result' ] == 'existing' ) {
112
- $this->_tpl( 'quic.login', 50, $data ) ;
113
- }
114
- elseif ( $response[ 'result' ] == 'none' ) {
115
- $this->_tpl( 'quic.register', 50, $data ) ;
116
- }
117
- else {
118
- exit( 'Unkown result' ) ;
119
- }
120
-
121
- exit ;
122
- }
123
-
124
- private function _register()
125
- {
126
- $_email = $_POST[ 'email' ] ;
127
-
128
- if ( empty( $_POST[ 'pswd' ] ) ) {
129
- exit( 'No password' ) ;
130
- }
131
-
132
- // Register
133
- $response = $this->_api( '/u/register', array( 'email' => $_email, 'pswd' => $_POST[ 'pswd' ] ) ) ;
134
- if ( empty( $response[ 'result' ] ) || $response[ 'result' ] !== 'success' ) {
135
-
136
- LiteSpeed_Cache_Log::debug( '[QUIC] Register failed' ) ;
137
-
138
- exit( "QUIC: Register failed" ) ;
139
- }
140
-
141
- // todo: add domain?
142
-
143
- exit ;
144
-
145
- }
146
-
147
- private function _login()
148
- {
149
- $_email = $_POST[ 'email' ] ;
150
-
151
- if ( empty( $_POST[ 'pswd' ] ) ) {
152
- exit( 'No password' ) ;
153
- }
154
-
155
- // Login
156
- $response = $this->_api( '/u/login', array( 'email' => $_email, 'pswd' => $_POST[ 'pswd' ] ) ) ;
157
-
158
- $data = array( 'email' => $_email ) ;
159
-
160
- // for login failed, redirect back to login page
161
- if ( empty( $response[ 'result' ] ) || $response[ 'result' ] !== 'success' ) {
162
-
163
- LiteSpeed_Cache_Log::debug( '[QUIC] Login failed' ) ;
164
-
165
- $data[ '_err' ] = $response[ 'result' ] ;
166
-
167
- $this->_tpl( 'quic.login', 50, $data ) ;
168
- exit ;
169
- }
170
-
171
- // Show domains list
172
- $this->_show_domains() ;
173
-
174
- exit ;
175
- }
176
-
177
- private function _tpl( $tpl, $_progress = false, $data = false )
178
- {
179
- require LSCWP_DIR . "admin/tpl/inc/modal.header.php" ;
180
- require LSCWP_DIR . "admin/tpl/api/$tpl.php" ;
181
- require LSCWP_DIR . "admin/tpl/inc/modal.footer.php" ;
182
- }
183
-
184
- private function _api( $uri, $data = false, $method = 'POST', $no_hash = false )
185
- {
186
- LiteSpeed_Cache_Log::debug( '[QUIC] _api call' ) ;
187
-
188
- $hash = 'no_hash' ;
189
- if ( ! $no_hash ) {
190
- $hash = Litespeed_String::rrand( 16 ) ;
191
- // store hash
192
- update_option( self::DB_API_HASH, $hash ) ;
193
- }
194
-
195
- $url = 'https://api.quic.cloud' . $uri ;
196
-
197
- $param = array(
198
- '_v' => LiteSpeed_Cache::PLUGIN_VERSION,
199
- '_hash' => $hash,
200
- '_data' => $data,
201
- ) ;
202
-
203
- $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => 15 ) ) ;
204
-
205
-
206
- if ( is_wp_error( $response ) ) {
207
- $error_message = $response->get_error_message() ;
208
- LiteSpeed_Cache_Log::debug( '[QUIC] failed to post: ' . $error_message ) ;
209
- return $error_message ;
210
- }
211
- LiteSpeed_Cache_Log::debug( '[QUIC] _api call response: ' . $response[ 'body' ] ) ;
212
-
213
- $json = json_decode( $response[ 'body' ], true ) ;
214
-
215
- return $json ;
216
-
217
- }
218
-
219
- /**
220
- * Handle all request actions from main cls
221
- *
222
- * @since 2.0
223
- * @access public
224
- */
225
- public static function handler()
226
- {
227
- LiteSpeed_Cache_Log::debug( '[QUIC] init' ) ;
228
- $instance = self::get_instance() ;
229
-
230
- $type = LiteSpeed_Cache_Router::verify_type() ;
231
-
232
- switch ( $type ) {
233
-
234
- default:
235
- $instance->_show_user_guide() ;
236
- break ;
237
- }
238
-
239
- LiteSpeed_Cache_Admin::redirect() ;
240
- }
241
-
242
- /**
243
- * Get the current instance object.
244
- *
245
- * @since 1.8
246
- * @access public
247
- * @return Current class instance.
248
- */
249
- public static function get_instance()
250
- {
251
- if ( ! isset( self::$_instance ) ) {
252
- self::$_instance = new self() ;
253
- }
254
-
255
- return self::$_instance ;
256
- }
257
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/config.class.php DELETED
@@ -1,819 +0,0 @@
1
- <?php
2
- /**
3
- * The core plugin config class.
4
- *
5
- * This maintains all the options and settings for this plugin.
6
- *
7
- * @since 1.0.0
8
- * @since 1.5 Moved into /inc
9
- * @package LiteSpeed_Cache
10
- * @subpackage LiteSpeed_Cache/inc
11
- * @author LiteSpeed Technologies <info@litespeedtech.com>
12
- */
13
-
14
- if ( ! defined( 'WPINC' ) ) {
15
- die ;
16
- }
17
-
18
- class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
19
- {
20
- private static $_instance ;
21
-
22
- const TYPE_SET = 'set' ;
23
-
24
- protected $options ;
25
- protected $vary_groups ;
26
- protected $exclude_optimization_roles ;
27
- protected $exclude_cache_roles ;
28
- protected $purge_options ;
29
-
30
- /**
31
- * Initialize the class and set its properties.
32
- *
33
- * @since 1.0.0
34
- * @access private
35
- */
36
- private function __construct()
37
- {
38
- if ( is_multisite() ) {
39
- $options = $this->construct_multisite_options() ;
40
- }
41
- else {
42
- $options = get_option( self::OPTION_NAME ) ;
43
- if ( ! $options ) {
44
- $options = $this->get_default_options() ;
45
- }
46
-
47
- // Check advanced_cache set
48
- $this->_define_adv_cache( $options ) ;
49
- }
50
-
51
- $this->options = $options ;
52
- $this->purge_options = explode('.', $options[ self::OPID_PURGE_BY_POST ] ) ;
53
-
54
- /**
55
- * Detect if has quic.cloud set
56
- * @since 2.9.7
57
- */
58
- if ( $this->options[ self::OPT_CDN_QUIC ] ) {
59
- ! defined( 'LITESPEED_ALLOWED' ) && define( 'LITESPEED_ALLOWED', true ) ;
60
- }
61
-
62
- // Init global const cache on set
63
- if ( $this->options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON
64
- // || ( is_multisite() && is_network_admin() && current_user_can( 'manage_network_options' ) && $this->options[ LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ] ) todo: need to check when primary is off and network is on, if can manage
65
- ) {
66
- $this->define_cache_on() ;
67
- }
68
-
69
- // Vary group settings
70
- $this->vary_groups = $this->get_item( self::VARY_GROUP ) ;
71
-
72
- // Exclude optimization role setting
73
- $this->exclude_optimization_roles = $this->get_item( self::EXCLUDE_OPTIMIZATION_ROLES ) ;
74
-
75
- // Exclude cache role setting
76
- $this->exclude_cache_roles = $this->get_item( self::EXCLUDE_CACHE_ROLES ) ;
77
-
78
- // Set security key if not initialized yet
79
- if ( isset( $this->options[ self::HASH ] ) && empty( $this->options[ self::HASH ] ) ) {
80
- $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
81
- }
82
-
83
- // Hook to options
84
- add_action( 'litespeed_init', array( $this, 'hook_options' ) ) ;
85
-
86
- }
87
-
88
- /**
89
- * Give an API to change all options val
90
- * All hooks need to be added before `after_setup_theme`
91
- *
92
- * @since 2.6
93
- * @access public
94
- */
95
- public function hook_options()
96
- {
97
- foreach ( $this->options as $k => $v ) {
98
- $new_v = apply_filters( "litespeed_option_$k", $v ) ;
99
-
100
- if ( $new_v !== $v ) {
101
- LiteSpeed_Cache_Log::debug( "[Conf] ** $k changed by hook [litespeed_option_$k] from " . var_export( $v, true ) . ' to ' . var_export( $new_v, true ) ) ;
102
- $this->options[ $k ] = $new_v ;
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * Force an option to a certain value
109
- *
110
- * @since 2.6
111
- * @access public
112
- */
113
- public function force_option( $k, $v )
114
- {
115
- if ( array_key_exists( $k, $this->options ) ) {
116
- LiteSpeed_Cache_Log::debug( "[Conf] ** $k forced value to " . var_export( $v, true ) ) ;
117
- $this->options[ $k ] = $v ;
118
- }
119
- }
120
-
121
- /**
122
- * Define `LSCACHE_ADV_CACHE` based on options setting
123
- *
124
- * NOTE: this must be before `LITESPEED_ON` defination
125
- *
126
- * @since 2.1
127
- * @access private
128
- */
129
- private function _define_adv_cache( $options )
130
- {
131
- if ( isset( $options[ self::OPID_CHECK_ADVANCEDCACHE ] ) && ! $options[ self::OPID_CHECK_ADVANCEDCACHE ] ) {
132
- ! defined( 'LSCACHE_ADV_CACHE' ) && define( 'LSCACHE_ADV_CACHE', true ) ;
133
- }
134
- }
135
-
136
- /**
137
- * Define `LITESPEED_ON`
138
- *
139
- * @since 2.1
140
- * @access public
141
- */
142
- public function define_cache_on()
143
- {
144
- defined( 'LITESPEED_ALLOWED' ) && defined( 'LSCACHE_ADV_CACHE' ) && ! defined( 'LITESPEED_ON' ) && define( 'LITESPEED_ON', true ) ;
145
-
146
- // Use this for cache enabled setting check
147
- ! defined( 'LITESPEED_ON_IN_SETTING' ) && define( 'LITESPEED_ON_IN_SETTING', true ) ;
148
- }
149
-
150
- /**
151
- * For multisite installations, the single site options need to be updated with the network wide options.
152
- *
153
- * @since 1.0.13
154
- * @access private
155
- * @return array The updated options.
156
- */
157
- private function construct_multisite_options()
158
- {
159
- $site_options = get_site_option( self::OPTION_NAME ) ;
160
-
161
- $this->_define_adv_cache( $site_options ) ;
162
-
163
- $options = get_option( self::OPTION_NAME ) ;
164
- if ( ! $options ) {
165
- $options = $this->get_default_options() ;
166
- }
167
-
168
- /**
169
- * In case this is called outside the admin page
170
- * @see https://codex.wordpress.org/Function_Reference/is_plugin_active_for_network
171
- * @since 2.0
172
- */
173
- if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
174
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;
175
- }
176
-
177
- // If don't have site options
178
- if ( ! $site_options || ! is_array( $site_options ) || ! is_plugin_active_for_network( 'litespeed-cache/litespeed-cache.php' ) ) {
179
- if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 ) { // Default to cache on
180
- $this->define_cache_on() ;
181
- }
182
- return $options ;
183
- }
184
-
185
- // If network set to use primary setting
186
- if ( ! empty ( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ) {
187
-
188
- // save temparary cron setting
189
- $CRWL_CRON_ACTIVE = $options[ self::CRWL_CRON_ACTIVE ] ;
190
-
191
- // Get the primary site settings
192
- $options = get_blog_option( BLOG_ID_CURRENT_SITE, LiteSpeed_Cache_Config::OPTION_NAME, array() ) ;
193
-
194
- // crawler cron activation is separated
195
- $options[ self::CRWL_CRON_ACTIVE ] = $CRWL_CRON_ACTIVE ;
196
- }
197
-
198
- // If use network setting
199
- if ( $options[ self::OPID_ENABLED_RADIO ] === self::VAL_ON2 && $site_options[ self::NETWORK_OPID_ENABLED ] ) {
200
- $this->define_cache_on() ;
201
- }
202
- // Set network eanble to on
203
- if ( $site_options[ self::NETWORK_OPID_ENABLED ] ) {
204
- ! defined( 'LITESPEED_NETWORK_ON' ) && define( 'LITESPEED_NETWORK_ON', true ) ;
205
- }
206
-
207
- // These two are not for single blog options
208
- unset( $site_options[ self::NETWORK_OPID_ENABLED ] ) ;
209
- unset( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ;
210
-
211
- // Append site options to single blog options
212
- $options = array_merge( $options, $site_options ) ;
213
-
214
- return $options ;
215
- }
216
-
217
- /**
218
- * Get the list of configured options for the blog.
219
- *
220
- * @since 1.0.0
221
- * @access public
222
- * @return array The list of configured options.
223
- */
224
- public function get_options()
225
- {
226
- return $this->options ;
227
- }
228
-
229
- /**
230
- * Get the selected configuration option.
231
- *
232
- * @since 1.0.0
233
- * @access public
234
- * @param string $id Configuration ID.
235
- * @return mixed Selected option if set, NULL if not.
236
- */
237
- public function get_option( $id )
238
- {
239
- if ( isset( $this->options[$id] ) ) {
240
- return $this->options[$id] ;
241
- }
242
-
243
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Cfg] Invalid option ID ' . $id ) ;
244
-
245
- return NULL ;
246
- }
247
-
248
- /**
249
- * Set the configured options.
250
- *
251
- * NOTE: No validation here. Do validate before use this function with LiteSpeed_Cache_Admin_Settings->validate_plugin_settings().
252
- *
253
- * @since 1.1.3
254
- * @access public
255
- * @param array $new_cfg The new settings to update, which will be update $this->options too.
256
- * @return array The result of update.
257
- */
258
- public function update_options( $new_cfg = array() )
259
- {
260
- if ( ! empty( $new_cfg ) ) {
261
- $this->options = array_merge( $this->options, $new_cfg ) ;
262
- }
263
- return update_option( self::OPTION_NAME, $this->options ) ;
264
- }
265
-
266
- /**
267
- * Save frontend url to private cached uri/no cache uri
268
- *
269
- * @since 1.3
270
- * @access public
271
- */
272
- public static function frontend_save()
273
- {
274
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
275
- exit( 'no referer' ) ;
276
- }
277
-
278
- if ( ! $type = LiteSpeed_Cache_Router::verify_type() ) {
279
- exit( 'no type' ) ;
280
- }
281
-
282
- switch ( $type ) {
283
- case 'forced_cache' :
284
- $id = self::ITEM_FORCE_CACHE_URI ;
285
- break ;
286
-
287
- case 'private' :
288
- $id = self::ITEM_CACHE_URI_PRIV ;
289
- break ;
290
-
291
- case 'nonoptimize' :
292
- $id = self::ITEM_OPTM_EXCLUDES ;
293
- break ;
294
-
295
- case 'nocache' :
296
- default:
297
- $id = self::ITEM_EXCLUDES_URI ;
298
- break ;
299
- }
300
-
301
- $instance = self::get_instance() ;
302
- $list = $instance->get_item( $id ) ;
303
-
304
- $list[] = $_SERVER[ 'HTTP_REFERER' ] . '$' ;
305
- $list = LiteSpeed_Cache_Utility::sanitize_lines( $list, 'relative' ) ;
306
-
307
- update_option( $id, $list ) ;
308
-
309
- // Purge this page & redirect
310
- LiteSpeed_Cache_Purge::purge_front() ;
311
- exit() ;
312
- }
313
-
314
- /**
315
- * Check if one user role is in vary group settings
316
- *
317
- * @since 1.2.0
318
- * @access public
319
- * @param string $role The user role
320
- * @return int The set value if already set
321
- */
322
- public function in_vary_group( $role )
323
- {
324
- $group = 0 ;
325
- if ( array_key_exists( $role, $this->vary_groups ) ) {
326
- $group = $this->vary_groups[ $role ] ;
327
- }
328
- elseif ( $role === 'administrator' ) {
329
- $group = 99 ;
330
- }
331
-
332
- if ( $group ) {
333
- LiteSpeed_Cache_Log::debug2( '[Cfg] role in vary_group [group] ' . $group ) ;
334
- }
335
-
336
- return $group ;
337
- }
338
-
339
- /**
340
- * Check if one user role is in exclude optimization group settings
341
- *
342
- * @since 1.6
343
- * @access public
344
- * @param string $role The user role
345
- * @return int The set value if already set
346
- */
347
- public function in_exclude_optimization_roles( $role = null )
348
- {
349
- // Get user role
350
- if ( $role === null ) {
351
- $role = LiteSpeed_Cache_Router::get_role() ;
352
- }
353
-
354
- if ( ! $role ) {
355
- return false ;
356
- }
357
-
358
- return in_array( $role, $this->exclude_optimization_roles ) ? $role : false ;
359
- }
360
-
361
- /**
362
- * Check if one user role is in exclude cache group settings
363
- *
364
- * @since 1.6.2
365
- * @access public
366
- * @param string $role The user role
367
- * @return int The set value if already set
368
- */
369
- public function in_exclude_cache_roles( $role = null )
370
- {
371
- // Get user role
372
- if ( $role === null ) {
373
- $role = LiteSpeed_Cache_Router::get_role() ;
374
- }
375
-
376
- if ( ! $role ) {
377
- return false ;
378
- }
379
-
380
- return in_array( $role, $this->exclude_cache_roles ) ? $role : false ;
381
- }
382
-
383
- /**
384
- * Get the configured purge options.
385
- *
386
- * @since 1.0.0
387
- * @access public
388
- * @return array The list of purge options.
389
- */
390
- public function get_purge_options()
391
- {
392
- return $this->purge_options ;
393
- }
394
-
395
- /**
396
- * Check if the flag type of posts should be purged on updates.
397
- *
398
- * @since 1.0.0
399
- * @access public
400
- * @param string $flag Post type. Refer to LiteSpeed_Cache_Config::PURGE_*
401
- * @return boolean True if the post type should be purged, false otherwise.
402
- */
403
- public function purge_by_post( $flag )
404
- {
405
- return in_array( $flag, $this->purge_options ) ;
406
- }
407
-
408
- /**
409
- * Get item val
410
- *
411
- * @since 2.2.1
412
- * @access public
413
- */
414
- public function get_item( $k, $return_string = false )
415
- {
416
- $val = get_option( $k ) ;
417
- // Separately call default_item() to improve performance
418
- if ( ! $val ) {
419
- $val = $this->default_item( $k ) ;
420
- }
421
-
422
- if ( ! $return_string && ! is_array( $val ) ) {
423
- $val = $val ? explode( "\n", $val ) : array() ;
424
- }
425
- elseif ( $return_string && is_array( $val ) ) {
426
- $val = implode( "\n", $val ) ;
427
- }
428
-
429
- return $val ;
430
- }
431
-
432
- /**
433
- * Get the plugin's site wide options.
434
- *
435
- * If the site wide options are not set yet, set it to default.
436
- *
437
- * @since 1.0.2
438
- * @access public
439
- * @return array Returns the current site options.
440
- */
441
- public function get_site_options()
442
- {
443
- if ( ! is_multisite() ) {
444
- return null ;
445
- }
446
- $site_options = get_site_option( self::OPTION_NAME ) ;
447
-
448
- if ( isset( $site_options ) && is_array( $site_options ) ) {
449
- return $site_options ;
450
- }
451
-
452
- $default_site_options = $this->get_default_site_options() ;
453
- add_site_option( self::OPTION_NAME, $default_site_options ) ;
454
-
455
- return $default_site_options ;
456
- }
457
-
458
-
459
- /**
460
- * Helper function to convert the options to replicate the input format.
461
- *
462
- * The only difference is the checkboxes.
463
- *
464
- * @since 1.0.15
465
- * @access public
466
- * @param array $options The options array to port to input format.
467
- * @return array $options The options array with input format.
468
- */
469
- public static function convert_options_to_input($options)
470
- {
471
- foreach ( $options as $key => $val ) {
472
- if ( $val === true ) {
473
- $options[$key] = self::VAL_ON ;
474
- }
475
- elseif ( $val === false ) {
476
- $options[$key] = self::VAL_OFF ;
477
- }
478
- }
479
- if ( isset($options[self::OPID_PURGE_BY_POST]) ) {
480
- $purge_opts = explode('.', $options[self::OPID_PURGE_BY_POST]) ;
481
-
482
- foreach ($purge_opts as $purge_opt) {
483
- $options['purge_' . $purge_opt] = self::VAL_ON ;
484
- }
485
- }
486
-
487
- // Convert CDN settings
488
- $mapping_fields = array(
489
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL,
490
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
491
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
492
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
493
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE
494
- ) ;
495
- $cdn_mapping = array() ;
496
- if ( isset( $options[ self::ITEM_CDN_MAPPING ] ) && is_array( $options[ self::ITEM_CDN_MAPPING ] ) ) {
497
- foreach ( $options[ self::ITEM_CDN_MAPPING ] as $k => $v ) {// $k is numeric
498
- foreach ( $mapping_fields as $v2 ) {
499
- if ( empty( $cdn_mapping[ $v2 ] ) ) {
500
- $cdn_mapping[ $v2 ] = array() ;
501
- }
502
- $cdn_mapping[ $v2 ][ $k ] = ! empty( $v[ $v2 ] ) ? $v[ $v2 ] : false ;
503
- }
504
- }
505
- }
506
- if ( empty( $cdn_mapping ) ) {
507
- // At least it has one item same as in setting page
508
- foreach ( $mapping_fields as $v2 ) {
509
- $cdn_mapping[ $v2 ] = array( 0 => false ) ;
510
- }
511
- }
512
- $options[ self::ITEM_CDN_MAPPING ] = $cdn_mapping ;
513
-
514
- /**
515
- * Convert Cookie Simulation in Crawler settings
516
- * @since 2.8.1 Fixed warning and lost cfg when deactivate->reactivate in v2.8
517
- */
518
- $id = self::ITEM_CRWL_COOKIES ;
519
- $crawler_cookies = array() ;
520
- if ( isset( $options[ $id ] ) && is_array( $options[ $id ] ) ) {
521
- $i = 0 ;
522
- foreach ( $options[ $id ] as $k => $v ) {
523
- $crawler_cookies[ 'name' ][ $i ] = $k ;
524
- $crawler_cookies[ 'vals' ][ $i ] = $v ;
525
- $i ++ ;
526
- }
527
- }
528
- $options[ $id ] = $crawler_cookies ;
529
-
530
- return $options ;
531
- }
532
-
533
- /**
534
- * Get the difference between the current options and the default options.
535
- *
536
- * @since 1.0.11
537
- * @access public
538
- * @param array $default_options The default options.
539
- * @param array $options The current options.
540
- * @return array New options.
541
- */
542
- public static function option_diff($default_options, $options)
543
- {
544
- $dkeys = array_keys($default_options) ;
545
- $keys = array_keys($options) ;
546
- $newkeys = array_diff($dkeys, $keys) ;
547
- if ( ! empty($newkeys) ) {
548
- foreach ( $newkeys as $newkey ) {
549
- $options[$newkey] = $default_options[$newkey] ;
550
-
551
- $log = '[Added] ' . $newkey . ' = ' . $default_options[$newkey] ;
552
- LiteSpeed_Cache_Log::debug( "[Cfg] option_diff $log" ) ;
553
- }
554
- }
555
- $retiredkeys = array_diff($keys, $dkeys) ;
556
- if ( ! empty($retiredkeys) ) {
557
- foreach ( $retiredkeys as $retired ) {
558
- unset($options[$retired]) ;
559
-
560
- $log = '[Removed] ' . $retired ;
561
- LiteSpeed_Cache_Log::debug( "[Cfg] option_diff $log" ) ;
562
- }
563
- }
564
- $options[self::OPID_VERSION] = LiteSpeed_Cache::PLUGIN_VERSION ;
565
-
566
- return $options ;
567
- }
568
-
569
- /**
570
- * Verify that the options are still valid.
571
- *
572
- * This is used only when upgrading the plugin versions.
573
- *
574
- * @since 1.0.0
575
- * @access public
576
- */
577
- public function plugin_upgrade()
578
- {
579
- $default_options = $this->get_default_options() ;
580
- $site_options = $this->get_site_options() ;
581
-
582
- // Skip count check if Use Primary Site Configurations is on
583
- if (
584
- $this->options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] &&
585
- (
586
- ( ! is_main_site() && ! empty ( $site_options[ self::NETWORK_OPID_USE_PRIMARY ] ) ) ||
587
- count( $default_options ) == count( $this->options )
588
- )
589
- ) {
590
- return ;
591
- }
592
-
593
- /**
594
- * Resave cdn cfg from lscfg to separate cfg when upgrade to v1.7
595
- * @since 1.7
596
- */
597
- if ( isset( $this->options[ 'cdn_url' ] ) ) {
598
- $cdn_mapping = array(
599
- self::ITEM_CDN_MAPPING_URL => $this->options[ 'cdn_url' ],
600
- self::ITEM_CDN_MAPPING_INC_IMG => $this->options[ 'cdn_inc_img' ],
601
- self::ITEM_CDN_MAPPING_INC_CSS => $this->options[ 'cdn_inc_css' ],
602
- self::ITEM_CDN_MAPPING_INC_JS => $this->options[ 'cdn_inc_js' ],
603
- self::ITEM_CDN_MAPPING_FILETYPE => $this->options[ 'cdn_filetype' ],
604
- ) ;
605
- update_option( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING, array( $cdn_mapping ) ) ;
606
- LiteSpeed_Cache_Log::debug( "[Cfg] plugin_upgrade option adding CDN map" ) ;
607
- }
608
-
609
- /**
610
- * Move Exclude settings to separate item
611
- * @since 2.3
612
- */
613
- if ( isset( $this->options[ 'forced_cache_uri' ] ) ) {
614
- update_option( LiteSpeed_Cache_Config::ITEM_FORCE_CACHE_URI, $this->options[ 'forced_cache_uri' ] ) ;
615
- }
616
- if ( isset( $this->options[ 'cache_uri_priv' ] ) ) {
617
- update_option( LiteSpeed_Cache_Config::ITEM_CACHE_URI_PRIV, $this->options[ 'cache_uri_priv' ] ) ;
618
- }
619
- if ( isset( $this->options[ 'optm_excludes' ] ) ) {
620
- update_option( LiteSpeed_Cache_Config::ITEM_OPTM_EXCLUDES, $this->options[ 'optm_excludes' ] ) ;
621
- }
622
- if ( isset( $this->options[ 'excludes_uri' ] ) ) {
623
- update_option( LiteSpeed_Cache_Config::ITEM_EXCLUDES_URI, $this->options[ 'excludes_uri' ] ) ;
624
- }
625
-
626
- $this->options = self::option_diff( $default_options, $this->options ) ;
627
-
628
- $this->update_options() ;
629
- define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
630
- LiteSpeed_Cache_Purge::purge_all() ;
631
-
632
- LiteSpeed_Cache_Log::debug( "[Cfg] plugin_upgrade option changed" ) ;
633
-
634
- // Update img_optm table data for upgrading
635
- LiteSpeed_Cache_Data::get_instance() ;
636
- }
637
-
638
- /**
639
- * Upgrade network options when the plugin is upgraded.
640
- *
641
- * @since 1.0.11
642
- * @access public
643
- */
644
- public function plugin_site_upgrade()
645
- {
646
- $default_options = $this->get_default_site_options() ;
647
- $options = $this->get_site_options() ;
648
-
649
- if ( $options[ self::OPID_VERSION ] == $default_options[ self::OPID_VERSION ] && count( $default_options ) == count( $options ) ) {
650
- return ;
651
- }
652
-
653
- $options = self::option_diff( $default_options, $options ) ;
654
-
655
- $res = update_site_option( self::OPTION_NAME, $options ) ;
656
-
657
- LiteSpeed_Cache_Log::debug( "[Cfg] plugin_upgrade option changed = $res\n" ) ;
658
- }
659
-
660
- /**
661
- * Update the WP_CACHE variable in the wp-config.php file.
662
- *
663
- * If enabling, check if the variable is defined, and if not, define it.
664
- * Vice versa for disabling.
665
- *
666
- * @since 1.0.0
667
- * @access public
668
- * @param boolean $enable True if enabling, false if disabling.
669
- * @return boolean True if the variable is the correct value, false if something went wrong.
670
- */
671
- public static function wp_cache_var_setter( $enable )
672
- {
673
- if ( $enable ) {
674
- if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
675
- return true ;
676
- }
677
- }
678
- elseif ( ! defined( 'WP_CACHE' ) || ( defined( 'WP_CACHE' ) && ! WP_CACHE ) ) {
679
- return true ;
680
- }
681
-
682
- $file = ABSPATH . 'wp-config.php' ;
683
-
684
- if ( ! is_writeable( $file ) ) {
685
- $file = dirname( ABSPATH ) . '/wp-config.php' ; // todo: is the path correct?
686
- if ( ! is_writeable( $file ) ) {
687
- error_log( 'wp-config file not writable for \'WP_CACHE\'' ) ;
688
- return LiteSpeed_Cache_Admin_Error::E_CONF_WRITE ;
689
- }
690
- }
691
-
692
- $file_content = file_get_contents( $file ) ;
693
-
694
- if ( $enable ) {
695
- $count = 0 ;
696
-
697
- $new_file_content = preg_replace( '/[\/]*define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', true);", $file_content, -1, $count ) ;
698
- if ( $count == 0 ) {
699
- $new_file_content = preg_replace( '/(\$table_prefix)/', "define('WP_CACHE', true);\n$1", $file_content ) ;
700
- if ( $count == 0 ) {
701
- $new_file_content = preg_replace( '/(\<\?php)/', "$1\ndefine('WP_CACHE', true);", $file_content, -1, $count ) ;
702
- }
703
-
704
- if ( $count == 0 ) {
705
- error_log( 'wp-config file did not find a place to insert define.' ) ;
706
- return LiteSpeed_Cache_Admin_Error::E_CONF_FIND ;
707
- }
708
- }
709
- }
710
- else {
711
- $new_file_content = preg_replace( '/define\(.*\'WP_CACHE\'.+;/', "define('WP_CACHE', false);", $file_content ) ;
712
- }
713
-
714
- file_put_contents( $file, $new_file_content ) ;
715
- return true ;
716
- }
717
-
718
- /**
719
- * On plugin activation, load the default options.
720
- *
721
- * @since 1.0.0
722
- * @access public
723
- * @param int $count The count of blogs active in multisite.
724
- */
725
- public function plugin_activation( $count )
726
- {
727
-
728
-
729
- }
730
-
731
- /**
732
- * Set one config value directly
733
- *
734
- * @since 2.9
735
- * @access private
736
- */
737
- private function _set_cfg()
738
- {
739
- if ( empty( $_GET[ self::TYPE_SET ] ) || ! is_array( $_GET[ self::TYPE_SET ] ) ) {
740
- return ;
741
- }
742
-
743
- $cfg = $cfg_v = false ;
744
- foreach ( $_GET[ self::TYPE_SET ] as $k => $v ) {
745
- if ( ! isset( $this->options[ $k ] ) ) {
746
- continue ;
747
- }
748
-
749
- if ( is_bool( $this->options[ $k ] ) ) {
750
- $v = (bool) $v ;
751
- }
752
-
753
- $cfg = $k ;
754
- $cfg_v = $v ;
755
- break ;// only allow one
756
- }
757
-
758
- if ( ! $cfg ) {
759
- return ;
760
- }
761
-
762
- $options = $this->options ;
763
- // Get items
764
- foreach ( $this->stored_items() as $v ) {
765
- $options[ $v ] = $this->get_item( $v ) ;
766
- }
767
-
768
- // Change value
769
- $options[ $cfg ] = $cfg_v ;
770
-
771
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
772
- $this->update_options( $output ) ;
773
-
774
- LiteSpeed_Cache_Log::debug( '[Cfg] Changed cfg ' . $cfg . ' to ' . var_export( $cfg_v, true ) ) ;
775
-
776
- $msg = __( 'Changed setting successfully.', 'litespeed-cache' ) ;
777
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
778
- }
779
-
780
- /**
781
- * Handle all request actions from main cls
782
- *
783
- * @since 2.9
784
- * @access public
785
- */
786
- public static function handler()
787
- {
788
- $instance = self::get_instance() ;
789
-
790
- $type = LiteSpeed_Cache_Router::verify_type() ;
791
-
792
- switch ( $type ) {
793
- case self::TYPE_SET :
794
- $instance->_set_cfg() ;
795
- break ;
796
-
797
- default:
798
- break ;
799
- }
800
-
801
- LiteSpeed_Cache_Admin::redirect() ;
802
- }
803
-
804
- /**
805
- * Get the current instance object.
806
- *
807
- * @since 1.1.0
808
- * @access public
809
- * @return Current class instance.
810
- */
811
- public static function get_instance()
812
- {
813
- if ( ! isset( self::$_instance ) ) {
814
- self::$_instance = new self() ;
815
- }
816
-
817
- return self::$_instance ;
818
- }
819
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/const.cls.php DELETED
@@ -1,662 +0,0 @@
1
- <?php
2
- /**
3
- * The core consts for config
4
- *
5
- * @since 2.4
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
- class LiteSpeed_Cache_Const
11
- {
12
- const OPTION_NAME = 'litespeed-cache-conf' ;
13
- const VARY_GROUP = 'litespeed-cache-vary-group' ;
14
- const EXCLUDE_OPTIMIZATION_ROLES = 'litespeed-cache-exclude-optimization-roles' ;
15
- const EXCLUDE_CACHE_ROLES = 'litespeed-cache-exclude-cache-roles' ;
16
- const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
17
- const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
18
- const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
19
- const ITEM_MEDIA_LAZY_IMG_CLS_EXC = 'litespeed-media-lazy-img-cls-excludes' ;
20
- const ITEM_IMG_OPTM_NEED_PULL = 'litespeed-media-need-pull' ;
21
- const ITEM_ENV_REF = 'litespeed-env-ref' ;
22
- const ITEM_CACHE_DROP_QS = 'litespeed-cache-drop_qs' ;
23
- const ITEM_CDN_MAPPING = 'litespeed-cache-cdn_mapping' ;
24
- const ITEM_DNS_PREFETCH = 'litespeed-cache-dns_prefetch' ;
25
- const ITEM_CLOUDFLARE_STATUS = 'litespeed-cache-cloudflare_status' ;
26
- const ITEM_LOG_IGNORE_FILTERS = 'litespeed-log_ignore_filters' ;
27
- const ITEM_LOG_IGNORE_PART_FILTERS = 'litespeed-log_ignore_part_filters' ;
28
- const ITEM_OBJECT_GLOBAL_GROUPS = 'litespeed-object_global_groups' ;
29
- const ITEM_OBJECT_NON_PERSISTENT_GROUPS = 'litespeed-object_non_persistent_groups' ;
30
- const ITEM_CRWL_AS_UIDS = 'litespeed-crawler-as-uids' ;
31
- const ITEM_CRWL_COOKIES = 'litespeed-crawler-cookies' ;
32
- const ITEM_ADV_PURGE_ALL_HOOKS = 'litespeed-adv-purge_all_hooks' ;
33
- const ITEM_CDN_ORI_DIR = 'litespeed-cdn-ori_dir' ;
34
- const ITEM_MEDIA_WEBP_ATTRIBUTE = 'litespeed-media-webp_attribute' ;
35
- const ITEM_FORCE_CACHE_URI = 'litespeed-forced_cache_uri' ;
36
- const ITEM_CACHE_URI_PRIV = 'litespeed-cache_uri_priv' ;
37
- const ITEM_OPTM_EXCLUDES = 'litespeed-optm_excludes' ;
38
- const ITEM_EXCLUDES_URI = 'litespeed-excludes_uri' ;
39
- const ITEM_OPTM_CCSS_SEPARATE_POSTTYPE = 'litespeed-optm-ccss-separate_posttype' ;
40
- const ITEM_OPTM_CCSS_SEPARATE_URI = 'litespeed-optm-css-separate_uri' ;
41
-
42
- const ITEM_SETTING_MODE = 'litespeed-setting-mode' ;
43
- const ITEM_CRAWLER_HASH = 'litespeed-crawler-hash' ;
44
- const ITEM_GUIDE = 'litespeed-guide' ; // Array of each guidance tag as key, step as val
45
- const ITEM_TIMESTAMP_PURGE_CSS = 'litespeed-timestamp-purge-css' ;
46
-
47
- // Server variables
48
- const ENV_CRAWLER_USLEEP = 'CRAWLER_USLEEP' ;
49
- const ENV_CRAWLER_LOAD_LIMIT = 'CRAWLER_LOAD_LIMIT' ;
50
- const ENV_CRAWLER_LOAD_LIMIT_ENFORCE = 'CRAWLER_LOAD_LIMIT_ENFORCE' ;
51
-
52
- // const ITEM_FAVICON = 'litespeed-cache-favicon' ;
53
-
54
- const ITEM_CDN_MAPPING_URL = 'url' ;
55
- const ITEM_CDN_MAPPING_INC_IMG = 'inc_img' ;
56
- const ITEM_CDN_MAPPING_INC_CSS = 'inc_css' ;
57
- const ITEM_CDN_MAPPING_INC_JS = 'inc_js' ;
58
- const ITEM_CDN_MAPPING_FILETYPE = 'filetype' ;
59
-
60
- const VAL_OFF = 0 ;
61
- const VAL_ON = 1 ;
62
- const VAL_ON2 = 2 ;
63
-
64
- const LOG_LEVEL_NONE = 0 ;
65
- const LOG_LEVEL_ERROR = 1 ;
66
- const LOG_LEVEL_NOTICE = 2 ;
67
- const LOG_LEVEL_INFO = 3 ;
68
- const LOG_LEVEL_DEBUG = 4 ;
69
- const OPID_VERSION = 'version' ;
70
- const OPID_ENABLED_RADIO = 'radio_select' ;
71
-
72
- const OPT_AUTO_UPGRADE = 'auto_upgrade' ;
73
- const OPT_NEWS = 'news' ;
74
- const OPID_CACHE_PRIV = 'cache_priv' ;
75
- const OPID_CACHE_COMMENTER = 'cache_commenter' ;
76
- const OPID_CACHE_REST = 'cache_rest' ;
77
- const OPID_CACHE_PAGE_LOGIN = 'cache_page_login' ;
78
- const OPID_CACHE_FAVICON = 'cache_favicon' ;
79
- const OPID_CACHE_RES = 'cache_resources' ;
80
- const OPID_CACHE_MOBILE = 'mobileview_enabled' ;
81
- const ID_MOBILEVIEW_LIST = 'mobileview_rules' ;
82
- const OPID_CACHE_OBJECT = 'cache_object' ;
83
- const OPID_CACHE_OBJECT_KIND = 'cache_object_kind' ;
84
- const OPID_CACHE_OBJECT_HOST = 'cache_object_host' ;
85
- const OPID_CACHE_OBJECT_PORT = 'cache_object_port' ;
86
- const OPID_CACHE_OBJECT_LIFE = 'cache_object_life' ;
87
- const OPID_CACHE_OBJECT_PERSISTENT = 'cache_object_persistent' ;
88
- const OPID_CACHE_OBJECT_ADMIN = 'cache_object_admin' ;
89
- const OPID_CACHE_OBJECT_TRANSIENTS = 'cache_object_transients' ;
90
- const OPID_CACHE_OBJECT_DB_ID = 'cache_object_db_id' ;
91
- const OPID_CACHE_OBJECT_USER = 'cache_object_user' ;
92
- const OPID_CACHE_OBJECT_PSWD = 'cache_object_pswd' ;
93
- const OPID_CACHE_BROWSER = 'cache_browser' ;
94
- const OPID_CACHE_BROWSER_TTL = 'cache_browser_ttl' ;
95
-
96
- const OPID_PURGE_ON_UPGRADE = 'purge_upgrade' ;
97
- const OPID_TIMED_URLS = 'timed_urls' ;
98
- const OPID_TIMED_URLS_TIME = 'timed_urls_time' ;
99
-
100
- const OPID_LOGIN_COOKIE = 'login_cookie' ;
101
- const OPID_CHECK_ADVANCEDCACHE = 'check_advancedcache' ;
102
- const OPID_USE_HTTP_FOR_HTTPS_VARY = 'use_http_for_https_vary' ;
103
- // do NOT set default options for these three, it is used for admin.
104
- const ID_NOCACHE_COOKIES = 'nocache_cookies' ;
105
- const ID_NOCACHE_USERAGENTS = 'nocache_useragents' ;
106
- const OPID_DEBUG_DISABLE_ALL = 'debug_disable_all' ;
107
- const OPID_DEBUG = 'debug' ;
108
- const OPID_ADMIN_IPS = 'admin_ips' ;
109
- const OPID_DEBUG_LEVEL = 'debug_level' ;
110
- const OPID_LOG_FILE_SIZE = 'log_file_size' ;
111
- const OPID_HEARTBEAT = 'heartbeat' ;
112
- const OPID_DEBUG_COOKIE = 'debug_cookie' ;
113
- const OPID_COLLAPS_QS = 'collaps_qs' ;
114
- const OPID_LOG_FILTERS = 'log_filters' ;
115
-
116
- const OPID_PUBLIC_TTL = 'public_ttl' ;
117
- const OPID_PRIVATE_TTL = 'private_ttl' ;
118
- const OPID_FRONT_PAGE_TTL = 'front_page_ttl' ;
119
- const OPID_FEED_TTL = 'feed_ttl' ;
120
- const OPID_403_TTL = '403_ttl' ;
121
- const OPID_404_TTL = '404_ttl' ;
122
- const OPID_500_TTL = '500_ttl' ;
123
- const OPID_PURGE_BY_POST = 'purge_by_post' ;
124
- const OPID_ESI_ENABLE = 'esi_enabled' ;
125
- const OPID_ESI_CACHE_ADMBAR = 'esi_cached_admbar' ;
126
- const OPID_ESI_CACHE_COMMFORM = 'esi_cached_commform' ;
127
- const PURGE_ALL_PAGES = '-' ;
128
- const PURGE_FRONT_PAGE = 'F' ;
129
- const PURGE_HOME_PAGE = 'H' ;
130
- const PURGE_PAGES = 'PGS' ;
131
- const PURGE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
132
- const PURGE_AUTHOR = 'A' ;
133
- const PURGE_YEAR = 'Y' ;
134
- const PURGE_MONTH = 'M' ;
135
- const PURGE_DATE = 'D' ;
136
- const PURGE_TERM = 'T' ; // include category|tag|tax
137
- const PURGE_POST_TYPE = 'PT' ;
138
-
139
- const OPID_EXCLUDES_QS = 'excludes_qs' ;
140
- const OPID_EXCLUDES_CAT = 'excludes_cat' ;
141
- const OPID_EXCLUDES_TAG = 'excludes_tag' ;
142
-
143
- // const OPID_ADV_FAVICON = 'adv_favicon' ;
144
- const OPID_ADV_INSTANT_CLICK = 'instant_click' ;
145
-
146
- const OPID_CSS_MINIFY = 'css_minify' ;
147
- const OPID_CSS_INLINE_MINIFY = 'css_inline_minify' ;
148
- const OPID_CSS_COMBINE = 'css_combine' ;
149
- const OPID_CSS_COMBINED_PRIORITY = 'css_combined_priority' ;
150
- const OPID_CSS_HTTP2 = 'css_http2' ;
151
- const OPID_CSS_EXCLUDES = 'css_exclude' ;
152
- const OPID_JS_MINIFY = 'js_minify' ;
153
- const OPID_JS_INLINE_MINIFY = 'js_inline_minify' ;
154
- const OPID_JS_COMBINE = 'js_combine' ;
155
- const OPID_JS_COMBINED_PRIORITY = 'js_combined_priority' ;
156
- const OPID_JS_HTTP2 = 'js_http2' ;
157
- const OPID_JS_EXCLUDES = 'js_exclude' ;
158
- const OPID_OPTIMIZE_TTL = 'optimize_ttl' ;
159
- const OPID_HTML_MINIFY = 'html_minify' ;
160
- const OPID_OPTM_QS_RM = 'optm_qs_rm' ;
161
- const OPID_OPTM_GGFONTS_RM = 'optm_ggfonts_rm' ;
162
- const OPID_OPTM_CSS_ASYNC = 'optm_css_async' ;
163
- const OPT_OPTM_CCSS_GEN = 'optm_ccss_gen' ;
164
- const OPT_OPTM_CCSS_ASYNC = 'optm_ccss_async' ;
165
- const OPT_OPTM_CSS_ASYNC_INLINE = 'optm_css_async_inline' ;
166
- const OPID_OPTM_JS_DEFER = 'optm_js_defer' ;
167
- const OPID_OPTM_EMOJI_RM = 'optm_emoji_rm' ;
168
- const OPID_OPTM_EXC_JQUERY = 'optm_exclude_jquery' ;
169
- const OPID_OPTM_GGFONTS_ASYNC = 'optm_ggfonts_async' ;
170
- const OPID_OPTM_MAX_SIZE = 'optm_max_size' ;
171
- const OPID_OPTM_RM_COMMENT = 'optm_rm_comment' ;
172
-
173
- const OPID_CDN = 'cdn' ;
174
- const OPID_CDN_ORI = 'cdn_ori' ;
175
- const OPID_CDN_EXCLUDE = 'cdn_exclude' ;
176
- const OPID_CDN_REMOTE_JQUERY = 'cdn_remote_jquery' ;
177
- const OPT_CDN_QUIC = 'cdn_quic' ;
178
- const OPT_CDN_QUIC_EMAIL = 'cdn_quic_email' ;
179
- const OPT_CDN_QUIC_KEY = 'cdn_quic_key' ;
180
- const OPID_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
181
- const OPID_CDN_CLOUDFLARE_EMAIL = 'cdn_cloudflare_email' ;
182
- const OPID_CDN_CLOUDFLARE_KEY = 'cdn_cloudflare_key' ;
183
- const OPID_CDN_CLOUDFLARE_NAME = 'cdn_cloudflare_name' ;
184
- const OPID_CDN_CLOUDFLARE_ZONE = 'cdn_cloudflare_zone' ;
185
-
186
- const OPID_MEDIA_IMG_LAZY = 'media_img_lazy' ;
187
- const OPID_MEDIA_IMG_LAZY_PLACEHOLDER = 'media_img_lazy_placeholder' ;
188
- const OPID_MEDIA_PLACEHOLDER_RESP = 'media_placeholder_resp' ;
189
- const OPID_MEDIA_PLACEHOLDER_RESP_COLOR = 'media_placeholder_resp_color' ;
190
- const OPID_MEDIA_PLACEHOLDER_RESP_ASYNC = 'media_placeholder_resp_async' ;
191
- const OPID_MEDIA_IFRAME_LAZY = 'media_iframe_lazy' ;
192
- const OPID_MEDIA_IMG_LAZYJS_INLINE = 'media_img_lazyjs_inline' ;
193
- const OPT_MEDIA_OPTM_AUTO = 'media_optm_auto' ;
194
- const OPT_MEDIA_OPTM_CRON = 'media_optm_cron' ;
195
- const OPT_MEDIA_OPTM_ORI = 'media_optm_ori' ;
196
- const OPT_MEDIA_RM_ORI_BKUP = 'media_rm_ori_bkup' ;
197
- const OPT_MEDIA_OPTM_WEBP = 'media_optm_webp' ;
198
- const OPT_MEDIA_OPTM_LOSSLESS = 'media_optm_lossless' ;
199
- const OPT_MEDIA_OPTM_EXIF = 'media_optm_exif' ;
200
- const OPT_MEDIA_WEBP_REPLACE = 'media_webp_replace' ;
201
- const OPT_MEDIA_WEBP_REPLACE_SRCSET = 'media_webp_replace_srcset' ;
202
-
203
- const HASH = 'hash' ;
204
-
205
- const NETWORK_OPID_ENABLED = 'network_enabled' ;
206
- const NETWORK_OPID_USE_PRIMARY = 'use_primary_settings' ;
207
-
208
- const CRWL_POSTS = 'crawler_include_posts' ;
209
- const CRWL_PAGES = 'crawler_include_pages' ;
210
- const CRWL_CATS = 'crawler_include_cats' ;
211
- const CRWL_TAGS = 'crawler_include_tags' ;
212
- const CRWL_EXCLUDES_CPT = 'crawler_excludes_cpt' ;
213
- const CRWL_ORDER_LINKS = 'crawler_order_links' ;
214
- const CRWL_USLEEP = 'crawler_usleep' ;
215
- const CRWL_RUN_DURATION = 'crawler_run_duration' ;
216
- const CRWL_RUN_INTERVAL = 'crawler_run_interval' ;
217
- const CRWL_CRAWL_INTERVAL = 'crawler_crawl_interval' ;
218
- const CRWL_THREADS = 'crawler_threads' ;
219
- const CRWL_LOAD_LIMIT = 'crawler_load_limit' ;
220
- const CRWL_DOMAIN_IP = 'crawler_domain_ip' ;
221
- const CRWL_CUSTOM_SITEMAP = 'crawler_custom_sitemap' ;
222
-
223
- const CRWL_CRON_ACTIVE = 'crawler_cron_active' ;
224
-
225
- const CRWL_DATE_DESC = 'date_desc' ;
226
- const CRWL_DATE_ASC = 'date_asc' ;
227
- const CRWL_ALPHA_DESC = 'alpha_desc' ;
228
- const CRWL_ALPHA_ASC = 'alpha_asc' ;
229
-
230
- const IMG_OPTM_BM_ORI = 1 ;
231
- const IMG_OPTM_BM_WEBP = 2 ;
232
- const IMG_OPTM_BM_LOSSLESS = 4 ;
233
- const IMG_OPTM_BM_EXIF = 8 ;
234
-
235
- /**
236
- * Get the items in wp_options that need for backup
237
- *
238
- * @since 2.2.1
239
- * @access public
240
- */
241
- public function stored_items()
242
- {
243
- return array(
244
- self::OPTION_NAME,
245
- self::VARY_GROUP,
246
- self::EXCLUDE_OPTIMIZATION_ROLES,
247
- self::EXCLUDE_CACHE_ROLES,
248
- self::ITEM_OPTM_CSS,
249
- self::ITEM_OPTM_JS_DEFER_EXC,
250
- self::ITEM_MEDIA_LAZY_IMG_EXC,
251
- self::ITEM_MEDIA_LAZY_IMG_CLS_EXC,
252
- self::ITEM_IMG_OPTM_NEED_PULL,
253
- self::ITEM_ENV_REF,
254
- self::ITEM_CACHE_DROP_QS,
255
- self::ITEM_CDN_MAPPING,
256
- self::ITEM_CDN_ORI_DIR,
257
- self::ITEM_DNS_PREFETCH,
258
- self::ITEM_CLOUDFLARE_STATUS,
259
- self::ITEM_LOG_IGNORE_FILTERS,
260
- self::ITEM_LOG_IGNORE_PART_FILTERS,
261
- self::ITEM_OBJECT_GLOBAL_GROUPS,
262
- self::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
263
- self::ITEM_CRWL_AS_UIDS,
264
- self::ITEM_CRWL_COOKIES,
265
- self::ITEM_ADV_PURGE_ALL_HOOKS,
266
- self::ITEM_FORCE_CACHE_URI,
267
- self::ITEM_CACHE_URI_PRIV,
268
- self::ITEM_OPTM_EXCLUDES,
269
- self::ITEM_EXCLUDES_URI,
270
- self::ITEM_MEDIA_WEBP_ATTRIBUTE,
271
- self::ITEM_OPTM_CCSS_SEPARATE_POSTTYPE,
272
- self::ITEM_OPTM_CCSS_SEPARATE_URI,
273
- ) ;
274
- }
275
-
276
- /**
277
- * Get default item val
278
- *
279
- * @since 1.8
280
- * @access public
281
- */
282
- public function default_item( $item )
283
- {
284
- /**
285
- * Allow terms default value
286
- * @since 2.7.1
287
- */
288
- if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
289
- $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true ) ;
290
-
291
- if ( ! empty( $default_ini_cfg[ $item ] ) ) {
292
-
293
- /**
294
- * Special handler for CDN_mapping
295
- *
296
- * format in .ini:
297
- * [litespeed-cache-cdn_mapping]
298
- * url[0] = 'https://example.com/'
299
- * inc_js[0] = true
300
- *
301
- * format out:
302
- * [0] = [ 'url' => 'https://example.com', 'inc_js' => true ]
303
- */
304
- if ( $item == self::ITEM_CDN_MAPPING ) {
305
- $mapping_fields = array(
306
- self::ITEM_CDN_MAPPING_URL,
307
- self::ITEM_CDN_MAPPING_INC_IMG,
308
- self::ITEM_CDN_MAPPING_INC_CSS,
309
- self::ITEM_CDN_MAPPING_INC_JS,
310
- self::ITEM_CDN_MAPPING_FILETYPE
311
- ) ;
312
- $cdn_mapping = array() ;
313
- foreach ( $default_ini_cfg[ $item ][ self::ITEM_CDN_MAPPING_URL ] as $k => $v ) {// $k is numeric
314
- $this_row = array() ;
315
- foreach ( $mapping_fields as $v2 ) {
316
- $this_row[ $v2 ] = ! empty( $default_ini_cfg[ $item ][ $v2 ][ $k ] ) ? $default_ini_cfg[ $item ][ $v2 ][ $k ] : false ;
317
- }
318
- $cdn_mapping[ $k ] = $this_row ;
319
- }
320
-
321
- return $cdn_mapping ;
322
- }
323
-
324
- return $default_ini_cfg[ $item ] ;
325
- }
326
- }
327
-
328
- switch ( $item ) {
329
- case self::ITEM_OBJECT_GLOBAL_GROUPS :
330
- return "users\nuserlogins\nusermeta\nuser_meta\nsite-transient\nsite-options\nsite-lookup\nblog-lookup\nblog-details\nrss\nglobal-posts\nblog-id-cache" ;
331
-
332
- case self::ITEM_OBJECT_NON_PERSISTENT_GROUPS :
333
- return "comment\ncounts\nplugins\nwc_session_id" ;
334
-
335
- case self::ITEM_ADV_PURGE_ALL_HOOKS :
336
- return "switch_theme\nwp_create_nav_menu\nwp_update_nav_menu\nwp_delete_nav_menu\ncreate_term\nedit_terms\ndelete_term\nadd_link\nedit_link\ndelete_link" ;
337
-
338
- case self::ITEM_CDN_ORI_DIR :
339
- return LSCWP_CONTENT_FOLDER . "\nwp-includes\n/min/" ;
340
-
341
- case self::ITEM_MEDIA_WEBP_ATTRIBUTE :
342
- return "img.src\n" .
343
- "div.data-thumb\n" .
344
- "img.data-src\n" .
345
- "div.data-large_image\n" .
346
- "img.retina_logo_url" ;
347
-
348
- case self::ITEM_LOG_IGNORE_FILTERS :
349
- return "gettext\ngettext_with_context\nget_the_terms\nget_term" ;
350
-
351
- case self::ITEM_LOG_IGNORE_PART_FILTERS :
352
- return "i18n\nlocale\nsettings\noption" ;
353
-
354
- default :
355
- break ;
356
- }
357
-
358
- return false ;
359
- }
360
-
361
- /**
362
- * Gets the default network options
363
- *
364
- * @since 1.0.11
365
- * @access protected
366
- * @return array An array of the default options.
367
- */
368
- protected function get_default_site_options()
369
- {
370
- $default_site_options = array(
371
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
372
- self::NETWORK_OPID_ENABLED => false,
373
- self::NETWORK_OPID_USE_PRIMARY => false,
374
- self::OPT_AUTO_UPGRADE => false,
375
- self::OPID_PURGE_ON_UPGRADE => true,
376
- self::OPID_CACHE_FAVICON => true,
377
- self::OPID_CACHE_RES => true,
378
- self::OPID_CACHE_MOBILE => 0, // todo: why not false
379
- self::ID_MOBILEVIEW_LIST => 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi',
380
- self::OPID_CACHE_OBJECT => false,
381
- self::OPID_CACHE_OBJECT_KIND => false,
382
- self::OPID_CACHE_OBJECT_HOST => 'localhost',
383
- self::OPID_CACHE_OBJECT_PORT => '11211',
384
- self::OPID_CACHE_OBJECT_LIFE => '360',
385
- self::OPID_CACHE_OBJECT_PERSISTENT => true,
386
- self::OPID_CACHE_OBJECT_ADMIN => true,
387
- self::OPID_CACHE_OBJECT_TRANSIENTS => true,
388
- self::OPID_CACHE_OBJECT_DB_ID => 0,
389
- self::OPID_CACHE_OBJECT_USER => '',
390
- self::OPID_CACHE_OBJECT_PSWD => '',
391
- self::OPID_CACHE_BROWSER => false,
392
- self::OPID_CACHE_BROWSER_TTL => 2592000,
393
- self::OPID_LOGIN_COOKIE => '',
394
- self::OPID_CHECK_ADVANCEDCACHE => true,
395
- self::ID_NOCACHE_COOKIES => '',
396
- self::ID_NOCACHE_USERAGENTS => '',
397
- self::OPT_MEDIA_WEBP_REPLACE => false,
398
- ) ;
399
- return $default_site_options ;
400
- }
401
-
402
- /**
403
- * Gets the default single site options
404
- *
405
- * @since 1.0.0
406
- * @access public
407
- * @param bool $include_thirdparty Whether to include the thirdparty options.
408
- * @return array An array of the default options.
409
- */
410
- public function get_default_options($include_thirdparty = true)
411
- {
412
- $default_purge_options = array(
413
- self::PURGE_FRONT_PAGE,
414
- self::PURGE_HOME_PAGE,
415
- self::PURGE_PAGES,
416
- self::PURGE_PAGES_WITH_RECENT_POSTS,
417
- self::PURGE_AUTHOR,
418
- self::PURGE_MONTH,
419
- self::PURGE_TERM,
420
- self::PURGE_POST_TYPE,
421
- ) ;
422
- sort($default_purge_options) ;
423
-
424
- //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
425
- if ( is_multisite() ) {
426
- $default_radio = 2 ;
427
- }
428
- else {
429
- $default_radio = 1 ;
430
- }
431
-
432
- $default_options = array(
433
- self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
434
- self::OPID_ENABLED_RADIO => $default_radio,
435
- self::OPT_AUTO_UPGRADE => false,
436
- self::OPT_NEWS => false,
437
- self::OPID_PURGE_ON_UPGRADE => true,
438
- self::OPID_CACHE_PRIV => true,
439
- self::OPID_CACHE_COMMENTER => true,
440
- self::OPID_CACHE_REST => true,
441
- self::OPID_CACHE_PAGE_LOGIN => true,
442
- self::OPID_TIMED_URLS => '',
443
- self::OPID_TIMED_URLS_TIME => '',
444
- self::OPID_CACHE_FAVICON => true,
445
- self::OPID_CACHE_RES => true,
446
- self::OPID_CACHE_MOBILE => false,
447
- self::ID_MOBILEVIEW_LIST => 'Mobile|Android|Silk/|Kindle|BlackBerry|Opera\ Mini|Opera\ Mobi',
448
- self::OPID_CACHE_OBJECT => false,
449
- self::OPID_CACHE_OBJECT_KIND => false,
450
- self::OPID_CACHE_OBJECT_HOST => 'localhost',
451
- self::OPID_CACHE_OBJECT_PORT => '11211',
452
- self::OPID_CACHE_OBJECT_LIFE => '360',
453
- self::OPID_CACHE_OBJECT_PERSISTENT => true,
454
- self::OPID_CACHE_OBJECT_ADMIN => true,
455
- self::OPID_CACHE_OBJECT_TRANSIENTS => true,
456
- self::OPID_CACHE_OBJECT_DB_ID => 0,
457
- self::OPID_CACHE_OBJECT_USER => '',
458
- self::OPID_CACHE_OBJECT_PSWD => '',
459
- self::OPID_CACHE_BROWSER => false,
460
- self::OPID_CACHE_BROWSER_TTL => 2592000,
461
-
462
- self::OPID_LOGIN_COOKIE => '',
463
- self::OPID_CHECK_ADVANCEDCACHE => true,
464
- self::OPID_USE_HTTP_FOR_HTTPS_VARY => false,
465
- self::OPID_DEBUG_DISABLE_ALL => false,
466
- self::OPID_DEBUG => self::LOG_LEVEL_NONE,
467
- self::OPID_ADMIN_IPS => '127.0.0.1',
468
- self::OPID_DEBUG_LEVEL => false,
469
- self::OPID_LOG_FILE_SIZE => 3,
470
- self::OPID_HEARTBEAT => true,
471
- self::OPID_DEBUG_COOKIE => false,
472
- self::OPID_COLLAPS_QS => false,
473
- self::OPID_LOG_FILTERS => false,
474
- self::OPID_PUBLIC_TTL => 604800,
475
- self::OPID_PRIVATE_TTL => 1800,
476
- self::OPID_FRONT_PAGE_TTL => 604800,
477
- self::OPID_FEED_TTL => 1,
478
- self::OPID_403_TTL => 3600,
479
- self::OPID_404_TTL => 3600,
480
- self::OPID_500_TTL => 3600,
481
- self::OPID_PURGE_BY_POST => implode('.', $default_purge_options),
482
- self::OPID_EXCLUDES_QS => '',
483
- self::OPID_EXCLUDES_CAT => '',
484
- self::OPID_EXCLUDES_TAG => '',
485
-
486
- // self::OPID_ADV_FAVICON => false,
487
- self::OPID_ADV_INSTANT_CLICK => false,
488
-
489
- self::OPID_CSS_MINIFY => false,
490
- self::OPID_CSS_INLINE_MINIFY => false,
491
- self::OPID_CSS_COMBINE => false,
492
- self::OPID_CSS_COMBINED_PRIORITY => false,
493
- self::OPID_CSS_HTTP2 => false,
494
- self::OPID_CSS_EXCLUDES => '',
495
- self::OPID_JS_MINIFY => false,
496
- self::OPID_JS_INLINE_MINIFY => false,
497
- self::OPID_JS_COMBINE => false,
498
- self::OPID_JS_COMBINED_PRIORITY => false,
499
- self::OPID_JS_HTTP2 => false,
500
- self::OPID_JS_EXCLUDES => '',
501
- self::OPID_OPTIMIZE_TTL => 604800,
502
- self::OPID_HTML_MINIFY => false,
503
- self::OPID_OPTM_QS_RM => false,
504
- self::OPID_OPTM_GGFONTS_RM => false,
505
- self::OPID_OPTM_CSS_ASYNC => false,
506
- self::OPT_OPTM_CCSS_GEN => true,
507
- self::OPT_OPTM_CCSS_ASYNC => true,
508
- self::OPT_OPTM_CSS_ASYNC_INLINE => true,
509
- self::OPID_OPTM_JS_DEFER => false,
510
- self::OPID_OPTM_EMOJI_RM => false,
511
- self::OPID_OPTM_EXC_JQUERY => true,
512
- self::OPID_OPTM_GGFONTS_ASYNC => false,
513
- self::OPID_OPTM_MAX_SIZE => 1.2,
514
- self::OPID_OPTM_RM_COMMENT => false,
515
-
516
- self::OPID_CDN => false,
517
- self::OPID_CDN_ORI => '',
518
- self::OPID_CDN_EXCLUDE => '',
519
- self::OPID_CDN_REMOTE_JQUERY => false,
520
- self::OPT_CDN_QUIC => false,
521
- self::OPT_CDN_QUIC_EMAIL => '',
522
- self::OPT_CDN_QUIC_KEY => '',
523
- self::OPID_CDN_CLOUDFLARE => false,
524
- self::OPID_CDN_CLOUDFLARE_EMAIL => '',
525
- self::OPID_CDN_CLOUDFLARE_KEY => '',
526
- self::OPID_CDN_CLOUDFLARE_NAME => '',
527
- self::OPID_CDN_CLOUDFLARE_ZONE => '',
528
-
529
- self::OPID_MEDIA_IMG_LAZY => false,
530
- self::OPID_MEDIA_IMG_LAZY_PLACEHOLDER => '',
531
- self::OPID_MEDIA_PLACEHOLDER_RESP => false,
532
- self::OPID_MEDIA_PLACEHOLDER_RESP_COLOR => '#cfd4db',
533
- self::OPID_MEDIA_PLACEHOLDER_RESP_ASYNC => true,
534
- self::OPID_MEDIA_IFRAME_LAZY => false,
535
- self::OPID_MEDIA_IMG_LAZYJS_INLINE => false,
536
- self::OPT_MEDIA_OPTM_AUTO => false,
537
- self::OPT_MEDIA_OPTM_CRON => true,
538
- self::OPT_MEDIA_OPTM_ORI => true,
539
- self::OPT_MEDIA_RM_ORI_BKUP => false,
540
- self::OPT_MEDIA_OPTM_WEBP => false,
541
- self::OPT_MEDIA_OPTM_LOSSLESS => false,
542
- self::OPT_MEDIA_OPTM_EXIF => false,
543
- self::OPT_MEDIA_WEBP_REPLACE => false,
544
- self::OPT_MEDIA_WEBP_REPLACE_SRCSET => false,
545
-
546
- self::HASH => '',
547
-
548
- self::ID_NOCACHE_COOKIES => '',
549
- self::ID_NOCACHE_USERAGENTS => '',
550
- self::CRWL_POSTS => true,
551
- self::CRWL_PAGES => true,
552
- self::CRWL_CATS => true,
553
- self::CRWL_TAGS => true,
554
- self::CRWL_EXCLUDES_CPT => '',
555
- self::CRWL_ORDER_LINKS => self::CRWL_DATE_DESC,
556
- self::CRWL_USLEEP => 500,
557
- self::CRWL_RUN_DURATION => 400,
558
- self::CRWL_RUN_INTERVAL => 600,
559
- self::CRWL_CRAWL_INTERVAL => 302400,
560
- self::CRWL_THREADS => 3,
561
- self::CRWL_LOAD_LIMIT => 1,
562
- self::CRWL_DOMAIN_IP => '',
563
- self::CRWL_CUSTOM_SITEMAP => '',
564
- self::CRWL_CRON_ACTIVE => false,
565
- ) ;
566
-
567
- // if ( LSWCP_ESI_SUPPORT ) {
568
- $default_options[self::OPID_ESI_ENABLE] = false ;
569
- $default_options[self::OPID_ESI_CACHE_ADMBAR] = true ;
570
- $default_options[self::OPID_ESI_CACHE_COMMFORM] = true ;
571
- // }
572
-
573
- // Load default.ini
574
- if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
575
- $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true ) ;
576
- foreach ( $default_options as $k => $v ) {
577
- if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
578
- continue ;
579
- }
580
-
581
- // Parse value in ini file
582
- $ini_v = $default_ini_cfg[ $k ] ;
583
- if ( is_bool( $v ) ) { // Keep value type constantly
584
- $ini_v = (bool) $default_ini_cfg[ $k ] ;
585
- }
586
-
587
- if ( $ini_v == $v ) {
588
- continue ;
589
- }
590
-
591
- $default_options[ $k ] = $ini_v ;
592
- }
593
-
594
- // Handle items in $this->default_item()
595
-
596
- }
597
-
598
- if ( ! $include_thirdparty ) {
599
- return $default_options ;
600
- }
601
-
602
- $tp_options = $this->get_thirdparty_options($default_options) ;
603
- if ( ! isset($tp_options) || ! is_array($tp_options) ) {
604
- return $default_options ;
605
- }
606
- return array_merge($default_options, $tp_options) ;
607
- }
608
-
609
- /**
610
- * Generate server vars
611
- *
612
- * @since 2.4.1
613
- */
614
- public function server_vars()
615
- {
616
- $consts = array(
617
- 'WP_SITEURL',
618
- 'WP_HOME',
619
- 'WP_CONTENT_DIR',
620
- 'SHORTINIT',
621
- 'LSCWP_CONTENT_DIR',
622
- 'LSCWP_CONTENT_FOLDER',
623
- 'LSCWP_DIR',
624
- 'LITESPEED_TIME_OFFSET',
625
- 'LITESPEED_SERVER_TYPE',
626
- 'LITESPEED_CLI',
627
- 'LITESPEED_ALLOWED',
628
- 'LITESPEED_ON',
629
- 'LITESPEED_ON_IN_SETTING',
630
- 'LSCACHE_ADV_CACHE',
631
- 'LSWCP_TAG_PREFIX',
632
- ) ;
633
- $server_vars = array() ;
634
- foreach ( $consts as $v ) {
635
- $server_vars[ $v ] = defined( $v ) ? constant( $v ) : NULL ;
636
- }
637
-
638
- return $server_vars ;
639
- }
640
-
641
- /**
642
- * Gets the third party options.
643
- * Will also strip the options that are actually normal options.
644
- *
645
- * @access public
646
- * @since 1.0.9
647
- * @param array $options Optional. The default options to compare against.
648
- * @return mixed boolean on failure, array of keys on success.
649
- */
650
- public function get_thirdparty_options($options = null)
651
- {
652
- $tp_options = apply_filters('litespeed_cache_get_options', array()) ;
653
- if ( empty($tp_options) ) {
654
- return false ;
655
- }
656
- if ( ! isset($options) ) {
657
- $options = $this->get_default_options(false) ;
658
- }
659
- return array_diff_key($tp_options, $options) ;
660
- }
661
-
662
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/control.class.php DELETED
@@ -1,772 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin cache-control class for X-Litespeed-Cache-Control
4
- *
5
- * @since 1.1.3
6
- * @since 1.5 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Control
17
- {
18
- private static $_instance ;
19
-
20
- const BM_CACHEABLE = 1 ;
21
- const BM_PRIVATE = 2 ;
22
- const BM_SHARED = 4 ;
23
- const BM_NO_VARY = 8 ;
24
- const BM_FORCED_CACHEABLE = 32 ;
25
- const BM_PUBLIC_FORCED = 64 ;
26
- const BM_STALE = 128 ;
27
- const BM_NOTCACHEABLE = 256 ;
28
-
29
- const X_HEADER = 'X-LiteSpeed-Cache-Control' ;
30
-
31
- protected static $_control = 0 ;
32
- protected static $_custom_ttl = 0 ;
33
- private static $_mobile = false ;
34
-
35
- /**
36
- * Init cache control
37
- *
38
- * @since 1.6.2
39
- * @access private
40
- */
41
- private function __construct()
42
- {
43
- /**
44
- * Add vary filter for Role Excludes
45
- * @since 1.6.2
46
- */
47
- add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
48
-
49
- // 301 redirect hook
50
- add_filter( 'wp_redirect', 'LiteSpeed_Cache_Control::check_redirect', 10, 2 ) ;
51
- }
52
-
53
- /**
54
- * Exclude role from optimization filter
55
- *
56
- * @since 1.6.2
57
- * @access public
58
- */
59
- public function vary_add_role_exclude( $varys )
60
- {
61
- if ( ! LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
62
- return $varys ;
63
- }
64
- $varys[ 'role_exclude_cache' ] = 1 ;
65
- return $varys ;
66
- }
67
-
68
- /**
69
- * 1. Initialize cacheable status for `wp` hook
70
- * 2. Hook error page tags for cacheable pages
71
- *
72
- * @since 1.1.3
73
- * @access public
74
- */
75
- public static function init_cacheable()
76
- {
77
- // Hook `wp` to mark default cacheable status
78
- // NOTE: Any process that does NOT run into `wp` hook will not get cacheable by default
79
- add_action( 'wp', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
80
-
81
- // Hook WP REST to be cacheable
82
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
83
- add_action( 'rest_api_init', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
84
- }
85
-
86
- // Cache resources
87
- // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
88
- $cache_res = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_RES ) ;
89
- if ( $cache_res ) {
90
- $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;// todo: check if need esc_url()
91
- $pattern = '!' . LSCWP_CONTENT_FOLDER . LiteSpeed_Cache_Admin_Rules::RW_PATTERN_RES . '!' ;
92
- if ( preg_match( $pattern, $uri ) ) {
93
- add_action( 'wp_loaded', 'LiteSpeed_Cache_Control::set_cacheable', 5 ) ;
94
- }
95
- }
96
-
97
- // Check error page
98
- add_filter( 'status_header', 'LiteSpeed_Cache_Tag::check_error_codes', 10, 2 ) ;
99
- }
100
-
101
- /**
102
- * Set no vary setting
103
- *
104
- * @access public
105
- * @since 1.1.3
106
- */
107
- public static function set_no_vary()
108
- {
109
- if ( self::is_no_vary() ) {
110
- return ;
111
- }
112
- self::$_control |= self::BM_NO_VARY ;
113
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control -> no-vary', 3 ) ;
114
- }
115
-
116
- /**
117
- * Get no vary setting
118
- *
119
- * @access public
120
- * @since 1.1.3
121
- */
122
- public static function is_no_vary()
123
- {
124
- return self::$_control & self::BM_NO_VARY ;
125
- }
126
-
127
- /**
128
- * Set stale
129
- *
130
- * @access public
131
- * @since 1.1.3
132
- */
133
- public static function set_stale()
134
- {
135
- if ( self::is_stale() ) {
136
- return ;
137
- }
138
- self::$_control |= self::BM_STALE ;
139
- LiteSpeed_Cache_Log::debug('[Ctrl] X Cache_control -> stale') ;
140
- }
141
-
142
- /**
143
- * Get stale
144
- *
145
- * @access public
146
- * @since 1.1.3
147
- */
148
- public static function is_stale()
149
- {
150
- return self::$_control & self::BM_STALE ;
151
- }
152
-
153
- /**
154
- * Set cache control to shared private
155
- *
156
- * @access public
157
- * @since 1.1.3
158
- * @param string $reason The reason to no cache
159
- */
160
- public static function set_shared( $reason = false )
161
- {
162
- if ( self::is_shared() ) {
163
- return ;
164
- }
165
- self::$_control |= self::BM_SHARED ;
166
- self::set_private() ;
167
-
168
- if ( ! is_string( $reason ) ) {
169
- $reason = false ;
170
- }
171
-
172
- if ( $reason ) {
173
- $reason = "( $reason )" ;
174
- }
175
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control -> shared ' . $reason ) ;
176
- }
177
-
178
- /**
179
- * Check if is shared private
180
- *
181
- * @access public
182
- * @since 1.1.3
183
- */
184
- public static function is_shared()
185
- {
186
- return (self::$_control & self::BM_SHARED) && self::is_private() ;
187
- }
188
-
189
- /**
190
- * Set cache control to forced public
191
- *
192
- * @access public
193
- * @since 1.7.1
194
- * @param string $reason The reason to no cache
195
- */
196
- public static function set_public_forced( $reason = false )
197
- {
198
- if ( self::is_public_forced() ) {
199
- return ;
200
- }
201
- self::$_control |= self::BM_PUBLIC_FORCED ;
202
-
203
- if ( ! is_string( $reason ) ) {
204
- $reason = false ;
205
- }
206
-
207
- if ( $reason ) {
208
- $reason = "( $reason )" ;
209
- }
210
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control -> public forced ' . $reason ) ;
211
- }
212
-
213
- /**
214
- * Check if is public forced
215
- *
216
- * @access public
217
- * @since 1.7.1
218
- */
219
- public static function is_public_forced()
220
- {
221
- return self::$_control & self::BM_PUBLIC_FORCED ;
222
- }
223
-
224
- /**
225
- * Set cache control to private
226
- *
227
- * @access public
228
- * @since 1.1.3
229
- * @param string $reason The reason to no cache
230
- */
231
- public static function set_private( $reason = false )
232
- {
233
- if ( self::is_private() ) {
234
- return ;
235
- }
236
- self::$_control |= self::BM_PRIVATE ;
237
-
238
- if ( ! is_string( $reason ) ) {
239
- $reason = false ;
240
- }
241
-
242
- if ( $reason ) {
243
- $reason = "( $reason )" ;
244
- }
245
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control -> private ' . $reason ) ;
246
- }
247
-
248
- /**
249
- * Check if is private
250
- *
251
- * @access public
252
- * @since 1.1.3
253
- */
254
- public static function is_private()
255
- {
256
- return self::$_control & self::BM_PRIVATE && ! self::is_public_forced() ;
257
- }
258
-
259
- /**
260
- * Initialize cacheable status in `wp` hook, if not call this, by default it will be non-cacheable
261
- *
262
- * @access public
263
- * @since 1.1.3
264
- */
265
- public static function set_cacheable( $reason = false )
266
- {
267
- self::$_control |= self::BM_CACHEABLE ;
268
-
269
- if ( ! is_string( $reason ) ) {
270
- $reason = false ;
271
- }
272
-
273
- if ( $reason ) {
274
- $reason = ' [reason] ' . $reason ;
275
- }
276
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control init on' . $reason ) ;
277
- }
278
-
279
- /**
280
- * This will disable non-cacheable BM
281
- *
282
- * @access public
283
- * @since 2.2
284
- */
285
- public static function force_cacheable( $reason = false )
286
- {
287
- self::$_control |= self::BM_FORCED_CACHEABLE ;
288
-
289
- if ( ! is_string( $reason ) ) {
290
- $reason = false ;
291
- }
292
-
293
- if ( $reason ) {
294
- $reason = ' [reason] ' . $reason ;
295
- }
296
- LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable' . $reason ) ;
297
- }
298
-
299
- /**
300
- * Switch to nocacheable status
301
- *
302
- * @access public
303
- * @since 1.1.3
304
- * @param string $reason The reason to no cache
305
- */
306
- public static function set_nocache( $reason = false )
307
- {
308
- self::$_control |= self::BM_NOTCACHEABLE ;
309
-
310
- if ( ! is_string( $reason ) ) {
311
- $reason = false ;
312
- }
313
-
314
- if ( $reason ) {
315
- $reason = "( $reason )" ;
316
- }
317
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control -> no Cache ' . $reason, 2 ) ;
318
- }
319
-
320
- /**
321
- * Check current notcacheable bit set
322
- *
323
- * @access public
324
- * @since 1.1.3
325
- * @return bool True if notcacheable bit is set, otherwise false.
326
- */
327
- public static function isset_notcacheable()
328
- {
329
- return self::$_control & self::BM_NOTCACHEABLE ;
330
- }
331
-
332
- /**
333
- * Check current force cacheable bit set
334
- *
335
- * @access public
336
- * @since 2.2
337
- */
338
- public static function is_forced_cacheable()
339
- {
340
- return self::$_control & self::BM_FORCED_CACHEABLE ;
341
- }
342
-
343
- /**
344
- * Check current cacheable status
345
- *
346
- * @access public
347
- * @since 1.1.3
348
- * @return bool True if is still cacheable, otherwise false.
349
- */
350
- public static function is_cacheable()
351
- {
352
- // If its forced cacheable
353
- if ( self::is_forced_cacheable() ) {
354
- return true ;
355
- }
356
-
357
- return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
358
- }
359
-
360
- /**
361
- * Set a custom TTL to use with the request if needed.
362
- *
363
- * @access public
364
- * @since 1.1.3
365
- * @param mixed $ttl An integer or string to use as the TTL. Must be numeric.
366
- */
367
- public static function set_custom_ttl($ttl)
368
- {
369
- if ( is_numeric($ttl) ) {
370
- self::$_custom_ttl = $ttl ;
371
- LiteSpeed_Cache_Log::debug('[Ctrl] X Cache_control TTL -> ' . $ttl) ;
372
- }
373
- }
374
-
375
- /**
376
- * Generate final TTL.
377
- *
378
- * @access public
379
- * @since 1.1.3
380
- * @return int $ttl An integer to use as the TTL.
381
- */
382
- public static function get_ttl()
383
- {
384
- if ( self::$_custom_ttl != 0 ) {
385
- return self::$_custom_ttl ;
386
- }
387
-
388
- // Check if is in timed url list or not
389
- $timed_urls = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_TIMED_URLS ) ;
390
- $timed_urls_time = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_TIMED_URLS_TIME ) ;
391
- if ( $timed_urls && $timed_urls_time ) {
392
- $timed_urls = explode( "\n", $timed_urls ) ;
393
- $current_url = LiteSpeed_Cache_Tag::build_uri_tag( true ) ;
394
- if ( in_array( $current_url, $timed_urls ) ) {
395
- // Use time limit ttl
396
- $scheduled_time = strtotime( $timed_urls_time ) ;
397
- $ttl = $scheduled_time - time() ;
398
- if ( $ttl < 0 ) {
399
- $ttl += 86400 ;// add one day
400
- }
401
- LiteSpeed_Cache_Log::debug( '[Ctrl] X Cache_control TTL is limited to ' . $ttl ) ;
402
- return $ttl ;
403
- }
404
- }
405
-
406
- // Private cache uses private ttl setting
407
- if ( self::is_private() ) {
408
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PRIVATE_TTL ) ;
409
- }
410
-
411
- if ( is_front_page() ){
412
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FRONT_PAGE_TTL ) ;
413
- }
414
-
415
- $feed_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FEED_TTL ) ;
416
- if ( is_feed() && $feed_ttl > 0 ) {
417
- return $feed_ttl ;
418
- }
419
-
420
- $ttl_404 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_404_TTL ) ;
421
- if ( is_404() && $ttl_404 > 0 ) {
422
- return $ttl_404 ;
423
- }
424
-
425
- if ( LiteSpeed_Cache_Tag::get_error_code() === 403 ) {
426
- $ttl_403 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_403_TTL ) ;
427
- return $ttl_403 ;
428
- }
429
-
430
- $ttl_500 = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_500_TTL ) ;
431
- if ( LiteSpeed_Cache_Tag::get_error_code() >= 500 ) {
432
- return $ttl_500 ;
433
- }
434
-
435
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_PUBLIC_TTL ) ;
436
- }
437
-
438
- /**
439
- * Check if need to set no cache status for redirection or not
440
- *
441
- * @access public
442
- * @since 1.1.3
443
- */
444
- public static function check_redirect( $location, $status )
445
- {
446
- if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
447
- LiteSpeed_Cache_Log::debug( "[Ctrl] 301 from " . $_SERVER[ 'SCRIPT_URI' ] ) ;
448
- LiteSpeed_Cache_Log::debug( "[Ctrl] 301 to $location" ) ;
449
-
450
- $to_check = array(
451
- PHP_URL_SCHEME,
452
- PHP_URL_HOST,
453
- PHP_URL_PATH,
454
- ) ;
455
-
456
- $is_same_redirect = true ;
457
-
458
- foreach ( $to_check as $v ) {
459
- if ( parse_url( $_SERVER[ 'SCRIPT_URI' ], $v ) != parse_url( $location, $v ) ) {
460
- $is_same_redirect = false ;
461
- LiteSpeed_Cache_Log::debug( "[Ctrl] 301 different redirection" ) ;
462
- break ;
463
- }
464
- }
465
-
466
- if ( $is_same_redirect ) {
467
- self::set_nocache( '301 to same url' ) ;
468
- }
469
- }
470
-
471
- return $location ;
472
- }
473
-
474
- /**
475
- * Sets up the Cache Control header.
476
- *
477
- * @since 1.1.3
478
- * @access public
479
- * @return string empty string if empty, otherwise the cache control header.
480
- */
481
- public static function output()
482
- {
483
- $esi_hdr = '' ;
484
- // Fix cli `uninstall --deactivate` fatal err
485
- if ( class_exists( 'LiteSpeed_Cache_ESI' ) && LiteSpeed_Cache_ESI::has_esi() ) {
486
- $esi_hdr = ',esi=on' ;
487
- }
488
-
489
- $hdr = self::X_HEADER . ': ' ;
490
-
491
- if ( ! self::is_cacheable() ) {
492
- $hdr .= 'no-cache' . $esi_hdr ;
493
- return $hdr ;
494
- }
495
-
496
- if ( self::is_shared() ) {
497
- $hdr .= 'shared,private' ;
498
- }
499
- elseif ( self::is_private() ) {
500
- $hdr .= 'private' ;
501
- }
502
- else {
503
- $hdr .= 'public' ;
504
- }
505
-
506
- if ( self::is_no_vary() ) {
507
- $hdr .= ',no-vary' ;
508
- }
509
-
510
- $hdr .= ',max-age=' . self::get_ttl() . $esi_hdr ;
511
- return $hdr ;
512
- }
513
-
514
- /**
515
- * Generate all `control` tags before output
516
- *
517
- * @access public
518
- * @since 1.1.3
519
- */
520
- public static function finalize()
521
- {
522
- // Check if URI is forced cache
523
- $excludes = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_FORCE_CACHE_URI ) ;
524
- if ( ! empty( $excludes ) ) {
525
- list( $result, $this_ttl ) = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true ) ;
526
- if ( $result ) {
527
- self::force_cacheable() ;
528
- LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable due to setting: ' . $result ) ;
529
- if ( $this_ttl ) {
530
- self::set_custom_ttl( $this_ttl ) ;
531
- }
532
- }
533
- }
534
-
535
- // if is not cacheable, terminate check
536
- // Even no need to run 3rd party hook
537
- if ( ! self::is_cacheable() ) {
538
- LiteSpeed_Cache_Log::debug( '[Ctrl] not cacheable before ctrl finalize' ) ;
539
- return ;
540
- }
541
-
542
- if ( defined('LSCACHE_NO_CACHE') && LSCACHE_NO_CACHE ) {
543
- self::set_nocache('LSCACHE_NO_CACHE constant defined') ;
544
- return ;
545
- }
546
-
547
- $instance = self::get_instance() ;
548
-
549
- // Apply 3rd party filter
550
- // NOTE: Hook always needs to run asap because some 3rd party set is_mobile in this hook
551
- do_action('litespeed_cache_api_control', defined( 'LSCACHE_IS_ESI' ) ? LSCACHE_IS_ESI : false ) ; // Pass ESI block id
552
-
553
- // if is not cacheable, terminate check
554
- if ( ! self::is_cacheable() ) {
555
- LiteSpeed_Cache_Log::debug( '[Ctrl] not cacheable after api_control' ) ;
556
- return ;
557
- }
558
-
559
- if ( is_preview() ) {
560
- self::set_nocache( 'preview page' ) ;
561
- return ;
562
- }
563
-
564
- // Check litespeed setting to set cacheable status
565
- if ( ! $instance->_setting_cacheable() ) {
566
- self::set_nocache() ;
567
- return ;
568
- }
569
-
570
- // If user has password cookie, do not cache (moved from vary)
571
- global $post ;
572
- if ( ! empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
573
- // If user has password cookie, do not cache
574
- self::set_nocache('pswd cookie') ;
575
- return ;
576
- }
577
-
578
- // The following check to the end is ONLY for mobile
579
- if ( ! LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE) ) {
580
- if ( self::is_mobile() ) {
581
- self::set_nocache('mobile') ;
582
- }
583
- return ;
584
- }
585
-
586
- if ( isset($_SERVER['LSCACHE_VARY_VALUE']) && strpos( $_SERVER['LSCACHE_VARY_VALUE'], 'ismobile' ) !== false ) {
587
- if ( ! wp_is_mobile() && ! self::is_mobile() ) {
588
- self::set_nocache( 'is not mobile' ) ;
589
- return ;
590
- }
591
- }
592
- elseif ( wp_is_mobile() || self::is_mobile() ) {
593
- self::set_nocache( 'is mobile' ) ;
594
- return ;
595
- }
596
-
597
- }
598
-
599
- /**
600
- * Check if a page is cacheable based on litespeed setting.
601
- *
602
- * @since 1.0.0
603
- * @access private
604
- * @return boolean True if cacheable, false otherwise.
605
- */
606
- private function _setting_cacheable()
607
- {
608
- // logged_in users already excluded, no hook added
609
-
610
- if( ! empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
611
- return $this->_no_cache_for( 'Query String Action' ) ;
612
- }
613
-
614
- if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
615
- return $this->_no_cache_for('not GET method:' . $_SERVER["REQUEST_METHOD"]) ;
616
- }
617
-
618
- if ( is_feed() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_FEED_TTL ) == 0 ) {
619
- return $this->_no_cache_for('feed') ;
620
- }
621
-
622
- if ( is_trackback() ) {
623
- return $this->_no_cache_for('trackback') ;
624
- }
625
-
626
- if ( is_404() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_404_TTL ) == 0 ) {
627
- return $this->_no_cache_for('404 pages') ;
628
- }
629
-
630
- if ( is_search() ) {
631
- return $this->_no_cache_for('search') ;
632
- }
633
-
634
- // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
635
- // return $this->_no_cache_for('no theme used') ;
636
- // }
637
-
638
- // Check private cache URI setting
639
- $excludes = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CACHE_URI_PRIV ) ;
640
- if ( ! empty( $excludes ) ) {
641
- $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
642
- if ( $result ) {
643
- self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
644
- }
645
- }
646
-
647
- if ( ! self::is_forced_cacheable() ) {
648
-
649
- // Check if URI is excluded from cache
650
- $excludes = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_EXCLUDES_URI ) ;
651
- if ( ! empty( $excludes ) ) {
652
- $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
653
- if ( $result ) {
654
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
655
- }
656
- }
657
-
658
- // Check QS excluded setting
659
- $excludes = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_EXCLUDES_QS ) ;
660
- if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( explode( "\n", $excludes ) ) ) {
661
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
662
- }
663
-
664
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT) ;
665
- if ( ! empty($excludes) && has_category(explode(',', $excludes)) ) {
666
- return $this->_no_cache_for('Admin configured Category Do not cache.') ;
667
- }
668
-
669
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG) ;
670
- if ( ! empty($excludes) && has_tag(explode(',', $excludes)) ) {
671
- return $this->_no_cache_for('Admin configured Tag Do not cache.') ;
672
- }
673
-
674
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_COOKIES) ;
675
- if ( ! empty($excludes) && ! empty($_COOKIE) ) {
676
- $exclude_list = explode('|', $excludes) ;
677
-
678
- foreach( $_COOKIE as $key=>$val) {
679
- if ( in_array($key, $exclude_list) ) {
680
- return $this->_no_cache_for('Admin configured Cookie Do not cache.') ;
681
- }
682
- }
683
- }
684
-
685
- $excludes = LiteSpeed_Cache::config(LiteSpeed_Cache_Config::ID_NOCACHE_USERAGENTS) ;
686
- if ( ! empty($excludes) && isset($_SERVER['HTTP_USER_AGENT']) ) {
687
- $pattern = '/' . $excludes . '/' ;
688
- $nummatches = preg_match($pattern, $_SERVER['HTTP_USER_AGENT']) ;
689
- if ( $nummatches ) {
690
- return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
691
- }
692
- }
693
-
694
- // Check if is exclude roles ( Need to set Vary too )
695
- if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_cache_roles() ) {
696
- return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
697
- }
698
- }
699
-
700
- return true ;
701
- }
702
-
703
- /**
704
- * Write a debug message for if a page is not cacheable.
705
- *
706
- * @since 1.0.0
707
- * @access private
708
- * @param string $reason An explanation for why the page is not cacheable.
709
- * @return boolean Return false.
710
- */
711
- private function _no_cache_for( $reason )
712
- {
713
- LiteSpeed_Cache_Log::debug('[Ctrl] X Cache_control off - ' . $reason) ;
714
- return false ;
715
- }
716
-
717
- /**
718
- * Check if current request has qs excluded setting
719
- *
720
- * @since 1.3
721
- * @access private
722
- * @param array $excludes QS excludes setting
723
- * @return boolean|string False if not excluded, otherwise the hit qs list
724
- */
725
- private function _is_qs_excluded( $excludes )
726
- {
727
- if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
728
- return implode( ',', $intersect ) ;
729
- }
730
- return false ;
731
- }
732
-
733
- /**
734
- * Gets whether any plugins determined that the current page is mobile.
735
- *
736
- * @access public
737
- * @return boolean True if the current page was deemed mobile, false otherwise.
738
- */
739
- public static function is_mobile()
740
- {
741
- return self::$_mobile ;
742
- }
743
-
744
- /**
745
- * Mark the current page as mobile. This may be useful for if the plugin does not override wp_is_mobile.
746
- *
747
- * Must be called before the shutdown hook point.
748
- *
749
- * @since 1.0.7
750
- * @access public
751
- */
752
- public static function set_mobile()
753
- {
754
- self::$_mobile = true ;
755
- }
756
-
757
- /**
758
- * Get the current instance object.
759
- *
760
- * @since 1.3
761
- * @access public
762
- * @return Current class instance.
763
- */
764
- public static function get_instance()
765
- {
766
- if ( ! isset( self::$_instance ) ) {
767
- self::$_instance = new self() ;
768
- }
769
-
770
- return self::$_instance ;
771
- }
772
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/crawler-sitemap.class.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * The Crawler Sitemap Class
4
- *
5
- *
6
- * @since 1.1.0
7
- * @since 1.5 Moved into /inc
8
- * @package LiteSpeed_Cache_Crawler_Sitemap
9
- * @subpackage LiteSpeed_Cache/inc
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
-
13
- if ( ! defined( 'WPINC' ) ) {
14
- die ;
15
- }
16
-
17
- class LiteSpeed_Cache_Crawler_Sitemap
18
- {
19
- private static $_instance ;
20
- private $home_url ;// Used to simplify urls
21
-
22
- protected $_urls = array() ;
23
-
24
- /**
25
- * Instantiate the class
26
- *
27
- * @since 1.1.0
28
- * @access private
29
- */
30
- private function __construct()
31
- {
32
- if ( is_multisite() ) {
33
- $this->home_url = get_home_url( get_current_blog_id() ) ;
34
- }
35
- else{
36
- $this->home_url = get_home_url() ;
37
- }
38
- }
39
-
40
- /**
41
- * Generate all urls
42
- *
43
- * @since 1.1.0
44
- * @access public
45
- */
46
- public function generate_data($blacklist = array())
47
- {
48
- global $wpdb ;
49
-
50
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
51
-
52
- $optionOrderBy = $options[LiteSpeed_Cache_Config::CRWL_ORDER_LINKS] ;
53
-
54
- $show_pages = $options[LiteSpeed_Cache_Config::CRWL_PAGES] ;
55
-
56
- $show_posts = $options[LiteSpeed_Cache_Config::CRWL_POSTS] ;
57
-
58
- $show_cats = $options[LiteSpeed_Cache_Config::CRWL_CATS] ;
59
-
60
- $show_tags = $options[LiteSpeed_Cache_Config::CRWL_TAGS] ;
61
-
62
- switch ( $optionOrderBy ) {
63
- case 'date_asc':
64
- $orderBy = " ORDER BY post_date ASC" ;
65
- break ;
66
-
67
- case 'alpha_desc':
68
- $orderBy = " ORDER BY post_title DESC" ;
69
- break ;
70
-
71
- case 'alpha_asc':
72
- $orderBy = " ORDER BY post_title ASC" ;
73
- break ;
74
-
75
- case 'date_desc':
76
- default:
77
- $orderBy = " ORDER BY post_date DESC" ;
78
- break ;
79
- }
80
-
81
- $post_type_array = array() ;
82
- if ( isset($show_pages) && $show_pages == 1 ) {
83
- $post_type_array[] = 'page' ;
84
- }
85
-
86
- if ( isset($show_posts) && $show_posts == 1 ) {
87
- $post_type_array[] = 'post' ;
88
- }
89
-
90
- $id = LiteSpeed_Cache_Config::CRWL_EXCLUDES_CPT ;
91
- if ( isset($options[$id]) ) {
92
- $excludeCptArr = explode(',', $options[$id]) ;
93
- $excludeCptArr = array_map('trim', $excludeCptArr) ;
94
- $cptArr = get_post_types() ;
95
- $cptArr = array_diff($cptArr, array('post', 'page')) ;
96
- $cptArr = array_diff($cptArr, $excludeCptArr) ;
97
- $post_type_array = array_merge($post_type_array, $cptArr) ;
98
- }
99
-
100
- if ( ! empty($post_type_array) ) {
101
- $post_type = implode("','", $post_type_array) ;
102
-
103
- LiteSpeed_Cache_Log::debug("Crawler sitemap log: post_type is '$post_type'") ;
104
-
105
- $query = "SELECT ID, post_date FROM ".$wpdb->prefix."posts where post_type IN ('".$post_type."') AND post_status='publish' ".$orderBy ;
106
- $results = $wpdb->get_results($query) ;
107
-
108
- foreach ( $results as $result ){
109
- $slug = str_replace($this->home_url, '', get_permalink($result->ID)) ;
110
- if ( ! in_array($slug, $blacklist) ) {
111
- $this->_urls[] = $slug ;
112
- }
113
- }
114
- }
115
-
116
- //Generate Categories Link if option checked
117
- if ( isset($show_cats) && $show_cats == 1 ) {
118
- $cats = get_terms("category", array("hide_empty"=>true, "hierarchical"=>false)) ;
119
- if ( $cats && is_array($cats) && count($cats) > 0 ) {
120
- foreach ( $cats as $cat ) {
121
- $slug = str_replace($this->home_url, '', get_category_link($cat->term_id)) ;
122
- if ( ! in_array($slug, $blacklist) ){
123
- $this->_urls[] = $slug ;//var_dump($slug);exit;//todo: check permalink
124
- }
125
- }
126
- }
127
- }
128
-
129
- //Generate tags Link if option checked
130
- if ( isset($show_tags) && $show_tags == 1 ) {
131
- $tags = get_terms("post_tag", array("hide_empty"=>true, "hierarchical"=>false)) ;
132
- if ( $tags && is_array($tags) && count($tags) > 0 ) {
133
- foreach ( $tags as $tag ) {
134
- $slug = str_replace($this->home_url, '', get_tag_link($tag->term_id)) ;
135
- if ( ! in_array($slug, $blacklist) ) {
136
- $this->_urls[] = $slug ;
137
- }
138
- }
139
- }
140
- }
141
-
142
- return apply_filters('litespeed_crawler_sitemap', $this->_urls) ;
143
- }
144
-
145
- /**
146
- * Get the current instance object.
147
- *
148
- * @since 1.1.0
149
- * @access public
150
- * @return Current class instance.
151
- */
152
- public static function get_instance()
153
- {
154
- if ( ! isset(self::$_instance) ) {
155
- self::$_instance = new self() ;
156
- }
157
-
158
- return self::$_instance ;
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/crawler.class.php DELETED
@@ -1,660 +0,0 @@
1
- <?php
2
- /**
3
- * The crawler class
4
- *
5
- *
6
- * @since 1.1.0
7
- * @since 1.5 Moved into /inc
8
- * @package LiteSpeed_Cache
9
- * @subpackage LiteSpeed_Cache/inc
10
- * @author LiteSpeed Technologies <info@litespeedtech.com>
11
- */
12
-
13
- if ( ! defined( 'WPINC' ) ) {
14
- die ;
15
- }
16
-
17
- class LiteSpeed_Cache_Crawler
18
- {
19
- private static $_instance;
20
- private $_sitemap_file ;
21
- private $_blacklist_file ;
22
- private $_home_url ;
23
- const CRWL_BLACKLIST = 'crawler_blacklist' ;
24
-
25
- private $_options ;
26
-
27
- /**
28
- * Initialize crawler, assign sitemap path
29
- *
30
- * @since 1.1.0
31
- * @access private
32
- */
33
- private function __construct()
34
- {
35
- $sitemapPath = LSCWP_DIR . 'var' ;
36
- if ( is_multisite() ) {
37
- $blogID = get_current_blog_id() ;
38
- $this->_sitemap_file = $sitemapPath . '/crawlermap-' . $blogID . '.data' ;
39
- $this->_home_url = get_home_url( $blogID ) ;
40
- }
41
- else{
42
- $this->_sitemap_file = $sitemapPath . '/crawlermap.data' ;
43
- $this->_home_url = get_home_url() ;
44
- }
45
- $this->_blacklist_file = $this->_sitemap_file . '.blacklist' ;
46
-
47
- $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
48
-
49
- LiteSpeed_Cache_Log::debug('Crawler: Initialized') ;
50
- }
51
-
52
- /**
53
- * Return crawler meta file
54
- *
55
- * @since 1.1.0
56
- * @access public
57
- * @return string Json data file path
58
- */
59
- public function get_crawler_json_path()
60
- {
61
- if ( ! file_exists($this->_sitemap_file . '.meta') ) {
62
- return false ;
63
- }
64
- $metaUrl = implode('/', array_slice(explode('/', $this->_sitemap_file . '.meta'), -5)) ;
65
- return $this->_home_url . '/' . $metaUrl ;
66
- }
67
-
68
- /**
69
- * Return blacklist content
70
- *
71
- * @since 1.1.0
72
- * @access public
73
- * @return string
74
- */
75
- public function get_blacklist()
76
- {
77
- return Litespeed_File::read($this->_blacklist_file) ;
78
- }
79
-
80
- /**
81
- * Return blacklist count
82
- *
83
- * @since 1.1.0
84
- * @access public
85
- * @return string
86
- */
87
- public function count_blacklist()
88
- {
89
- return Litespeed_File::count_lines($this->_blacklist_file) ;
90
- }
91
-
92
- /**
93
- * Save blacklist to file
94
- *
95
- * @since 1.1.0
96
- * @access public
97
- * @return bool If saved successfully
98
- */
99
- public function save_blacklist()
100
- {
101
- if ( ! isset( $_POST[ self::CRWL_BLACKLIST ] ) ) {
102
- $msg = __( 'Can not find any form data for blacklist', 'litespeed-cache' ) ;
103
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $msg ) ;
104
- return false ;
105
- }
106
- $content = $_POST[ self::CRWL_BLACKLIST ] ;
107
- $content = array_map( 'trim', explode( "\n", $content ) ) ;// remove space
108
- $content = implode( "\n", array_unique( array_filter( $content ) ) ) ;
109
-
110
- // save blacklist file
111
- $ret = Litespeed_File::save( $this->_blacklist_file, $content, true, false, false ) ;
112
- if ( $ret !== true ) {
113
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $ret ) ;
114
- }
115
- else {
116
- $msg = sprintf(
117
- __( 'File saved successfully: %s', 'litespeed-cache' ),
118
- $this->_blacklist_file
119
- ) ;
120
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
121
- }
122
-
123
- return true ;
124
- }
125
-
126
- /**
127
- * Append urls to current list
128
- *
129
- * @since 1.1.0
130
- * @access public
131
- * @param array $list The url list needs to be appended
132
- */
133
- public function append_blacklist( $list )
134
- {
135
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Crawler: append blacklist ' . count( $list ) ) ;
136
-
137
- $ori_list = Litespeed_File::read( $this->_blacklist_file ) ;
138
- $ori_list = explode( "\n", $ori_list ) ;
139
- $ori_list = array_merge( $ori_list, $list ) ;
140
- $ori_list = array_map( 'trim', $ori_list ) ;
141
- $ori_list = array_filter( $ori_list ) ;
142
- $ori_list = array_unique( $ori_list ) ;
143
- $content = implode( "\n", $ori_list ) ;
144
-
145
- // save blacklist
146
- $ret = Litespeed_File::save( $this->_blacklist_file, $content, true, false, false ) ;
147
- if ( $ret !== true ) {
148
- LiteSpeed_Cache_Log::debug( 'Crawler: append blacklist failed: ' . $ret ) ;
149
- return false ;
150
- }
151
-
152
- return true ;
153
- }
154
-
155
- /**
156
- * Generate sitemap
157
- *
158
- * @since 1.1.0
159
- * @access public
160
- */
161
- public function generate_sitemap()
162
- {
163
- $ret = $this->_generate_sitemap() ;
164
- if ( $ret !== true ) {
165
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_RED, $ret) ;
166
- }
167
- else {
168
- $msg = sprintf(
169
- __('File created successfully: %s', 'litespeed-cache'),
170
- $this->_sitemap_file
171
- ) ;
172
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
173
- }
174
- }
175
-
176
- /**
177
- * Parse custom sitemap and return urls
178
- *
179
- * @since 1.1.1
180
- * @access public
181
- * @param string $sitemap The url set map address
182
- * @param boolean $return_detail If return url list
183
- * @return bollean|array Url list or if is a sitemap
184
- */
185
- public function parse_custom_sitemap($sitemap, $return_detail = true)
186
- {
187
- /**
188
- * Read via wp func to avoid allow_url_fopen = off
189
- * @since 2.2.7
190
- */
191
- $response = wp_remote_get( $sitemap, array( 'timeout' => 15 ) ) ;
192
- if ( is_wp_error( $response ) ) {
193
- $error_message = $response->get_error_message() ;
194
- LiteSpeed_Cache_Log::debug( '[Crawler] failed to read sitemap: ' . $error_message ) ;
195
- return LiteSpeed_Cache_Admin_Error::E_SETTING_CUSTOM_SITEMAP_READ ;
196
- }
197
-
198
- $xml_object = simplexml_load_string( $response[ 'body' ] ) ;
199
- if ( ! $xml_object ) {
200
- return LiteSpeed_Cache_Admin_Error::E_SETTING_CUSTOM_SITEMAP_PARSE ;
201
- }
202
- if ( ! $return_detail ) {
203
- return true ;
204
- }
205
- // start parsing
206
- $_urls = array() ;
207
-
208
- $xml_array = (array)$xml_object ;
209
- if ( !empty($xml_array['sitemap']) ) {// parse sitemap set
210
- if ( is_object($xml_array['sitemap']) ) {
211
- $xml_array['sitemap'] = (array)$xml_array['sitemap'] ;
212
- }
213
- if ( !empty($xml_array['sitemap']['loc']) ) {// is single sitemap
214
- $urls = $this->parse_custom_sitemap($xml_array['sitemap']['loc']) ;
215
- if ( is_array($urls) && !empty($urls) ) {
216
- $_urls = array_merge($_urls, $urls) ;
217
- }
218
- }
219
- else {
220
- // parse multiple sitemaps
221
- foreach ($xml_array['sitemap'] as $val) {
222
- $val = (array)$val ;
223
- if ( !empty($val['loc']) ) {
224
- $urls = $this->parse_custom_sitemap($val['loc']) ;// recursive parse sitemap
225
- if ( is_array($urls) && !empty($urls) ) {
226
- $_urls = array_merge($_urls, $urls) ;
227
- }
228
- }
229
- }
230
- }
231
- }
232
- elseif ( !empty($xml_array['url']) ) {// parse url set
233
- if ( is_object($xml_array['url']) ) {
234
- $xml_array['url'] = (array)$xml_array['url'] ;
235
- }
236
- // if only 1 element
237
- if ( !empty($xml_array['url']['loc']) ) {
238
- $_urls[] = $xml_array['url']['loc'] ;
239
- }
240
- else {
241
- foreach ($xml_array['url'] as $val) {
242
- $val = (array)$val ;
243
- if ( !empty($val['loc']) ) {
244
- $_urls[] = $val['loc'] ;
245
- }
246
- }
247
- }
248
- }
249
-
250
- return $_urls ;
251
- }
252
-
253
- /**
254
- * Generate the sitemap
255
- *
256
- * @since 1.1.0
257
- * @access protected
258
- * @return string|true
259
- */
260
- protected function _generate_sitemap()
261
- {
262
- // use custom sitemap
263
- if ( $sitemap = $this->_options[ LiteSpeed_Cache_Config::CRWL_CUSTOM_SITEMAP ] ) {
264
- $sitemap_urls = $this->parse_custom_sitemap( $sitemap ) ;
265
- $urls = array() ;
266
- $offset = strlen( $this->_home_url ) ;
267
- if ( is_array( $sitemap_urls ) && ! empty( $sitemap_urls ) ) {
268
- foreach ( $sitemap_urls as $val ) {
269
- if ( stripos( $val, $this->_home_url ) === 0 ) {
270
- $urls[] = substr( $val, $offset ) ;
271
- }
272
- }
273
- }
274
- $urls = array_unique( $urls ) ;
275
- }
276
- else {
277
- $urls = LiteSpeed_Cache_Crawler_Sitemap::get_instance()->generate_data() ;
278
- }
279
-
280
- // filter urls
281
- $blacklist = Litespeed_File::read( $this->_blacklist_file ) ;
282
- $blacklist = explode( "\n", $blacklist ) ;
283
- $urls = array_diff( $urls, $blacklist ) ;
284
- LiteSpeed_Cache_Log::debug( 'Crawler: Generate sitemap' ) ;
285
-
286
- $ret = Litespeed_File::save( $this->_sitemap_file, implode( "\n", $urls ), true, false, false ) ;
287
-
288
- clearstatcache() ;
289
-
290
- // refresh list size in meta
291
- $crawler = new Litespeed_Crawler( $this->_sitemap_file ) ;
292
- $crawler->refresh_list_size() ;
293
-
294
- return $ret ;
295
- }
296
-
297
- /**
298
- * Get sitemap file info
299
- *
300
- * @since 1.1.0
301
- * @access public
302
- */
303
- public function sitemap_time()
304
- {
305
- if ( ! file_exists($this->_sitemap_file) ) {
306
- return false ;
307
- }
308
-
309
- $filetime = date('m/d/Y H:i:s', filemtime($this->_sitemap_file) + LITESPEED_TIME_OFFSET ) ;
310
-
311
- return $filetime ;
312
- }
313
-
314
- /**
315
- * Create reset pos file
316
- *
317
- * @since 1.1.0
318
- * @access public
319
- * @return mixed True or error message
320
- */
321
- public function reset_pos()
322
- {
323
- $crawler = new Litespeed_Crawler($this->_sitemap_file) ;
324
- $ret = $crawler->reset_pos() ;
325
- $log = 'Crawler: Reset pos. ' ;
326
- if ( $ret !== true ) {
327
- $log .= "Error: $ret" ;
328
- $msg = sprintf(__('Failed to send position reset notification: %s', 'litespeed-cache'), $ret) ;
329
- LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_RED, $msg) ;
330
- }
331
- else {
332
- $msg = __('Position reset notification sent successfully', 'litespeed-cache') ;
333
- // LiteSpeed_Cache_Admin_Display::add_notice(LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg) ;
334
- }
335
- LiteSpeed_Cache_Log::debug($log) ;
336
- }
337
-
338
- /**
339
- * Proceed crawling
340
- *
341
- * @since 1.1.0
342
- * @access public
343
- * @param bool $force If ignore whole crawling interval
344
- */
345
- public static function crawl_data($force = false)
346
- {
347
- if ( ! LiteSpeed_Cache_Router::can_crawl() ) {
348
- LiteSpeed_Cache_Log::debug('Crawler: ......crawler is NOT allowed by the server admin......') ;
349
- return false;
350
- }
351
- if ( $force ) {
352
- LiteSpeed_Cache_Log::debug('Crawler: ......crawler manually ran......') ;
353
- }
354
- return self::get_instance()->_crawl_data($force) ;
355
- }
356
-
357
- /**
358
- * Receive meta info from crawler
359
- *
360
- * @since 1.9.1
361
- * @access public
362
- */
363
- public function read_meta()
364
- {
365
- $crawler = new Litespeed_Crawler( $this->_sitemap_file ) ;
366
- return $crawler->read_meta() ;
367
- }
368
-
369
- /**
370
- * Crawling start
371
- *
372
- * @since 1.1.0
373
- * @access protected
374
- * @param bool $force If ignore whole crawling interval
375
- */
376
- protected function _crawl_data($force)
377
- {
378
- LiteSpeed_Cache_Log::debug('Crawler: ......crawler started......') ;
379
- // for the first time running
380
- if ( ! file_exists($this->_sitemap_file) ) {
381
- $ret = $this->_generate_sitemap() ;
382
- if ( $ret !== true ) {
383
- LiteSpeed_Cache_Log::debug('Crawler: ' . $ret) ;
384
- return $this->output($ret) ;
385
- }
386
- }
387
-
388
- $crawler = new Litespeed_Crawler($this->_sitemap_file) ;
389
- // if finished last time, regenerate sitemap
390
- if ( $last_fnished_at = $crawler->get_done_status() ) {
391
- // check whole crawling interval
392
- if ( ! $force && time() - $last_fnished_at < $this->_options[LiteSpeed_Cache_Config::CRWL_CRAWL_INTERVAL] ) {
393
- LiteSpeed_Cache_Log::debug('Crawler: Cron abort: cache warmed already.') ;
394
- // if not reach whole crawling interval, exit
395
- return;
396
- }
397
- LiteSpeed_Cache_Log::debug( 'Crawler: TouchedEnd. regenerate sitemap....' ) ;
398
- $this->_generate_sitemap() ;
399
- }
400
- $crawler->set_base_url($this->_home_url) ;
401
- $crawler->set_run_duration($this->_options[LiteSpeed_Cache_Config::CRWL_RUN_DURATION]) ;
402
-
403
- /**
404
- * Limit delay to use server setting
405
- * @since 1.8.3
406
- */
407
- $usleep = $this->_options[ LiteSpeed_Cache_Config::CRWL_USLEEP ] ;
408
- if ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ) && $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] > $usleep ) {
409
- $usleep = $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_USLEEP ] ;
410
- }
411
- $crawler->set_run_delay( $usleep ) ;
412
- $crawler->set_threads_limit( $this->_options[ LiteSpeed_Cache_Config::CRWL_THREADS ] ) ;
413
-
414
- $server_load_limit = $this->_options[ LiteSpeed_Cache_Config::CRWL_LOAD_LIMIT ] ;
415
- if ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ) ) {
416
- $server_load_limit = $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT_ENFORCE ] ;
417
- }
418
- elseif ( ! empty( $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT ] ) && $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT ] < $server_load_limit ) {
419
- $server_load_limit = $_SERVER[ LiteSpeed_Cache_Config::ENV_CRAWLER_LOAD_LIMIT ] ;
420
- }
421
- $crawler->set_load_limit( $server_load_limit ) ;
422
- if ( $this->_options[LiteSpeed_Cache_Config::CRWL_DOMAIN_IP] ) {
423
- $crawler->set_domain_ip($this->_options[LiteSpeed_Cache_Config::CRWL_DOMAIN_IP]) ;
424
- }
425
-
426
- // Get current crawler
427
- $meta = $crawler->read_meta() ;
428
- $curr_crawler_pos = $meta[ 'curr_crawler' ] ;
429
-
430
- // Generate all crawlers
431
- $crawlers = $this->list_crawlers() ;
432
-
433
- // In case crawlers are all done but not reload, reload it
434
- if ( empty( $crawlers[ $curr_crawler_pos ] ) ) {
435
- $curr_crawler_pos = 0 ;
436
- }
437
- $current_crawler = $crawlers[ $curr_crawler_pos ] ;
438
-
439
- $cookies = array() ;
440
- /**
441
- * Set role simulation
442
- * @since 1.9.1
443
- */
444
- if ( ! empty( $current_crawler[ 'uid' ] ) ) {
445
- // Get role simulation vary name
446
- $vary_inst = LiteSpeed_Cache_Vary::get_instance() ;
447
- $vary_name = $vary_inst->get_vary_name() ;
448
- $vary_val = $vary_inst->finalize_default_vary( $current_crawler[ 'uid' ] ) ;
449
- $cookies[ $vary_name ] = $vary_val ;
450
- $cookies[ 'litespeed_role' ] = $current_crawler[ 'uid' ] ;
451
- }
452
-
453
- /**
454
- * Check cookie crawler
455
- * @since 2.8
456
- */
457
- foreach ( $current_crawler as $k => $v ) {
458
- if ( strpos( $k, 'cookie:') !== 0 ) {
459
- continue ;
460
- }
461
-
462
- $cookies[ substr( $k, 7 ) ] = $v ;
463
- }
464
-
465
- if ( $cookies ) {
466
- $crawler->set_cookies( $cookies ) ;
467
- }
468
-
469
- /**
470
- * Set WebP simulation
471
- * @since 1.9.1
472
- */
473
- if ( ! empty( $current_crawler[ 'webp' ] ) ) {
474
- $crawler->set_headers( array( 'Accept: image/webp,*/*' ) ) ;
475
- }
476
-
477
- /**
478
- * Set mobile crawler
479
- * @since 2.8
480
- */
481
- if ( ! empty( $current_crawler[ 'mobile' ] ) ) {
482
- $crawler->set_ua( 'Mobile' ) ;
483
- }
484
-
485
- $ret = $crawler->engine_start() ;
486
-
487
- // merge blacklist
488
- if ( $ret['blacklist'] ) {
489
- $this->append_blacklist($ret['blacklist']) ;
490
- }
491
-
492
- if ( ! empty($ret['crawled']) ) {
493
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'Crawler: Last crawled ' . $ret[ 'crawled' ] . ' item(s)' ) ;
494
- }
495
-
496
- // return error
497
- if ( $ret['error'] !== false ) {
498
- LiteSpeed_Cache_Log::debug('Crawler: ' . $ret['error']) ;
499
- return $this->output($ret['error']) ;
500
- }
501
- else {
502
- $msg = 'Crawler #' . ( $curr_crawler_pos + 1 ) . ' reached end of sitemap file.' ;
503
- $msg_t = sprintf( __( 'Crawler %s reached end of sitemap file.', 'litespeed-cache' ), '#' . ( $curr_crawler_pos + 1 ) ) ;
504
- LiteSpeed_Cache_Log::debug('Crawler: ' . $msg) ;
505
- return $this->output($msg_t) ;
506
- }
507
- }
508
-
509
- /**
510
- * List all crawlers
511
- *
512
- * @since 1.9.1
513
- * @access public
514
- */
515
- public function list_crawlers( $count_only = false )
516
- {
517
- /**
518
- * Data structure:
519
- * [
520
- * tagA => [
521
- * valueA => titleA,
522
- * valueB => titleB
523
- * ...
524
- * ],
525
- * ...
526
- * ]
527
- */
528
- $crawler_factors = array() ;
529
-
530
- // Add default Guest crawler
531
- $crawler_factors[ 'uid' ] = array( 0 => __( 'Guest', 'litespeed-cache' ) ) ;
532
-
533
- // WebP on/off
534
- if ( LiteSpeed_Cache_Media::webp_enabled() ) {
535
- $crawler_factors[ 'webp' ] = array( 0 => '', 1 => 'WebP' ) ;
536
- }
537
-
538
- // Mobile crawler
539
- if ( $this->_options[ LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ] ) {
540
- $crawler_factors[ 'mobile' ] = array( 0 => '', 1 => '<font title="Mobile">📱</font>' ) ;
541
- }
542
-
543
- // Get roles set
544
- $roles = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ) ;
545
- // List all roles
546
- foreach ( $roles as $v ) {
547
- $role_title = '' ;
548
- $udata = get_userdata( $v ) ;
549
- if ( isset( $udata->roles ) && is_array( $udata->roles ) ) {
550
- $tmp = array_values( $udata->roles ) ;
551
- $role_title = array_shift( $tmp ) ;
552
- }
553
- if ( ! $role_title ) {
554
- continue ;
555
- }
556
-
557
- $crawler_factors[ 'uid' ][ $v ] = ucfirst( $role_title ) ;
558
- }
559
-
560
- // Cookie crawler
561
- $cookie_crawlers = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CRWL_COOKIES ) ;
562
- foreach ( $cookie_crawlers as $k => $v ) {
563
-
564
- $this_cookie_key = 'cookie:' . $k ;
565
-
566
- $crawler_factors[ $this_cookie_key ] = array() ;
567
-
568
- foreach ( explode( "\n", $v ) as $v2 ) {
569
- $v2 = trim( $v2 ) ;
570
- $crawler_factors[ $this_cookie_key ][ $v2 ] = $v2 ? "<font title='Cookie'>🍪</font>$k=$v2" : '' ;
571
- }
572
- }
573
-
574
- // Crossing generate the crawler list
575
- $crawler_list = $this->_recursive_build_crawler( $crawler_factors ) ;
576
-
577
- if ( $count_only ) {
578
- return count( $crawler_list ) ;
579
- }
580
-
581
- return $crawler_list ;
582
- }
583
-
584
-
585
- /**
586
- * Build a crawler list recursively
587
- *
588
- * @since 2.8
589
- * @access private
590
- */
591
- private function _recursive_build_crawler( $crawler_factors, $group = array(), $i = 0 )
592
- {
593
- $current_factor = array_keys( $crawler_factors ) ;
594
- $current_factor = $current_factor[ $i ] ;
595
-
596
- $if_touch_end = $i + 1 >= count( $crawler_factors ) ;
597
-
598
- $final_list = array() ;
599
-
600
- foreach ( $crawler_factors[ $current_factor ] as $k => $v ) {
601
-
602
- // Don't alter $group bcos of loop usage
603
- $item = $group ;
604
- $item[ 'title' ] = ! empty( $group[ 'title' ] ) ? $group[ 'title' ] : '' ;
605
- if ( $v ) {
606
- if ( $item[ 'title' ] ) {
607
- $item[ 'title' ] .= ' - ' ;
608
- }
609
- $item[ 'title' ] .= $v ;
610
- }
611
- $item[ $current_factor ] = $k ;
612
-
613
- if ( $if_touch_end ) {
614
- $final_list[] = $item ;
615
- }
616
- else {
617
- // Inception: next layer
618
- $final_list = array_merge( $final_list, $this->_recursive_build_crawler( $crawler_factors, $item, $i + 1 ) ) ;
619
- }
620
-
621
- }
622
-
623
- return $final_list ;
624
- }
625
-
626
- /**
627
- * Output info and exit
628
- *
629
- * @since 1.1.0
630
- * @access protected
631
- * @param string $error Error info
632
- */
633
- protected function output($msg)
634
- {
635
- if ( defined('DOING_CRON') ) {
636
- echo $msg ;
637
- // exit();
638
- }
639
- else {
640
- echo "<script>alert('" . htmlspecialchars($msg) . "');</script>" ;
641
- // exit;
642
- }
643
- }
644
-
645
- /**
646
- * Get the current instance object.
647
- *
648
- * @since 1.1.0
649
- * @access public
650
- * @return Current class instance.
651
- */
652
- public static function get_instance()
653
- {
654
- if ( ! isset( self::$_instance ) ) {
655
- self::$_instance = new self() ;
656
- }
657
-
658
- return self::$_instance ;
659
- }
660
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/css.cls.php DELETED
@@ -1,363 +0,0 @@
1
- <?php
2
- /**
3
- * The optimize css class.
4
- *
5
- * @since 2.3
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_CSS
16
- {
17
- private static $_instance ;
18
-
19
- const TYPE_GENERATE_CRITICAL = 'generate_critical' ;
20
-
21
- const DB_CCSS_SUMMARY = 'litespeed-ccss-summary' ;
22
-
23
- /**
24
- * Output critical css
25
- *
26
- * @since 1.3
27
- * @since 2.3 Migrated from optimize.cls
28
- * @access public
29
- */
30
- public static function prepend_ccss( $html_head )
31
- {
32
- // Get critical css for current page
33
- // Note: need to consider mobile
34
- $rules = self::get_instance()->_ccss() ;
35
-
36
- // Append default critical css
37
- $rules .= LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OPTM_CSS, true ) ;
38
-
39
- $html_head = '<style id="litespeed-optm-css-rules">' . $rules . '</style>' . $html_head ;
40
-
41
- return $html_head ;
42
- }
43
-
44
- /**
45
- * Check if there is a queue for cron or not
46
- *
47
- * @since 2.3
48
- * @access public
49
- */
50
- public static function has_queue()
51
- {
52
- $req_summary = self::get_summary() ;
53
- if ( ! empty( $req_summary[ 'queue' ] ) ) {
54
- return true ;
55
- }
56
-
57
- return false ;
58
- }
59
-
60
- /**
61
- * Check if there is a ccss cache folder
62
- *
63
- * @since 2.3
64
- * @access public
65
- */
66
- public static function has_ccss_cache()
67
- {
68
- return is_dir( LSCWP_CONTENT_DIR . '/cache/ccss' ) ;
69
- }
70
-
71
- /**
72
- * Save ccss summary
73
- *
74
- * @since 2.3
75
- * @access private
76
- */
77
- private function _save_summary( $data )
78
- {
79
- update_option( self::DB_CCSS_SUMMARY, $data ) ;
80
- }
81
-
82
- /**
83
- * Read last time generated info
84
- *
85
- * @since 2.3
86
- * @access public
87
- */
88
- public static function get_summary()
89
- {
90
- return get_option( self::DB_CCSS_SUMMARY, array() ) ;
91
- }
92
-
93
- /**
94
- * Generate realpath of ccss
95
- *
96
- * @since 2.3
97
- * @access private
98
- */
99
- private function _ccss_realpath( $ccss_type )
100
- {
101
- return LSCWP_CONTENT_DIR . "/cache/ccss/$ccss_type.css" ;
102
- }
103
-
104
- /**
105
- * Delete file-based cache folder
106
- *
107
- * @since 2.3
108
- * @access public
109
- */
110
- public function rm_cache_folder()
111
- {
112
- if ( file_exists( LSCWP_CONTENT_DIR . '/cache/ccss' ) ) {
113
- Litespeed_File::rrmdir( LSCWP_CONTENT_DIR . '/cache/ccss' ) ;
114
- }
115
-
116
- // Clear CCSS in queue too
117
- $req_summary = self::get_summary() ;
118
- $req_summary[ 'queue' ] = array() ;
119
- $req_summary[ 'curr_request' ] = 0 ;
120
- $this->_save_summary( $req_summary ) ;
121
-
122
- LiteSpeed_Cache_Log::debug2( '[CSS] Cleared ccss queue' ) ;
123
- }
124
-
125
- /**
126
- * The critical css content of the current page
127
- *
128
- * @since 2.3
129
- * @access private
130
- */
131
- private function _ccss()
132
- {
133
- // If don't need to generate CCSS, bypass
134
- if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CCSS_GEN ) ) {
135
- LiteSpeed_Cache_Log::debug( '[CSS] bypassed ccss due to setting' ) ;
136
- return '' ;
137
- }
138
-
139
- $ccss_type = $this->_which_css() ;
140
- $ccss_file = $this->_ccss_realpath( $ccss_type ) ;
141
-
142
- if ( file_exists( $ccss_file ) ) {
143
- LiteSpeed_Cache_Log::debug2( '[CSS] existing ccss ' . $ccss_file ) ;
144
- return Litespeed_File::read( $ccss_file ) ;
145
- }
146
-
147
- // Check if is already in a request, bypass current one
148
- $req_summary = self::get_summary() ;
149
- if ( $req_summary && ! empty( $req_summary[ 'curr_request' ] ) && time() - $req_summary[ 'curr_request' ] < 300 ) {
150
- return '' ;
151
- }
152
-
153
- global $wp ;
154
- $request_url = home_url( $wp->request ) ;
155
-
156
- // If generate in backend, log it and bypass
157
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC ) ) {
158
- // Store it to prepare for cron
159
- if ( empty( $req_summary[ 'queue' ] ) ) {
160
- $req_summary[ 'queue' ] = array() ;
161
- }
162
- $req_summary[ 'queue' ][ $ccss_type ] = array(
163
- 'url' => $request_url,
164
- 'user_agent' => $_SERVER[ 'HTTP_USER_AGENT' ],
165
- 'is_mobile' => $this->_separate_mobile_ccss(),
166
- ) ;// Current UA will be used to request
167
- LiteSpeed_Cache_Log::debug( '[CSS] Added queue [type] ' . $ccss_type . ' [url] ' . $request_url . ' [UA] ' . $_SERVER[ 'HTTP_USER_AGENT' ] ) ;
168
-
169
- $this->_save_summary( $req_summary ) ;
170
- return '' ;
171
- }
172
-
173
- // generate on the fly
174
- return $this->_generate_ccss( $request_url, $ccss_type, $_SERVER[ 'HTTP_USER_AGENT' ], $this->_separate_mobile_ccss() ) ;
175
- }
176
-
177
- /**
178
- * Check if need to separate ccss for mobile
179
- *
180
- * @since 2.6.4
181
- * @access private
182
- */
183
- private function _separate_mobile_ccss()
184
- {
185
- return wp_is_mobile() && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_MOBILE ) ;
186
- }
187
-
188
- /**
189
- * Cron ccss generation
190
- *
191
- * @since 2.3
192
- * @access private
193
- */
194
- public static function cron_ccss( $continue = false )
195
- {
196
- $req_summary = self::get_summary() ;
197
- if ( empty( $req_summary[ 'queue' ] ) ) {
198
- return ;
199
- }
200
-
201
- // For cron, need to check request interval too
202
- if ( ! $continue ) {
203
- if ( $req_summary && ! empty( $req_summary[ 'curr_request' ] ) && time() - $req_summary[ 'curr_request' ] < 300 ) {
204
- return ;
205
- }
206
- }
207
-
208
- foreach ( $req_summary[ 'queue' ] as $k => $v ) {
209
- if ( ! is_array( $v ) ) {// Backward compatibility for v2.6.4-
210
- LiteSpeed_Cache_Log::debug( '[CSS] previous v2.6.4- data' ) ;
211
- return ;
212
- }
213
-
214
- LiteSpeed_Cache_Log::debug( '[CSS] cron job [type] ' . $k . ' [url] ' . $v[ 'url' ] . ( $v[ 'is_mobile' ] ? ' 📱 ' : '' ) . ' [UA] ' . $v[ 'user_agent' ] ) ;
215
-
216
- self::get_instance()->_generate_ccss( $v[ 'url' ], $k, $v[ 'user_agent' ], $v[ 'is_mobile' ] ) ;
217
-
218
- // only request first one
219
- if ( ! $continue ) {
220
- return ;
221
- }
222
- }
223
- }
224
-
225
- /**
226
- * Send to LiteSpeed CCSS API to generate CCSS
227
- *
228
- * @since 2.3
229
- * @access private
230
- */
231
- private function _generate_ccss( $request_url, $ccss_type, $user_agent, $is_mobile )
232
- {
233
- $req_summary = self::get_summary() ;
234
-
235
- $ccss_file = $this->_ccss_realpath( $ccss_type ) ;
236
-
237
- // Update css request status
238
- $req_summary[ 'curr_request' ] = time() ;
239
- $this->_save_summary( $req_summary ) ;
240
-
241
- // Generate critical css
242
- $data = array(
243
- 'home_url' => home_url(),
244
- 'url' => $request_url,
245
- 'ccss_type' => $ccss_type,
246
- 'user_agent' => $user_agent,
247
- 'is_mobile' => $is_mobile ? 1 : 0,
248
- ) ;
249
-
250
- LiteSpeed_Cache_Log::debug( '[CSS] Generating: ', $data ) ;
251
-
252
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_CCSS, $data, true, false, 60 ) ;
253
-
254
- if ( empty( $json[ 'ccss' ] ) ) {
255
- LiteSpeed_Cache_Log::debug( '[CSS] empty ccss ' ) ;
256
- return false ;
257
- }
258
-
259
- // Add filters
260
- $ccss = apply_filters( 'litespeed_ccss', $json[ 'ccss' ], $ccss_type ) ;
261
-
262
- // Write to file
263
- Litespeed_File::save( $ccss_file, $ccss, true ) ;
264
-
265
- // Save summary data
266
- $req_summary[ 'last_spent' ] = time() - $req_summary[ 'curr_request' ] ;
267
- $req_summary[ 'last_request' ] = $req_summary[ 'curr_request' ] ;
268
- $req_summary[ 'curr_request' ] = 0 ;
269
- if ( empty( $req_summary[ 'ccss_type_history' ] ) ) {
270
- $req_summary[ 'ccss_type_history' ] = array() ;
271
- }
272
- $req_summary[ 'ccss_type_history' ][ $ccss_type ] = $request_url ;
273
- unset( $req_summary[ 'queue' ][ $ccss_type ] ) ;
274
-
275
- $this->_save_summary( $req_summary ) ;
276
-
277
- LiteSpeed_Cache_Log::debug( '[CSS] saved ccss ' . $ccss_file ) ;
278
-
279
- LiteSpeed_Cache_Log::debug2( '[CSS] ccss con: ' . $ccss ) ;
280
-
281
- return $ccss ;
282
- }
283
-
284
- /**
285
- * The critical css file for current page
286
- *
287
- * @since 2.3
288
- * @access private
289
- */
290
- private function _which_css()
291
- {
292
- $css = LiteSpeed_Cache_Utility::page_type() ;
293
-
294
- $unique = false ;
295
-
296
- // Check if in separate css type option
297
- $separate_posttypes = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_POSTTYPE ) ;
298
- if ( ! empty( $separate_posttypes ) && in_array( $css, $separate_posttypes ) ) {
299
- LiteSpeed_Cache_Log::debug( '[CSS] Hit separate posttype setting [type] ' . $css ) ;
300
- $unique = true ;
301
- }
302
-
303
- $separate_uri = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OPTM_CCSS_SEPARATE_URI ) ;
304
- if ( ! empty( $separate_uri ) ) {
305
- $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $separate_uri ) ;
306
- if ( $result ) {
307
- LiteSpeed_Cache_Log::debug( '[CSS] Hit separate URI setting: ' . $result ) ;
308
- $unique = true ;
309
- }
310
- }
311
-
312
- if ( $unique ) {
313
- $css .= '-' . md5( $_SERVER[ 'REQUEST_URI' ] ) ;
314
- }
315
-
316
- if ( $this->_separate_mobile_ccss() ) {
317
- $css .= '.mobile' ;
318
- }
319
-
320
- return $css ;
321
- }
322
-
323
- /**
324
- * Handle all request actions from main cls
325
- *
326
- * @since 2.3
327
- * @access public
328
- */
329
- public static function handler()
330
- {
331
- $instance = self::get_instance() ;
332
-
333
- $type = LiteSpeed_Cache_Router::verify_type() ;
334
-
335
- switch ( $type ) {
336
- case self::TYPE_GENERATE_CRITICAL :
337
- self::cron_ccss( true ) ;
338
- break ;
339
-
340
- default:
341
- break ;
342
- }
343
-
344
- LiteSpeed_Cache_Admin::redirect() ;
345
- }
346
-
347
- /**
348
- * Get the current instance object.
349
- *
350
- * @since 2.3
351
- * @access public
352
- * @return Current class instance.
353
- */
354
- public static function get_instance()
355
- {
356
- if ( ! isset( self::$_instance ) ) {
357
- self::$_instance = new self() ;
358
- }
359
-
360
- return self::$_instance ;
361
- }
362
-
363
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/data.class.php DELETED
@@ -1,359 +0,0 @@
1
- <?php
2
- /**
3
- * The class to store and manage litespeed db data.
4
- *
5
- * @since 1.3.1
6
- * @since 1.5 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Data
17
- {
18
- private static $_instance ;
19
-
20
- const TB_OPTIMIZER = 'litespeed_optimizer' ;
21
- const TB_IMG_OPTM = 'litespeed_img_optm' ;
22
-
23
- private $_charset_collate ;
24
- private $_tb_optm ;
25
- private $_tb_img_optm ;
26
-
27
- /**
28
- * Init
29
- *
30
- * @since 1.3.1
31
- * @access private
32
- */
33
- private function __construct()
34
- {
35
- LiteSpeed_Cache_Log::debug2( 'Data init' ) ;
36
- global $wpdb ;
37
-
38
- $this->_charset_collate = $wpdb->get_charset_collate() ;
39
-
40
- $this->_tb_optm = $wpdb->prefix . self::TB_OPTIMIZER ;
41
- $this->_tb_img_optm = $wpdb->prefix . self::TB_IMG_OPTM ;
42
-
43
- $this->_create_tb_img_optm() ;
44
- $this->_create_tb_html_optm() ;
45
- }
46
-
47
- /**
48
- * Get img_optm table name
49
- *
50
- * @since 2.0
51
- * @access public
52
- */
53
- public static function get_tb_img_optm()
54
- {
55
- global $wpdb ;
56
- return $wpdb->prefix . self::TB_IMG_OPTM ;
57
- }
58
-
59
- /**
60
- * Get optimizer table
61
- *
62
- * @since 1.4
63
- * @access public
64
- */
65
- public static function get_optm_table()
66
- {
67
- global $wpdb ;
68
- return $wpdb->prefix . self::TB_OPTIMIZER ;
69
- }
70
-
71
- /**
72
- * Check if optimizer table exists or not
73
- *
74
- * @since 1.3.1.1
75
- * @access public
76
- */
77
- public static function optm_available()
78
- {
79
- global $wpdb ;
80
- $instance = self::get_instance() ;
81
- return $wpdb->get_var( "SHOW TABLES LIKE '$instance->_tb_optm'" ) ;
82
- }
83
-
84
- /**
85
- * Get data structure of one table
86
- *
87
- * @since 2.0
88
- * @access private
89
- */
90
- private function _get_data_structure( $tb )
91
- {
92
- return Litespeed_File::read( LSCWP_DIR . 'inc/data_structure/' . $tb . '.sql' ) ;
93
- }
94
-
95
- /**
96
- * Drop table img_optm
97
- *
98
- * @since 2.0
99
- * @access private
100
- */
101
- public function delete_tb_img_optm()
102
- {
103
- global $wpdb ;
104
-
105
- if ( ! $wpdb->get_var( "SHOW TABLES LIKE '$this->_tb_img_optm'" ) ) {
106
- return ;
107
- }
108
-
109
- LiteSpeed_Cache_Log::debug( '[Data] Deleting img_optm table' ) ;
110
-
111
- $q = "DROP TABLE IF EXISTS $this->_tb_img_optm" ;
112
- $wpdb->query( $q ) ;
113
-
114
- delete_option( $this->_tb_img_optm ) ;
115
- }
116
-
117
- /**
118
- * Create img optm table and sync data from wp_postmeta
119
- *
120
- * @since 2.0
121
- * @access private
122
- */
123
- private function _create_tb_img_optm()
124
- {
125
- if ( defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
126
- return ;
127
- }
128
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
129
-
130
- global $wpdb ;
131
-
132
- LiteSpeed_Cache_Log::debug2( '[Data] Checking img_optm table' ) ;
133
-
134
- // Check if table exists first
135
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->_tb_img_optm'" ) ) {
136
- LiteSpeed_Cache_Log::debug2( '[Data] Existed' ) ;
137
- // return ;
138
- }
139
- else {
140
- LiteSpeed_Cache_Log::debug( '[Data] Creating img_optm table' ) ;
141
-
142
- $sql = sprintf(
143
- 'CREATE TABLE IF NOT EXISTS `%1$s` (' . $this->_get_data_structure( 'img_optm' ) . ') %2$s;',
144
- $this->_tb_img_optm,
145
- $this->_charset_collate // 'DEFAULT CHARSET=utf8'
146
- ) ;
147
-
148
- $res = $wpdb->query( $sql ) ;
149
- if ( $res !== true ) {
150
- LiteSpeed_Cache_Log::debug( '[Data] Warning: Creating img_optm table failed!', $sql ) ;
151
- }
152
-
153
- // Clear OC to avoid get `_tb_img_optm` from option failed
154
- if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
155
- LiteSpeed_Cache_Object::get_instance()->flush() ;
156
- }
157
-
158
- }
159
-
160
- // Table version only exists after all old data migrated
161
- // Last modified is v2.4.2
162
- $ver = get_option( $this->_tb_img_optm ) ;
163
- if ( $ver && version_compare( $ver, '2.4.2', '>=' ) ) {
164
- return ;
165
- }
166
-
167
- /**
168
- * Convert old data from postmeta to img_optm table
169
- * @since 2.0
170
- */
171
- if ( ! $ver || version_compare( $ver, '2.0', '<' ) ) {
172
- // Migrate data from `wp_postmeta` to `wp_litespeed_img_optm`
173
- $mids_to_del = array() ;
174
- $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_id" ;
175
- $meta_value_list = $wpdb->get_results( $wpdb->prepare( $q, array( LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_DATA ) ) ) ;
176
- if ( $meta_value_list ) {
177
- $max_k = count( $meta_value_list ) - 1 ;
178
- foreach ( $meta_value_list as $k => $v ) {
179
- $md52src_list = maybe_unserialize( $v->meta_value ) ;
180
- foreach ( $md52src_list as $md5 => $v2 ) {
181
- $f = array(
182
- 'post_id' => $v->post_id,
183
- 'optm_status' => $v2[ 1 ],
184
- 'src' => $v2[ 0 ],
185
- 'srcpath_md5' => md5( $v2[ 0 ] ),
186
- 'src_md5' => $md5,
187
- 'server' => $v2[ 2 ],
188
- ) ;
189
- $wpdb->replace( $this->_tb_img_optm, $f ) ;
190
- }
191
- $mids_to_del[] = $v->meta_id ;
192
-
193
- // Delete from postmeta
194
- if ( count( $mids_to_del ) > 100 || $k == $max_k ) {
195
- $q = "DELETE FROM $wpdb->postmeta WHERE meta_id IN ( " . implode( ',', array_fill( 0, count( $mids_to_del ), '%s' ) ) . " ) " ;
196
- $wpdb->query( $wpdb->prepare( $q, $mids_to_del ) ) ;
197
-
198
- $mids_to_del = array() ;
199
- }
200
- }
201
-
202
- LiteSpeed_Cache_Log::debug( '[Data] img_optm inserted records: ' . $k ) ;
203
- }
204
-
205
- $q = "DELETE FROM $wpdb->postmeta WHERE meta_key = %s" ;
206
- $rows = $wpdb->query( $wpdb->prepare( $q, LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_STATUS ) ) ;
207
- LiteSpeed_Cache_Log::debug( '[Data] img_optm delete optm_status records: ' . $rows ) ;
208
- }
209
-
210
- /**
211
- * Add target_md5 field to table
212
- * @since 2.4.2
213
- */
214
- if ( $ver && version_compare( $ver, '2.4.2', '<' ) && version_compare( $ver, '2.0', '>=' ) ) {// NOTE: For new users, need to bypass this section, thats why used the first cond
215
- $sql = sprintf(
216
- 'ALTER TABLE `%1$s` ADD `server_info` text NOT NULL, DROP COLUMN `server`',
217
- $this->_tb_img_optm
218
- ) ;
219
-
220
- $res = $wpdb->query( $sql ) ;
221
- if ( $res !== true ) {
222
- LiteSpeed_Cache_Log::debug( '[Data] Warning: Alter table img_optm failed!', $sql ) ;
223
- }
224
- else {
225
- LiteSpeed_Cache_Log::debug( '[Data] Successfully upgraded table img_optm.' ) ;
226
- }
227
-
228
- }
229
-
230
- // Record tb version
231
- update_option( $this->_tb_img_optm, LiteSpeed_Cache::PLUGIN_VERSION ) ;
232
- }
233
-
234
- /**
235
- * Create optimizer table
236
- *
237
- * @since 1.3.1
238
- * @access private
239
- */
240
- private function _create_tb_html_optm()
241
- {
242
- if ( defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
243
- return ;
244
- }
245
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
246
-
247
- global $wpdb ;
248
-
249
- LiteSpeed_Cache_Log::debug2( '[Data] Checking html optm table' ) ;
250
-
251
- // Check if table exists first
252
- if ( $wpdb->get_var( "SHOW TABLES LIKE '$this->_tb_optm'" ) ) {
253
- LiteSpeed_Cache_Log::debug2( '[Data] Existed' ) ;
254
- return ;
255
- }
256
-
257
- LiteSpeed_Cache_Log::debug( '[Data] Creating html optm table' ) ;
258
-
259
- $sql = sprintf(
260
- 'CREATE TABLE IF NOT EXISTS `%1$s` (' . $this->_get_data_structure( 'optm' ) . ') %2$s;',
261
- $this->_tb_optm,
262
- $this->_charset_collate
263
- ) ;
264
-
265
- $res = $wpdb->query( $sql ) ;
266
- if ( $res !== true ) {
267
- LiteSpeed_Cache_Log::debug( '[Data] Warning: Creating html optm table failed!' ) ;
268
- }
269
-
270
- // Move data from wp_options to here
271
- $hashes = get_option( 'litespeed-cache-optimized' ) ;
272
- if ( $hashes ) {
273
- foreach ( $hashes as $k => $v ) {
274
- $f = array(
275
- 'hash_name' => $k,
276
- 'src' => json_encode( $v ),
277
- 'dateline' => time(),
278
- 'refer' => '',
279
- ) ;
280
- $wpdb->replace( $this->_tb_optm, $f ) ;
281
- }
282
- }
283
- delete_option( 'litespeed-cache-optimized' ) ;
284
-
285
- // Record tb version
286
- update_option( $this->_tb_optm, LiteSpeed_Cache::PLUGIN_VERSION ) ;
287
-
288
- }
289
-
290
- /**
291
- * save optimizer src to db
292
- *
293
- * @since 1.3.1
294
- * @access public
295
- */
296
- public static function optm_save_src( $filename, $src )
297
- {
298
- $instance = self::get_instance() ;
299
- return $instance->_optm_save_src( $filename, $src ) ;
300
- }
301
- private function _optm_save_src( $filename, $src )
302
- {
303
- global $wpdb ;
304
-
305
- $src = json_encode( $src ) ;
306
- $f = array(
307
- 'hash_name' => $filename,
308
- 'src' => $src,
309
- 'dateline' => time(),
310
- 'refer' => ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ? $_SERVER[ 'SCRIPT_URI' ] : '',
311
- ) ;
312
-
313
- $res = $wpdb->replace( $this->_tb_optm, $f ) ;
314
-
315
- return $res ;
316
- }
317
-
318
- /**
319
- * Get src set from hash in optimizer
320
- *
321
- * @since 1.3.1
322
- * @access public
323
- */
324
- public static function optm_hash2src( $filename )
325
- {
326
- $instance = self::get_instance() ;
327
- return $instance->_optm_hash2src( $filename ) ;
328
- }
329
- private function _optm_hash2src( $filename )
330
- {
331
- global $wpdb ;
332
-
333
- $sql = $wpdb->prepare( 'SELECT src FROM `' . $this->_tb_optm . '` WHERE `hash_name` = %s', $filename ) ;
334
- $res = $wpdb->get_var( $sql ) ;
335
-
336
- LiteSpeed_Cache_Log::debug2( '[Data] Loaded hash2src ' . $res ) ;
337
-
338
- $res = json_decode( $res, true ) ;
339
-
340
- return $res ;
341
- }
342
-
343
- /**
344
- * Get the current instance object.
345
- *
346
- * @since 1.3.1
347
- * @access public
348
- * @return Current class instance.
349
- */
350
- public static function get_instance()
351
- {
352
- if ( ! isset( self::$_instance ) ) {
353
- self::$_instance = new self() ;
354
- }
355
-
356
- return self::$_instance ;
357
- }
358
-
359
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/data_structure/img_optm.sql DELETED
@@ -1,20 +0,0 @@
1
- `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
2
- `post_id` bigint(20) unsigned NOT NULL DEFAULT '0',
3
- `optm_status` varchar(64) NOT NULL DEFAULT '',
4
- `src` varchar(1000) NOT NULL DEFAULT '',
5
- `srcpath_md5` varchar(128) NOT NULL DEFAULT '',
6
- `src_md5` varchar(128) NOT NULL DEFAULT '',
7
- `root_id` int(11) NOT NULL DEFAULT '0',
8
- `src_filesize` int(11) NOT NULL DEFAULT '0',
9
- `target_filesize` int(11) NOT NULL DEFAULT '0',
10
- `target_saved` int(11) NOT NULL DEFAULT '0',
11
- `webp_filesize` int(11) NOT NULL DEFAULT '0',
12
- `webp_saved` int(11) NOT NULL DEFAULT '0',
13
- `server_info` text NOT NULL,
14
- PRIMARY KEY (`id`),
15
- UNIQUE KEY `post_id_2` (`post_id`,`srcpath_md5`),
16
- KEY `post_id` (`post_id`),
17
- KEY `optm_status` (`optm_status`),
18
- KEY `root_id` (`root_id`),
19
- KEY `src_md5` (`src_md5`),
20
- KEY `srcpath_md5` (`srcpath_md5`)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/data_structure/optm.sql DELETED
@@ -1,8 +0,0 @@
1
- `id` int(11) NOT NULL AUTO_INCREMENT,
2
- `hash_name` varchar(60) NOT NULL COMMENT "hash.filetype",
3
- `src` text NOT NULL COMMENT "full url array set",
4
- `dateline` int(11) NOT NULL,
5
- `refer` varchar(255) NOT NULL COMMENT "The container page url",
6
- PRIMARY KEY (`id`),
7
- UNIQUE KEY `hash_name` (`hash_name`),
8
- KEY `dateline` (`dateline`)
 
 
 
 
 
 
 
 
inc/doc.cls.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * The Doc class.
4
- *
5
- * @since 2.2.7
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Doc
16
- {
17
- // private static $_instance ;
18
-
19
- /**
20
- * Privacy policy
21
- *
22
- * @since 2.2.7
23
- * @access public
24
- */
25
- public static function privacy_policy()
26
- {
27
- return __( 'This site utilizes caching in order to facilitate a faster response time and better user experience. Caching potentially stores a duplicate copy of every web page that is on display on this site. All cache files are temporary, and are never accessed by any third party, except as necessary to obtain technical support from the cache plugin vendor. Cache files expire on a schedule set by the site administrator, but may easily be purged by the admin before their natural expiration, if necessary.', 'litespeed-cache' ) ;
28
- }
29
-
30
-
31
- /**
32
- * Learn more link
33
- *
34
- * @since 2.4.2
35
- * @access public
36
- */
37
- public static function learn_more( $url )
38
- {
39
- return ' <a href="' . $url . '" target="_blank" class="litespeed-learn-more">' . __( 'Learn More', 'litespeed-cache' ) . '</a>' ;
40
- }
41
-
42
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/img_optm.class.php DELETED
@@ -1,2168 +0,0 @@
1
- <?php
2
- /**
3
- * The class to optimize image.
4
- *
5
- * @since 2.0
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Img_Optm
16
- {
17
- private static $_instance ;
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_OPTM_DESTROY = 'img_optm_destroy' ;
23
- const TYPE_IMG_OPTM_DESTROY_UNFINISHED = 'img_optm_destroy-unfinished' ;
24
- const TYPE_IMG_PULL = 'img_pull' ;
25
- const TYPE_IMG_BATCH_SWITCH_ORI = 'img_optm_batch_switch_ori' ;
26
- const TYPE_IMG_BATCH_SWITCH_OPTM = 'img_optm_batch_switch_optm' ;
27
- const TYPE_CALC_BKUP = 'calc_bkup' ;
28
- const TYPE_RESET_ROW = 'reset_row' ;
29
- const TYPE_RM_BKUP = 'rm_bkup' ;
30
-
31
- const ITEM_IMG_OPTM_CRON_RUN = 'litespeed-img_optm_cron_run' ; // last cron running time
32
-
33
- const DB_IMG_OPTIMIZE_DESTROY = 'litespeed-optimize-destroy' ;
34
- const DB_IMG_OPTIMIZE_DATA = 'litespeed-optimize-data' ;
35
- const DB_IMG_OPTIMIZE_STATUS = 'litespeed-optimize-status' ;
36
- const DB_IMG_OPTIMIZE_STATUS_PREPARE = 'prepare' ;
37
- const DB_IMG_OPTIMIZE_STATUS_REQUESTED = 'requested' ;
38
- const DB_IMG_OPTIMIZE_STATUS_NOTIFIED = 'notified' ;
39
- const DB_IMG_OPTIMIZE_STATUS_PULLED = 'pulled' ;
40
- const DB_IMG_OPTIMIZE_STATUS_FAILED = 'failed' ;
41
- const DB_IMG_OPTIMIZE_STATUS_MISS = 'miss' ;
42
- const DB_IMG_OPTIMIZE_STATUS_ERR = 'err' ;
43
- const DB_IMG_OPTIMIZE_STATUS_ERR_FETCH = 'err_fetch' ;
44
- const DB_IMG_OPTIMIZE_STATUS_ERR_OPTM = 'err_optm' ;
45
- const DB_IMG_OPTIMIZE_STATUS_XMETA = 'xmeta' ;
46
- const DB_IMG_OPTIMIZE_SIZE = 'litespeed-optimize-size' ;
47
-
48
- const DB_IMG_OPTM_SUMMARY = 'litespeed_img_optm_summary' ;
49
- const DB_IMG_OPTM_BK_SUMMARY = 'litespeed_img_optm_bk_summary' ;
50
- const DB_IMG_OPTM_RMBK_SUMMARY = 'litespeed_img_optm_rmbk_summary' ;
51
-
52
- const NUM_THRESHOLD_AUTO_REQUEST = 1200 ;
53
-
54
- private $wp_upload_dir ;
55
- private $tmp_pid ;
56
- private $tmp_path ;
57
- private $_img_in_queue = array() ;
58
- private $_img_duplicated_in_queue = array() ;
59
- private $_missed_img_in_queue = array() ;
60
- private $_img_srcpath_md5_array = array() ;
61
- private $_img_total = 0 ;
62
- private $_table_img_optm ;
63
- private $_cron_ran = false ;
64
-
65
- private $__media ;
66
-
67
- /**
68
- * Init
69
- *
70
- * @since 2.0
71
- * @access private
72
- */
73
- private function __construct()
74
- {
75
- LiteSpeed_Cache_Log::debug2( 'ImgOptm init' ) ;
76
-
77
- $this->wp_upload_dir = wp_upload_dir() ;
78
- $this->__media = LiteSpeed_Cache_Media::get_instance() ;
79
- $this->_table_img_optm = LiteSpeed_Cache_Data::get_tb_img_optm() ;
80
- }
81
-
82
- /**
83
- * Sync data from litespeed IAPI server for CLI usage
84
- *
85
- * @since 2.4.4
86
- * @access public
87
- */
88
- public function sync_data()
89
- {
90
- return $this->_sync_data( true ) ;
91
- }
92
-
93
- /**
94
- * Sync data from litespeed IAPI server
95
- *
96
- * @since 1.6.5
97
- * @access private
98
- */
99
- private function _sync_data( $try_level_up = false )
100
- {
101
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_MEDIA_SYNC_DATA, false, true ) ;
102
-
103
- if ( ! is_array( $json ) ) {
104
- return ;
105
- }
106
-
107
- if ( ! empty( $json ) ) {
108
- update_option( self::DB_IMG_OPTM_SUMMARY, $json ) ;
109
- }
110
-
111
- // If this is for level up try, return data directly
112
- if ( $try_level_up ) {
113
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Try Level Up ~ !' ) ;
114
- return $json ;
115
- }
116
-
117
- $msg = __( 'Communicated with LiteSpeed Image Optimization Server successfully.', 'litespeed-cache' ) ;
118
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
119
-
120
- if ( ! defined( 'LITESPEED_CLI' ) ) {
121
- LiteSpeed_Cache_Admin::redirect() ;
122
- }
123
- }
124
-
125
- /**
126
- * Request optm to litespeed IAPI server for CLI usage
127
- *
128
- * @since 2.4.4
129
- * @access public
130
- */
131
- public function request_optm()
132
- {
133
- return $this->_request_optm() ;
134
- }
135
-
136
- /**
137
- * Push raw img to LiteSpeed IAPI server
138
- *
139
- * @since 1.6
140
- * @access private
141
- */
142
- private function _request_optm()
143
- {
144
- global $wpdb ;
145
-
146
- $_credit = (int) $this->summary_info( 'credit' ) ;
147
- $credit_recovered = (int) $this->summary_info( 'credit_recovered' ) ;
148
-
149
-
150
- LiteSpeed_Cache_Log::debug( '[Img_Optm] preparing images to push' ) ;
151
-
152
- // Get images
153
- $q = "SELECT b.post_id, b.meta_value
154
- FROM $wpdb->posts a
155
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
156
- LEFT JOIN $this->_table_img_optm c ON c.post_id = a.ID
157
- WHERE a.post_type = 'attachment'
158
- AND a.post_status = 'inherit'
159
- AND a.post_mime_type IN ('image/jpeg', 'image/png')
160
- AND b.meta_key = '_wp_attachment_metadata'
161
- AND c.id IS NULL
162
- ORDER BY a.ID DESC
163
- LIMIT %d
164
- " ;
165
- $q = $wpdb->prepare( $q, apply_filters( 'litespeed_img_optimize_max_rows', 3000 ) ) ;
166
-
167
- $img_set = array() ;
168
- $list = $wpdb->get_results( $q ) ;
169
- if ( ! $list ) {
170
- $msg = __( 'No image found.', 'litespeed-cache' ) ;
171
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
172
-
173
- LiteSpeed_Cache_Log::debug( '[Img_Optm] optimize bypass: no image found' ) ;
174
- return $msg ;
175
- }
176
-
177
- LiteSpeed_Cache_Log::debug( '[Img_Optm] found images: ' . count( $list ) ) ;
178
-
179
- foreach ( $list as $v ) {
180
-
181
- $meta_value = $this->_parse_wp_meta_value( $v ) ;
182
- if ( ! $meta_value ) {
183
- $this->_mark_wrong_meta_src( $v->post_id ) ;
184
- continue ;
185
- }
186
-
187
- /**
188
- * Only send 500 images one time
189
- * @since 1.6.3
190
- * @since 1.6.5 use credit limit
191
- */
192
- $num_will_incease = 1 ;
193
- if ( ! empty( $meta_value[ 'sizes' ] ) ) {
194
- $num_will_incease += count( $meta_value[ 'sizes' ] ) ;
195
- }
196
- if ( $this->_img_total + $num_will_incease > $_credit ) {
197
- if ( ! $this->_img_total ) {
198
- $msg = sprintf( __( 'Number of images in one image group (%s) exceeds the credit (%s)', 'litespeed-cache' ), $num_will_incease, $_credit ) ;
199
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
200
- }
201
- LiteSpeed_Cache_Log::debug( '[Img_Optm] img request hit limit: [total] ' . $this->_img_total . " \t[add] $num_will_incease \t[credit] $_credit" ) ;
202
- break ;
203
- }
204
- /**
205
- * Check if need to test run ( new user only allow 1 group at first time)
206
- * @since 1.6.6.1
207
- */
208
- if ( $this->_img_total && ! $credit_recovered ) {
209
- LiteSpeed_Cache_Log::debug( '[Img_Optm] test run only allow 1 group ' ) ;
210
- break ;
211
- }
212
-
213
- // push orig image to queue
214
- $this->tmp_pid = $v->post_id ;
215
- $this->tmp_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/' ;
216
- $this->_img_queue( $meta_value, true ) ;
217
- if ( ! empty( $meta_value[ 'sizes' ] ) ) {
218
- array_map( array( $this, '_img_queue' ), $meta_value[ 'sizes' ] ) ;
219
- }
220
- }
221
-
222
- // Save missed images into img_optm
223
- $this->_save_missed_into_img_optm() ;
224
-
225
- if ( empty( $this->_img_in_queue ) ) {
226
- $msg = __( 'Requested successfully.', 'litespeed-cache' ) ;
227
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
228
-
229
- LiteSpeed_Cache_Log::debug( '[Img_Optm] optimize bypass: empty _img_in_queue' ) ;
230
- return array( 'ok' => $msg ) ;
231
- }
232
-
233
- // Filtered from existing data
234
- $this->_filter_existing_src() ;
235
-
236
- /**
237
- * Filter same src in $this->_img_in_queue
238
- *
239
- * 1. Save them to tmp array $this->_img_duplicated_in_queue
240
- * 2. Remove them from $this->_img_in_queue
241
- * 3. After inserted $this->_img_in_queue into img_optm, insert $this->_img_duplicated_in_queue into img_optm with root_id
242
- */
243
- $this->_filter_duplicated_src() ;
244
-
245
- if ( empty( $this->_img_in_queue ) ) {
246
- $msg = __( 'Optimized successfully.', 'litespeed-cache' ) ;
247
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
248
- return array( 'ok' => $msg ) ;
249
- }
250
-
251
- $total_groups = count( $this->_img_in_queue ) ;
252
- LiteSpeed_Cache_Log::debug( '[Img_Optm] prepared images to push: groups ' . $total_groups . ' images ' . $this->_img_total ) ;
253
-
254
- // Push to LiteSpeed IAPI server
255
- $json = $this->_push_img_in_queue_to_iapi() ;
256
- if ( ! is_array( $json ) ) {
257
- return $json ;
258
- }
259
- $pids = $json[ 'pids' ] ;
260
-
261
- $data_to_add = array() ;
262
- foreach ( $pids as $pid ) {
263
- foreach ( $this->_img_in_queue[ $pid ] as $md5 => $src_data ) {
264
- $data_to_add[] = $pid ;
265
- $data_to_add[] = self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ;
266
- $data_to_add[] = $src_data[ 'src' ] ;
267
- $data_to_add[] = $src_data[ 'srcpath_md5' ] ;
268
- $data_to_add[] = $md5 ;
269
- $data_to_add[] = $src_data[ 'src_filesize' ] ;
270
- }
271
- }
272
- $this->_insert_img_optm( $data_to_add ) ;
273
-
274
- // Insert duplicated data
275
- if ( $this->_img_duplicated_in_queue ) {
276
- // Generate root_id from inserted ones
277
- $srcpath_md5_to_search = array() ;
278
- foreach ( $this->_img_duplicated_in_queue as $v ) {
279
- $srcpath_md5_to_search[] = $v[ 'info' ][ 'srcpath_md5' ] ;
280
- }
281
- $existing_img_list = $this->_select_img_by_root_srcpath( $srcpath_md5_to_search ) ;
282
-
283
- $data_to_add = array() ;
284
- foreach ( $this->_img_duplicated_in_queue as $v ) {
285
- $existing_info = $existing_img_list[ $v[ 'info' ][ 'srcpath_md5' ] ] ;
286
-
287
- $data_to_add[] = $v[ 'pid' ] ;
288
- $data_to_add[] = $existing_info[ 'status' ] ;
289
- $data_to_add[] = $existing_info[ 'src' ] ;
290
- $data_to_add[] = $existing_info[ 'srcpath_md5' ] ;
291
- $data_to_add[] = $existing_info[ 'src_md5' ] ;
292
- $data_to_add[] = $existing_info[ 'src_filesize' ] ;
293
- $data_to_add[] = $existing_info[ 'id' ] ;
294
- }
295
- $this->_insert_img_optm( $data_to_add, 'post_id, optm_status, src, srcpath_md5, src_md5, src_filesize, root_id' ) ;
296
- }
297
-
298
- $accepted_groups = count( $pids ) ;
299
- $accepted_imgs = $json[ 'total' ] ;
300
-
301
- $placeholder1 = LiteSpeed_Cache_Admin_Display::print_plural( $total_groups ) . ' (' . LiteSpeed_Cache_Admin_Display::print_plural( $this->_img_total, 'image' ) . ')' ;
302
- $placeholder2 = LiteSpeed_Cache_Admin_Display::print_plural( $accepted_groups ) . ' (' . LiteSpeed_Cache_Admin_Display::print_plural( $accepted_imgs, 'image' ) . ')' ;
303
- $msg = sprintf( __( 'Pushed %1$s to LiteSpeed optimization server, accepted %2$s.', 'litespeed-cache' ), $placeholder1, $placeholder2 ) ;
304
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
305
-
306
- // Update credit info
307
- if ( isset( $json[ 'credit' ] ) ) {
308
- $this->_update_credit( $json[ 'credit' ] ) ;
309
- }
310
-
311
- return array( 'ok' => $msg ) ;
312
-
313
- }
314
-
315
- /**
316
- * Insert data into table img_optm
317
- *
318
- * @since 2.0
319
- * @access private
320
- */
321
- private function _insert_img_optm( $data, $fields = 'post_id, optm_status, src, srcpath_md5, src_md5, src_filesize' )
322
- {
323
- if ( empty( $data ) ) {
324
- return ;
325
- }
326
-
327
- global $wpdb ;
328
-
329
- $division = substr_count( $fields, ',' ) + 1 ;
330
-
331
- $q = "REPLACE INTO $this->_table_img_optm ( $fields ) VALUES " ;
332
-
333
- // Add placeholder
334
- $q .= $this->_chunk_placeholder( $data, $division ) ;
335
-
336
- // Store data
337
- $wpdb->query( $wpdb->prepare( $q, $data ) ) ;
338
- }
339
-
340
- /**
341
- * Get all root img data by srcpath_md5
342
- *
343
- * @since 2.0
344
- * @access private
345
- */
346
- private function _select_img_by_root_srcpath( $srcpath_md5_to_search )
347
- {
348
- global $wpdb ;
349
-
350
- $existing_img_list = array() ;
351
-
352
- $srcpath_md5_to_search = array_unique( $srcpath_md5_to_search ) ;
353
-
354
- $q = "SELECT * FROM $this->_table_img_optm WHERE root_id=0 AND srcpath_md5 IN ( " . implode( ',', array_fill( 0, count( $srcpath_md5_to_search ), '%s' ) ) . " )" ;
355
- $tmp = $wpdb->get_results( $wpdb->prepare( $q, $srcpath_md5_to_search ) ) ;
356
- foreach ( $tmp as $v ) {
357
- $existing_img_list[ $v->srcpath_md5 ] = array(
358
- 'id' => $v->id,
359
- 'status' => $v->optm_status,
360
- 'pid' => $v->post_id,
361
- 'src' => $v->src,
362
- 'srcpath_md5' => $v->srcpath_md5,
363
- 'src_md5' => $v->src_md5,
364
- 'src_filesize' => $v->src_filesize,
365
- ) ;
366
- }
367
-
368
- return $existing_img_list ;
369
- }
370
-
371
- /**
372
- * Save failed to parse meta info
373
- *
374
- * @since 2.1.1
375
- * @access private
376
- */
377
- private function _mark_wrong_meta_src( $pid )
378
- {
379
- $data = array(
380
- $pid,
381
- self::DB_IMG_OPTIMIZE_STATUS_XMETA,
382
- ) ;
383
- $this->_insert_img_optm( $data, 'post_id, optm_status' ) ;
384
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Mark wrong meta [pid] ' . $pid ) ;
385
- }
386
-
387
- /**
388
- * Handle existing same src path images
389
- *
390
- * @since 2.0
391
- * @access private
392
- */
393
- private function _filter_existing_src()
394
- {
395
- global $wpdb ;
396
- // var_dump($this->_img_in_queue);
397
- // var_dump($this->_img_srcpath_md5_array);
398
- $existing_img_list = $this->_select_img_by_root_srcpath( $this->_img_srcpath_md5_array ) ;
399
- // var_dump($existing_img_list);
400
- // Handle existing same src data
401
- $existing_img_optm = array() ;
402
- $size_to_store = array() ;// pulled images need to update `wp_postmeta` size info
403
- foreach ( $this->_img_in_queue as $pid => $img_list ) {
404
- $changed = false ;
405
- foreach ( $img_list as $md5 => $v ) {
406
- if ( array_key_exists( $v[ 'srcpath_md5' ], $existing_img_list ) ) {
407
- $existing_info = $existing_img_list[ $v[ 'srcpath_md5' ] ] ;
408
-
409
- // Insert into img_optm table directly
410
- $existing_img_optm[] = $pid ;
411
- $existing_img_optm[] = $existing_info[ 'status' ] ;
412
- $existing_img_optm[] = $existing_info[ 'src' ] ;
413
- $existing_img_optm[] = $existing_info[ 'srcpath_md5' ] ;
414
- $existing_img_optm[] = $existing_info[ 'src_md5' ] ;
415
- $existing_img_optm[] = $existing_info[ 'src_filesize' ] ;
416
- $existing_img_optm[] = $existing_info[ 'id' ] ;
417
-
418
- // Bypass IAPI posting by removing from img_in_queue
419
- unset( $this->_img_in_queue[ $pid ][ $md5 ] ) ;
420
-
421
- // Size info exists. Prepare size info for `wp_postmeta`
422
- // Only pulled images have size_info
423
- if ( $existing_info[ 'status' ] == self::DB_IMG_OPTIMIZE_STATUS_PULLED ) {
424
- $size_to_store[ $pid ] = $existing_info[ 'pid' ] ;
425
- }
426
-
427
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Existing pulled [pid] ' . $pid . " \t\t\t[status] " . $existing_info[ 'status' ] . " \t\t\t[src] " . $v[ 'src' ] ) ;
428
-
429
- $changed = true ;
430
- }
431
- }
432
-
433
- if ( $changed ) {
434
- if ( empty( $this->_img_in_queue[ $pid ] ) ) {
435
- unset( $this->_img_in_queue[ $pid ] ) ;
436
- }
437
- }
438
-
439
- }
440
- // var_dump($this->_img_in_queue);
441
- // var_dump($existing_img_list);
442
- // var_dump($existing_img_optm);//exit;
443
- // Existing img needs to be inserted separately
444
- if ( $existing_img_optm ) {
445
- $this->_insert_img_optm( $existing_img_optm, 'post_id, optm_status, src, srcpath_md5, src_md5, src_filesize, root_id' ) ;
446
- }
447
-
448
- // These post_meta in key need to update size info to same as post_meta in val
449
- if ( $size_to_store ) {
450
- // Get current data
451
- $pids = array_unique( $size_to_store ) ;
452
-
453
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Existing size info root pids', $pids ) ;
454
-
455
- // NOTE: Separate this query while not using LEFT JOIN in SELECT * FROM $this->_table_img_optm in previous query to lower db load
456
- $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s AND post_id IN ( " . implode( ',', array_fill( 0, count( $pids ), '%s' ) ) . " )" ;
457
- $tmp = $wpdb->get_results( $wpdb->prepare( $q, array_merge( array( self::DB_IMG_OPTIMIZE_SIZE ), $pids ) ) ) ;
458
- $existing_sizes = array() ;
459
- foreach ( $tmp as $v ) {
460
- $existing_sizes[ $v->post_id ] = $v->meta_value ;
461
- }
462
-
463
- // Get existing new data
464
- $size_to_store_pids = array_keys( $size_to_store ) ;
465
- $q = "SELECT * FROM $wpdb->postmeta WHERE meta_key = %s AND post_id IN ( " . implode( ',', array_fill( 0, count( $size_to_store_pids ), '%s' ) ) . " )" ;
466
- $tmp = $wpdb->get_results( $wpdb->prepare( $q, array_merge( array( self::DB_IMG_OPTIMIZE_SIZE ), $size_to_store_pids ) ) ) ;
467
- $q_to_update = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d" ;
468
- $size_to_update_pids = array() ;
469
- foreach ( $tmp as $v ) {
470
- $size_to_update_pids[] = $v->post_id ;
471
- $from_pid = $size_to_store[ $v->post_id ] ;
472
- // Update existing data ( Replaced with existing size info wholly )
473
- $wpdb->query( $wpdb->prepare( $q_to_update, array( $existing_sizes[ $from_pid ], $v->meta_id ) ) ) ;
474
-
475
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Updated optm_size info [pid] ' . $v->post_id . " \t\t\t[from_pid] " . $from_pid ) ;
476
- }
477
-
478
- // Insert new size info
479
- $size_to_insert_pids = array_diff( $size_to_store_pids, $size_to_update_pids ) ;
480
- $q = "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES " ;
481
- $data = array() ;
482
- foreach ( $size_to_insert_pids as $pid ) {
483
- $data[] = $pid ;
484
- $data[] = self::DB_IMG_OPTIMIZE_SIZE ;
485
- $data[] = $existing_sizes[ $size_to_store[ $pid ] ] ;
486
- }
487
-
488
- // Add placeholder
489
- $q .= $this->_chunk_placeholder( $data, 3 ) ;
490
-
491
- // Store data
492
- $wpdb->query( $wpdb->prepare( $q, $data ) ) ;
493
-
494
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Inserted optm_size info [total] ' . count( $size_to_insert_pids ) ) ;
495
-
496
- }
497
-
498
- }
499
-
500
- /**
501
- * Filter duplicated src in $this->_img_in_queue
502
- *
503
- * @since 2.0
504
- * @access private
505
- */
506
- private function _filter_duplicated_src()
507
- {
508
- $srcpath_md5_list = array() ;
509
- $total_img_duplicated = 0 ;
510
- $total_pid_unset = 0 ;
511
- foreach ( $this->_img_in_queue as $pid => $img_list ) {
512
- foreach ( $img_list as $md5 => $v ) {
513
- if ( in_array( $v[ 'srcpath_md5' ], $srcpath_md5_list ) ) {
514
- $this->_img_duplicated_in_queue[] = array(
515
- 'pid' => $pid,
516
- 'info' => $v,
517
- ) ;
518
-
519
- $total_img_duplicated ++ ;
520
-
521
- unset( $this->_img_in_queue[ $pid ][ $md5 ] ) ;
522
-
523
- continue ;
524
- }
525
-
526
- $srcpath_md5_list[ $pid . '.' . $md5 ] = $v[ 'srcpath_md5' ] ;
527
-
528
- }
529
-
530
- if ( empty( $this->_img_in_queue[ $pid ] ) ) {
531
- unset( $this->_img_in_queue[ $pid ] ) ;
532
- $total_pid_unset ++ ;
533
- }
534
- }
535
-
536
- if ( $this->_img_duplicated_in_queue ) {
537
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Found duplicated src [total_img_duplicated] ' . $total_img_duplicated . ' [total_pid_unset] ' . $total_pid_unset ) ;
538
- }
539
- }
540
-
541
- /**
542
- * Generate placeholder for an array to query
543
- *
544
- * @since 2.0
545
- * @access private
546
- */
547
- private function _chunk_placeholder( $data, $division )
548
- {
549
- $q = implode( ',', array_map(
550
- function( $el ) { return '(' . implode( ',', $el ) . ')' ; },
551
- array_chunk( array_fill( 0, count( $data ), '%s' ), $division )
552
- ) ) ;
553
-
554
- return $q ;
555
- }
556
-
557
- /**
558
- * Saved non-existed images into img_optm
559
- *
560
- * @since 2.0
561
- * @access private
562
- */
563
- private function _save_missed_into_img_optm()
564
- {
565
- if ( ! $this->_missed_img_in_queue ) {
566
- return ;
567
- }
568
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Missed img need to save [total] ' . count( $this->_missed_img_in_queue ) ) ;
569
-
570
- $data_to_add = array() ;
571
- foreach ( $this->_missed_img_in_queue as $src_data ) {
572
- $data_to_add[] = $src_data[ 'pid' ] ;
573
- $data_to_add[] = self::DB_IMG_OPTIMIZE_STATUS_MISS ;
574
- $data_to_add[] = $src_data[ 'src' ] ;
575
- $data_to_add[] = $src_data[ 'srcpath_md5' ] ;
576
- }
577
- $this->_insert_img_optm( $data_to_add, 'post_id, optm_status, src, srcpath_md5' ) ;
578
- }
579
-
580
- /**
581
- * Add a new img to queue which will be pushed to LiteSpeed
582
- *
583
- * @since 1.6
584
- * @access private
585
- */
586
- private function _img_queue( $meta_value, $ori_file = false )
587
- {
588
- if ( empty( $meta_value[ 'file' ] ) || empty( $meta_value[ 'width' ] ) || empty( $meta_value[ 'height' ] ) ) {
589
- LiteSpeed_Cache_Log::debug2( '[Img_Optm] bypass image due to lack of file/w/h: pid ' . $this->tmp_pid, $meta_value ) ;
590
- return ;
591
- }
592
-
593
- $short_file_path = $meta_value[ 'file' ] ;
594
-
595
- if ( ! $ori_file ) {
596
- $short_file_path = $this->tmp_path . $short_file_path ;
597
- }
598
-
599
- // check file exists or not
600
- $_img_info = $this->__media->info( $short_file_path, $this->tmp_pid ) ;
601
-
602
- if ( ! $_img_info || ! in_array( pathinfo( $short_file_path, PATHINFO_EXTENSION ), array( 'jpg', 'jpeg', 'png' ) ) ) {
603
- $this->_missed_img_in_queue[] = array(
604
- 'pid' => $this->tmp_pid,
605
- 'src' => $short_file_path,
606
- 'srcpath_md5' => md5( $short_file_path ),
607
- ) ;
608
- LiteSpeed_Cache_Log::debug2( '[Img_Optm] bypass image due to file not exist: pid ' . $this->tmp_pid . ' ' . $short_file_path ) ;
609
- return ;
610
- }
611
-
612
- LiteSpeed_Cache_Log::debug2( '[Img_Optm] adding image: pid ' . $this->tmp_pid ) ;
613
-
614
- /**
615
- * Filter `litespeed_img_optm_options_per_image`
616
- * @since 2.4.2
617
- */
618
- /**
619
- * To use the filter `litespeed_img_optm_options_per_image` to manipulate `optm_options`, do below:
620
- *
621
- * add_filter( 'litespeed_img_optm_options_per_image', function( $optm_options, $file ){
622
- * // To add optimize original image
623
- * if ( Your conditions ) {
624
- * $optm_options |= LiteSpeed_Cache_API::IMG_OPTM_BM_ORI ;
625
- * }
626
- *
627
- * // To add optimize webp image
628
- * if ( Your conditions ) {
629
- * $optm_options |= LiteSpeed_Cache_API::IMG_OPTM_BM_WEBP ;
630
- * }
631
- *
632
- * // To turn on lossless optimize for this image e.g. if filename contains `magzine`
633
- * if ( strpos( $file, 'magzine' ) !== false ) {
634
- * $optm_options |= LiteSpeed_Cache_API::IMG_OPTM_BM_LOSSLESS ;
635
- * }
636
- *
637
- * // To set keep exif info for this image
638
- * if ( Your conditions ) {
639
- * $optm_options |= LiteSpeed_Cache_API::IMG_OPTM_BM_EXIF ;
640
- * }
641
- *
642
- * return $optm_options ;
643
- * } ) ;
644
- *
645
- */
646
- $optm_options = apply_filters( 'litespeed_img_optm_options_per_image', 0, $short_file_path ) ;
647
-
648
- $img_info = array(
649
- 'url' => $_img_info[ 'url' ],
650
- 'src' => $short_file_path, // not needed in LiteSpeed IAPI, just leave for local storage after post
651
- 'width' => $meta_value[ 'width' ],
652
- 'height' => $meta_value[ 'height' ],
653
- 'mime_type' => ! empty( $meta_value[ 'mime-type' ] ) ? $meta_value[ 'mime-type' ] : '' ,
654
- 'srcpath_md5' => md5( $short_file_path ),
655
- 'src_filesize' => $_img_info[ 'size' ], // Only used for local storage and calculation
656
- 'optm_options' => $optm_options,
657
- ) ;
658
-
659
- if ( empty( $this->_img_in_queue[ $this->tmp_pid ] ) ) {
660
- $this->_img_in_queue[ $this->tmp_pid ] = array() ;
661
- }
662
- $this->_img_in_queue[ $this->tmp_pid ][ $_img_info[ 'md5' ] ] = $img_info ;
663
- $this->_img_total ++ ;
664
-
665
- // Build existing data checking array
666
- $this->_img_srcpath_md5_array[] = $img_info[ 'srcpath_md5' ] ;
667
- }
668
-
669
- /**
670
- * Push img to LiteSpeed IAPI server
671
- *
672
- * @since 1.6.7
673
- * @access private
674
- */
675
- private function _push_img_in_queue_to_iapi()
676
- {
677
- $data = array(
678
- 'list' => $this->_img_in_queue,
679
- 'optm_ori' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ? 1 : 0,
680
- 'optm_webp' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ? 1 : 0,
681
- 'optm_lossless' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_LOSSLESS ) ? 1 : 0,
682
- 'keep_exif' => LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_EXIF ) ? 1 : 0,
683
- ) ;
684
-
685
- // Push to LiteSpeed IAPI server
686
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_REQUEST_OPTIMIZE, LiteSpeed_Cache_Utility::arr2str( $data ), true, false ) ;
687
-
688
- // admin_api will handle common err
689
- if ( ! is_array( $json ) ) {
690
- return $json ;
691
- }
692
-
693
- // Check data format
694
- if ( empty( $json[ 'pids' ] ) || ! is_array( $json[ 'pids' ] ) ) {
695
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to parse data from LiteSpeed IAPI server ', $json[ 'pids' ] ) ;
696
- $msg = sprintf( __( 'Failed to parse data from LiteSpeed IAPI server: %s', 'litespeed-cache' ), var_export( $json[ 'pids' ], true ) ) ;
697
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
698
- return $json ;
699
- }
700
-
701
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Returned data from LiteSpeed IAPI server count: ' . count( $json[ 'pids' ] ) ) ;
702
-
703
- return $json ;
704
-
705
- }
706
-
707
- /**
708
- * LiteSpeed Child server notify Client img status changed
709
- *
710
- * @since 1.6
711
- * @since 1.6.5 Added err/request status free switch
712
- * @access public
713
- */
714
- public function notify_img()
715
- {
716
- global $wpdb ;
717
-
718
- list( $notified_data, $server, $status ) = $this->_parse_notify_data() ;
719
-
720
- $pids = array_keys( $notified_data ) ;
721
-
722
- $q = "SELECT a.*, b.meta_id as b_meta_id, b.meta_value AS b_optm_info
723
- FROM $this->_table_img_optm a
724
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.post_id AND b.meta_key = %s
725
- WHERE a.optm_status != %s AND a.post_id IN ( " . implode( ',', array_fill( 0, count( $pids ), '%d' ) ) . " )" ;
726
- $list = $wpdb->get_results( $wpdb->prepare( $q, array_merge( array( self::DB_IMG_OPTIMIZE_SIZE, self::DB_IMG_OPTIMIZE_STATUS_PULLED ), $pids ) ) ) ;
727
-
728
- $need_pull = false ;
729
- $last_log_pid = 0 ;
730
- $postmeta_info = array() ;
731
- $child_postmeta_info = array() ;
732
-
733
- foreach ( $list as $v ) {
734
- if ( ! array_key_exists( $v->src_md5, $notified_data[ $v->post_id ] ) ) {
735
- // This image is not in notifcation
736
- continue ;
737
- }
738
-
739
- $json = $notified_data[ $v->post_id ][ $v->src_md5 ] ;
740
-
741
- $server_info = array(
742
- 'server' => $server,
743
- ) ;
744
-
745
- // Only need to update meta_info for pull notification, for other notifications, no need to modify meta_info
746
- if ( ! empty( $json[ 'ori' ] ) || ! empty( $json[ 'webp' ] ) ) {
747
- // Save server side ID to send taken notification after pulled
748
- $server_info[ 'id' ] = $json[ 'id' ] ;
749
-
750
- // Default optm info array
751
- if ( empty( $postmeta_info[ $v->post_id ] ) ) {
752
- $postmeta_info[ $v->post_id ] = array(
753
- 'meta_id' => $v->b_meta_id,
754
- 'meta_info' => array(
755
- 'ori_total' => 0,
756
- 'ori_saved' => 0,
757
- 'webp_total' => 0,
758
- 'webp_saved' => 0,
759
- ),
760
- ) ;
761
- // Init optm_info for the first one
762
- if ( ! empty( $v->b_meta_id ) ) {
763
- foreach ( maybe_unserialize( $v->b_optm_info ) as $k2 => $v2 ) {
764
- $postmeta_info[ $v->post_id ][ 'meta_info' ][ $k2 ] += $v2 ;
765
- }
766
- }
767
- }
768
-
769
- }
770
-
771
- $target_saved = 0 ;
772
- if ( ! empty( $json[ 'ori' ] ) ) {
773
- $server_info[ 'ori_md5' ] = $json[ 'ori_md5' ] ;
774
- $server_info[ 'ori' ] = $json[ 'ori' ] ;
775
-
776
- $target_saved = $json[ 'ori_reduced' ] ;
777
-
778
- // Append meta info
779
- $postmeta_info[ $v->post_id ][ 'meta_info' ][ 'ori_total' ] += $json[ 'src_size' ] ;
780
- $postmeta_info[ $v->post_id ][ 'meta_info' ][ 'ori_saved' ] += $json[ 'ori_reduced' ] ;
781
-
782
- }
783
-
784
- $webp_saved = 0 ;
785
- if ( ! empty( $json[ 'webp' ] ) ) {
786
- $server_info[ 'webp_md5' ] = $json[ 'webp_md5' ] ;
787
- $server_info[ 'webp' ] = $json[ 'webp' ] ;
788
-
789
- $webp_saved = $json[ 'webp_reduced' ] ;
790
-
791
- // Append meta info
792
- $postmeta_info[ $v->post_id ][ 'meta_info' ][ 'webp_total' ] += $json[ 'src_size' ] ;
793
- $postmeta_info[ $v->post_id ][ 'meta_info' ][ 'webp_saved' ] += $json[ 'webp_reduced' ] ;
794
- }
795
-
796
- // Update status and data
797
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_saved = %d, webp_saved = %d, server_info = %s WHERE id = %d " ;
798
- $wpdb->query( $wpdb->prepare( $q, array( $status, $target_saved, $webp_saved, json_encode( $server_info ), $v->id ) ) ) ;
799
-
800
- // Update child images ( same md5 files )
801
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_saved = %d, webp_saved = %d WHERE root_id = %d " ;
802
- $child_count = $wpdb->query( $wpdb->prepare( $q, array( $status, $target_saved, $webp_saved, $v->id ) ) ) ;
803
-
804
- // Group child meta_info for later update
805
- if ( ! empty( $json[ 'ori' ] ) || ! empty( $json[ 'webp' ] ) ) {
806
- if ( $child_count ) {
807
- $child_postmeta_info[ $v->id ] = $postmeta_info[ $v->post_id ][ 'meta_info' ] ;
808
- }
809
- }
810
-
811
- // write log
812
- $pid_log = $last_log_pid == $v->post_id ? '.' : $v->post_id ;
813
- LiteSpeed_Cache_Log::debug( '[Img_Optm] notify_img [status] ' . $status . " \t\t[pid] " . $pid_log . " \t\t[id] " . $v->id ) ;
814
- $last_log_pid = $v->post_id ;
815
-
816
- // set need_pull tag
817
- if ( $status == self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
818
- $need_pull = true ;
819
- }
820
-
821
- }
822
-
823
- /**
824
- * Update size saved info
825
- * @since 1.6.5
826
- */
827
- if ( $postmeta_info ) {
828
- foreach ( $postmeta_info as $post_id => $optm_arr ) {
829
- $optm_info = serialize( $optm_arr[ 'meta_info' ] ) ;
830
-
831
- if ( ! empty( $optm_arr[ 'meta_id' ] ) ) {
832
- $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d " ;
833
- $wpdb->query( $wpdb->prepare( $q, array( $optm_info, $optm_arr[ 'meta_id' ] ) ) ) ;
834
- }
835
- else {
836
- LiteSpeed_Cache_Log::debug( '[Img_Optm] New size info [pid] ' . $post_id ) ;
837
- $q = "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES ( %d, %s, %s )" ;
838
- $wpdb->query( $wpdb->prepare( $q, array( $post_id, self::DB_IMG_OPTIMIZE_SIZE, $optm_info ) ) ) ;
839
- }
840
- }
841
- }
842
-
843
- // Update child postmeta data based on root_id
844
- if ( $child_postmeta_info ) {
845
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Proceed child images [total] ' . count( $child_postmeta_info ) ) ;
846
-
847
- $root_id_list = array_keys( $child_postmeta_info ) ;
848
-
849
- $q = "SELECT a.*, b.meta_id as b_meta_id
850
- FROM $this->_table_img_optm a
851
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.post_id AND b.meta_key = %s
852
- WHERE a.root_id IN ( " . implode( ',', array_fill( 0, count( $root_id_list ), '%d' ) ) . " ) GROUP BY a.post_id" ;
853
-
854
- $tmp = $wpdb->get_results( $wpdb->prepare( $q, array_merge( array( self::DB_IMG_OPTIMIZE_SIZE ), $root_id_list ) ) ) ;
855
-
856
- $pids_to_update = array() ;
857
- $pids_data_to_insert = array() ;
858
- foreach ( $tmp as $v ) {
859
- $optm_info = serialize( $child_postmeta_info[ $v->root_id ] ) ;
860
-
861
- if ( $v->b_meta_id ) {
862
- $pids_to_update[] = $v->post_id ;
863
- }
864
- else {
865
- $pids_data_to_insert[] = $v->post_id ;
866
- $pids_data_to_insert[] = self::DB_IMG_OPTIMIZE_SIZE ;
867
- $pids_data_to_insert[] = $optm_info ;
868
- }
869
- }
870
-
871
- // Update these size_info
872
- if ( $pids_to_update ) {
873
- $pids_to_update = array_unique( $pids_to_update ) ;
874
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Update child group size_info [total] ' . count( $pids_to_update ) ) ;
875
-
876
- $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_key = %s AND post_id IN ( " . implode( ',', array_fill( 0, count( $pids_to_update ), '%d' ) ) . " )" ;
877
- $wpdb->query( $wpdb->prepare( $q, array_merge( array( $optm_info, self::DB_IMG_OPTIMIZE_SIZE ), $pids_to_update ) ) ) ;
878
- }
879
-
880
- // Insert these size_info
881
- if ( $pids_data_to_insert ) {
882
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Insert child group size_info [total] ' . ( count( $pids_data_to_insert ) / 3 ) ) ;
883
-
884
- $q = "INSERT INTO $wpdb->postmeta ( post_id, meta_key, meta_value ) VALUES " ;
885
- // Add placeholder
886
- $q .= $this->_chunk_placeholder( $pids_data_to_insert, 3 ) ;
887
- $wpdb->query( $wpdb->prepare( $q, $pids_data_to_insert ) ) ;
888
- }
889
-
890
- }
891
-
892
- // Mark need_pull tag for cron
893
- if ( $need_pull ) {
894
- update_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ;
895
- }
896
-
897
- // redo count err
898
-
899
- echo json_encode( array( 'count' => count( $notified_data ) ) ) ;
900
- exit() ;
901
-
902
- }
903
-
904
- /**
905
- * parse LiteSpeed IAPI server data
906
- *
907
- * @since 1.6.5
908
- * @access public
909
- */
910
- private function _parse_notify_data()
911
- {
912
- $notified_data = json_decode( base64_decode( $_POST[ 'data' ] ), true ) ;
913
- if ( empty( $notified_data ) || ! is_array( $notified_data ) ) {
914
- LiteSpeed_Cache_Log::debug( '[Img_Optm] ❌ notify exit: no notified data' ) ;
915
- exit( json_encode( 'no notified data' ) ) ;
916
- }
917
-
918
- if ( empty( $_POST[ 'server' ] ) || substr( $_POST[ 'server' ], -21 ) !== 'api.litespeedtech.com' ) {
919
- LiteSpeed_Cache_Log::debug( '[Img_Optm] notify exit: no/wrong server' ) ;
920
- exit( json_encode( 'no/wrong server' ) ) ;
921
- }
922
-
923
- $_allowed_status = array(
924
- self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED,
925
- self::DB_IMG_OPTIMIZE_STATUS_REQUESTED,
926
- ) ;
927
-
928
- if ( empty( $_POST[ 'status' ] ) || ( ! in_array( $_POST[ 'status' ], $_allowed_status ) && substr( $_POST[ 'status' ], 0, 3 ) != self::DB_IMG_OPTIMIZE_STATUS_ERR ) ) {
929
- LiteSpeed_Cache_Log::debug( '[Img_Optm] notify exit: no/wrong status' ) ;
930
- exit( json_encode( 'no/wrong status' ) ) ;
931
- }
932
-
933
- return array( $notified_data, $_POST[ 'server' ], $_POST[ 'status' ] ) ;
934
- }
935
-
936
- /**
937
- * Cron pull optimized img
938
- *
939
- * @since 1.6
940
- * @access public
941
- */
942
- public static function cron_pull_optimized_img()
943
- {
944
- if ( ! defined( 'DOING_CRON' ) ) {
945
- return ;
946
- }
947
-
948
- $tag = get_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL ) ;
949
-
950
- if ( ! $tag || $tag !== self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) {
951
- return ;
952
- }
953
-
954
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Cron pull_optimized_img started' ) ;
955
-
956
- self::get_instance()->_pull_optimized_img() ;
957
- }
958
-
959
- /**
960
- * Pull optm data from litespeed IAPI server for CLI usage
961
- *
962
- * @since 2.4.4
963
- * @access public
964
- */
965
- public function pull_img()
966
- {
967
- $res = $this->_pull_optimized_img() ;
968
-
969
- $this->_update_cron_running( true ) ;
970
-
971
- return $res ;
972
- }
973
-
974
- /**
975
- * Pull optimized img
976
- *
977
- * @since 1.6
978
- * @access private
979
- */
980
- private function _pull_optimized_img( $manual = false )
981
- {
982
- if ( $this->cron_running() ) {
983
- $msg = '[Img_Optm] fetch cron is running' ;
984
- LiteSpeed_Cache_Log::debug( $msg ) ;
985
- return $msg ;
986
- }
987
-
988
- global $wpdb ;
989
-
990
- $q = "SELECT * FROM $this->_table_img_optm FORCE INDEX ( optm_status ) WHERE root_id = 0 AND optm_status = %s ORDER BY id LIMIT 1" ;
991
- $_q = $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ;
992
-
993
- $optm_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_ORI ) ;
994
- $rm_ori_bkup = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_RM_ORI_BKUP ) ;
995
- $optm_webp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_WEBP ) ;
996
-
997
- // pull 1 min images each time
998
- $end_time = time() + ( $manual ? 120 : 60 ) ;
999
-
1000
- $server_list = array() ;
1001
-
1002
- $total_pulled_ori = 0 ;
1003
- $total_pulled_webp = 0 ;
1004
- $beginning = time() ;
1005
-
1006
- set_time_limit( $end_time + 20 ) ;
1007
- while ( time() < $end_time ) {
1008
- $row_img = $wpdb->get_row( $_q ) ;
1009
- if ( ! $row_img ) {
1010
- // No image
1011
- break ;
1012
- }
1013
-
1014
- /**
1015
- * Update cron timestamp to avoid duplicated running
1016
- * @since 1.6.2
1017
- */
1018
- $this->_update_cron_running() ;
1019
-
1020
- /**
1021
- * If no server_info, will fail to pull
1022
- * This is only for v2.4.2- data
1023
- * @see https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization:2-4-2-upgrade
1024
- */
1025
- $server_info = json_decode( $row_img->server_info, true ) ;
1026
- if ( empty( $server_info[ 'server' ] ) ) {
1027
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to decode server_info.' ) ;
1028
-
1029
- $msg = sprintf(
1030
- __( 'LSCWP %1$s has simplified the image pulling process. Please %2$s, or resend the pull notification this one time only. After that, the process will be automated.', 'litespeed-cache' ),
1031
- 'v2.9.6',
1032
- LiteSpeed_Cache_GUI::img_optm_clean_up_unfinished()
1033
- ) ;
1034
-
1035
- $msg .= LiteSpeed_Cache_Doc::learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:image-optimization:2-4-2-upgrade' ) ;
1036
-
1037
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1038
-
1039
- return ;
1040
- }
1041
- $server = $server_info[ 'server' ] ;
1042
-
1043
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $row_img->src ;
1044
-
1045
- // Save ori optm image
1046
- $target_size = 0 ;
1047
-
1048
- if ( ! empty( $server_info[ 'ori' ] ) ) {
1049
- /**
1050
- * Use wp orignal get func to avoid allow_url_open off issue
1051
- * @since 1.6.5
1052
- */
1053
- $response = wp_remote_get( $server_info[ 'ori' ], array( 'timeout' => 15 ) ) ;
1054
- if ( is_wp_error( $response ) ) {
1055
- $error_message = $response->get_error_message() ;
1056
- LiteSpeed_Cache_Log::debug( 'IAPI failed to pull image: ' . $error_message ) ;
1057
- return ;
1058
- }
1059
-
1060
- file_put_contents( $local_file . '.tmp', $response[ 'body' ] ) ;
1061
-
1062
- if ( ! file_exists( $local_file . '.tmp' ) || ! filesize( $local_file . '.tmp' ) || md5_file( $local_file . '.tmp' ) !== $server_info[ 'ori_md5' ] ) {
1063
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized img: file md5 dismatch, server md5: ' . $server_info[ 'ori_md5' ] ) ;
1064
-
1065
- // update status to failed
1066
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
1067
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
1068
- // Update child images
1069
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE root_id = %d " ;
1070
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
1071
-
1072
- return 'Md5 dismatch' ; // exit from running pull process
1073
- }
1074
-
1075
- // Backup ori img
1076
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1077
- $bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
1078
-
1079
- if ( ! $rm_ori_bkup ) {
1080
- file_exists( $local_file ) && rename( $local_file, $bk_file ) ;
1081
- }
1082
-
1083
- // Replace ori img
1084
- rename( $local_file . '.tmp', $local_file ) ;
1085
-
1086
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img: ' . $local_file ) ;
1087
-
1088
- $target_size = filesize( $local_file ) ;
1089
-
1090
- /**
1091
- * API Hook
1092
- * @since 2.9.5
1093
- */
1094
- do_action( 'litespeed_img_pull_ori', $row_img, $local_file ) ;
1095
-
1096
- $total_pulled_ori ++ ;
1097
- }
1098
-
1099
- // Save webp image
1100
- $webp_size = 0 ;
1101
-
1102
- if ( ! empty( $server_info[ 'webp' ] ) ) {
1103
-
1104
- // Fetch
1105
- $response = wp_remote_get( $server_info[ 'webp' ], array( 'timeout' => 15 ) ) ;
1106
- if ( is_wp_error( $response ) ) {
1107
- $error_message = $response->get_error_message() ;
1108
- LiteSpeed_Cache_Log::debug( 'IAPI failed to pull webp image: ' . $error_message ) ;
1109
- return ;
1110
- }
1111
-
1112
- file_put_contents( $local_file . '.webp', $response[ 'body' ] ) ;
1113
-
1114
- if ( ! file_exists( $local_file . '.webp' ) || ! filesize( $local_file . '.webp' ) || md5_file( $local_file . '.webp' ) !== $server_info[ 'webp_md5' ] ) {
1115
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Failed to pull optimized webp img: file md5 dismatch, server md5: ' . $server_info[ 'webp_md5' ] ) ;
1116
-
1117
- // update status to failed
1118
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE id = %d " ;
1119
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
1120
- // Update child images
1121
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s WHERE root_id = %d " ;
1122
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_FAILED, $row_img->id ) ) ) ;
1123
-
1124
- return 'WebP md5 dismatch' ; // exit from running pull process
1125
- }
1126
-
1127
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
1128
-
1129
- $webp_size = filesize( $local_file . '.webp' ) ;
1130
-
1131
- /**
1132
- * API for WebP
1133
- * @since 2.9.5
1134
- * @see #751737 - API docs for WEBP generation
1135
- */
1136
- do_action( 'litespeed_img_pull_webp', $row_img, $local_file . '.webp' ) ;
1137
-
1138
- $total_pulled_webp ++ ;
1139
- }
1140
-
1141
- LiteSpeed_Cache_Log::debug2( '[Img_Optm] Update _table_img_optm record [id] ' . $row_img->id ) ;
1142
-
1143
- // Update pulled status
1144
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, webp_filesize = %d WHERE id = %d " ;
1145
- $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $webp_size, $row_img->id ) ) ) ;
1146
-
1147
- // Update child images ( same md5 files )
1148
- $q = "UPDATE $this->_table_img_optm SET optm_status = %s, target_filesize = %d, webp_filesize = %d WHERE root_id = %d " ;
1149
- $child_count = $wpdb->query( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $target_size, $webp_size, $row_img->id ) ) ) ;
1150
-
1151
- // Save server_list to notify taken
1152
- if ( empty( $server_list[ $server ] ) ) {
1153
- $server_list[ $server ] = array() ;
1154
- }
1155
- $server_list[ $server ][] = $server_info[ 'id' ] ;
1156
-
1157
- }
1158
-
1159
- // Notify IAPI images taken
1160
- $json = false ;
1161
- foreach ( $server_list as $server => $img_list ) {
1162
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_IMG_TAKEN, $img_list, $server, true ) ;
1163
- }
1164
-
1165
- // use latest credit from last server response
1166
- // Recover credit
1167
- if ( is_array( $json ) && isset( $json[ 'credit' ] ) ) {
1168
- $this->_update_credit( $json[ 'credit' ] ) ;
1169
- }
1170
-
1171
- // Try level up
1172
- $tried_level_up = $this->_try_level_up() ;
1173
-
1174
- // Check if there is still task in queue
1175
- $q = "SELECT * FROM $this->_table_img_optm WHERE root_id = 0 AND optm_status = %s LIMIT 1" ;
1176
- $tmp = $wpdb->get_row( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED ) ) ;
1177
- if ( $tmp ) {
1178
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Task in queue, to be continued...' ) ;
1179
- return array( 'ok' => 'to_be_continued' ) ;
1180
- }
1181
-
1182
- // If all pulled, update tag to done
1183
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Marked pull status to all pulled' ) ;
1184
- update_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ;
1185
-
1186
- $time_cost = time() - $beginning ;
1187
- if ( $tried_level_up ) {
1188
- $tried_level_up = "[Msg] $tried_level_up" ;
1189
- }
1190
-
1191
- return array( 'ok' => "Pulled [ori] $total_pulled_ori [WebP] $total_pulled_webp [cost] {$time_cost}s $tried_level_up" ) ;
1192
- }
1193
-
1194
- /**
1195
- * Auto send optm request
1196
- *
1197
- * @since 2.4.1
1198
- * @access public
1199
- */
1200
- public static function cron_auto_request()
1201
- {
1202
- if ( ! defined( 'DOING_CRON' ) ) {
1203
- return false ;
1204
- }
1205
-
1206
- $instance = self::get_instance() ;
1207
-
1208
- $credit = (int) $instance->summary_info( 'credit' ) ;
1209
- if ( $credit < self::NUM_THRESHOLD_AUTO_REQUEST ) {
1210
- return false ;
1211
- }
1212
-
1213
- // No need to check last time request interval for now
1214
-
1215
- $instance->_request_optm( 'from cron' ) ;
1216
- }
1217
-
1218
- /**
1219
- * Show an image's optm status
1220
- *
1221
- * @since 1.6.5
1222
- * @access public
1223
- */
1224
- public function check_img()
1225
- {
1226
- global $wpdb ;
1227
-
1228
- $pid = $_POST[ 'data' ] ;
1229
-
1230
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Check image [ID] ' . $pid ) ;
1231
-
1232
- $data = array() ;
1233
-
1234
- $data[ 'img_count' ] = $this->img_count() ;
1235
- $data[ 'optm_summary' ] = $this->summary_info() ;
1236
-
1237
- $data[ '_wp_attached_file' ] = get_post_meta( $pid, '_wp_attached_file', true ) ;
1238
- $data[ '_wp_attachment_metadata' ] = get_post_meta( $pid, '_wp_attachment_metadata', true ) ;
1239
-
1240
- // Get img_optm data
1241
- $q = "SELECT * FROM $this->_table_img_optm WHERE post_id = %d" ;
1242
- $list = $wpdb->get_results( $wpdb->prepare( $q, $pid ) ) ;
1243
- $img_data = array() ;
1244
- if ( $list ) {
1245
- foreach ( $list as $v ) {
1246
- $img_data[] = array(
1247
- 'id' => $v->id,
1248
- 'optm_status' => $v->optm_status,
1249
- 'src' => $v->src,
1250
- 'srcpath_md5' => $v->srcpath_md5,
1251
- 'src_md5' => $v->src_md5,
1252
- 'server_info' => $v->server_info,
1253
- ) ;
1254
- }
1255
- }
1256
- $data[ 'img_data' ] = $img_data ;
1257
-
1258
- echo json_encode( $data ) ;
1259
- exit;
1260
- }
1261
-
1262
- /**
1263
- * Parse wp's meta value
1264
- *
1265
- * @since 1.6.7
1266
- * @access private
1267
- */
1268
- private function _parse_wp_meta_value( $v )
1269
- {
1270
- if ( ! $v->meta_value ) {
1271
- LiteSpeed_Cache_Log::debug( '[Img_Optm] bypassed parsing meta due to no meta_value: pid ' . $v->post_id ) ;
1272
- return false ;
1273
- }
1274
-
1275
- $meta_value = @maybe_unserialize( $v->meta_value ) ;
1276
- if ( ! is_array( $meta_value ) ) {
1277
- LiteSpeed_Cache_Log::debug( '[Img_Optm] bypassed parsing meta due to meta_value not json: pid ' . $v->post_id ) ;
1278
- return false ;
1279
- }
1280
-
1281
- if ( empty( $meta_value[ 'file' ] ) ) {
1282
- LiteSpeed_Cache_Log::debug( '[Img_Optm] bypassed parsing meta due to no ori file: pid ' . $v->post_id ) ;
1283
- return false ;
1284
- }
1285
-
1286
- return $meta_value ;
1287
- }
1288
-
1289
- /**
1290
- * Clean up unfinished data for CLI usage
1291
- *
1292
- * @since 2.4.4
1293
- * @access public
1294
- */
1295
- public function destroy_unfinished()
1296
- {
1297
- $res = $this->_img_optimize_destroy_unfinished() ;
1298
-
1299
- return $res ;
1300
- }
1301
-
1302
- /**
1303
- * Destroy all unfinished queue locally and to LiteSpeed IAPI server
1304
- *
1305
- * @since 2.1.2
1306
- * @access private
1307
- */
1308
- private function _img_optimize_destroy_unfinished()
1309
- {
1310
- global $wpdb ;
1311
-
1312
- LiteSpeed_Cache_Log::debug( '[Img_Optm] sending DESTROY_UNFINISHED cmd to LiteSpeed IAPI' ) ;
1313
-
1314
- // Push to LiteSpeed IAPI server and recover credit
1315
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_REQUEST_DESTROY_UNFINISHED, false, true ) ;
1316
-
1317
- // confirm link will be displayed by Admin_API automatically
1318
- if ( is_array( $json ) ) {
1319
- LiteSpeed_Cache_Log::debug( '[Img_Optm] cmd result', $json ) ;
1320
- }
1321
-
1322
- // If failed to run request to IAPI
1323
- if ( ! is_array( $json ) || empty( $json[ 'success' ] ) ) {
1324
-
1325
- // For other errors that Admin_API didn't take
1326
- if ( ! is_array( $json ) ) {
1327
- LiteSpeed_Cache_Admin_Display::error( $json ) ;
1328
-
1329
- LiteSpeed_Cache_Log::debug( '[Img_Optm] err ', $json ) ;
1330
-
1331
- return $json ;
1332
- }
1333
-
1334
- return ;
1335
- }
1336
-
1337
- // Clear local queue
1338
- $_status_to_clear = array(
1339
- self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED,
1340
- self::DB_IMG_OPTIMIZE_STATUS_REQUESTED,
1341
- self::DB_IMG_OPTIMIZE_STATUS_ERR_FETCH,
1342
- ) ;
1343
- $q = "DELETE FROM $this->_table_img_optm WHERE optm_status IN ( " . implode( ',', array_fill( 0, count( $_status_to_clear ), '%s' ) ) . " )" ;
1344
- $wpdb->query( $wpdb->prepare( $q, $_status_to_clear ) ) ;
1345
-
1346
- // Recover credit
1347
- $this->_sync_data( true ) ;
1348
-
1349
- $msg = __( 'Destroy unfinished data successfully.', 'litespeed-cache' ) ;
1350
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1351
-
1352
- return $msg ;
1353
-
1354
- }
1355
-
1356
- /**
1357
- * Send destroy all requests cmd to LiteSpeed IAPI server and get the link to finish it ( avoid click by mistake )
1358
- *
1359
- * @since 1.6.7
1360
- * @access private
1361
- */
1362
- private function _img_optimize_destroy()
1363
- {
1364
- LiteSpeed_Cache_Log::debug( '[Img_Optm] sending DESTROY cmd to LiteSpeed IAPI' ) ;
1365
-
1366
- // Mark request time to avoid duplicated request
1367
- update_option( self::DB_IMG_OPTIMIZE_DESTROY, time() ) ;
1368
-
1369
- // Push to LiteSpeed IAPI server
1370
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_REQUEST_DESTROY, false, true ) ;
1371
-
1372
- // confirm link will be displayed by Admin_API automatically
1373
- if ( is_array( $json ) && $json ) {
1374
- LiteSpeed_Cache_Log::debug( '[Img_Optm] cmd result', $json ) ;
1375
- }
1376
-
1377
- }
1378
-
1379
- /**
1380
- * Callback from LiteSpeed IAPI server to destroy all optm data
1381
- *
1382
- * @since 1.6.7
1383
- * @access private
1384
- */
1385
- public function img_optimize_destroy_callback()
1386
- {
1387
- global $wpdb ;
1388
- LiteSpeed_Cache_Log::debug( '[Img_Optm] excuting DESTROY process' ) ;
1389
-
1390
- $request_time = get_option( self::DB_IMG_OPTIMIZE_DESTROY ) ;
1391
- if ( time() - $request_time > 300 ) {
1392
- LiteSpeed_Cache_Log::debug( '[Img_Optm] terminate DESTROY process due to timeout' ) ;
1393
- exit( 'Destroy callback timeout ( 300 seconds )[' . time() . " - $request_time]" ) ;
1394
- }
1395
-
1396
- /**
1397
- * Limit to 3000 images each time before redirection to fix Out of memory issue. #665465
1398
- * @since 2.9.8
1399
- */
1400
- // Start deleting files
1401
- $limit = apply_filters( 'litespeed_imgoptm_destroy_max_rows', 3000 ) ;
1402
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE optm_status = %s ORDER BY id LIMIT %d" ;
1403
- $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED, $limit ) ) ;
1404
- foreach ( $list as $v ) {
1405
- // del webp
1406
- $this->__media->info( $v->src . '.webp', $v->post_id ) && $this->__media->del( $v->src . '.webp', $v->post_id ) ;
1407
- $this->__media->info( $v->src . '.optm.webp', $v->post_id ) && $this->__media->del( $v->src . '.optm.webp', $v->post_id ) ;
1408
-
1409
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
1410
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
1411
- $bk_file = $local_filename . '.bk.' . $extension ;
1412
- $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1413
-
1414
- // del optimized ori
1415
- if ( $this->__media->info( $bk_file, $v->post_id ) ) {
1416
- $this->__media->del( $v->src, $v->post_id ) ;
1417
- $this->__media->rename( $bk_file, $v->src, $v->post_id ) ;
1418
- }
1419
- $this->__media->info( $bk_optm_file, $v->post_id ) && $this->__media->del( $bk_optm_file, $v->post_id ) ;
1420
- }
1421
-
1422
- // Check if there are more images, then return `to_be_continued` code
1423
- $q = "SELECT COUNT(*) FROM $this->_table_img_optm WHERE optm_status = %s" ;
1424
- $total_img = $wpdb->get_var( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1425
- if ( $total_img > $limit ) {
1426
- $q = "DELETE FROM $this->_table_img_optm WHERE optm_status = %s ORDER BY id LIMIT %d" ;
1427
- $wpdb->query( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED, $limit ) ) ;
1428
-
1429
- // Return continue signal
1430
- update_option( self::DB_IMG_OPTIMIZE_DESTROY, time() ) ;
1431
-
1432
- LiteSpeed_Cache_Log::debug( '[Img_Optm] To be continued 🚦' ) ;
1433
-
1434
- exit( 'to_be_continued' ) ;
1435
- }
1436
-
1437
- // Delete optm info
1438
- $q = "DELETE FROM $wpdb->postmeta WHERE meta_key LIKE 'litespeed-optimize%'" ;
1439
- $wpdb->query( $q ) ;
1440
-
1441
- // Delete img_optm table
1442
- LiteSpeed_Cache_Data::get_instance()->delete_tb_img_optm() ;
1443
-
1444
- // Clear credit info
1445
- delete_option( self::DB_IMG_OPTM_SUMMARY ) ;
1446
- delete_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL ) ;
1447
-
1448
- exit( 'ok' ) ;
1449
- }
1450
-
1451
- /**
1452
- * Resend requested img to LiteSpeed IAPI server
1453
- *
1454
- * @since 1.6.7
1455
- * @access private
1456
- */
1457
- private function _img_optimize_rescan()
1458
- {return;
1459
- LiteSpeed_Cache_Log::debug( '[Img_Optm] resend requested images' ) ;
1460
-
1461
- $_credit = (int) $this->summary_info( 'credit' ) ;
1462
-
1463
- global $wpdb ;
1464
-
1465
- $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
1466
- FROM $wpdb->postmeta a
1467
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.post_id
1468
- LEFT JOIN $wpdb->postmeta c ON c.post_id = a.post_id
1469
- WHERE a.meta_key = '_wp_attachment_metadata'
1470
- AND b.meta_key = %s
1471
- AND c.meta_key = %s
1472
- LIMIT %d
1473
- " ;
1474
- $limit_rows = apply_filters( 'litespeed_img_optm_resend_rows', 300 ) ;
1475
- $list = $wpdb->get_results( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS, self::DB_IMG_OPTIMIZE_DATA, $limit_rows ) ) ) ;
1476
- if ( ! $list ) {
1477
- LiteSpeed_Cache_Log::debug( '[Img_Optm] resend request bypassed: no image found' ) ;
1478
- $msg = __( 'No image found.', 'litespeed-cache' ) ;
1479
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
1480
- return ;
1481
- }
1482
-
1483
- // meta list
1484
- $optm_data_list = array() ;
1485
- $optm_data_pid2mid_list = array() ;
1486
-
1487
- foreach ( $list as $v ) {
1488
- // wp meta
1489
- $meta_value = $this->_parse_wp_meta_value( $v ) ;
1490
- if ( ! $meta_value ) {
1491
- continue ;
1492
- }
1493
- if ( empty( $meta_value[ 'sizes' ] ) ) {
1494
- continue ;
1495
- }
1496
-
1497
- $optm_data_pid2mid_list[ $v->post_id ] = array( 'status_mid' => $v->bmeta_id, 'data_mid' => $v->cmeta_id ) ;
1498
-
1499
- // prepare for pushing
1500
- $this->tmp_pid = $v->post_id ;
1501
- $this->tmp_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/' ;
1502
-
1503
- // ls optimized meta
1504
- $optm_meta = $optm_data_list[ $v->post_id ] = maybe_unserialize( $v->cmeta_value ) ;
1505
- $optm_list = array() ;
1506
- foreach ( $optm_meta as $md5 => $optm_row ) {
1507
- $optm_list[] = $optm_row[ 0 ] ;
1508
- // only do for requested/notified img
1509
- // if ( ! in_array( $optm_row[ 1 ], array( self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ) ) {
1510
- // continue ;
1511
- // }
1512
- }
1513
-
1514
- // check if there is new files from wp meta
1515
- $img_queue = array() ;
1516
- foreach ( $meta_value[ 'sizes' ] as $v2 ) {
1517
- $curr_file = $this->tmp_path . $v2[ 'file' ] ;
1518
-
1519
- // new child file OR not finished yet
1520
- if ( ! in_array( $curr_file, $optm_list ) ) {
1521
- $img_queue[] = $v2 ;
1522
- }
1523
- }
1524
-
1525
- // nothing to add
1526
- if ( ! $img_queue ) {
1527
- continue ;
1528
- }
1529
-
1530
- $num_will_incease = count( $img_queue ) ;
1531
- if ( $this->_img_total + $num_will_incease > $_credit ) {
1532
- LiteSpeed_Cache_Log::debug( '[Img_Optm] resend img request hit limit: [total] ' . $this->_img_total . " \t[add] $num_will_incease \t[credit] $_credit" ) ;
1533
- break ;
1534
- }
1535
-
1536
- foreach ( $img_queue as $v2 ) {
1537
- $this->_img_queue( $v2 ) ;
1538
- }
1539
- }
1540
-
1541
- // push to LiteSpeed IAPI server
1542
- if ( empty( $this->_img_in_queue ) ) {
1543
- $msg = __( 'No image found.', 'litespeed-cache' ) ;
1544
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1545
- return ;
1546
- }
1547
-
1548
- $total_groups = count( $this->_img_in_queue ) ;
1549
- LiteSpeed_Cache_Log::debug( '[Img_Optm] prepared images to push: groups ' . $total_groups . ' images ' . $this->_img_total ) ;
1550
-
1551
- // Push to LiteSpeed IAPI server
1552
- $json = $this->_push_img_in_queue_to_iapi() ;
1553
- if ( ! is_array( $json ) ) {
1554
- return $json ;
1555
- }
1556
- // Returned data is the requested and notifed images
1557
- $pids = $json[ 'pids' ] ;
1558
-
1559
- $q = "UPDATE $wpdb->postmeta SET meta_value = %s WHERE meta_id = %d" ;
1560
-
1561
- // Update data
1562
- foreach ( $pids as $pid ) {
1563
- $md52src_list = $optm_data_list[ $pid ] ;
1564
-
1565
- foreach ( $this->_img_in_queue[ $pid ] as $md5 => $src_data ) {
1566
- $md52src_list[ $md5 ] = array( $src_data[ 'src' ], self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
1567
- }
1568
-
1569
- $new_status = $this->_get_status_by_meta_data( $md52src_list, self::DB_IMG_OPTIMIZE_STATUS_REQUESTED ) ;
1570
-
1571
- $md52src_list = serialize( $md52src_list ) ;
1572
-
1573
- // Store data
1574
- $wpdb->query( $wpdb->prepare( $q, array( $new_status, $optm_data_pid2mid_list[ $pid ][ 'status_mid' ] ) ) ) ;
1575
- $wpdb->query( $wpdb->prepare( $q, array( $md52src_list, $optm_data_pid2mid_list[ $pid ][ 'data_mid' ] ) ) ) ;
1576
- }
1577
-
1578
- $accepted_groups = count( $pids ) ;
1579
- $accepted_imgs = $json[ 'total' ] ;
1580
-
1581
- $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 ) ;
1582
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1583
-
1584
- // Update credit info
1585
- if ( isset( $json[ 'credit' ] ) ) {
1586
- $this->_update_credit( $json[ 'credit' ] ) ;
1587
- }
1588
-
1589
- }
1590
-
1591
- /**
1592
- * Try to level up
1593
- *
1594
- * @since 2.4.1
1595
- * @access private
1596
- */
1597
- private function _try_level_up()
1598
- {
1599
- $optm_summary = $this->summary_info() ;
1600
- if ( empty( $optm_summary[ 'level' ] ) || empty( $optm_summary[ 'credit_recovered' ] ) || empty( $optm_summary[ '_level_data' ] ) ) {
1601
- return ;
1602
- }
1603
-
1604
- // level beyond 5 should be triggered manually
1605
- if ( $optm_summary[ 'level' ] >= 5 ) {
1606
- return ;
1607
- }
1608
-
1609
- $next_level = $optm_summary[ 'level' ] + 1 ;
1610
- $next_level_data = $optm_summary[ '_level_data' ][ $next_level ] ;
1611
-
1612
- if ( $optm_summary[ 'credit_recovered' ] <= $next_level_data[ 0 ] ) {
1613
- return ;
1614
- }
1615
-
1616
- // Now do level up magic
1617
- // Bless we can get more reviews to encourage me ~
1618
- $json = $this->_sync_data( true ) ;
1619
- if ( $json[ 'level' ] > $optm_summary[ 'level' ] ) {
1620
- $msg = "Upgraded to level $json[level] !" ;
1621
- LiteSpeed_Cache_Log::debug( "[Img_Optm] $msg" ) ;
1622
- return $msg ;
1623
- }
1624
- else {
1625
- LiteSpeed_Cache_Log::debug( "[Img_Optm] Upgrade failed [old level data] " . var_export( $optm_summary, true ), $json ) ;
1626
- }
1627
- }
1628
-
1629
- /**
1630
- * Update client credit info
1631
- *
1632
- * @since 1.6.5
1633
- * @access private
1634
- */
1635
- private function _update_credit( $credit )
1636
- {
1637
- $summary = get_option( self::DB_IMG_OPTM_SUMMARY, array() ) ;
1638
-
1639
- if ( empty( $summary[ 'credit' ] ) ) {
1640
- $summary[ 'credit' ] = 0 ;
1641
- }
1642
-
1643
- if ( $credit === '++' ) {
1644
- $credit = $summary[ 'credit' ] + 1 ;
1645
- }
1646
-
1647
- $old = $summary[ 'credit' ] ?: '-' ;
1648
- LiteSpeed_Cache_Log::debug( "[Img_Optm] Credit updated \t\t[Old] $old \t\t[New] $credit" ) ;
1649
-
1650
- // Mark credit recovered
1651
- if ( $credit > $summary[ 'credit' ] ) {
1652
- if ( empty( $summary[ 'credit_recovered' ] ) ) {
1653
- $summary[ 'credit_recovered' ] = 0 ;
1654
- }
1655
- $summary[ 'credit_recovered' ] += $credit - $summary[ 'credit' ] ;
1656
- }
1657
-
1658
- $summary[ 'credit' ] = $credit ;
1659
-
1660
- update_option( self::DB_IMG_OPTM_SUMMARY, $summary ) ;
1661
- }
1662
-
1663
- /**
1664
- * Calculate bkup original images storage
1665
- *
1666
- * @since 2.2.6
1667
- * @access private
1668
- */
1669
- private function _calc_bkup()
1670
- {
1671
- global $wpdb ;
1672
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE optm_status = %s" ;
1673
- $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1674
-
1675
- $i = 0 ;
1676
- $total_size = 0 ;
1677
- foreach ( $list as $v ) {
1678
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
1679
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
1680
- $bk_file = $local_filename . '.bk.' . $extension ;
1681
-
1682
- $img_info = $this->__media->info( $bk_file, $v->post_id ) ;
1683
- if ( ! $img_info ) {
1684
- continue ;
1685
- }
1686
-
1687
- $i ++ ;
1688
- $total_size += $img_info[ 'size' ] ;
1689
-
1690
- }
1691
-
1692
- $data = array(
1693
- 'date' => time(),
1694
- 'count' => $i,
1695
- 'sum' => $total_size,
1696
- ) ;
1697
- update_option( self::DB_IMG_OPTM_BK_SUMMARY, $data ) ;
1698
-
1699
- LiteSpeed_Cache_Log::debug( '[Img_Optm] _calc_bkup total: ' . $i . ' [size] ' . $total_size ) ;
1700
-
1701
- }
1702
-
1703
- /**
1704
- * Remove backups for CLI usage
1705
- *
1706
- * @since 2.5
1707
- * @access public
1708
- */
1709
- public function rm_bkup()
1710
- {
1711
- return $this->_rm_bkup() ;
1712
- }
1713
-
1714
- /**
1715
- * Delete bkup original images storage
1716
- *
1717
- * @since 2.2.6
1718
- * @access private
1719
- */
1720
- private function _rm_bkup()
1721
- {
1722
- global $wpdb ;
1723
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE optm_status = %s" ;
1724
- $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1725
-
1726
- $i = 0 ;
1727
- $total_size = 0 ;
1728
- foreach ( $list as $v ) {
1729
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
1730
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
1731
- $bk_file = $local_filename . '.bk.' . $extension ;
1732
-
1733
- // Del ori file
1734
- $img_info = $this->__media->info( $bk_file, $v->post_id ) ;
1735
- if ( ! $img_info ) {
1736
- continue ;
1737
- }
1738
-
1739
- $i ++ ;
1740
- $total_size += $img_info[ 'size' ] ;
1741
-
1742
- $this->__media->del( $bk_file, $v->post_id ) ;
1743
- }
1744
-
1745
- $data = array(
1746
- 'date' => time(),
1747
- 'count' => $i,
1748
- 'sum' => $total_size,
1749
- ) ;
1750
- update_option( self::DB_IMG_OPTM_RMBK_SUMMARY, $data ) ;
1751
-
1752
- LiteSpeed_Cache_Log::debug( '[Img_Optm] _rm_bkup total: ' . $i . ' [size] ' . $total_size ) ;
1753
-
1754
- $msg = sprintf( __( 'Removed %1$s images and saved %2$s successfully.', 'litespeed-cache' ), $i, LiteSpeed_Cache_Utility::real_size( $total_size ) ) ;
1755
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
1756
-
1757
- return $msg ;
1758
- }
1759
-
1760
- /**
1761
- * Get optm summary
1762
- *
1763
- * @since 1.6.5
1764
- * @access public
1765
- */
1766
- public function summary_info( $field = false )
1767
- {
1768
- $optm_summary = get_option( self::DB_IMG_OPTM_SUMMARY, array() ) ;
1769
-
1770
- if ( ! $field ) {
1771
- return $optm_summary ;
1772
- }
1773
- return ! empty( $optm_summary[ $field ] ) ? $optm_summary[ $field ] : 0 ;
1774
- }
1775
-
1776
- /**
1777
- * Get optm bkup usage summary
1778
- *
1779
- * @since 2.2.6
1780
- * @access public
1781
- */
1782
- public function storage_data()
1783
- {
1784
- $summary = get_option( self::DB_IMG_OPTM_BK_SUMMARY, array() ) ;
1785
- $rm_log = get_option( self::DB_IMG_OPTM_RMBK_SUMMARY, array() ) ;
1786
-
1787
- return array( $summary, $rm_log ) ;
1788
- }
1789
-
1790
- /**
1791
- * Count images
1792
- *
1793
- * @since 1.6
1794
- * @access public
1795
- */
1796
- public function img_count()
1797
- {
1798
- global $wpdb ;
1799
- $q = "SELECT count(*)
1800
- FROM $wpdb->posts a
1801
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1802
- WHERE a.post_type = 'attachment'
1803
- AND a.post_status = 'inherit'
1804
- AND a.post_mime_type IN ('image/jpeg', 'image/png')
1805
- AND b.meta_key = '_wp_attachment_metadata'
1806
- " ;
1807
- // $q = "SELECT count(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status = 'inherit' AND post_mime_type IN ('image/jpeg', 'image/png') " ;
1808
- $total_img = $wpdb->get_var( $q ) ;
1809
-
1810
- $q = "SELECT count(*)
1811
- FROM $wpdb->posts a
1812
- LEFT JOIN $wpdb->postmeta b ON b.post_id = a.ID
1813
- LEFT JOIN $this->_table_img_optm c ON c.post_id = a.ID
1814
- WHERE a.post_type = 'attachment'
1815
- AND a.post_status = 'inherit'
1816
- AND a.post_mime_type IN ('image/jpeg', 'image/png')
1817
- AND b.meta_key = '_wp_attachment_metadata'
1818
- AND c.id IS NULL
1819
- " ;
1820
- $total_not_requested = $wpdb->get_var( $q ) ;
1821
-
1822
- // images count from img_optm table
1823
- $q_groups = "SELECT count(distinct post_id) FROM $this->_table_img_optm WHERE optm_status = %s" ;
1824
- $q = "SELECT count(*) FROM $this->_table_img_optm WHERE optm_status = %s" ;
1825
-
1826
- // The groups to check
1827
- $images_to_check = $groups_to_check = array(
1828
- self::DB_IMG_OPTIMIZE_STATUS_REQUESTED,
1829
- self::DB_IMG_OPTIMIZE_STATUS_NOTIFIED,
1830
- self::DB_IMG_OPTIMIZE_STATUS_PULLED,
1831
- self::DB_IMG_OPTIMIZE_STATUS_ERR,
1832
- self::DB_IMG_OPTIMIZE_STATUS_ERR_FETCH,
1833
- self::DB_IMG_OPTIMIZE_STATUS_ERR_OPTM,
1834
- self::DB_IMG_OPTIMIZE_STATUS_MISS,
1835
- ) ;
1836
-
1837
- // The images to check
1838
- $images_to_check[] = self::DB_IMG_OPTIMIZE_STATUS_XMETA ;
1839
-
1840
- $count_list = array() ;
1841
-
1842
- foreach ( $groups_to_check as $v ) {
1843
- $count_list[ 'group.' . $v ] = $wpdb->get_var( $wpdb->prepare( $q_groups, $v ) ) ;
1844
- }
1845
-
1846
- foreach ( $images_to_check as $v ) {
1847
- $count_list[ 'img.' . $v ] = $wpdb->get_var( $wpdb->prepare( $q, $v ) ) ;
1848
- }
1849
-
1850
- $data = array(
1851
- 'total_img' => $total_img,
1852
- 'total_not_requested' => $total_not_requested,
1853
- ) ;
1854
-
1855
- return array_merge( $data, $count_list ) ;
1856
- }
1857
-
1858
- /**
1859
- * Check if fetch cron is running
1860
- *
1861
- * @since 1.6.2
1862
- * @access public
1863
- */
1864
- public function cron_running( $bool_res = true )
1865
- {
1866
- $last_run = get_option( self::ITEM_IMG_OPTM_CRON_RUN ) ;
1867
-
1868
- $is_running = $last_run && time() - $last_run < 120 ;
1869
-
1870
- if ( $bool_res ) {
1871
- return $is_running ;
1872
- }
1873
-
1874
- return array( $last_run, $is_running ) ;
1875
- }
1876
-
1877
- /**
1878
- * Update fetch cron timestamp tag
1879
- *
1880
- * @since 1.6.2
1881
- * @access private
1882
- */
1883
- private function _update_cron_running( $done = false )
1884
- {
1885
- $ts = time() ;
1886
-
1887
- if ( $done ) {
1888
- // Only update cron tag when its from the active running cron
1889
- if ( $this->_cron_ran ) {
1890
- // Rollback for next running
1891
- $ts -= 120 ;
1892
- }
1893
- else {
1894
- return ;
1895
- }
1896
- }
1897
-
1898
- update_option( self::ITEM_IMG_OPTM_CRON_RUN, $ts ) ;
1899
-
1900
- $this->_cron_ran = true ;
1901
- }
1902
-
1903
- /**
1904
- * Batch switch images to ori/optm version
1905
- *
1906
- * @since 1.6.2
1907
- * @access private
1908
- */
1909
- private function _batch_switch( $type )
1910
- {
1911
- global $wpdb ;
1912
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE optm_status = %s" ;
1913
- $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1914
-
1915
- $i = 0 ;
1916
- foreach ( $list as $v ) {
1917
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
1918
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
1919
- $bk_file = $local_filename . '.bk.' . $extension ;
1920
- $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1921
-
1922
- // switch to ori
1923
- if ( $type === self::TYPE_IMG_BATCH_SWITCH_ORI ) {
1924
- if ( ! $this->__media->info( $bk_file, $v->post_id ) ) {
1925
- continue ;
1926
- }
1927
-
1928
- $i ++ ;
1929
-
1930
- $this->__media->rename( $v->src, $bk_optm_file, $v->post_id ) ;
1931
- $this->__media->rename( $bk_file, $v->src, $v->post_id ) ;
1932
- }
1933
- // switch to optm
1934
- elseif ( $type === self::TYPE_IMG_BATCH_SWITCH_OPTM ) {
1935
- if ( ! $this->__media->info( $bk_optm_file, $v->post_id ) ) {
1936
- continue ;
1937
- }
1938
-
1939
- $i ++ ;
1940
-
1941
- $this->__media->rename( $v->src, $bk_file, $v->post_id ) ;
1942
- $this->__media->rename( $bk_optm_file, $v->src, $v->post_id ) ;
1943
- }
1944
- }
1945
-
1946
- LiteSpeed_Cache_Log::debug( '[Img_Optm] batch switched images total: ' . $i ) ;
1947
- $msg = __( 'Switched images successfully.', 'litespeed-cache' ) ;
1948
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
1949
-
1950
- }
1951
-
1952
- /**
1953
- * Switch image between original one and optimized one
1954
- *
1955
- * @since 1.6.2
1956
- * @access private
1957
- */
1958
- private function _switch_optm_file( $type )
1959
- {
1960
- $pid = substr( $type, 4 ) ;
1961
- $switch_type = substr( $type, 0, 4 ) ;
1962
-
1963
- global $wpdb ;
1964
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE optm_status = %s AND post_id = %d" ;
1965
- $list = $wpdb->get_results( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $pid ) ) ) ;
1966
-
1967
- $msg = 'Unknown Msg' ;
1968
-
1969
- foreach ( $list as $v ) {
1970
- // to switch webp file
1971
- if ( $switch_type === 'webp' ) {
1972
- if ( $this->__media->info( $v->src . '.webp', $v->post_id ) ) {
1973
- $this->__media->rename( $v->src . '.webp', $v->src . '.optm.webp', $v->post_id ) ;
1974
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Disabled WebP: ' . $v->src ) ;
1975
-
1976
- $msg = __( 'Disabled WebP file successfully.', 'litespeed-cache' ) ;
1977
- }
1978
- elseif ( $this->__media->info( $v->src . '.optm.webp', $v->post_id ) ) {
1979
- $this->__media->rename( $v->src . '.optm.webp', $v->src . '.webp', $v->post_id ) ;
1980
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Enable WebP: ' . $v->src ) ;
1981
-
1982
- $msg = __( 'Enabled WebP file successfully.', 'litespeed-cache' ) ;
1983
- }
1984
- }
1985
- // to switch original file
1986
- else {
1987
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
1988
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
1989
- $bk_file = $local_filename . '.bk.' . $extension ;
1990
- $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1991
-
1992
- // revert ori back
1993
- if ( $this->__media->info( $bk_file, $v->post_id ) ) {
1994
- $this->__media->rename( $v->src, $bk_optm_file, $v->post_id ) ;
1995
- $this->__media->rename( $bk_file, $v->src, $v->post_id ) ;
1996
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Restore original img: ' . $bk_file ) ;
1997
-
1998
- $msg = __( 'Restored original file successfully.', 'litespeed-cache' ) ;
1999
- }
2000
- elseif ( $this->__media->info( $bk_optm_file, $v->post_id ) ) {
2001
- $this->__media->rename( $v->src, $bk_file, $v->post_id ) ;
2002
- $this->__media->rename( $bk_optm_file, $v->src, $v->post_id ) ;
2003
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Switch to optm img: ' . $v->src ) ;
2004
-
2005
- $msg = __( 'Switched to optimized file successfully.', 'litespeed-cache' ) ;
2006
- }
2007
-
2008
- }
2009
- }
2010
-
2011
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
2012
- }
2013
-
2014
- /**
2015
- * Delete one optm data and recover original file
2016
- *
2017
- * @since 2.4.2
2018
- * @access public
2019
- */
2020
- public function reset_row( $post_id )
2021
- {
2022
- if ( ! $post_id ) {
2023
- return ;
2024
- }
2025
-
2026
- $size_meta = get_post_meta( $post_id, self::DB_IMG_OPTIMIZE_SIZE, true ) ;
2027
-
2028
- if ( ! $size_meta ) {
2029
- return ;
2030
- }
2031
-
2032
- LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row [pid] ' . $post_id ) ;
2033
-
2034
- global $wpdb ;
2035
- $q = "SELECT src,post_id FROM $this->_table_img_optm WHERE post_id = %d" ;
2036
- $list = $wpdb->get_results( $wpdb->prepare( $q, array( $post_id ) ) ) ;
2037
-
2038
- foreach ( $list as $v ) {
2039
- $this->__media->info( $v->src . '.webp', $v->post_id ) && $this->__media->del( $v->src . '.webp', $v->post_id ) ;
2040
- $this->__media->info( $v->src . '.optm.webp', $v->post_id ) && $this->__media->del( $v->src . '.optm.webp', $v->post_id ) ;
2041
-
2042
- $extension = pathinfo( $v->src, PATHINFO_EXTENSION ) ;
2043
- $local_filename = substr( $v->src, 0, - strlen( $extension ) - 1 ) ;
2044
- $bk_file = $local_filename . '.bk.' . $extension ;
2045
- $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
2046
-
2047
- if ( $this->__media->info( $bk_file, $v->post_id ) ) {
2048
- LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row Revert ori file' . $bk_file ) ;
2049
- $this->__media->del( $v->src, $v->post_id ) ;
2050
- $this->__media->rename( $bk_file, $v->src, $v->post_id ) ;
2051
- }
2052
- elseif ( $this->__media->info( $bk_optm_file, $v->post_id ) ) {
2053
- LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row Del ori bk file' . $bk_optm_file ) ;
2054
- $this->__media->del( $bk_optm_file, $v->post_id ) ;
2055
- }
2056
- }
2057
-
2058
- $q = "DELETE FROM $this->_table_img_optm WHERE post_id = %d" ;
2059
- $wpdb->query( $wpdb->prepare( $q, $post_id ) ) ;
2060
-
2061
- delete_post_meta( $post_id, self::DB_IMG_OPTIMIZE_SIZE ) ;
2062
-
2063
- $msg = __( 'Reset the optimized data successfully.', 'litespeed-cache' ) ;
2064
-
2065
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
2066
- }
2067
-
2068
- /**
2069
- * Handle all request actions from main cls
2070
- *
2071
- * @since 2.0
2072
- * @access public
2073
- */
2074
- public static function handler()
2075
- {
2076
- $instance = self::get_instance() ;
2077
-
2078
- $type = LiteSpeed_Cache_Router::verify_type() ;
2079
-
2080
- switch ( $type ) {
2081
- case self::TYPE_RESET_ROW :
2082
- $instance->reset_row( ! empty( $_GET[ 'id' ] ) ? $_GET[ 'id' ] : false ) ;
2083
- break ;
2084
-
2085
- case self::TYPE_CALC_BKUP :
2086
- $instance->_calc_bkup() ;
2087
- break ;
2088
-
2089
- case self::TYPE_RM_BKUP :
2090
- $instance->_rm_bkup() ;
2091
- break ;
2092
-
2093
- case self::TYPE_SYNC_DATA :
2094
- $instance->_sync_data() ;
2095
- break ;
2096
-
2097
- case self::TYPE_IMG_OPTIMIZE :
2098
- $instance->_request_optm() ;
2099
- break ;
2100
-
2101
- case self::TYPE_IMG_OPTIMIZE_RESCAN :
2102
- $instance->_img_optimize_rescan() ;
2103
- break ;
2104
-
2105
- case self::TYPE_IMG_OPTM_DESTROY :
2106
- $instance->_img_optimize_destroy() ;
2107
- break ;
2108
-
2109
- case self::TYPE_IMG_OPTM_DESTROY_UNFINISHED :
2110
- $instance->_img_optimize_destroy_unfinished() ;
2111
- break ;
2112
-
2113
- case self::TYPE_IMG_PULL :
2114
- LiteSpeed_Cache_Log::debug( 'ImgOptm: Manually running Cron pull_optimized_img' ) ;
2115
- $result = $instance->_pull_optimized_img( true ) ;
2116
- // Manually running needs to roll back timestamp for next running
2117
- $instance->_update_cron_running( true ) ;
2118
-
2119
- // Check if need to self redirect
2120
- if ( is_array( $result ) && $result[ 'ok' ] === 'to_be_continued' ) {
2121
- $link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_IMG_PULL ) ;
2122
- // Add i to avoid browser too many redirected warning
2123
- $i = ! empty( $_GET[ 'i' ] ) ? $_GET[ 'i' ] : 0 ;
2124
- $i ++ ;
2125
- $url = html_entity_decode( $link ) . '&i=' . $i ;
2126
- exit( "<meta http-equiv='refresh' content='0;url=$url'>" ) ;
2127
- // LiteSpeed_Cache_Admin::redirect( $url ) ;
2128
- }
2129
- break ;
2130
-
2131
- /**
2132
- * Batch switch
2133
- * @since 1.6.3
2134
- */
2135
- case self::TYPE_IMG_BATCH_SWITCH_ORI :
2136
- case self::TYPE_IMG_BATCH_SWITCH_OPTM :
2137
- $instance->_batch_switch( $type ) ;
2138
- break ;
2139
-
2140
- case substr( $type, 0, 4 ) === 'webp' :
2141
- case substr( $type, 0, 4 ) === 'orig' :
2142
- $instance->_switch_optm_file( $type ) ;
2143
- break ;
2144
-
2145
- default:
2146
- break ;
2147
- }
2148
-
2149
- LiteSpeed_Cache_Admin::redirect() ;
2150
- }
2151
-
2152
- /**
2153
- * Get the current instance object.
2154
- *
2155
- * @since 2.0
2156
- * @access public
2157
- * @return Current class instance.
2158
- */
2159
- public static function get_instance()
2160
- {
2161
- if ( ! isset( self::$_instance ) ) {
2162
- self::$_instance = new self() ;
2163
- }
2164
-
2165
- return self::$_instance ;
2166
- }
2167
-
2168
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/import.class.php DELETED
@@ -1,291 +0,0 @@
1
- <?php
2
- /**
3
- * The import/export class.
4
- *
5
- * @since 1.8.2
6
- * @package LiteSpeed_Cache
7
- * @subpackage LiteSpeed_Cache/inc
8
- * @author LiteSpeed Technologies <info@litespeedtech.com>
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Import
16
- {
17
- private static $_instance ;
18
-
19
- private $_cfg_items ;
20
- private $__cfg ;
21
-
22
- const TYPE_IMPORT = 'import' ;
23
- const TYPE_EXPORT = 'export' ;
24
- const TYPE_RESET = 'reset' ;
25
-
26
- const DB_IMPORT_LOG = 'litespeed_import_log' ;
27
-
28
- /**
29
- * Init
30
- *
31
- * @since 1.8.2
32
- * @access private
33
- */
34
- private function __construct()
35
- {
36
- LiteSpeed_Cache_Log::debug( 'Import init' ) ;
37
-
38
- $this->__cfg = LiteSpeed_Cache_Config::get_instance() ;
39
-
40
- $this->_cfg_items = $this->__cfg->stored_items() ;
41
- }
42
-
43
- /**
44
- * Handle all request actions from main cls
45
- *
46
- * @since 1.8.2
47
- * @access public
48
- */
49
- public static function handler()
50
- {
51
- $instance = self::get_instance() ;
52
-
53
- $type = LiteSpeed_Cache_Router::verify_type() ;
54
-
55
- switch ( $type ) {
56
- case self::TYPE_IMPORT :
57
- $instance->_import() ;
58
- break ;
59
-
60
- case self::TYPE_EXPORT :
61
- $instance->_export() ;
62
- break ;
63
-
64
- case self::TYPE_RESET :
65
- $instance->_reset() ;
66
- break ;
67
-
68
- default:
69
- break ;
70
- }
71
-
72
- LiteSpeed_Cache_Admin::redirect() ;
73
- }
74
-
75
- /**
76
- * Export settings
77
- *
78
- * @since 2.4.1
79
- * @return string All settings data
80
- */
81
- public function export()
82
- {
83
- return $this->_export( true ) ;
84
- }
85
-
86
- /**
87
- * Export settings to file
88
- *
89
- * @since 1.8.2
90
- * @access private
91
- */
92
- private function _export( $only_data_return = false )
93
- {
94
-
95
- $data = array() ;
96
- foreach ( $this->_cfg_items as $v ) {
97
- $data[ $v ] = get_option( $v ) ;// Here doesn't need the default_item value so no need to call `LiteSpeed_Cache_Config::get_instance()->get_item()`
98
- }
99
-
100
- $data = base64_encode( json_encode( $data ) ) ;
101
-
102
- if ( $only_data_return ) {
103
- return $data ;
104
- }
105
-
106
- $filename = $this->_generate_filename() ;
107
-
108
- // Update log
109
- $log = get_option( self::DB_IMPORT_LOG, array() ) ;
110
- if ( empty( $log[ 'export' ] ) ) {
111
- $log[ 'export' ] = array() ;
112
- }
113
- $log[ 'export' ][ 'file' ] = $filename ;
114
- $log[ 'export' ][ 'time' ] = time() ;
115
-
116
- update_option( self::DB_IMPORT_LOG, $log ) ;
117
-
118
- LiteSpeed_Cache_Log::debug( 'Import: Saved to ' . $filename ) ;
119
-
120
- @header( 'Content-Disposition: attachment; filename=' . $filename ) ;
121
- echo $data ;
122
-
123
- exit ;
124
- }
125
-
126
- /**
127
- * Import settings
128
- *
129
- * @since 2.4.1
130
- */
131
- public function import( $file )
132
- {
133
- return $this->_import( $file ) ;
134
- }
135
-
136
- /**
137
- * Import settings from file
138
- *
139
- * @since 1.8.2
140
- * @access private
141
- */
142
- private function _import( $file = false )
143
- {
144
- if ( ! $file ) {
145
- if ( empty( $_FILES[ 'ls_file' ][ 'name' ] ) || substr( $_FILES[ 'ls_file' ][ 'name' ], -5 ) != '.data' || empty( $_FILES[ 'ls_file' ][ 'tmp_name' ] ) ) {
146
- LiteSpeed_Cache_Log::debug( 'Import: Failed to import, wront ls_file' ) ;
147
-
148
- $msg = __( 'Import failed due to file error.', 'litespeed-cache' ) ;
149
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
150
-
151
- return false ;
152
- }
153
-
154
- // Update log
155
- $log = get_option( self::DB_IMPORT_LOG, array() ) ;
156
- if ( empty( $log[ 'import' ] ) ) {
157
- $log[ 'import' ] = array() ;
158
- }
159
- $log[ 'import' ][ 'file' ] = $_FILES[ 'ls_file' ][ 'name' ] ;
160
- $log[ 'import' ][ 'time' ] = time() ;
161
-
162
- update_option( self::DB_IMPORT_LOG, $log ) ;
163
-
164
- $data = file_get_contents( $_FILES[ 'ls_file' ][ 'tmp_name' ] ) ;
165
- }
166
- else {
167
- $data = file_get_contents( $file ) ;
168
- }
169
-
170
- try {
171
- $data = json_decode( base64_decode( $data ), true ) ;
172
- } catch ( \Exception $ex ) {
173
- LiteSpeed_Cache_Log::debug( 'Import: Failed to parse serialized data' ) ;
174
- return false ;
175
- }
176
-
177
- if ( ! $data ) {
178
- LiteSpeed_Cache_Log::debug( 'Import: Failed to import, no data' ) ;
179
- return false ;
180
- }
181
-
182
- $options = $data[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
183
- foreach ( $this->_cfg_items as $v ) {
184
- $options[ $v ] = $data[ $v ] ;
185
- }
186
-
187
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
188
-
189
- global $wp_settings_errors ;
190
- if ( ! empty( $wp_settings_errors ) ) {
191
- foreach ( $wp_settings_errors as $err ) {
192
- LiteSpeed_Cache_Admin_Display::error( $err[ 'message' ] ) ;
193
- LiteSpeed_Cache_Log::debug( '[Import] err ' . $err[ 'message' ] ) ;
194
- }
195
- return false ;
196
- }
197
-
198
- if ( ! $file ) {
199
- LiteSpeed_Cache_Log::debug( 'Import: Imported ' . $_FILES[ 'ls_file' ][ 'name' ] ) ;
200
-
201
- $msg = sprintf( __( 'Imported setting file %s successfully.', 'litespeed-cache' ), $_FILES[ 'ls_file' ][ 'name' ] ) ;
202
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
203
- }
204
- else {
205
- LiteSpeed_Cache_Log::debug( 'Import: Imported ' . $file ) ;
206
- }
207
-
208
- $ret = $this->__cfg->update_options( $output ) ;
209
-
210
- return true ;
211
-
212
- }
213
-
214
- /**
215
- * Reset all settings
216
- *
217
- * @since 2.6.3
218
- */
219
- public function reset()
220
- {
221
- return $this->_reset() ;
222
- }
223
-
224
- /**
225
- * Reset all configs to default values.
226
- *
227
- * @since 2.6.3
228
- * @access private
229
- */
230
- private function _reset()
231
- {
232
- $options = $this->__cfg->get_default_options() ;
233
- // Get items
234
- foreach ( $this->_cfg_items as $v ) {
235
- $options[ $v ] = $this->__cfg->default_item( $v ) ;
236
- }
237
-
238
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
239
-
240
- $ret = $this->__cfg->update_options( $output ) ;
241
-
242
- LiteSpeed_Cache_Log::debug( '[Import] Reset successfully.' ) ;
243
-
244
- $msg = __( 'Reset successfully.', 'litespeed-cache' ) ;
245
- LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
246
-
247
- return true ;
248
- }
249
-
250
- /**
251
- * Generate the filename to export
252
- *
253
- * @since 1.8.2
254
- * @access private
255
- */
256
- private function _generate_filename()
257
- {
258
- // Generate filename
259
- $parsed_home = parse_url( get_home_url() ) ;
260
- $filename = 'LSCWP_cfg-' ;
261
- if ( ! empty( $parsed_home[ 'host' ] ) ) {
262
- $filename .= $parsed_home[ 'host' ] . '_' ;
263
- }
264
-
265
- if ( ! empty( $parsed_home[ 'path' ] ) ) {
266
- $filename .= $parsed_home[ 'path' ] . '_' ;
267
- }
268
-
269
- $filename = str_replace( '/', '_', $filename ) ;
270
-
271
- $filename .= '-' . date( 'Ymd_His' ) . '.data' ;
272
-
273
- return $filename ;
274
- }
275
-
276
- /**
277
- * Get the current instance object.
278
- *
279
- * @since 1.1.0
280
- * @access public
281
- * @return Current class instance.
282
- */
283
- public static function get_instance()
284
- {
285
- if ( ! isset( self::$_instance ) ) {
286
- self::$_instance = new self() ;
287
- }
288
-
289
- return self::$_instance ;
290
- }
291
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/litespeed-cache.class.php DELETED
@@ -1,774 +0,0 @@
1
- <?php
2
- /**
3
- * The core plugin class.
4
- *
5
- * This is used to define internationalization, admin-specific hooks, and
6
- * public-facing site hooks.
7
- *
8
- * Also maintains the unique identifier of this plugin as well as the current
9
- * version of the plugin.
10
- *
11
- * @since 1.0.0
12
- * @since 1.5 Moved into /inc
13
- * @package LiteSpeed_Cache
14
- * @subpackage LiteSpeed_Cache/inc
15
- * @author LiteSpeed Technologies <info@litespeedtech.com>
16
- */
17
-
18
- if ( ! defined( 'WPINC' ) ) {
19
- die ;
20
- }
21
-
22
- class LiteSpeed_Cache
23
- {
24
- private static $_instance ;
25
-
26
- const NAME = 'LiteSpeed Cache' ;
27
- const PLUGIN_NAME = 'litespeed-cache' ;
28
- const PLUGIN_FILE = 'litespeed-cache/litespeed-cache.php' ;
29
- const PLUGIN_VERSION = '2.9.9.2' ;
30
-
31
- const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
-
33
- const NONCE_NAME = 'LSCWP_NONCE' ;
34
- const ACTION_KEY = 'LSCWP_CTRL' ;
35
- const ACTION_DISMISS = 'dismiss' ;
36
- const ACTION_SAVE_HTACCESS = 'save-htaccess' ;
37
- const ACTION_SAVE_SETTINGS = 'save-settings' ;
38
- const ACTION_SAVE_SETTINGS_NETWORK = 'save-settings-network' ;
39
- const ACTION_PURGE_BY = 'PURGE_BY' ;
40
- const ACTION_PURGE_EMPTYCACHE = 'PURGE_EMPTYCACHE' ;
41
- const ACTION_QS_PURGE = 'PURGE' ;
42
- const ACTION_QS_PURGE_SINGLE = 'PURGESINGLE' ;
43
- const ACTION_QS_SHOW_HEADERS = 'SHOWHEADERS' ;
44
- const ACTION_QS_PURGE_ALL = 'purge_all' ;
45
- const ACTION_QS_PURGE_EMPTYCACHE = 'empty_all' ;
46
- const ACTION_QS_NOCACHE = 'NOCACHE' ;
47
- const ACTION_CRAWLER_GENERATE_FILE = 'crawler-generate-file' ;
48
- const ACTION_CRAWLER_RESET_POS = 'crawler-reset-pos' ;
49
- const ACTION_CRAWLER_CRON_ENABLE = 'crawler-cron-enable' ;
50
- const ACTION_DO_CRAWL = 'do-crawl' ;
51
- const ACTION_BLACKLIST_SAVE = 'blacklist-save' ;
52
- const ACTION_CDN_CLOUDFLARE = 'cdn_cloudflare' ;
53
- const ACTION_CDN_QUIC = 'cdn_quic' ;
54
- const ACTION_CFG = 'cfg' ;
55
- const ACTION_ACTIVATION = 'activate' ;
56
- const ACTION_UTIL = 'util' ;
57
-
58
- const ACTION_FRONT_EXCLUDE = 'front-exclude' ;
59
-
60
- const ACTION_DB_OPTIMIZE = 'db_optimize' ;
61
- const ACTION_LOG = 'log' ;
62
-
63
- const ACTION_IMPORT = 'import' ;
64
- const ACTION_PURGE = 'purge' ;
65
- const ACTION_MEDIA = 'media' ;
66
- const ACTION_IMG_OPTM = 'img_optm' ;
67
- const ACTION_IAPI = 'iapi' ;
68
- const ACTION_CDN = 'cdn' ;
69
- const ACTION_REPORT = 'report' ;
70
- const ACTION_CSS = 'css' ;
71
- const ACTION_SAPI_PASSIVE_CALLBACK = 'sapi_passive_callback' ;
72
- const ACTION_SAPI_AGGRESSIVE_CALLBACK = 'sapi_aggressive_callback' ;
73
-
74
- const WHM_MSG = 'lscwp_whm_install' ;
75
- const WHM_MSG_VAL = 'whm_install' ;
76
-
77
- const HEADER_DEBUG = 'X-LiteSpeed-Debug' ;
78
-
79
- protected static $_debug_show_header = false ;
80
-
81
- private $footer_comment = '' ;
82
-
83
- /**
84
- * Define the core functionality of the plugin.
85
- *
86
- * Set the plugin name and the plugin version that can be used throughout the plugin.
87
- * Load the dependencies, define the locale, and set the hooks for the admin area and
88
- * the public-facing side of the site.
89
- *
90
- * @since 1.0.0
91
- */
92
- private function __construct()
93
- {
94
- LiteSpeed_Cache_Config::get_instance() ;
95
-
96
- // Check if debug is on
97
- $should_debug = intval( self::config( LiteSpeed_Cache_Config::OPID_DEBUG ) ) ;
98
- if ( $should_debug == LiteSpeed_Cache_Config::VAL_ON || $should_debug == LiteSpeed_Cache_Config::VAL_ON2 ) {
99
- LiteSpeed_Cache_Log::init() ;
100
- }
101
-
102
- if ( defined( 'LITESPEED_ON' ) ) {
103
- // Load third party detection if lscache enabled.
104
- include_once LSCWP_DIR . 'thirdparty/lscwp-registry-3rd.php' ;
105
- }
106
-
107
- if ( self::config( LiteSpeed_Cache_Config::OPID_DEBUG_DISABLE_ALL ) ) {
108
- ! defined( 'LITESPEED_DISABLE_ALL' ) && define( 'LITESPEED_DISABLE_ALL', true ) ;
109
- }
110
-
111
- /**
112
- * Register plugin activate/deactivate/uninstall hooks
113
- * NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
114
- *
115
- * @since 2.7.1 Disabled admin&CLI check to make frontend able to enable cache too
116
- */
117
- // if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
118
- $plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
119
- register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
120
- register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
121
- register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
122
- // }
123
-
124
- add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
125
-
126
- // Check if there is a purge request in queue
127
- if ( $purge_queue = get_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ) {
128
- @header( $purge_queue ) ;
129
- LiteSpeed_Cache_Log::debug( '[Core] Purge Queue found&sent: ' . $purge_queue ) ;
130
- delete_option( LiteSpeed_Cache_Purge::PURGE_QUEUE ) ;
131
- }
132
-
133
- /**
134
- * Hook internal REST
135
- * @since 2.9.4
136
- */
137
- LiteSpeed_Cache_REST::get_instance() ;
138
-
139
- /**
140
- * Added hook before init
141
- * @since 1.6.6
142
- * @deprecated 2.9.7.2 This can't be used by any plugin due to unpredictable plugin loading priority.
143
- */
144
- do_action( 'litespeed_before_init' ) ;
145
-
146
- /**
147
- * Preload ESI functionality for ESI request uri recovery
148
- * @since 1.8.1
149
- */
150
- LiteSpeed_Cache_ESI::get_instance() ;
151
- }
152
-
153
- /**
154
- * The plugin initializer.
155
- *
156
- * 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.
157
- *
158
- * NOTE: WP user doesn't init yet
159
- *
160
- * @since 1.0.0
161
- * @access public
162
- */
163
- public function init()
164
- {
165
- /**
166
- * Added hook before init
167
- * @since 1.6.6
168
- * @since 2.6 Added filter to all config values in LiteSpeed_Cache_Config
169
- */
170
- do_action( 'litespeed_init' ) ;
171
-
172
- // in `after_setup_theme`, before `init` hook
173
- LiteSpeed_Cache_Activation::auto_update() ;
174
-
175
- if( is_admin() ) {
176
- LiteSpeed_Cache_Admin::get_instance() ;
177
- }
178
-
179
- // if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) ) {
180
- // return ;
181
- // }
182
-
183
- if ( defined( 'LITESPEED_DISABLE_ALL' ) ) {
184
- LiteSpeed_Cache_Log::debug( '[Core] Bypassed due to debug disable all setting' ) ;
185
- return ;
186
- }
187
-
188
- do_action( 'litespeed_initing' ) ;
189
-
190
- ob_start( array( $this, 'send_headers_force' ) ) ;
191
- add_action( 'shutdown', array( $this, 'send_headers' ), 0 ) ;
192
- add_action( 'wp_footer', 'LiteSpeed_Cache::footer_hook' ) ;
193
-
194
- /**
195
- * Check if is non optm simulator
196
- * @since 2.9
197
- */
198
- if ( ! empty( $_GET[ LiteSpeed_Cache::ACTION_KEY ] ) && $_GET[ LiteSpeed_Cache::ACTION_KEY ] == 'before_optm' ) {
199
- ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
200
- }
201
-
202
- /**
203
- * Register vary filter
204
- * @since 1.6.2
205
- */
206
- LiteSpeed_Cache_Control::get_instance() ;
207
-
208
- // 1. Init vary
209
- // 2. Init cacheable status
210
- LiteSpeed_Cache_Vary::get_instance() ;
211
-
212
- // Init Purge hooks
213
- LiteSpeed_Cache_Purge::get_instance() ;
214
-
215
- LiteSpeed_Cache_Tag::get_instance() ;
216
-
217
- // Load hooks that may be related to users
218
- add_action( 'init', array( $this, 'after_user_init' ) ) ;
219
-
220
- // Load 3rd party hooks
221
- add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
222
- }
223
-
224
- /**
225
- * Run hooks after user init
226
- *
227
- * @since 2.9.8
228
- * @access public
229
- */
230
- public function after_user_init()
231
- {
232
- LiteSpeed_Cache_Router::get_instance()->is_crawler_role_simulation() ;
233
-
234
- if ( ! is_admin() && $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
235
- LiteSpeed_Cache_Log::debug( '[Core] ⛑️ bypass_optm: hit Role Excludes setting: ' . $result ) ;
236
- ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
237
- }
238
-
239
- // Todo: Move to tool.cls in v3.0
240
- if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
241
- LiteSpeed_Cache_Log::disable_heartbeat() ;
242
- }
243
-
244
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
245
- /**
246
- * Check lazy lib request in the very beginning
247
- * @since 1.4
248
- * Note: this should be before optimizer to avoid lazyload lib catched wrongly
249
- */
250
- LiteSpeed_Cache_Media::get_instance() ;
251
-
252
- // Check minify file request in the very beginning
253
- LiteSpeed_Cache_Optimize::get_instance() ;
254
-
255
- // Hook cdn for attachements
256
- LiteSpeed_Cache_CDN::get_instance() ;
257
-
258
- // load cron tasks
259
- LiteSpeed_Cache_Task::get_instance() ;
260
- }
261
-
262
- // load litespeed actions
263
- if ( $action = LiteSpeed_Cache_Router::get_action() ) {
264
- $this->proceed_action( $action ) ;
265
- }
266
-
267
- // Load frontend GUI
268
- LiteSpeed_Cache_GUI::get_instance() ;
269
-
270
- }
271
-
272
- /**
273
- * Run frontend actions
274
- *
275
- * @since 1.1.0
276
- * @access public
277
- */
278
- public function proceed_action( $action )
279
- {
280
- $msg = false ;
281
- // handle actions
282
- switch ( $action ) {
283
- case LiteSpeed_Cache::ACTION_QS_PURGE:
284
- LiteSpeed_Cache_Purge::set_purge_related() ;
285
- break;
286
-
287
- case self::ACTION_QS_SHOW_HEADERS:
288
- self::$_debug_show_header = true ;
289
- break;
290
-
291
- case LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE:
292
- LiteSpeed_Cache_Purge::set_purge_single() ;
293
- break;
294
-
295
- case LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE:
296
- LiteSpeed_Cache_Crawler::get_instance()->generate_sitemap() ;
297
- LiteSpeed_Cache_Admin::redirect() ;
298
- break;
299
-
300
- case LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS:
301
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
302
- LiteSpeed_Cache_Admin::redirect() ;
303
- break;
304
-
305
- case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
306
- LiteSpeed_Cache_Task::enable() ;
307
- break;
308
-
309
- // Handle the ajax request to proceed crawler manually by admin
310
- case LiteSpeed_Cache::ACTION_DO_CRAWL:
311
- LiteSpeed_Cache_Crawler::crawl_data( true ) ;
312
- break ;
313
-
314
- case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
315
- LiteSpeed_Cache_Crawler::get_instance()->save_blacklist() ;
316
- $msg = __( 'Crawler blacklist is saved.', 'litespeed-cache' ) ;
317
- break ;
318
-
319
- case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
320
- LiteSpeed_Cache_Purge::purge_all() ;
321
- break;
322
-
323
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:
324
- case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
325
- define( 'LSWCP_EMPTYCACHE', true ) ;// clear all sites caches
326
- LiteSpeed_Cache_Purge::purge_all() ;
327
- $msg = __( 'Notified LiteSpeed Web Server to purge everything.', 'litespeed-cache' ) ;
328
- break;
329
-
330
- case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
331
- // redirect inside
332
- LiteSpeed_Cache_Config::frontend_save() ;
333
- break ;
334
-
335
- case LiteSpeed_Cache::ACTION_PURGE_BY:
336
- LiteSpeed_Cache_Purge::get_instance()->purge_list() ;
337
- $msg = __( 'Notified LiteSpeed Web Server to purge the list.', 'litespeed-cache' ) ;
338
- break;
339
-
340
- case LiteSpeed_Cache::ACTION_DISMISS:// Even its from ajax, we don't need to register wp ajax callback function but directly use our action
341
- LiteSpeed_Cache_GUI::dismiss() ;
342
- break ;
343
-
344
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
345
- $msg = LiteSpeed_Cache_Admin_Optimize::run_db_clean() ;
346
- break ;
347
-
348
- case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK:
349
- LiteSpeed_Cache_Admin_API::sapi_passive_callback() ;
350
- break ;
351
-
352
- case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK:
353
- LiteSpeed_Cache_Admin_API::sapi_aggressive_callback() ;
354
- break ;
355
-
356
- case LiteSpeed_Cache::ACTION_MEDIA:
357
- $msg = LiteSpeed_Cache_Media::handler() ;
358
- break ;
359
-
360
- case LiteSpeed_Cache::ACTION_IMG_OPTM:
361
- $msg = LiteSpeed_Cache_Img_Optm::handler() ;
362
- break ;
363
-
364
- case LiteSpeed_Cache::ACTION_PURGE:
365
- $msg = LiteSpeed_Cache_Purge::handler() ;
366
- break ;
367
-
368
- case LiteSpeed_Cache::ACTION_IAPI:
369
- $msg = LiteSpeed_Cache_Admin_API::handler() ;
370
- break ;
371
-
372
- case LiteSpeed_Cache::ACTION_LOG:
373
- $msg = LiteSpeed_Cache_Log::handler() ;
374
- break ;
375
-
376
- case LiteSpeed_Cache::ACTION_REPORT:
377
- $msg = LiteSpeed_Cache_Admin_Report::handler() ;
378
- break ;
379
-
380
- case LiteSpeed_Cache::ACTION_IMPORT:
381
- $msg = LiteSpeed_Cache_Import::handler() ;
382
- break ;
383
-
384
- case LiteSpeed_Cache::ACTION_CSS:
385
- $msg = LiteSpeed_Cache_CSS::handler() ;
386
- break ;
387
-
388
- case LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE:
389
- $msg = LiteSpeed_Cache_CDN_Cloudflare::handler() ;
390
- break ;
391
-
392
- case LiteSpeed_Cache::ACTION_CDN_QUIC:
393
- $msg = LiteSpeed_Cache_CDN_Quic::handler() ;
394
- break ;
395
-
396
- case LiteSpeed_Cache::ACTION_CFG :
397
- $msg = LiteSpeed_Cache_Config::handler() ;
398
- break ;
399
-
400
- case LiteSpeed_Cache::ACTION_ACTIVATION :
401
- $msg = LiteSpeed_Cache_Activation::handler() ;
402
- break ;
403
-
404
- case LiteSpeed_Cache::ACTION_UTIL :
405
- $msg = LiteSpeed_Cache_Utility::handler() ;
406
- break ;
407
-
408
- default:
409
- break ;
410
- }
411
- if ( $msg && ! LiteSpeed_Cache_Router::is_ajax() ) {
412
- LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, $msg ) ;
413
- LiteSpeed_Cache_Admin::redirect() ;
414
- return ;
415
- }
416
-
417
- if ( LiteSpeed_Cache_Router::is_ajax() ) {
418
- exit ;
419
- }
420
- }
421
-
422
- /**
423
- * Callback used to call the detect third party action.
424
- *
425
- * The detect action is used by third party plugin integration classes to determine if they should add the rest of their hooks.
426
- *
427
- * @since 1.0.5
428
- * @access public
429
- */
430
- public function load_thirdparty()
431
- {
432
- do_action( 'litespeed_cache_api_load_thirdparty' ) ;
433
- }
434
-
435
- /**
436
- * A shortcut to get the LiteSpeed_Cache_Config config value
437
- *
438
- * @since 1.0.0
439
- * @access public
440
- * @param string $opt_id An option ID if getting an option.
441
- * @return the option value
442
- */
443
- public static function config( $opt_id )
444
- {
445
- return LiteSpeed_Cache_Config::get_instance()->get_option( $opt_id ) ;
446
- }
447
-
448
- /**
449
- * Mark wp_footer called
450
- *
451
- * @since 1.3
452
- * @access public
453
- */
454
- public static function footer_hook()
455
- {
456
- LiteSpeed_Cache_Log::debug( '[Core] Footer hook called' ) ;
457
- if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
458
- define( 'LITESPEED_FOOTER_CALLED', true ) ;
459
- }
460
- }
461
-
462
- /**
463
- * Tigger coment info display hook
464
- *
465
- * @since 1.3
466
- * @access private
467
- */
468
- private function _check_is_html( $buffer = null )
469
- {
470
- if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
471
- LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: miss footer const' ) ;
472
- return ;
473
- }
474
-
475
- if ( defined( 'DOING_AJAX' ) ) {
476
- LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing ajax' ) ;
477
- return ;
478
- }
479
-
480
- if ( defined( 'DOING_CRON' ) ) {
481
- LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: doing cron' ) ;
482
- return ;
483
- }
484
-
485
- if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {
486
- LiteSpeed_Cache_Log::debug2( '[Core] CHK html bypass: not get method ' . $_SERVER[ 'REQUEST_METHOD' ] ) ;
487
- return ;
488
- }
489
-
490
- if ( $buffer === null ) {
491
- $buffer = ob_get_contents() ;
492
- }
493
-
494
- // double check to make sure it is a html file
495
- if ( strlen( $buffer ) > 300 ) {
496
- $buffer = substr( $buffer, 0, 300 ) ;
497
- }
498
- if ( strstr( $buffer, '<!--' ) !== false ) {
499
- $buffer = preg_replace( '|<!--.*?-->|s', '', $buffer ) ;
500
- }
501
- $buffer = trim( $buffer ) ;
502
-
503
- $buffer = Litespeed_File::remove_zero_space( $buffer ) ;
504
-
505
- $is_html = stripos( $buffer, '<html' ) === 0 || stripos( $buffer, '<!DOCTYPE' ) === 0 ;
506
-
507
- if ( ! $is_html ) {
508
- LiteSpeed_Cache_Log::debug( '[Core] Footer check failed: ' . ob_get_level() . '-' . substr( $buffer, 0, 100 ) ) ;
509
- return ;
510
- }
511
-
512
- LiteSpeed_Cache_Log::debug( '[Core] Footer check passed' ) ;
513
-
514
- if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
515
- define( 'LITESPEED_IS_HTML', true ) ;
516
- }
517
- }
518
-
519
- /**
520
- * For compatibility with those plugins have 'Bad' logic that forced all buffer output even it is NOT their buffer :(
521
- *
522
- * Usually this is called after send_headers() if following orignal WP process
523
- *
524
- * @since 1.1.5
525
- * @access public
526
- * @param string $buffer
527
- * @return string
528
- */
529
- public function send_headers_force( $buffer )
530
- {
531
- $this->_check_is_html( $buffer ) ;
532
-
533
- // Replace ESI preserved list
534
- $buffer = LiteSpeed_Cache_ESI::finalize( $buffer ) ;
535
-
536
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
537
- // Image lazy load check
538
- $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
539
- }
540
-
541
- /**
542
- * Clean wrapper mainly for esi block
543
- * NOTE: this needs to be before optimizer to avoid wrapper being removed
544
- * @since 1.4
545
- */
546
- $buffer = LiteSpeed_Cache_GUI::finalize( $buffer ) ;
547
-
548
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
549
- $buffer = LiteSpeed_Cache_Optimize::finalize( $buffer ) ;
550
-
551
- $buffer = LiteSpeed_Cache_CDN::finalize( $buffer ) ;
552
- }
553
-
554
- $this->send_headers( true ) ;
555
-
556
- if ( $this->footer_comment ) {
557
- $buffer .= $this->footer_comment ;
558
- }
559
-
560
- /**
561
- * If ESI req is JSON, give the content JSON format
562
- * @since 2.9.3
563
- * @since 2.9.4 ESI req could be from internal REST call, so moved json_encode out of this cond
564
- */
565
- if ( defined( 'LSCACHE_IS_ESI' ) ) {
566
- LiteSpeed_Cache_Log::debug( '[Core] ESI Start 👇' ) ;
567
- if ( strlen( $buffer ) > 100 ) {
568
- LiteSpeed_Cache_Log::debug( trim( substr( $buffer, 0, 100 ) ) . '.....' ) ;
569
- }
570
- else {
571
- LiteSpeed_Cache_Log::debug( $buffer ) ;
572
- }
573
- LiteSpeed_Cache_Log::debug( '[Core] ESI End 👆' ) ;
574
- }
575
-
576
- if ( apply_filters( 'litespeed_is_json', false ) ) {
577
- if ( json_decode( $buffer, true ) == NULL ) {
578
- LiteSpeed_Cache_Log::debug( '[Core] Buffer converting to JSON' ) ;
579
- $buffer = json_encode( $buffer ) ;
580
- $buffer = trim( $buffer, '"' ) ;
581
- }
582
- else {
583
- LiteSpeed_Cache_Log::debug( '[Core] JSON Buffer' ) ;
584
- }
585
- }
586
-
587
- LiteSpeed_Cache_Log::debug( "End response\n--------------------------------------------------------------------------------\n" ) ;
588
-
589
- return $buffer ;
590
- }
591
-
592
- /**
593
- * Sends the headers out at the end of processing the request.
594
- *
595
- * This will send out all LiteSpeed Cache related response headers needed for the post.
596
- *
597
- * @since 1.0.5
598
- * @access public
599
- * @param boolean $is_forced If the header is sent following our normal finalizing logic
600
- */
601
- public function send_headers( $is_forced = false )
602
- {
603
- // Make sure header output only run once
604
- if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
605
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
606
- }
607
- else {
608
- return ;
609
- }
610
-
611
- $this->_check_is_html() ;
612
-
613
- // NOTE: cache ctrl output needs to be done first, as currently some varies are added in 3rd party hook `litespeed_cache_api_control`.
614
- LiteSpeed_Cache_Control::finalize() ;
615
-
616
- $vary_header = LiteSpeed_Cache_Vary::finalize() ;
617
-
618
- // If is not cacheable but Admin QS is `purge` or `purgesingle`, `tag` still needs to be generated
619
- $tag_header = LiteSpeed_Cache_Tag::output() ;
620
- if ( LiteSpeed_Cache_Control::is_cacheable() && ! $tag_header ) {
621
- LiteSpeed_Cache_Control::set_nocache( 'empty tag header' ) ;
622
- }
623
-
624
- // NOTE: `purge` output needs to be after `tag` output as Admin QS may need to send `tag` header
625
- $purge_header = LiteSpeed_Cache_Purge::output() ;
626
-
627
- // generate `control` header in the end in case control status is changed by other headers.
628
- $control_header = LiteSpeed_Cache_Control::output() ;
629
-
630
- // Init comment info
631
- $running_info_showing = defined( 'LITESPEED_IS_HTML' ) || defined( 'LSCACHE_IS_ESI' ) ;
632
- if ( defined( 'LSCACHE_ESI_SILENCE' ) ) {
633
- $running_info_showing = false ;
634
- LiteSpeed_Cache_Log::debug( '[Core] ESI silence' ) ;
635
- }
636
- /**
637
- * Silence comment for json req
638
- * @since 2.9.3
639
- */
640
- if ( LiteSpeed_Cache_REST::get_instance()->is_rest() || LiteSpeed_Cache_Router::is_ajax() ) {
641
- $running_info_showing = false ;
642
- LiteSpeed_Cache_Log::debug( '[Core] Silence Comment due to REST/AJAX' ) ;
643
- }
644
-
645
- $running_info_showing = apply_filters( 'litespeed_comment', $running_info_showing ) ;
646
-
647
- if ( $running_info_showing ) {
648
- // Give one more break to avoid ff crash
649
- if ( ! defined( 'LSCACHE_IS_ESI' ) ) {
650
- $this->footer_comment .= "\n" ;
651
- }
652
-
653
- $cache_support = 'supported' ;
654
- if ( defined( 'LITESPEED_ON' ) ) {
655
- $cache_support = LiteSpeed_Cache_Control::is_cacheable() ? 'generated' : 'uncached' ;
656
- }
657
-
658
- $this->footer_comment .= sprintf(
659
- '<!-- %1$s %2$s by LiteSpeed Cache %4$s on %3$s -->',
660
- defined( 'LSCACHE_IS_ESI' ) ? 'Block' : 'Page',
661
- $cache_support,
662
- date( 'Y-m-d H:i:s', time() + LITESPEED_TIME_OFFSET ),
663
- self::PLUGIN_VERSION
664
- ) ;
665
- }
666
-
667
- // send Control header
668
- if ( defined( 'LITESPEED_ON' ) && $control_header ) {
669
- @header( $control_header ) ;
670
- if ( defined( 'LSCWP_LOG' ) ) {
671
- LiteSpeed_Cache_Log::debug( $control_header ) ;
672
- if ( $running_info_showing ) {
673
- $this->footer_comment .= "\n<!-- " . $control_header . " -->" ;
674
- }
675
- }
676
- }
677
- // send PURGE header (Always send regardless of cache setting disabled/enabled)
678
- if ( defined( 'LITESPEED_ON' ) && $purge_header ) {
679
- @header( $purge_header ) ;
680
- LiteSpeed_Cache_Log::log_purge( $purge_header ) ;
681
-
682
- if ( defined( 'LSCWP_LOG' ) ) {
683
- LiteSpeed_Cache_Log::debug( $purge_header ) ;
684
- if ( $running_info_showing ) {
685
- $this->footer_comment .= "\n<!-- " . $purge_header . " -->" ;
686
- }
687
- }
688
- }
689
- // send Vary header
690
- if ( defined( 'LITESPEED_ON' ) && $vary_header ) {
691
- @header( $vary_header ) ;
692
- if ( defined( 'LSCWP_LOG' ) ) {
693
- LiteSpeed_Cache_Log::debug( $vary_header ) ;
694
- if ( $running_info_showing ) {
695
- $this->footer_comment .= "\n<!-- " . $vary_header . " -->" ;
696
- }
697
- }
698
- }
699
-
700
- // Admin QS show header action
701
- if ( self::$_debug_show_header ) {
702
- $debug_header = self::HEADER_DEBUG . ': ' ;
703
- if ( $control_header ) {
704
- $debug_header .= $control_header . '; ' ;
705
- }
706
- if ( $purge_header ) {
707
- $debug_header .= $purge_header . '; ' ;
708
- }
709
- if ( $tag_header ) {
710
- $debug_header .= $tag_header . '; ' ;
711
- }
712
- if ( $vary_header ) {
713
- $debug_header .= $vary_header . '; ' ;
714
- }
715
- @header( $debug_header ) ;
716
- LiteSpeed_Cache_Log::debug( $debug_header ) ;
717
- }
718
- else {
719
- // Control header
720
- if ( defined( 'LITESPEED_ON' ) && LiteSpeed_Cache_Control::is_cacheable() && $tag_header ) {
721
- @header( $tag_header ) ;
722
- if ( defined( 'LSCWP_LOG' ) ) {
723
- LiteSpeed_Cache_Log::debug( $tag_header ) ;
724
- if ( $running_info_showing ) {
725
- $this->footer_comment .= "\n<!-- " . $tag_header . " -->" ;
726
- }
727
- }
728
- }
729
- }
730
-
731
- // Object cache comment
732
- if ( $running_info_showing && defined( 'LSCWP_LOG' ) && defined( 'LSCWP_OBJECT_CACHE' ) && method_exists( 'WP_Object_Cache', 'debug' ) ) {
733
- $this->footer_comment .= "\n<!-- Object Cache " . WP_Object_Cache::get_instance()->debug() . " -->" ;
734
- }
735
-
736
- if ( $is_forced ) {
737
- LiteSpeed_Cache_Log::debug( '--forced--' ) ;
738
- }
739
-
740
- }
741
-
742
- /**
743
- * Deprecated calls for backward compatibility to v1.1.2.2
744
- */
745
- public function purge_post( $id )
746
- {
747
- litespeed_purge_single_post( $id ) ;
748
- }
749
-
750
- /**
751
- * Deprecated calls for backward compatibility to v1.1.2.2
752
- */
753
- public function purge_all()
754
- {
755
- LiteSpeed_Cache_API::purge_all() ;
756
- }
757
-
758
- /**
759
- * Get the current instance object.
760
- *
761
- * @since 1.1.0
762
- * @access public
763
- * @return Current class instance.
764
- */
765
- public static function get_instance()
766
- {
767
- if ( ! isset(self::$_instance) ) {
768
- self::$_instance = new self() ;
769
- }
770
-
771
- return self::$_instance ;
772
- }
773
-
774
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/litespeed.autoload.php DELETED
@@ -1,151 +0,0 @@
1
- <?php
2
- /**
3
- * Auto registration for LiteSpeed classes
4
- *
5
- * @since 1.1.0
6
- * @since 1.5 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined('WPINC') ) {
13
- die ;
14
- }
15
-
16
- if ( !function_exists('_litespeed_autoload') ) {
17
- function _litespeed_autoload($cls)
18
- {
19
- $class2fileArr = array(
20
- 'LiteSpeed' => 'lib/litespeed/litespeed.class.php',
21
- 'Litespeed_Crawler' => 'lib/litespeed/litespeed-crawler.class.php',
22
- 'Litespeed_File' => 'lib/litespeed/litespeed-file.class.php',
23
- 'Litespeed_String' => 'lib/litespeed/litespeed-string.class.php',
24
-
25
- 'LiteSpeed_Cache' => 'inc/litespeed-cache.class.php',
26
- 'LiteSpeed_Cache_Activation' => 'inc/activation.class.php',
27
- 'LiteSpeed_Cache_API' => 'inc/api.class.php',
28
- 'LiteSpeed_Cache_CDN' => 'inc/cdn.class.php',
29
- 'LiteSpeed_Cache_CDN_Cloudflare' => 'inc/cdn/cloudflare.class.php',
30
- 'LiteSpeed_Cache_CDN_Quic' => 'inc/cdn/quic.class.php',
31
- 'LiteSpeed_Cache_Config' => 'inc/config.class.php',
32
- 'LiteSpeed_Cache_Control' => 'inc/control.class.php',
33
- 'LiteSpeed_Cache_Const' => 'inc/const.cls.php',
34
- 'LiteSpeed_Cache_Crawler' => 'inc/crawler.class.php',
35
- 'LiteSpeed_Cache_Crawler_Sitemap' => 'inc/crawler-sitemap.class.php',
36
- 'LiteSpeed_Cache_CSS' => 'inc/css.cls.php',
37
- 'LiteSpeed_Cache_Data' => 'inc/data.class.php',
38
- 'LiteSpeed_Cache_Doc' => 'inc/doc.cls.php',
39
- 'LiteSpeed_Cache_ESI' => 'inc/esi.class.php',
40
- 'LiteSpeed_Cache_GUI' => 'inc/gui.class.php',
41
- 'LiteSpeed_Cache_Import' => 'inc/import.class.php',
42
- 'LiteSpeed_Cache_Img_Optm' => 'inc/img_optm.class.php',
43
- 'LiteSpeed_Cache_Log' => 'inc/log.class.php',
44
- 'LiteSpeed_Cache_Media' => 'inc/media.class.php',
45
- 'LiteSpeed_Cache_Object' => 'inc/object.class.php',
46
- 'LiteSpeed_Cache_Optimize' => 'inc/optimize.class.php',
47
- 'LiteSpeed_Cache_Optimizer' => 'inc/optimizer.class.php',
48
- 'LiteSpeed_Cache_Purge' => 'inc/purge.class.php',
49
- 'LiteSpeed_Cache_REST' => 'inc/rest.cls.php',
50
- 'LiteSpeed_Cache_Router' => 'inc/router.class.php',
51
- 'LiteSpeed_Cache_Tag' => 'inc/tag.class.php',
52
- 'LiteSpeed_Cache_Task' => 'inc/task.class.php',
53
- 'LiteSpeed_Cache_Vary' => 'inc/vary.class.php',
54
- 'LiteSpeed_Cache_Utility' => 'inc/utility.class.php',
55
-
56
- 'LiteSpeed_Cache_Admin' => 'admin/litespeed-cache-admin.class.php',
57
- 'LiteSpeed_Cache_Admin_API' => 'admin/admin-api.class.php',
58
- 'LiteSpeed_Cache_Admin_Display' => 'admin/litespeed-cache-admin-display.class.php',
59
- 'LiteSpeed_Cache_Admin_Error' => 'admin/litespeed-cache-admin-error.class.php',
60
- 'LiteSpeed_Cache_Admin_Optimize' => 'admin/litespeed-cache-admin-optimize.class.php',
61
- 'LiteSpeed_Cache_Admin_Report' => 'admin/litespeed-cache-admin-report.class.php',
62
- 'LiteSpeed_Cache_Admin_Rules' => 'admin/litespeed-cache-admin-rules.class.php',
63
- 'LiteSpeed_Cache_Admin_Settings' => 'admin/litespeed-cache-admin-settings.class.php',
64
-
65
- 'LiteSpeed_Cache_Cli_Admin' => 'cli/litespeed-cache-cli-admin.class.php',
66
- 'LiteSpeed_Cache_CLI_IAPI' => 'cli/litespeed-cache-cli-iapi.class.php',
67
- 'LiteSpeed_Cache_Cli_Purge' => 'cli/litespeed-cache-cli-purge.class.php',
68
-
69
- 'LiteSpeed_Cache_Tags' => 'includes/deprecated-litespeed-cache-tags.class.php',
70
-
71
- 'LiteSpeed_3rd_Lib\Minify_HTML' => 'lib/html_min.class.php',
72
- 'LiteSpeed_3rd_Lib\css_min\Minifier' => 'lib/css_min.class.php',
73
- 'LiteSpeed_3rd_Lib\css_min\Colors' => 'lib/css_min.colors.class.php',
74
- 'LiteSpeed_3rd_Lib\css_min\Utils' => 'lib/css_min.utils.class.php',
75
- 'LiteSpeed_3rd_Lib\css_min\UriRewriter' => 'lib/css_min.url_rewritter.class.php',
76
- 'LiteSpeed_3rd_Lib\js_min\JSMin' => 'lib/js_min.class.php',
77
- );
78
- if( array_key_exists($cls, $class2fileArr) && file_exists(LSCWP_DIR . $class2fileArr[$cls]) ) {
79
- require_once LSCWP_DIR . $class2fileArr[$cls];
80
- }
81
- }
82
- }
83
-
84
- spl_autoload_register('_litespeed_autoload');
85
-
86
-
87
- /**
88
- * Tmp preload all for v3.0
89
- * @since v2.9.9
90
- */
91
- $class2fileArr = array(
92
- 'Litespeed_Crawler' => 'lib/litespeed/litespeed-crawler.class.php',
93
- 'Litespeed_File' => 'lib/litespeed/litespeed-file.class.php',
94
- 'Litespeed_String' => 'lib/litespeed/litespeed-string.class.php',
95
-
96
- 'LiteSpeed_Cache' => 'inc/litespeed-cache.class.php',
97
- 'LiteSpeed_Cache_Activation' => 'inc/activation.class.php',
98
- 'LiteSpeed_Cache_API' => 'inc/api.class.php',
99
- 'LiteSpeed_Cache_CDN' => 'inc/cdn.class.php',
100
- 'LiteSpeed_Cache_CDN_Cloudflare' => 'inc/cdn/cloudflare.class.php',
101
- 'LiteSpeed_Cache_CDN_Quic' => 'inc/cdn/quic.class.php',
102
- 'LiteSpeed_Cache_Config' => 'inc/config.class.php',
103
- 'LiteSpeed_Cache_Control' => 'inc/control.class.php',
104
- 'LiteSpeed_Cache_Const' => 'inc/const.cls.php',
105
- 'LiteSpeed_Cache_Crawler' => 'inc/crawler.class.php',
106
- 'LiteSpeed_Cache_Crawler_Sitemap' => 'inc/crawler-sitemap.class.php',
107
- 'LiteSpeed_Cache_CSS' => 'inc/css.cls.php',
108
- 'LiteSpeed_Cache_Data' => 'inc/data.class.php',
109
- 'LiteSpeed_Cache_Doc' => 'inc/doc.cls.php',
110
- 'LiteSpeed_Cache_ESI' => 'inc/esi.class.php',
111
- 'LiteSpeed_Cache_GUI' => 'inc/gui.class.php',
112
- 'LiteSpeed_Cache_Import' => 'inc/import.class.php',
113
- 'LiteSpeed_Cache_Img_Optm' => 'inc/img_optm.class.php',
114
- 'LiteSpeed_Cache_Log' => 'inc/log.class.php',
115
- 'LiteSpeed_Cache_Media' => 'inc/media.class.php',
116
- 'LiteSpeed_Cache_Object' => 'inc/object.class.php',
117
- 'LiteSpeed_Cache_Optimize' => 'inc/optimize.class.php',
118
- 'LiteSpeed_Cache_Optimizer' => 'inc/optimizer.class.php',
119
- 'LiteSpeed_Cache_Purge' => 'inc/purge.class.php',
120
- 'LiteSpeed_Cache_REST' => 'inc/rest.cls.php',
121
- 'LiteSpeed_Cache_Router' => 'inc/router.class.php',
122
- 'LiteSpeed_Cache_Tag' => 'inc/tag.class.php',
123
- 'LiteSpeed_Cache_Task' => 'inc/task.class.php',
124
- 'LiteSpeed_Cache_Vary' => 'inc/vary.class.php',
125
- 'LiteSpeed_Cache_Utility' => 'inc/utility.class.php',
126
-
127
- 'LiteSpeed_Cache_Admin' => 'admin/litespeed-cache-admin.class.php',
128
- 'LiteSpeed_Cache_Admin_API' => 'admin/admin-api.class.php',
129
- 'LiteSpeed_Cache_Admin_Display' => 'admin/litespeed-cache-admin-display.class.php',
130
- 'LiteSpeed_Cache_Admin_Error' => 'admin/litespeed-cache-admin-error.class.php',
131
- 'LiteSpeed_Cache_Admin_Optimize' => 'admin/litespeed-cache-admin-optimize.class.php',
132
- 'LiteSpeed_Cache_Admin_Report' => 'admin/litespeed-cache-admin-report.class.php',
133
- 'LiteSpeed_Cache_Admin_Rules' => 'admin/litespeed-cache-admin-rules.class.php',
134
- 'LiteSpeed_Cache_Admin_Settings' => 'admin/litespeed-cache-admin-settings.class.php',
135
-
136
- 'LiteSpeed_Cache_Cli_Admin' => 'cli/litespeed-cache-cli-admin.class.php',
137
- 'LiteSpeed_Cache_CLI_IAPI' => 'cli/litespeed-cache-cli-iapi.class.php',
138
- 'LiteSpeed_Cache_Cli_Purge' => 'cli/litespeed-cache-cli-purge.class.php',
139
-
140
- 'LiteSpeed_Cache_Tags' => 'includes/deprecated-litespeed-cache-tags.class.php',
141
-
142
- 'LiteSpeed_3rd_Lib\Minify_HTML' => 'lib/html_min.class.php',
143
- 'LiteSpeed_3rd_Lib\css_min\Minifier' => 'lib/css_min.class.php',
144
- 'LiteSpeed_3rd_Lib\css_min\Colors' => 'lib/css_min.colors.class.php',
145
- 'LiteSpeed_3rd_Lib\css_min\Utils' => 'lib/css_min.utils.class.php',
146
- 'LiteSpeed_3rd_Lib\css_min\UriRewriter' => 'lib/css_min.url_rewritter.class.php',
147
- 'LiteSpeed_3rd_Lib\js_min\JSMin' => 'lib/js_min.class.php',
148
- );
149
- foreach ( $class2fileArr as $v ) {
150
- require_once LSCWP_DIR . $v ;
151
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/log.class.php DELETED
@@ -1,498 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin logging class.
4
- *
5
- * This generate the valid action.
6
- *
7
- * @since 1.1.0
8
- * @since 1.5 Moved into /inc
9
- * @package LiteSpeed_Cache
10
- * @subpackage LiteSpeed_Cache/inc
11
- * @author LiteSpeed Technologies <info@litespeedtech.com>
12
- */
13
-
14
- if ( ! defined( 'WPINC' ) ) {
15
- die ;
16
- }
17
-
18
- class LiteSpeed_Cache_Log
19
- {
20
- private static $_instance ;
21
- private static $log_path ;
22
- private static $_prefix ;
23
-
24
- private static $_ignore_filters ;
25
- private static $_ignore_part_filters ;
26
-
27
- const TYPE_CLEAR_LOG = 'clear_log' ;
28
- const TYPE_BETA_TEST = 'beta_test' ;
29
-
30
- const BETA_TEST_URL = 'beta_test_url' ;
31
-
32
- /**
33
- * Log class Constructor
34
- *
35
- * NOTE: in this process, until last step ( define const LSCWP_LOG = true ), any usage to WP filter will not be logged to prevent infinite loop with log_filters()
36
- *
37
- * @since 1.1.2
38
- * @access public
39
- */
40
- private function __construct()
41
- {
42
- self::$log_path = LSCWP_CONTENT_DIR . '/debug.log' ;
43
- if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Litespeed_Crawler::FAST_USER_AGENT ) === 0 ) {
44
- self::$log_path = LSCWP_CONTENT_DIR . '/crawler.log' ;
45
- }
46
-
47
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', get_current_blog_id() ) ;
48
-
49
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_DEBUG_LEVEL ) ) {
50
- ! defined( 'LSCWP_LOG_MORE' ) && define( 'LSCWP_LOG_MORE', true ) ;
51
- }
52
-
53
- }
54
-
55
- /**
56
- * Beta test upgrade
57
- *
58
- * @since 2.9.5
59
- * @access public
60
- */
61
- public function beta_test( $zip = false )
62
- {
63
- if ( ! $zip ) {
64
- if ( empty( $_POST[ self::BETA_TEST_URL ] ) ) {
65
- return ;
66
- }
67
-
68
- // Generate zip url
69
- $commit = substr( $_POST[ self::BETA_TEST_URL ], strpos( $_POST[ self::BETA_TEST_URL ], '/commit/' ) + 8 ) ;
70
- $zip = $this->_package_zip( $commit ) ;
71
- }
72
-
73
- if ( ! $zip ) {
74
- LiteSpeed_Cache_Log::debug( '[Log] ❌ No ZIP file' ) ;
75
- return ;
76
- }
77
-
78
- LiteSpeed_Cache_Log::debug( '[Log] ZIP file ' . $zip ) ;
79
-
80
- $update_plugins = get_site_transient( 'update_plugins' ) ;
81
- if ( ! is_object( $update_plugins ) ) {
82
- $update_plugins = new \stdClass() ;
83
- }
84
-
85
- $plugin_info = new \stdClass() ;
86
- $plugin_info->new_version = LiteSpeed_Cache::PLUGIN_VERSION . '.0.0' ;
87
- $plugin_info->slug = LiteSpeed_Cache::PLUGIN_NAME ;
88
- $plugin_info->plugin = LiteSpeed_Cache::PLUGIN_FILE ;
89
- $plugin_info->package = $zip ;
90
- $plugin_info->url = 'https://wordpress.org/plugins/litespeed-cache/' ;
91
-
92
- $update_plugins->response[ LiteSpeed_Cache::PLUGIN_FILE ] = $plugin_info ;
93
-
94
- set_site_transient( 'update_plugins', $update_plugins ) ;
95
-
96
- // Run upgrade
97
- LiteSpeed_Cache_Activation::get_instance()->upgrade() ;
98
- }
99
-
100
- /**
101
- * Git package refresh
102
- *
103
- * @since 2.9.5
104
- * @access private
105
- */
106
- private function _package_zip( $commit )
107
- {
108
- // Check latest stable version allowed to upgrade
109
- $url = 'https://wp.api.litespeedtech.com/client.package_zip?commit=' . $commit ;
110
-
111
- $response = wp_remote_get( $url, array( 'timeout' => 120 ) ) ;
112
- if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
113
- return false ;
114
- }
115
-
116
- $url = json_decode( $response[ 'body' ], true ) ;
117
-
118
- if ( empty( $url[ 'zip' ] ) ) {
119
- return false ;
120
- }
121
-
122
- return $url[ 'zip' ] ;
123
- }
124
-
125
- /**
126
- * Log Purge headers separately
127
- *
128
- * @since 2.7
129
- * @access public
130
- */
131
- public static function log_purge( $purge_header )
132
- {
133
- // Check if debug is ON
134
- if ( ! defined( 'LSCWP_LOG' ) && ! defined( 'LSCWP_LOG_BYPASS_NOTADMIN' ) ) {
135
- return ;
136
- }
137
-
138
- $purge_file = LSCWP_CONTENT_DIR . '/debug.purge.log' ;
139
-
140
- self::get_instance()->_init_request( $purge_file ) ;
141
-
142
- $msg = $purge_header . self::_backtrace_info( 6 ) ;
143
-
144
- Litespeed_File::append( $purge_file, self::format_message( $msg ) ) ;
145
-
146
- }
147
-
148
- /**
149
- * Enable debug log
150
- *
151
- * @since 1.1.0
152
- * @access public
153
- */
154
- public static function init()
155
- {
156
- $debug = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_DEBUG ) ;
157
- if ( $debug == LiteSpeed_Cache_Config::VAL_ON2 ) {
158
- if ( ! LiteSpeed_Cache_Router::is_admin_ip() ) {
159
- define( 'LSCWP_LOG_BYPASS_NOTADMIN', true ) ;
160
- return ;
161
- }
162
- }
163
-
164
- if ( ! defined( 'LSCWP_LOG' ) ) {// If not initialized, do it now
165
- self::get_instance()->_init_request() ;
166
- define( 'LSCWP_LOG', true ) ;
167
-
168
- }
169
-
170
- // Check if hook filters
171
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_FILTERS ) ) {
172
- self::$_ignore_filters = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_FILTERS ) ;
173
- self::$_ignore_part_filters = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_LOG_IGNORE_PART_FILTERS ) ;
174
-
175
- add_action( 'all', 'LiteSpeed_Cache_Log::log_filters' ) ;
176
- }
177
- }
178
-
179
- /**
180
- * Create the initial log messages with the request parameters.
181
- *
182
- * @since 1.0.12
183
- * @access private
184
- */
185
- private function _init_request( $log_file = null )
186
- {
187
- if ( ! $log_file ) {
188
- $log_file = self::$log_path ;
189
- }
190
-
191
- // Check log file size
192
- $log_file_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_LOG_FILE_SIZE ) ;
193
- if ( file_exists( $log_file ) && filesize( $log_file ) > $log_file_size * 1000000 ) {
194
- Litespeed_File::save( $log_file, '' ) ;
195
- }
196
-
197
- // For more than 2s's requests, add more break
198
- if ( file_exists( $log_file ) && time() - filemtime( $log_file ) > 2 ) {
199
- Litespeed_File::append( $log_file, "\n\n\n\n" ) ;
200
- }
201
-
202
- if ( PHP_SAPI == 'cli' ) {
203
- return ;
204
- }
205
-
206
- $servervars = array(
207
- 'Query String' => '',
208
- 'HTTP_ACCEPT' => '',
209
- 'HTTP_USER_AGENT' => '',
210
- 'HTTP_ACCEPT_ENCODING' => '',
211
- 'HTTP_COOKIE' => '',
212
- 'X-LSCACHE' => '',
213
- 'LSCACHE_VARY_COOKIE' => '',
214
- 'LSCACHE_VARY_VALUE' => '',
215
- 'ESI_CONTENT_TYPE' => '',
216
- ) ;
217
- $server = array_merge( $servervars, $_SERVER ) ;
218
- $params = array() ;
219
-
220
- if ( isset( $_SERVER[ 'HTTPS' ] ) && $_SERVER[ 'HTTPS' ] == 'on' ) {
221
- $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
222
- }
223
-
224
- $param = sprintf( '💓 ------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
225
-
226
- $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
227
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
228
- if ( strlen( $qs ) > 53 ) {
229
- $qs = substr( $qs, 0, 53 ) . '...' ;
230
- }
231
- if ( $qs ) {
232
- $param .= ' ? ' . $qs ;
233
- }
234
- $params[] = $param ;
235
- }
236
- else {
237
- $params[] = $param ;
238
- $params[] = 'Query String: ' . $qs ;
239
- }
240
-
241
- if ( ! empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
242
- $params[] = 'HTTP_REFERER: ' . $server[ 'HTTP_REFERER' ] ;
243
- }
244
-
245
- if ( defined( 'LSCWP_LOG_MORE' ) ) {
246
- $params[] = 'User Agent: ' . $server[ 'HTTP_USER_AGENT' ] ;
247
- $params[] = 'Accept: ' . $server['HTTP_ACCEPT'] ;
248
- $params[] = 'Accept Encoding: ' . $server['HTTP_ACCEPT_ENCODING'] ;
249
- }
250
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_DEBUG_COOKIE ) ) {
251
- $params[] = 'Cookie: ' . $server['HTTP_COOKIE'] ;
252
- }
253
- if ( isset( $_COOKIE[ '_lscache_vary' ] ) ) {
254
- $params[] = 'Cookie _lscache_vary: ' . $_COOKIE[ '_lscache_vary' ] ;
255
- }
256
- if ( defined( 'LSCWP_LOG_MORE' ) ) {
257
- $params[] = 'X-LSCACHE: ' . ( ! empty( $server[ 'X-LSCACHE' ] ) ? 'true' : 'false' ) ;
258
- }
259
- if( $server['LSCACHE_VARY_COOKIE'] ) {
260
- $params[] = 'LSCACHE_VARY_COOKIE: ' . $server['LSCACHE_VARY_COOKIE'] ;
261
- }
262
- if( $server['LSCACHE_VARY_VALUE'] ) {
263
- $params[] = 'LSCACHE_VARY_VALUE: ' . $server['LSCACHE_VARY_VALUE'] ;
264
- }
265
- if( $server['ESI_CONTENT_TYPE'] ) {
266
- $params[] = 'ESI_CONTENT_TYPE: ' . $server['ESI_CONTENT_TYPE'] ;
267
- }
268
-
269
- $request = array_map( 'self::format_message', $params ) ;
270
-
271
- Litespeed_File::append( $log_file, $request ) ;
272
- }
273
-
274
- /**
275
- * Log all filters and action hooks
276
- *
277
- * @since 1.1.5
278
- * @access public
279
- */
280
- public static function log_filters()
281
- {
282
- $action = current_filter() ;
283
-
284
- if ( self::$_ignore_filters && in_array( $action, self::$_ignore_filters ) ) {
285
- return ;
286
- }
287
-
288
- if ( self::$_ignore_part_filters ) {
289
- foreach ( self::$_ignore_part_filters as $val ) {
290
- if ( stripos( $action, $val ) !== false ) {
291
- return ;
292
- }
293
- }
294
- }
295
-
296
- self::debug( "===log filter: $action" ) ;
297
- }
298
-
299
- /**
300
- * Formats the log message with a consistent prefix.
301
- *
302
- * @since 1.0.12
303
- * @access private
304
- * @param string $msg The log message to write.
305
- * @return string The formatted log message.
306
- */
307
- private static function format_message( $msg )
308
- {
309
- // If call here without calling get_enabled() first, improve compatibility
310
- if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
311
- return $msg . "\n" ;
312
- }
313
-
314
- if ( ! isset( self::$_prefix ) ) {
315
- // address
316
- if ( PHP_SAPI == 'cli' ) {
317
- $addr = '=CLI=' ;
318
- if ( isset( $_SERVER[ 'USER' ] ) ) {
319
- $addr .= $_SERVER[ 'USER' ] ;
320
- }
321
- elseif ( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) {
322
- $addr .= $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ;
323
- }
324
- }
325
- else {
326
- $addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ] ;
327
- }
328
-
329
- // Generate a unique string per request
330
- self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, Litespeed_String::rrand( 3 ) ) ;
331
- }
332
- list( $usec, $sec ) = explode(' ', microtime() ) ;
333
- return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n" ;
334
- }
335
-
336
- /**
337
- * Direct call to log a debug message.
338
- *
339
- * @since 1.1.3
340
- * @since 1.6 Added array dump as 2nd param
341
- * @access public
342
- * @param string $msg The debug message.
343
- * @param int|array $backtrace_limit Backtrace depth, Or the array to dump
344
- */
345
- public static function debug( $msg, $backtrace_limit = false )
346
- {
347
- if ( ! defined( 'LSCWP_LOG' ) ) {
348
- return ;
349
- }
350
-
351
- if ( $backtrace_limit !== false ) {
352
- if ( ! is_numeric( $backtrace_limit ) ) {
353
- $msg .= ' --- ' . var_export( $backtrace_limit, true ) ;
354
- self::push( $msg ) ;
355
- return ;
356
- }
357
-
358
- self::push( $msg, $backtrace_limit + 1 ) ;
359
- return ;
360
- }
361
-
362
- self::push( $msg ) ;
363
- }
364
-
365
- /**
366
- * Direct call to log an advanced debug message.
367
- *
368
- * @since 1.2.0
369
- * @access public
370
- * @param string $msg The debug message.
371
- * @param int $backtrace_limit Backtrace depth.
372
- */
373
- public static function debug2( $msg, $backtrace_limit = false )
374
- {
375
- if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
376
- return ;
377
- }
378
- self::debug( $msg, $backtrace_limit ) ;
379
- }
380
-
381
- /**
382
- * Logs a debug message.
383
- *
384
- * @since 1.1.0
385
- * @access private
386
- * @param string $msg The debug message.
387
- * @param int $backtrace_limit Backtrace depth.
388
- */
389
- private static function push( $msg, $backtrace_limit = false )
390
- {
391
- // backtrace handler
392
- if ( defined( 'LSCWP_LOG_MORE' ) && $backtrace_limit !== false ) {
393
- $msg .= self::_backtrace_info( $backtrace_limit ) ;
394
- }
395
-
396
- Litespeed_File::append( self::$log_path, self::format_message( $msg ) ) ;
397
- }
398
-
399
- /**
400
- * Backtrace info
401
- *
402
- * @since 2.7
403
- */
404
- private static function _backtrace_info( $backtrace_limit )
405
- {
406
- $msg = '' ;
407
-
408
- $trace = version_compare( PHP_VERSION, '5.4.0', '<' ) ? debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ) : debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS, $backtrace_limit + 3 ) ;
409
- for ( $i=2 ; $i <= $backtrace_limit + 2 ; $i++ ) {// 0st => _backtrace_info(), 1st => push()
410
- if ( empty( $trace[ $i ][ 'class' ] ) ) {
411
- if ( empty( $trace[ $i ][ 'file' ] ) ) {
412
- break ;
413
- }
414
- $log = "\n" . $trace[ $i ][ 'file' ] ;
415
- }
416
- else {
417
- if ( $trace[$i]['class'] == 'LiteSpeed_Cache_Log' ) {
418
- continue ;
419
- }
420
-
421
- $log = str_replace('LiteSpeed_Cache', 'LSC', $trace[$i]['class']) . $trace[$i]['type'] . $trace[$i]['function'] . '()' ;
422
- }
423
- if ( ! empty( $trace[$i-1]['line'] ) ) {
424
- $log .= '@' . $trace[$i-1]['line'] ;
425
- }
426
- $msg .= " => $log" ;
427
- }
428
-
429
- return $msg ;
430
- }
431
-
432
- /**
433
- * Clear log file
434
- *
435
- * @since 1.6.6
436
- * @access private
437
- */
438
- private function _clear_log()
439
- {
440
- Litespeed_File::save( self::$log_path, '' ) ;
441
- Litespeed_File::save( LSCWP_CONTENT_DIR . '/debug.purge.log', '' ) ;
442
- }
443
-
444
- /**
445
- * Heartbeat control
446
- *
447
- * @since 1.1.5
448
- * @access public
449
- */
450
- public static function disable_heartbeat()
451
- {
452
- wp_deregister_script( 'heartbeat' ) ;
453
- }
454
-
455
- /**
456
- * Handle all request actions from main cls
457
- *
458
- * @since 1.6.6
459
- * @access public
460
- */
461
- public static function handler()
462
- {
463
- $instance = self::get_instance() ;
464
-
465
- $type = LiteSpeed_Cache_Router::verify_type() ;
466
-
467
- switch ( $type ) {
468
- case self::TYPE_CLEAR_LOG :
469
- $instance->_clear_log() ;
470
- break ;
471
-
472
- case self::TYPE_BETA_TEST :
473
- $instance->beta_test() ;
474
- break ;
475
-
476
- default:
477
- break ;
478
- }
479
-
480
- LiteSpeed_Cache_Admin::redirect() ;
481
- }
482
-
483
- /**
484
- * Get the current instance object.
485
- *
486
- * @since 1.1.0
487
- * @access public
488
- * @return Current class instance.
489
- */
490
- public static function get_instance()
491
- {
492
- if ( ! isset( self::$_instance ) ) {
493
- self::$_instance = new self() ;
494
- }
495
-
496
- return self::$_instance ;
497
- }
498
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/media.class.php DELETED
@@ -1,1084 +0,0 @@
1
- <?php
2
- /**
3
- * The class to operate media data.
4
- *
5
- * @since 1.4
6
- * @since 1.5 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_Media
17
- {
18
- private static $_instance ;
19
-
20
- const LIB_FILE_IMG_LAZYLOAD = 'js/lazyload.min.js' ;
21
-
22
- const TYPE_GENERATE_PLACEHOLDER = 'generate_placeholder' ;
23
- const DB_PLACEHOLDER_SUMMARY = 'litespeed-media-placeholder-summary' ;
24
-
25
- private $content ;
26
- private $wp_upload_dir ;
27
-
28
- private $_cfg_img_webp ;
29
- private $_cfg_placeholder_resp ;
30
- private $_cfg_placeholder_resp_color ;
31
- private $_cfg_placeholder_resp_async ;
32
- private $_placeholder_resp_dict = array() ;
33
- private $_ph_queue = array() ;
34
-
35
- /**
36
- * Init
37
- *
38
- * @since 1.4
39
- * @access private
40
- */
41
- private function __construct()
42
- {
43
- LiteSpeed_Cache_Log::debug2( 'Media init' ) ;
44
-
45
- $this->wp_upload_dir = wp_upload_dir() ;
46
-
47
- if ( $this->can_media() ) {
48
- $this->_cfg_img_webp = self::webp_enabled() ;
49
-
50
- // Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
51
- if ( $this->_cfg_img_webp ) {
52
- /**
53
- * Add vary filter
54
- * @since 1.6.2
55
- */
56
- // Moved to htaccess
57
- // add_filter( 'litespeed_vary', array( $this, 'vary_add' ) ) ;
58
-
59
- //
60
- if ( $this->webp_support() ) {
61
- // Hook to srcset
62
- if ( function_exists( 'wp_calculate_image_srcset' ) ) {
63
- add_filter( 'wp_calculate_image_srcset', array( $this, 'webp_srcset' ), 988 ) ;
64
- }
65
- // Hook to mime icon
66
- // add_filter( 'wp_get_attachment_image_src', array( $this, 'webp_attach_img_src' ), 988 ) ;// todo: need to check why not
67
- // add_filter( 'wp_get_attachment_url', array( $this, 'webp_url' ), 988 ) ; // disabled to avoid wp-admin display
68
- }
69
- }
70
- }
71
-
72
- add_action( 'litspeed_after_admin_init', array( $this, 'after_admin_init' ) ) ;
73
-
74
- $this->_cfg_placeholder_resp = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP ) ;
75
- $this->_cfg_placeholder_resp_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_ASYNC ) ;
76
- $this->_cfg_placeholder_resp_color = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_COLOR ) ;
77
- // Encode the color
78
- if ( $this->_cfg_placeholder_resp_color ) {
79
- $this->_cfg_placeholder_resp_color = base64_encode( $this->_cfg_placeholder_resp_color ) ;
80
- }
81
-
82
- }
83
-
84
- /**
85
- * Check if it can use Media frontend
86
- *
87
- * @since 1.6.2
88
- * @access private
89
- */
90
- private function can_media()
91
- {
92
- if ( is_admin() ) {
93
- return false ;
94
- }
95
-
96
- return true ;
97
- }
98
-
99
- /**
100
- * Check if enabled webp or not
101
- *
102
- * @since 2.4
103
- * @access public
104
- */
105
- public static function webp_enabled()
106
- {
107
- return LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE ) ;
108
- }
109
-
110
- /**
111
- * Register admin menu
112
- *
113
- * @since 1.6.3
114
- * @access public
115
- */
116
- public function after_admin_init()
117
- {
118
- if ( get_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL ) ) {
119
- add_filter( 'manage_media_columns', array( $this, 'media_row_title' ) ) ;
120
- add_filter( 'manage_media_custom_column', array( $this, 'media_row_actions' ), 10, 2 ) ;
121
-
122
- // Hook to attachment delete action
123
- add_action( 'delete_attachment', array( $this, 'delete_attachment' ) ) ;
124
- }
125
- }
126
-
127
- /**
128
- * Media delete action hook
129
- *
130
- * @since 2.4.3
131
- * @access public
132
- */
133
- public function delete_attachment( $post_id )
134
- {
135
- LiteSpeed_Cache_Log::debug( '[Media] delete_attachment [pid] ' . $post_id ) ;
136
- LiteSpeed_Cache_Img_Optm::get_instance()->reset_row( $post_id ) ;
137
- }
138
-
139
- /**
140
- * Return media file info if exists
141
- *
142
- * This is for remote attachment plugins
143
- *
144
- * @since 2.9.8
145
- * @access public
146
- */
147
- public function info( $short_file_path, $post_id )
148
- {
149
- $real_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $short_file_path ;
150
-
151
- if ( file_exists( $real_file ) ) {
152
- return array(
153
- 'url' => $this->wp_upload_dir[ 'baseurl' ] . '/' . $short_file_path,
154
- 'md5' => md5_file( $real_file ),
155
- 'size' => filesize( $real_file ),
156
- ) ;
157
- }
158
-
159
- /**
160
- * WP Stateless compatibility #143 https://github.com/litespeedtech/lscache_wp/issues/143
161
- * @since 2.9.8
162
- * @return array( 'url', 'md5', 'size' )
163
- */
164
- $info = apply_filters( 'litespeed_media_info', array(), $short_file_path, $post_id ) ;
165
- if ( ! empty( $info[ 'url' ] ) && ! empty( $info[ 'md5' ] ) && ! empty( $info[ 'size' ] ) ) {
166
- return $info ;
167
- }
168
-
169
- return false ;
170
- }
171
-
172
- /**
173
- * Delete media file
174
- *
175
- * @since 2.9.8
176
- * @access public
177
- */
178
- public function del( $short_file_path, $post_id )
179
- {
180
- $real_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $short_file_path ;
181
-
182
- if ( file_exists( $real_file ) ) {
183
- unlink( $real_file ) ;
184
- LiteSpeed_Cache_Log::debug( '[Img_Optm] deleted ' . $real_file ) ;
185
- }
186
-
187
- do_action( 'litespeed_media_del', $short_file_path, $post_id ) ;
188
- }
189
-
190
- /**
191
- * Rename media file
192
- *
193
- * @since 2.9.8
194
- * @access public
195
- */
196
- public function rename( $short_file_path, $short_file_path_new, $post_id )
197
- {
198
- $real_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $short_file_path ;
199
- $real_file_new = $this->wp_upload_dir[ 'basedir' ] . '/' . $short_file_path_new ;
200
-
201
- if ( file_exists( $real_file ) ) {
202
- rename( $real_file, $real_file_new ) ;
203
- LiteSpeed_Cache_Log::debug( '[Img_Optm] renamed ' . $real_file . ' to ' . $real_file_new ) ;
204
- }
205
-
206
- do_action( 'litespeed_media_rename', $short_file_path, $short_file_path_new, $post_id ) ;
207
- }
208
-
209
- /**
210
- * Media Admin Menu -> Image Optimization Column Title
211
- *
212
- * @since 1.6.3
213
- * @access public
214
- */
215
- public function media_row_title( $posts_columns )
216
- {
217
- $posts_columns[ 'imgoptm' ] = __( 'LiteSpeed Optimization', 'litespeed-cache' ) ;
218
-
219
- return $posts_columns ;
220
- }
221
-
222
- /**
223
- * Media Admin Menu -> Image Optimization Column
224
- *
225
- * @since 1.6.2
226
- * @access public
227
- */
228
- public function media_row_actions( $column_name, $post_id )
229
- {
230
- if ( $column_name !== 'imgoptm' ) {
231
- return ;
232
- }
233
-
234
- $local_file = get_attached_file( $post_id ) ;
235
- $local_file = substr( $local_file, strlen( $this->wp_upload_dir[ 'basedir' ] ) ) ;
236
-
237
- $size_meta = get_post_meta( $post_id, LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_SIZE, true ) ;
238
-
239
- // WebP info
240
- $info_webp = '' ;
241
- if ( $size_meta && ! empty ( $size_meta[ 'webp_saved' ] ) ) {
242
- $percent = ceil( $size_meta[ 'webp_saved' ] * 100 / $size_meta[ 'webp_total' ] ) ;
243
- $pie_webp = LiteSpeed_Cache_GUI::pie( $percent, 30 ) ;
244
- $txt_webp = sprintf( __( 'WebP saved %s', 'litespeed-cache' ), LiteSpeed_Cache_Utility::real_size( $size_meta[ 'webp_saved' ] ) ) ;
245
-
246
- $link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, 'webp' . $post_id ) ;
247
- $desc = false ;
248
- $cls = 'litespeed-icon-media-webp' ;
249
- $cls_webp = '' ;
250
- if ( $this->info( $local_file . '.webp', $post_id ) ) {
251
- $desc = __( 'Click to Disable WebP', 'litespeed-cache' ) ;
252
- $cls_webp = 'litespeed-txt-webp' ;
253
- }
254
- elseif ( $this->info( $local_file . '.optm.webp', $post_id ) ) {
255
- $cls .= '-disabled' ;
256
- $desc = __( 'Click to Enable WebP', 'litespeed-cache' ) ;
257
- $cls_webp = 'litespeed-txt-disabled' ;
258
- }
259
-
260
- $info_webp = "<div class='litespeed-media-p $cls_webp litespeed-right20'><div class='litespeed-text-dimgray litespeed-text-center'>WebP</div>" ;
261
-
262
- if ( $desc ) {
263
- $info_webp .= sprintf( '<div><a href="%1$s" class="litespeed-media-href" title="%2$s' . "\n\n" . '%3$s">%4$s</a></div>', $link, $txt_webp, $desc, $pie_webp ) ;
264
- }
265
- else {
266
- $info_webp .= sprintf( '<div title="%1$s">%2$s</div>', $txt_webp, $pie_webp ) ;
267
- }
268
-
269
- $info_webp .= '</div>' ;
270
- }
271
-
272
- // Original image info
273
- $info_ori = '' ;
274
- if ( $size_meta && ! empty ( $size_meta[ 'ori_saved' ] ) ) {
275
- $percent = ceil( $size_meta[ 'ori_saved' ] * 100 / $size_meta[ 'ori_total' ] ) ;
276
- $pie_ori = LiteSpeed_Cache_GUI::pie( $percent, 30 ) ;
277
- $txt_ori = sprintf( __( 'Original saved %s', 'litespeed-cache' ), LiteSpeed_Cache_Utility::real_size( $size_meta[ 'ori_saved' ] ) ) ;
278
-
279
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
280
- $bk_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.' . $extension ;
281
- $bk_optm_file = substr( $local_file, 0, -strlen( $extension ) ) . 'bk.optm.' . $extension ;
282
-
283
- $link = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, 'orig' . $post_id ) ;
284
- $desc = false ;
285
- $cls = 'litespeed-icon-media-optm' ;
286
- $cls_ori = '' ;
287
- if ( $this->info( $bk_file, $post_id ) ) {
288
- $desc = __( 'Click to Restore Original File', 'litespeed-cache' ) ;
289
- $cls_ori = 'litespeed-txt-ori' ;
290
- }
291
- elseif ( $this->info( $bk_optm_file, $post_id ) ) {
292
- $cls .= '-disabled' ;
293
- $desc = __( 'Click to Switch To Optimized File', 'litespeed-cache' ) ;
294
- $cls_ori = 'litespeed-txt-disabled' ;
295
- }
296
-
297
- $info_ori = "<div class='litespeed-media-p $cls_ori litespeed-right30'><div class='litespeed-text-dimgray litespeed-text-center'>Orig.</div>" ;
298
-
299
- if ( $desc ) {
300
- $info_ori .= sprintf( '<div><a href="%1$s" class="litespeed-media-href" title="%2$s' . "\n\n" . '%3$s">%4$s</a></div>', $link, $txt_ori, $desc, $pie_ori ) ;
301
- }
302
- else {
303
- $info_ori .= sprintf( '<div title="%1$s">%2$s</div>', $txt_ori, $pie_ori ) ;
304
- }
305
-
306
- $info_ori .= '</div>' ;
307
- }
308
-
309
- // Delete row btn
310
- $del_row = '' ;
311
- if ( $size_meta ) {
312
- $del_row = '<div><div class="litespeed-text-dimgray litespeed-text-center">' . __( 'Reset', 'litespeed-cache' ) . '</div>' ;
313
- $del_row .= sprintf( '<div class="litespeed-media-p"><a href="%1$s" class="">%2$s</a></div>',
314
- LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_IMG_OPTM, LiteSpeed_Cache_Img_Optm::TYPE_RESET_ROW, false, null, array( 'id' => $post_id ) ),
315
- '<span class="dashicons dashicons-trash dashicons-large litespeed-warning litespeed-dashicons-large"></span>'
316
- ) ;
317
- $del_row .= '</div>' ;
318
- }
319
-
320
- echo <<<eot
321
- <div class="litespeed-flex-container">
322
- $info_webp
323
- $info_ori
324
- $del_row
325
- </div>
326
- eot;
327
-
328
- }
329
-
330
- /**
331
- * Get wp size info
332
- *
333
- * NOTE: this is not used because it has to be after admin_init
334
- *
335
- * @since 1.6.2
336
- * @access private
337
- * @return array $sizes Data for all currently-registered image sizes.
338
- */
339
- private function get_image_sizes() {
340
- global $_wp_additional_image_sizes ;
341
- $sizes = array();
342
-
343
- foreach ( get_intermediate_image_sizes() as $_size ) {
344
- if ( in_array( $_size, array( 'thumbnail', 'medium', 'medium_large', 'large' ) ) ) {
345
- $sizes[ $_size ][ 'width' ] = get_option( $_size . '_size_w' ) ;
346
- $sizes[ $_size ][ 'height' ] = get_option( $_size . '_size_h' ) ;
347
- $sizes[ $_size ][ 'crop' ] = (bool) get_option( $_size . '_crop' ) ;
348
- } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
349
- $sizes[ $_size ] = array(
350
- 'width' => $_wp_additional_image_sizes[ $_size ][ 'width' ],
351
- 'height' => $_wp_additional_image_sizes[ $_size ][ 'height' ],
352
- 'crop' => $_wp_additional_image_sizes[ $_size ][ 'crop' ]
353
- ) ;
354
- }
355
- }
356
-
357
- return $sizes ;
358
- }
359
-
360
-
361
- /**
362
- * Exclude role from optimization filter
363
- *
364
- * @since 1.6.2
365
- * @access public
366
- */
367
- private function webp_support()
368
- {
369
- if ( ! empty( $_SERVER[ 'HTTP_ACCEPT' ] ) && strpos( $_SERVER[ 'HTTP_ACCEPT' ], 'image/webp' ) !== false ) {
370
- return true ;
371
- }
372
-
373
- if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], 'Page Speed' ) !== false ) {
374
- return true ;
375
- }
376
-
377
- return false ;
378
- }
379
-
380
- /**
381
- * Run lazy load process
382
- * NOTE: As this is after cache finalized, can NOT set any cache control anymore
383
- *
384
- * Only do for main page. Do NOT do for esi or dynamic content.
385
- *
386
- * @since 1.4
387
- * @access public
388
- * @return string The buffer
389
- */
390
- public static function finalize( $content )
391
- {
392
- if ( defined( 'LITESPEED_NO_LAZY' ) ) {
393
- LiteSpeed_Cache_Log::debug2( '[Media] bypass: NO_LAZY const' ) ;
394
- return $content ;
395
- }
396
-
397
- if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
398
- LiteSpeed_Cache_Log::debug2( '[Media] bypass: Not frontend HTML type' ) ;
399
- return $content ;
400
- }
401
-
402
- LiteSpeed_Cache_Log::debug( '[Media] finalize' ) ;
403
-
404
- $instance = self::get_instance() ;
405
- $instance->content = $content ;
406
-
407
- $instance->_finalize() ;
408
- return $instance->content ;
409
- }
410
-
411
- /**
412
- * Run lazyload replacement for images in buffer
413
- *
414
- * @since 1.4
415
- * @access private
416
- */
417
- private function _finalize()
418
- {
419
- /**
420
- * Use webp for optimized images
421
- * @since 1.6.2
422
- */
423
- if ( $this->_cfg_img_webp && $this->webp_support() ) {
424
- $this->_replace_buffer_img_webp() ;
425
- }
426
-
427
- $cfg_img_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY ) ;
428
- $cfg_iframe_lazy = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IFRAME_LAZY ) ;
429
-
430
- if ( $cfg_img_lazy ) {
431
- list( $src_list, $html_list, $placeholder_list ) = $this->_parse_img() ;
432
- $html_list_ori = $html_list ;
433
- }
434
-
435
- // image lazy load
436
- if ( $cfg_img_lazy ) {
437
-
438
- $default_placeholder = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZY_PLACEHOLDER ) ?: LITESPEED_PLACEHOLDER ;
439
-
440
- foreach ( $html_list as $k => $v ) {
441
- $size = $placeholder_list[ $k ] ;
442
- // Check if need to enable responsive placeholder or not
443
- $this_placeholder = $this->_placeholder( $size ) ?: $default_placeholder ;
444
-
445
- $additional_attr = '' ;
446
- if ( $this_placeholder != $default_placeholder ) {
447
- LiteSpeed_Cache_Log::debug2( '[Media] Use resp placeholder [size] ' . $size ) ;
448
- $additional_attr = ' data-placeholder-resp="' . $size . '"' ;
449
- }
450
-
451
- $snippet = '<noscript>' . $v . '</noscript>' ;
452
- $v = str_replace( array( ' src=', ' srcset=', ' sizes=' ), array( ' data-src=', ' data-srcset=', ' data-sizes=' ), $v ) ;
453
- $v = str_replace( '<img ', '<img data-lazyloaded="1"' . $additional_attr . ' src="' . $this_placeholder . '" ', $v ) ;
454
- $snippet = $v . $snippet ;
455
-
456
- $html_list[ $k ] = $snippet ;
457
- }
458
- }
459
-
460
- if ( $cfg_img_lazy ) {
461
- $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
462
- }
463
-
464
- // iframe lazy load
465
- if ( $cfg_iframe_lazy ) {
466
- $html_list = $this->_parse_iframe() ;
467
- $html_list_ori = $html_list ;
468
-
469
- foreach ( $html_list as $k => $v ) {
470
- $snippet = '<noscript>' . $v . '</noscript>' ;
471
- $v = str_replace( ' src=', ' data-src=', $v ) ;
472
- $v = str_replace( '<iframe ', '<iframe data-lazyloaded="1" src="about:blank" ', $v ) ;
473
- $snippet = $v . $snippet ;
474
-
475
- $html_list[ $k ] = $snippet ;
476
- }
477
-
478
- $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
479
- }
480
-
481
- // Include lazyload lib js and init lazyload
482
- if ( $cfg_img_lazy || $cfg_iframe_lazy ) {
483
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZYJS_INLINE ) ) {
484
- $lazy_lib = '<script>' . Litespeed_File::read( LSCWP_DIR . self::LIB_FILE_IMG_LAZYLOAD ) . '</script>' ;
485
- } else {
486
- $lazy_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_IMG_LAZYLOAD ;
487
- $lazy_lib = '<script src="' . $lazy_lib_url . '"></script>' ;
488
- }
489
-
490
- $this->content = str_replace( '</body>', $lazy_lib . '</body>', $this->content ) ;
491
- }
492
- }
493
-
494
- /**
495
- * Generate responsive placeholder
496
- *
497
- * @since 2.5.1
498
- * @access private
499
- */
500
- private function _placeholder( $size )
501
- {
502
- if ( ! $size ) {
503
- return false ;
504
- }
505
-
506
- if ( ! $this->_cfg_placeholder_resp ) {
507
- return false ;
508
- }
509
-
510
- // Check if its already in dict or not
511
- if ( ! empty( $this->_placeholder_resp_dict[ $size ] ) ) {
512
- LiteSpeed_Cache_Log::debug2( '[Media] Resp placeholder already in dict [size] ' . $size ) ;
513
-
514
- return $this->_placeholder_resp_dict[ $size ] ;
515
- }
516
-
517
- // Need to generate the responsive placeholder
518
- $placeholder_realpath = $this->_placeholder_realpath( $size ) ;
519
- if ( file_exists( $placeholder_realpath ) ) {
520
- LiteSpeed_Cache_Log::debug2( '[Media] Resp placeholder file exists [size] ' . $size ) ;
521
- $this->_placeholder_resp_dict[ $size ] = Litespeed_File::read( $placeholder_realpath ) ;
522
-
523
- return $this->_placeholder_resp_dict[ $size ] ;
524
- }
525
-
526
- // Add to cron queue
527
-
528
- // Prevent repeated requests
529
- if ( in_array( $size, $this->_ph_queue ) ) {
530
- LiteSpeed_Cache_Log::debug2( '[Media] Resp placeholder file bypass generating due to in queue [size] ' . $size ) ;
531
- return false ;
532
- }
533
- $this->_ph_queue[] = $size ;
534
-
535
- $req_summary = self::get_summary() ;
536
-
537
- // Send request to generate placeholder
538
- if ( ! $this->_cfg_placeholder_resp_async ) {
539
- // If requested recently, bypass
540
- if ( $req_summary && ! empty( $req_summary[ 'curr_request' ] ) && time() - $req_summary[ 'curr_request' ] < 300 ) {
541
- LiteSpeed_Cache_Log::debug2( '[Media] Resp placeholder file bypass generating due to interval limit [size] ' . $size ) ;
542
- return false ;
543
- }
544
- // Generate immediately
545
- $this->_placeholder_resp_dict[ $size ] = $this->_generate_placeholder( $size ) ;
546
-
547
- return $this->_placeholder_resp_dict[ $size ] ;
548
- }
549
-
550
- // Store it to prepare for cron
551
- if ( empty( $req_summary[ 'queue' ] ) ) {
552
- $req_summary[ 'queue' ] = array() ;
553
- }
554
- if ( in_array( $size, $req_summary[ 'queue' ] ) ) {
555
- LiteSpeed_Cache_Log::debug2( '[Media] Resp placeholder already in queue [size] ' . $size ) ;
556
-
557
- return false ;
558
- }
559
-
560
- $req_summary[ 'queue' ][] = $size ;
561
-
562
- LiteSpeed_Cache_Log::debug( '[Media] Added placeholder queue [size] ' . $size ) ;
563
-
564
- $this->_save_summary( $req_summary ) ;
565
- return false ;
566
-
567
- }
568
-
569
- /**
570
- * Parse img src
571
- *
572
- * @since 1.4
573
- * @access private
574
- * @return array All the src & related raw html list
575
- */
576
- private function _parse_img()
577
- {
578
- /**
579
- * Exclude list
580
- * @since 1.5
581
- * @since 2.7.1 Changed to array
582
- */
583
- $excludes = apply_filters( 'litespeed_cache_media_lazy_img_excludes', LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ) ) ;
584
-
585
- $cls_excludes = apply_filters( 'litespeed_media_lazy_img_cls_excludes', LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_CLS_EXC ) ) ;
586
-
587
- $src_list = array() ;
588
- $html_list = array() ;
589
- $placeholder_list = array() ;
590
-
591
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
592
- preg_match_all( '#<img \s*([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER ) ;
593
- foreach ( $matches as $match ) {
594
- $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
595
-
596
- if ( empty( $attrs[ 'src' ] ) ) {
597
- continue ;
598
- }
599
-
600
- /**
601
- * Add src validation to bypass base64 img src
602
- * @since 1.6
603
- */
604
- if ( strpos( $attrs[ 'src' ], 'base64' ) !== false || substr( $attrs[ 'src' ], 0, 5 ) === 'data:' ) {
605
- LiteSpeed_Cache_Log::debug2( '[Media] lazyload bypassed base64 img' ) ;
606
- continue ;
607
- }
608
-
609
- LiteSpeed_Cache_Log::debug2( '[Media] lazyload found: ' . $attrs[ 'src' ] ) ;
610
-
611
- if ( ! empty( $attrs[ 'data-no-lazy' ] ) || ! empty( $attrs[ 'data-lazyloaded' ] ) || ! empty( $attrs[ 'data-src' ] ) || ! empty( $attrs[ 'data-srcset' ] ) ) {
612
- LiteSpeed_Cache_Log::debug2( '[Media] bypassed' ) ;
613
- continue ;
614
- }
615
-
616
- if ( ! empty( $attrs[ 'class' ] ) && $hit = LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'class' ], $cls_excludes ) ) {
617
- LiteSpeed_Cache_Log::debug2( '[Media] lazyload image cls excludes [hit] ' . $hit ) ;
618
- continue ;
619
- }
620
-
621
- /**
622
- * Exclude from lazyload by setting
623
- * @since 1.5
624
- */
625
- if ( $excludes && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'src' ], $excludes ) ) {
626
- LiteSpeed_Cache_Log::debug2( '[Media] lazyload image exclude ' . $attrs[ 'src' ] ) ;
627
- continue ;
628
- }
629
-
630
- /**
631
- * Excldues invalid image src from buddypress avatar crop
632
- * @see https://wordpress.org/support/topic/lazy-load-breaking-buddypress-upload-avatar-feature/#post-11040512
633
- * @since 2.9.1
634
- */
635
- if ( strpos( $attrs[ 'src' ], '{' ) !== false ) {
636
- LiteSpeed_Cache_Log::debug2( '[Media] image src has {} ' . $attrs[ 'src' ] ) ;
637
- continue ;
638
- }
639
-
640
- // to avoid multiple replacement
641
- if ( in_array( $match[ 0 ], $html_list ) ) {
642
- continue ;
643
- }
644
-
645
- $placeholder = false ;
646
- if ( ! empty( $attrs[ 'width' ] ) && ! empty( $attrs[ 'height' ] ) ) {
647
- $placeholder = $attrs[ 'width' ] . 'x' . $attrs[ 'height' ] ;
648
- }
649
-
650
- $src_list[] = $attrs[ 'src' ] ;
651
- $html_list[] = $match[ 0 ] ;
652
- $placeholder_list[] = $placeholder ;
653
- }
654
-
655
- return array( $src_list, $html_list, $placeholder_list ) ;
656
- }
657
-
658
- /**
659
- * Parse iframe src
660
- *
661
- * @since 1.4
662
- * @access private
663
- * @return array All the src & related raw html list
664
- */
665
- private function _parse_iframe()
666
- {
667
- $html_list = array() ;
668
-
669
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
670
- preg_match_all( '#<iframe \s*([^>]+)></iframe>#isU', $content, $matches, PREG_SET_ORDER ) ;
671
- foreach ( $matches as $match ) {
672
- $attrs = LiteSpeed_Cache_Utility::parse_attr( $match[ 1 ] ) ;
673
-
674
- if ( empty( $attrs[ 'src' ] ) ) {
675
- continue ;
676
- }
677
-
678
- LiteSpeed_Cache_Log::debug2( '[Media] found iframe: ' . $attrs[ 'src' ] ) ;
679
-
680
- if ( ! empty( $attrs[ 'data-no-lazy' ] ) || ! empty( $attrs[ 'data-lazyloaded' ] ) || ! empty( $attrs[ 'data-src' ] ) ) {
681
- LiteSpeed_Cache_Log::debug2( '[Media] bypassed' ) ;
682
- continue ;
683
- }
684
-
685
- // to avoid multiple replacement
686
- if ( in_array( $match[ 0 ], $html_list ) ) {
687
- continue ;
688
- }
689
-
690
- $html_list[] = $match[ 0 ] ;
691
- }
692
-
693
- return $html_list ;
694
- }
695
-
696
- /**
697
- * Replace image src to webp
698
- *
699
- * @since 1.6.2
700
- * @access private
701
- */
702
- private function _replace_buffer_img_webp()
703
- {
704
- // preg_match_all( '#<img([^>]+?)src=([\'"\\\]*)([^\'"\s\\\>]+)([\'"\\\]*)([^>]*)>#i', $this->content, $matches ) ;
705
- /**
706
- * Added custom element & attribute support
707
- * @since 2.2.2
708
- */
709
- $webp_ele_to_check = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ) ;
710
-
711
- foreach ( $webp_ele_to_check as $v ) {
712
- if ( ! $v || strpos( $v, '.' ) === false ) {
713
- LiteSpeed_Cache_Log::debug2( '[Media] buffer_webp no . attribute ' . $v ) ;
714
- continue ;
715
- }
716
-
717
- LiteSpeed_Cache_Log::debug2( '[Media] buffer_webp attribute ' . $v ) ;
718
-
719
- $v = explode( '.', $v ) ;
720
- $attr = preg_quote( $v[ 1 ], '#' ) ;
721
- if ( $v[ 0 ] ) {
722
- $pattern = '#<' . preg_quote( $v[ 0 ], '#' ) . '([^>]+)' . $attr . '=([\'"])(.+)\g{2}#iU' ;
723
- }
724
- else {
725
- $pattern = '# ' . $attr . '=([\'"])(.+)\g{1}#iU' ;
726
- }
727
-
728
- preg_match_all( $pattern, $this->content, $matches ) ;
729
-
730
- foreach ( $matches[ $v[ 0 ] ? 3 : 2 ] as $k2 => $url ) {
731
- // Check if is a DATA-URI
732
- if ( strpos( $url, 'data:image' ) !== false ) {
733
- continue ;
734
- }
735
-
736
- if ( ! $url2 = $this->replace_webp( $url ) ) {
737
- continue ;
738
- }
739
-
740
- if ( $v[ 0 ] ) {
741
- $html_snippet = sprintf(
742
- '<' . $v[ 0 ] . '%1$s' . $v[ 1 ] . '=%2$s',
743
- $matches[ 1 ][ $k2 ],
744
- $matches[ 2 ][ $k2 ] . $url2 . $matches[ 2 ][ $k2 ]
745
- ) ;
746
- }
747
- else {
748
- $html_snippet = sprintf(
749
- ' ' . $v[ 1 ] . '=%1$s',
750
- $matches[ 1 ][ $k2 ] . $url2 . $matches[ 1 ][ $k2 ]
751
- ) ;
752
- }
753
-
754
- $this->content = str_replace( $matches[ 0 ][ $k2 ], $html_snippet, $this->content ) ;
755
-
756
- }
757
- }
758
-
759
- // parse srcset
760
- // todo: should apply this to cdn too
761
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_WEBP_REPLACE_SRCSET ) ) {
762
- $this->content = LiteSpeed_Cache_Utility::srcset_replace( $this->content, array( $this, 'replace_webp' ) ) ;
763
- }
764
-
765
- // Replace background-image
766
- preg_match_all( '#background\-image:(\s*)url\((.*)\)#iU', $this->content, $matches ) ;
767
- foreach ( $matches[ 2 ] as $k => $url ) {
768
- // Check if is a DATA-URI
769
- if ( strpos( $url, 'data:image' ) !== false ) {
770
- continue ;
771
- }
772
-
773
- /**
774
- * Support quotes in src `background-image: url('src')`
775
- * @since 2.9.3
776
- */
777
- $url = trim( $url, '\'"' ) ;
778
-
779
- if ( ! $url2 = $this->replace_webp( $url ) ) {
780
- continue ;
781
- }
782
-
783
- // $html_snippet = sprintf( 'background-image:%1$surl(%2$s)', $matches[ 1 ][ $k ], $url2 ) ;
784
- $html_snippet = str_replace( $url, $url2, $matches[ 0 ][ $k ] ) ;
785
- $this->content = str_replace( $matches[ 0 ][ $k ], $html_snippet, $this->content ) ;
786
- }
787
- }
788
-
789
- /**
790
- * Hook to wp_get_attachment_image_src
791
- *
792
- * @since 1.6.2
793
- * @access public
794
- * @param array $img The URL of the attachment image src, the width, the height
795
- * @return array
796
- */
797
- public function webp_attach_img_src( $img )
798
- {
799
- LiteSpeed_Cache_Log::debug2( '[Media] changing attach src: ' . $img[0] ) ;
800
- if ( $img && $url = $this->replace_webp( $img[ 0 ] ) ) {
801
- $img[ 0 ] = $url ;
802
- }
803
- return $img ;
804
- }
805
-
806
- /**
807
- * Try to replace img url
808
- *
809
- * @since 1.6.2
810
- * @access public
811
- * @param string $url
812
- * @return string
813
- */
814
- public function webp_url( $url )
815
- {
816
- if ( $url && $url2 = $this->replace_webp( $url ) ) {
817
- $url = $url2 ;
818
- }
819
- return $url ;
820
- }
821
-
822
- /**
823
- * Hook to replace WP responsive images
824
- *
825
- * @since 1.6.2
826
- * @access public
827
- * @param array $srcs
828
- * @return array
829
- */
830
- public function webp_srcset( $srcs )
831
- {
832
- if ( $srcs ) {
833
- foreach ( $srcs as $w => $data ) {
834
- if( ! $url = $this->replace_webp( $data[ 'url' ] ) ) {
835
- continue ;
836
- }
837
- $srcs[ $w ][ 'url' ] = $url ;
838
- }
839
- }
840
- return $srcs ;
841
- }
842
-
843
- /**
844
- * Replace internal image src to webp
845
- *
846
- * @since 1.6.2
847
- * @access public
848
- */
849
- public function replace_webp( $url )
850
- {
851
- LiteSpeed_Cache_Log::debug2( '[Media] webp replacing: ' . $url, 4 ) ;
852
-
853
- if ( substr( $url, -5 ) == '.webp' ) {
854
- LiteSpeed_Cache_Log::debug2( '[Media] already webp' ) ;
855
- return false ;
856
- }
857
-
858
- /**
859
- * WebP API hook
860
- * NOTE: As $url may contain query strings, WebP check will need to parse_url before appending .webp
861
- * @since 2.9.5
862
- * @see #751737 - API docs for WEBP generation
863
- */
864
- if ( apply_filters( 'litespeed_media_check_ori', LiteSpeed_Cache_Utility::is_internal_file( $url ), $url ) ) {
865
- // check if has webp file
866
- if ( apply_filters( 'litespeed_media_check_webp', LiteSpeed_Cache_Utility::is_internal_file( $url, 'webp' ), $url ) ) {
867
- $url .= '.webp' ;
868
- }
869
- else {
870
- LiteSpeed_Cache_Log::debug2( '[Media] -no WebP file, bypassed' ) ;
871
- return false ;
872
- }
873
- }
874
- else {
875
- LiteSpeed_Cache_Log::debug2( '[Media] -no file, bypassed' ) ;
876
- return false ;
877
- }
878
-
879
- LiteSpeed_Cache_Log::debug2( '[Media] - replaced to: ' . $url ) ;
880
-
881
- return $url ;
882
- }
883
-
884
- /**
885
- * Check if there is a queue for cron or not
886
- *
887
- * @since 2.5.1
888
- * @access public
889
- */
890
- public static function has_queue()
891
- {
892
- $req_summary = self::get_summary() ;
893
- if ( ! empty( $req_summary[ 'queue' ] ) ) {
894
- return true ;
895
- }
896
-
897
- return false ;
898
- }
899
-
900
- /**
901
- * Check if there is a placeholder cache folder
902
- *
903
- * @since 2.5.1
904
- * @access public
905
- */
906
- public static function has_placehoder_cache()
907
- {
908
- return is_dir( LSCWP_CONTENT_DIR . '/cache/placeholder' ) ;
909
- }
910
-
911
- /**
912
- * Save image placeholder summary
913
- *
914
- * @since 2.5.1
915
- * @access private
916
- */
917
- private function _save_summary( $data )
918
- {
919
- update_option( self::DB_PLACEHOLDER_SUMMARY, $data ) ;
920
- }
921
-
922
- /**
923
- * Read last time generated info
924
- *
925
- * @since 2.5.1
926
- * @access public
927
- */
928
- public static function get_summary()
929
- {
930
- return get_option( self::DB_PLACEHOLDER_SUMMARY, array() ) ;
931
- }
932
-
933
- /**
934
- * Generate realpath of placeholder file
935
- *
936
- * @since 2.5.1
937
- * @access private
938
- */
939
- private function _placeholder_realpath( $size )
940
- {
941
- return LSCWP_CONTENT_DIR . "/cache/placeholder/$size." . md5( $this->_cfg_placeholder_resp_color ) ;
942
- }
943
-
944
- /**
945
- * Delete file-based cache folder
946
- *
947
- * @since 2.5.1
948
- * @access public
949
- */
950
- public function rm_cache_folder()
951
- {
952
- if ( file_exists( LSCWP_CONTENT_DIR . '/cache/placeholder' ) ) {
953
- Litespeed_File::rrmdir( LSCWP_CONTENT_DIR . '/cache/placeholder' ) ;
954
- }
955
-
956
- // Clear placeholder in queue too
957
- $this->_save_summary( array() ) ;
958
-
959
- LiteSpeed_Cache_Log::debug2( '[Media] Cleared placeholder queue' ) ;
960
- }
961
-
962
- /**
963
- * Cron placeholder generation
964
- *
965
- * @since 2.5.1
966
- * @access public
967
- */
968
- public static function cron_placeholder( $continue = false )
969
- {
970
- $req_summary = self::get_summary() ;
971
- if ( empty( $req_summary[ 'queue' ] ) ) {
972
- return ;
973
- }
974
-
975
- // For cron, need to check request interval too
976
- if ( ! $continue ) {
977
- if ( $req_summary && ! empty( $req_summary[ 'curr_request' ] ) && time() - $req_summary[ 'curr_request' ] < 300 ) {
978
- return ;
979
- }
980
- }
981
-
982
- foreach ( $req_summary[ 'queue' ] as $v ) {
983
- LiteSpeed_Cache_Log::debug( '[Media] cron job [size] ' . $v ) ;
984
-
985
- self::get_instance()->_generate_placeholder( $v ) ;
986
-
987
- // only request first one
988
- if ( ! $continue ) {
989
- return ;
990
- }
991
- }
992
- }
993
-
994
- /**
995
- * Send to LiteSpeed API to generate placeholder
996
- *
997
- * @since 2.5.1
998
- * @access private
999
- */
1000
- private function _generate_placeholder( $size )
1001
- {
1002
- $req_summary = self::get_summary() ;
1003
-
1004
- $file = $this->_placeholder_realpath( $size ) ;
1005
-
1006
- // Update request status
1007
- $req_summary[ 'curr_request' ] = time() ;
1008
- $this->_save_summary( $req_summary ) ;
1009
-
1010
- // Generate placeholder
1011
- $req_data = array(
1012
- 'size' => $size,
1013
- 'color' => $this->_cfg_placeholder_resp_color,
1014
- ) ;
1015
- $data = LiteSpeed_Cache_Admin_API::get( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PLACEHOLDER, $req_data, true ) ;
1016
-
1017
- LiteSpeed_Cache_Log::debug( '[Media] _generate_placeholder ' ) ;
1018
-
1019
- if ( strpos( $data, 'data:image/png;base64,' ) !== 0 ) {
1020
- LiteSpeed_Cache_Log::debug( '[Media] failed to decode response: ' . $data ) ;
1021
- return false ;
1022
- }
1023
-
1024
- // Write to file
1025
- Litespeed_File::save( $file, $data, true ) ;
1026
-
1027
- // Save summary data
1028
- $req_summary[ 'last_spent' ] = time() - $req_summary[ 'curr_request' ] ;
1029
- $req_summary[ 'last_request' ] = $req_summary[ 'curr_request' ] ;
1030
- $req_summary[ 'curr_request' ] = 0 ;
1031
- if ( ! empty( $req_summary[ 'queue' ] ) && in_array( $size, $req_summary[ 'queue' ] ) ) {
1032
- unset( $req_summary[ 'queue' ][ array_search( $size, $req_summary[ 'queue' ] ) ] ) ;
1033
- }
1034
-
1035
- $this->_save_summary( $req_summary ) ;
1036
-
1037
- LiteSpeed_Cache_Log::debug( '[Media] saved placeholder ' . $file ) ;
1038
-
1039
- LiteSpeed_Cache_Log::debug2( '[Media] placeholder con: ' . $data ) ;
1040
-
1041
- return $data ;
1042
- }
1043
-
1044
- /**
1045
- * Handle all request actions from main cls
1046
- *
1047
- * @since 2.5.1
1048
- * @access public
1049
- */
1050
- public static function handler()
1051
- {
1052
- $instance = self::get_instance() ;
1053
-
1054
- $type = LiteSpeed_Cache_Router::verify_type() ;
1055
-
1056
- switch ( $type ) {
1057
- case self::TYPE_GENERATE_PLACEHOLDER :
1058
- self::cron_placeholder( true ) ;
1059
- break ;
1060
-
1061
- default:
1062
- break ;
1063
- }
1064
-
1065
- LiteSpeed_Cache_Admin::redirect() ;
1066
- }
1067
-
1068
- /**
1069
- * Get the current instance object.
1070
- *
1071
- * @since 1.4
1072
- * @access public
1073
- * @return Current class instance.
1074
- */
1075
- public static function get_instance()
1076
- {
1077
- if ( ! isset( self::$_instance ) ) {
1078
- self::$_instance = new self() ;
1079
- }
1080
-
1081
- return self::$_instance ;
1082
- }
1083
-
1084
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/object.lib.php CHANGED
@@ -1,655 +1,3 @@
1
  <?php
2
- /**
3
- * LiteSpeed Object Cache Library
4
- *
5
- * @since 1.8
6
- */
7
 
8
- if ( ! defined( 'WPINC' ) ) {
9
- die ;
10
- }
11
-
12
- require_once dirname( __FILE__ ) . '/object.class.php' ;
13
-
14
- /**
15
- * Sets up Object Cache Global and assigns it.
16
- *
17
- * @since 1.8
18
- */
19
- function wp_cache_init()
20
- {
21
- $GLOBALS['wp_object_cache'] = WP_Object_Cache::get_instance();
22
- }
23
-
24
- /**
25
- * Retrieves the cache contents from the cache by key and group.
26
- *
27
- * @since 1.8
28
- */
29
- function wp_cache_get( $key, $group = '', $force = false, &$found = null )
30
- {
31
- global $wp_object_cache ;
32
-
33
- return $wp_object_cache->get( $key, $group, $force, $found ) ;
34
- }
35
-
36
- /**
37
- * Saves the data to the cache.
38
- *
39
- * @since 1.8
40
- */
41
- function wp_cache_set( $key, $data, $group = '', $expire = 0 )
42
- {
43
- global $wp_object_cache ;
44
-
45
- return $wp_object_cache->set( $key, $data, $group, $expire ) ;
46
- }
47
-
48
- /**
49
- * Adds data to the cache, if the cache key doesn't already exist.
50
- *
51
- * @since 1.8
52
- */
53
- function wp_cache_add( $key, $data, $group = '', $expire = 0 )
54
- {
55
- global $wp_object_cache ;
56
-
57
- return $wp_object_cache->add( $key, $data, $group, $expire ) ;
58
- }
59
-
60
- /**
61
- * Replaces the contents of the cache with new data.
62
- *
63
- * @since 1.8
64
- */
65
- function wp_cache_replace( $key, $data, $group = '', $expire = 0 )
66
- {
67
- global $wp_object_cache ;
68
-
69
- return $wp_object_cache->replace( $key, $data, $group, $expire ) ;
70
- }
71
-
72
- /**
73
- * Increment numeric cache item's value
74
- *
75
- * @since 1.8
76
- */
77
- function wp_cache_incr( $key, $offset = 1, $group = '' )
78
- {
79
- global $wp_object_cache ;
80
-
81
- return $wp_object_cache->incr_desr( $key, $offset, $group ) ;
82
- }
83
-
84
- /**
85
- * Decrements numeric cache item's value.
86
- *
87
- * @since 1.8
88
- */
89
- function wp_cache_decr( $key, $offset = 1, $group = '' )
90
- {
91
- global $wp_object_cache ;
92
-
93
- return $wp_object_cache->incr_desr( $key, $offset, $group, false ) ;
94
- }
95
-
96
- /**
97
- * Removes the cache contents matching key and group.
98
- *
99
- * @since 1.8
100
- */
101
- function wp_cache_delete( $key, $group = '' )
102
- {
103
- global $wp_object_cache ;
104
-
105
- return $wp_object_cache->delete( $key, $group ) ;
106
- }
107
-
108
- /**
109
- * Removes all cache items.
110
- *
111
- * @since 1.8
112
- */
113
- function wp_cache_flush()
114
- {
115
- global $wp_object_cache ;
116
-
117
- return $wp_object_cache->flush() ;
118
- }
119
-
120
- /**
121
- * Adds a group or set of groups to the list of global groups.
122
- *
123
- * @since 1.8
124
- */
125
- function wp_cache_add_global_groups( $groups )
126
- {
127
- global $wp_object_cache ;
128
-
129
- $wp_object_cache->add_global_groups( $groups ) ;
130
- }
131
-
132
- /**
133
- * Adds a group or set of groups to the list of non-persistent groups.
134
- *
135
- * @since 1.8
136
- */
137
- function wp_cache_add_non_persistent_groups( $groups )
138
- {
139
- global $wp_object_cache ;
140
-
141
- $wp_object_cache->add_non_persistent_groups( $groups ) ;
142
- }
143
-
144
- /**
145
- * Switches the internal blog ID.
146
- *
147
- * This changes the blog id used to create keys in blog specific groups.
148
- *
149
- * @since 1.8
150
- *
151
- * @see WP_Object_Cache::switch_to_blog()
152
- * @global WP_Object_Cache $wp_object_cache Object cache global instance.
153
- *
154
- * @param int $blog_id Site ID.
155
- */
156
- function wp_cache_switch_to_blog( $blog_id ) {
157
- global $wp_object_cache ;
158
-
159
- $wp_object_cache->switch_to_blog( $blog_id ) ;
160
- }
161
-
162
- /**
163
- * Closes the cache.
164
- *
165
- * @since 1.8
166
- */
167
- function wp_cache_close()
168
- {
169
- return true ;
170
- }
171
-
172
-
173
-
174
- class WP_Object_Cache
175
- {
176
- private static $_instance ;
177
-
178
- private $_object_cache ;
179
-
180
- private $_cache = array() ;
181
- private $_cache_404 = array() ;
182
-
183
- private $cache_total = 0 ;
184
- private $count_hit_incall = 0 ;
185
- private $count_hit = 0 ;
186
- private $count_miss_incall = 0 ;
187
- private $count_miss = 0 ;
188
- private $count_set = 0 ;
189
-
190
- private $blog_prefix ;
191
-
192
- /**
193
- * Init
194
- *
195
- * @since 1.8
196
- * @access private
197
- */
198
- private function __construct()
199
- {
200
- $this->_object_cache = LiteSpeed_Cache_Object::get_instance() ;
201
-
202
- $this->multisite = is_multisite() ;
203
- $this->blog_prefix = $this->multisite ? get_current_blog_id() . ':' : '' ;
204
-
205
- /**
206
- * Fix multiple instance using same oc issue
207
- * @since 1.8.2
208
- */
209
- ! defined( 'LSOC_PREFIX' ) && define( 'LSOC_PREFIX', substr( md5( __FILE__ ), -5 ) ) ;
210
- }
211
-
212
- /**
213
- * Output debug info
214
- *
215
- * @since 1.8
216
- * @access public
217
- */
218
- public function debug()
219
- {
220
- $log = ' [total] ' . $this->cache_total
221
- . ' [hit_incall] ' . $this->count_hit_incall
222
- . ' [hit] ' . $this->count_hit
223
- . ' [miss_incall] ' . $this->count_miss_incall
224
- . ' [miss] ' . $this->count_miss
225
- . ' [set] ' . $this->count_set ;
226
-
227
- return $log ;
228
- }
229
-
230
- /**
231
- * Get from cache
232
- *
233
- * @since 1.8
234
- * @access public
235
- */
236
- public function get( $key, $group = 'default', $force = false, &$found = null )
237
- {
238
- $final_key = $this->_key( $key, $group ) ;
239
- // error_log('');
240
- // error_log("oc: get \t\t\t[key] " . $final_key . ( $force ? "\t\t\t [forced] " : '' ) );
241
- $found = false ;
242
- $found_in_oc = false ;
243
- $cache_val = false ;
244
- if ( array_key_exists( $final_key, $this->_cache ) && ! $force ) {
245
- $found = true ;
246
- $cache_val = $this->_cache[ $final_key ] ;
247
- $this->count_hit_incall ++ ;
248
- }
249
- elseif ( ! array_key_exists( $final_key, $this->_cache_404 ) && ! $this->_object_cache->is_non_persistent( $group ) ) {
250
- $v = $this->_object_cache->get( $final_key ) ;
251
-
252
- if ( $v !== null ) {
253
- $v = @maybe_unserialize( $v ) ;
254
- }
255
-
256
- // To be compatible with false val
257
- if ( is_array( $v ) && array_key_exists( 'data', $v ) ) {
258
- $this->count_hit ++ ;
259
- $found = true ;
260
- $found_in_oc = true ;
261
- $cache_val = $v[ 'data' ] ;
262
- }
263
- else { // Can't find key, cache it to 404
264
- // error_log("oc: add404\t\t\t[key] " . $final_key ) ;
265
- $this->_cache_404[ $final_key ] = 1 ;
266
- $this->count_miss ++ ;
267
- }
268
- }
269
- else {
270
- $this->count_miss_incall ++ ;
271
- }
272
-
273
- if ( is_object( $cache_val ) ) {
274
- $cache_val = clone $cache_val ;
275
- }
276
-
277
- // If not found but has `Store Transients` cfg on, still need to follow WP's get_transient() logic
278
- if ( ! $found && $this->_object_cache->store_transients( $group ) ) {
279
- $cache_val = $this->_transient_get( $key, $group ) ;
280
- if ( $cache_val ) {
281
- $found = true ; // $found not used for now (v1.8.3)
282
- }
283
- }
284
-
285
- if ( $found_in_oc ) {
286
- $this->_cache[ $final_key ] = $cache_val ;
287
- }
288
-
289
- $this->cache_total ++ ;
290
-
291
- return $cache_val ;
292
- }
293
-
294
- /**
295
- * Set to cache
296
- *
297
- * @since 1.8
298
- * @access public
299
- */
300
- public function set( $key, $data, $group = 'default', $expire = 0 )
301
- {
302
- $final_key = $this->_key( $key, $group ) ;
303
-
304
- if ( is_object( $data ) ) {
305
- $data = clone $data ;
306
- }
307
- // error_log("oc: set \t\t\t[key] " . $final_key ) ;
308
- $this->_cache[ $final_key ] = $data ;
309
-
310
- if( array_key_exists( $final_key, $this->_cache_404 ) ) {
311
- // error_log("oc: unset404\t\t\t[key] " . $final_key ) ;
312
- unset( $this->_cache_404[ $final_key ] ) ;
313
- }
314
-
315
- if ( ! $this->_object_cache->is_non_persistent( $group ) ) {
316
- $this->_object_cache->set( $final_key, serialize( array( 'data' => $data ) ), $expire ) ;
317
- $this->count_set ++ ;
318
- }
319
-
320
- if ( $this->_object_cache->store_transients( $group ) ) {
321
- $this->_transient_set( $key, $data, $group, $expire ) ;
322
- }
323
-
324
- return true ;
325
- }
326
-
327
- /**
328
- * Adds data to the cache if it doesn't already exist.
329
- *
330
- * @since 1.8
331
- * @access public
332
- */
333
- public function add( $key, $data, $group = 'default', $expire = 0 )
334
- {
335
- if ( wp_suspend_cache_addition() ) {
336
- return false ;
337
- }
338
-
339
- $final_key = $this->_key( $key, $group ) ;
340
-
341
- if ( array_key_exists( $final_key, $this->_cache ) ) {
342
- return false ;
343
- }
344
-
345
- return $this->set( $key, $data, $group, $expire ) ;
346
- }
347
-
348
- /**
349
- * Replace cache if the cache key exists.
350
- *
351
- * @since 1.8
352
- * @access public
353
- */
354
- public function replace( $key, $data, $group = 'default', $expire = 0 )
355
- {
356
- $final_key = $this->_key( $key, $group ) ;
357
-
358
- if ( ! array_key_exists( $final_key, $this->_cache ) ) {
359
- return false ;
360
- }
361
-
362
- return $this->set( $key, $data, $group, $expire ) ;
363
- }
364
-
365
- /**
366
- * Increments numeric cache item's value.
367
- *
368
- * @since 1.8
369
- * @access public
370
- */
371
- public function incr_desr( $key, $offset = 1, $group = 'default', $incr = true )
372
- {
373
- $cache_val = $this->get( $key, $group ) ;
374
-
375
- if ( $cache_val === false ) {
376
- return false ;
377
- }
378
-
379
- if ( ! is_numeric( $cache_val ) ) {
380
- $cache_val = 0 ;
381
- }
382
-
383
- $offset = (int) $offset ;
384
-
385
- if ( $incr ) {
386
- $cache_val += $offset ;
387
- }
388
- else {
389
- $cache_val -= $offset ;
390
- }
391
-
392
- if ( $cache_val < 0 ) {
393
- $cache_val = 0 ;
394
- }
395
-
396
- $this->set( $key, $cache_val, $group ) ;
397
-
398
- return $cache_val ;
399
- }
400
-
401
- /**
402
- * Delete cache
403
- *
404
- * @since 1.8
405
- * @access public
406
- */
407
- public function delete( $key, $group = 'default' )
408
- {
409
-
410
- $final_key = $this->_key( $key, $group ) ;
411
-
412
- if ( $this->_object_cache->store_transients( $group ) ) {
413
- $this->_transient_del( $key, $group ) ;
414
- }
415
-
416
- if ( array_key_exists( $final_key, $this->_cache ) ) {
417
- unset( $this->_cache[ $final_key ] ) ;
418
- }
419
- // error_log("oc: delete \t\t\t[key] " . $final_key ) ;
420
-
421
- if ( $this->_object_cache->is_non_persistent( $group ) ) {
422
- return false ;
423
- }
424
-
425
- return $this->_object_cache->delete( $final_key ) ;
426
- }
427
-
428
- /**
429
- * Clear all cached data
430
- *
431
- * @since 1.8
432
- * @access public
433
- */
434
- public function flush()
435
- {
436
- $this->_cache = array() ;
437
- $this->_cache_404 = array() ;
438
- // error_log("oc: flush " ) ;
439
-
440
- $this->_object_cache->flush() ;
441
-
442
- return true ;
443
- }
444
-
445
- /**
446
- * Add global groups
447
- *
448
- * @since 1.8
449
- * @access public
450
- */
451
- public function add_global_groups( $groups )
452
- {
453
- $this->_object_cache->add_global_groups( $groups ) ;
454
- }
455
-
456
- /**
457
- * Add non persistent groups
458
- *
459
- * @since 1.8
460
- * @access public
461
- */
462
- public function add_non_persistent_groups( $groups )
463
- {
464
- $this->_object_cache->add_non_persistent_groups( $groups ) ;
465
- }
466
-
467
- /**
468
- * Get the final key
469
- *
470
- * @since 1.8
471
- * @access private
472
- */
473
- private function _key( $key, $group = 'default' )
474
- {
475
- $prefix = $this->_object_cache->is_global( $group ) ? '' : $this->blog_prefix ;
476
-
477
- return LSOC_PREFIX . $prefix . $group . '.' . $key ;
478
- }
479
-
480
- /**
481
- * Switches the internal blog ID.
482
- *
483
- * This changes the blog ID used to create keys in blog specific groups.
484
- *
485
- * @since 1.8
486
- *
487
- * @param int $blog_id Blog ID.
488
- */
489
- public function switch_to_blog( $blog_id ) {
490
- $blog_id = (int) $blog_id ;
491
- $this->blog_prefix = $this->multisite ? $blog_id . ':' : '' ;
492
- }
493
-
494
- /**
495
- * Get transient from wp table
496
- *
497
- * @since 1.8.3
498
- * @access private
499
- * @see `wp-includes/option.php` function `get_transient`/`set_site_transient`
500
- */
501
- private function _transient_get( $transient, $group )
502
- {
503
- if ( $group == 'transient' ) {
504
- /**** Ori WP func start ****/
505
- $transient_option = '_transient_' . $transient;
506
- if ( ! wp_installing() ) {
507
- // If option is not in alloptions, it is not autoloaded and thus has a timeout
508
- $alloptions = wp_load_alloptions();
509
- if ( !isset( $alloptions[$transient_option] ) ) {
510
- $transient_timeout = '_transient_timeout_' . $transient;
511
- $timeout = get_option( $transient_timeout );
512
- if ( false !== $timeout && $timeout < time() ) {
513
- delete_option( $transient_option );
514
- delete_option( $transient_timeout );
515
- $value = false;
516
- }
517
- }
518
- }
519
-
520
- if ( ! isset( $value ) )
521
- $value = get_option( $transient_option );
522
- /**** Ori WP func end ****/
523
- }
524
- elseif ( $group == 'site-transient' ) {
525
- /**** Ori WP func start ****/
526
- $no_timeout = array('update_core', 'update_plugins', 'update_themes');
527
- $transient_option = '_site_transient_' . $transient;
528
- if ( ! in_array( $transient, $no_timeout ) ) {
529
- $transient_timeout = '_site_transient_timeout_' . $transient;
530
- $timeout = get_site_option( $transient_timeout );
531
- if ( false !== $timeout && $timeout < time() ) {
532
- delete_site_option( $transient_option );
533
- delete_site_option( $transient_timeout );
534
- $value = false;
535
- }
536
- }
537
-
538
- if ( ! isset( $value ) )
539
- $value = get_site_option( $transient_option );
540
- /**** Ori WP func end ****/
541
- }
542
- else {
543
- $value = false ;
544
- }
545
-
546
- return $value ;
547
- }
548
-
549
- /**
550
- * Set transient to WP table
551
- *
552
- * @since 1.8.3
553
- * @access private
554
- * @see `wp-includes/option.php` function `set_transient`/`set_site_transient`
555
- */
556
- private function _transient_set( $transient, $value, $group, $expiration )
557
- {
558
- if ( $group == 'transient' ) {
559
- /**** Ori WP func start ****/
560
- $transient_timeout = '_transient_timeout_' . $transient;
561
- $transient_option = '_transient_' . $transient;
562
- if ( false === get_option( $transient_option ) ) {
563
- $autoload = 'yes';
564
- if ( $expiration ) {
565
- $autoload = 'no';
566
- add_option( $transient_timeout, time() + $expiration, '', 'no' );
567
- }
568
- $result = add_option( $transient_option, $value, '', $autoload );
569
- } else {
570
- // If expiration is requested, but the transient has no timeout option,
571
- // delete, then re-create transient rather than update.
572
- $update = true;
573
- if ( $expiration ) {
574
- if ( false === get_option( $transient_timeout ) ) {
575
- delete_option( $transient_option );
576
- add_option( $transient_timeout, time() + $expiration, '', 'no' );
577
- $result = add_option( $transient_option, $value, '', 'no' );
578
- $update = false;
579
- } else {
580
- update_option( $transient_timeout, time() + $expiration );
581
- }
582
- }
583
- if ( $update ) {
584
- $result = update_option( $transient_option, $value );
585
- }
586
- }
587
- /**** Ori WP func end ****/
588
- }
589
- elseif ( $group == 'site-transient' ) {
590
- /**** Ori WP func start ****/
591
- $transient_timeout = '_site_transient_timeout_' . $transient;
592
- $option = '_site_transient_' . $transient;
593
- if ( false === get_site_option( $option ) ) {
594
- if ( $expiration )
595
- add_site_option( $transient_timeout, time() + $expiration );
596
- $result = add_site_option( $option, $value );
597
- } else {
598
- if ( $expiration )
599
- update_site_option( $transient_timeout, time() + $expiration );
600
- $result = update_site_option( $option, $value );
601
- }
602
- /**** Ori WP func end ****/
603
- }
604
- else {
605
- $result = null ;
606
- }
607
-
608
- return $result ;
609
- }
610
-
611
- /**
612
- * Delete transient from WP table
613
- *
614
- * @since 1.8.3
615
- * @access private
616
- * @see `wp-includes/option.php` function `delete_transient`/`delete_site_transient`
617
- */
618
- private function _transient_del( $transient, $group )
619
- {
620
- if ( $group == 'transient' ) {
621
- /**** Ori WP func start ****/
622
- $option_timeout = '_transient_timeout_' . $transient;
623
- $option = '_transient_' . $transient;
624
- $result = delete_option( $option );
625
- if ( $result )
626
- delete_option( $option_timeout );
627
- /**** Ori WP func end ****/
628
- }
629
- elseif ( $group == 'site-transient' ) {
630
- /**** Ori WP func start ****/
631
- $option_timeout = '_site_transient_timeout_' . $transient;
632
- $option = '_site_transient_' . $transient;
633
- $result = delete_site_option( $option );
634
- if ( $result )
635
- delete_site_option( $option_timeout );
636
- /**** Ori WP func end ****/
637
- }
638
- }
639
-
640
- /**
641
- * Get the current instance object.
642
- *
643
- * @since 1.8
644
- * @access public
645
- * @return Current class instance.
646
- */
647
- public static function get_instance()
648
- {
649
- if ( ! isset( self::$_instance ) ) {
650
- self::$_instance = new self() ;
651
- }
652
-
653
- return self::$_instance ;
654
- }
655
- }
1
  <?php
 
 
 
 
 
2
 
3
+ // A compatibility placeholder for v2.9.9- when upgrading to v3 require_once $lscwp_dir . 'inc/object.lib.php' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/purge.class.php DELETED
@@ -1,1051 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin purge class for X-LiteSpeed-Purge
4
- *
5
- * @since 1.1.3
6
- * @since 1.5 Moved into /inc
7
- * @since 2.2 Refactored. Changed access from public to private for most func and class variables.
8
- */
9
-
10
- if ( ! defined( 'WPINC' ) ) {
11
- die ;
12
- }
13
-
14
- class LiteSpeed_Cache_Purge
15
- {
16
- private static $_instance ;
17
- protected $_pub_purge = array() ;
18
- protected $_priv_purge = array() ;
19
- protected $_purge_related = false ;
20
- protected $_purge_single = false ;
21
-
22
- const X_HEADER = 'X-LiteSpeed-Purge' ;
23
- const PURGE_QUEUE = 'litespeed-cache-purge-queue' ;
24
-
25
- const TYPE_PURGE_ALL = 'purge_all' ;
26
- const TYPE_PURGE_ALL_LSCACHE = 'purge_all_lscache' ;
27
- const TYPE_PURGE_ALL_CSSJS = 'purge_all_cssjs' ;
28
- const TYPE_PURGE_ALL_CCSS = 'purge_all_ccss' ;
29
- const TYPE_PURGE_ALL_PLACEHOLDER = 'purge_all_placeholder' ;
30
- const TYPE_PURGE_ALL_OBJECT = 'purge_all_object' ;
31
- const TYPE_PURGE_ALL_OPCACHE = 'purge_all_opcache' ;
32
-
33
- const TYPE_PURGE_FRONT = 'purge_front' ;
34
- const TYPE_PURGE_FRONTPAGE = 'purge_frontpage' ;
35
- const TYPE_PURGE_PAGES = 'purge_pages' ;
36
- const TYPE_PURGE_ERROR = 'purge_error' ;
37
-
38
- /**
39
- * Initialize
40
- *
41
- * @since 2.2.3
42
- */
43
- private function __construct()
44
- {
45
- //register purge actions
46
- $purge_post_events = array(
47
- 'edit_post',
48
- 'save_post',
49
- 'deleted_post',
50
- 'trashed_post',
51
- 'delete_attachment',
52
- // 'clean_post_cache', // This will disable wc's not purge product when stock status not change setting
53
- ) ;
54
- foreach ( $purge_post_events as $event ) {
55
- // this will purge all related tags
56
- add_action( $event, 'LiteSpeed_Cache_Purge::purge_post', 10, 2 ) ;
57
- }
58
-
59
- add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_feeds' ) ;
60
-
61
- }
62
-
63
- /**
64
- * Handle all request actions from main cls
65
- *
66
- * @since 1.8
67
- * @access public
68
- */
69
- public static function handler()
70
- {
71
- $instance = self::get_instance() ;
72
-
73
- $type = LiteSpeed_Cache_Router::verify_type() ;
74
-
75
- switch ( $type ) {
76
- case self::TYPE_PURGE_ALL :
77
- $instance->_purge_all() ;
78
- break ;
79
-
80
- case self::TYPE_PURGE_ALL_LSCACHE :
81
- $instance->_purge_all_lscache() ;
82
- break ;
83
-
84
- case self::TYPE_PURGE_ALL_CSSJS :
85
- $instance->_purge_all_cssjs() ;
86
- break ;
87
-
88
- case self::TYPE_PURGE_ALL_CCSS :
89
- $instance->_purge_all_ccss() ;
90
- break ;
91
-
92
- case self::TYPE_PURGE_ALL_PLACEHOLDER :
93
- $instance->_purge_all_placeholder() ;
94
- break ;
95
-
96
- case self::TYPE_PURGE_ALL_OBJECT :
97
- $instance->_purge_all_object() ;
98
- break ;
99
-
100
- case self::TYPE_PURGE_ALL_OPCACHE :
101
- $instance->_purge_all_opcache() ;
102
- break ;
103
-
104
- case self::TYPE_PURGE_FRONT :
105
- $instance->_purge_front() ;
106
- break ;
107
-
108
- case self::TYPE_PURGE_FRONTPAGE :
109
- $instance->_purge_frontpage() ;
110
- break ;
111
-
112
- case self::TYPE_PURGE_PAGES :
113
- $instance->_purge_pages() ;
114
- break ;
115
-
116
- case strpos( $type, self::TYPE_PURGE_ERROR ) === 0 :
117
- $instance->_purge_error( substr( $type, strlen( self::TYPE_PURGE_ERROR ) ) ) ;
118
- break ;
119
-
120
- default:
121
- break ;
122
- }
123
-
124
- LiteSpeed_Cache_Admin::redirect() ;
125
- }
126
-
127
- /**
128
- * Shortcut to purge all lscache
129
- *
130
- * @since 1.0.0
131
- * @access public
132
- */
133
- public static function purge_all( $reason = false )
134
- {
135
- self::get_instance()->_purge_all( $reason ) ;
136
- }
137
-
138
- /**
139
- * Purge all caches (lscache/op/oc)
140
- *
141
- * @since 2.2
142
- * @access private
143
- */
144
- private function _purge_all( $reason = false )
145
- {
146
- $this->_purge_all_lscache( true ) ;
147
- $this->_purge_all_cssjs( true ) ;
148
- // $this->_purge_all_ccss( true ) ;
149
- // $this->_purge_all_placeholder( true ) ;
150
- $this->_purge_all_object( true ) ;
151
- $this->_purge_all_opcache( true ) ;
152
-
153
- if ( ! is_string( $reason ) ) {
154
- $reason = false ;
155
- }
156
-
157
- if ( $reason ) {
158
- $reason = "( $reason )" ;
159
- }
160
-
161
- LiteSpeed_Cache_Log::debug( '[Purge] Purge all ' . $reason, 3 ) ;
162
-
163
- $msg = __( 'Purged all caches successfully.', 'litespeed-cache' ) ;
164
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
165
- }
166
-
167
- /**
168
- * Alerts LiteSpeed Web Server to purge all pages.
169
- *
170
- * For multisite installs, if this is called by a site admin (not network admin),
171
- * it will only purge all posts associated with that site.
172
- *
173
- * @since 2.2
174
- * @access public
175
- */
176
- private function _purge_all_lscache( $silence = false )
177
- {
178
- $this->_add( '*' ) ;
179
-
180
- // check if need to reset crawler
181
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) ) {
182
- LiteSpeed_Cache_Crawler::get_instance()->reset_pos() ;
183
- }
184
-
185
- if ( ! $silence ) {
186
- $msg = __( 'Notified LiteSpeed Web Server to purge all LSCache entries.', 'litespeed-cache' ) ;
187
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
188
- }
189
- }
190
-
191
- /**
192
- * Delete all critical css
193
- *
194
- * @since 2.3
195
- * @access private
196
- */
197
- private function _purge_all_ccss( $silence = false )
198
- {
199
- LiteSpeed_Cache_CSS::get_instance()->rm_cache_folder() ;
200
-
201
- if ( ! $silence ) {
202
- $msg = __( 'Cleaned all critical CSS files.', 'litespeed-cache' ) ;
203
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
204
- }
205
- }
206
-
207
- /**
208
- * Delete all placeholder images
209
- *
210
- * @since 2.5.1
211
- * @access private
212
- */
213
- private function _purge_all_placeholder( $silence = false )
214
- {
215
- LiteSpeed_Cache_Media::get_instance()->rm_cache_folder() ;
216
-
217
- if ( ! $silence ) {
218
- $msg = __( 'Cleaned all placeholder files.', 'litespeed-cache' ) ;
219
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
220
- }
221
- }
222
-
223
- /**
224
- * Alerts LiteSpeed Web Server to purge pages.
225
- *
226
- * @since 1.2.2
227
- * @access private
228
- */
229
- private function _purge_all_cssjs( $silence = false )
230
- {
231
- update_option( LiteSpeed_Cache_Config::ITEM_TIMESTAMP_PURGE_CSS, time() ) ;
232
-
233
- $this->_add( LiteSpeed_Cache_Tag::TYPE_MIN ) ;
234
-
235
- // For non-ls users
236
- LiteSpeed_Cache_Optimize::get_instance()->rm_cache_folder() ;
237
-
238
- if ( ! $silence ) {
239
- $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
240
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
241
- }
242
- }
243
-
244
- /**
245
- * Purge opcode cache
246
- *
247
- * @since 1.8.2
248
- * @access private
249
- */
250
- private function _purge_all_opcache( $silence = false )
251
- {
252
- if ( ! LiteSpeed_Cache_Router::opcache_enabled() ) {
253
- LiteSpeed_Cache_Log::debug( '[Purge] Failed to reset opcode cache due to opcache not enabled' ) ;
254
-
255
- if ( ! $silence ) {
256
- $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
257
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
258
- }
259
-
260
- return false ;
261
- }
262
-
263
- // Purge opcode cache
264
- opcache_reset() ;
265
- LiteSpeed_Cache_Log::debug( '[Purge] Reset opcode cache' ) ;
266
-
267
- if ( ! $silence ) {
268
- $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
269
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
270
- }
271
-
272
- return true ;
273
- }
274
-
275
- /**
276
- * Purge object cache
277
- *
278
- * @since 1.8
279
- * @access private
280
- */
281
- private function _purge_all_object( $silence = false )
282
- {
283
- if ( ! defined( 'LSCWP_OBJECT_CACHE' ) ) {
284
- LiteSpeed_Cache_Log::debug( '[Purge] Failed to flush object cache due to object cache not enabled' ) ;
285
-
286
- if ( ! $silence ) {
287
- $msg = __( 'Object cache is not enabled.', 'litespeed-cache' ) ;
288
- LiteSpeed_Cache_Admin_Display::error( $msg ) ;
289
- }
290
-
291
- return false ;
292
- }
293
- LiteSpeed_Cache_Object::get_instance()->flush() ;
294
- LiteSpeed_Cache_Log::debug( '[Purge] Flushed object cache' ) ;
295
-
296
- if ( ! $silence ) {
297
- $msg = __( 'Purge all object caches successfully.', 'litespeed-cache' ) ;
298
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
299
- }
300
-
301
- return true ;
302
- }
303
-
304
- /**
305
- * Adds new public purge tags to the array of purge tags for the request.
306
- *
307
- * @since 1.1.3
308
- * @access public
309
- * @param mixed $tags Tags to add to the list.
310
- */
311
- public static function add( $tags )
312
- {
313
- self::get_instance()->_add( $tags ) ;
314
- }
315
-
316
- /**
317
- * Add tags to purge
318
- *
319
- * @since 2.2
320
- * @access private
321
- */
322
- private function _add( $tags )
323
- {
324
- if ( ! is_array( $tags ) ) {
325
- $tags = array( $tags ) ;
326
- }
327
- if ( ! array_diff( $tags, $this->_pub_purge ) ) {
328
- return ;
329
- }
330
-
331
- $this->_pub_purge = array_merge( $this->_pub_purge, $tags ) ;
332
- LiteSpeed_Cache_Log::debug( '[Purge] added ' . implode( ',', $tags ), 8 ) ;
333
-
334
- // Send purge header immediately
335
- $curr_built = $this->_build() ;
336
- if ( defined( 'LITESPEED_DID_send_headers' ) ) {
337
- // Can't send, already has output, need to save and wait for next run
338
- update_option( self::PURGE_QUEUE, $curr_built ) ;
339
- LiteSpeed_Cache_Log::debug( '[Purge] Output existed, queue stored: ' . $curr_built ) ;
340
- }
341
- else {
342
- @header( $curr_built ) ;
343
- LiteSpeed_Cache_Log::debug( $curr_built ) ;
344
- }
345
-
346
- }
347
-
348
- /**
349
- * Adds new private purge tags to the array of purge tags for the request.
350
- *
351
- * @since 1.1.3
352
- * @access public
353
- * @param mixed $tags Tags to add to the list.
354
- */
355
- public static function add_private( $tags )
356
- {
357
- self::get_instance()->_add_private( $tags ) ;
358
- }
359
-
360
- /**
361
- * Add tags to private purge
362
- *
363
- * @since 2.2
364
- * @access private
365
- */
366
- private function _add_private( $tags )
367
- {
368
- if ( ! is_array( $tags ) ) {
369
- $tags = array( $tags ) ;
370
- }
371
- if ( ! array_diff( $tags, $this->_priv_purge ) ) {
372
- return ;
373
- }
374
-
375
- LiteSpeed_Cache_Log::debug( '[Purge] added [private] ' . implode( ',', $tags ), 3 ) ;
376
-
377
- $this->_priv_purge = array_merge( $this->_priv_purge, $tags ) ;
378
-
379
- // Send purge header immediately
380
- @header( $this->_build() ) ;
381
- }
382
-
383
- /**
384
- * Activate `purge related tags` for Admin QS.
385
- *
386
- * @since 1.1.3
387
- * @access public
388
- */
389
- public static function set_purge_related()
390
- {
391
- self::get_instance()->_purge_related = true ;
392
- }
393
-
394
- /**
395
- * Activate `purge single url tag` for Admin QS.
396
- *
397
- * @since 1.1.3
398
- * @access public
399
- */
400
- public static function set_purge_single()
401
- {
402
- self::get_instance()->_purge_single = true ;
403
- }
404
-
405
- /**
406
- * Called from cfg::frontend_save() to purge front page
407
- *
408
- * @since 2.2
409
- * @access public
410
- */
411
- public static function purge_front()
412
- {
413
- self::get_instance()->_purge_front() ;
414
- }
415
-
416
- /**
417
- * Purge frontend url
418
- *
419
- * @since 1.3
420
- * @since 2.2 Renamed from `frontend_purge`; Access changed from public
421
- * @access private
422
- */
423
- private function _purge_front()
424
- {
425
- if ( empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
426
- exit( 'no referer' ) ;
427
- }
428
-
429
- $this->purgeby_url_cb( $_SERVER[ 'HTTP_REFERER' ] ) ;
430
-
431
- wp_redirect( $_SERVER[ 'HTTP_REFERER' ] ) ;
432
- exit() ;
433
- }
434
-
435
- /**
436
- * Alerts LiteSpeed Web Server to purge the front page.
437
- *
438
- * @since 1.0.3
439
- * @since 2.2 Access changed from public to private, renamed from `_purge_front`
440
- * @access private
441
- */
442
- private function _purge_frontpage()
443
- {
444
- $this->_add( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
445
- if ( LITESPEED_SERVER_TYPE !== 'LITESPEED_SERVER_OLS' ) {
446
- $this->_add_private( LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ) ;
447
- }
448
-
449
- $msg = __( 'Notified LiteSpeed Web Server to purge the front page.', 'litespeed-cache' ) ;
450
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
451
- }
452
-
453
- /**
454
- * Alerts LiteSpeed Web Server to purge pages.
455
- *
456
- * @since 1.0.15
457
- * @access private
458
- */
459
- private function _purge_pages()
460
- {
461
- $this->_add( LiteSpeed_Cache_Tag::TYPE_PAGES ) ;
462
-
463
- $msg = __( 'Notified LiteSpeed Web Server to purge pages.', 'litespeed-cache' ) ;
464
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
465
- }
466
-
467
- /**
468
- * Alerts LiteSpeed Web Server to purge error pages.
469
- *
470
- * @since 1.0.14
471
- * @access private
472
- */
473
- private function _purge_error( $type = false )
474
- {
475
- $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR ) ;
476
-
477
- if ( ! $type || ! in_array( $type, array( '403', '404', '500' ) ) ) {
478
- return ;
479
- }
480
-
481
- $this->_add( LiteSpeed_Cache_Tag::TYPE_ERROR . $type ) ;
482
-
483
- $msg = __( 'Notified LiteSpeed Web Server to purge error pages.', 'litespeed-cache' ) ;
484
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
485
- }
486
-
487
- /**
488
- * Callback to add purge tags if admin selects to purge selected category pages.
489
- *
490
- * @since 1.0.7
491
- * @access public
492
- * @param string $value The category slug.
493
- * @param string $key Unused.
494
- */
495
- public function purgeby_cat_cb( $value, $key )
496
- {
497
- $val = trim( $value ) ;
498
- if ( empty( $val ) ) {
499
- return ;
500
- }
501
- if ( preg_match( '/^[a-zA-Z0-9-]+$/', $val ) == 0 ) {
502
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_INV ) ;
503
- return ;
504
- }
505
- $cat = get_category_by_slug( $val ) ;
506
- if ( $cat == false ) {
507
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_CAT_DNE, $val ) ;
508
- return ;
509
- }
510
-
511
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge category %s', 'litespeed-cache' ), $val ) ) ;
512
-
513
- $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $cat->term_id ) ;
514
- }
515
-
516
- /**
517
- * Callback to add purge tags if admin selects to purge selected post IDs.
518
- *
519
- * @since 1.0.7
520
- * @access public
521
- * @param string $value The post ID.
522
- * @param string $key Unused.
523
- */
524
- public function purgeby_pid_cb( $value, $key )
525
- {
526
- $val = trim( $value ) ;
527
- if ( empty( $val ) ) {
528
- return ;
529
- }
530
- if ( ! is_numeric( $val ) ) {
531
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_NUM, $val ) ;
532
- return ;
533
- }
534
- elseif ( get_post_status( $val ) !== 'publish' ) {
535
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_PID_DNE, $val ) ;
536
- return ;
537
- }
538
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge Post ID %s', 'litespeed-cache' ), $val ) ) ;
539
-
540
- $this->_add( LiteSpeed_Cache_Tag::TYPE_POST . $val ) ;
541
- }
542
-
543
- /**
544
- * Callback to add purge tags if admin selects to purge selected tag pages.
545
- *
546
- * @since 1.0.7
547
- * @access public
548
- * @param string $value The tag slug.
549
- * @param string $key Unused.
550
- */
551
- public function purgeby_tag_cb( $value, $key )
552
- {
553
- $val = trim( $value ) ;
554
- if ( empty( $val ) ) {
555
- return ;
556
- }
557
- if ( preg_match( '/^[a-zA-Z0-9-]+$/', $val ) == 0 ) {
558
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_INV ) ;
559
- return ;
560
- }
561
- $term = get_term_by( 'slug', $val, 'post_tag' ) ;
562
- if ( $term == 0 ) {
563
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_TAG_DNE, $val ) ;
564
- return ;
565
- }
566
-
567
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge tag %s', 'litespeed-cache' ), $val ) ) ;
568
-
569
- $this->_add( LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ) ;
570
- }
571
-
572
- /**
573
- * Callback to add purge tags if admin selects to purge selected urls.
574
- *
575
- * @since 1.0.7
576
- * @access public
577
- * @param string $value A url to purge.
578
- * @param string $key Unused.
579
- */
580
- public function purgeby_url_cb( $value, $key = false )
581
- {
582
- $val = trim( $value ) ;
583
- if ( empty( $val ) ) {
584
- return ;
585
- }
586
-
587
- if ( strpos( $val, '<' ) !== false ) {
588
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_BAD ) ;
589
- return ;
590
- }
591
-
592
- $val = LiteSpeed_Cache_Utility::make_relative( $val ) ;
593
-
594
- $hash = LiteSpeed_Cache_Tag::get_uri_tag( $val ) ;
595
-
596
- if ( $hash === false ) {
597
- LiteSpeed_Cache_Admin_Display::add_error( LiteSpeed_Cache_Admin_Error::E_PURGEBY_URL_INV, $val ) ;
598
- return ;
599
- }
600
-
601
- ! defined( 'LITESPEED_PURGE_SILENT' ) && LiteSpeed_Cache_Admin_Display::succeed( sprintf( __( 'Purge url %s', 'litespeed-cache' ), $val ) ) ;
602
-
603
- $this->_add( $hash ) ;
604
- return ;
605
- }
606
-
607
- /**
608
- * Purge a list of pages when selected by admin. This method will
609
- * look at the post arguments to determine how and what to purge.
610
- *
611
- * @since 1.0.7
612
- * @access public
613
- */
614
- public function purge_list()
615
- {
616
- if ( ! isset($_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT]) || ! isset($_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST]) ) {
617
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGE_FORM) ;
618
- return ;
619
- }
620
- $sel = $_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT] ;
621
- $list_buf = $_REQUEST[LiteSpeed_Cache_Admin_Display::PURGEBYOPT_LIST] ;
622
- if ( empty($list_buf) ) {
623
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_EMPTY) ;
624
- return ;
625
- }
626
- $list_buf = str_replace(",", "\n", $list_buf) ;// for cli
627
- $list = explode("\n", $list_buf) ;
628
- switch($sel) {
629
- case LiteSpeed_Cache_Admin_Display::PURGEBY_CAT:
630
- $cb = 'purgeby_cat_cb' ;
631
- break ;
632
- case LiteSpeed_Cache_Admin_Display::PURGEBY_PID:
633
- $cb = 'purgeby_pid_cb' ;
634
- break ;
635
- case LiteSpeed_Cache_Admin_Display::PURGEBY_TAG:
636
- $cb = 'purgeby_tag_cb' ;
637
- break ;
638
- case LiteSpeed_Cache_Admin_Display::PURGEBY_URL:
639
- $cb = 'purgeby_url_cb' ;
640
- break ;
641
- default:
642
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_PURGEBY_BAD) ;
643
- return ;
644
- }
645
- array_walk( $list, array( $this, $cb ) ) ;
646
-
647
- // for redirection
648
- $_GET[ LiteSpeed_Cache_Admin_Display::PURGEBYOPT_SELECT ] = $sel ;
649
- }
650
-
651
- /**
652
- * Purge a post on update.
653
- *
654
- * This function will get the relevant purge tags to add to the response
655
- * as well.
656
- *
657
- * @since 1.0.0
658
- * @access public
659
- * @param integer $id The post id to purge.
660
- */
661
- public static function purge_post( $id )
662
- {
663
- $post_id = intval($id) ;
664
- // ignore the status we don't care
665
- if ( ! in_array(get_post_status($post_id), array( 'publish', 'trash', 'private', 'draft' )) ) {
666
- return ;
667
- }
668
-
669
- $instance = self::get_instance() ;
670
-
671
- $purge_tags = $instance->_get_purge_tags_by_post($post_id) ;
672
- if ( empty($purge_tags) ) {
673
- return ;
674
- }
675
- if ( in_array( '*', $purge_tags ) ) {
676
- $instance->_purge_all_lscache() ;
677
- }
678
- else {
679
- $instance->_add( $purge_tags ) ;
680
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_REST ) ) {
681
- $instance->_add( LiteSpeed_Cache_Tag::TYPE_REST ) ;
682
- }
683
- }
684
- LiteSpeed_Cache_Control::set_stale() ;
685
- }
686
-
687
- /**
688
- * Hooked to the load-widgets.php action.
689
- * Attempts to purge a single widget from cache.
690
- * If no widget id is passed in, the method will attempt to find the widget id.
691
- *
692
- * @since 1.1.3
693
- * @access public
694
- * @param type $widget_id The id of the widget to purge.
695
- */
696
- public static function purge_widget($widget_id = null)
697
- {
698
- if ( is_null($widget_id) ) {
699
- $widget_id = $_POST['widget-id'] ;
700
- if ( is_null($widget_id) ) {
701
- return ;
702
- }
703
- }
704
- self::add(LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget_id) ;
705
- self::add_private(LiteSpeed_Cache_Tag::TYPE_WIDGET . $widget_id) ;
706
- }
707
-
708
- /**
709
- * Hooked to the wp_update_comment_count action.
710
- * Purges the comment widget when the count is updated.
711
- *
712
- * @access public
713
- * @since 1.1.3
714
- * @global type $wp_widget_factory
715
- */
716
- public static function purge_comment_widget()
717
- {
718
- global $wp_widget_factory ;
719
- $recent_comments = $wp_widget_factory->widgets['WP_Widget_Recent_Comments'] ;
720
- if ( !is_null($recent_comments) ) {
721
- self::add(LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_comments->id) ;
722
- self::add_private(LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_comments->id) ;
723
- }
724
- }
725
-
726
- /**
727
- * Purges feeds on comment count update.
728
- *
729
- * @since 1.0.9
730
- * @access public
731
- */
732
- public static function purge_feeds()
733
- {
734
- if ( LiteSpeed_Cache::config(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0 ) {
735
- self::add(LiteSpeed_Cache_Tag::TYPE_FEED) ;
736
- }
737
- }
738
-
739
- /**
740
- * Purges all private cache entries when the user logs out.
741
- *
742
- * @access public
743
- * @since 1.1.3
744
- */
745
- public static function purge_on_logout()
746
- {
747
- self::add_private('*') ;
748
- }
749
-
750
- /**
751
- * Generate all purge tags before output
752
- *
753
- * @access private
754
- * @since 1.1.3
755
- */
756
- private function _finalize()
757
- {
758
- // Make sure header output only run once
759
- if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
760
- define( 'LITESPEED_DID_' . __FUNCTION__, true ) ;
761
- }
762
- else {
763
- return ;
764
- }
765
-
766
- do_action('litespeed_cache_api_purge') ;
767
-
768
- // Append unique uri purge tags if Admin QS is `PURGESINGLE`
769
- if ( $this->_purge_single ) {
770
- $this->_pub_purge[] = LiteSpeed_Cache_Tag::build_uri_tag() ; // TODO: add private tag too
771
- }
772
- // Append related purge tags if Admin QS is `PURGE`
773
- if ( $this->_purge_related ) {
774
- // Before this, tags need to be finalized
775
- $tags_related = LiteSpeed_Cache_Tag::output_tags() ;
776
- // NOTE: need to remove the empty item `B1_` to avoid purging all
777
- $tags_related = array_filter($tags_related) ;
778
- if ( $tags_related ) {
779
- $this->_pub_purge = array_merge($this->_pub_purge, $tags_related) ;
780
- }
781
- }
782
-
783
- if ( ! empty($this->_pub_purge) ) {
784
- $this->_pub_purge = array_unique($this->_pub_purge) ;
785
- }
786
-
787
- if ( ! empty($this->_priv_purge) ) {
788
- $this->_priv_purge = array_unique($this->_priv_purge) ;
789
- }
790
- }
791
-
792
- /**
793
- * Gathers all the purge headers.
794
- *
795
- * This will collect all site wide purge tags as well as third party plugin defined purge tags.
796
- *
797
- * @since 1.1.0
798
- * @access public
799
- * @return string the built purge header
800
- */
801
- public static function output()
802
- {
803
- $instance = self::get_instance() ;
804
-
805
- $instance->_finalize() ;
806
-
807
- return $instance->_build() ;
808
- }
809
-
810
- /**
811
- * Build the current purge headers.
812
- *
813
- * @since 1.1.5
814
- * @access private
815
- * @return string the built purge header
816
- */
817
- private function _build()
818
- {
819
- if ( empty( $this->_pub_purge ) && empty( $this->_priv_purge ) ) {
820
- return ;
821
- }
822
-
823
- $purge_header = '' ;
824
- $private_prefix = self::X_HEADER . ': private,' ;
825
-
826
- if ( ! empty( $this->_pub_purge ) ) {
827
- $public_tags = $this->_append_prefix( $this->_pub_purge ) ;
828
- if ( empty( $public_tags ) ) {
829
- // If this ends up empty, private will also end up empty
830
- return ;
831
- }
832
- $purge_header = self::X_HEADER . ': public,' ;
833
- if ( LiteSpeed_Cache_Control::is_stale() ) {
834
- $purge_header .= 'stale,' ;
835
- }
836
- $purge_header .= implode( ',', $public_tags ) ;
837
- $private_prefix = ';private,' ;
838
- }
839
-
840
- // Handle priv purge tags
841
- if ( ! empty( $this->_priv_purge ) ) {
842
- $private_tags = $this->_append_prefix( $this->_priv_purge, true ) ;
843
- $purge_header .= $private_prefix . implode( ',', $private_tags ) ;
844
- }
845
-
846
- return $purge_header ;
847
- }
848
-
849
- /**
850
- * Append prefix to an array of purge headers
851
- *
852
- * @since 1.1.0
853
- * @access private
854
- * @param array $purge_tags The purge tags to apply the prefix to.
855
- * @param boolean $is_private If is private tags or not.
856
- * @return array The array of built purge tags.
857
- */
858
- private function _append_prefix( $purge_tags, $is_private = false )
859
- {
860
- $curr_bid = is_multisite() ? get_current_blog_id() : '' ;
861
-
862
- if ( ! in_array('*', $purge_tags) ) {
863
- $tags = array() ;
864
- foreach ($purge_tags as $val) {
865
- $tags[] = LSWCP_TAG_PREFIX . $curr_bid . '_' . $val ;
866
- }
867
- return $tags ;
868
- }
869
-
870
- if ( defined('LSWCP_EMPTYCACHE') || $is_private ) {
871
- return array('*') ;
872
- }
873
-
874
- // Would only use multisite and network admin except is_network_admin
875
- // is false for ajax calls, which is used by wordpress updates v4.6+
876
- if ( is_multisite() && (is_network_admin() || (
877
- LiteSpeed_Cache_Router::is_ajax() && (check_ajax_referer('updates', false, false) || check_ajax_referer('litespeed-purgeall-network', false, false))
878
- )) ) {
879
- $blogs = LiteSpeed_Cache_Activation::get_network_ids() ;
880
- if ( empty($blogs) ) {
881
- LiteSpeed_Cache_Log::debug('[Purge] build_purge_headers: blog list is empty') ;
882
- return '' ;
883
- }
884
- $tags = array() ;
885
- foreach ($blogs as $blog_id) {
886
- $tags[] = LSWCP_TAG_PREFIX . $blog_id . '_' ;
887
- }
888
- return $tags ;
889
- }
890
- else {
891
- return array(LSWCP_TAG_PREFIX . $curr_bid . '_') ;
892
- }
893
- }
894
-
895
- /**
896
- * Gets all the purge tags correlated with the post about to be purged.
897
- *
898
- * If the purge all pages configuration is set, all pages will be purged.
899
- *
900
- * This includes site wide post types (e.g. front page) as well as
901
- * any third party plugin specific post tags.
902
- *
903
- * @since 1.0.0
904
- * @access private
905
- * @param integer $post_id The id of the post about to be purged.
906
- * @return array The list of purge tags correlated with the post.
907
- */
908
- private function _get_purge_tags_by_post( $post_id )
909
- {
910
- // If this is a valid post we want to purge the post, the home page and any associated tags & cats
911
- // If not, purge everything on the site.
912
-
913
- $purge_tags = array() ;
914
- $config = LiteSpeed_Cache_Config::get_instance() ;
915
-
916
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_ALL_PAGES) ) {
917
- // ignore the rest if purge all
918
- return array( '*' ) ;
919
- }
920
-
921
- // now do API hook action for post purge
922
- do_action('litespeed_cache_api_purge_post', $post_id) ;
923
-
924
- // post
925
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $post_id ;
926
- $purge_tags[] = LiteSpeed_Cache_Tag::get_uri_tag(wp_make_link_relative(get_permalink($post_id))) ;
927
-
928
- // for archive of categories|tags|custom tax
929
- global $post ;
930
- $original_post = $post ;
931
- $post = get_post($post_id) ;
932
- $post_type = $post->post_type ;
933
-
934
- global $wp_widget_factory ;
935
- $recent_posts = $wp_widget_factory->widgets['WP_Widget_Recent_Posts'] ;
936
- if ( ! is_null($recent_posts) ) {
937
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_WIDGET . $recent_posts->id ;
938
- }
939
-
940
- // get adjacent posts id as related post tag
941
- if( $post_type == 'post' ){
942
- $prev_post = get_previous_post() ;
943
- $next_post = get_next_post() ;
944
- if( ! empty($prev_post->ID) ) {
945
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $prev_post->ID ;
946
- LiteSpeed_Cache_Log::debug('--------purge_tags prev is: '.$prev_post->ID) ;
947
- }
948
- if( ! empty($next_post->ID) ) {
949
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_POST . $next_post->ID ;
950
- LiteSpeed_Cache_Log::debug('--------purge_tags next is: '.$next_post->ID) ;
951
- }
952
- }
953
-
954
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_TERM) ) {
955
- $taxonomies = get_object_taxonomies($post_type) ;
956
- //LiteSpeed_Cache_Log::debug('purge by post, check tax = ' . var_export($taxonomies, true)) ;
957
- foreach ( $taxonomies as $tax ) {
958
- $terms = get_the_terms($post_id, $tax) ;
959
- if ( ! empty($terms) ) {
960
- foreach ( $terms as $term ) {
961
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM . $term->term_id ;
962
- }
963
- }
964
- }
965
- }
966
-
967
- if ( $config->get_option(LiteSpeed_Cache_Config::OPID_FEED_TTL) > 0 ) {
968
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_FEED ;
969
- }
970
-
971
- // author, for author posts and feed list
972
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_AUTHOR) ) {
973
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_AUTHOR . get_post_field('post_author', $post_id) ;
974
- }
975
-
976
- // archive and feed of post type
977
- // todo: check if type contains space
978
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_POST_TYPE) ) {
979
- if ( get_post_type_archive_link($post_type) ) {
980
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_POSTTYPE . $post_type ;
981
- }
982
- }
983
-
984
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_FRONT_PAGE) ) {
985
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
986
- }
987
-
988
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_HOME_PAGE) ) {
989
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_HOME ;
990
- }
991
-
992
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES) ) {
993
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_PAGES ;
994
- }
995
-
996
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_PAGES_WITH_RECENT_POSTS) ) {
997
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_PAGES_WITH_RECENT_POSTS ;
998
- }
999
-
1000
- // if configured to have archived by date
1001
- $date = $post->post_date ;
1002
- $date = strtotime($date) ;
1003
-
1004
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_DATE) ) {
1005
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Ymd', $date) ;
1006
- }
1007
-
1008
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_MONTH) ) {
1009
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Ym', $date) ;
1010
- }
1011
-
1012
- if ( $config->purge_by_post(LiteSpeed_Cache_Config::PURGE_YEAR) ) {
1013
- $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
1014
- }
1015
-
1016
- // Set back to original post as $post_id might affecting the global $post value
1017
- $post = $original_post ;
1018
-
1019
- return array_unique($purge_tags) ;
1020
- }
1021
-
1022
- /**
1023
- * The dummy filter for purge all
1024
- *
1025
- * @since 1.1.5
1026
- * @access public
1027
- * @param string $val The filter value
1028
- * @return string The filter value
1029
- */
1030
- public static function filter_with_purge_all( $val )
1031
- {
1032
- self::purge_all() ;
1033
- return $val ;
1034
- }
1035
-
1036
- /**
1037
- * Get the current instance object.
1038
- *
1039
- * @since 1.1.3
1040
- * @access public
1041
- * @return Current class instance.
1042
- */
1043
- public static function get_instance()
1044
- {
1045
- if ( ! isset( self::$_instance ) ) {
1046
- self::$_instance = new self() ;
1047
- }
1048
-
1049
- return self::$_instance ;
1050
- }
1051
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/rest.cls.php DELETED
@@ -1,123 +0,0 @@
1
- <?php
2
- /**
3
- * The REST related class.
4
- *
5
- * @since 2.9.4
6
- */
7
- defined( 'WPINC' ) || exit ;
8
-
9
- class LiteSpeed_Cache_REST
10
- {
11
- private static $_instance ;
12
-
13
- private $_internal_rest_status = false ;
14
-
15
- /**
16
- * Constructor of ESI
17
- *
18
- * @since 2.9.4
19
- * @access private
20
- */
21
- private function __construct()
22
- {
23
- // Hook to internal REST call
24
- add_filter( 'rest_request_before_callbacks', array( $this, 'set_internal_rest_on' ) ) ;
25
- add_filter( 'rest_request_after_callbacks', array( $this, 'set_internal_rest_off' ) ) ;
26
-
27
- }
28
-
29
- /**
30
- * Set internal REST tag to ON
31
- *
32
- * @since 2.9.4
33
- * @access public
34
- */
35
- public function set_internal_rest_on( $not_used = null )
36
- {
37
- $this->_internal_rest_status = true ;
38
- LiteSpeed_Cache_Log::debug2( '[REST] ✅ Internal REST ON [filter] rest_request_before_callbacks' ) ;
39
-
40
- return $not_used ;
41
- }
42
-
43
- /**
44
- * Set internal REST tag to OFF
45
- *
46
- * @since 2.9.4
47
- * @access public
48
- */
49
- public function set_internal_rest_off( $not_used = null )
50
- {
51
- $this->_internal_rest_status = false ;
52
- LiteSpeed_Cache_Log::debug2( '[REST] ❎ Internal REST OFF [filter] rest_request_after_callbacks' ) ;
53
-
54
- return $not_used ;
55
- }
56
-
57
- /**
58
- * Get internal REST tag
59
- *
60
- * @since 2.9.4
61
- * @access public
62
- */
63
- public function is_internal_rest()
64
- {
65
- return $this->_internal_rest_status ;
66
- }
67
-
68
- /**
69
- * Check if an URL or current page is REST req or not
70
- *
71
- * @since 2.9.3
72
- * @since 2.9.4 Moved here from LiteSpeed_Cache_Utility, dropped static
73
- * @access public
74
- */
75
- public function is_rest( $url = false )
76
- {
77
- // For WP 4.4.0- compatibility
78
- if ( ! function_exists( 'rest_get_url_prefix' ) ) {
79
- return defined( 'REST_REQUEST' ) && REST_REQUEST ;
80
- }
81
-
82
- $prefix = rest_get_url_prefix() ;
83
-
84
- // Case #1: After WP_REST_Request initialisation
85
- if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
86
- return true ;
87
- }
88
-
89
- // Case #2: Support "plain" permalink settings
90
- if ( isset( $_GET[ 'rest_route' ] ) && strpos( trim( $_GET[ 'rest_route' ], '\\/' ), $prefix , 0 ) === 0 ) {
91
- return true ;
92
- }
93
-
94
- if ( ! $url ) {
95
- return false ;
96
- }
97
-
98
- // Case #3: URL Path begins with wp-json/ (REST prefix) Safe for subfolder installation
99
- $rest_url = wp_parse_url( site_url( $prefix ) ) ;
100
- $current_url = wp_parse_url( $url ) ;
101
- // LiteSpeed_Cache_Log::debug( '[Util] is_rest check [base] ', $rest_url ) ;
102
- // LiteSpeed_Cache_Log::debug( '[Util] is_rest check [curr] ', $current_url ) ;
103
- // LiteSpeed_Cache_Log::debug( '[Util] is_rest check [curr2] ', wp_parse_url( add_query_arg( array( ) ) ) ) ;
104
- return strpos( $current_url[ 'path' ], $rest_url[ 'path' ] ) === 0 ;
105
- }
106
-
107
-
108
- /**
109
- * Get the current instance object.
110
- *
111
- * @since 2.9
112
- * @access public
113
- * @return Current class instance.
114
- */
115
- public static function get_instance()
116
- {
117
- if ( ! isset( self::$_instance ) ) {
118
- self::$_instance = new self() ;
119
- }
120
-
121
- return self::$_instance ;
122
- }
123
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/router.class.php DELETED
@@ -1,715 +0,0 @@
1
- <?php
2
- /**
3
- * The core plugin router class.
4
- *
5
- * This generate the valid action.
6
- *
7
- * @since 1.1.0
8
- * @since 1.5 Moved into /inc
9
- */
10
-
11
- if ( ! defined( 'WPINC' ) ) {
12
- die ;
13
- }
14
-
15
- class LiteSpeed_Cache_Router
16
- {
17
- private static $_instance ;
18
-
19
- private static $_esi_enabled ;
20
- private static $_is_ajax ;
21
- private static $_is_logged_in ;
22
- private static $_can_crawl ;
23
- private static $_ip ;
24
- private static $_action ;
25
- private static $_is_admin_ip ;
26
- private static $_frontend_path ;
27
-
28
- /**
29
- * Check if can run optimize
30
- *
31
- * @since 1.3
32
- * @since 2.3.1 Relocated from cdn.cls
33
- * @access public
34
- */
35
- public static function can_optm()
36
- {
37
- $can = true ;
38
-
39
- if ( is_admin() ) {
40
- $can = false ;
41
- }
42
-
43
- if ( is_feed() ) {
44
- $can = false ;
45
- }
46
-
47
- if ( is_preview() ) {
48
- $can = false ;
49
- }
50
-
51
- if ( self::is_ajax() ) {
52
- $can = false ;
53
- }
54
-
55
- if ( self::_is_login_page() ) {
56
- LiteSpeed_Cache_Log::debug( '[Router] Optm bypassed: login/reg page' ) ;
57
- $can = false ;
58
- }
59
-
60
- $can_final = apply_filters( 'litespeed_can_optm', $can ) ;
61
-
62
- if ( $can_final != $can ) {
63
- LiteSpeed_Cache_Log::debug( '[Router] Optm bypassed: filter' ) ;
64
- }
65
-
66
- return $can_final ;
67
- }
68
-
69
- /**
70
- * Check referer page to see if its from admin
71
- *
72
- * @since 2.4.2.1
73
- * @access public
74
- */
75
- public static function from_admin()
76
- {
77
- return ! empty( $_SERVER[ 'HTTP_REFERER' ] ) && strpos( $_SERVER[ 'HTTP_REFERER' ], get_admin_url() ) === 0 ;
78
- }
79
-
80
- /**
81
- * Check if it can use CDN replacement
82
- *
83
- * @since 1.2.3
84
- * @since 2.3.1 Relocated from cdn.cls
85
- * @access public
86
- */
87
- public static function can_cdn()
88
- {
89
- $can = true ;
90
-
91
- if ( is_admin() ) {
92
- if ( ! self::is_ajax() ) {
93
- LiteSpeed_Cache_Log::debug2( '[Router] CDN bypassed: is not ajax call' ) ;
94
- $can = false ;
95
- }
96
-
97
- if ( self::from_admin() ) {
98
- LiteSpeed_Cache_Log::debug2( '[Router] CDN bypassed: ajax call from admin' ) ;
99
- $can = false ;
100
- }
101
- }
102
-
103
- if ( is_feed() ) {
104
- $can = false ;
105
- }
106
-
107
- if ( is_preview() ) {
108
- $can = false ;
109
- }
110
-
111
- /**
112
- * Bypass cron to avoid deregister jq notice `Do not deregister the <code>jquery-core</code> script in the administration area.`
113
- * @since 2.7.2
114
- */
115
- if ( defined( 'DOING_CRON' ) ) {
116
- $can = false ;
117
- }
118
-
119
- /**
120
- * Bypass login/reg page
121
- * @since 1.6
122
- */
123
- if ( self::_is_login_page() ) {
124
- LiteSpeed_Cache_Log::debug( '[Router] CDN bypassed: login/reg page' ) ;
125
- $can = false ;
126
- }
127
-
128
- /**
129
- * Bypass post/page link setting
130
- * @since 2.9.8.5
131
- */
132
- if (
133
- strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-json/wp/v2/media' ) !== false
134
- && strpos( $_SERVER[ 'HTTP_REFERER' ], 'wp-admin') !== false
135
- ) {
136
- LiteSpeed_Cache_Log::debug( '[Router] CDN bypassed: wp-json on admin page' ) ;
137
- $can = false ;
138
- }
139
-
140
- $can_final = apply_filters( 'litespeed_can_cdn', $can ) ;
141
-
142
- if ( $can_final != $can ) {
143
- LiteSpeed_Cache_Log::debug( '[Router] CDN bypassed: filter' ) ;
144
- }
145
-
146
- return $can_final ;
147
- }
148
-
149
- /**
150
- * Check if is login page or not
151
- *
152
- * @since 2.3.1
153
- * @access protected
154
- */
155
- protected static function _is_login_page()
156
- {
157
- if ( in_array( $GLOBALS[ 'pagenow' ], array( 'wp-login.php', 'wp-register.php' ), true ) ) {
158
- return true ;
159
- }
160
-
161
- return false ;
162
- }
163
-
164
- /**
165
- * Crawler simulate role
166
- *
167
- * @since 1.9.1
168
- * @access public
169
- */
170
- public function is_crawler_role_simulation()
171
- {
172
- if( is_admin() ) {
173
- return ;
174
- }
175
-
176
- if ( empty( $_COOKIE[ 'litespeed_role' ] ) || empty( $_COOKIE[ 'litespeed_hash' ] ) ) {
177
- return ;
178
- }
179
-
180
- LiteSpeed_Cache_Log::debug( '[Router] starting crawler role validation' ) ;
181
-
182
- // Check if is from crawler
183
- if ( empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) || strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Litespeed_Crawler::FAST_USER_AGENT ) !== 0 ) {
184
- LiteSpeed_Cache_Log::debug( '[Router] user agent not match' ) ;
185
- return ;
186
- }
187
-
188
- // Hash validation
189
- $hash = get_option( LiteSpeed_Cache_Config::ITEM_CRAWLER_HASH ) ;
190
- if ( ! $hash || $_COOKIE[ 'litespeed_hash' ] != $hash ) {
191
- LiteSpeed_Cache_Log::debug( '[Router] crawler hash not match ' . $_COOKIE[ 'litespeed_hash' ] . ' != ' . $hash ) ;
192
- return ;
193
- }
194
-
195
- $role_uid = $_COOKIE[ 'litespeed_role' ] ;
196
- LiteSpeed_Cache_Log::debug( '[Router] role simulate litespeed_role uid ' . $role_uid ) ;
197
-
198
- wp_set_current_user( $role_uid ) ;
199
- }
200
-
201
- /**
202
- * Get user id
203
- *
204
- * @since 1.6.2
205
- */
206
- public static function get_uid()
207
- {
208
- if ( defined( 'LITESPEED_WP_UID' ) ) {
209
- return LITESPEED_WP_UID ;
210
- }
211
-
212
- $user = wp_get_current_user() ;
213
- $user_id = $user->ID ;
214
-
215
- LiteSpeed_Cache_Log::debug( '[Router] get_uid: ' . $user_id, 3 ) ;
216
-
217
- define( 'LITESPEED_WP_UID', $user_id ) ;
218
-
219
- return LITESPEED_WP_UID ;
220
- }
221
-
222
- /**
223
- * Get user role
224
- *
225
- * @since 1.6.2
226
- */
227
- public static function get_role( $uid = null )
228
- {
229
- if ( defined( 'LITESPEED_WP_ROLE' ) ) {
230
- return LITESPEED_WP_ROLE ;
231
- }
232
-
233
- if ( $uid === null ) {
234
- $uid = self::get_uid() ;
235
- }
236
-
237
- $role = false ;
238
- if ( $uid ) {
239
- $user = get_userdata( $uid ) ;
240
- if ( isset( $user->roles ) && is_array( $user->roles ) ) {
241
- $tmp = array_values( $user->roles ) ;
242
- $role = array_shift( $tmp ) ;
243
- }
244
- }
245
- LiteSpeed_Cache_Log::debug( '[Router] get_role: ' . $role ) ;
246
-
247
- if ( ! $role ) {
248
- return $role ;
249
- // Guest user
250
- LiteSpeed_Cache_Log::debug( '[Router] role: guest' ) ;
251
-
252
- /**
253
- * Fix double login issue
254
- * The previous user init refactoring didn't fix this bcos this is in login process and the user role could change
255
- * @see https://github.com/litespeedtech/lscache_wp/commit/69e7bc71d0de5cd58961bae953380b581abdc088
256
- * @since 2.9.8 Won't assign const if in login process
257
- */
258
- if ( substr_compare( wp_login_url(), $GLOBALS[ 'pagenow' ], -strlen( $GLOBALS[ 'pagenow' ] ) ) === 0 ) {
259
- return $role ;
260
- }
261
- }
262
-
263
- define( 'LITESPEED_WP_ROLE', $role ) ;
264
-
265
- return LITESPEED_WP_ROLE ;
266
- }
267
-
268
- /**
269
- * Get frontend path
270
- *
271
- * @since 1.2.2
272
- * @access public
273
- * @return boolean
274
- */
275
- public static function frontend_path()
276
- {
277
- if ( ! isset( self::$_frontend_path ) ) {
278
- $frontend = rtrim( ABSPATH, '/' ) ; // /home/user/public_html/frontend
279
- // get home path failed. Trac ticket #37668 (e.g. frontend:/blog backend:/wordpress)
280
- if ( ! $frontend ) {
281
- LiteSpeed_Cache_Log::debug( '[Router] No ABSPATH, generating from home option' ) ;
282
- $frontend = parse_url( get_option( 'home' ) ) ;
283
- $frontend = ! empty( $frontend[ 'path' ] ) ? $frontend[ 'path' ] : '' ;
284
- $frontend = $_SERVER[ 'DOCUMENT_ROOT' ] . $frontend ;
285
- }
286
- $frontend = realpath( $frontend ) ;
287
-
288
- self::$_frontend_path = $frontend ;
289
- }
290
- return self::$_frontend_path ;
291
- }
292
-
293
- /**
294
- * Check if ESI is enabled or not
295
- *
296
- * @since 1.2.0
297
- * @access public
298
- * @return boolean
299
- */
300
- public static function esi_enabled()
301
- {
302
- if ( ! isset( self::$_esi_enabled ) ) {
303
- self::$_esi_enabled = defined( 'LITESPEED_ON' ) && LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ESI_ENABLE ) ;
304
- }
305
- return self::$_esi_enabled ;
306
- }
307
-
308
- /**
309
- * Check if crawler is enabled on server level
310
- *
311
- * @since 1.1.1
312
- * @access public
313
- * @return boolean
314
- */
315
- public static function can_crawl()
316
- {
317
- if ( ! isset( self::$_can_crawl ) ) {
318
- self::$_can_crawl = true ;
319
-
320
- if ( isset( $_SERVER['X-LSCACHE'] ) && strpos( $_SERVER['X-LSCACHE'], 'crawler' ) === false ) {
321
- self::$_can_crawl = false ;
322
- }
323
-
324
- // CLI will bypass this check as crawler library can always do the 428 check
325
- if ( defined( 'LITESPEED_CLI' ) ) {
326
- self::$_can_crawl = true ;
327
- }
328
-
329
- }
330
-
331
- return self::$_can_crawl ;
332
- }
333
-
334
- /**
335
- * Check action
336
- *
337
- * @since 1.1.0
338
- * @access public
339
- * @return string
340
- */
341
- public static function get_action()
342
- {
343
- if ( ! isset( self::$_action ) ) {
344
- self::$_action = false;
345
- self::get_instance()->verify_action() ;
346
- if ( self::$_action ) {
347
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( '[Router] LSCWP_CTRL verified: ' . var_export( self::$_action, true ) ) ;
348
- }
349
-
350
- }
351
- return self::$_action ;
352
- }
353
-
354
- /**
355
- * Check if is logged in
356
- *
357
- * @since 1.1.3
358
- * @access public
359
- * @return boolean
360
- */
361
- public static function is_logged_in()
362
- {
363
- if ( ! isset( self::$_is_logged_in ) ) {
364
- self::$_is_logged_in = is_user_logged_in() ;
365
- }
366
- return self::$_is_logged_in ;
367
- }
368
-
369
- /**
370
- * Check if is ajax call
371
- *
372
- * @since 1.1.0
373
- * @access public
374
- * @return boolean
375
- */
376
- public static function is_ajax()
377
- {
378
- if ( ! isset( self::$_is_ajax ) ) {
379
- self::$_is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ;
380
- }
381
- return self::$_is_ajax ;
382
- }
383
-
384
- /**
385
- * Check if is admin ip
386
- *
387
- * @since 1.1.0
388
- * @access public
389
- * @return boolean
390
- */
391
- public static function is_admin_ip()
392
- {
393
- if ( ! isset( self::$_is_admin_ip ) ) {
394
- $ips = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_ADMIN_IPS ) ;
395
-
396
- self::$_is_admin_ip = self::get_instance()->ip_access( $ips ) ;
397
- }
398
- return self::$_is_admin_ip ;
399
- }
400
-
401
- /**
402
- * Create type value for url
403
- *
404
- * @since 1.6
405
- * @access public
406
- */
407
- public static function build_type( $val )
408
- {
409
- return array( 'type' => $val ) ;
410
- }
411
-
412
- /**
413
- * Get type value
414
- *
415
- * @since 1.6
416
- * @access public
417
- */
418
- public static function verify_type()
419
- {
420
- if ( empty( $_REQUEST[ 'type' ] ) ) {
421
- LiteSpeed_Cache_Log::debug( '[Router] no type', 2 ) ;
422
- return false ;
423
- }
424
-
425
- LiteSpeed_Cache_Log::debug( '[Router] parsed type: ' . $_REQUEST[ 'type' ], 2 ) ;
426
-
427
- return $_REQUEST[ 'type' ] ;
428
- }
429
-
430
- /**
431
- * Check privilege and nonce for the action
432
- *
433
- * @since 1.1.0
434
- * @access private
435
- */
436
- private function verify_action()
437
- {
438
- if ( empty( $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ) ) {
439
- LiteSpeed_Cache_Log::debug2( '[Router] LSCWP_CTRL bypassed empty' ) ;
440
- return ;
441
- }
442
-
443
- $action = $_REQUEST[ LiteSpeed_Cache::ACTION_KEY ] ;
444
- $_is_public_action = false ;
445
-
446
- // Each action must have a valid nonce unless its from admin ip and is public action
447
- // Validate requests nonce (from admin logged in page or cli)
448
- if ( ! $this->verify_nonce( $action ) && ! $this->_verify_sapi_passive( $action ) && ! $this->_verify_sapi_aggressive( $action ) ) {
449
- // check if it is from admin ip
450
- if ( ! $this->is_admin_ip() ) {
451
- LiteSpeed_Cache_Log::debug( '[Router] LSCWP_CTRL query string - did not match admin IP: ' . $action ) ;
452
- return ;
453
- }
454
-
455
- // check if it is public action
456
- if ( ! in_array( $action, array(
457
- LiteSpeed_Cache::ACTION_QS_NOCACHE,
458
- LiteSpeed_Cache::ACTION_QS_PURGE,
459
- LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE,
460
- LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS,
461
- LiteSpeed_Cache::ACTION_QS_PURGE_ALL,
462
- LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE,
463
- ) ) ) {
464
- LiteSpeed_Cache_Log::debug( '[Router] LSCWP_CTRL query string - did not match admin IP Actions: ' . $action ) ;
465
- return ;
466
- }
467
-
468
- $_is_public_action = true ;
469
- }
470
-
471
- /* Now it is a valid action, lets log and check the permission */
472
- LiteSpeed_Cache_Log::debug( '[Router] LSCWP_CTRL: ' . $action ) ;
473
-
474
- // OK, as we want to do something magic, lets check if its allowed
475
- $_is_multisite = is_multisite() ;
476
- $_is_network_admin = $_is_multisite && is_network_admin() ;
477
- $_can_network_option = $_is_network_admin && current_user_can( 'manage_network_options' ) ;
478
- $_can_option = current_user_can( 'manage_options' ) ;
479
-
480
- switch ( $action ) {
481
- // Save htaccess
482
- case LiteSpeed_Cache::ACTION_SAVE_HTACCESS:
483
- if ( ( ! $_is_multisite && $_can_option ) || $_can_network_option ) {
484
- self::$_action = $action ;
485
- }
486
- return ;
487
-
488
- // Save network settings
489
- case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
490
- if ( $_can_network_option ) {
491
- self::$_action = $action ;
492
- }
493
- return ;
494
-
495
- case LiteSpeed_Cache::ACTION_PURGE_BY:
496
- case LiteSpeed_Cache::ACTION_FRONT_EXCLUDE:
497
- if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || $_can_option || self::is_ajax() ) ) {//here may need more security
498
- self::$_action = $action ;
499
- }
500
- return ;
501
-
502
- case LiteSpeed_Cache::ACTION_DB_OPTIMIZE:
503
- if ( $_can_network_option || $_can_option ) {
504
- self::$_action = $action ;
505
- }
506
- return ;
507
-
508
- case LiteSpeed_Cache::ACTION_PURGE_EMPTYCACHE:// todo: moved to purge.cls type action
509
- if ( defined( 'LITESPEED_ON' ) && ( $_can_network_option || ( ! $_is_multisite && $_can_option ) ) ) {
510
- self::$_action = $action ;
511
- }
512
- return ;
513
-
514
- case LiteSpeed_Cache::ACTION_QS_NOCACHE:
515
- case LiteSpeed_Cache::ACTION_QS_PURGE:
516
- case LiteSpeed_Cache::ACTION_QS_PURGE_SINGLE:
517
- case LiteSpeed_Cache::ACTION_QS_SHOW_HEADERS:
518
- case LiteSpeed_Cache::ACTION_QS_PURGE_ALL:
519
- case LiteSpeed_Cache::ACTION_QS_PURGE_EMPTYCACHE:
520
- if ( defined( 'LITESPEED_ON' ) && ( $_is_public_action || self::is_ajax() ) ) {
521
- self::$_action = $action ;
522
- }
523
- return ;
524
-
525
- case LiteSpeed_Cache::ACTION_CRAWLER_GENERATE_FILE:
526
- case LiteSpeed_Cache::ACTION_CRAWLER_RESET_POS:
527
- case LiteSpeed_Cache::ACTION_CRAWLER_CRON_ENABLE:
528
- case LiteSpeed_Cache::ACTION_DO_CRAWL:
529
- case LiteSpeed_Cache::ACTION_BLACKLIST_SAVE:
530
- case LiteSpeed_Cache::ACTION_PURGE:
531
- case LiteSpeed_Cache::ACTION_MEDIA:
532
- case LiteSpeed_Cache::ACTION_IMG_OPTM:
533
- case LiteSpeed_Cache::ACTION_IAPI:
534
- case LiteSpeed_Cache::ACTION_CDN_CLOUDFLARE:
535
- case LiteSpeed_Cache::ACTION_CDN_QUIC:
536
- case LiteSpeed_Cache::ACTION_IMPORT:
537
- case LiteSpeed_Cache::ACTION_REPORT:
538
- case LiteSpeed_Cache::ACTION_CSS:
539
- case LiteSpeed_Cache::ACTION_CFG:
540
- case LiteSpeed_Cache::ACTION_ACTIVATION:
541
- case LiteSpeed_Cache::ACTION_UTIL:
542
- if ( $_can_option && ! $_is_network_admin ) {
543
- self::$_action = $action ;
544
- }
545
- return ;
546
-
547
- case LiteSpeed_Cache::ACTION_LOG:
548
- if ( $_can_network_option || $_can_option ) {
549
- self::$_action = $action ;
550
- }
551
- return ;
552
-
553
- case LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK :
554
- case LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK :
555
- self::$_action = $action ;
556
- return ;
557
-
558
- case LiteSpeed_Cache::ACTION_DISMISS:
559
- /**
560
- * Non ajax call can dismiss too
561
- * @since 2.9
562
- */
563
- // if ( self::is_ajax() ) {
564
- self::$_action = $action ;
565
- // }
566
- return ;
567
-
568
- default:
569
- LiteSpeed_Cache_Log::debug( '[Router] LSCWP_CTRL match falied: ' . $action ) ;
570
- return ;
571
- }
572
-
573
- }
574
-
575
- /**
576
- * Verify sapi passive callback
577
- *
578
- * @since 1.5
579
- * @access private
580
- * @param string $action
581
- * @return bool
582
- */
583
- private function _verify_sapi_passive( $action )
584
- {
585
- if ( $action === LiteSpeed_Cache::ACTION_SAPI_PASSIVE_CALLBACK ) {
586
- if ( LiteSpeed_Cache_Admin_API::sapi_valiate_passive_callback() ) {
587
- return true ;
588
- }
589
- exit( 'wrong passive callback' ) ;
590
- }
591
-
592
- return false ;
593
- }
594
-
595
- /**
596
- * Verify sapi aggressive callback
597
- *
598
- * @since 1.6
599
- * @access private
600
- * @param string $action
601
- * @return bool
602
- */
603
- private function _verify_sapi_aggressive( $action )
604
- {
605
- if ( $action === LiteSpeed_Cache::ACTION_SAPI_AGGRESSIVE_CALLBACK ) {
606
- if ( LiteSpeed_Cache_Admin_API::sapi_validate_aggressive_callback() ) {
607
- return true ;
608
- }
609
-
610
- exit( 'wrong aggressive callback' ) ;
611
- }
612
- return false ;
613
- }
614
-
615
- /**
616
- * Verify nonce
617
- *
618
- * @since 1.1.0
619
- * @access private
620
- * @param string $action
621
- * @return bool
622
- */
623
- private function verify_nonce( $action )
624
- {
625
- if ( ! isset( $_REQUEST[LiteSpeed_Cache::NONCE_NAME] ) || ! wp_verify_nonce( $_REQUEST[LiteSpeed_Cache::NONCE_NAME], $action ) ) {
626
- return false ;
627
- }
628
- else{
629
- return true ;
630
- }
631
- }
632
-
633
- /**
634
- * Check if the ip is in the range
635
- *
636
- * @since 1.1.0
637
- * @access private
638
- * @param string $ip_list IP list
639
- * @return bool
640
- */
641
- private function ip_access( $ip_list )
642
- {
643
- if ( ! $ip_list ) {
644
- return false ;
645
- }
646
- if ( ! isset( self::$_ip ) ) {
647
- self::$_ip = $this->get_ip() ;
648
- }
649
- // $uip = explode('.', $_ip) ;
650
- // if(empty($uip) || count($uip) != 4) Return false ;
651
- if ( ! is_array( $ip_list ) ) {
652
- $ip_list = explode( "\n", $ip_list ) ;
653
- }
654
- // foreach($ip_list as $key => $ip) $ip_list[$key] = explode('.', trim($ip)) ;
655
- // foreach($ip_list as $key => $ip) {
656
- // if(count($ip) != 4) continue ;
657
- // for($i = 0 ; $i <= 3 ; $i++) if($ip[$i] == '*') $ip_list[$key][$i] = $uip[$i] ;
658
- // }
659
- return in_array( self::$_ip, $ip_list ) ;
660
- }
661
-
662
- /**
663
- * Get client ip
664
- *
665
- * @since 1.1.0
666
- * @since 1.6.5 changed to public
667
- * @access public
668
- * @return string
669
- */
670
- public static function get_ip()
671
- {
672
- $_ip = '' ;
673
- if ( function_exists( 'apache_request_headers' ) ) {
674
- $apache_headers = apache_request_headers() ;
675
- $_ip = ! empty( $apache_headers['True-Client-IP'] ) ? $apache_headers['True-Client-IP'] : false ;
676
- if ( ! $_ip ) {
677
- $_ip = ! empty( $apache_headers['X-Forwarded-For'] ) ? $apache_headers['X-Forwarded-For'] : false ;
678
- $_ip = explode( ", ", $_ip ) ;
679
- $_ip = array_shift( $_ip ) ;
680
- }
681
-
682
- if ( ! $_ip ) {
683
- $_ip = ! empty( $_SERVER['REMOTE_ADDR'] ) ? $_SERVER['REMOTE_ADDR'] : false ;
684
- }
685
- }
686
- return $_ip ;
687
- }
688
-
689
- /**
690
- * Check if opcode cache is enabled
691
- *
692
- * @since 1.8.2
693
- * @access public
694
- */
695
- public static function opcache_enabled()
696
- {
697
- return function_exists( 'opcache_reset' ) && ini_get( 'opcache.enable' ) ;
698
- }
699
-
700
- /**
701
- * Get the current instance object.
702
- *
703
- * @since 1.1.0
704
- * @access public
705
- * @return Current class instance.
706
- */
707
- public static function get_instance()
708
- {
709
- if ( ! isset( self::$_instance ) ) {
710
- self::$_instance = new self() ;
711
- }
712
-
713
- return self::$_instance ;
714
- }
715
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/task.class.php DELETED
@@ -1,274 +0,0 @@
1
- <?php
2
- /**
3
- * The cron task class.
4
- *
5
- * @since 1.1.3
6
- * @since 1.5 Moved into /inc
7
- */
8
-
9
- if ( ! defined( 'WPINC' ) ) {
10
- die ;
11
- }
12
-
13
- class LiteSpeed_Cache_Task
14
- {
15
- private static $_instance ;
16
-
17
- const CRON_ACTION_HOOK_CRAWLER = 'litespeed_crawl_trigger' ;
18
- const CRON_ACTION_HOOK_IMGOPTM = 'litespeed_imgoptm_trigger' ;
19
- const CRON_ACTION_HOOK_IMGOPTM_AUTO_REQUEST = 'litespeed_imgoptm_auto_request_trigger' ;
20
- const CRON_ACTION_HOOK_CCSS = 'litespeed_ccss_trigger' ;
21
- const CRON_ACTION_HOOK_IMG_PLACEHOLDER = 'litespeed_img_placeholder_trigger' ;
22
- const CRON_FITLER_CRAWLER = 'litespeed_crawl_filter' ;
23
- const CRON_FITLER = 'litespeed_filter' ;
24
-
25
- /**
26
- * Init
27
- *
28
- * @since 1.6
29
- * @access private
30
- */
31
- private function __construct()
32
- {
33
- LiteSpeed_Cache_Log::debug2( 'Task init' ) ;
34
-
35
- // Register crawler cron
36
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ) && LiteSpeed_Cache_Router::can_crawl() ) {
37
- // keep cron intval filter
38
- self::schedule_filter_crawler() ;
39
-
40
- // cron hook
41
- add_action( self::CRON_ACTION_HOOK_CRAWLER, 'LiteSpeed_Cache_Crawler::crawl_data' ) ;
42
- }
43
-
44
- // Register img optimization fetch ( always fetch immediately )
45
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_CRON ) ) {
46
- self::schedule_filter_imgoptm() ;
47
-
48
- add_action( self::CRON_ACTION_HOOK_IMGOPTM, 'LiteSpeed_Cache_Img_Optm::cron_pull_optimized_img' ) ;
49
- }
50
-
51
- // Image optm auto request
52
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_MEDIA_OPTM_AUTO ) ) {
53
- self::schedule_filter_imgoptm_auto_request() ;
54
-
55
- add_action( self::CRON_ACTION_HOOK_IMGOPTM_AUTO_REQUEST, 'LiteSpeed_Cache_Img_Optm::cron_auto_request' ) ;
56
- }
57
-
58
- // Register ccss generation
59
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CCSS_ASYNC ) && LiteSpeed_Cache_CSS::has_queue() ) {
60
- self::schedule_filter_ccss() ;
61
-
62
- add_action( self::CRON_ACTION_HOOK_CCSS, 'LiteSpeed_Cache_CSS::cron_ccss' ) ;
63
- }
64
-
65
- // Register image placeholder generation
66
- if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_PLACEHOLDER_RESP_ASYNC ) && LiteSpeed_Cache_Media::has_queue() ) {
67
- self::schedule_filter_placeholder() ;
68
-
69
- add_action( self::CRON_ACTION_HOOK_IMG_PLACEHOLDER, 'LiteSpeed_Cache_Media::cron_placeholder' ) ;
70
- }
71
- }
72
-
73
- /**
74
- * Enable/Disable cron task
75
- *
76
- * @since 1.1.0
77
- * @access public
78
- */
79
- public static function enable()
80
- {
81
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
82
-
83
- // get new setting
84
- $is_enabled = ! LiteSpeed_Cache::config( $id ) ;
85
-
86
- // log
87
- LiteSpeed_Cache_Log::debug( 'Crawler log: Crawler is ' . ( $is_enabled ? 'enabled' : 'disabled' ) ) ;
88
-
89
- // update config
90
- LiteSpeed_Cache_Config::get_instance()->update_options( array( $id => $is_enabled ) ) ;
91
-
92
- self::update() ;
93
-
94
- echo json_encode( array( 'enable' => $is_enabled ) ) ;
95
- wp_die() ;
96
- }
97
-
98
- /**
99
- * Update cron status
100
- *
101
- * @since 1.1.0
102
- * @access public
103
- * @param array $options The options to check if cron should be enabled
104
- */
105
- public static function update( $options = false )
106
- {
107
- $id = LiteSpeed_Cache_Config::CRWL_CRON_ACTIVE ;
108
- if ( $options && isset( $options[ $id ] ) ) {
109
- $is_active = $options[$id] ;
110
- }
111
- else {
112
- $is_active = LiteSpeed_Cache::config( $id ) ;
113
- }
114
-
115
- if ( ! $is_active ) {
116
- self::clear() ;
117
- }
118
-
119
- }
120
-
121
- /**
122
- * Schedule cron img optm auto request
123
- *
124
- * @since 2.4.1
125
- * @access public
126
- */
127
- public static function schedule_filter_imgoptm_auto_request()
128
- {
129
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
130
-
131
- // Schedule event here to see if it can lost again or not
132
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_IMGOPTM_AUTO_REQUEST ) ) {
133
- LiteSpeed_Cache_Log::debug( 'Cron log: ......img optm auto request cron hook register......' ) ;
134
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK_IMGOPTM_AUTO_REQUEST ) ;
135
- }
136
- }
137
-
138
- /**
139
- * Schedule cron img optimization
140
- *
141
- * @since 1.6.1
142
- * @access public
143
- */
144
- public static function schedule_filter_imgoptm()
145
- {
146
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
147
-
148
- // Schedule event here to see if it can lost again or not
149
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_IMGOPTM ) ) {
150
- LiteSpeed_Cache_Log::debug( 'Cron log: ......img optimization cron hook register......' ) ;
151
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK_IMGOPTM ) ;
152
- }
153
- }
154
-
155
- /**
156
- * Schedule cron ccss generation
157
- *
158
- * @since 2.3
159
- * @access public
160
- */
161
- public static function schedule_filter_ccss()
162
- {
163
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
164
-
165
- // Schedule event here to see if it can lost again or not
166
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_CCSS ) ) {
167
- LiteSpeed_Cache_Log::debug( 'Cron log: ......ccss cron hook register......' ) ;
168
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK_CCSS ) ;
169
- }
170
- }
171
-
172
- /**
173
- * Schedule cron image placeholder generation
174
- *
175
- * @since 2.5.1
176
- * @access public
177
- */
178
- public static function schedule_filter_placeholder()
179
- {
180
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter' ) ;
181
-
182
- // Schedule event here to see if it can lost again or not
183
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_IMG_PLACEHOLDER ) ) {
184
- LiteSpeed_Cache_Log::debug( 'Cron log: ......image placeholder cron hook register......' ) ;
185
- wp_schedule_event( time(), self::CRON_FITLER, self::CRON_ACTION_HOOK_IMG_PLACEHOLDER ) ;
186
- }
187
- }
188
-
189
- /**
190
- * Schedule cron crawler
191
- *
192
- * @since 1.1.0
193
- * @access public
194
- */
195
- public static function schedule_filter_crawler()
196
- {
197
- add_filter( 'cron_schedules', 'LiteSpeed_Cache_Task::lscache_cron_filter_crawler' ) ;
198
-
199
- // Schedule event here to see if it can lost again or not
200
- if( ! wp_next_scheduled( self::CRON_ACTION_HOOK_CRAWLER ) ) {
201
- LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook register......' ) ;
202
- wp_schedule_event( time(), self::CRON_FITLER_CRAWLER, self::CRON_ACTION_HOOK_CRAWLER ) ;
203
- }
204
- }
205
-
206
- /**
207
- * Register cron interval imgoptm
208
- *
209
- * @since 1.6.1
210
- * @access public
211
- * @param array $schedules WP Hook
212
- */
213
- public static function lscache_cron_filter( $schedules )
214
- {
215
- if ( ! array_key_exists( self::CRON_FITLER, $schedules ) ) {
216
- $schedules[ self::CRON_FITLER ] = array(
217
- 'interval' => 60,
218
- 'display' => __( 'LiteSpeed Cache Custom Cron Common', 'litespeed-cache' ),
219
- ) ;
220
- }
221
- return $schedules ;
222
- }
223
-
224
- /**
225
- * Register cron interval
226
- *
227
- * @since 1.1.0
228
- * @access public
229
- * @param array $schedules WP Hook
230
- */
231
- public static function lscache_cron_filter_crawler( $schedules )
232
- {
233
- $interval = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::CRWL_RUN_INTERVAL ) ;
234
- // $wp_schedules = wp_get_schedules() ;
235
- if ( ! array_key_exists( self::CRON_FITLER_CRAWLER, $schedules ) ) {
236
- // LiteSpeed_Cache_Log::debug('Crawler cron log: ......cron filter '.$interval.' added......') ;
237
- $schedules[ self::CRON_FITLER_CRAWLER ] = array(
238
- 'interval' => $interval,
239
- 'display' => __( 'LiteSpeed Cache Custom Cron Crawler', 'litespeed-cache' ),
240
- ) ;
241
- }
242
- return $schedules ;
243
- }
244
-
245
- /**
246
- * Clear cron
247
- *
248
- * @since 1.1.0
249
- * @access public
250
- */
251
- public static function clear()
252
- {
253
- LiteSpeed_Cache_Log::debug( 'Crawler cron log: ......cron hook cleared......' ) ;
254
- wp_clear_scheduled_hook( self::CRON_ACTION_HOOK_CRAWLER ) ;
255
- }
256
-
257
-
258
- /**
259
- * Get the current instance object.
260
- *
261
- * @since 1.6
262
- * @access public
263
- * @return Current class instance.
264
- */
265
- public static function get_instance()
266
- {
267
- if ( ! isset( self::$_instance ) ) {
268
- self::$_instance = new self() ;
269
- }
270
-
271
- return self::$_instance ;
272
- }
273
-
274
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/utility.class.php DELETED
@@ -1,833 +0,0 @@
1
- <?php
2
- /**
3
- * The utility class.
4
- *
5
- * @since 1.1.5
6
- * @since 1.5 Moved into /inc
7
- */
8
-
9
- if ( ! defined( 'WPINC' ) ) {
10
- die ;
11
- }
12
-
13
- class LiteSpeed_Cache_Utility
14
- {
15
- private static $_instance ;
16
- private static $_internal_domains ;
17
-
18
- const TYPE_SCORE_CHK = 'score_chk' ;
19
-
20
- /**
21
- * Check if an URL or current page is REST req or not
22
- *
23
- * @since 2.9.3
24
- * @deprecated 2.9.4 Moved to REST class
25
- * @access public
26
- */
27
- public static function is_rest( $url = false )
28
- {
29
- return false ;
30
- }
31
-
32
- /**
33
- * Check page score
34
- *
35
- * @since 2.9
36
- * @access private
37
- */
38
- private function _score_check()
39
- {
40
- $_gui = LiteSpeed_Cache_GUI::get_instance() ;
41
-
42
- $_summary = $_gui->get_summary() ;
43
-
44
- $_summary[ 'score.last_check' ] = time() ;
45
- $_gui->save_summary( $_summary ) ;
46
-
47
- $score = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_PAGESCORE, false, true, true, 600 ) ;
48
- $_summary[ 'score.data' ] = $score ;
49
- $_gui->save_summary( $_summary ) ;
50
-
51
- LiteSpeed_Cache_Log::debug( '[Util] Saved page score ', $score ) ;
52
-
53
- exit() ;
54
- }
55
-
56
- /**
57
- * Check latest version
58
- *
59
- * @since 2.9
60
- * @access public
61
- */
62
- public static function version_check( $src = false )
63
- {
64
- // Check latest stable version allowed to upgrade
65
- $url = 'https://wp.api.litespeedtech.com/auto_upgrade_v?v=' . LiteSpeed_Cache::PLUGIN_VERSION . '&src=' . $src ;
66
-
67
- if ( defined( 'LITESPEED_ERR' ) ) {
68
- $url .= '&err=' . base64_encode( ! is_string( LITESPEED_ERR ) ? json_encode( LITESPEED_ERR ) : LITESPEED_ERR ) ;
69
- }
70
-
71
- $response = wp_remote_get( $url, array( 'timeout' => 15 ) ) ;
72
- if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
73
- return false ;
74
- }
75
-
76
- return $response[ 'body' ] ;
77
- }
78
-
79
- /**
80
- * Get current page type
81
- *
82
- * @since 2.9
83
- */
84
- public static function page_type()
85
- {
86
- global $wp_query ;
87
- $page_type = 'default' ;
88
-
89
- if ( $wp_query->is_page ) {
90
- $page_type = is_front_page() ? 'front' : 'page' ;
91
- }
92
- elseif ( $wp_query->is_home ) {
93
- $page_type = 'home' ;
94
- }
95
- elseif ( $wp_query->is_single ) {
96
- // $page_type = $wp_query->is_attachment ? 'attachment' : 'single' ;
97
- $page_type = get_post_type() ;
98
- }
99
- elseif ( $wp_query->is_category ) {
100
- $page_type = 'category' ;
101
- }
102
- elseif ( $wp_query->is_tag ) {
103
- $page_type = 'tag' ;
104
- }
105
- elseif ( $wp_query->is_tax ) {
106
- $page_type = 'tax' ;
107
- // $page_type = get_queried_object()->taxonomy ;
108
- }
109
- elseif ( $wp_query->is_archive ) {
110
- if ( $wp_query->is_day ) {
111
- $page_type = 'day' ;
112
- }
113
- elseif ( $wp_query->is_month ) {
114
- $page_type = 'month' ;
115
- }
116
- elseif ( $wp_query->is_year ) {
117
- $page_type = 'year' ;
118
- }
119
- elseif ( $wp_query->is_author ) {
120
- $page_type = 'author' ;
121
- }
122
- else {
123
- $page_type = 'archive' ;
124
- }
125
- }
126
- elseif ( $wp_query->is_search ) {
127
- $page_type = 'search' ;
128
- }
129
- elseif ( $wp_query->is_404 ) {
130
- $page_type = '404' ;
131
- }
132
-
133
- return $page_type;
134
-
135
- // if ( is_404() ) {
136
- // $page_type = '404' ;
137
- // }
138
- // elseif ( is_singular() ) {
139
- // $page_type = get_post_type() ;
140
- // }
141
- // elseif ( is_home() && get_option( 'show_on_front' ) == 'page' ) {
142
- // $page_type = 'home' ;
143
- // }
144
- // elseif ( is_front_page() ) {
145
- // $page_type = 'front' ;
146
- // }
147
- // elseif ( is_tax() ) {
148
- // $page_type = get_queried_object()->taxonomy ;
149
- // }
150
- // elseif ( is_category() ) {
151
- // $page_type = 'category' ;
152
- // }
153
- // elseif ( is_tag() ) {
154
- // $page_type = 'tag' ;
155
- // }
156
-
157
- // return $page_type ;
158
- }
159
-
160
- /**
161
- * Get ping speed
162
- *
163
- * @since 2.9
164
- */
165
- public static function ping( $domain )
166
- {
167
- if ( strpos( $domain, ':' ) ) {
168
- $domain = parse_url( $domain, PHP_URL_HOST ) ;
169
- }
170
- $starttime = microtime( true ) ;
171
- $file = fsockopen( $domain, 80, $errno, $errstr, 10 ) ;
172
- $stoptime = microtime( true ) ;
173
- $status = 0 ;
174
-
175
- if ( ! $file ) $status = 99999 ;// Site is down
176
- else {
177
- fclose( $file ) ;
178
- $status = ( $stoptime - $starttime ) * 1000 ;
179
- $status = floor( $status ) ;
180
- }
181
-
182
- LiteSpeed_Cache_Log::debug( "[Util] ping [Domain] $domain \t[Speed] $status" ) ;
183
-
184
- return $status ;
185
- }
186
-
187
- /**
188
- * Set seconds/timestamp to readable format
189
- *
190
- * @since 1.6.5
191
- * @access public
192
- */
193
- public static function readable_time( $seconds_or_timestamp, $timeout = 3600, $backward = true )
194
- {
195
-
196
- if ( strlen( $seconds_or_timestamp ) == 10 ) {
197
- $seconds = time() - $seconds_or_timestamp ;
198
- if ( $seconds > $timeout ) {
199
- return date( 'm/d/Y H:i:s', $seconds_or_timestamp + LITESPEED_TIME_OFFSET ) ;
200
- }
201
- }
202
- else {
203
- $seconds = $seconds_or_timestamp ;
204
- }
205
-
206
- $res = '';
207
- if ( $seconds > 86400 ) {
208
- $num = floor( $seconds / 86400 ) ;
209
- $res .= $num . 'd' ;
210
- $seconds %= 86400 ;
211
- }
212
-
213
- if ( $seconds > 3600 ) {
214
- if ( $res ) {
215
- $res .= ', ' ;
216
- }
217
- $num = floor( $seconds / 3600 ) ;
218
- $res .= $num . 'h' ;
219
- $seconds %= 3600 ;
220
- }
221
-
222
- if ( $seconds > 60 ) {
223
- if ( $res ) {
224
- $res .= ', ' ;
225
- }
226
- $num = floor( $seconds / 60 ) ;
227
- $res .= $num . 'm' ;
228
- $seconds %= 60 ;
229
- }
230
-
231
- if ( $seconds > 0 ) {
232
- if ( $res ) {
233
- $res .= ' ' ;
234
- }
235
- $res .= $seconds . 's' ;
236
- }
237
-
238
- if ( ! $res ) {
239
- return $backward ? __( 'just now', 'litespeed-cache' ) : __( 'right now', 'litespeed-cache' ) ;
240
- }
241
-
242
- $res = $backward ? sprintf( __( ' %s ago', 'litespeed-cache' ), $res ) : $res ;
243
-
244
- return $res ;
245
- }
246
-
247
-
248
- /**
249
- * Convert array to string
250
- *
251
- * @since 1.6
252
- * @access public
253
- * @return string
254
- */
255
- public static function arr2str( $arr )
256
- {
257
- if ( ! is_array( $arr ) ) {
258
- return $arr ;
259
- }
260
-
261
- return base64_encode( json_encode( $arr ) ) ;
262
- }
263
-
264
- /**
265
- * Get human readable size
266
- *
267
- * @since 1.6
268
- * @access public
269
- * @return string
270
- */
271
- public static function real_size( $filesize )
272
- {
273
- if ( $filesize >= 1073741824 ) {
274
- $filesize = round( $filesize / 1073741824 * 100 ) / 100 . 'G' ;
275
- }
276
- elseif ( $filesize >= 1048576 ) {
277
- $filesize = round( $filesize / 1048576 * 100 ) / 100 . 'M' ;
278
- }
279
- elseif ( $filesize >= 1024 ) {
280
- $filesize = round( $filesize / 1024 * 100 ) / 100 . 'K' ;
281
- }
282
- else {
283
- $filesize = $filesize . 'B' ;
284
- }
285
- return $filesize ;
286
- }
287
-
288
- /**
289
- * Parse attributes from string
290
- *
291
- * @since 1.2.2
292
- * @since 1.4 Moved from optimize to utility
293
- * @access private
294
- * @param string $str
295
- * @return array All the attributes
296
- */
297
- public static function parse_attr( $str )
298
- {
299
- $attrs = array() ;
300
- preg_match_all( '#([\w-]+)=["\']([^"\']*)["\']#isU', $str, $matches, PREG_SET_ORDER ) ;
301
- foreach ( $matches as $match ) {
302
- $attrs[ $match[ 1 ] ] = trim( $match[ 2 ] ) ;
303
- }
304
- return $attrs ;
305
- }
306
-
307
- /**
308
- * Get url based on permalink setting
309
- *
310
- * @since 1.3
311
- * @access public
312
- * @return string
313
- */
314
- public static function get_permalink_url( $relative_url )
315
- {
316
- return $GLOBALS[ 'wp_rewrite' ]->using_permalinks() ? home_url( $relative_url ) : home_url() . '/?' . $relative_url ;
317
- }
318
-
319
- /**
320
- * Check if an array has a string
321
- *
322
- * Support $ exact match
323
- *
324
- * @since 1.3
325
- * @access private
326
- * @param string $needle The string to search with
327
- * @param array $haystack
328
- * @return bool|string False if not found, otherwise return the matched string in haystack.
329
- */
330
- public static function str_hit_array( $needle, $haystack, $has_ttl = false )
331
- {
332
- /**
333
- * Safety check to avoid PHP warning
334
- * @see https://github.com/litespeedtech/lscache_wp/pull/131/commits/45fc03af308c7d6b5583d1664fad68f75fb6d017
335
- */
336
- if ( ! is_array( $haystack ) ) {
337
- LiteSpeed_Cache_Log::debug( "[Util] ❌ bad param in str_hit_array()!" ) ;
338
-
339
- return false ;
340
- }
341
-
342
- $hit = false ;
343
- $this_ttl = 0 ;
344
- foreach( $haystack as $item ) {
345
- if ( ! $item ) {
346
- continue ;
347
- }
348
-
349
- if ( $has_ttl ) {
350
- $this_ttl = 0 ;
351
- $item = explode( ' ', $item ) ;
352
- if ( ! empty( $item[ 1 ] ) ) {
353
- $this_ttl = $item[ 1 ] ;
354
- }
355
- $item = $item[ 0 ] ;
356
- }
357
-
358
- if ( substr( $item, -1 ) === '$' ) {
359
- // do exact match
360
- if ( substr( $item, 0, -1 ) === $needle ) {
361
- $hit = $item ;
362
- break ;
363
- }
364
- }
365
- elseif ( substr( $item, 0, 1 ) === '^' ) {
366
- // match beginning
367
- if ( substr( $item, 1 ) === substr( $needle, 0, strlen( $item ) - 1 ) ) {
368
- $hit = $item ;
369
- break ;
370
- }
371
- }
372
- else {
373
- if ( strpos( $needle, $item ) !== false ) {
374
- $hit = $item ;
375
- break ;
376
- }
377
- }
378
- }
379
-
380
- if ( $hit ) {
381
- if ( $has_ttl ) {
382
- return array( $hit, $this_ttl ) ;
383
- }
384
-
385
- return $hit ;
386
- }
387
-
388
- return false ;
389
- }
390
-
391
- /**
392
- * Improve compatibility to PHP old versions
393
- *
394
- * @since 1.2.2
395
- *
396
- */
397
- public static function compatibility()
398
- {
399
- require_once LSCWP_DIR . 'lib/litespeed-php-compatibility.func.php' ;
400
- }
401
-
402
- /**
403
- * Convert URI to URL
404
- *
405
- * @since 1.3
406
- * @access public
407
- * @param string $uri `xx/xx.html` or `/subfolder/xx/xx.html`
408
- * @return string http://www.example.com/subfolder/xx/xx.html
409
- */
410
- public static function uri2url( $uri )
411
- {
412
- if ( substr( $uri, 0, 1 ) === '/' ) {
413
- self::domain_const() ;
414
- $url = LSCWP_DOMAIN . $uri ;
415
- }
416
- else {
417
- $url = home_url( '/' ) . $uri ;
418
- }
419
-
420
- return $url ;
421
- }
422
-
423
- /**
424
- * Convert URL to URI
425
- *
426
- * @since 1.2.2
427
- * @since 1.6.2.1 Added 2nd param keep_qs
428
- * @access public
429
- */
430
- public static function url2uri( $url, $keep_qs = false )
431
- {
432
- $url = trim( $url ) ;
433
- $uri = @parse_url( $url, PHP_URL_PATH ) ;
434
- $qs = @parse_url( $url, PHP_URL_QUERY ) ;
435
-
436
- if ( ! $keep_qs || ! $qs ) {
437
- return $uri ;
438
- }
439
-
440
- return $uri . '?' . $qs ;
441
- }
442
-
443
- /**
444
- * Make URL to be relative
445
- *
446
- * NOTE: for subfolder home_url, will keep subfolder part (strip nothing but scheme and host)
447
- *
448
- * @param string $url
449
- * @return string Relative URL, start with /
450
- */
451
- public static function make_relative( $url )
452
- {
453
- // replace home_url if the url is full url
454
- self::domain_const() ;
455
- if ( strpos( $url, LSCWP_DOMAIN ) === 0 ) {
456
- $url = substr( $url, strlen( LSCWP_DOMAIN ) ) ;
457
- }
458
- return trim( $url ) ;
459
- }
460
-
461
- /**
462
- * Convert URL to domain only
463
- *
464
- * @since 1.7.1
465
- */
466
- public static function parse_domain( $url )
467
- {
468
- $url = @parse_url( $url ) ;
469
- if ( empty( $url[ 'host' ] ) ) {
470
- return '' ;
471
- }
472
-
473
- if ( ! empty( $url[ 'scheme' ] ) ) {
474
- return $url[ 'scheme' ] . '://' . $url[ 'host' ] ;
475
- }
476
-
477
- return '//' . $url[ 'host' ] ;
478
- }
479
-
480
- /**
481
- * Generate domain const
482
- *
483
- * This will generate http://www.example.com even there is a subfolder in home_url setting
484
- *
485
- * Const LSCWP_DOMAIN has NO trailing /
486
- *
487
- * @since 1.3
488
- * @access public
489
- */
490
- public static function domain_const()
491
- {
492
- if ( defined( 'LSCWP_DOMAIN' ) ) {
493
- return ;
494
- }
495
-
496
- $home_url = get_home_url( is_multisite() ? get_current_blog_id() : null ) ;
497
-
498
- self::compatibility() ;
499
- $domain = http_build_url( $home_url, array(), HTTP_URL_STRIP_ALL ) ;
500
-
501
- define( 'LSCWP_DOMAIN', $domain ) ;
502
- }
503
-
504
- /**
505
- * Array map one textarea to sanitize the url
506
- *
507
- * @since 1.3
508
- * @access public
509
- * @param string $content
510
- * @param bool $type String handler type
511
- * @return string
512
- */
513
- public static function sanitize_lines( $arr, $type = null )
514
- {
515
- if ( ! $arr ) {
516
- return $arr ;
517
- }
518
-
519
- if ( ! is_array( $arr ) ) {
520
- $arr = explode( "\n", $arr ) ;
521
- }
522
-
523
- $arr = array_map( 'trim', $arr ) ;
524
- if ( $type === 'uri' ) {
525
- $arr = array_map( 'LiteSpeed_Cache_Utility::url2uri', $arr ) ;
526
- }
527
- if ( $type === 'relative' ) {
528
- $arr = array_map( 'LiteSpeed_Cache_Utility::make_relative', $arr ) ;// Remove domain
529
- }
530
- if ( $type === 'domain' ) {
531
- $arr = array_map( 'LiteSpeed_Cache_Utility::parse_domain', $arr ) ;// Only keep domain
532
- }
533
- $arr = array_map( 'trim', $arr ) ;
534
- $arr = array_unique( $arr ) ;
535
- $arr = array_filter( $arr ) ;
536
- if ( $type === 'array' ) {
537
- return $arr ;
538
- }
539
- return implode( "\n", $arr ) ;
540
- }
541
-
542
- /**
543
- * Builds an url with an action and a nonce.
544
- *
545
- * Assumes user capabilities are already checked.
546
- *
547
- * @since 1.6 Changed order of 2nd&3rd param, changed 3rd param `append_str` to 2nd `type`
548
- * @access public
549
- * @param string $action The LSCWP_CTRL action to do in the url.
550
- * @param string $is_ajax if is AJAX call or not
551
- * @param string $type The appending type to url
552
- * @return string The built url.
553
- */
554
- public static function build_url( $action, $type = false, $is_ajax = false, $page = null, $append_arr = null )
555
- {
556
- $prefix = '?' ;
557
-
558
- if ( ! $is_ajax ) {
559
- if ( $page ) {
560
- // If use admin url
561
- if ( $page === true ) {
562
- $page = 'admin.php' ;
563
- }
564
- else {
565
- if ( strpos( $page, '?' ) !== false ) {
566
- $prefix = '&' ;
567
- }
568
- }
569
- $combined = $page . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
570
- }
571
- else {
572
- // Current page rebuild URL
573
- $params = $_GET ;
574
-
575
- if ( ! empty( $params ) ) {
576
- if ( isset( $params[ 'LSCWP_CTRL' ] ) ) {
577
- unset( $params[ 'LSCWP_CTRL' ] ) ;
578
- }
579
- if ( isset( $params[ '_wpnonce' ] ) ) {
580
- unset( $params[ '_wpnonce' ] ) ;
581
- }
582
- if ( ! empty( $params ) ) {
583
- $prefix .= http_build_query( $params ) . '&' ;
584
- }
585
- }
586
- global $pagenow ;
587
- $combined = $pagenow . $prefix . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
588
- }
589
- }
590
- else {
591
- $combined = 'admin-ajax.php?action=litespeed_ajax&' . LiteSpeed_Cache::ACTION_KEY . '=' . $action ;
592
- }
593
-
594
- if ( is_network_admin() ) {
595
- $prenonce = network_admin_url( $combined ) ;
596
- }
597
- else {
598
- $prenonce = admin_url( $combined ) ;
599
- }
600
- $url = wp_nonce_url( $prenonce, $action, LiteSpeed_Cache::NONCE_NAME ) ;
601
-
602
- if ( $type ) {
603
- // Remove potential param `type` from url
604
- $url = parse_url( htmlspecialchars_decode( $url ) ) ;
605
- parse_str( $url[ 'query' ], $query ) ;
606
-
607
- $built_arr = array_merge( $query, LiteSpeed_Cache_Router::build_type( $type ) ) ;
608
- if ( $append_arr ) {
609
- $built_arr = array_merge( $built_arr, $append_arr ) ;
610
- }
611
- $url[ 'query' ] = http_build_query( $built_arr ) ;
612
- self::compatibility() ;
613
- $url = http_build_url( $url ) ;
614
- $url = htmlspecialchars( $url, ENT_QUOTES, 'UTF-8' ) ;
615
- }
616
-
617
- return $url ;
618
- }
619
-
620
- /**
621
- * Check if the host is the internal host
622
- *
623
- * @since 1.2.3
624
- *
625
- */
626
- public static function internal( $host )
627
- {
628
- if ( ! defined( 'LITESPEED_FRONTEND_HOST' ) ) {
629
- if ( defined( 'WP_HOME' ) ) {
630
- $home_host = WP_HOME ;// Also think of `WP_SITEURL`
631
- }
632
- else {
633
- $home_host = get_option( 'home' ) ;
634
- }
635
- define( 'LITESPEED_FRONTEND_HOST', parse_url( $home_host, PHP_URL_HOST ) ) ;
636
- }
637
-
638
- if ( $host === LITESPEED_FRONTEND_HOST ) {
639
- return true ;
640
- }
641
-
642
- /**
643
- * Filter for multiple domains
644
- * @since 2.9.4
645
- */
646
- if ( ! isset( self::$_internal_domains ) ) {
647
- self::$_internal_domains = apply_filters( 'litespeed_internal_domains', array() ) ;
648
- }
649
-
650
- if ( self::$_internal_domains ) {
651
- return in_array( $host, self::$_internal_domains ) ;
652
- }
653
-
654
- return false ;
655
- }
656
-
657
- /**
658
- * Check if an URL is a internal existing file
659
- *
660
- * @since 1.2.2
661
- * @since 1.6.2 Moved here from optm.cls due to usage of media.cls
662
- * @access public
663
- * @return string|bool The real path of file OR false
664
- */
665
- public static function is_internal_file( $url, $addition_postfix = false )
666
- {
667
- $url_parsed = parse_url( $url ) ;
668
- if ( isset( $url_parsed[ 'host' ] ) && ! self::internal( $url_parsed[ 'host' ] ) ) {
669
- // Check if is cdn path
670
- // Do this to avoid user hardcoded src in tpl
671
- if ( ! LiteSpeed_Cache_CDN::internal( $url_parsed[ 'host' ] ) ) {
672
- LiteSpeed_Cache_Log::debug2( '[Util] external' ) ;
673
- return false ;
674
- }
675
- }
676
-
677
- if ( empty( $url_parsed[ 'path' ] ) ) {
678
- return false ;
679
- }
680
-
681
- // Need to replace child blog path for assets, ref: .htaccess
682
- if ( is_multisite() && defined( 'PATH_CURRENT_SITE' ) ) {
683
- $pattern = '#^' . PATH_CURRENT_SITE . '([_0-9a-zA-Z-]+/)(wp-(content|admin|includes))#U' ;
684
- $replacement = PATH_CURRENT_SITE . '$2' ;
685
- $url_parsed[ 'path' ] = preg_replace( $pattern, $replacement, $url_parsed[ 'path' ] ) ;
686
- // $current_blog = (int) get_current_blog_id() ;
687
- // $main_blog_id = (int) get_network()->site_id ;
688
- // if ( $current_blog === $main_blog_id ) {
689
- // define( 'LITESPEED_IS_MAIN_BLOG', true ) ;
690
- // }
691
- // else {
692
- // define( 'LITESPEED_IS_MAIN_BLOG', false ) ;
693
- // }
694
- }
695
-
696
- // Parse file path
697
- /**
698
- * Trying to fix pure /.htaccess rewrite to /wordpress case
699
- *
700
- * Add `define( 'LITESPEED_WP_REALPATH', '/wordpress' ) ;` in wp-config.php in this case
701
- *
702
- * @internal #611001 - Combine & Minify not working?
703
- * @since 1.6.3
704
- */
705
- if ( substr( $url_parsed[ 'path' ], 0, 1 ) === '/' ) {
706
- if ( defined( 'LITESPEED_WP_REALPATH' ) ) {
707
- $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . LITESPEED_WP_REALPATH . $url_parsed[ 'path' ] ;
708
- }
709
- else {
710
- $file_path_ori = $_SERVER[ 'DOCUMENT_ROOT' ] . $url_parsed[ 'path' ] ;
711
- }
712
- }
713
- else {
714
- $file_path_ori = LiteSpeed_Cache_Router::frontend_path() . '/' . $url_parsed[ 'path' ] ;
715
- }
716
-
717
- /**
718
- * Added new file postfix to be check if passed in
719
- * @since 2.2.4
720
- */
721
- if ( $addition_postfix ) {
722
- $file_path_ori .= '.' . $addition_postfix ;
723
- }
724
-
725
- /**
726
- * Added this filter for those plugins which overwrite the filepath
727
- * @see #101091 plugin `Hide My WordPress`
728
- * @since 2.2.3
729
- */
730
- $file_path_ori = apply_filters( 'litespeed_realpath', $file_path_ori ) ;
731
-
732
- $file_path = realpath( $file_path_ori ) ;
733
- if ( ! is_file( $file_path ) ) {
734
- LiteSpeed_Cache_Log::debug2( '[Util] file not exist: ' . $file_path_ori ) ;
735
- return false ;
736
- }
737
-
738
- return array( $file_path, filesize( $file_path ) ) ;
739
- }
740
-
741
- /**
742
- * Replace url in srcset to new value
743
- *
744
- * @since 2.2.3
745
- */
746
- public static function srcset_replace( $content, $callback )
747
- {
748
- preg_match_all( '# srcset=([\'"])(.+)\g{1}#iU', $content, $matches ) ;
749
- $srcset_ori = array() ;
750
- $srcset_final = array() ;
751
- foreach ( $matches[ 2 ] as $k => $urls_ori ) {
752
-
753
- $urls_final = explode( ',', $urls_ori ) ;
754
-
755
- $changed = false ;
756
-
757
- foreach ( $urls_final as $k2 => $url_info ) {
758
- list( $url, $size ) = explode( ' ', trim( $url_info ) ) ;
759
-
760
- if ( ! $url2 = call_user_func( $callback, $url ) ) {
761
- continue ;
762
- }
763
-
764
- $changed = true ;
765
-
766
- $urls_final[ $k2 ] = str_replace( $url, $url2, $url_info ) ;
767
-
768
- LiteSpeed_Cache_Log::debug2( '[Util] - srcset replaced to ' . $url2 . ' ' . $size ) ;
769
- }
770
-
771
- if ( ! $changed ) {
772
- continue ;
773
- }
774
-
775
- $urls_final = implode( ',', $urls_final ) ;
776
-
777
- $srcset_ori[] = $matches[ 0 ][ $k ] ;
778
-
779
- $srcset_final[] = str_replace( $urls_ori, $urls_final, $matches[ 0 ][ $k ] ) ;
780
- }
781
-
782
- if ( $srcset_ori ) {
783
- $content = str_replace( $srcset_ori, $srcset_final, $content ) ;
784
- LiteSpeed_Cache_Log::debug2( '[Util] - srcset replaced' ) ;
785
- }
786
-
787
- return $content ;
788
-
789
- }
790
-
791
-
792
-
793
-
794
- /**
795
- * Handle all request actions from main cls
796
- *
797
- * @since 2.9
798
- * @access public
799
- */
800
- public static function handler()
801
- {
802
- $instance = self::get_instance() ;
803
-
804
- $type = LiteSpeed_Cache_Router::verify_type() ;
805
-
806
- switch ( $type ) {
807
- case self::TYPE_SCORE_CHK :
808
- $instance->_score_check() ;
809
- break ;
810
-
811
- default:
812
- break ;
813
- }
814
-
815
- LiteSpeed_Cache_Admin::redirect() ;
816
- }
817
-
818
- /**
819
- * Get the current instance object.
820
- *
821
- * @since 2.9
822
- * @access public
823
- * @return Current class instance.
824
- */
825
- public static function get_instance()
826
- {
827
- if ( ! isset( self::$_instance ) ) {
828
- self::$_instance = new self() ;
829
- }
830
-
831
- return self::$_instance ;
832
- }
833
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/advanced-cache.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * LiteSpeed Cache Plugin
5
- */
6
- if (!defined('ABSPATH')) {
7
- die();
8
- }
9
-
10
- define('LSCACHE_ADV_CACHE', true);
11
-
12
- /**
13
- * Because of the way it handles caching, the LiteSpeed Cache plugin for WordPress does not need an advanced-cache.php file.
14
- * For this reason, there is no real logic in this file. So why include it at all?
15
- * Setting the WP_CACHE global variable requires that an advanced-cache.php file exists.
16
- * This variable can help to increase compatibility as other plugins can check it to determine whether or not a cache is currently being used.
17
- * It can also help to avoid conflicts with other full page caches such as W3 Total Cache, etc.
18
- *
19
- */
20
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/deprecated-litespeed-cache-tags.class.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Deprecated Class for API backward compatibility to v1.1.2.2
5
- */
6
- class LiteSpeed_Cache_Tags
7
- {
8
- public static function add_purge_tag( $tag )
9
- {
10
- LiteSpeed_Cache_API::purge( $tag ) ;
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
includes/litespeed-cache-api.class.php DELETED
@@ -1,658 +0,0 @@
1
- <?php
2
- /**
3
- * The plugin API class.
4
- *
5
- * @since 1.1.3
6
- * @since 1.4 Moved into /inc
7
- * @package LiteSpeed_Cache
8
- * @subpackage LiteSpeed_Cache/inc
9
- * @author LiteSpeed Technologies <info@litespeedtech.com>
10
- */
11
-
12
- if ( ! defined( 'WPINC' ) ) {
13
- die ;
14
- }
15
-
16
- class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
17
- {
18
- const VERSION = LiteSpeed_Cache::PLUGIN_VERSION ;
19
-
20
- const TYPE_FEED = LiteSpeed_Cache_Tag::TYPE_FEED ;
21
- const TYPE_FRONTPAGE = LiteSpeed_Cache_Tag::TYPE_FRONTPAGE ;
22
- const TYPE_HOME = LiteSpeed_Cache_Tag::TYPE_HOME ;
23
- const TYPE_PAGES = LiteSpeed_Cache_Tag::TYPE_PAGES ;
24
- const TYPE_PAGES_WITH_RECENT_POSTS = LiteSpeed_Cache_Tag::TYPE_PAGES_WITH_RECENT_POSTS ;
25
- const TYPE_ERROR = LiteSpeed_Cache_Tag::TYPE_ERROR ;
26
- const TYPE_POST = LiteSpeed_Cache_Tag::TYPE_POST ;
27
- const TYPE_ARCHIVE_POSTTYPE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_POSTTYPE ;
28
- const TYPE_ARCHIVE_TERM = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_TERM ;
29
- const TYPE_AUTHOR = LiteSpeed_Cache_Tag::TYPE_AUTHOR ;
30
- const TYPE_ARCHIVE_DATE = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE ;
31
- const TYPE_BLOG = LiteSpeed_Cache_Tag::TYPE_BLOG ;
32
- const TYPE_LOGIN = LiteSpeed_Cache_Tag::TYPE_LOGIN ;
33
- const TYPE_URL = LiteSpeed_Cache_Tag::TYPE_URL ;
34
- const TYPE_WIDGET = LiteSpeed_Cache_Tag::TYPE_WIDGET ;
35
-
36
- const PARAM_NAME = LiteSpeed_Cache_ESI::PARAM_NAME ;
37
- const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
- const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
-
40
- /**
41
- * Disable All
42
- *
43
- * @since 2.9.7.2
44
- * @access public
45
- */
46
- public static function disable_all( $reason )
47
- {
48
- self::debug( '[API] Disabled_all due to ' . $reason ) ;
49
-
50
- ! defined( 'LITESPEED_DISABLE_ALL' ) && define( 'LITESPEED_DISABLE_ALL', true ) ;
51
- }
52
-
53
- /**
54
- * Force to set an option
55
- * Note: it will only affect the AFTER usage of that option
56
- *
57
- * @since 2.6
58
- * @access public
59
- */
60
- public static function force_option( $k, $v )
61
- {
62
- LiteSpeed_Cache_Config::get_instance()->force_option( $k, $v ) ;
63
- }
64
-
65
- /**
66
- * Start a to-be-removed html wrapper
67
- *
68
- * @since 1.4
69
- * @access public
70
- */
71
- public static function clean_wrapper_begin( $counter = false )
72
- {
73
- return LiteSpeed_Cache_GUI::clean_wrapper_begin( $counter ) ;
74
- }
75
-
76
- /**
77
- * End a to-be-removed html wrapper
78
- *
79
- * @since 1.4
80
- * @access public
81
- */
82
- public static function clean_wrapper_end( $counter = false )
83
- {
84
- return LiteSpeed_Cache_GUI::clean_wrapper_end( $counter ) ;
85
- }
86
-
87
- /**
88
- * Compare version
89
- *
90
- * @since 1.3
91
- * @access public
92
- */
93
- public static function v( $v )
94
- {
95
- return version_compare( self::VERSION, $v, '>=' ) ;
96
- }
97
-
98
- /**
99
- * Set mobile
100
- *
101
- * @since 1.1.3
102
- * @access public
103
- */
104
- public static function set_mobile()
105
- {
106
- LiteSpeed_Cache_Control::set_mobile() ;
107
- }
108
-
109
- /**
110
- * Set cache status to not cacheable
111
- *
112
- * @since 1.1.3
113
- * @access public
114
- */
115
- public static function set_cache_private()
116
- {
117
- LiteSpeed_Cache_Control::set_private() ;
118
- }
119
-
120
- /**
121
- * Set cache status to no vary
122
- *
123
- * @since 1.2.0
124
- * @access public
125
- */
126
- public static function set_cache_no_vary()
127
- {
128
- LiteSpeed_Cache_Control::set_no_vary() ;
129
- }
130
-
131
- /**
132
- * Set cache status to not cacheable
133
- *
134
- * @since 1.1.3
135
- * @access public
136
- */
137
- public static function set_nocache( $reason = false )
138
- {
139
- LiteSpeed_Cache_Control::set_nocache( $reason ?: 'api' ) ;
140
- }
141
-
142
- /**
143
- * Set cache status to cacheable ( By default cacheable status will be set when called WP hook `wp` )
144
- *
145
- * @since 2.2
146
- * @access public
147
- */
148
- public static function set_cacheable( $reason )
149
- {
150
- LiteSpeed_Cache_Control::set_cacheable( $reason ) ;
151
- }
152
-
153
- /**
154
- * Set cache status to force cacheable ( Will ignore most kinds of non-cacheable conditions )
155
- *
156
- * @since 2.2
157
- * @access public
158
- */
159
- public static function set_force_cacheable( $reason )
160
- {
161
- LiteSpeed_Cache_Control::force_cacheable( $reason ) ;
162
- }
163
-
164
- /**
165
- * Set cache to force public cache if cacheable ( Will ignore most kinds of non-cacheable conditions )
166
- *
167
- * @since 2.9.7.2
168
- * @access public
169
- */
170
- public static function set_force_public( $reason )
171
- {
172
- LiteSpeed_Cache_Control::set_public_forced( $reason ) ;
173
- }
174
-
175
- /**
176
- * Get current not cacheable status
177
- *
178
- * @since 1.1.3
179
- * @access public
180
- */
181
- public static function not_cacheable()
182
- {
183
- return ! LiteSpeed_Cache_Control::is_cacheable() ;
184
- }
185
-
186
- /**
187
- * Set cache control ttl to use frontpage ttl
188
- *
189
- * @since 1.1.3
190
- * @access public
191
- */
192
- public static function set_use_frontpage_ttl()
193
- {
194
- LiteSpeed_Cache_Control::set_custom_ttl( self::config( self::OPID_FRONT_PAGE_TTL ) ) ;
195
- }
196
-
197
- /**
198
- * Set cache control ttl
199
- *
200
- * @since 1.1.5
201
- * @access public
202
- */
203
- public static function set_ttl( $val )
204
- {
205
- LiteSpeed_Cache_Control::set_custom_ttl( $val ) ;
206
- }
207
-
208
- /**
209
- * Get current cache control ttl
210
- *
211
- * @since 1.1.5
212
- * @access public
213
- */
214
- public static function get_ttl()
215
- {
216
- return LiteSpeed_Cache_Control::get_ttl() ;
217
- }
218
-
219
- /**
220
- * Add public tag to cache
221
- *
222
- * @since 1.1.3
223
- * @access public
224
- */
225
- public static function tag_add($tags)
226
- {
227
- LiteSpeed_Cache_Tag::add($tags) ;
228
- }
229
-
230
- /**
231
- * Add public tag to cache
232
- *
233
- * @since 1.6.3
234
- * @access public
235
- */
236
- public static function add_private( $tags )
237
- {
238
- LiteSpeed_Cache_Tag::add_private( $tags ) ;
239
- }
240
-
241
- /**
242
- * Hook new vary cookies to vary finialization
243
- *
244
- * @since 2.6
245
- * @access public
246
- */
247
- public static function hook_vary_add( $hook )
248
- {
249
- add_action( 'litespeed_vary_add', $hook ) ;
250
- }
251
-
252
- /**
253
- * Add a new vary cookie
254
- *
255
- * @since 1.1.3
256
- * @since 2.7.1 Changed to filter hook instead of `LiteSpeed_Cache_Vary::add()`
257
- * @access public
258
- */
259
- public static function vary_add( $vary, $priority = 10 )
260
- {
261
- add_filter( 'litespeed_vary_cookies', function( $cookies ) use( $vary ) {
262
- if ( ! is_array( $vary ) ) {
263
- $vary = array( $vary ) ;
264
- }
265
- $cookies = array_merge( $cookies, $vary ) ;
266
- return $cookies ;
267
- }, $priority ) ;
268
- }
269
-
270
- /**
271
- * Hook vary cookies to vary finialization
272
- *
273
- * @since 2.7.1
274
- * @access public
275
- */
276
- public static function filter_vary_cookies( $hook, $priority = 10 )
277
- {
278
- add_filter( 'litespeed_vary_cookies', $hook, $priority ) ;
279
- }
280
-
281
- /**
282
- * Alter default vary cookie value
283
- *
284
- * Default vary cookie is an array before finalization, after that it will be combined to a string and store as default vary cookie name
285
- *
286
- * @since 2.6
287
- * @access public
288
- */
289
- public static function vary( $k, $v, $default = null )
290
- {
291
- if ( $v === $default ) {
292
- return ;
293
- }
294
- LiteSpeed_Cache_Vary::append( $k, $v ) ;
295
- }
296
-
297
- /**
298
- * Hook vary tags to default vary finialization
299
- *
300
- * @since 1.7.2
301
- * @access public
302
- */
303
- public static function hook_vary_finalize( $hook )
304
- {
305
- add_filter( 'litespeed_vary', $hook ) ;
306
- }
307
-
308
- /**
309
- * Force finalize vary even if its in an AJAX call
310
- *
311
- * @since 2.6
312
- * @access public
313
- */
314
- public static function force_vary()
315
- {
316
- LiteSpeed_Cache_Vary::can_ajax_vary() ;
317
- }
318
-
319
- /**
320
- * Hook vary appending to vary
321
- *
322
- * NOTE: This will add vary to rewrite rule
323
- *
324
- * @since 1.1.3
325
- * @since 2.7.1 This didn't work in 2.7- due to used add_action not filter
326
- * @access public
327
- */
328
- public static function hook_vary( $hook )
329
- {
330
- add_filter( 'litespeed_cache_api_vary', $hook ) ;
331
- }
332
-
333
- /**
334
- * Purge all action
335
- *
336
- * @since 1.1.3
337
- * @access public
338
- */
339
- public static function purge_all()
340
- {
341
- LiteSpeed_Cache_Purge::purge_all() ;
342
- }
343
-
344
- /**
345
- * Purge all private
346
- *
347
- * @since 1.6.3
348
- * @access public
349
- */
350
- public static function purge_private_all()
351
- {
352
- LiteSpeed_Cache_Purge::add_private( '*' ) ;
353
- }
354
-
355
- /**
356
- * Purge private tag
357
- *
358
- * @since 1.6.3
359
- * @access public
360
- */
361
- public static function purge_private( $tags )
362
- {
363
- LiteSpeed_Cache_Purge::add_private( $tags ) ;
364
- }
365
-
366
- /**
367
- * Purge single action
368
- *
369
- * @since 1.3
370
- * @access public
371
- * @param int $pid The ID of a post
372
- */
373
- public static function purge_post( $pid )
374
- {
375
- LiteSpeed_Cache_Purge::purge_post( $pid ) ;
376
- }
377
-
378
- /**
379
- * Add purge tags
380
- *
381
- * @since 1.1.3
382
- * @access public
383
- */
384
- public static function purge($tags)
385
- {
386
- LiteSpeed_Cache_Purge::add($tags) ;
387
- }
388
-
389
- /**
390
- * Build a switch div html snippet
391
- *
392
- * @since 1.1.3
393
- * @access public
394
- * @param string $id
395
- * @param boolean $return Return the html or echo it
396
- */
397
- public static function build_switch( $id, $checked = null, $return = false )
398
- {
399
- return LiteSpeed_Cache_Admin_Display::get_instance()->build_switch( $id, $checked, $return ) ;
400
- }
401
-
402
- /**
403
- * Filter the value for checkbox via input and id (enabled/disabled)
404
- *
405
- * @since 1.1.6
406
- * @access public
407
- * @param int $i