LiteSpeed Cache - Version 2.9.5

Version Description

  • Mar 14 2019 =
  • Auto convert default WordPress nonce to ESI to avoid expiration.
  • API: Ability to easily convert custom nonce to ESI by registering LiteSpeed_Cache_API::nonce_action.
  • OPTM: Tweaked redundant attr data-no-optimize in func _analyse_links to data-ignore-optimize to offer the API to bypass optimization but still move src to top of source code.
  • API: Renamed default nonce ESI ID from lscwp_nonce_esi to nonce.
  • API: Added WebP generation & validation hook API. (@alim #wp-stateless)
  • API: Added hook to bypass vary commenter check. (#wpdiscuz)
  • Doc: Clarified Cache Mobile description. (@JohnnyNguyen)
  • Doc: Replaced incorrect link in description. (@JohnnyNguyen)
  • 3rd: Improved wpDiscuz compatibility.
  • 3rd: Fixed Divi Theme Builder comment compatibility on non-builder pages. (#410919)
  • 3rd: Added YITH ESI adjustment.
Download this release

Release Info

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

Code changes from version 2.9.4.1 to 2.9.5

admin/tpl/debug_log.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
4
-
5
  ?>
6
 
7
  <div class="wrap">
@@ -13,7 +12,20 @@ if ( ! defined( 'WPINC' ) ) die ;
13
  </span>
14
  <hr class="wp-header-end">
15
  </div>
 
16
  <div class="wrap">
 
 
 
 
 
 
 
 
 
 
 
 
17
  <?php
18
 
19
  $file = LSCWP_CONTENT_DIR . '/debug.log' ;
1
  <?php
2
  if ( ! defined( 'WPINC' ) ) die ;
3
 
 
4
  ?>
5
 
6
  <div class="wrap">
12
  </span>
13
  <hr class="wp-header-end">
14
  </div>
15
+
16
  <div class="wrap">
17
+ <form method="post" action="admin.php?page=lscache-debug">
18
+ <?php $this->form_action( LiteSpeed_Cache::ACTION_LOG, LiteSpeed_Cache_Log::TYPE_BETA_TEST ) ; ?>
19
+
20
+ <h3 class="litespeed-title"><?php echo __( 'Try GitHub Version', 'litespeed-cache' ) ; ?></h3>
21
+
22
+ <input type="text" name="<?php echo LiteSpeed_Cache_Log::BETA_TEST_URL; ?>" class="litespeed-input-long">
23
+
24
+ <div class="litespeed-desc">Example: https://github.com/litespeedtech/lscache_wp/commit/253715525b1708c25f73460635f7eaf152448821</div>
25
+
26
+ <button type="submit" class="litespeed-btn-primary"><?php echo __('Upgrade', 'litespeed-cache'); ?></button>
27
+ </form>
28
+
29
  <?php
30
 
31
  $file = LSCWP_CONTENT_DIR . '/debug.log' ;
admin/tpl/setting/settings_debug.php CHANGED
@@ -59,7 +59,7 @@ if ( ! defined( 'WPINC' ) ) die ;
59
  <?php echo __( 'Your IP', 'litespeed-cache' ) ; ?>: <code><?php echo LiteSpeed_Cache_Router::get_ip() ; ?></code>
60
  <br />
61
  <?php $this->learn_more(
62
- 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:admin-ip-commands',
63
  __( 'More information about the available commands can be found here.', 'litespeed-cache' )
64
  ) ; ?>
65
  </div>
59
  <?php echo __( 'Your IP', 'litespeed-cache' ) ; ?>: <code><?php echo LiteSpeed_Cache_Router::get_ip() ; ?></code>
60
  <br />
61
  <?php $this->learn_more(
62
+ 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:information:admin-ip-commands',
63
  __( 'More information about the available commands can be found here.', 'litespeed-cache' )
64
  ) ; ?>
65
  </div>
admin/tpl/setting/settings_inc.cache_mobile.php CHANGED
@@ -11,8 +11,8 @@ if (!defined('WPINC')) die;
11
  $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE);
12
  ?>
13
  <div class="litespeed-desc">
14
- <?php echo __('When enabled, mobile views will be cached separately.', 'litespeed-cache'); ?>
15
- <?php echo __('A site built with responsive design does not need to check this.', 'litespeed-cache'); ?>
16
  <br /><font class="litespeed-warning">
17
  ⚠️
18
  <?php echo __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ; ?>
11
  $this->build_switch(LiteSpeed_Cache_Config::OPID_CACHE_MOBILE);
12
  ?>
13
  <div class="litespeed-desc">
14
+ <?php echo __('Cache mobile views separately.', 'litespeed-cache'); ?>
15
+ <?php echo __('Only enable for AMP or mobile-specific design/content, not for responsive sites.', 'litespeed-cache'); ?>
16
  <br /><font class="litespeed-warning">
17
  ⚠️
18
  <?php echo __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ; ?>
inc/activation.class.php CHANGED
@@ -333,9 +333,9 @@ class LiteSpeed_Cache_Activation
333
  * Upgrade LSCWP
334
  *
335
  * @since 2.9
336
- * @access private
337
  */
338
- private function _upgrade()
339
  {
340
  $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
341
 
@@ -382,7 +382,7 @@ class LiteSpeed_Cache_Activation
382
 
383
  switch ( $type ) {
384
  case self::TYPE_UPGRADE :
385
- $instance->_upgrade() ;
386
  break ;
387
 
388
  default:
333
  * Upgrade LSCWP
334
  *
335
  * @since 2.9
336
+ * @access public
337
  */
338
+ public function upgrade()
339
  {
340
  $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
341
 
382
 
383
  switch ( $type ) {
384
  case self::TYPE_UPGRADE :
385
+ $instance->upgrade() ;
386
  break ;
387
 
388
  default:
inc/api.class.php CHANGED
@@ -530,6 +530,7 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
530
  * Easiest way to replace WP nonce to an ESI widget
531
  *
532
  * @since 2.6
 
533
  * @access public
534
  */
535
  public static function nonce( $action = -1, $defence_for_html_filter = true )
@@ -539,7 +540,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
539
  }
540
 
541
  // Replace it to ESI
542
- return self::esi_url( 'lscwp_nonce_esi', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
 
 
 
 
 
 
 
 
 
 
543
  }
544
 
545
  /**
530
  * Easiest way to replace WP nonce to an ESI widget
531
  *
532
  * @since 2.6
533
+ * @deprecated 2.9.5 Dropped-in wp_create_nonce replacement
534
  * @access public
535
  */
536
  public static function nonce( $action = -1, $defence_for_html_filter = true )
540
  }
541
 
542
  // Replace it to ESI
543
+ return self::esi_url( 'nonce', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
544
+ }
545
+
546
+ /**
547
+ * Append an action to nonce to convert it to ESI
548
+ *
549
+ * @since 2.9.5
550
+ */
551
+ public static function nonce_action( $action )
552
+ {
553
+ LiteSpeed_Cache_ESI::get_instance()->nonce_action( $action ) ;
554
  }
555
 
556
  /**
inc/esi.class.php CHANGED
@@ -22,6 +22,7 @@ class LiteSpeed_Cache_ESI
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
24
  private $_esi_preserve_list = array() ;
 
25
 
26
  const QS_ACTION = 'lsesi' ;
27
  const QS_PARAMS = 'esi' ;
@@ -48,7 +49,7 @@ class LiteSpeed_Cache_ESI
48
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
49
 
50
  // This defination is along with LiteSpeed_Cache_API::nonce() func
51
- ! defined( 'LSCWP_NONCE' ) && define( 'LSCWP_NONCE', true ) ;
52
 
53
  /**
54
  * Recover REQUEST_URI
@@ -74,6 +75,81 @@ class LiteSpeed_Cache_ESI
74
  if ( ! is_admin() ) {
75
  add_shortcode( 'esi', array( $this, 'shortcode' ) ) ;
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  /**
@@ -162,7 +238,7 @@ class LiteSpeed_Cache_ESI
162
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
163
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
164
 
165
- add_action('litespeed_cache_load_esi_block-lscwp_nonce_esi', array( $this, 'load_nonce_block' ) ) ;
166
  add_action('litespeed_cache_load_esi_block-esi', array( $this, 'load_esi_shortcode' ) ) ;
167
  }
168
 
@@ -294,7 +370,7 @@ class LiteSpeed_Cache_ESI
294
  $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
295
  }
296
 
297
- LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
298
  LiteSpeed_Cache_Log::debug2( $output ) ;
299
 
300
  self::set_has_esi() ;
@@ -350,11 +426,11 @@ class LiteSpeed_Cache_ESI
350
  $params = $this->_parse_esi_param() ;
351
 
352
  if ( defined( 'LSCWP_LOG' ) ) {
353
- $logInfo = '------- ESI ------- ' ;
354
  if( ! empty( $params[ self::PARAM_NAME ] ) ) {
355
  $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ' ;
356
  }
357
- $logInfo .= LSCACHE_IS_ESI . ' -------' ;
358
  LiteSpeed_Cache_Log::debug( $logInfo ) ;
359
  }
360
 
@@ -621,7 +697,12 @@ class LiteSpeed_Cache_ESI
621
  LiteSpeed_Cache_Control::set_private() ;
622
  }
623
 
624
- echo wp_create_nonce( $action ) ;
 
 
 
 
 
625
  }
626
 
627
  /**
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
24
  private $_esi_preserve_list = array() ;
25
+ private $_nonce_actions = array( -1 ) ;
26
 
27
  const QS_ACTION = 'lsesi' ;
28
  const QS_PARAMS = 'esi' ;
49
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
50
 
51
  // This defination is along with LiteSpeed_Cache_API::nonce() func
52
+ ! defined( 'LSCWP_NONCE' ) && define( 'LSCWP_NONCE', true ) ;//Used in Bloom
53
 
54
  /**
55
  * Recover REQUEST_URI
75
  if ( ! is_admin() ) {
76
  add_shortcode( 'esi', array( $this, 'shortcode' ) ) ;
77
  }
78
+
79
+ /**
80
+ * Overwrite wp_create_nonce func
81
+ * @since 2.9.5
82
+ */
83
+ if ( ! is_admin() && ! function_exists( 'wp_create_nonce' ) ) {
84
+ $this->_transform_nonce() ;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Take over all nonce calls and transform to ESI
90
+ *
91
+ * @since 2.9.5
92
+ */
93
+ private function _transform_nonce()
94
+ {
95
+ LiteSpeed_Cache_Log::debug( '[ESI] Overwrite wp_create_nonce()' ) ;
96
+ /**
97
+ * If the nonce is in none_actions filter, convert it to ESI
98
+ */
99
+ function wp_create_nonce( $action = -1 ) {
100
+ if ( LiteSpeed_Cache_ESI::get_instance()->is_nonce_action( $action ) ) {
101
+ $params = array(
102
+ 'action' => $action,
103
+ ) ;
104
+ return LiteSpeed_Cache_ESI::sub_esi_block( 'nonce', 'wp_create_nonce ' . $action, $params, '', true, true ) ;
105
+ }
106
+
107
+ return wp_create_nonce_litespeed_esi( $action ) ;
108
+
109
+ }
110
+
111
+ /**
112
+ * Ori WP wp_create_nonce
113
+ */
114
+ function wp_create_nonce_litespeed_esi( $action = -1 ) {
115
+ $user = wp_get_current_user();
116
+ $uid = (int) $user->ID;
117
+ if ( ! $uid ) {
118
+ /** This filter is documented in wp-includes/pluggable.php */
119
+ $uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
120
+ }
121
+
122
+ $token = wp_get_session_token();
123
+ $i = wp_nonce_tick();
124
+
125
+ return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Register a new nonce action to convert it to ESI
131
+ *
132
+ * @since 2.9.5
133
+ */
134
+ public function nonce_action( $action )
135
+ {
136
+ if ( in_array( $action, $this->_nonce_actions ) ) {
137
+ return ;
138
+ }
139
+
140
+ LiteSpeed_Cache_Log::debug( '[ESI] Append nonce action to nonce list [action] ' . $action ) ;
141
+
142
+ $this->_nonce_actions[] = $action ;
143
+ }
144
+
145
+ /**
146
+ * Check if an action is registered to replace ESI
147
+ *
148
+ * @since 2.9.5
149
+ */
150
+ public function is_nonce_action( $action )
151
+ {
152
+ return in_array( $action, $this->_nonce_actions ) ;
153
  }
154
 
155
  /**
238
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
239
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
240
 
241
+ add_action('litespeed_cache_load_esi_block-nonce', array( $this, 'load_nonce_block' ) ) ;
242
  add_action('litespeed_cache_load_esi_block-esi', array( $this, 'load_esi_shortcode' ) ) ;
243
  }
244
 
370
  $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
371
  }
372
 
373
+ LiteSpeed_Cache_Log::debug( "[ESI] 💕 [BLock_ID] $block_id \t[wrapper] $wrapper \t\t[Control] $control" ) ;
374
  LiteSpeed_Cache_Log::debug2( $output ) ;
375
 
376
  self::set_has_esi() ;
426
  $params = $this->_parse_esi_param() ;
427
 
428
  if ( defined( 'LSCWP_LOG' ) ) {
429
+ $logInfo = '[ESI] ' ;
430
  if( ! empty( $params[ self::PARAM_NAME ] ) ) {
431
  $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ' ;
432
  }
433
+ $logInfo .= ' [ID] ' . LSCACHE_IS_ESI ;
434
  LiteSpeed_Cache_Log::debug( $logInfo ) ;
435
  }
436
 
697
  LiteSpeed_Cache_Control::set_private() ;
698
  }
699
 
700
+ if ( function_exists( 'wp_create_nonce_litespeed_esi' ) ) {
701
+ echo wp_create_nonce_litespeed_esi( $action ) ;
702
+ }
703
+ else {
704
+ echo wp_create_nonce( $action ) ;
705
+ }
706
  }
707
 
708
  /**
inc/img_optm.class.php CHANGED
@@ -1082,6 +1082,12 @@ class LiteSpeed_Cache_Img_Optm
1082
 
1083
  LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img: ' . $local_file ) ;
1084
 
 
 
 
 
 
 
1085
  $target_size = filesize( $local_file ) ;
1086
 
1087
  $total_pulled_ori ++ ;
@@ -1117,6 +1123,13 @@ class LiteSpeed_Cache_Img_Optm
1117
 
1118
  LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
1119
 
 
 
 
 
 
 
 
1120
  $webp_size = filesize( $local_file . '.webp' ) ;
1121
 
1122
  $total_pulled_webp ++ ;
1082
 
1083
  LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img: ' . $local_file ) ;
1084
 
1085
+ /**
1086
+ * API Hook
1087
+ * @since 2.9.5
1088
+ */
1089
+ do_action( 'litespeed_img_pull_ori', $row_img, $local_file ) ;
1090
+
1091
  $target_size = filesize( $local_file ) ;
1092
 
1093
  $total_pulled_ori ++ ;
1123
 
1124
  LiteSpeed_Cache_Log::debug( '[Img_Optm] Pulled optimized img WebP: ' . $local_file . '.webp' ) ;
1125
 
1126
+ /**
1127
+ * API for WebP
1128
+ * @since 2.9.5
1129
+ * @see #751737 - API docs for WEBP generation
1130
+ */
1131
+ do_action( 'litespeed_img_pull_webp', $row_img, $local_file . '.webp' ) ;
1132
+
1133
  $webp_size = filesize( $local_file . '.webp' ) ;
1134
 
1135
  $total_pulled_webp ++ ;
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.4.1' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
@@ -573,9 +573,14 @@ class LiteSpeed_Cache
573
  * @since 2.9.4 ESI req could be from internal REST call, so moved json_encode out of this cond
574
  */
575
  if ( defined( 'LSCACHE_IS_ESI' ) ) {
576
- LiteSpeed_Cache_Log::debug( '[Core] ESI----------Start--------' ) ;
577
- LiteSpeed_Cache_Log::debug( $buffer ) ;
578
- LiteSpeed_Cache_Log::debug( '[Core] ESI----------End--------' ) ;
 
 
 
 
 
579
  }
580
 
581
  if ( apply_filters( 'litespeed_is_json', false ) ) {
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.5' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
573
  * @since 2.9.4 ESI req could be from internal REST call, so moved json_encode out of this cond
574
  */
575
  if ( defined( 'LSCACHE_IS_ESI' ) ) {
576
+ LiteSpeed_Cache_Log::debug( '[Core] ESI Start 👇' ) ;
577
+ if ( strlen( $buffer ) > 100 ) {
578
+ LiteSpeed_Cache_Log::debug( trim( substr( $buffer, 0, 100 ) ) . '.....' ) ;
579
+ }
580
+ else {
581
+ LiteSpeed_Cache_Log::debug( $buffer ) ;
582
+ }
583
+ LiteSpeed_Cache_Log::debug( '[Core] ESI End 👆' ) ;
584
  }
585
 
586
  if ( apply_filters( 'litespeed_is_json', false ) ) {
inc/log.class.php CHANGED
@@ -25,6 +25,9 @@ class LiteSpeed_Cache_Log
25
  private static $_ignore_part_filters ;
26
 
27
  const TYPE_CLEAR_LOG = 'clear_log' ;
 
 
 
28
 
29
  /**
30
  * Log class Constructor
@@ -49,6 +52,74 @@ class LiteSpeed_Cache_Log
49
 
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Log Purge headers separately
54
  *
@@ -148,7 +219,7 @@ class LiteSpeed_Cache_Log
148
  $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
149
  }
150
 
151
- $param = sprintf( '------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
152
 
153
  $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
154
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
@@ -396,6 +467,10 @@ class LiteSpeed_Cache_Log
396
  $instance->_clear_log() ;
397
  break ;
398
 
 
 
 
 
399
  default:
400
  break ;
401
  }
25
  private static $_ignore_part_filters ;
26
 
27
  const TYPE_CLEAR_LOG = 'clear_log' ;
28
+ const TYPE_BETA_TEST = 'beta_test' ;
29
+
30
+ const BETA_TEST_URL = 'beta_test_url' ;
31
 
32
  /**
33
  * Log class Constructor
52
 
53
  }
54
 
55
+ /**
56
+ * Beta test upgrade
57
+ *
58
+ * @since 2.9.5
59
+ * @access private
60
+ */
61
+ private function _beta_test()
62
+ {
63
+ if ( empty( $_POST[ self::BETA_TEST_URL ] ) ) {
64
+ return ;
65
+ }
66
+
67
+ // Generate zip url
68
+ $commit = substr( $_POST[ self::BETA_TEST_URL ], strpos( $_POST[ self::BETA_TEST_URL ], '/commit/' ) + 8 ) ;
69
+ $zip = $this->_package_zip( $commit ) ;
70
+
71
+ if ( ! $zip ) {
72
+ LiteSpeed_Cache_Log::debug( '[Log] ❌ No ZIP file' ) ;
73
+ return ;
74
+ }
75
+
76
+ LiteSpeed_Cache_Log::debug( '[Log] ZIP file ' . $zip ) ;
77
+
78
+ $update_plugins = get_site_transient( 'update_plugins' ) ;
79
+ if ( ! is_object( $update_plugins ) ) {
80
+ $update_plugins = new \stdClass() ;
81
+ }
82
+
83
+ $plugin_info = new \stdClass() ;
84
+ $plugin_info->new_version = LiteSpeed_Cache::PLUGIN_VERSION . '.0.0' ;
85
+ $plugin_info->slug = LiteSpeed_Cache::PLUGIN_NAME ;
86
+ $plugin_info->plugin = LiteSpeed_Cache::PLUGIN_FILE ;
87
+ $plugin_info->package = $zip ;
88
+ $plugin_info->url = 'https://wordpress.org/plugins/litespeed-cache/' ;
89
+
90
+ $update_plugins->response[ LiteSpeed_Cache::PLUGIN_FILE ] = $plugin_info ;
91
+
92
+ set_site_transient( 'update_plugins', $update_plugins ) ;
93
+
94
+ // Run upgrade
95
+ LiteSpeed_Cache_Activation::get_instance()->upgrade() ;
96
+ }
97
+
98
+ /**
99
+ * Git package refresh
100
+ *
101
+ * @since 2.9.5
102
+ * @access private
103
+ */
104
+ private function _package_zip( $commit )
105
+ {
106
+ // Check latest stable version allowed to upgrade
107
+ $url = 'https://wp.api.litespeedtech.com/client.package_zip?commit=' . $commit ;
108
+
109
+ $response = wp_remote_get( $url, array( 'timeout' => 120 ) ) ;
110
+ if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
111
+ return false ;
112
+ }
113
+
114
+ $url = json_decode( $response[ 'body' ], true ) ;
115
+
116
+ if ( empty( $url[ 'zip' ] ) ) {
117
+ return false ;
118
+ }
119
+
120
+ return $url[ 'zip' ] ;
121
+ }
122
+
123
  /**
124
  * Log Purge headers separately
125
  *
219
  $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
220
  }
221
 
222
+ $param = sprintf( '💓 ------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
223
 
224
  $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
225
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
467
  $instance->_clear_log() ;
468
  break ;
469
 
470
+ case self::TYPE_BETA_TEST :
471
+ $instance->_beta_test() ;
472
+ break ;
473
+
474
  default:
475
  break ;
476
  }
inc/media.class.php CHANGED
@@ -784,9 +784,15 @@ eot;
784
  return false ;
785
  }
786
 
787
- if ( LiteSpeed_Cache_Utility::is_internal_file( $url ) ) {
 
 
 
 
 
 
788
  // check if has webp file
789
- if ( LiteSpeed_Cache_Utility::is_internal_file( $url, 'webp' ) ) {
790
  $url .= '.webp' ;
791
  }
792
  else {
784
  return false ;
785
  }
786
 
787
+ /**
788
+ * WebP API hook
789
+ * NOTE: As $url may contain query strings, WebP check will need to parse_url before appending .webp
790
+ * @since 2.9.5
791
+ * @see #751737 - API docs for WEBP generation
792
+ */
793
+ if ( apply_filters( 'litespeed_media_check_ori', LiteSpeed_Cache_Utility::is_internal_file( $url ), $url ) ) {
794
  // check if has webp file
795
+ if ( apply_filters( 'litespeed_media_check_webp', LiteSpeed_Cache_Utility::is_internal_file( $url, 'webp' ), $url ) ) {
796
  $url .= '.webp' ;
797
  }
798
  else {
inc/optimize.class.php CHANGED
@@ -829,9 +829,9 @@ class LiteSpeed_Cache_Optimize
829
  // }
830
 
831
  // Check if has no-optimize attr
832
- if ( strpos( $html_list[ $key ], 'data-no-optimize' ) !== false ) {
833
  $ignored_html[] = $html_list[ $key ] ;
834
- LiteSpeed_Cache_Log::debug2( '[Optm] Abort excludes: attr data-no-optimize' ) ;
835
  continue ;
836
  }
837
 
829
  // }
830
 
831
  // Check if has no-optimize attr
832
+ if ( strpos( $html_list[ $key ], 'data-ignore-optimize' ) !== false ) {
833
  $ignored_html[] = $html_list[ $key ] ;
834
+ LiteSpeed_Cache_Log::debug2( '[Optm] Abort excludes: attr data-ignore-optimize' ) ;
835
  continue ;
836
  }
837
 
inc/rest.cls.php CHANGED
File without changes
inc/vary.class.php CHANGED
@@ -141,26 +141,32 @@ class LiteSpeed_Cache_Vary
141
  */
142
  public function check_commenter( $comments )
143
  {
144
- $pending = false ;
145
- foreach ( $comments as $comment ) {
146
- if ( ! $comment->comment_approved ) {// current user has pending comment
147
- $pending = true ;
148
- break ;
 
 
 
 
 
 
149
  }
150
- }
151
 
152
- // No pending comments, don't need to add private cache
153
- if ( ! $pending ) {
154
- $this->remove_commenter() ;
155
 
156
- // Remove commenter prefilled info if exists, for public cache
157
- foreach( $_COOKIE as $cookie_name => $cookie_value ) {
158
- if ( strlen( $cookie_name ) >= 15 && strpos( $cookie_name, 'comment_author_' ) === 0 ) {
159
- unset( $_COOKIE[ $cookie_name ] ) ;
 
160
  }
161
- }
162
 
163
- return $comments ;
 
164
  }
165
 
166
  // Current user/visitor has pending comments
141
  */
142
  public function check_commenter( $comments )
143
  {
144
+ /**
145
+ * Hook to bypass pending comment check for comment related plugins compatibility
146
+ * @since 2.9.5
147
+ */
148
+ if ( apply_filters( 'litespeed_vary_check_commenter_pending', true ) ) {
149
+ $pending = false ;
150
+ foreach ( $comments as $comment ) {
151
+ if ( ! $comment->comment_approved ) {// current user has pending comment
152
+ $pending = true ;
153
+ break ;
154
+ }
155
  }
 
156
 
157
+ // No pending comments, don't need to add private cache
158
+ if ( ! $pending ) {
159
+ $this->remove_commenter() ;
160
 
161
+ // Remove commenter prefilled info if exists, for public cache
162
+ foreach( $_COOKIE as $cookie_name => $cookie_value ) {
163
+ if ( strlen( $cookie_name ) >= 15 && strpos( $cookie_name, 'comment_author_' ) === 0 ) {
164
+ unset( $_COOKIE[ $cookie_name ] ) ;
165
+ }
166
  }
 
167
 
168
+ return $comments ;
169
+ }
170
  }
171
 
172
  // Current user/visitor has pending comments
includes/litespeed-cache-activation.class.php CHANGED
@@ -333,9 +333,9 @@ class LiteSpeed_Cache_Activation
333
  * Upgrade LSCWP
334
  *
335
  * @since 2.9
336
- * @access private
337
  */
338
- private function _upgrade()
339
  {
340
  $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
341
 
@@ -382,7 +382,7 @@ class LiteSpeed_Cache_Activation
382
 
383
  switch ( $type ) {
384
  case self::TYPE_UPGRADE :
385
- $instance->_upgrade() ;
386
  break ;
387
 
388
  default:
333
  * Upgrade LSCWP
334
  *
335
  * @since 2.9
336
+ * @access public
337
  */
338
+ public function upgrade()
339
  {
340
  $plugin = LiteSpeed_Cache::PLUGIN_FILE ;
341
 
382
 
383
  switch ( $type ) {
384
  case self::TYPE_UPGRADE :
385
+ $instance->upgrade() ;
386
  break ;
387
 
388
  default:
includes/litespeed-cache-api.class.php CHANGED
@@ -530,6 +530,7 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
530
  * Easiest way to replace WP nonce to an ESI widget
531
  *
532
  * @since 2.6
 
533
  * @access public
534
  */
535
  public static function nonce( $action = -1, $defence_for_html_filter = true )
@@ -539,7 +540,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
539
  }
540
 
541
  // Replace it to ESI
542
- return self::esi_url( 'lscwp_nonce_esi', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
 
 
 
 
 
 
 
 
 
 
543
  }
544
 
545
  /**
530
  * Easiest way to replace WP nonce to an ESI widget
531
  *
532
  * @since 2.6
533
+ * @deprecated 2.9.5 Dropped-in wp_create_nonce replacement
534
  * @access public
535
  */
536
  public static function nonce( $action = -1, $defence_for_html_filter = true )
540
  }
541
 
542
  // Replace it to ESI
543
+ return self::esi_url( 'nonce', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
544
+ }
545
+
546
+ /**
547
+ * Append an action to nonce to convert it to ESI
548
+ *
549
+ * @since 2.9.5
550
+ */
551
+ public static function nonce_action( $action )
552
+ {
553
+ LiteSpeed_Cache_ESI::get_instance()->nonce_action( $action ) ;
554
  }
555
 
556
  /**
includes/litespeed-cache-esi.class.php CHANGED
@@ -22,6 +22,7 @@ class LiteSpeed_Cache_ESI
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
24
  private $_esi_preserve_list = array() ;
 
25
 
26
  const QS_ACTION = 'lsesi' ;
27
  const QS_PARAMS = 'esi' ;
@@ -48,7 +49,7 @@ class LiteSpeed_Cache_ESI
48
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
49
 
50
  // This defination is along with LiteSpeed_Cache_API::nonce() func
51
- ! defined( 'LSCWP_NONCE' ) && define( 'LSCWP_NONCE', true ) ;
52
 
53
  /**
54
  * Recover REQUEST_URI
@@ -74,6 +75,81 @@ class LiteSpeed_Cache_ESI
74
  if ( ! is_admin() ) {
75
  add_shortcode( 'esi', array( $this, 'shortcode' ) ) ;
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  }
78
 
79
  /**
@@ -162,7 +238,7 @@ class LiteSpeed_Cache_ESI
162
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
163
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
164
 
165
- add_action('litespeed_cache_load_esi_block-lscwp_nonce_esi', array( $this, 'load_nonce_block' ) ) ;
166
  add_action('litespeed_cache_load_esi_block-esi', array( $this, 'load_esi_shortcode' ) ) ;
167
  }
168
 
@@ -294,7 +370,7 @@ class LiteSpeed_Cache_ESI
294
  $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
295
  }
296
 
297
- LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
298
  LiteSpeed_Cache_Log::debug2( $output ) ;
299
 
300
  self::set_has_esi() ;
@@ -350,11 +426,11 @@ class LiteSpeed_Cache_ESI
350
  $params = $this->_parse_esi_param() ;
351
 
352
  if ( defined( 'LSCWP_LOG' ) ) {
353
- $logInfo = '------- ESI ------- ' ;
354
  if( ! empty( $params[ self::PARAM_NAME ] ) ) {
355
  $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ' ;
356
  }
357
- $logInfo .= LSCACHE_IS_ESI . ' -------' ;
358
  LiteSpeed_Cache_Log::debug( $logInfo ) ;
359
  }
360
 
@@ -621,7 +697,12 @@ class LiteSpeed_Cache_ESI
621
  LiteSpeed_Cache_Control::set_private() ;
622
  }
623
 
624
- echo wp_create_nonce( $action ) ;
 
 
 
 
 
625
  }
626
 
627
  /**
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
24
  private $_esi_preserve_list = array() ;
25
+ private $_nonce_actions = array( -1 ) ;
26
 
27
  const QS_ACTION = 'lsesi' ;
28
  const QS_PARAMS = 'esi' ;
49
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
50
 
51
  // This defination is along with LiteSpeed_Cache_API::nonce() func
52
+ ! defined( 'LSCWP_NONCE' ) && define( 'LSCWP_NONCE', true ) ;//Used in Bloom
53
 
54
  /**
55
  * Recover REQUEST_URI
75
  if ( ! is_admin() ) {
76
  add_shortcode( 'esi', array( $this, 'shortcode' ) ) ;
77
  }
78
+
79
+ /**
80
+ * Overwrite wp_create_nonce func
81
+ * @since 2.9.5
82
+ */
83
+ if ( ! is_admin() && ! function_exists( 'wp_create_nonce' ) ) {
84
+ $this->_transform_nonce() ;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Take over all nonce calls and transform to ESI
90
+ *
91
+ * @since 2.9.5
92
+ */
93
+ private function _transform_nonce()
94
+ {
95
+ LiteSpeed_Cache_Log::debug( '[ESI] Overwrite wp_create_nonce()' ) ;
96
+ /**
97
+ * If the nonce is in none_actions filter, convert it to ESI
98
+ */
99
+ function wp_create_nonce( $action = -1 ) {
100
+ if ( LiteSpeed_Cache_ESI::get_instance()->is_nonce_action( $action ) ) {
101
+ $params = array(
102
+ 'action' => $action,
103
+ ) ;
104
+ return LiteSpeed_Cache_ESI::sub_esi_block( 'nonce', 'wp_create_nonce ' . $action, $params, '', true, true ) ;
105
+ }
106
+
107
+ return wp_create_nonce_litespeed_esi( $action ) ;
108
+
109
+ }
110
+
111
+ /**
112
+ * Ori WP wp_create_nonce
113
+ */
114
+ function wp_create_nonce_litespeed_esi( $action = -1 ) {
115
+ $user = wp_get_current_user();
116
+ $uid = (int) $user->ID;
117
+ if ( ! $uid ) {
118
+ /** This filter is documented in wp-includes/pluggable.php */
119
+ $uid = apply_filters( 'nonce_user_logged_out', $uid, $action );
120
+ }
121
+
122
+ $token = wp_get_session_token();
123
+ $i = wp_nonce_tick();
124
+
125
+ return substr( wp_hash( $i . '|' . $action . '|' . $uid . '|' . $token, 'nonce' ), -12, 10 );
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Register a new nonce action to convert it to ESI
131
+ *
132
+ * @since 2.9.5
133
+ */
134
+ public function nonce_action( $action )
135
+ {
136
+ if ( in_array( $action, $this->_nonce_actions ) ) {
137
+ return ;
138
+ }
139
+
140
+ LiteSpeed_Cache_Log::debug( '[ESI] Append nonce action to nonce list [action] ' . $action ) ;
141
+
142
+ $this->_nonce_actions[] = $action ;
143
+ }
144
+
145
+ /**
146
+ * Check if an action is registered to replace ESI
147
+ *
148
+ * @since 2.9.5
149
+ */
150
+ public function is_nonce_action( $action )
151
+ {
152
+ return in_array( $action, $this->_nonce_actions ) ;
153
  }
154
 
155
  /**
238
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
239
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
240
 
241
+ add_action('litespeed_cache_load_esi_block-nonce', array( $this, 'load_nonce_block' ) ) ;
242
  add_action('litespeed_cache_load_esi_block-esi', array( $this, 'load_esi_shortcode' ) ) ;
243
  }
244
 
370
  $output = "<!-- lscwp $wrapper -->$output<!-- lscwp $wrapper esi end -->" ;
371
  }
372
 
373
+ LiteSpeed_Cache_Log::debug( "[ESI] 💕 [BLock_ID] $block_id \t[wrapper] $wrapper \t\t[Control] $control" ) ;
374
  LiteSpeed_Cache_Log::debug2( $output ) ;
375
 
376
  self::set_has_esi() ;
426
  $params = $this->_parse_esi_param() ;
427
 
428
  if ( defined( 'LSCWP_LOG' ) ) {
429
+ $logInfo = '[ESI] ' ;
430
  if( ! empty( $params[ self::PARAM_NAME ] ) ) {
431
  $logInfo .= ' Name: ' . $params[ self::PARAM_NAME ] . ' ----- ' ;
432
  }
433
+ $logInfo .= ' [ID] ' . LSCACHE_IS_ESI ;
434
  LiteSpeed_Cache_Log::debug( $logInfo ) ;
435
  }
436
 
697
  LiteSpeed_Cache_Control::set_private() ;
698
  }
699
 
700
+ if ( function_exists( 'wp_create_nonce_litespeed_esi' ) ) {
701
+ echo wp_create_nonce_litespeed_esi( $action ) ;
702
+ }
703
+ else {
704
+ echo wp_create_nonce( $action ) ;
705
+ }
706
  }
707
 
708
  /**
includes/litespeed-cache-log.class.php CHANGED
@@ -25,6 +25,9 @@ class LiteSpeed_Cache_Log
25
  private static $_ignore_part_filters ;
26
 
27
  const TYPE_CLEAR_LOG = 'clear_log' ;
 
 
 
28
 
29
  /**
30
  * Log class Constructor
@@ -49,6 +52,74 @@ class LiteSpeed_Cache_Log
49
 
50
  }
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Log Purge headers separately
54
  *
@@ -148,7 +219,7 @@ class LiteSpeed_Cache_Log
148
  $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
149
  }
150
 
151
- $param = sprintf( '------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
152
 
153
  $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
154
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
@@ -396,6 +467,10 @@ class LiteSpeed_Cache_Log
396
  $instance->_clear_log() ;
397
  break ;
398
 
 
 
 
 
399
  default:
400
  break ;
401
  }
25
  private static $_ignore_part_filters ;
26
 
27
  const TYPE_CLEAR_LOG = 'clear_log' ;
28
+ const TYPE_BETA_TEST = 'beta_test' ;
29
+
30
+ const BETA_TEST_URL = 'beta_test_url' ;
31
 
32
  /**
33
  * Log class Constructor
52
 
53
  }
54
 
55
+ /**
56
+ * Beta test upgrade
57
+ *
58
+ * @since 2.9.5
59
+ * @access private
60
+ */
61
+ private function _beta_test()
62
+ {
63
+ if ( empty( $_POST[ self::BETA_TEST_URL ] ) ) {
64
+ return ;
65
+ }
66
+
67
+ // Generate zip url
68
+ $commit = substr( $_POST[ self::BETA_TEST_URL ], strpos( $_POST[ self::BETA_TEST_URL ], '/commit/' ) + 8 ) ;
69
+ $zip = $this->_package_zip( $commit ) ;
70
+
71
+ if ( ! $zip ) {
72
+ LiteSpeed_Cache_Log::debug( '[Log] ❌ No ZIP file' ) ;
73
+ return ;
74
+ }
75
+
76
+ LiteSpeed_Cache_Log::debug( '[Log] ZIP file ' . $zip ) ;
77
+
78
+ $update_plugins = get_site_transient( 'update_plugins' ) ;
79
+ if ( ! is_object( $update_plugins ) ) {
80
+ $update_plugins = new \stdClass() ;
81
+ }
82
+
83
+ $plugin_info = new \stdClass() ;
84
+ $plugin_info->new_version = LiteSpeed_Cache::PLUGIN_VERSION . '.0.0' ;
85
+ $plugin_info->slug = LiteSpeed_Cache::PLUGIN_NAME ;
86
+ $plugin_info->plugin = LiteSpeed_Cache::PLUGIN_FILE ;
87
+ $plugin_info->package = $zip ;
88
+ $plugin_info->url = 'https://wordpress.org/plugins/litespeed-cache/' ;
89
+
90
+ $update_plugins->response[ LiteSpeed_Cache::PLUGIN_FILE ] = $plugin_info ;
91
+
92
+ set_site_transient( 'update_plugins', $update_plugins ) ;
93
+
94
+ // Run upgrade
95
+ LiteSpeed_Cache_Activation::get_instance()->upgrade() ;
96
+ }
97
+
98
+ /**
99
+ * Git package refresh
100
+ *
101
+ * @since 2.9.5
102
+ * @access private
103
+ */
104
+ private function _package_zip( $commit )
105
+ {
106
+ // Check latest stable version allowed to upgrade
107
+ $url = 'https://wp.api.litespeedtech.com/client.package_zip?commit=' . $commit ;
108
+
109
+ $response = wp_remote_get( $url, array( 'timeout' => 120 ) ) ;
110
+ if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
111
+ return false ;
112
+ }
113
+
114
+ $url = json_decode( $response[ 'body' ], true ) ;
115
+
116
+ if ( empty( $url[ 'zip' ] ) ) {
117
+ return false ;
118
+ }
119
+
120
+ return $url[ 'zip' ] ;
121
+ }
122
+
123
  /**
124
  * Log Purge headers separately
125
  *
219
  $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
220
  }
221
 
222
+ $param = sprintf( '💓 ------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
223
 
224
  $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
225
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_COLLAPS_QS ) ) {
467
  $instance->_clear_log() ;
468
  break ;
469
 
470
+ case self::TYPE_BETA_TEST :
471
+ $instance->_beta_test() ;
472
+ break ;
473
+
474
  default:
475
  break ;
476
  }
includes/litespeed-cache-optimize.class.php CHANGED
@@ -829,9 +829,9 @@ class LiteSpeed_Cache_Optimize
829
  // }
830
 
831
  // Check if has no-optimize attr
832
- if ( strpos( $html_list[ $key ], 'data-no-optimize' ) !== false ) {
833
  $ignored_html[] = $html_list[ $key ] ;
834
- LiteSpeed_Cache_Log::debug2( '[Optm] Abort excludes: attr data-no-optimize' ) ;
835
  continue ;
836
  }
837
 
829
  // }
830
 
831
  // Check if has no-optimize attr
832
+ if ( strpos( $html_list[ $key ], 'data-ignore-optimize' ) !== false ) {
833
  $ignored_html[] = $html_list[ $key ] ;
834
+ LiteSpeed_Cache_Log::debug2( '[Optm] Abort excludes: attr data-ignore-optimize' ) ;
835
  continue ;
836
  }
837
 
includes/litespeed-cache-vary.class.php CHANGED
@@ -141,26 +141,32 @@ class LiteSpeed_Cache_Vary
141
  */
142
  public function check_commenter( $comments )
143
  {
144
- $pending = false ;
145
- foreach ( $comments as $comment ) {
146
- if ( ! $comment->comment_approved ) {// current user has pending comment
147
- $pending = true ;
148
- break ;
 
 
 
 
 
 
149
  }
150
- }
151
 
152
- // No pending comments, don't need to add private cache
153
- if ( ! $pending ) {
154
- $this->remove_commenter() ;
155
 
156
- // Remove commenter prefilled info if exists, for public cache
157
- foreach( $_COOKIE as $cookie_name => $cookie_value ) {
158
- if ( strlen( $cookie_name ) >= 15 && strpos( $cookie_name, 'comment_author_' ) === 0 ) {
159
- unset( $_COOKIE[ $cookie_name ] ) ;
 
160
  }
161
- }
162
 
163
- return $comments ;
 
164
  }
165
 
166
  // Current user/visitor has pending comments
141
  */
142
  public function check_commenter( $comments )
143
  {
144
+ /**
145
+ * Hook to bypass pending comment check for comment related plugins compatibility
146
+ * @since 2.9.5
147
+ */
148
+ if ( apply_filters( 'litespeed_vary_check_commenter_pending', true ) ) {
149
+ $pending = false ;
150
+ foreach ( $comments as $comment ) {
151
+ if ( ! $comment->comment_approved ) {// current user has pending comment
152
+ $pending = true ;
153
+ break ;
154
+ }
155
  }
 
156
 
157
+ // No pending comments, don't need to add private cache
158
+ if ( ! $pending ) {
159
+ $this->remove_commenter() ;
160
 
161
+ // Remove commenter prefilled info if exists, for public cache
162
+ foreach( $_COOKIE as $cookie_name => $cookie_value ) {
163
+ if ( strlen( $cookie_name ) >= 15 && strpos( $cookie_name, 'comment_author_' ) === 0 ) {
164
+ unset( $_COOKIE[ $cookie_name ] ) ;
165
+ }
166
  }
 
167
 
168
+ return $comments ;
169
+ }
170
  }
171
 
172
  // Current user/visitor has pending comments
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.4.1' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
@@ -573,9 +573,14 @@ class LiteSpeed_Cache
573
  * @since 2.9.4 ESI req could be from internal REST call, so moved json_encode out of this cond
574
  */
575
  if ( defined( 'LSCACHE_IS_ESI' ) ) {
576
- LiteSpeed_Cache_Log::debug( '[Core] ESI----------Start--------' ) ;
577
- LiteSpeed_Cache_Log::debug( $buffer ) ;
578
- LiteSpeed_Cache_Log::debug( '[Core] ESI----------End--------' ) ;
 
 
 
 
 
579
  }
580
 
581
  if ( apply_filters( 'litespeed_is_json', false ) ) {
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.5' ;
30
 
31
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
32
 
573
  * @since 2.9.4 ESI req could be from internal REST call, so moved json_encode out of this cond
574
  */
575
  if ( defined( 'LSCACHE_IS_ESI' ) ) {
576
+ LiteSpeed_Cache_Log::debug( '[Core] ESI Start 👇' ) ;
577
+ if ( strlen( $buffer ) > 100 ) {
578
+ LiteSpeed_Cache_Log::debug( trim( substr( $buffer, 0, 100 ) ) . '.....' ) ;
579
+ }
580
+ else {
581
+ LiteSpeed_Cache_Log::debug( $buffer ) ;
582
+ }
583
+ LiteSpeed_Cache_Log::debug( '[Core] ESI End 👆' ) ;
584
  }
585
 
586
  if ( apply_filters( 'litespeed_is_json', false ) ) {
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.4\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2019-02-27 15:22:04+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -713,11 +713,19 @@ msgid ""
713
  "crawling."
714
  msgstr ""
715
 
716
- #: admin/tpl/debug_log.php:9
717
  msgid "LiteSpeed Cache Debug Log Viewer"
718
  msgstr ""
719
 
720
- #: admin/tpl/debug_log.php:30
 
 
 
 
 
 
 
 
721
  msgid "Clear Log"
722
  msgstr ""
723
 
@@ -852,7 +860,7 @@ msgstr ""
852
  msgid "Rate %s on %s"
853
  msgstr ""
854
 
855
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.9.4) #-#-#-#-#
856
  #. Plugin Name of the plugin/theme
857
  #: admin/tpl/inc/admin_footer.php:6
858
  #: admin/tpl/inc/banner_promo.new_version.php:56 inc/gui.class.php:477
@@ -884,10 +892,6 @@ msgstr ""
884
  msgid "New release %s is available now."
885
  msgstr ""
886
 
887
- #: admin/tpl/inc/banner_promo.new_version.php:68
888
- msgid "Upgrade"
889
- msgstr ""
890
-
891
  #: admin/tpl/inc/banner_promo.new_version.php:78
892
  msgid "Turn On Auto Upgrade"
893
  msgstr ""
@@ -2847,11 +2851,13 @@ msgid "Cache Mobile"
2847
  msgstr ""
2848
 
2849
  #: admin/tpl/setting/settings_inc.cache_mobile.php:14
2850
- msgid "When enabled, mobile views will be cached separately."
2851
  msgstr ""
2852
 
2853
  #: admin/tpl/setting/settings_inc.cache_mobile.php:15
2854
- msgid "A site built with responsive design does not need to check this."
 
 
2855
  msgstr ""
2856
 
2857
  #: admin/tpl/setting/settings_inc.cache_mobile.php:25
@@ -4147,8 +4153,8 @@ msgstr ""
4147
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4148
  msgstr ""
4149
 
4150
- #: inc/img_optm.class.php:167 inc/img_optm.class.php:1451
4151
- #: inc/img_optm.class.php:1516
4152
  msgid "No image found."
4153
  msgstr ""
4154
 
@@ -4179,41 +4185,41 @@ msgid ""
4179
  "automated."
4180
  msgstr ""
4181
 
4182
- #: inc/img_optm.class.php:1340
4183
  msgid "Destroy unfinished data successfully."
4184
  msgstr ""
4185
 
4186
- #: inc/img_optm.class.php:1554
4187
  msgid ""
4188
  "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
4189
  "accepted %3$s groups with %4$s images."
4190
  msgstr ""
4191
 
4192
- #: inc/img_optm.class.php:1730
4193
  msgid "Removed %1$s images and saved %2$s successfully."
4194
  msgstr ""
4195
 
4196
- #: inc/img_optm.class.php:1925
4197
  msgid "Switched images successfully."
4198
  msgstr ""
4199
 
4200
- #: inc/img_optm.class.php:1956
4201
  msgid "Disabled WebP file successfully."
4202
  msgstr ""
4203
 
4204
- #: inc/img_optm.class.php:1962
4205
  msgid "Enabled WebP file successfully."
4206
  msgstr ""
4207
 
4208
- #: inc/img_optm.class.php:1978
4209
  msgid "Restored original file successfully."
4210
  msgstr ""
4211
 
4212
- #: inc/img_optm.class.php:1985
4213
  msgid "Switched to optimized file successfully."
4214
  msgstr ""
4215
 
4216
- #: inc/img_optm.class.php:2045
4217
  msgid "Reset the optimized data successfully."
4218
  msgstr ""
4219
 
@@ -4341,15 +4347,15 @@ msgstr ""
4341
  msgid "LiteSpeed Cache Custom Cron Crawler"
4342
  msgstr ""
4343
 
4344
- #: inc/utility.class.php:223 includes/litespeed-cache-utility.class.php:223
4345
  msgid "just now"
4346
  msgstr ""
4347
 
4348
- #: inc/utility.class.php:223 includes/litespeed-cache-utility.class.php:223
4349
  msgid "right now"
4350
  msgstr ""
4351
 
4352
- #: inc/utility.class.php:226 includes/litespeed-cache-utility.class.php:226
4353
  msgid " %s ago"
4354
  msgstr ""
4355
 
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.5\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2019-03-14 17:35:45+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
713
  "crawling."
714
  msgstr ""
715
 
716
+ #: admin/tpl/debug_log.php:8
717
  msgid "LiteSpeed Cache Debug Log Viewer"
718
  msgstr ""
719
 
720
+ #: admin/tpl/debug_log.php:20
721
+ msgid "Try GitHub Version"
722
+ msgstr ""
723
+
724
+ #: admin/tpl/debug_log.php:26 admin/tpl/inc/banner_promo.new_version.php:68
725
+ msgid "Upgrade"
726
+ msgstr ""
727
+
728
+ #: admin/tpl/debug_log.php:42
729
  msgid "Clear Log"
730
  msgstr ""
731
 
860
  msgid "Rate %s on %s"
861
  msgstr ""
862
 
863
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.9.5) #-#-#-#-#
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
892
  msgid "New release %s is available now."
893
  msgstr ""
894
 
 
 
 
 
895
  #: admin/tpl/inc/banner_promo.new_version.php:78
896
  msgid "Turn On Auto Upgrade"
897
  msgstr ""
2851
  msgstr ""
2852
 
2853
  #: admin/tpl/setting/settings_inc.cache_mobile.php:14
2854
+ msgid "Cache mobile views separately."
2855
  msgstr ""
2856
 
2857
  #: admin/tpl/setting/settings_inc.cache_mobile.php:15
2858
+ msgid ""
2859
+ "Only enable for AMP or mobile-specific design/content, not for responsive "
2860
+ "sites."
2861
  msgstr ""
2862
 
2863
  #: admin/tpl/setting/settings_inc.cache_mobile.php:25
4153
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4154
  msgstr ""
4155
 
4156
+ #: inc/img_optm.class.php:167 inc/img_optm.class.php:1464
4157
+ #: inc/img_optm.class.php:1529
4158
  msgid "No image found."
4159
  msgstr ""
4160
 
4185
  "automated."
4186
  msgstr ""
4187
 
4188
+ #: inc/img_optm.class.php:1353
4189
  msgid "Destroy unfinished data successfully."
4190
  msgstr ""
4191
 
4192
+ #: inc/img_optm.class.php:1567
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:1743
4199
  msgid "Removed %1$s images and saved %2$s successfully."
4200
  msgstr ""
4201
 
4202
+ #: inc/img_optm.class.php:1938
4203
  msgid "Switched images successfully."
4204
  msgstr ""
4205
 
4206
+ #: inc/img_optm.class.php:1969
4207
  msgid "Disabled WebP file successfully."
4208
  msgstr ""
4209
 
4210
+ #: inc/img_optm.class.php:1975
4211
  msgid "Enabled WebP file successfully."
4212
  msgstr ""
4213
 
4214
+ #: inc/img_optm.class.php:1991
4215
  msgid "Restored original file successfully."
4216
  msgstr ""
4217
 
4218
+ #: inc/img_optm.class.php:1998
4219
  msgid "Switched to optimized file successfully."
4220
  msgstr ""
4221
 
4222
+ #: inc/img_optm.class.php:2058
4223
  msgid "Reset the optimized data successfully."
4224
  msgstr ""
4225
 
4347
  msgid "LiteSpeed Cache Custom Cron Crawler"
4348
  msgstr ""
4349
 
4350
+ #: inc/utility.class.php:235 includes/litespeed-cache-utility.class.php:235
4351
  msgid "just now"
4352
  msgstr ""
4353
 
4354
+ #: inc/utility.class.php:235 includes/litespeed-cache-utility.class.php:235
4355
  msgid "right now"
4356
  msgstr ""
4357
 
4358
+ #: inc/utility.class.php:238 includes/litespeed-cache-utility.class.php:238
4359
  msgid " %s ago"
4360
  msgstr ""
4361
 
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.4.1
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.5
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
6
- Stable tag: 2.9.4.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -279,10 +279,24 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
279
  * [BoomBox — Viral Magazine WordPress Theme](https://themeforest.net/item/boombox-viral-buzz-wordpress-theme/16596434?ref=PX-lab)
280
  * Beaver Builder
281
  * FacetWP (LSWS 5.3.6+)
 
282
 
283
 
284
  == Changelog ==
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  = 2.9.4.1 - Feb 28 2019 =
287
  * 🔥🐞<strong>Tag</strong>: Fixed issue where unnecessary warning potentially displayed after upgrade process when object cache is enabled.
288
 
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.5
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
279
  * [BoomBox — Viral Magazine WordPress Theme](https://themeforest.net/item/boombox-viral-buzz-wordpress-theme/16596434?ref=PX-lab)
280
  * Beaver Builder
281
  * FacetWP (LSWS 5.3.6+)
282
+ * WpDiscuz
283
 
284
 
285
  == Changelog ==
286
 
287
+ = 2.9.5 - Mar 14 2019 =
288
+ * 🌱 Auto convert default WordPress nonce to ESI to avoid expiration.
289
+ * 🌱 <strong>API</strong>: Ability to easily convert custom nonce to ESI by registering `LiteSpeed_Cache_API::nonce_action`.
290
+ * <strong>OPTM</strong>: Tweaked redundant attr `data-no-optimize` in func `_analyse_links` to `data-ignore-optimize` to offer the API to bypass optimization but still move src to top of source code.
291
+ * <strong>API</strong>: Renamed default nonce ESI ID from `lscwp_nonce_esi` to `nonce`.
292
+ * <strong>API</strong>: Added WebP generation & validation hook API. (@alim #wp-stateless)
293
+ * <strong>API</strong>: Added hook to bypass vary commenter check. (#wpdiscuz)
294
+ * <strong>Doc</strong>: Clarified Cache Mobile description. (@JohnnyNguyen)
295
+ * <strong>Doc</strong>: Replaced incorrect link in description. (@JohnnyNguyen)
296
+ * <strong>3rd</strong>: Improved wpDiscuz compatibility.
297
+ * 🐞<strong>3rd</strong>: Fixed Divi Theme Builder comment compatibility on non-builder pages. (#410919)
298
+ * <strong>3rd</strong>: Added YITH ESI adjustment.
299
+
300
  = 2.9.4.1 - Feb 28 2019 =
301
  * 🔥🐞<strong>Tag</strong>: Fixed issue where unnecessary warning potentially displayed after upgrade process when object cache is enabled.
302
 
thirdparty/lscwp-3rd-divi-theme-builder.cls.php CHANGED
@@ -19,6 +19,7 @@ class LiteSpeed_Cache_ThirdParty_Divi_Theme_Builder
19
  public static function detect()
20
  {
21
  if ( ! defined( 'ET_CORE' ) ) return ;
 
22
 
23
  add_action( 'et_fb_before_comments_template', 'LiteSpeed_Cache_ThirdParty_Divi_Theme_Builder::js_comment_box_on' ) ;
24
  add_action( 'et_fb_after_comments_template', 'LiteSpeed_Cache_ThirdParty_Divi_Theme_Builder::js_comment_box_off' ) ;
19
  public static function detect()
20
  {
21
  if ( ! defined( 'ET_CORE' ) ) return ;
22
+ if ( empty( $_GET['et_fb'] ) ) return ;
23
 
24
  add_action( 'et_fb_before_comments_template', 'LiteSpeed_Cache_ThirdParty_Divi_Theme_Builder::js_comment_box_on' ) ;
25
  add_action( 'et_fb_after_comments_template', 'LiteSpeed_Cache_ThirdParty_Divi_Theme_Builder::js_comment_box_off' ) ;
thirdparty/lscwp-3rd-wpdiscuz.cls.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The Third Party integration with Wpdiscuz.
4
+ *
5
+ * @since 2.9.5
6
+ * @package LiteSpeed_Cache
7
+ * @subpackage LiteSpeed_Cache/thirdparty
8
+ * @author LiteSpeed Technologies <info@litespeedtech.com>
9
+ */
10
+ if ( ! defined('ABSPATH') ) {
11
+ die() ;
12
+ }
13
+
14
+ LiteSpeed_Cache_API::register( 'LiteSpeed_Cache_ThirdParty_Wpdiscuz' ) ;
15
+
16
+ class LiteSpeed_Cache_ThirdParty_Wpdiscuz
17
+ {
18
+ public static function detect()
19
+ {
20
+ if ( ! defined( 'WPDISCUZ_DS' ) ) return ;
21
+
22
+ LiteSpeed_Cache_ThirdParty_Wpdiscuz::check_commenter() ;
23
+ add_action( 'wpdiscuz_add_comment', 'LiteSpeed_Cache_ThirdParty_Wpdiscuz::add_comment' ) ;
24
+
25
+ }
26
+
27
+ public static function add_comment()
28
+ {
29
+ LiteSpeed_Cache_Vary::get_instance()->append_commenter() ;
30
+ }
31
+
32
+ public static function check_commenter()
33
+ {
34
+ $commentor = wp_get_current_commenter() ;
35
+
36
+ if ( strlen( $commentor[ 'comment_author' ] ) > 0 ) {
37
+ add_filter( 'litespeed_vary_check_commenter_pending', '__return_false' ) ;
38
+ }
39
+ }
40
+ }
thirdparty/lscwp-3rd-wpml.cls.php CHANGED
File without changes
thirdparty/lscwp-3rd-yith-wishlist.cls.php CHANGED
@@ -86,8 +86,7 @@ class LiteSpeed_Cache_ThirdParty_Yith_Wishlist
86
  $params = array(
87
  self::ESI_PARAM_POSTID => $post->ID
88
  ) ;
89
- echo LiteSpeed_Cache_API::esi_url( 'yith-wcwl-add', 'YITH ADD TO WISHLIST', $params ) ;
90
- return '' ;
91
  }
92
 
93
  /**
86
  $params = array(
87
  self::ESI_PARAM_POSTID => $post->ID
88
  ) ;
89
+ return LiteSpeed_Cache_API::esi_url( 'yith-wcwl-add', 'YITH ADD TO WISHLIST', $params ) ;
 
90
  }
91
 
92
  /**
thirdparty/lscwp-registry-3rd.php CHANGED
@@ -32,6 +32,7 @@ $thirdparty_list = array(
32
  'wp-postratings',
33
  'divi-theme-builder',
34
  'wpml',
 
35
  ) ;
36
 
37
  foreach ($thirdparty_list as $val) {
32
  'wp-postratings',
33
  'divi-theme-builder',
34
  'wpml',
35
+ 'wpdiscuz',
36
  ) ;
37
 
38
  foreach ($thirdparty_list as $val) {