LiteSpeed Cache - Version 2.9

Version Description

  • Dec 31 2018 =
  • Media: Lazy Load Image Classname Excludes. (@thinkmedia)
  • : New EU/AS cloud servers for faster image optimization handling.
  • : New EU/AS cloud servers for faster CCSS generation.
  • : New EU/AS cloud servers for faster responsive placeholder generation.
  • Conf: Ability to set single options via link.
  • Cache: Ability to add custom TTLs to Force Cache URIs.
  • Purge: Added post type to Purge tags.
  • Purge: Redefined CCSS page types.
  • Core: Using Exception for .htaccess R/W.
  • IAPI: New cloud servers added. Please whitelist the new IAPI IP List.
  • Optm: Trim BOM when detecting if the page is HTML.
  • GUI: Added PageSpeed Score comparison into promotion banner.
  • GUI: Refactored promotion banner logic.
  • GUI: Removed page optimized comment when ESI Silence is requested.
  • GUI: WHM transient changed to option instead of transient when storing.
  • GUI: Appending more descriptions to CDN filetype setting.
  • IAPI: Removed duplicate messages.
  • IAPI: Removed taken_failed/client_pull(duplicated) status.
  • Debug: Environment report no longer generates hash for validation.
  • 3rd: Non-cacheable pages no longer punch ESI holes for Divi compatibility.
  • Network: Added slashes for mobile rules when activating plugin.
  • CCSS: Eliminated a PHP notice when appending CCSS.
Download this release

Release Info

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

Code changes from version 2.8.1 to 2.9

Files changed (51) hide show
  1. admin/admin-api.class.php +142 -16
  2. admin/litespeed-cache-admin-display.class.php +27 -22
  3. admin/litespeed-cache-admin-report.class.php +1 -1
  4. admin/litespeed-cache-admin-rules.class.php +23 -27
  5. admin/litespeed-cache-admin-settings.class.php +4 -0
  6. admin/tpl/crawler.php +0 -1
  7. admin/tpl/edit_htaccess.php +10 -5
  8. admin/tpl/image_optimization.php +0 -1
  9. admin/tpl/inc/banner_promo.ajax.php +13 -0
  10. admin/tpl/inc/banner_promo.new_version.php +96 -0
  11. admin/tpl/inc/banner_promo.php +172 -18
  12. admin/tpl/inc/banner_promo.slack.php +21 -19
  13. admin/tpl/inc/img_optm.summary.php +4 -5
  14. admin/tpl/manage.php +0 -1
  15. admin/tpl/setting/settings_cdn.php +4 -0
  16. admin/tpl/setting/settings_esi.php +1 -1
  17. admin/tpl/setting/settings_excludes.php +2 -0
  18. admin/tpl/setting/settings_inc.cache_mobile.php +0 -2
  19. admin/tpl/setting/settings_media.php +12 -0
  20. admin/tpl/settings.php +0 -2
  21. css/litespeed.css +192 -32
  22. img/lscwp-logo_256x256.png +0 -0
  23. img/lscwp-logo_90x90.png +0 -0
  24. inc/activation.class.php +90 -3
  25. inc/config.class.php +75 -0
  26. inc/const.cls.php +2 -0
  27. inc/control.class.php +4 -1
  28. inc/css.cls.php +4 -50
  29. inc/esi.class.php +4 -0
  30. inc/gui.class.php +173 -59
  31. inc/img_optm.class.php +5 -21
  32. inc/litespeed-cache.class.php +57 -28
  33. inc/media.class.php +13 -13
  34. inc/optimizer.class.php +3 -1
  35. inc/router.class.php +10 -3
  36. inc/tag.class.php +2 -0
  37. inc/utility.class.php +216 -5
  38. includes/litespeed-cache-activation.class.php +90 -3
  39. includes/litespeed-cache-config.class.php +75 -0
  40. includes/litespeed-cache-control.class.php +4 -1
  41. includes/litespeed-cache-esi.class.php +4 -0
  42. includes/litespeed-cache-gui.class.php +173 -59
  43. includes/litespeed-cache-router.class.php +10 -3
  44. includes/litespeed-cache-tag.class.php +2 -0
  45. includes/litespeed-cache-utility.class.php +216 -5
  46. includes/litespeed-cache.class.php +57 -28
  47. js/litespeed-cache-admin.js +3 -7
  48. languages/litespeed-cache.pot +417 -359
  49. lib/litespeed/litespeed-file.class.php +5 -4
  50. litespeed-cache.php +1 -1
  51. readme.txt +38 -10
admin/admin-api.class.php CHANGED
@@ -17,8 +17,10 @@ class LiteSpeed_Cache_Admin_API
17
private static $_instance ;
18
19
private $_iapi_key ;
20
21
const DB_API_KEY = 'litespeed_api_key' ;
22
const DB_API_KEY_HASH = 'litespeed_api_key_hash' ;
23
24
// For each request, send a callback to confirm
@@ -29,14 +31,16 @@ class LiteSpeed_Cache_Admin_API
29
const TYPE_RESET_KEY = 'reset_key' ;
30
31
const IAPI_ACTION_REQUEST_KEY = 'request_key' ;
32
const IAPI_ACTION_MEDIA_SYNC_DATA = 'media_sync_data' ;
33
const IAPI_ACTION_REQUEST_OPTIMIZE = 'request_optimize' ;
34
- const IAPI_ACTION_PULL_IMG = 'client_pull' ; // Deprecated
35
const IAPI_ACTION_IMG_TAKEN = 'client_img_taken' ;
36
- const IAPI_ACTION_PULL_IMG_FAILED = 'client_pull_failed' ;
37
const IAPI_ACTION_REQUEST_DESTROY = 'imgoptm_destroy' ;
38
const IAPI_ACTION_REQUEST_DESTROY_UNFINISHED = 'imgoptm_destroy_unfinished' ;
39
const IAPI_ACTION_ENV_REPORT = 'env_report' ;
40
41
/**
42
* Init
@@ -47,6 +51,7 @@ class LiteSpeed_Cache_Admin_API
47
private function __construct()
48
{
49
$this->_iapi_key = get_option( self::DB_API_KEY ) ?: '' ;
50
}
51
52
/**
@@ -207,16 +212,44 @@ class LiteSpeed_Cache_Admin_API
207
}
208
209
/**
210
- * Post data to LiteSpeed image server
211
*
212
* @since 1.6
213
* @access public
214
- * @param array $data
215
*/
216
- public static function post( $action, $data = false, $server = false, $no_hash = false )
217
{
218
$instance = self::get_instance() ;
219
220
/**
221
* All requests must have api_key first
222
* @since 1.6.5
@@ -225,19 +258,23 @@ class LiteSpeed_Cache_Admin_API
225
$instance->_request_key() ;
226
}
227
228
- return $instance->_post( $action, $data, $server, $no_hash ) ;
229
}
230
231
/**
232
* request key from LiteSpeed
233
*
234
* @since 1.5
235
* @access private
236
*/
237
private function _request_key()
238
{
239
// Send request to LiteSpeed
240
- $json = $this->_post( self::IAPI_ACTION_REQUEST_KEY, home_url() ) ;
241
242
// Check if get key&server correctly
243
if ( empty( $json[ 'auth_key' ] ) ) {
@@ -257,6 +294,52 @@ class LiteSpeed_Cache_Admin_API
257
$this->_iapi_key = $json[ 'auth_key' ] ;
258
}
259
260
/**
261
* delete key
262
*
@@ -266,21 +349,60 @@ class LiteSpeed_Cache_Admin_API
266
private function _reset_key()
267
{
268
delete_option( self::DB_API_KEY ) ;
269
- LiteSpeed_Cache_Log::debug( '[IAPI] delete auth_key' ) ;
270
271
$msg = __( 'Reset IAPI key successfully.', 'litespeed-cache' ) ;
272
LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
273
}
274
275
/**
276
- * Post data to LiteSpeed image server
277
*
278
* @since 1.6
279
* @access private
280
- * @param array $data
281
* @return string | array Must return an error msg string or json array
282
*/
283
- private function _post( $action, $data = false, $server = false, $no_hash = false )
284
{
285
$hash = 'no_hash' ;
286
if ( ! $no_hash ) {
@@ -292,6 +414,9 @@ class LiteSpeed_Cache_Admin_API
292
if ( $server == false ) {
293
$server = 'https://wp.api.litespeedtech.com' ;
294
}
295
296
$url = $server . '/' . $action ;
297
@@ -299,6 +424,7 @@ class LiteSpeed_Cache_Admin_API
299
300
$param = array(
301
'auth_key' => $this->_iapi_key,
302
'v' => LiteSpeed_Cache::PLUGIN_VERSION,
303
'hash' => $hash,
304
'data' => $data,
@@ -307,7 +433,7 @@ class LiteSpeed_Cache_Admin_API
307
* Extended timeout to avoid cUrl 28 timeout issue as we need callback validation
308
* @since 1.6.4
309
*/
310
- $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => 15 ) ) ;
311
312
if ( is_wp_error( $response ) ) {
313
$error_message = $response->get_error_message() ;
@@ -324,7 +450,7 @@ class LiteSpeed_Cache_Admin_API
324
$msg = __( 'Failed to post via WordPress', 'litespeed-cache' ) . ': ' . $response[ 'body' ] ;
325
LiteSpeed_Cache_Admin_Display::error( $msg ) ;
326
327
- return $response[ 'body' ] ;
328
}
329
330
if ( ! empty( $json[ '_err' ] ) ) {
@@ -332,7 +458,7 @@ class LiteSpeed_Cache_Admin_API
332
$msg = __( 'Failed to communicate with LiteSpeed image server', 'litespeed-cache' ) . ': ' . $json[ '_err' ] ;
333
$msg .= $this->_parse_link( $json ) ;
334
LiteSpeed_Cache_Admin_Display::error( $msg ) ;
335
- return $json[ '_err' ] ;
336
}
337
338
if ( ! empty( $json[ '_503' ] ) ) {
@@ -342,7 +468,7 @@ class LiteSpeed_Cache_Admin_API
342
$msg .= ' ' . $json[ '_503' ] ;
343
LiteSpeed_Cache_Admin_Display::error( $msg ) ;
344
345
- return $json[ '_503' ] ;
346
}
347
348
if ( ! empty( $json[ '_info' ] ) ) {
@@ -379,7 +505,7 @@ class LiteSpeed_Cache_Admin_API
379
380
$msg2 .= $this->_parse_link( $json ) ;
381
LiteSpeed_Cache_Admin_Display::error( $msg . $msg2 ) ;
382
- return $msg ;
383
}
384
385
return $json ;
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
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
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
/**
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
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' ] ) ) {
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
*
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 ) {
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
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,
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() ;
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' ] ) ) {
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' ] ) ) {
468
$msg .= ' ' . $json[ '_503' ] ;
469
LiteSpeed_Cache_Admin_Display::error( $msg ) ;
470
471
+ return false ;
472
}
473
474
if ( ! empty( $json[ '_info' ] ) ) {
505
506
$msg2 .= $this->_parse_link( $json ) ;
507
LiteSpeed_Cache_Admin_Display::error( $msg . $msg2 ) ;
508
+ return false ;
509
}
510
511
return $json ;
admin/litespeed-cache-admin-display.class.php CHANGED
@@ -21,7 +21,7 @@ class LiteSpeed_Cache_Admin_Display
21
const NOTICE_GREEN = 'notice notice-success' ;
22
const NOTICE_RED = 'notice notice-error' ;
23
const NOTICE_YELLOW = 'notice notice-warning' ;
24
- const TRANSIENT_LITESPEED_MESSAGE = 'litespeed_messages' ;
25
26
const PURGEBY_CAT = '0' ;
27
const PURGEBY_PID = '1' ;
@@ -71,7 +71,8 @@ class LiteSpeed_Cache_Admin_Display
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
}
76
77
/**
@@ -220,8 +221,9 @@ class LiteSpeed_Cache_Admin_Display
220
$localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
221
}
222
223
- if ( LiteSpeed_Cache_GUI::has_promo_msg() || LiteSpeed_Cache_GUI::has_promo_msg( 'slack' ) ) {
224
- $ajax_url_promo = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, true ) ;
225
$localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
226
}
227
@@ -469,10 +471,20 @@ class LiteSpeed_Cache_Admin_Display
469
{
470
// Bypass adding for CLI or cron
471
if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
472
return ;
473
}
474
475
- $messages = (array)get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
476
if( ! $messages ) {
477
$messages = array() ;
478
}
@@ -484,7 +496,7 @@ class LiteSpeed_Cache_Admin_Display
484
else {
485
$messages[] = self::build_notice($color, $msg) ;
486
}
487
- set_transient(self::TRANSIENT_LITESPEED_MESSAGE, $messages, 86400) ;
488
}
489
490
/**
@@ -495,7 +507,8 @@ class LiteSpeed_Cache_Admin_Display
495
*/
496
public function display_messages()
497
{
498
- $messages = get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
499
if( is_array($messages) ) {
500
$messages = array_unique($messages) ;
501
@@ -509,22 +522,14 @@ class LiteSpeed_Cache_Admin_Display
509
echo $msg ;
510
}
511
}
512
- delete_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
513
- }
514
515
- /**
516
- * Check if has new messages
517
- *
518
- * @since 1.1.0
519
- * @access public
520
- */
521
- public function check_messages()
522
- {
523
- $messages = get_transient(self::TRANSIENT_LITESPEED_MESSAGE) ;
524
- if( ! $messages ) {
525
- return ;
526
- }
527
- add_action(is_network_admin() ? 'network_admin_notices' : 'admin_notices', array($this, 'display_messages')) ;
528
}
529
530
/**
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' ;
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
/**
221
$localize_data[ 'ajax_url_dismiss_ruleconflict' ] = $ajax_url ;
222
}
223
224
+ $promo_tag = LiteSpeed_Cache_GUI::get_instance()->show_promo( true ) ;
225
+ if ( $promo_tag ) {
226
+ $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 ) ) ;
227
$localize_data[ 'ajax_url_promo' ] = $ajax_url_promo ;
228
}
229
471
{
472
// Bypass adding for CLI or cron
473
if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
474
+ // WP CLI will show the info directly
475
+ if ( defined( 'WP_CLI' ) && WP_CLI ) {
476
+ $msg = strip_tags( $msg ) ;
477
+ if ( $color == self::NOTICE_RED ) {
478
+ WP_CLI::error( $msg ) ;
479
+ }
480
+ else {
481
+ WP_CLI::success( $msg ) ;
482
+ }
483
+ }
484
return ;
485
}
486
487
+ $messages = (array)get_option( self::LITESPEED_MSG ) ;
488
if( ! $messages ) {
489
$messages = array() ;
490
}
496
else {
497
$messages[] = self::build_notice($color, $msg) ;
498
}
499
+ update_option( self::LITESPEED_MSG, $messages ) ;
500
}
501
502
/**
507
*/
508
public function display_messages()
509
{
510
+ // One time msg
511
+ $messages = get_option( self::LITESPEED_MSG ) ;
512
if( is_array($messages) ) {
513
$messages = array_unique($messages) ;
514
522
echo $msg ;
523
}
524
}
525
+ delete_option( self::LITESPEED_MSG ) ;
526
+
527
+ /**
528
+ * Check promo msg first
529
+ * @since 2.9
530
+ */
531
+ LiteSpeed_Cache_GUI::get_instance()->show_promo() ;
532
533
}
534
535
/**
admin/litespeed-cache-admin-report.class.php CHANGED
@@ -57,7 +57,7 @@ class LiteSpeed_Cache_Admin_Report
57
'env' => $report_con,
58
) ;
59
60
- $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_ENV_REPORT, LiteSpeed_Cache_Utility::arr2str( $data ) ) ;
61
62
if ( ! is_array( $json ) ) {
63
LiteSpeed_Cache_Log::debug( 'Env: Failed to post to LiteSpeed server ', $json ) ;
57
'env' => $report_con,
58
) ;
59
60
+ $json = LiteSpeed_Cache_Admin_API::post( LiteSpeed_Cache_Admin_API::IAPI_ACTION_ENV_REPORT, LiteSpeed_Cache_Utility::arr2str( $data ), false, true ) ;
61
62
if ( ! is_array( $json ) ) {
63
LiteSpeed_Cache_Log::debug( 'Env: Failed to post to LiteSpeed server ', $json ) ;
admin/litespeed-cache-admin-rules.class.php CHANGED
@@ -249,6 +249,7 @@ class LiteSpeed_Cache_Admin_Rules
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
* @access public
253
* @param string $path The path to get the content from.
254
* @return boolean True if succeeded, false otherwise.
@@ -261,14 +262,12 @@ class LiteSpeed_Cache_Admin_Rules
261
return "\n" ;
262
}
263
if ( ! self::readable($kind) || ! self::writable($kind) ) {
264
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_RW) ;
265
- return false ;
266
}
267
268
$content = file_get_contents($path) ;
269
if ( $content === false ) {
270
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_GET) ;
271
- return false ;
272
}
273
274
// Remove ^M characters.
@@ -298,29 +297,23 @@ class LiteSpeed_Cache_Admin_Rules
298
$path = $this->htaccess_path($kind) ;
299
300
if ( ! self::readable($kind) ) {
301
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_R) ;
302
- return false ;
303
}
304
305
if ( ! self::writable($kind) ) {
306
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_W) ;
307
- return false ;
308
}
309
310
//failed to backup, not good.
311
if ( $backup && $this->htaccess_backup($kind) === false ) {
312
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_BU) ;
313
- return false ;
314
}
315
316
// File put contents will truncate by default. Will create file if doesn't exist.
317
$ret = file_put_contents($path, $content, LOCK_EX) ;
318
if ( $ret === false ) {
319
- LiteSpeed_Cache_Admin_Display::add_error(LiteSpeed_Cache_Admin_Error::E_HTA_SAVE) ;
320
- return false ;
321
}
322
-
323
- return true ;
324
}
325
326
/**
@@ -438,13 +431,13 @@ class LiteSpeed_Cache_Admin_Rules
438
if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
439
return false ;
440
}
441
-
442
$rule_cookie = substr( $rule, strlen( 'RewriteRule .? - [E=' ), -1 ) ;
443
444
if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
445
return trim( $rule_cookie, '"' ) ;
446
}
447
-
448
return $rule_cookie ;
449
}
450
@@ -1016,23 +1009,26 @@ class LiteSpeed_Cache_Admin_Rules
1016
* Only admin can do this
1017
*
1018
* @since 1.0.4
1019
* @access public
1020
*/
1021
public function htaccess_editor_save()
1022
{
1023
- if ( isset($_POST[self::EDITOR_TEXTAREA_NAME]) ) {
1024
- $content = LiteSpeed_Cache_Admin::cleanup_text($_POST[self::EDITOR_TEXTAREA_NAME]) ;
1025
- $msg = $this->htaccess_save($content) ;
1026
- if ( $msg === true ) {
1027
- $msg = __('File Saved.', 'litespeed-cache') ;
1028
- $color = LiteSpeed_Cache_Admin_Display::NOTICE_GREEN ;
1029
- }
1030
- else {
1031
- $color = LiteSpeed_Cache_Admin_Display::NOTICE_RED ;
1032
- }
1033
- LiteSpeed_Cache_Admin_Display::add_notice($color, $msg) ;
1034
}
1035
1036
}
1037
1038
/**
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.
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.
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
/**
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
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
/**
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -757,6 +757,10 @@ class LiteSpeed_Cache_Admin_Settings
757
$id = LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ;
758
$this->_save_item( $id, 'uri' ) ;
759
760
$id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ;
761
$this->_save_item( $id ) ;
762
}
757
$id = LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ;
758
$this->_save_item( $id, 'uri' ) ;
759
760
+ // Update lazyload image classname excludes
761
+ $id = LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_CLS_EXC ;
762
+ $this->_save_item( $id ) ;
763
+
764
$id = LiteSpeed_Cache_Config::ITEM_MEDIA_WEBP_ATTRIBUTE ;
765
$this->_save_item( $id ) ;
766
}
admin/tpl/crawler.php CHANGED
@@ -18,7 +18,6 @@ $is_running = time() - $meta[ 'is_running' ] <= $_options[LiteSpeed_Cache_Config
18
19
$disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
20
21
- LiteSpeed_Cache_GUI::show_promo() ;
22
?>
23
24
<div class="wrap">
18
19
$disabled = LiteSpeed_Cache_Router::can_crawl() ? '' : 'disabled' ;
20
21
?>
22
23
<div class="wrap">
admin/tpl/edit_htaccess.php CHANGED
@@ -2,7 +2,15 @@
2
if (!defined('WPINC')) die;
3
4
$readonly = LiteSpeed_Cache_Admin_Rules::writable() ? '' : 'readonly';
5
- $content = LiteSpeed_Cache_Admin_Rules::get_instance()->htaccess_read();
6
$htaccess_path = LiteSpeed_Cache_Admin_Rules::get_frontend_htaccess() ;
7
8
// Check if there is `ExpiresDefault` in .htaccess
@@ -48,10 +56,7 @@ if ( defined( 'LITESPEED_ON' ) ) {
48
<?php if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT): ?>
49
<div class="litespeed-h3"><?php echo __('File editing is disabled in configuration.', 'litespeed-cache'); ?></div>
50
51
- <?php elseif($content === false): ?>
52
- <div class="litespeed-h3"><?php $this->display_messages(); ?></div>
53
-
54
- <?php else: ?>
55
56
<form method="post" action="admin.php?page=<?php echo LiteSpeed_Cache::PAGE_EDIT_HTACCESS; ?>">
57
<?php $this->form_action(LiteSpeed_Cache::ACTION_SAVE_HTACCESS); ?>
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
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); ?>
admin/tpl/image_optimization.php CHANGED
@@ -19,7 +19,6 @@ else {
19
$finished_percentage = 0 ;
20
}
21
22
- LiteSpeed_Cache_GUI::show_promo() ;
23
?>
24
25
<div class="wrap">
19
$finished_percentage = 0 ;
20
}
21
22
?>
23
24
<div class="wrap">
admin/tpl/inc/banner_promo.ajax.php ADDED
@@ -0,0 +1,13 @@
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_UTIL, LiteSpeed_Cache_Utility::TYPE_SCORE_CHK, true ) ;
5
+ $url = htmlspecialchars_decode( $url ) ;
6
+ ?>
7
+ <script type='text/javascript'>
8
+ document.addEventListener( 'DOMContentLoaded', function( event ) {
9
+ jQuery(document).ready( function() {
10
+ jQuery.get( '<?php echo $url ?>' ) ;
11
+ } ) ;
12
+ } ) ;
13
+ </script>
admin/tpl/inc/banner_promo.new_version.php ADDED
@@ -0,0 +1,96 @@
1
+ <?php
2
+ if ( ! defined( 'WPINC' ) ) die ;
3
+
4
+ /**
5
+ * NOTE: Only show for single site
6
+ */
7
+ if ( is_multisite() ) {
8
+ return ;
9
+ }
10
+
11
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
12
+ return ;
13
+ }
14
+
15
+ $current = get_site_transient( 'update_plugins' ) ;
16
+ if ( ! isset( $current->response[ LiteSpeed_Cache::PLUGIN_FILE ] ) ) {
17
+ return ;
18
+ }
19
+
20
+ $last_check = empty( $_summary[ 'new_version.last_check' ] ) ? 0 : $_summary[ 'new_version.last_check' ] ;
21
+ // Check once in a half day
22
+ if ( time() - $last_check > 43200 ) {
23
+ $_summary[ 'new_version.last_check' ] = time() ;
24
+ $this->save_summary( $_summary ) ;
25
+
26
+ // Detect version
27
+ $auto_v = LiteSpeed_Cache_Utility::version_check() ;
28
+ $_summary[ 'new_version.v' ] = $auto_v ;
29
+ $this->save_summary( $_summary ) ;
30
+ // After detect, don't show, just return and show next time
31
+ return ;
32
+ }
33
+
34
+ if ( ! isset( $_summary[ 'new_version.v' ] ) ) {
35
+ return ;
36
+ }
37
+
38
+ // Check if current version is newer than auto_v or not
39
+ if ( LiteSpeed_Cache_API::v( $_summary[ 'new_version.v' ] ) ) {
40
+ return ;
41
+ }
42
+
43
+ //********** Can show now **********//
44
+
45
+ $this->_promo_true = true ;
46
+
47
+ if ( $check_only ) {
48
+ return ;
49
+ }
50
+
51
+ ?>
52
+ <div class="litespeed-wrap notice notice-success litespeed-banner-promo-full">
53
+ <div class="litespeed-banner-promo-logo"></div>
54
+
55
+ <div class="litespeed-banner-promo-content">
56
+ <h3 class="litespeed-banner-title litespeed-top15"><?php echo __( 'New Version Available!', 'litespeed-cache' ) ; ?></h3>
57
+ <div class="litespeed-banner-description">
58
+ <div class="litespeed-banner-description-padding-right-15">
59
+ <p class="litespeed-banner-desciption-content">
60
+ <?php echo sprintf( __( 'New release %s is available now.', 'litespeed-cache' ), 'v' . $_summary[ 'new_version.v' ] ) ; ?>
61
+ </p>
62
+ </div>
63
+ <div class="litespeed-row-flex litespeed-banner-description">
64
+ <div class="litespeed-banner-description-padding-right-15">
65
+ <?php $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_ACTIVATION, LiteSpeed_Cache_Activation::TYPE_UPGRADE ) ; ?>
66
+ <a href="<?php echo $url ; ?>" class="litespeed-btn-success litespeed-btn-mini">
67
+ <i class="dashicons dashicons-image-rotate">&nbsp;</i>
68
+ <?php echo __( 'Upgrade', 'litespeed-cache' ) ; ?>
69
+ </a>
70
+ </div>
71
+ <div class="litespeed-banner-description-padding-right-15">
72
+ <?php
73
+ $cfg = array( LiteSpeed_Cache_Config::TYPE_SET . '[' . LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE . ']' => 1 ) ;
74
+ $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_CFG, LiteSpeed_Cache_Config::TYPE_SET, false, null, $cfg ) ;
75
+ ?>
76
+ <a href="<?php echo $url ; ?>" class="litespeed-btn-primary litespeed-btn-mini">
77
+ <i class="dashicons dashicons-update">&nbsp;</i>
78
+ <?php echo __( 'Turn On Auto Upgrade', 'litespeed-cache' ) ; ?>
79
+ </a>
80
+ </div>
81
+ <div class="litespeed-banner-description-padding-right-15">
82
+ <?php $url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'banner_promo.new_version' ) ) ; ?>
83
+ <a href="<?php echo $url ; ?>" class="litespeed-btn-warning litespeed-btn-mini">
84
+ <?php echo __( 'Maybe Later', 'litespeed-cache' ) ; ?>
85
+ </a>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ </div>
90
+
91
+ <div>
92
+ <?php $dismiss_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'banner_promo.new_version', 'later' => 1 ) ) ; ?>
93
+ <span class="screen-reader-text">Dismiss this notice.</span>
94
+ <a href="<?php echo $dismiss_url ; ?>" class="litespeed-notice-dismiss">X</a>
95
+ </div>
96
+ </div>
admin/tpl/inc/banner_promo.php CHANGED
@@ -1,33 +1,187 @@
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
- if ( ! LiteSpeed_Cache_GUI::should_show_promo() ) {
5
return ;
6
}
7
8
?>
9
- <div class="litespeed-wrap notice notice-info litespeed-banner-promo">
10
<div class="litespeed-banner-promo-logo"></div>
11
12
<div class="litespeed-banner-promo-content">
13
14
- <h2><?php echo __( 'Welcome to LiteSpeed', 'litespeed-cache' ) ; ?></h2>
15
16
- <p>
17
- <?php echo __( 'Thank you for using LiteSpeed.', 'litespeed-cache' ) ; ?>
18
- <?php echo sprintf(
19
- __( 'If you have any questions, please do not hesitate to let us know in <a %s>our support forum</a> or by <a %s>submitting a ticket with us</a>.', 'litespeed-cache' ),
20
- 'href="https://wordpress.org/support/plugin/litespeed-cache" target="_blank"',
21
- 'href="https://www.litespeedtech.com/support" target="_blank"'
22
- ) ; ?>
23
- </p>
24
25
- <p>
26
- <?php echo __( 'This plugin is created with love by LiteSpeed. Your rating is the simplest way to support us. We really appreciate it!', 'litespeed-cache' ) ; ?>
27
- </p>
28
29
- <a class="litespeed-btn-success litespeed-btn-xs" href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" target="_blank"><?php echo __( 'Sure I\'d love to!', 'litespeed-cache' ) ; ?></a>
30
- <button type="button" class="litespeed-btn-primary litespeed-btn-xs" id="litespeed-promo-done"><?php echo __( 'I\'ve already left a review', 'litespeed-cache' ) ; ?></button>
31
- <button type="button" class="litespeed-btn-warning litespeed-btn-xs" id="litespeed-promo-later"><?php echo __( 'Maybe later', 'litespeed-cache' ) ; ?></button>
32
</div>
33
- </div>
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
4
+ $last_check = empty( $_summary[ 'score.last_check' ] ) ? 0 : $_summary[ 'score.last_check' ] ;
5
+ // Check once per 10 days
6
+ if ( time() - $last_check > 864000 ) {
7
+ // Generate the ajax code to check score in separate request
8
+ $this->_enqueue_score_req_ajax() ;
9
+ // After detect, don't show, just return and show next time
10
return ;
11
}
12
13
+ if ( ! isset( $_summary[ 'score.data' ] ) ) {
14
+ return ;
15
+ }
16
+
17
+ $_score = $_summary[ 'score.data' ] ;
18
+
19
+ if ( empty( $_score[ 'speed_before_cache' ] ) || empty( $_score[ 'speed_after_cache' ] ) || empty( $_score[ 'score_before_optm' ] ) || empty( $_score[ 'score_after_optm' ] ) ) {
20
+ return ;
21
+ }
22
+
23
+ // If speed is not reduced half or score is larger
24
+ if ( $_score[ 'speed_before_cache' ] < $_score[ 'speed_after_cache' ] * 2 || $_score[ 'score_before_optm' ] > $_score[ 'score_after_optm' ] ) {
25
+ return ;
26
+ }
27
+
28
+ //********** Can show now **********//
29
+ $this->_promo_true = true ;
30
+
31
+ if ( $check_only ) {
32
+ return ;
33
+ }
34
+
35
+ // Format loading time
36
+ $speed_before_cache = $_score[ 'speed_before_cache' ] / 1000 ;
37
+ if ( $speed_before_cache < 0.01 ) {
38
+ $speed_before_cache = 0.01 ;
39
+ }
40
+ $speed_before_cache = number_format( $speed_before_cache, 2 ) ;
41
+
42
+ $speed_after_cache = $_score[ 'speed_after_cache' ] / 1000 ;
43
+ if ( $speed_after_cache < 0.01 ) {
44
+ $speed_after_cache = number_format( $speed_after_cache, 3 ) ;
45
+ }
46
+ else {
47
+ $speed_after_cache = number_format( $speed_after_cache, 2 ) ;
48
+ }
49
+
50
+ $speed_improved = ( $_score[ 'speed_before_cache' ] - $_score[ 'speed_after_cache' ] ) * 100 / $_score[ 'speed_before_cache' ] ;
51
+ if ( $speed_improved > 99 ) {
52
+ $speed_improved = number_format( $speed_improved, 2 ) ;
53
+ }
54
+ else {
55
+ $speed_improved = number_format( $speed_improved ) ;
56
+ }
57
+
58
+ // Format PageSpeed Score
59
+ $score_improved = ( $_score[ 'score_after_optm' ] - $_score[ 'score_before_optm' ] ) * 100 / $_score[ 'score_after_optm' ] ;
60
+ if ( $score_improved > 99 ) {
61
+ $score_improved = number_format( $score_improved, 2 ) ;
62
+ }
63
+ else {
64
+ $score_improved = number_format( $score_improved ) ;
65
+ }
66
+
67
?>
68
+ <div class="litespeed-wrap notice notice-info litespeed-banner-promo-full">
69
<div class="litespeed-banner-promo-logo"></div>
70
71
<div class="litespeed-banner-promo-content">
72
+ <h3 class="litespeed-banner-title litespeed-banner-promo-content"><?php echo __( 'Thank You for Using the LiteSpeed Cache Plugin!', 'litespeed-cache' ) ; ?></h3>
73
+
74
+ <div class="litespeed-row-flex litespeed-banner-promo-content litespeed-margin-left-remove litespeed-flex-wrap">
75
+ <div class="litespeed-right50 litespeed-margin-bottom20">
76
+ <h2 class="litespeed-text-grey litespeed-margin-bottom-remove litespeed-top10">Page Load Time</h2>
77
+ <hr class="litespeed-margin-bottom-remove" />
78
+ <div class="litespeed-row-flex" style="margin-left: -10px;">
79
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
80
+ <div>
81
+ <p class="litespeed-text-grey litespeed-margin-y-remove">
82
+ Before
83
+ </p>
84
+ </div>
85
+ <div class="litespeed-top10 litespeed-text-jumbo litespeed-text-grey">
86
+ <?php echo $speed_before_cache ; ?><span class="litespeed-text-large">s</span>
87
+ </div>
88
+
89
+ </div>
90
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
91
+ <div>
92
+ <p class="litespeed-text-grey litespeed-margin-y-remove">
93
+ After
94
+ </p>
95
+ </div>
96
+ <div class="litespeed-top10 litespeed-text-jumbo litespeed-success">
97
+ <?php echo $speed_after_cache ; ?><span class="litespeed-text-large">s</span>
98
+ </div>
99
+ </div>
100
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
101
+ <div>
102
+ <p class="litespeed-text-grey litespeed-margin-y-remove" style="white-space: nowrap;">
103
+ Improved by
104
+ </p>
105
+ </div>
106
+ <div class="litespeed-top10 litespeed-text-jumbo litespeed-text-fern">
107
+ <?php echo $speed_improved ; ?><span class="litespeed-text-large">%</span>
108
+ </div>
109
+ </div>
110
+ </div>
111
+
112
+ </div>
113
114
+ <?php if ( $_score[ 'score_before_optm' ] < $_score[ 'score_after_optm' ] ) : ?>
115
+ <div class="litespeed-margin-bottom20">
116
+ <h2 class="litespeed-text-grey litespeed-margin-bottom-remove litespeed-top10">PageSpeed Score</h2>
117
+ <hr class="litespeed-margin-bottom-remove" />
118
+ <div class="litespeed-row-flex" style="margin-left: -10px;">
119
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
120
+ <div>
121
+ <p class="litespeed-text-grey litespeed-text-center litespeed-margin-y-remove">
122
+ Before
123
+ </p>
124
+ </div>
125
+ <div style="margin-top:-5px;">
126
+ <?php echo LiteSpeed_Cache_GUI::pie( $_score[ 'score_before_optm' ], 45, false, true, 'litespeed-pie-' . $this->get_cls_of_pagescore( $_score[ 'score_before_optm' ] ) ) ; ?>
127
+ </div>
128
+ </div>
129
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
130
+ <div>
131
+ <p class="litespeed-text-grey litespeed-text-center litespeed-margin-y-remove">
132
+ After
133
+ </p>
134
+ </div>
135
+ <div style="margin-top:-5px;">
136
+ <?php echo LiteSpeed_Cache_GUI::pie( $_score[ 'score_after_optm' ], 45, false, true, 'litespeed-pie-' . $this->get_cls_of_pagescore( $_score[ 'score_after_optm' ] ) ) ; ?>
137
+ </div>
138
+ </div>
139
+ <div class="litespeed-width-1-3 litespeed-padding-space litespeed-margin-x5">
140
+ <div>
141
+ <p class="litespeed-text-grey litespeed-margin-y-remove" style="white-space: nowrap;">
142
+ Improved by
143
+ </p>
144
+ </div>
145
+ <div class="litespeed-top10 litespeed-text-jumbo litespeed-text-fern">
146
+ <?php echo $score_improved ; ?><span class="litespeed-text-large">%</span>
147
+ </div>
148
+ </div>
149
+ </div>
150
151
+ </div>
152
+ <?php endif ; ?>
153
154
+ </div>
155
156
+ <div class="litespeed-row-flex litespeed-flex-wrap litespeed-margin-y5">
157
+ <div class="litespeed-banner-description-padding-right-15">
158
+
159
+ <a href="https://wordpress.org/support/plugin/litespeed-cache/reviews/?filter=5#new-post" target="_blank" style="text-decoration: none;">
160
+ <button class="litespeed-btn-success litespeed-btn-mini">
161
+ <?php echo __( 'Sure I\'d love to review!', 'litespeed-cache' ) ; ?>
162
+ ⭐⭐⭐⭐⭐
163
+ </button>
164
+ </a>
165
+ <button type="button" class="litespeed-btn-primary litespeed-btn-mini" id="litespeed-promo-done"> <?php echo __( 'I\'ve already left a review', 'litespeed-cache' ) ; ?></button>
166
+ <button type="button" class="litespeed-btn-warning litespeed-btn-mini" id="litespeed-promo-later"> <?php echo __( 'Maybe later', 'litespeed-cache' ) ; ?></button>
167
+ </div>
168
+ <div>
169
+ <p class="litespeed-text-small">
170
+ <?php echo __( 'Created with ❤️ by LiteSpeed team.', 'litespeed-cache' ) ; ?>
171
+ <?php echo sprintf(
172
+ __( '<a %s>Support forum</a> | <a %s>Submit a ticket</a>', 'litespeed-cache' ),
173
+ 'href="https://wordpress.org/support/plugin/litespeed-cache" target="_blank"',
174
+ 'href="https://www.litespeedtech.com/support" target="_blank"'
175
+ ) ; ?>
176
+ </p>
177
+ </div>
178
+ </div>
179
+ </div>
180
+
181
+ <div>
182
+ <?php $dismiss_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'banner_promo', 'later' => 1 ) ) ; ?>
183
+ <span class="screen-reader-text">Dismiss this notice.</span>
184
+ <a href="<?php echo $dismiss_url ; ?>" class="litespeed-notice-dismiss">X</a>
185
</div>
186
+
187
+ </div>
admin/tpl/inc/banner_promo.slack.php CHANGED
@@ -1,33 +1,35 @@
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
-
4
- if ( ! LiteSpeed_Cache_GUI::should_show_promo( 'slack' ) ) {
5
- return ;
6
- }
7
-
8
?>
9
- <div class="litespeed-wrap notice notice-info litespeed-banner-promo-full is-dismissible" id="litespeed-banner-promo-slack">
10
<div class="litespeed-banner-promo-logo"></div>
11
12
<div class="litespeed-banner-promo-content">
13
- <h1><?php echo __( 'Welcome to LiteSpeed', 'litespeed-cache' ) ; ?></h1>
14
-
15
- <div class="litespeed-banner-promo">
16
-
17
- <div class="litespeed-banner-promo-slacklogo"></div>
18
-
19
- <div class="litespeed-banner-promo-content">
20
- <p class="litespeed-banner-promo-slack-line1">
21
<?php echo __( 'Want to connect with other LiteSpeed users?', 'litespeed-cache' ) ; ?>
22
<?php echo sprintf( __( 'Join the %s community.', 'litespeed-cache' ), '<a href="https://goo.gl/mrKuTw" target="_blank" class="litespeed-banner-promo-slack-textlink">LiteSpeed Slack</a>' ) ; ?>
23
</p>
24
-
25
<p class="litespeed-banner-promo-slack-line2">
26
- <span class="litespeed-banner-promo-slack-link">golitespeed.slack.com</span>
27
- <a href="https://goo.gl/mrKuTw" target="_blank" class="litespeed-btn-success litespeed-btn-xs litespeed-banner-promo-slack-btn"><?php echo __( 'Join Us on Slack', 'litespeed-cache' ) ; ?></a>
28
</p>
29
</div>
30
-
31
</div>
32
</div>
33
- </div>
1
<?php
2
if ( ! defined( 'WPINC' ) ) die ;
3
?>
4
+ <div class="litespeed-wrap notice notice-info litespeed-banner-promo-full" id="litespeed-banner-promo-slack">
5
<div class="litespeed-banner-promo-logo"></div>
6
7
<div class="litespeed-banner-promo-content">
8
+ <h3 class="litespeed-banner-title"><?php echo __( 'Welcome to LiteSpeed', 'litespeed-cache' ) ; ?></h3>
9
+ <div class="litespeed-banner-description">
10
+ <div class="litespeed-banner-description-padding-right-15">
11
+ <p class="litespeed-banner-desciption-content">
12
<?php echo __( 'Want to connect with other LiteSpeed users?', 'litespeed-cache' ) ; ?>
13
<?php echo sprintf( __( 'Join the %s community.', 'litespeed-cache' ), '<a href="https://goo.gl/mrKuTw" target="_blank" class="litespeed-banner-promo-slack-textlink">LiteSpeed Slack</a>' ) ; ?>
14
</p>
15
<p class="litespeed-banner-promo-slack-line2">
16
+ golitespeed.slack.com
17
</p>
18
</div>
19
+ <div>
20
+ <h3 class="litespeed-banner-button-link">
21
+ <a href="https://goo.gl/mrKuTw" target="_blank">
22
+ <?php echo __( 'Join Us on Slack', 'litespeed-cache' ) ; ?>
23
+ </a>
24
+ </h3>
25
+ </div>
26
</div>
27
</div>
28
+ <div>
29
+ <?php $dismiss_url = LiteSpeed_Cache_Utility::build_url( LiteSpeed_Cache::ACTION_DISMISS, LiteSpeed_Cache_GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'banner_promo.slack' ) ) ; ?>
30
+ <span class="screen-reader-text">Dismiss this notice.</span>
31
+ <a href="<?php echo $dismiss_url ; ?>" class="litespeed-notice-dismiss">
32
+ Dismiss
33
+ </a>
34
+ </div>
35
+ </div>
admin/tpl/inc/img_optm.summary.php CHANGED
@@ -3,6 +3,7 @@ if ( ! defined( 'WPINC' ) ) {
3
die ;
4
}
5
6
?>
7
8
<div class="litespeed-width-7-10">
@@ -19,6 +20,9 @@ if ( ! defined( 'WPINC' ) ) {
19
<div class="litespeed-empty-space-small"></div>
20
21
<div class="litespeed-desc">
22
<?php echo __( 'This will send the optimization request and the images to LiteSpeed\'s Image Optimization Server.', 'litespeed-cache' ) ; ?>
23
<?php echo sprintf( __( 'You can send at most %s images at once.', 'litespeed-cache' ), '<code>' . $optm_summary[ 'credit' ] . '</code>' ) ; ?>
24
</div>
@@ -155,11 +159,6 @@ if ( ! defined( 'WPINC' ) ) {
155
</p>
156
<?php endif ; ?>
157
158
- <?php if ( ! empty( $optm_summary[ 'pull_failed' ] ) ) : ?>
159
- <p>
160
- <?php echo __( 'Images failed to pull', 'litespeed-cache' ) ; ?>: <code><?php echo $optm_summary[ 'pull_failed' ] ; ?></code>
161
- </p>
162
- <?php endif ; ?>
163
</div>
164
165
<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>
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">
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>
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>
admin/tpl/manage.php CHANGED
@@ -10,7 +10,6 @@ if ( ! is_network_admin() ) {
10
$menu_list[ 'cdn' ] = __( 'CDN', 'litespeed-cache' ) ;
11
}
12
13
- LiteSpeed_Cache_GUI::show_promo() ;
14
?>
15
16
<div class="wrap">
10
$menu_list[ 'cdn' ] = __( 'CDN', 'litespeed-cache' ) ;
11
}
12
13
?>
14
15
<div class="wrap">
admin/tpl/setting/settings_cdn.php CHANGED
@@ -107,6 +107,10 @@ $cdn_mapping = $this->config->get_item( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING
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
</div>
111
112
</td>
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>
admin/tpl/setting/settings_esi.php CHANGED
@@ -26,7 +26,7 @@ if ( ! defined( 'WPINC' ) ) die ;
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( 'href="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
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
admin/tpl/setting/settings_excludes.php CHANGED
@@ -17,6 +17,8 @@ if ( ! defined( 'WPINC' ) ) die ;
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
</div>
21
</td>
22
</tr>
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>
admin/tpl/setting/settings_inc.cache_mobile.php CHANGED
@@ -34,8 +34,6 @@ if (!defined('WPINC')) die;
34
// if enabled, check the setting in file
35
if ( defined( 'LITESPEED_ON' ) ) {
36
37
- $this->display_messages() ;
38
-
39
$mobile_agents = LiteSpeed_Cache_Admin_Rules::get_instance()->get_rewrite_rule_mobile_agents() ;
40
if ( $mobile_agents !== $_options[ $id ] ) {
41
echo '<div class="litespeed-callout-danger">'
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">'
admin/tpl/setting/settings_media.php CHANGED
@@ -43,6 +43,18 @@ $last_responsive_placeholder_generated = LiteSpeed_Cache_Media::get_summary() ;
43
</td>
44
</tr>
45
46
<tr>
47
<th><?php echo __( 'Lazy Load Image Placeholder', 'litespeed-cache' ) ; ?></th>
48
<td>
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>
admin/tpl/settings.php CHANGED
@@ -85,8 +85,6 @@ foreach ( $wp_roles->roles as $k => $v ) {
85
}
86
ksort( $roles ) ;
87
88
- LiteSpeed_Cache_GUI::show_promo() ;
89
-
90
/**
91
* Switch basic/advanced mode
92
* @since 1.8.2
85
}
86
ksort( $roles ) ;
87
88
/**
89
* Switch basic/advanced mode
90
* @since 1.8.2
css/litespeed.css CHANGED
@@ -30,6 +30,10 @@
30
color: #a7a7a7!important;
31
}
32
33
.litespeed-success {
34
color: #73b38d!important;
35
}
@@ -43,29 +47,44 @@
43
}
44
45
.litespeed-left10 {
46
- margin-left: 10px;
47
}
48
-
49
.litespeed-right10 {
50
- margin-right: 10px;
51
}
52
.litespeed-right20 {
53
- margin-right: 20px;
54
}
55
.litespeed-right30 {
56
- margin-right: 30px;
57
}
58
-
59
.litespeed-top10 {
60
- margin-top: 10px;
61
}
62
-
63
.litespeed-top20 {
64
- margin-top: 20px;
65
}
66
67
.litespeed-top30 {
68
- margin-top: 30px;
69
}
70
71
.litespeed-wrap .litespeed-left20,
@@ -284,6 +303,12 @@ h3 .litespeed-learn-more {
284
padding-right: 20px;
285
}
286
287
/********************************* nav tabs *******************************/
288
.litespeed-wrap {
289
margin: 10px 20px 0 2px;
@@ -616,6 +641,14 @@ h3 .litespeed-learn-more {
616
min-width: 14px ;
617
}
618
619
/********************************* switch *******************************/
620
.litespeed-switch {
621
border: 1px solid #538ac6;
@@ -1238,7 +1271,7 @@ ul.litespeed-shell-body {
1238
.litespeed-banner-promo,
1239
.litespeed-banner-promo-full{
1240
display: flex;
1241
- padding: 10px;
1242
}
1243
1244
.litespeed-banner-promo-full{
@@ -1246,27 +1279,26 @@ ul.litespeed-shell-body {
1246
padding: 0px;
1247
}
1248
1249
- .litespeed-banner-promo-logo{
1250
- background-image: url("../img/lscwp-logo_256x256.png") ;
1251
background-size: contain;
1252
- width: 150px;
1253
- height: 150px;
1254
- margin: 5px;
1255
background-repeat: no-repeat;
1256
display: inline-block;
1257
}
1258
1259
.litespeed-banner-promo-full .litespeed-banner-promo-logo {
1260
margin: 0px;
1261
- width: 170px;
1262
}
1263
1264
.litespeed-banner-promo-content{
1265
- margin-left: 20px;
1266
}
1267
1268
.litespeed-banner-promo-full .litespeed-banner-promo-content {
1269
- width: 100%;
1270
}
1271
1272
.litespeed-banner-promo-content h1{
@@ -1275,6 +1307,11 @@ ul.litespeed-shell-body {
1275
margin-top: 10px;
1276
}
1277
1278
.litespeed-banner-promo-slacklogo{
1279
background-image: url("../img/slack-logo.png") ;
1280
background-size: contain;
@@ -1302,8 +1339,9 @@ ul.litespeed-shell-body {
1302
}
1303
1304
.litespeed-banner-promo-slack-line2{
1305
- font-size: 18px;
1306
margin: 0px;
1307
}
1308
1309
.litespeed-banner-promo-slack-link{
@@ -1311,7 +1349,7 @@ ul.litespeed-shell-body {
1311
}
1312
1313
a.litespeed-btn-xs.litespeed-banner-promo-slack-btn{
1314
- margin:0px 50px 0px 50px;
1315
}
1316
1317
/********************************* admin -> media lib icon *******************************/
@@ -1371,6 +1409,8 @@ p.litespeed-txt-disabled {
1371
margin: 5px;
1372
}
1373
1374
circle.litespeed-pie_bg {
1375
stroke: #efefef;
1376
stroke-width: 2;
@@ -1395,14 +1435,39 @@ circle.litespeed-pie_circle {
1395
r: 15.91549431;
1396
}
1397
1398
g.litespeed-pie_info text{
1399
alignment-baseline: central;
1400
text-anchor: middle;
1401
- font-size: 11px ;
1402
}
1403
1404
g.litespeed-pie_info .litespeed-pie-done {
1405
- fill: #73b38d ;
1406
}
1407
1408
@@ -1880,6 +1945,10 @@ input.litespeed-input-warning {
1880
padding: 20px;
1881
1882
}
1883
.litespeed-width-7-10 {
1884
width: 65%;
1885
padding: 20px;
@@ -1890,35 +1959,39 @@ input.litespeed-input-warning {
1890
}
1891
1892
.litespeed-column-java {
1893
- background: #5CADAD;
1894
}
1895
1896
.litespeed-text-shipgrey {
1897
- color: #535342;
1898
}
1899
1900
.litespeed-text-dimgray {
1901
- color: #666666;
1902
}
1903
1904
.litespeed-text-whisper {
1905
- color: #E6E6E6;
1906
}
1907
1908
.litespeed-text-malibu {
1909
- color: #5CBDDE;
1910
}
1911
1912
.litespeed-text-morningglory {
1913
- color: #99CCCC;
1914
}
1915
1916
.litespeed-text-fern {
1917
- color: #66CC66;
1918
}
1919
1920
.litespeed-text-persiangreen {
1921
- color: #009999;
1922
}
1923
1924
.litespeed-text-right {
@@ -1928,7 +2001,21 @@ input.litespeed-input-warning {
1928
.litespeed-text-center {
1929
text-align: center;
1930
}
1931
1932
.litespeed-align-center {
1933
margin-left: auto;
1934
margin-right: auto;
@@ -2234,7 +2321,7 @@ input.litespeed-input-warning {
2234
.litespeed-media-p a .dashicons-trash {
2235
font-size: 2.25em;
2236
vertical-align: middle;
2237
- display: inline;
2238
border-radius: 50%;
2239
line-height: 1.5em;
2240
}
@@ -2256,3 +2343,76 @@ input.litespeed-input-warning {
2256
background: rgba(236,242,249,0.1);
2257
border-radius: 50%;
2258
}
30
color: #a7a7a7!important;
31
}
32
33
+ .litespeed-primary {
34
+ color: #3366CC!important;
35
+ }
36
+
37
.litespeed-success {
38
color: #73b38d!important;
39
}
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,
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;
641
min-width: 14px ;
642
}
643
644
+ .litespeed-wrap .litespeed-btn-mini {
645
+ padding: 2px 5px !important;
646
+ font-size: 12px !important;
647
+ font-weight: 600 !important;
648
+ margin: 5px !important;
649
+ }
650
+
651
+
652
/********************************* switch *******************************/
653
.litespeed-switch {
654
border: 1px solid #538ac6;
1271
.litespeed-banner-promo,
1272
.litespeed-banner-promo-full{
1273
display: flex;
1274
+ padding: 0px;
1275
}
1276
1277
.litespeed-banner-promo-full{
1279
padding: 0px;
1280
}
1281
1282
+ .litespeed-banner-promo-logo {
1283
+ background-image: url(../img/lscwp-logo_90x90.png);
1284
background-size: contain;
1285
+ width: 90px;
1286
background-repeat: no-repeat;
1287
display: inline-block;
1288
}
1289
1290
.litespeed-banner-promo-full .litespeed-banner-promo-logo {
1291
margin: 0px;
1292
+ width: 90px;
1293
+ height: 90px;
1294
}
1295
1296
.litespeed-banner-promo-content{
1297
+ margin-left: 25px;
1298
}
1299
1300
.litespeed-banner-promo-full .litespeed-banner-promo-content {
1301
+ width: 75%;
1302
}
1303
1304
.litespeed-banner-promo-content h1{
1307
margin-top: 10px;
1308
}
1309
1310
+ .litespeed-banner-title {
1311
+ font-size: 1.3em;
1312
+ margin: 8px 0px 5px 0px;
1313
+ }
1314
+
1315
.litespeed-banner-promo-slacklogo{
1316
background-image: url("../img/slack-logo.png") ;
1317
background-size: contain;
1339
}
1340
1341
.litespeed-banner-promo-slack-line2{
1342
+ font-size: 15px;
1343
margin: 0px;
1344
+ line-height: .75em;
1345
}
1346
1347
.litespeed-banner-promo-slack-link{
1349
}
1350
1351
a.litespeed-btn-xs.litespeed-banner-promo-slack-btn{
1352
+ margin:0px 5px;
1353
}
1354
1355
/********************************* admin -> media lib icon *******************************/
1409
margin: 5px;
1410
}
1411
1412
+
1413
+
1414
circle.litespeed-pie_bg {
1415
stroke: #efefef;
1416
stroke-width: 2;
1435
r: 15.91549431;
1436
}
1437
1438
+ .litespeed-pie-success circle.litespeed-pie_circle {
1439
+ stroke: #178239;
1440
+ }
1441
+
1442
+ .litespeed-pie-warning circle.litespeed-pie_circle {
1443
+ stroke: #e67700;
1444
+ }
1445
+
1446
+ .litespeed-pie-danger circle.litespeed-pie_circle {
1447
+ stroke: #c7221f;
1448
+ }
1449
+
1450
g.litespeed-pie_info text{
1451
alignment-baseline: central;
1452
text-anchor: middle;
1453
+ font-size: 14px;
1454
+ font-weight: 600;
1455
+ }
1456
+
1457
+ .litespeed-pie-success g.litespeed-pie_info text{
1458
+ fill: #178239;
1459
+ }
1460
+
1461
+ .litespeed-pie-warning g.litespeed-pie_info text{
1462
+ fill: #e67700;
1463
+ }
1464
+
1465
+ .litespeed-pie-danger g.litespeed-pie_info text{
1466
+ fill: #c7221f;
1467
}
1468
1469
g.litespeed-pie_info .litespeed-pie-done {
1470
+ fill: #73b38d;
1471
}
1472
1473
1945
padding: 20px;
1946
1947
}
1948
+ .litespeed-width-1-3 {
1949
+ width: 30%;
1950
+ padding: 25px;
1951
+ }
1952
.litespeed-width-7-10 {
1953
width: 65%;
1954
padding: 20px;
1959
}
1960
1961
.litespeed-column-java {
1962
+ background: #5CADAD !important;
1963
}
1964
1965
.litespeed-text-shipgrey {
1966
+ color: #535342 !important;
1967
}
1968
1969
.litespeed-text-dimgray {
1970
+ color: #666666 !important;
1971
+ }
1972
+
1973
+ .litespeed-text-grey {
1974
+ color: #999999 !important;
1975
}
1976
1977
.litespeed-text-whisper {
1978
+ color: #E6E6E6 !important;
1979
}
1980
1981
.litespeed-text-malibu {
1982
+ color: #5CBDDE !important;
1983
}
1984
1985
.litespeed-text-morningglory {
1986
+ color: #99CCCC !important;
1987
}
1988
1989
.litespeed-text-fern {
1990
+ color: #66CC66 !important;
1991
}
1992
1993
.litespeed-text-persiangreen {
1994
+ color: #009999 !important;
1995
}
1996
1997
.litespeed-text-right {
2001
.litespeed-text-center {
2002
text-align: center;
2003
}
2004
+ .litespeed-text-bold {
2005
+ font-weight: 600;
2006
+ }
2007
+
2008
+ .litespeed-text-lead {
2009
+ font-size: 16px;
2010
+ }
2011
2012
+ .litespeed-text-small {
2013
+ font-size: 12px;
2014
+ line-height: 14px;
2015
+ }
2016
+ .litespeed-text-thin {
2017
+ font-weight: 100;
2018
+ }
2019
.litespeed-align-center {
2020
margin-left: auto;
2021
margin-right: auto;
2321
.litespeed-media-p a .dashicons-trash {
2322
font-size: 2.25em;
2323
vertical-align: middle;
2324
+ display: inline;
2325
border-radius: 50%;
2326
line-height: 1.5em;
2327
}
2343
background: rgba(236,242,249,0.1);
2344
border-radius: 50%;
2345
}
2346
+
2347
+ .litespeed-banner-description-padding-right-15 {
2348
+ padding-right: 15px;
2349
+ }
2350
+ .litespeed-banner-description {
2351
+ display: inline-flex;
2352
+ flex-wrap: wrap;
2353
+ }
2354
+ .litespeed-banner-desciption-content {
2355
+ margin: 0px;
2356
+ line-height: 1.25em;
2357
+ padding: 0px !important;
2358
+ }
2359
+
2360
+ .litespeed-row-flex {
2361
+ display: inline-flex;
2362
+
2363
+ }
2364
+ .litespeed-flex-wrap {
2365
+ flex-wrap: wrap;
2366
+ }
2367
+
2368
+ .litespeed-padding-space {
2369
+ padding: 5px 10px;
2370
+ }
2371
+ .litespeed-margin-bottom20 {
2372
+ margin-bottom: 20px;
2373
+ }
2374
+ .litespeed-margin-bottom-remove {
2375
+ margin-bottom: 0px !important;
2376
+ }
2377
+ .litespeed-margin-top-remove {
2378
+ margin-top: 0px !important;
2379
+ }
2380
+ .litespeed-margin-left-remove {
2381
+ margin-left: 0px !important;
2382
+ }
2383
+ .litespeed-margin-y-remove {
2384
+ margin-top: 0px !important;
2385
+ margin-bottom: 0px !important;
2386
+ }
2387
+
2388
+
2389
+ .litespeed-banner-button-link {
2390
+ white-space: nowrap;
2391
+ margin: 0px;
2392
+ line-height: 1.5em;
2393
+ padding-bottom: 5px;
2394
+ }
2395
+
2396
+
2397
+
2398
+ .litespeed-notice-dismiss{
2399
+ position: absolute;
2400
+ right: 25px;
2401
+ border: none;
2402
+ margin: 0;
2403
+ padding: 10px;
2404
+ background: none;
2405
+ cursor: pointer;
2406
+ color: #888888;
2407
+ display: block;
2408
+ height: 20px;
2409
+ text-align: center;
2410
+ -webkit-font-smoothing: antialiased;
2411
+ -moz-osx-font-smoothing: grayscale;
2412
+ font-weight: 600;
2413
+ text-decoration: none;
2414
+ }
2415
+
2416
+ .litespeed-notice-dismiss:hover, .litespeed-notice-dismiss:active, .litespeed-notice-dismiss:focus {
2417
+ color: #CC2929;
2418
+ }
img/lscwp-logo_256x256.png DELETED
Binary file
img/lscwp-logo_90x90.png ADDED
Binary file
inc/activation.class.php CHANGED
@@ -15,6 +15,10 @@ if ( ! defined( 'WPINC' ) ) {
15
16
class LiteSpeed_Cache_Activation
17
{
18
const NETWORK_TRANSIENT_COUNT = 'lscwp_network_count' ;
19
20
/**
@@ -79,6 +83,11 @@ class LiteSpeed_Cache_Activation
79
$options[ $id ] = $__cfg->get_item( $id ) ;
80
}
81
82
LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $options, true ) ;
83
return ;
84
}
@@ -100,7 +109,7 @@ class LiteSpeed_Cache_Activation
100
LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
101
102
if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
103
- set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
104
}
105
106
// Register crawler cron task
@@ -305,15 +314,93 @@ class LiteSpeed_Cache_Activation
305
}
306
307
/**
308
- * Delete whm transient msg tag
309
*
310
* @since 1.1.1
311
* @access public
312
*/
313
public static function dismiss_whm()
314
{
315
- delete_transient( LiteSpeed_Cache::WHM_TRANSIENT ) ;
316
}
317
318
319
}
15
16
class LiteSpeed_Cache_Activation
17
{
18
+ private static $_instance ;
19
+
20
+ const TYPE_UPGRADE = 'upgrade' ;
21
+
22
const NETWORK_TRANSIENT_COUNT = 'lscwp_network_count' ;
23
24
/**
83
$options[ $id ] = $__cfg->get_item( $id ) ;
84
}
85
86
+ if ( ! empty($options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ]) ) {
87
+ $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] =
88
+ addslashes( $options[ LiteSpeed_Cache_Config::ID_MOBILEVIEW_LIST ] );
89
+ }
90
+
91
LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $options, true ) ;
92
return ;
93
}
109
LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
110
111
if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
112
+ update_option( LiteSpeed_Cache::WHM_MSG, LiteSpeed_Cache::WHM_MSG_VAL ) ;
113
}
114
115
// Register crawler cron task
314
}
315
316
/**
317
+ * Delete whm msg tag
318
*
319
* @since 1.1.1
320
* @access public
321
*/
322
public static function dismiss_whm()
323
{
324
+ delete_option( LiteSpeed_Cache::WHM_MSG ) ;
325
+ }
326
+
327
+ /**
328
+ * Upgrade LSCWP
329
+ *
330
+ * @since 2.9
331
+ * @access private
332
+ */
333
+ private function _upgrade()
334
+ {
335
+ $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
336
+
337
+ /**
338
+ * @see wp-admin/update.php
339
+ */
340
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' ;
341
+ include_once ABSPATH . 'wp-admin/includes/file.php' ;
342
+ include_once ABSPATH . 'wp-admin/includes/misc.php' ;
343
+
344
+ try {
345
+ ob_start() ;
346
+ $skin = new \WP_Ajax_Upgrader_Skin() ;
347
+ $upgrader = new \Plugin_Upgrader( $skin ) ;
348
+ $result = $upgrader->upgrade( $plugin ) ;
349
+ if ( ! is_plugin_active( $plugin ) ) {// todo: upgrade should reactivate the plugin again by WP. Need to check why disabled after upgraded.
350
+ activate_plugin( $plugin ) ;
351
+ }
352
+ ob_end_clean() ;
353
+ } catch ( \Exception $e ) {
354
+ LiteSpeed_Cache_Admin_Display::error( __( 'Failed to upgrade.', 'litespeed-cache' ) ) ;
355
+ return ;
356
+ }
357
+
358
+ if ( is_wp_error( $result ) ) {
359
+ LiteSpeed_Cache_Admin_Display::error( __( 'Failed to upgrade.', 'litespeed-cache' ) ) ;
360
+ return ;
361
+ }
362
+
363
+ LiteSpeed_Cache_Admin_Display::succeed( __( 'Upgraded successfully.', 'litespeed-cache' ) ) ;
364
}
365
366
+ /**
367
+ * Handle all request actions from main cls
368
+ *
369
+ * @since 2.9
370
+ * @access public
371
+ */
372
+ public static function handler()
373
+ {
374
+ $instance = self::get_instance() ;
375
+
376
+ $type = LiteSpeed_Cache_Router::verify_type() ;
377
+
378
+ switch ( $type ) {
379
+ case self::TYPE_UPGRADE :
380
+ $instance->_upgrade() ;
381
+ break ;
382
+
383
+ default:
384
+ break ;
385
+ }
386
+
387
+ LiteSpeed_Cache_Admin::redirect() ;
388
+ }
389
+
390
+ /**
391
+ * Get the current instance object.
392
+ *
393
+ * @since 2.9
394
+ * @access public
395
+ * @return Current class instance.
396
+ */
397
+ public static function get_instance()
398
+ {
399
+ if ( ! isset( self::$_instance ) ) {
400
+ self::$_instance = new self() ;
401
+ }
402
+
403
+ return self::$_instance ;
404
+ }
405
406
}
inc/config.class.php CHANGED
@@ -19,6 +19,8 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
19
{
20
private static $_instance ;
21
22
protected $options ;
23
protected $vary_groups ;
24
protected $exclude_optimization_roles ;
@@ -718,6 +720,79 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
718
719
}
720
721
/**
722
* Get the current instance object.
723
*
19
{
20
private static $_instance ;
21
22
+ const TYPE_SET = 'set' ;
23
+
24
protected $options ;
25
protected $vary_groups ;
26
protected $exclude_optimization_roles ;
720
721
}
722
723
+ /**
724
+ * Set one config value directly
725
+ *
726
+ * @since 2.9
727
+ * @access private
728
+ */
729
+ private function _set_cfg()
730
+ {
731
+ if ( empty( $_GET[ self::TYPE_SET ] ) || ! is_array( $_GET[ self::TYPE_SET ] ) ) {
732
+ return ;
733
+ }
734
+
735
+ $cfg = $cfg_v = false ;
736
+ foreach ( $_GET[ self::TYPE_SET ] as $k => $v ) {
737
+ if ( ! isset( $this->options[ $k ] ) ) {
738
+ continue ;
739
+ }
740
+
741
+ if ( is_bool( $this->options[ $k ] ) ) {
742
+ $v = (bool) $v ;
743
+ }
744
+
745
+ $cfg = $k ;
746
+ $cfg_v = $v ;
747
+ break ;// only allow one
748
+ }
749
+
750
+ if ( ! $cfg ) {
751
+ return ;
752
+ }
753
+
754
+ $options = $this->options ;
755
+ // Get items
756
+ foreach ( $this->stored_items() as $v ) {
757
+ $options[ $v ] = $this->get_item( $v ) ;
758
+ }
759
+
760
+ // Change value
761
+ $options[ $cfg ] = $cfg_v ;
762
+
763
+ $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
764
+ $this->update_options( $output ) ;
765
+
766
+ LiteSpeed_Cache_Log::debug( '[Cfg] Changed cfg ' . $cfg . ' to ' . var_export( $cfg_v, true ) ) ;
767
+
768
+ $msg = __( 'Changed setting successfully.', 'litespeed-cache' ) ;
769
+ LiteSpeed_Cache_Admin_Display::succeed( $msg ) ;
770
+ }
771
+
772
+ /**
773
+ * Handle all request actions from main cls
774
+ *
775
+ * @since 2.9
776
+ * @access public
777
+ */
778
+ public static function handler()
779
+ {
780
+ $instance = self::get_instance() ;
781
+
782
+ $type = LiteSpeed_Cache_Router::verify_type() ;
783
+
784
+ switch ( $type ) {
785
+ case self::TYPE_SET :
786
+ $instance->_set_cfg() ;
787
+ break ;
788
+
789
+ default:
790
+ break ;
791
+ }
792
+
793
+ LiteSpeed_Cache_Admin::redirect() ;
794
+ }
795
+
796
/**
797
* Get the current instance object.
798
*
inc/const.cls.php CHANGED
@@ -16,6 +16,7 @@ class LiteSpeed_Cache_Const
16
const ITEM_OPTM_CSS = 'litespeed-optm-css' ;// separate critical css that should be stored in option table
17
const ITEM_OPTM_JS_DEFER_EXC = 'litespeed-optm-js-defer-excludes' ;
18
const ITEM_MEDIA_LAZY_IMG_EXC = 'litespeed-media-lazy-img-excludes' ;
19
const ITEM_IMG_OPTM_NEED_PULL = 'litespeed-media-need-pull' ;
20
const ITEM_ENV_REF = 'litespeed-env-ref' ;
21
const ITEM_CACHE_DROP_QS = 'litespeed-cache-drop_qs' ;
@@ -246,6 +247,7 @@ class LiteSpeed_Cache_Const
246
self::ITEM_OPTM_CSS,
247
self::ITEM_OPTM_JS_DEFER_EXC,
248
self::ITEM_MEDIA_LAZY_IMG_EXC,
249
self::ITEM_IMG_OPTM_NEED_PULL,
250
self::ITEM_ENV_REF,
251
self::ITEM_CACHE_DROP_QS,
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' ;
247
self::ITEM_OPTM_CSS,
248
self::ITEM_OPTM_JS_DEFER_EXC,
249
self::ITEM_MEDIA_LAZY_IMG_EXC,
250
+ self::ITEM_MEDIA_LAZY_IMG_CLS_EXC,
251
self::ITEM_IMG_OPTM_NEED_PULL,
252
self::ITEM_ENV_REF,
253
self::ITEM_CACHE_DROP_QS,
inc/control.class.php CHANGED
@@ -522,10 +522,13 @@ class LiteSpeed_Cache_Control
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
- $result = LiteSpeed_Cache_Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
526
if ( $result ) {
527
self::force_cacheable() ;
528
LiteSpeed_Cache_Log::debug( '[Ctrl] Forced cacheable due to setting: ' . $result ) ;
529
}
530
}
531
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
inc/css.cls.php CHANGED
@@ -34,7 +34,7 @@ class LiteSpeed_Cache_CSS
34
$rules = self::get_instance()->_ccss() ;
35
36
// Append default critical css
37
- $rules .= get_option( LiteSpeed_Cache_Config::ITEM_OPTM_CSS ) ;
38
39
$html_head = '<style id="litespeed-optm-css-rules">' . $rules . '</style>' . $html_head ;
40
@@ -239,8 +239,6 @@ class LiteSpeed_Cache_CSS
239
$this->_save_summary( $req_summary ) ;
240
241
// Generate critical css
242
- $url = 'http://ccss.api.litespeedtech.com' ;
243
-
244
$data = array(
245
'home_url' => home_url(),
246
'url' => $request_url,
@@ -249,32 +247,9 @@ class LiteSpeed_Cache_CSS
249
'is_mobile' => $is_mobile ? 1 : 0,
250
) ;
251
252
- LiteSpeed_Cache_Log::debug( '[CSS] posting to : ' . $url, $data ) ;
253
-
254
- $param = array(
255
- 'v' => LiteSpeed_Cache::PLUGIN_VERSION,
256
- 'data' => $data,
257
- ) ;
258
-
259
- $response = wp_remote_post( $url, array( 'body' => $param, 'timeout' => 15 ) ) ;
260
-
261
- // Parse response data
262
- if ( is_wp_error( $response ) ) {
263
- $error_message = $response->get_error_message() ;
264
- LiteSpeed_Cache_Log::debug( '[CSS] failed to post: ' . $error_message ) ;
265
- return false ;
266
- }
267
268
- $json = json_decode( $response[ 'body' ], true ) ;
269
- if ( ! is_array( $json ) ) {
270
- LiteSpeed_Cache_Log::debug( '[CSS] failed to decode post json: ' . $response[ 'body' ] ) ;
271
- return false ;
272
- }
273
-
274
- if ( ! empty( $json[ '_err' ] ) ) {
275
- LiteSpeed_Cache_Log::debug( '[CSS] _err: ' . $json[ '_err' ] ) ;
276
- return false ;
277
- }
278
279
if ( empty( $json[ 'ccss' ] ) ) {
280
LiteSpeed_Cache_Log::debug( '[CSS] empty ccss ' ) ;
@@ -311,28 +286,7 @@ class LiteSpeed_Cache_CSS
311
*/
312
private function _which_css()
313
{
314
- $css = 'default' ;
315
- if ( is_404() ) {
316
- $css = '404' ;
317
- }
318
- elseif ( is_singular() ) {
319
- $css = get_post_type() ;
320
- }
321
- elseif ( is_home() && get_option( 'show_on_front' ) == 'page' ) {
322
- $css = 'home' ;
323
- }
324
- elseif ( is_front_page() ) {
325
- $css = 'front' ;
326
- }
327
- elseif ( is_tax() ) {
328
- $css = get_queried_object()->taxonomy ;
329
- }
330
- elseif ( is_category() ) {
331
- $css = 'category' ;
332
- }
333
- elseif ( is_tag() ) {
334
- $css = 'tag' ;
335
- }
336
337
$unique = false ;
338
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
239
$this->_save_summary( $req_summary ) ;
240
241
// Generate critical css
242
$data = array(
243
'home_url' => home_url(),
244
'url' => $request_url,
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 ) ;
253
254
if ( empty( $json[ 'ccss' ] ) ) {
255
LiteSpeed_Cache_Log::debug( '[CSS] empty ccss ' ) ;
286
*/
287
private function _which_css()
288
{
289
+ $css = LiteSpeed_Cache_Utility::page_type() ;
290
291
$unique = false ;
292
inc/esi.class.php CHANGED
@@ -177,6 +177,10 @@ class LiteSpeed_Cache_ESI
177
{
178
do_action('litespeed_cache_is_not_esi_template') ;
179
180
if ( LiteSpeed_Cache_Router::is_ajax() ) {
181
return ;
182
}
177
{
178
do_action('litespeed_cache_is_not_esi_template') ;
179
180
+ if ( ! LiteSpeed_Cache_Control::is_cacheable() ) {
181
+ return ;
182
+ }
183
+
184
if ( LiteSpeed_Cache_Router::is_ajax() ) {
185
return ;
186
}
inc/gui.class.php CHANGED
@@ -19,10 +19,22 @@ class LiteSpeed_Cache_GUI
19
20
private static $_clean_counter = 0 ;
21
22
const TYPE_DISMISS_WHM = 'whm' ;
23
const TYPE_DISMISS_EXPIRESDEFAULT = 'ExpiresDefault' ;
24
const TYPE_DISMISS_PROMO = 'promo' ;
25
26
/**
27
* Init
28
*
@@ -82,14 +94,16 @@ class LiteSpeed_Cache_GUI
82
*
83
* @since 1.6.6
84
*/
85
- public static function pie( $percent, $width = 50, $finished_tick = false )
86
{
87
- $percentage = '<text x="16.91549431" y="15.5">' . $percent . '%</text>' ;
88
if ( $percent == 100 && $finished_tick ) {
89
$percentage = '<text x="16.91549431" y="15.5" class="litespeed-pie-done">&#x2713</text>' ;
90
}
91
return "
92
- <svg class='litespeed-pie' viewbox='0 0 33.83098862 33.83098862' width='$width' height='$width' xmlns='http://www.w3.org/2000/svg'>
93
<circle class='litespeed-pie_bg' />
94
<circle class='litespeed-pie_circle' stroke-dasharray='$percent,100' />
95
<g class='litespeed-pie_info'>$percentage</g>
@@ -98,6 +112,52 @@ class LiteSpeed_Cache_GUI
98
99
}
100