LiteSpeed Cache - Version 2.9.8

Version Description

  • May 22 2019 =
  • Core: Refactored loading priority so user related functions & optimization features are set after user initialization. (#717223 #114165 #413338)
  • Media: Improved backup file calculation query to prevent out-of-memory issue.
  • Conf: Feed cache now defaults to ON.
  • API: Fully remote attachment compatibility API of image optimization now supported.
  • : Bypassed vary change for crawler; crawler can now simulate default vary cookie.
  • ESI: Refactored ESI widget. Removed widget_load_get_options() function.
  • ESI: Changed the input name of widget fields in form.
  • 3rd: Elementor can now save ESI widget settings in frontend builder.
  • 3rd: WP-Stateless compatibility.
  • IAPI: Image optimization can now successfully finish the destroy process with large volume images with automatic continual mode.
  • CDN: Fixed issue with Load JQuery Remotely setting where WP 5.2.1 provided an unexpected jQuery version.
  • 3rd: Login process now gets the correct role; fixed double login issue.
Download this release

Release Info

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

Code changes from version 2.9.7.2 to 2.9.8

admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -1230,13 +1230,17 @@ class LiteSpeed_Cache_Admin_Settings
1230
  */
1231
  public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget )
1232
  {
1233
- if ( empty( $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ) {
1234
  return $instance ;
1235
  }
1236
- $current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
1237
- $input = $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
1238
- $esistr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
1239
- $ttlstr = $input[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
 
 
 
 
1240
 
1241
  if ( ! is_numeric( $ttlstr ) || ! is_numeric( $esistr ) ) {
1242
  add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
@@ -1257,6 +1261,7 @@ class LiteSpeed_Cache_Admin_Settings
1257
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
1258
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
1259
 
 
1260
  if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
1261
  LiteSpeed_Cache_Purge::purge_all( 'Wdiget ESI_enable changed' ) ;
1262
  }
1230
  */
1231
  public static function validate_widget_save( $instance, $new_instance, $old_instance, $widget )
1232
  {
1233
+ if ( empty( $new_instance ) ) {
1234
  return $instance ;
1235
  }
1236
+ if ( ! isset( $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) ) {
1237
+ return $instance ;
1238
+ }
1239
+ if ( ! isset( $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ) ) {
1240
+ return $instance ;
1241
+ }
1242
+ $esistr = $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ;
1243
+ $ttlstr = $new_instance[ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] ;
1244
 
1245
  if ( ! is_numeric( $ttlstr ) || ! is_numeric( $esistr ) ) {
1246
  add_filter( 'wp_redirect', 'LiteSpeed_Cache_Admin_Settings::widget_save_err' ) ;
1261
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] = $esi ;
1262
  $instance[ LiteSpeed_Cache_Config::OPTION_NAME ][ LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ] = $ttl ;
1263
 
1264
+ $current = ! empty( $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $old_instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : false ;
1265
  if ( ! $current || $esi != $current[ LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ] ) {
1266
  LiteSpeed_Cache_Purge::purge_all( 'Wdiget ESI_enable changed' ) ;
1267
  }
admin/tpl/esi_widget_edit.php CHANGED
@@ -2,12 +2,16 @@
2
  if ( !defined('WPINC') ) die;
3
  // $widget, $return, $instance
4
 
5
- $options = LiteSpeed_Cache_ESI::widget_load_get_options( $widget ) ;
 
6
  if ( empty( $options ) ) {
7
  $options = array(
8
  LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE => LiteSpeed_Cache_Config::VAL_OFF,
9
  LiteSpeed_Cache_ESI::WIDGET_OPID_TTL => '28800'
10
  ) ;
 
 
 
11
  $options = apply_filters( 'litespeed_cache_widget_default_options', $options, $widget ) ;
12
  }
13
 
@@ -33,30 +37,20 @@ $display = LiteSpeed_Cache_Admin_Display::get_instance() ;
33
  <div class="litespeed-switch litespeed-mini">
34
  <?php
35
  $id = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
 
36
 
37
- echo $this->build_radio(
38
- $id,
39
- LiteSpeed_Cache_Config::VAL_ON,
40
- __( 'Public', 'litespeed-cache' ),
41
- $esi === LiteSpeed_Cache_Config::VAL_ON,
42
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_ON
43
- );
44
-
45
- echo $this->build_radio(
46
- $id,
47
- LiteSpeed_Cache_Config::VAL_ON2,
48
- __( 'Private', 'litespeed-cache' ),
49
- $esi === LiteSpeed_Cache_Config::VAL_ON2,
50
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_ON2
51
- );
52
 
53
- echo $this->build_radio(
54
- $id,
55
- LiteSpeed_Cache_Config::VAL_OFF,
56
- __( 'Disable', 'litespeed-cache' ),
57
- $esi === LiteSpeed_Cache_Config::VAL_OFF,
58
- 'litespeed-cfg-' . $widget->id . '_' . LiteSpeed_Cache_Config::VAL_OFF
59
- );
60
  ?>
61
 
62
  </div>
@@ -65,7 +59,11 @@ $display = LiteSpeed_Cache_Admin_Display::get_instance() ;
65
 
66
  <b><?php echo __( 'Widget Cache TTL:', 'litespeed-cache' ) ; ?></b>
67
  &nbsp;&nbsp;
68
- <?php $display->build_input( LiteSpeed_Cache_ESI::WIDGET_OPID_TTL, 'litespeed-reset', $ttl, null, 'size="7"' ) ; ?>
 
 
 
 
69
  <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
70
 
71
  <p class="install-help">
2
  if ( !defined('WPINC') ) die;
3
  // $widget, $return, $instance
4
 
5
+ $options = ! empty( $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ? $instance[ LiteSpeed_Cache_Config::OPTION_NAME ] : array() ;
6
+
7
  if ( empty( $options ) ) {
8
  $options = array(
9
  LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE => LiteSpeed_Cache_Config::VAL_OFF,
10
  LiteSpeed_Cache_ESI::WIDGET_OPID_TTL => '28800'
11
  ) ;
12
+
13
+ add_filter('litespeed_cache_widget_default_options', 'LiteSpeed_Cache_ESI::widget_default_options', 10, 2) ;
14
+
15
  $options = apply_filters( 'litespeed_cache_widget_default_options', $options, $widget ) ;
16
  }
17
 
37
  <div class="litespeed-switch litespeed-mini">
38
  <?php
39
  $id = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
40
+ $name = $widget->get_field_name( $id ) ;
41
 
42
+ $cache_status_list = array(
43
+ array( LiteSpeed_Cache_Config::VAL_ON, __( 'Public', 'litespeed-cache' ) ),
44
+ array( LiteSpeed_Cache_Config::VAL_ON2, __( 'Private', 'litespeed-cache' ) ),
45
+ array( LiteSpeed_Cache_Config::VAL_OFF, __( 'Disable', 'litespeed-cache' ) ),
46
+ ) ;
 
 
 
 
 
 
 
 
 
 
47
 
48
+ foreach ( $cache_status_list as $v ) {
49
+ list( $v, $txt ) = $v ;
50
+ $id_attr = $widget->get_field_id( $id ) . '_' . $v ;
51
+ $checked = $esi === $v ? 'checked' : '' ;
52
+ echo "<input type='radio' name='$name' id='$id_attr' value='$v' $checked /> <label for='$id_attr'>$txt</label>" ;
53
+ }
 
54
  ?>
55
 
56
  </div>
59
 
60
  <b><?php echo __( 'Widget Cache TTL:', 'litespeed-cache' ) ; ?></b>
61
  &nbsp;&nbsp;
62
+ <?php
63
+ $id = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
64
+ $name = $widget->get_field_name( $id ) ;
65
+ echo "<input type='text' class='litespeed-regular-text litespeed-reset' name='$name' value='$ttl' size='7' />" ;
66
+ ?>
67
  <?php echo __( 'seconds', 'litespeed-cache' ) ; ?>
68
 
69
  <p class="install-help">
inc/activation.class.php CHANGED
@@ -329,6 +329,32 @@ class LiteSpeed_Cache_Activation
329
  delete_option( LiteSpeed_Cache::WHM_MSG ) ;
330
  }
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  /**
333
  * Upgrade LSCWP
334
  *
329
  delete_option( LiteSpeed_Cache::WHM_MSG ) ;
330
  }
331
 
332
+ /**
333
+ * Handle auto update
334
+ *
335
+ * @since 2.7.2
336
+ * @since 2.9.8 Moved here from ls.cls
337
+ * @access public
338
+ */
339
+ public static function auto_update()
340
+ {
341
+ if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
342
+ return ;
343
+ }
344
+
345
+ add_filter( 'auto_update_plugin', function( $update, $item ) {
346
+ if ( $item->slug == 'litespeed-cache' ) {
347
+ $auto_v = LiteSpeed_Cache_Utility::version_check( 'auto_update_plugin' ) ;
348
+
349
+ if ( $auto_v && ! empty( $item->new_version ) && $auto_v === $item->new_version ) {
350
+ return true ;
351
+ }
352
+ }
353
+
354
+ return $update; // Else, use the normal API response to decide whether to update or not
355
+ }, 10, 2 ) ;
356
+ }
357
+
358
  /**
359
  * Upgrade LSCWP
360
  *
inc/cdn.class.php CHANGED
@@ -56,7 +56,7 @@ class LiteSpeed_Cache_CDN
56
  */
57
  $this->_cfg_cdn_remote_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY ) ;
58
  if ( $this->_cfg_cdn_remote_jquery ) {
59
- add_action( 'init', array( $this, 'load_jquery_remotely' ) ) ;
60
  }
61
 
62
  $this->_cfg_cdn = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN ) ;
@@ -577,9 +577,10 @@ class LiteSpeed_Cache_CDN
577
  * Remote load jQuery remotely
578
  *
579
  * @since 1.5
580
- * @access public
 
581
  */
582
- public function load_jquery_remotely()
583
  {
584
  // default jq version
585
  $v = '1.12.4' ;
@@ -588,6 +589,8 @@ class LiteSpeed_Cache_CDN
588
  global $wp_scripts ;
589
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
590
  $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
 
 
591
  }
592
 
593
  $src = $this->_cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
56
  */
57
  $this->_cfg_cdn_remote_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY ) ;
58
  if ( $this->_cfg_cdn_remote_jquery ) {
59
+ $this->_load_jquery_remotely() ;
60
  }
61
 
62
  $this->_cfg_cdn = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN ) ;
577
  * Remote load jQuery remotely
578
  *
579
  * @since 1.5
580
+ * @since 2.9.8 Changed to private
581
+ * @access private
582
  */
583
+ private function _load_jquery_remotely()
584
  {
585
  // default jq version
586
  $v = '1.12.4' ;
589
  global $wp_scripts ;
590
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
591
  $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
592
+ // Remove all unexpected chars to fix WP5.2.1 jq version issue @see https://wordpress.org/support/topic/problem-with-wordpress-5-2-1/
593
+ $v = preg_replace( '|[^\d\.]|', '', $v ) ;
594
  }
595
 
596
  $src = $this->_cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
inc/const.cls.php CHANGED
@@ -472,7 +472,7 @@ class LiteSpeed_Cache_Const
472
  self::OPID_PUBLIC_TTL => 604800,
473
  self::OPID_PRIVATE_TTL => 1800,
474
  self::OPID_FRONT_PAGE_TTL => 604800,
475
- self::OPID_FEED_TTL => 0,
476
  self::OPID_403_TTL => 3600,
477
  self::OPID_404_TTL => 3600,
478
  self::OPID_500_TTL => 3600,
472
  self::OPID_PUBLIC_TTL => 604800,
473
  self::OPID_PRIVATE_TTL => 1800,
474
  self::OPID_FRONT_PAGE_TTL => 604800,
475
+ self::OPID_FEED_TTL => 1,
476
  self::OPID_403_TTL => 3600,
477
  self::OPID_404_TTL => 3600,
478
  self::OPID_500_TTL => 3600,
inc/esi.class.php CHANGED
@@ -305,7 +305,7 @@ class LiteSpeed_Cache_ESI
305
  return ;
306
  }
307
 
308
- add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3) ;
309
 
310
  // Add admin_bar esi
311
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
@@ -531,42 +531,6 @@ class LiteSpeed_Cache_ESI
531
  // The *_sub_* functions are helpers for the sub_* functions.
532
  // The *_load_* functions are helpers for the load_* functions.
533
 
534
- /**
535
- * Get the configuration option for the current widget.
536
- *
537
- * @since 1.1.3
538
- * @access public
539
- * @param WP_Widget $widget The widget to get the options for.
540
- * @return mixed null if not found, an array of the options otherwise.
541
- */
542
- public static function widget_load_get_options($widget)
543
- {
544
- add_filter('litespeed_cache_widget_default_options', 'LiteSpeed_Cache_ESI::widget_default_options', 10, 2) ;
545
-
546
- if ( ! is_numeric($widget->number) ) {
547
- return null ;
548
- }
549
-
550
- if ( $widget->updated ) {
551
- $settings = get_option($widget->option_name) ;
552
- }
553
- else {
554
- $settings = $widget->get_settings() ;
555
- }
556
-
557
- if ( ! isset($settings) ) {
558
- return null ;
559
- }
560
-
561
- $instance = $settings[$widget->number] ;
562
-
563
- if ( ! isset($instance) || ! isset($instance[LiteSpeed_Cache_Config::OPTION_NAME]) ) {
564
- return null;
565
- }
566
-
567
- return $instance[LiteSpeed_Cache_Config::OPTION_NAME] ;
568
- }
569
-
570
  /**
571
  * Loads the default options for default WordPress widgets.
572
  *
@@ -674,9 +638,11 @@ class LiteSpeed_Cache_ESI
674
  */
675
  public function load_widget_block( $params )
676
  {
677
- global $wp_widget_factory ;
678
- $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ] ;
679
- $option = self::widget_load_get_options( $widget ) ;
 
 
680
  // Since we only reach here via esi, safe to assume setting exists.
681
  $ttl = $option[ self::WIDGET_OPID_TTL ] ;
682
  defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl ) ;
305
  return ;
306
  }
307
 
308
+ add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3) ;
309
 
310
  // Add admin_bar esi
311
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
531
  // The *_sub_* functions are helpers for the sub_* functions.
532
  // The *_load_* functions are helpers for the load_* functions.
533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  /**
535
  * Loads the default options for default WordPress widgets.
536
  *
638
  */
639
  public function load_widget_block( $params )
640
  {
641
+ // global $wp_widget_factory ;
642
+ // $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ] ;
643
+ $option = $params[ self::PARAM_INSTANCE ] ;
644
+ $option = $option[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
645
+
646
  // Since we only reach here via esi, safe to assume setting exists.
647
  $ttl = $option[ self::WIDGET_OPID_TTL ] ;
648
  defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl ) ;
inc/img_optm.class.php CHANGED
@@ -62,6 +62,8 @@ class LiteSpeed_Cache_Img_Optm
62
  private $_table_img_optm ;
63
  private $_cron_ran = false ;
64
 
 
 
65
  /**
66
  * Init
67
  *
@@ -73,6 +75,7 @@ class LiteSpeed_Cache_Img_Optm
73
  LiteSpeed_Cache_Log::debug2( 'ImgOptm init' ) ;
74
 
75
  $this->wp_upload_dir = wp_upload_dir() ;
 
76
  $this->_table_img_optm = LiteSpeed_Cache_Data::get_tb_img_optm() ;
77
  }
78
 
@@ -587,70 +590,76 @@ class LiteSpeed_Cache_Img_Optm
587
  return ;
588
  }
589
 
 
 
590
  if ( ! $ori_file ) {
591
- $meta_value[ 'file' ] = $this->tmp_path . $meta_value[ 'file' ] ;
592
  }
593
 
594
  // check file exists or not
595
- $real_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $meta_value[ 'file' ] ;
596
- $ext = pathinfo( $real_file, PATHINFO_EXTENSION ) ;
597
- if ( ! file_exists( $real_file ) || ! in_array( $ext, array( 'jpg', 'jpeg', 'png' ) ) ) {
598
  $this->_missed_img_in_queue[] = array(
599
  'pid' => $this->tmp_pid,
600
- 'src' => $meta_value[ 'file' ],
601
- 'srcpath_md5' => md5( $meta_value[ 'file' ] ),
602
  ) ;
603
- LiteSpeed_Cache_Log::debug2( '[Img_Optm] bypass image due to file not exist: pid ' . $this->tmp_pid . ' ' . $real_file ) ;
604
  return ;
605
  }
606
 
607
  LiteSpeed_Cache_Log::debug2( '[Img_Optm] adding image: pid ' . $this->tmp_pid ) ;
608
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
  $img_info = array(
610
- 'url' => $this->wp_upload_dir[ 'baseurl' ] . '/' . $meta_value[ 'file' ],
611
- 'src' => $meta_value[ 'file' ], // not needed in LiteSpeed sapi, just leave for local storage after post
612
  'width' => $meta_value[ 'width' ],
613
  'height' => $meta_value[ 'height' ],
614
  'mime_type' => ! empty( $meta_value[ 'mime-type' ] ) ? $meta_value[ 'mime-type' ] : '' ,
615
- 'srcpath_md5' => md5( $meta_value[ 'file' ] ),
616
- 'src_filesize' => filesize( $real_file ),
617
- /**
618
- * To use the filter `litespeed_img_optm_options_per_image`, do below:
619
- *
620
- * add_filter( 'litespeed_img_optm_options_per_image', function( $opt_val, $file ){
621
- * // To add optimize original image
622
- * if ( Your conditions ) {
623
- * $opt_val |= LiteSpeed_Cache_API::IMG_OPTM_BM_ORI ;
624
- * }
625
- *
626
- * // To add optimize webp image
627
- * if ( Your conditions ) {
628
- * $opt_val |= LiteSpeed_Cache_API::IMG_OPTM_BM_WEBP ;
629
- * }
630
- *
631
- * // To turn on lossless optimize for this image e.g. if filename contains `magzine`
632
- * if ( strpos( $file, 'magzine' ) !== false ) {
633
- * $opt_val |= LiteSpeed_Cache_API::IMG_OPTM_BM_LOSSLESS ;
634
- * }
635
- *
636
- * // To set keep exif info for this image
637
- * if ( Your conditions ) {
638
- * $opt_val |= LiteSpeed_Cache_API::IMG_OPTM_BM_EXIF ;
639
- * }
640
- *
641
- * return $opt_val ;
642
- * } ) ;
643
- *
644
- * @since 2.4.2
645
- */
646
- 'optm_options' => apply_filters( 'litespeed_img_optm_options_per_image', 0, $meta_value[ 'file' ] ),
647
  ) ;
648
- $md5 = md5_file( $real_file ) ;
649
 
650
  if ( empty( $this->_img_in_queue[ $this->tmp_pid ] ) ) {
651
  $this->_img_in_queue[ $this->tmp_pid ] = array() ;
652
  }
653
- $this->_img_in_queue[ $this->tmp_pid ][ $md5 ] = $img_info ;
654
  $this->_img_total ++ ;
655
 
656
  // Build existing data checking array
@@ -1384,27 +1393,45 @@ class LiteSpeed_Cache_Img_Optm
1384
  exit( 'Destroy callback timeout ( 300 seconds )[' . time() . " - $request_time]" ) ;
1385
  }
1386
 
 
 
 
 
1387
  // Start deleting files
1388
- $q = "SELECT * FROM $this->_table_img_optm WHERE optm_status = %s" ;
1389
- $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
 
1390
  foreach ( $list as $v ) {
1391
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
1392
-
1393
  // del webp
1394
- file_exists( $local_file . '.webp' ) && unlink( $local_file . '.webp' ) ;
1395
- file_exists( $local_file . '.optm.webp' ) && unlink( $local_file . '.optm.webp' ) ;
1396
 
1397
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1398
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1399
  $bk_file = $local_filename . '.bk.' . $extension ;
1400
  $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1401
 
1402
  // del optimized ori
1403
- if ( file_exists( $bk_file ) ) {
1404
- unlink( $local_file ) ;
1405
- rename( $bk_file, $local_file ) ;
1406
  }
1407
- file_exists( $bk_optm_file ) && unlink( $bk_optm_file ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1408
  }
1409
 
1410
  // Delete optm info
@@ -1642,25 +1669,23 @@ class LiteSpeed_Cache_Img_Optm
1642
  private function _calc_bkup()
1643
  {
1644
  global $wpdb ;
1645
- $q = "SELECT * FROM $this->_table_img_optm WHERE optm_status = %s" ;
1646
  $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1647
 
1648
  $i = 0 ;
1649
  $total_size = 0 ;
1650
  foreach ( $list as $v ) {
1651
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
1652
-
1653
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1654
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1655
  $bk_file = $local_filename . '.bk.' . $extension ;
1656
 
1657
- // switch to ori
1658
- if ( ! file_exists( $bk_file ) ) {
1659
  continue ;
1660
  }
1661
 
1662
  $i ++ ;
1663
- $total_size += filesize( $bk_file ) ;
1664
 
1665
  }
1666
 
@@ -1695,27 +1720,26 @@ class LiteSpeed_Cache_Img_Optm
1695
  private function _rm_bkup()
1696
  {
1697
  global $wpdb ;
1698
- $q = "SELECT * FROM $this->_table_img_optm WHERE optm_status = %s" ;
1699
  $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1700
 
1701
  $i = 0 ;
1702
  $total_size = 0 ;
1703
  foreach ( $list as $v ) {
1704
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
1705
-
1706
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1707
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1708
  $bk_file = $local_filename . '.bk.' . $extension ;
1709
 
1710
- // switch to ori
1711
- if ( ! file_exists( $bk_file ) ) {
 
1712
  continue ;
1713
  }
1714
 
1715
  $i ++ ;
1716
- $total_size += filesize( $bk_file ) ;
1717
 
1718
- unlink( $bk_file ) ;
1719
  }
1720
 
1721
  $data = array(
@@ -1885,39 +1909,37 @@ class LiteSpeed_Cache_Img_Optm
1885
  private function _batch_switch( $type )
1886
  {
1887
  global $wpdb ;
1888
- $q = "SELECT * FROM $this->_table_img_optm WHERE optm_status = %s" ;
1889
  $list = $wpdb->get_results( $wpdb->prepare( $q, self::DB_IMG_OPTIMIZE_STATUS_PULLED ) ) ;
1890
 
1891
  $i = 0 ;
1892
  foreach ( $list as $v ) {
1893
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
1894
-
1895
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1896
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1897
  $bk_file = $local_filename . '.bk.' . $extension ;
1898
  $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1899
 
1900
  // switch to ori
1901
  if ( $type === self::TYPE_IMG_BATCH_SWITCH_ORI ) {
1902
- if ( ! file_exists( $bk_file ) ) {
1903
  continue ;
1904
  }
1905
 
1906
  $i ++ ;
1907
 
1908
- rename( $local_file, $bk_optm_file ) ;
1909
- rename( $bk_file, $local_file ) ;
1910
  }
1911
  // switch to optm
1912
  elseif ( $type === self::TYPE_IMG_BATCH_SWITCH_OPTM ) {
1913
- if ( ! file_exists( $bk_optm_file ) ) {
1914
  continue ;
1915
  }
1916
 
1917
  $i ++ ;
1918
 
1919
- rename( $local_file, $bk_file ) ;
1920
- rename( $bk_optm_file, $local_file ) ;
1921
  }
1922
  }
1923
 
@@ -1939,48 +1961,46 @@ class LiteSpeed_Cache_Img_Optm
1939
  $switch_type = substr( $type, 0, 4 ) ;
1940
 
1941
  global $wpdb ;
1942
- $q = "SELECT * FROM $this->_table_img_optm WHERE optm_status = %s AND post_id = %d" ;
1943
  $list = $wpdb->get_results( $wpdb->prepare( $q, array( self::DB_IMG_OPTIMIZE_STATUS_PULLED, $pid ) ) ) ;
1944
 
1945
  $msg = 'Unknown Msg' ;
1946
 
1947
  foreach ( $list as $v ) {
1948
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
1949
-
1950
  // to switch webp file
1951
  if ( $switch_type === 'webp' ) {
1952
- if ( file_exists( $local_file . '.webp' ) ) {
1953
- rename( $local_file . '.webp', $local_file . '.optm.webp' ) ;
1954
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Disabled WebP: ' . $local_file ) ;
1955
 
1956
  $msg = __( 'Disabled WebP file successfully.', 'litespeed-cache' ) ;
1957
  }
1958
- elseif ( file_exists( $local_file . '.optm.webp' ) ) {
1959
- rename( $local_file . '.optm.webp', $local_file . '.webp' ) ;
1960
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Enable WebP: ' . $local_file ) ;
1961
 
1962
  $msg = __( 'Enabled WebP file successfully.', 'litespeed-cache' ) ;
1963
  }
1964
  }
1965
  // to switch original file
1966
  else {
1967
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
1968
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
1969
  $bk_file = $local_filename . '.bk.' . $extension ;
1970
  $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
1971
 
1972
  // revert ori back
1973
- if ( file_exists( $bk_file ) ) {
1974
- rename( $local_file, $bk_optm_file ) ;
1975
- rename( $bk_file, $local_file ) ;
1976
  LiteSpeed_Cache_Log::debug( '[Img_Optm] Restore original img: ' . $bk_file ) ;
1977
 
1978
  $msg = __( 'Restored original file successfully.', 'litespeed-cache' ) ;
1979
  }
1980
- elseif ( file_exists( $bk_optm_file ) ) {
1981
- rename( $local_file, $bk_file ) ;
1982
- rename( $bk_optm_file, $local_file ) ;
1983
- LiteSpeed_Cache_Log::debug( '[Img_Optm] Switch to optm img: ' . $local_file ) ;
1984
 
1985
  $msg = __( 'Switched to optimized file successfully.', 'litespeed-cache' ) ;
1986
  }
@@ -2012,28 +2032,26 @@ class LiteSpeed_Cache_Img_Optm
2012
  LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row [pid] ' . $post_id ) ;
2013
 
2014
  global $wpdb ;
2015
- $q = "SELECT * FROM $this->_table_img_optm WHERE post_id = %d" ;
2016
  $list = $wpdb->get_results( $wpdb->prepare( $q, array( $post_id ) ) ) ;
2017
 
2018
  foreach ( $list as $v ) {
2019
- $local_file = $this->wp_upload_dir[ 'basedir' ] . '/' . $v->src ;
2020
-
2021
- file_exists( $local_file . '.webp' ) && unlink( $local_file . '.webp' ) ;
2022
- file_exists( $local_file . '.optm.webp' ) && unlink( $local_file . '.optm.webp' ) ;
2023
 
2024
- $extension = pathinfo( $local_file, PATHINFO_EXTENSION ) ;
2025
- $local_filename = substr( $local_file, 0, - strlen( $extension ) - 1 ) ;
2026
  $bk_file = $local_filename . '.bk.' . $extension ;
2027
  $bk_optm_file = $local_filename . '.bk.optm.' . $extension ;
2028
 
2029
- if ( file_exists( $bk_file ) ) {
2030
  LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row Revert ori file' . $bk_file ) ;
2031
- unlink( $local_file ) ;
2032
- rename( $bk_file, $local_file ) ;
2033
  }
2034
- elseif ( file_exists( $bk_optm_file ) ) {
2035
  LiteSpeed_Cache_Log::debug( '[Img_Optm] _reset_row Del ori bk file' . $bk_optm_file ) ;
2036
- unlink( $bk_optm_file ) ;
2037
  }
2038
  }
2039
 
62
  private $_table_img_optm ;
63
  private $_cron_ran = false ;
64
 
65
+ private $__media ;
66
+
67
  /**
68
  * Init
69
  *
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
 
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
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
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
 
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(
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
 
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
  }
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
 
inc/litespeed-cache.class.php CHANGED
@@ -26,7 +26,7 @@ class LiteSpeed_Cache
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.7.2' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
@@ -170,18 +170,12 @@ class LiteSpeed_Cache
170
  do_action( 'litespeed_init' ) ;
171
 
172
  // in `after_setup_theme`, before `init` hook
173
- $this->_auto_update() ;
174
-
175
- if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
176
- add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
177
- }
178
 
179
  if( is_admin() ) {
180
  LiteSpeed_Cache_Admin::get_instance() ;
181
  }
182
 
183
- LiteSpeed_Cache_Router::get_instance()->is_crawler_role_simulation() ;
184
-
185
  // if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) ) {
186
  // return ;
187
  // }
@@ -205,18 +199,6 @@ class LiteSpeed_Cache
205
  ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
206
  }
207
 
208
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
209
- /**
210
- * Check lazy lib request in the very beginning
211
- * @since 1.4
212
- * Note: this should be before optimizer to avoid lazyload lib catched wrongly
213
- */
214
- LiteSpeed_Cache_Media::get_instance() ;
215
-
216
- // Check minify file request in the very beginning
217
- LiteSpeed_Cache_Optimize::get_instance() ;
218
- }
219
-
220
  /**
221
  * Register vary filter
222
  * @since 1.6.2
@@ -227,57 +209,64 @@ class LiteSpeed_Cache
227
  // 2. Init cacheable status
228
  LiteSpeed_Cache_Vary::get_instance() ;
229
 
230
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
231
- // Hook cdn for attachements
232
- LiteSpeed_Cache_CDN::get_instance() ;
233
- }
234
-
235
  // Init Purge hooks
236
  LiteSpeed_Cache_Purge::get_instance() ;
237
 
238
  LiteSpeed_Cache_Tag::get_instance() ;
239
 
240
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
241
- // load cron tasks
242
- LiteSpeed_Cache_Task::get_instance() ;
243
- }
244
 
245
  // Load 3rd party hooks
246
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
247
-
248
- // load litespeed actions
249
- if ( $action = LiteSpeed_Cache_Router::get_action() ) {
250
- $this->proceed_action( $action ) ;
251
- }
252
-
253
- // Load frontend GUI
254
- LiteSpeed_Cache_GUI::get_instance() ;
255
-
256
  }
257
 
258
  /**
259
- * Handle auto update
260
  *
261
- * @since 2.7.2
262
- * @access private
263
  */
264
- private function _auto_update()
265
  {
266
- if ( ! self::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
267
- return ;
 
 
 
268
  }
269
 
270
- add_filter( 'auto_update_plugin', function( $update, $item ) {
271
- if ( $item->slug == 'litespeed-cache' ) {
272
- $auto_v = LiteSpeed_Cache_Utility::version_check( 'auto_update_plugin' ) ;
 
273
 
274
- if ( $auto_v && ! empty( $item->new_version ) && $auto_v === $item->new_version ) {
275
- return true ;
276
- }
277
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
- return $update; // Else, use the normal API response to decide whether to update or not
280
- }, 10, 2 ) ;
281
  }
282
 
283
  /**
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.8' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
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
  // }
199
  ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  /**
203
  * Register vary filter
204
  * @since 1.6.2
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 ( $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
  /**
inc/media.class.php CHANGED
@@ -93,11 +93,6 @@ class LiteSpeed_Cache_Media
93
  return false ;
94
  }
95
 
96
- if ( $result = LiteSpeed_Cache_Config::get_instance()->in_exclude_optimization_roles() ) {
97
- LiteSpeed_Cache_Log::debug( '[Media] ⛑️ bypass: hit Role Excludes setting: ' . $result ) ;
98
- return false ;
99
- }
100
-
101
  return true ;
102
  }
103
 
@@ -141,6 +136,76 @@ class LiteSpeed_Cache_Media
141
  LiteSpeed_Cache_Img_Optm::get_instance()->reset_row( $post_id ) ;
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Media Admin Menu -> Image Optimization Column Title
146
  *
@@ -167,6 +232,7 @@ class LiteSpeed_Cache_Media
167
  }
168
 
169
  $local_file = get_attached_file( $post_id ) ;
 
170
 
171
  $size_meta = get_post_meta( $post_id, LiteSpeed_Cache_Img_Optm::DB_IMG_OPTIMIZE_SIZE, true ) ;
172
 
@@ -181,11 +247,11 @@ class LiteSpeed_Cache_Media
181
  $desc = false ;
182
  $cls = 'litespeed-icon-media-webp' ;
183
  $cls_webp = '' ;
184
- if ( file_exists( $local_file . '.webp' ) ) {
185
  $desc = __( 'Click to Disable WebP', 'litespeed-cache' ) ;
186
  $cls_webp = 'litespeed-txt-webp' ;
187
  }
188
- elseif ( file_exists( $local_file . '.optm.webp' ) ) {
189
  $cls .= '-disabled' ;
190
  $desc = __( 'Click to Enable WebP', 'litespeed-cache' ) ;
191
  $cls_webp = 'litespeed-txt-disabled' ;
@@ -218,11 +284,11 @@ class LiteSpeed_Cache_Media
218
  $desc = false ;
219
  $cls = 'litespeed-icon-media-optm' ;
220
  $cls_ori = '' ;
221
- if ( file_exists( $bk_file ) ) {
222
  $desc = __( 'Click to Restore Original File', 'litespeed-cache' ) ;
223
  $cls_ori = 'litespeed-txt-ori' ;
224
  }
225
- elseif ( file_exists( $bk_optm_file ) ) {
226
  $cls .= '-disabled' ;
227
  $desc = __( 'Click to Switch To Optimized File', 'litespeed-cache' ) ;
228
  $cls_ori = 'litespeed-txt-disabled' ;
93
  return false ;
94
  }
95
 
 
 
 
 
 
96
  return true ;
97
  }
98
 
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
  *
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
 
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' ;
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' ;
inc/optimize.class.php CHANGED
@@ -73,7 +73,7 @@ class LiteSpeed_Cache_Optimize
73
 
74
  // To remove emoji from WP
75
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
76
- add_action( 'init', array( $this, 'emoji_rm' ) ) ;
77
  }
78
 
79
  if ( $this->cfg_qs_rm ) {
@@ -127,9 +127,10 @@ class LiteSpeed_Cache_Optimize
127
  * Remove emoji from WP
128
  *
129
  * @since 1.4
130
- * @access public
 
131
  */
132
- public function emoji_rm()
133
  {
134
  remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
135
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
73
 
74
  // To remove emoji from WP
75
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
76
+ $this->_emoji_rm() ;
77
  }
78
 
79
  if ( $this->cfg_qs_rm ) {
127
  * Remove emoji from WP
128
  *
129
  * @since 1.4
130
+ * @since 2.9.8 Changed to private
131
+ * @access private
132
  */
133
+ private function _emoji_rm()
134
  {
135
  remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
136
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
inc/router.class.php CHANGED
@@ -235,6 +235,16 @@ class LiteSpeed_Cache_Router
235
  if ( ! $role ) {
236
  // Guest user
237
  LiteSpeed_Cache_Log::debug( '[Router] role: guest' ) ;
 
 
 
 
 
 
 
 
 
 
238
  }
239
 
240
  define( 'LITESPEED_WP_ROLE', $role ) ;
235
  if ( ! $role ) {
236
  // Guest user
237
  LiteSpeed_Cache_Log::debug( '[Router] role: guest' ) ;
238
+
239
+ /**
240
+ * Fix double login issue
241
+ * The previous user init refactoring didn't fix this bcos this is in login process and the user role could change
242
+ * @see https://github.com/litespeedtech/lscache_wp/commit/69e7bc71d0de5cd58961bae953380b581abdc088
243
+ * @since 2.9.8 Won't assign const if in login process
244
+ */
245
+ if ( substr_compare( wp_login_url(), $GLOBALS[ 'pagenow' ], -strlen( $GLOBALS[ 'pagenow' ] ) ) === 0 ) {
246
+ return $role ;
247
+ }
248
  }
249
 
250
  define( 'LITESPEED_WP_ROLE', $role ) ;
inc/vary.class.php CHANGED
@@ -279,6 +279,15 @@ class LiteSpeed_Cache_Vary
279
  return false ;
280
  }
281
 
 
 
 
 
 
 
 
 
 
282
  if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
283
  LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
284
  return false ;
279
  return false ;
280
  }
281
 
282
+ /**
283
+ * Disable vary change if is from crawler
284
+ * @since 2.9.8 To enable woocommerce cart not empty warm up (@Taba)
285
+ */
286
+ if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Litespeed_Crawler::FAST_USER_AGENT ) === 0 ) {
287
+ LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to crawler' ) ;
288
+ return false ;
289
+ }
290
+
291
  if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
292
  LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
293
  return false ;
includes/litespeed-cache-activation.class.php CHANGED
@@ -329,6 +329,32 @@ class LiteSpeed_Cache_Activation
329
  delete_option( LiteSpeed_Cache::WHM_MSG ) ;
330
  }
331
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
332
  /**
333
  * Upgrade LSCWP
334
  *
329
  delete_option( LiteSpeed_Cache::WHM_MSG ) ;
330
  }
331
 
332
+ /**
333
+ * Handle auto update
334
+ *
335
+ * @since 2.7.2
336
+ * @since 2.9.8 Moved here from ls.cls
337
+ * @access public
338
+ */
339
+ public static function auto_update()
340
+ {
341
+ if ( ! LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
342
+ return ;
343
+ }
344
+
345
+ add_filter( 'auto_update_plugin', function( $update, $item ) {
346
+ if ( $item->slug == 'litespeed-cache' ) {
347
+ $auto_v = LiteSpeed_Cache_Utility::version_check( 'auto_update_plugin' ) ;
348
+
349
+ if ( $auto_v && ! empty( $item->new_version ) && $auto_v === $item->new_version ) {
350
+ return true ;
351
+ }
352
+ }
353
+
354
+ return $update; // Else, use the normal API response to decide whether to update or not
355
+ }, 10, 2 ) ;
356
+ }
357
+
358
  /**
359
  * Upgrade LSCWP
360
  *
includes/litespeed-cache-cdn.class.php CHANGED
@@ -56,7 +56,7 @@ class LiteSpeed_Cache_CDN
56
  */
57
  $this->_cfg_cdn_remote_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY ) ;
58
  if ( $this->_cfg_cdn_remote_jquery ) {
59
- add_action( 'init', array( $this, 'load_jquery_remotely' ) ) ;
60
  }
61
 
62
  $this->_cfg_cdn = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN ) ;
@@ -577,9 +577,10 @@ class LiteSpeed_Cache_CDN
577
  * Remote load jQuery remotely
578
  *
579
  * @since 1.5
580
- * @access public
 
581
  */
582
- public function load_jquery_remotely()
583
  {
584
  // default jq version
585
  $v = '1.12.4' ;
@@ -588,6 +589,8 @@ class LiteSpeed_Cache_CDN
588
  global $wp_scripts ;
589
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
590
  $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
 
 
591
  }
592
 
593
  $src = $this->_cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
56
  */
57
  $this->_cfg_cdn_remote_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_REMOTE_JQUERY ) ;
58
  if ( $this->_cfg_cdn_remote_jquery ) {
59
+ $this->_load_jquery_remotely() ;
60
  }
61
 
62
  $this->_cfg_cdn = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN ) ;
577
  * Remote load jQuery remotely
578
  *
579
  * @since 1.5
580
+ * @since 2.9.8 Changed to private
581
+ * @access private
582
  */
583
+ private function _load_jquery_remotely()
584
  {
585
  // default jq version
586
  $v = '1.12.4' ;
589
  global $wp_scripts ;
590
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
591
  $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
592
+ // Remove all unexpected chars to fix WP5.2.1 jq version issue @see https://wordpress.org/support/topic/problem-with-wordpress-5-2-1/
593
+ $v = preg_replace( '|[^\d\.]|', '', $v ) ;
594
  }
595
 
596
  $src = $this->_cfg_cdn_remote_jquery === LiteSpeed_Cache_Config::VAL_ON ? "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" : "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" ;
includes/litespeed-cache-esi.class.php CHANGED
@@ -305,7 +305,7 @@ class LiteSpeed_Cache_ESI
305
  return ;
306
  }
307
 
308
- add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3) ;
309
 
310
  // Add admin_bar esi
311
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
@@ -531,42 +531,6 @@ class LiteSpeed_Cache_ESI
531
  // The *_sub_* functions are helpers for the sub_* functions.
532
  // The *_load_* functions are helpers for the load_* functions.
533
 
534
- /**
535
- * Get the configuration option for the current widget.
536
- *
537
- * @since 1.1.3
538
- * @access public
539
- * @param WP_Widget $widget The widget to get the options for.
540
- * @return mixed null if not found, an array of the options otherwise.
541
- */
542
- public static function widget_load_get_options($widget)
543
- {
544
- add_filter('litespeed_cache_widget_default_options', 'LiteSpeed_Cache_ESI::widget_default_options', 10, 2) ;
545
-
546
- if ( ! is_numeric($widget->number) ) {
547
- return null ;
548
- }
549
-
550
- if ( $widget->updated ) {
551
- $settings = get_option($widget->option_name) ;
552
- }
553
- else {
554
- $settings = $widget->get_settings() ;
555
- }
556
-
557
- if ( ! isset($settings) ) {
558
- return null ;
559
- }
560
-
561
- $instance = $settings[$widget->number] ;
562
-
563
- if ( ! isset($instance) || ! isset($instance[LiteSpeed_Cache_Config::OPTION_NAME]) ) {
564
- return null;
565
- }
566
-
567
- return $instance[LiteSpeed_Cache_Config::OPTION_NAME] ;
568
- }
569
-
570
  /**
571
  * Loads the default options for default WordPress widgets.
572
  *
@@ -674,9 +638,11 @@ class LiteSpeed_Cache_ESI
674
  */
675
  public function load_widget_block( $params )
676
  {
677
- global $wp_widget_factory ;
678
- $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ] ;
679
- $option = self::widget_load_get_options( $widget ) ;
 
 
680
  // Since we only reach here via esi, safe to assume setting exists.
681
  $ttl = $option[ self::WIDGET_OPID_TTL ] ;
682
  defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl ) ;
305
  return ;
306
  }
307
 
308
+ add_filter('widget_display_callback', array($this, 'sub_widget_block'), 0, 3) ;
309
 
310
  // Add admin_bar esi
311
  if ( LiteSpeed_Cache_Router::is_logged_in() ) {
531
  // The *_sub_* functions are helpers for the sub_* functions.
532
  // The *_load_* functions are helpers for the load_* functions.
533
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
  /**
535
  * Loads the default options for default WordPress widgets.
536
  *
638
  */
639
  public function load_widget_block( $params )
640
  {
641
+ // global $wp_widget_factory ;
642
+ // $widget = $wp_widget_factory->widgets[ $params[ self::PARAM_NAME ] ] ;
643
+ $option = $params[ self::PARAM_INSTANCE ] ;
644
+ $option = $option[ LiteSpeed_Cache_Config::OPTION_NAME ] ;
645
+
646
  // Since we only reach here via esi, safe to assume setting exists.
647
  $ttl = $option[ self::WIDGET_OPID_TTL ] ;
648
  defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( 'ESI widget render: name ' . $params[ self::PARAM_NAME ] . ', id ' . $params[ self::PARAM_ID ] . ', ttl ' . $ttl ) ;
includes/litespeed-cache-optimize.class.php CHANGED
@@ -73,7 +73,7 @@ class LiteSpeed_Cache_Optimize
73
 
74
  // To remove emoji from WP
75
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
76
- add_action( 'init', array( $this, 'emoji_rm' ) ) ;
77
  }
78
 
79
  if ( $this->cfg_qs_rm ) {
@@ -127,9 +127,10 @@ class LiteSpeed_Cache_Optimize
127
  * Remove emoji from WP
128
  *
129
  * @since 1.4
130
- * @access public
 
131
  */
132
- public function emoji_rm()
133
  {
134
  remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
135
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
73
 
74
  // To remove emoji from WP
75
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EMOJI_RM ) ) {
76
+ $this->_emoji_rm() ;
77
  }
78
 
79
  if ( $this->cfg_qs_rm ) {
127
  * Remove emoji from WP
128
  *
129
  * @since 1.4
130
+ * @since 2.9.8 Changed to private
131
+ * @access private
132
  */
133
+ private function _emoji_rm()
134
  {
135
  remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
136
  remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
includes/litespeed-cache-router.class.php CHANGED
@@ -235,6 +235,16 @@ class LiteSpeed_Cache_Router
235
  if ( ! $role ) {
236
  // Guest user
237
  LiteSpeed_Cache_Log::debug( '[Router] role: guest' ) ;
 
 
 
 
 
 
 
 
 
 
238
  }
239
 
240
  define( 'LITESPEED_WP_ROLE', $role ) ;
235
  if ( ! $role ) {
236
  // Guest user
237
  LiteSpeed_Cache_Log::debug( '[Router] role: guest' ) ;
238
+
239
+ /**
240
+ * Fix double login issue
241
+ * The previous user init refactoring didn't fix this bcos this is in login process and the user role could change
242
+ * @see https://github.com/litespeedtech/lscache_wp/commit/69e7bc71d0de5cd58961bae953380b581abdc088
243
+ * @since 2.9.8 Won't assign const if in login process
244
+ */
245
+ if ( substr_compare( wp_login_url(), $GLOBALS[ 'pagenow' ], -strlen( $GLOBALS[ 'pagenow' ] ) ) === 0 ) {
246
+ return $role ;
247
+ }
248
  }
249
 
250
  define( 'LITESPEED_WP_ROLE', $role ) ;
includes/litespeed-cache-vary.class.php CHANGED
@@ -279,6 +279,15 @@ class LiteSpeed_Cache_Vary
279
  return false ;
280
  }
281
 
 
 
 
 
 
 
 
 
 
282
  if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
283
  LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
284
  return false ;
279
  return false ;
280
  }
281
 
282
+ /**
283
+ * Disable vary change if is from crawler
284
+ * @since 2.9.8 To enable woocommerce cart not empty warm up (@Taba)
285
+ */
286
+ if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Litespeed_Crawler::FAST_USER_AGENT ) === 0 ) {
287
+ LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to crawler' ) ;
288
+ return false ;
289
+ }
290
+
291
  if ( ! apply_filters( 'litespeed_can_change_vary', true ) ) {
292
  LiteSpeed_Cache_Log::debug( '[Vary] can_change_vary bypassed due to litespeed_can_change_vary hook' ) ;
293
  return false ;
includes/litespeed-cache.class.php CHANGED
@@ -26,7 +26,7 @@ class LiteSpeed_Cache
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.7.2' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
@@ -170,18 +170,12 @@ class LiteSpeed_Cache
170
  do_action( 'litespeed_init' ) ;
171
 
172
  // in `after_setup_theme`, before `init` hook
173
- $this->_auto_update() ;
174
-
175
- if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
176
- add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
177
- }
178
 
179
  if( is_admin() ) {
180
  LiteSpeed_Cache_Admin::get_instance() ;
181
  }
182
 
183
- LiteSpeed_Cache_Router::get_instance()->is_crawler_role_simulation() ;
184
-
185
  // if ( ! defined( 'LITESPEED_ON' ) || ! defined( 'LSCACHE_ADV_CACHE' ) ) {
186
  // return ;
187
  // }
@@ -205,18 +199,6 @@ class LiteSpeed_Cache
205
  ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
206
  }
207
 
208
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
209
- /**
210
- * Check lazy lib request in the very beginning
211
- * @since 1.4
212
- * Note: this should be before optimizer to avoid lazyload lib catched wrongly
213
- */
214
- LiteSpeed_Cache_Media::get_instance() ;
215
-
216
- // Check minify file request in the very beginning
217
- LiteSpeed_Cache_Optimize::get_instance() ;
218
- }
219
-
220
  /**
221
  * Register vary filter
222
  * @since 1.6.2
@@ -227,57 +209,64 @@ class LiteSpeed_Cache
227
  // 2. Init cacheable status
228
  LiteSpeed_Cache_Vary::get_instance() ;
229
 
230
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
231
- // Hook cdn for attachements
232
- LiteSpeed_Cache_CDN::get_instance() ;
233
- }
234
-
235
  // Init Purge hooks
236
  LiteSpeed_Cache_Purge::get_instance() ;
237
 
238
  LiteSpeed_Cache_Tag::get_instance() ;
239
 
240
- if ( ! defined( 'LITESPEED_BYPASS_OPTM' ) ) {
241
- // load cron tasks
242
- LiteSpeed_Cache_Task::get_instance() ;
243
- }
244
 
245
  // Load 3rd party hooks
246
  add_action( 'wp_loaded', array( $this, 'load_thirdparty' ), 2 ) ;
247
-
248
- // load litespeed actions
249
- if ( $action = LiteSpeed_Cache_Router::get_action() ) {
250
- $this->proceed_action( $action ) ;
251
- }
252
-
253
- // Load frontend GUI
254
- LiteSpeed_Cache_GUI::get_instance() ;
255
-
256
  }
257
 
258
  /**
259
- * Handle auto update
260
  *
261
- * @since 2.7.2
262
- * @access private
263
  */
264
- private function _auto_update()
265
  {
266
- if ( ! self::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
267
- return ;
 
 
 
268
  }
269
 
270
- add_filter( 'auto_update_plugin', function( $update, $item ) {
271
- if ( $item->slug == 'litespeed-cache' ) {
272
- $auto_v = LiteSpeed_Cache_Utility::version_check( 'auto_update_plugin' ) ;
 
273
 
274
- if ( $auto_v && ! empty( $item->new_version ) && $auto_v === $item->new_version ) {
275
- return true ;
276
- }
277
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
- return $update; // Else, use the normal API response to decide whether to update or not
280
- }, 10, 2 ) ;
281
  }
282
 
283
  /**
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.8' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
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
  // }
199
  ! defined( 'LITESPEED_BYPASS_OPTM' ) && define( 'LITESPEED_BYPASS_OPTM', true ) ;
200
  }
201
 
 
 
 
 
 
 
 
 
 
 
 
 
202
  /**
203
  * Register vary filter
204
  * @since 1.6.2
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 ( $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
  /**
languages/litespeed-cache.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the LiteSpeed Cache package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: LiteSpeed Cache 2.9.7.2\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2019-05-02 16:39:41+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -577,7 +577,7 @@ msgstr ""
577
  msgid "Enable"
578
  msgstr ""
579
 
580
- #: admin/tpl/crawler.php:84 admin/tpl/esi_widget_edit.php:56
581
  #: admin/tpl/setting/settings_general.php:30
582
  msgid "Disable"
583
  msgstr ""
@@ -757,23 +757,23 @@ msgstr ""
757
  msgid "DO NOT EDIT ANYTHING WITHIN %s"
758
  msgstr ""
759
 
760
- #: admin/tpl/esi_widget_edit.php:30 admin/tpl/setting/settings_esi.php:43
761
  msgid "Enable ESI"
762
  msgstr ""
763
 
764
- #: admin/tpl/esi_widget_edit.php:40
765
  msgid "Public"
766
  msgstr ""
767
 
768
- #: admin/tpl/esi_widget_edit.php:48
769
  msgid "Private"
770
  msgstr ""
771
 
772
- #: admin/tpl/esi_widget_edit.php:66
773
  msgid "Widget Cache TTL:"
774
  msgstr ""
775
 
776
- #: admin/tpl/esi_widget_edit.php:69 admin/tpl/setting/settings_crawler.php:40
777
  #: admin/tpl/setting/settings_crawler.php:52
778
  #: admin/tpl/setting/settings_crawler.php:64
779
  #: admin/tpl/setting/settings_general.php:65
@@ -789,11 +789,11 @@ msgstr ""
789
  msgid "seconds"
790
  msgstr ""
791
 
792
- #: admin/tpl/esi_widget_edit.php:72
793
  msgid "Recommended value: 28800 seconds (8 hours)."
794
  msgstr ""
795
 
796
- #: admin/tpl/esi_widget_edit.php:73
797
  msgid "A TTL of 0 indicates do not cache."
798
  msgstr ""
799
 
@@ -848,7 +848,7 @@ msgstr ""
848
  msgid "Are you sure to reset all settings to default settings?"
849
  msgstr ""
850
 
851
- #: admin/tpl/import_export.php:61 inc/media.class.php:246
852
  msgid "Reset"
853
  msgstr ""
854
 
@@ -860,7 +860,7 @@ msgstr ""
860
  msgid "Rate %s on %s"
861
  msgstr ""
862
 
863
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.9.7.2) #-#-#-#-#
864
  #. Plugin Name of the plugin/theme
865
  #: admin/tpl/inc/admin_footer.php:6
866
  #: admin/tpl/inc/banner_promo.new_version.php:56 inc/gui.class.php:477
@@ -4002,14 +4002,14 @@ msgstr ""
4002
  msgid "Purged the tags!"
4003
  msgstr ""
4004
 
4005
- #: inc/activation.class.php:359 inc/activation.class.php:364
4006
- #: includes/litespeed-cache-activation.class.php:359
4007
- #: includes/litespeed-cache-activation.class.php:364
4008
  msgid "Failed to upgrade."
4009
  msgstr ""
4010
 
4011
- #: inc/activation.class.php:368
4012
- #: includes/litespeed-cache-activation.class.php:368
4013
  msgid "Upgraded successfully."
4014
  msgstr ""
4015
 
@@ -4149,77 +4149,77 @@ msgstr ""
4149
  msgid "Update %s now"
4150
  msgstr ""
4151
 
4152
- #: inc/img_optm.class.php:114
4153
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4154
  msgstr ""
4155
 
4156
- #: inc/img_optm.class.php:167 inc/img_optm.class.php:1451
4157
- #: inc/img_optm.class.php:1516
4158
  msgid "No image found."
4159
  msgstr ""
4160
 
4161
- #: inc/img_optm.class.php:195
4162
  msgid "Number of images in one image group (%s) exceeds the credit (%s)"
4163
  msgstr ""
4164
 
4165
- #: inc/img_optm.class.php:223
4166
  msgid "Requested successfully."
4167
  msgstr ""
4168
 
4169
- #: inc/img_optm.class.php:243
4170
  msgid "Optimized successfully."
4171
  msgstr ""
4172
 
4173
- #: inc/img_optm.class.php:300
4174
  msgid "Pushed %1$s to LiteSpeed optimization server, accepted %2$s."
4175
  msgstr ""
4176
 
4177
- #: inc/img_optm.class.php:687
4178
  msgid "Failed to parse data from LiteSpeed IAPI server: %s"
4179
  msgstr ""
4180
 
4181
- #: inc/img_optm.class.php:1021
4182
  msgid ""
4183
  "LSCWP %1$s has simplified the image pulling process. Please %2$s, or resend "
4184
  "the pull notification this one time only. After that, the process will be "
4185
  "automated."
4186
  msgstr ""
4187
 
4188
- #: inc/img_optm.class.php:1340
4189
  msgid "Destroy unfinished data successfully."
4190
  msgstr ""
4191
 
4192
- #: inc/img_optm.class.php:1554
4193
  msgid ""
4194
  "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
4195
  "accepted %3$s groups with %4$s images."
4196
  msgstr ""
4197
 
4198
- #: inc/img_optm.class.php:1730
4199
  msgid "Removed %1$s images and saved %2$s successfully."
4200
  msgstr ""
4201
 
4202
- #: inc/img_optm.class.php:1925
4203
  msgid "Switched images successfully."
4204
  msgstr ""
4205
 
4206
- #: inc/img_optm.class.php:1956
4207
  msgid "Disabled WebP file successfully."
4208
  msgstr ""
4209
 
4210
- #: inc/img_optm.class.php:1962
4211
  msgid "Enabled WebP file successfully."
4212
  msgstr ""
4213
 
4214
- #: inc/img_optm.class.php:1978
4215
  msgid "Restored original file successfully."
4216
  msgstr ""
4217
 
4218
- #: inc/img_optm.class.php:1985
4219
  msgid "Switched to optimized file successfully."
4220
  msgstr ""
4221
 
4222
- #: inc/img_optm.class.php:2045
4223
  msgid "Reset the optimized data successfully."
4224
  msgstr ""
4225
 
@@ -4235,43 +4235,43 @@ msgstr ""
4235
  msgid "Reset successfully."
4236
  msgstr ""
4237
 
4238
- #: inc/litespeed-cache.class.php:327 includes/litespeed-cache.class.php:327
4239
  msgid "Crawler blacklist is saved."
4240
  msgstr ""
4241
 
4242
- #: inc/litespeed-cache.class.php:338 includes/litespeed-cache.class.php:338
4243
  msgid "Notified LiteSpeed Web Server to purge everything."
4244
  msgstr ""
4245
 
4246
- #: inc/litespeed-cache.class.php:348 includes/litespeed-cache.class.php:348
4247
  msgid "Notified LiteSpeed Web Server to purge the list."
4248
  msgstr ""
4249
 
4250
- #: inc/media.class.php:152
4251
  msgid "LiteSpeed Optimization"
4252
  msgstr ""
4253
 
4254
- #: inc/media.class.php:178
4255
  msgid "WebP saved %s"
4256
  msgstr ""
4257
 
4258
- #: inc/media.class.php:185
4259
  msgid "Click to Disable WebP"
4260
  msgstr ""
4261
 
4262
- #: inc/media.class.php:190
4263
  msgid "Click to Enable WebP"
4264
  msgstr ""
4265
 
4266
- #: inc/media.class.php:211
4267
  msgid "Original saved %s"
4268
  msgstr ""
4269
 
4270
- #: inc/media.class.php:222
4271
  msgid "Click to Restore Original File"
4272
  msgstr ""
4273
 
4274
- #: inc/media.class.php:227
4275
  msgid "Click to Switch To Optimized File"
4276
  msgstr ""
4277
 
2
  # This file is distributed under the same license as the LiteSpeed Cache package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: LiteSpeed Cache 2.9.8\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2019-05-23 01:54:52+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
577
  msgid "Enable"
578
  msgstr ""
579
 
580
+ #: admin/tpl/crawler.php:84 admin/tpl/esi_widget_edit.php:45
581
  #: admin/tpl/setting/settings_general.php:30
582
  msgid "Disable"
583
  msgstr ""
757
  msgid "DO NOT EDIT ANYTHING WITHIN %s"
758
  msgstr ""
759
 
760
+ #: admin/tpl/esi_widget_edit.php:34 admin/tpl/setting/settings_esi.php:43
761
  msgid "Enable ESI"
762
  msgstr ""
763
 
764
+ #: admin/tpl/esi_widget_edit.php:43
765
  msgid "Public"
766
  msgstr ""
767
 
768
+ #: admin/tpl/esi_widget_edit.php:44
769
  msgid "Private"
770
  msgstr ""
771
 
772
+ #: admin/tpl/esi_widget_edit.php:60
773
  msgid "Widget Cache TTL:"
774
  msgstr ""
775
 
776
+ #: admin/tpl/esi_widget_edit.php:67 admin/tpl/setting/settings_crawler.php:40
777
  #: admin/tpl/setting/settings_crawler.php:52
778
  #: admin/tpl/setting/settings_crawler.php:64
779
  #: admin/tpl/setting/settings_general.php:65
789
  msgid "seconds"
790
  msgstr ""
791
 
792
+ #: admin/tpl/esi_widget_edit.php:70
793
  msgid "Recommended value: 28800 seconds (8 hours)."
794
  msgstr ""
795
 
796
+ #: admin/tpl/esi_widget_edit.php:71
797
  msgid "A TTL of 0 indicates do not cache."
798
  msgstr ""
799
 
848
  msgid "Are you sure to reset all settings to default settings?"
849
  msgstr ""
850
 
851
+ #: admin/tpl/import_export.php:61 inc/media.class.php:312
852
  msgid "Reset"
853
  msgstr ""
854
 
860
  msgid "Rate %s on %s"
861
  msgstr ""
862
 
863
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.9.8) #-#-#-#-#
864
  #. Plugin Name of the plugin/theme
865
  #: admin/tpl/inc/admin_footer.php:6
866
  #: admin/tpl/inc/banner_promo.new_version.php:56 inc/gui.class.php:477
4002
  msgid "Purged the tags!"
4003
  msgstr ""
4004
 
4005
+ #: inc/activation.class.php:385 inc/activation.class.php:390
4006
+ #: includes/litespeed-cache-activation.class.php:385
4007
+ #: includes/litespeed-cache-activation.class.php:390
4008
  msgid "Failed to upgrade."
4009
  msgstr ""
4010
 
4011
+ #: inc/activation.class.php:394
4012
+ #: includes/litespeed-cache-activation.class.php:394
4013
  msgid "Upgraded successfully."
4014
  msgstr ""
4015
 
4149
  msgid "Update %s now"
4150
  msgstr ""
4151
 
4152
+ #: inc/img_optm.class.php:117
4153
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4154
  msgstr ""
4155
 
4156
+ #: inc/img_optm.class.php:170 inc/img_optm.class.php:1478
4157
+ #: inc/img_optm.class.php:1543
4158
  msgid "No image found."
4159
  msgstr ""
4160
 
4161
+ #: inc/img_optm.class.php:198
4162
  msgid "Number of images in one image group (%s) exceeds the credit (%s)"
4163
  msgstr ""
4164
 
4165
+ #: inc/img_optm.class.php:226
4166
  msgid "Requested successfully."
4167
  msgstr ""
4168
 
4169
+ #: inc/img_optm.class.php:246
4170
  msgid "Optimized successfully."
4171
  msgstr ""
4172
 
4173
+ #: inc/img_optm.class.php:303
4174
  msgid "Pushed %1$s to LiteSpeed optimization server, accepted %2$s."
4175
  msgstr ""
4176
 
4177
+ #: inc/img_optm.class.php:696
4178
  msgid "Failed to parse data from LiteSpeed IAPI server: %s"
4179
  msgstr ""
4180
 
4181
+ #: inc/img_optm.class.php:1030
4182
  msgid ""
4183
  "LSCWP %1$s has simplified the image pulling process. Please %2$s, or resend "
4184
  "the pull notification this one time only. After that, the process will be "
4185
  "automated."
4186
  msgstr ""
4187
 
4188
+ #: inc/img_optm.class.php:1349
4189
  msgid "Destroy unfinished data successfully."
4190
  msgstr ""
4191
 
4192
+ #: inc/img_optm.class.php:1581
4193
  msgid ""
4194
  "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
4195
  "accepted %3$s groups with %4$s images."
4196
  msgstr ""
4197
 
4198
+ #: inc/img_optm.class.php:1754
4199
  msgid "Removed %1$s images and saved %2$s successfully."
4200
  msgstr ""
4201
 
4202
+ #: inc/img_optm.class.php:1947
4203
  msgid "Switched images successfully."
4204
  msgstr ""
4205
 
4206
+ #: inc/img_optm.class.php:1976
4207
  msgid "Disabled WebP file successfully."
4208
  msgstr ""
4209
 
4210
+ #: inc/img_optm.class.php:1982
4211
  msgid "Enabled WebP file successfully."
4212
  msgstr ""
4213
 
4214
+ #: inc/img_optm.class.php:1998
4215
  msgid "Restored original file successfully."
4216
  msgstr ""
4217
 
4218
+ #: inc/img_optm.class.php:2005
4219
  msgid "Switched to optimized file successfully."
4220
  msgstr ""
4221
 
4222
+ #: inc/img_optm.class.php:2063
4223
  msgid "Reset the optimized data successfully."
4224
  msgstr ""
4225
 
4235
  msgid "Reset successfully."
4236
  msgstr ""
4237
 
4238
+ #: inc/litespeed-cache.class.php:316 includes/litespeed-cache.class.php:316
4239
  msgid "Crawler blacklist is saved."
4240
  msgstr ""
4241
 
4242
+ #: inc/litespeed-cache.class.php:327 includes/litespeed-cache.class.php:327
4243
  msgid "Notified LiteSpeed Web Server to purge everything."
4244
  msgstr ""
4245
 
4246
+ #: inc/litespeed-cache.class.php:337 includes/litespeed-cache.class.php:337
4247
  msgid "Notified LiteSpeed Web Server to purge the list."
4248
  msgstr ""
4249
 
4250
+ #: inc/media.class.php:217
4251
  msgid "LiteSpeed Optimization"
4252
  msgstr ""
4253
 
4254
+ #: inc/media.class.php:244
4255
  msgid "WebP saved %s"
4256
  msgstr ""
4257
 
4258
+ #: inc/media.class.php:251
4259
  msgid "Click to Disable WebP"
4260
  msgstr ""
4261
 
4262
+ #: inc/media.class.php:256
4263
  msgid "Click to Enable WebP"
4264
  msgstr ""
4265
 
4266
+ #: inc/media.class.php:277
4267
  msgid "Original saved %s"
4268
  msgstr ""
4269
 
4270
+ #: inc/media.class.php:288
4271
  msgid "Click to Restore Original File"
4272
  msgstr ""
4273
 
4274
+ #: inc/media.class.php:293
4275
  msgid "Click to Switch To Optimized File"
4276
  msgstr ""
4277
 
litespeed-cache.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: LiteSpeed Cache
16
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
17
  * Description: High-performance page caching and site optimization from LiteSpeed
18
- * Version: 2.9.7.2
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
15
  * Plugin Name: LiteSpeed Cache
16
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
17
  * Description: High-performance page caching and site optimization from LiteSpeed
18
+ * Version: 2.9.8
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: LiteSpeedTech
3
  Tags: caching, optimize, performance, pagespeed, seo, speed, image optimize, compress, object cache, redis, memcached, database cleaner
4
  Requires at least: 4.0
5
- Tested up to: 5.1.1
6
- Stable tag: 2.9.7.2
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -283,10 +283,26 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
283
  * Beaver Builder
284
  * FacetWP (LSWS 5.3.6+)
285
  * WpDiscuz
 
 
286
 
287
 
288
  == Changelog ==
289
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  = 2.9.7.2 - May 2 2019 =
291
  * <strong>Conf</strong>: Enhanced compatibility when an option is not properly initialized.
292
  * <strong>Conf</strong>: Prevent non-array instance in widget from causing 500 error. (#210407)
2
  Contributors: LiteSpeedTech
3
  Tags: caching, optimize, performance, pagespeed, seo, speed, image optimize, compress, object cache, redis, memcached, database cleaner
4
  Requires at least: 4.0
5
+ Tested up to: 5.2.1
6
+ Stable tag: 2.9.8
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
283
  * Beaver Builder
284
  * FacetWP (LSWS 5.3.6+)
285
  * WpDiscuz
286
+ * WP-Stateless
287
+ * Elementor
288
 
289
 
290
  == Changelog ==
291
 
292
+ = 2.9.8 - May 22 2019 =
293
+ * <strong>Core</strong>: Refactored loading priority so user related functions & optimization features are set after user initialization. (#717223 #114165 #413338)
294
+ * <strong>Media</strong>: Improved backup file calculation query to prevent out-of-memory issue.
295
+ * <strong>Conf</strong>: Feed cache now defaults to ON.
296
+ * <strong>API</strong>: Fully remote attachment compatibility API of image optimization now supported.
297
+ * 🕷️: Bypassed vary change for crawler; crawler can now simulate default vary cookie.
298
+ * <strong>ESI</strong>: Refactored ESI widget. Removed `widget_load_get_options()` function.
299
+ * <strong>ESI</strong>: Changed the input name of widget fields in form.
300
+ * <strong>3rd</strong>: Elementor can now save ESI widget settings in frontend builder.
301
+ * <strong>3rd</strong>: WP-Stateless compatibility.
302
+ * <strong>IAPI</strong>: Image optimization can now successfully finish the destroy process with large volume images with automatic continual mode.
303
+ * 🐞<strong>CDN</strong>: Fixed issue with Load JQuery Remotely setting where WP 5.2.1 provided an unexpected jQuery version.
304
+ * 🐞<strong>3rd</strong>: Login process now gets the correct role; fixed double login issue.
305
+
306
  = 2.9.7.2 - May 2 2019 =
307
  * <strong>Conf</strong>: Enhanced compatibility when an option is not properly initialized.
308
  * <strong>Conf</strong>: Prevent non-array instance in widget from causing 500 error. (#210407)