LiteSpeed Cache - Version 2.6

Version Description

  • Sep 22 2018 =
  • Vary: Moved litespeed_cache_api_vary hook outside of OLS condition for .htaccess generation.
  • CDN: Trim spaces in original URL of CDN setting.
  • API: New filter litespeed_option_ to change all options dynamically.
  • API: New LiteSpeed_Cache_API::force_option() to change all options dynamically.
  • API: New LiteSpeed_Cache_API::vary() to set default vary directly for easier compaitiblity with WPML WooCommerce Multilingual.
  • API: New LiteSpeed_Cache_API::nonce() to safely and easily allow caching of wp-nonce.
  • API: New LiteSpeed_Cache_API::hook_vary_add() to add new vary.
  • Optm: Changed HTML/JS/CSS optimization options assignment position from constructor to finalize().
  • Doc: Added nonce to FAQ and mentioned nonce in 3rd Party Compatibility section.
  • GUI: Moved inline minify to under html minify due to the dependency.
  • 3rd: Cached Aelia CurrencySwitcher by default.
  • : Fixed issue where enabling remote JQuery caused missing jquery-migrate library error.
Download this release

Release Info

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

Code changes from version 2.5.1 to 2.6

admin/litespeed-cache-admin-rules.class.php CHANGED
@@ -623,6 +623,8 @@ class LiteSpeed_Cache_Admin_Rules
623
 
624
  // check login cookie
625
  $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
 
 
626
  if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
627
  if ( ! empty( $cfg[ $id ] ) ) {
628
  $cfg[ $id ] .= ',wp-postpass_' . COOKIEHASH ;
@@ -630,11 +632,16 @@ class LiteSpeed_Cache_Admin_Rules
630
  else {
631
  $cfg[ $id ] = 'wp-postpass_' . COOKIEHASH ;
632
  }
 
633
 
634
- $tp_cookies = apply_filters( 'litespeed_cache_api_vary', array() ) ;
635
- if ( ! empty( $tp_cookies ) && is_array( $tp_cookies ) ) {
 
636
  $cfg[ $id ] .= ',' . implode( ',', $tp_cookies ) ;
637
  }
 
 
 
638
  }
639
  // frontend and backend
640
  if ( ! empty( $cfg[ $id ] ) ) {
623
 
624
  // check login cookie
625
  $id = LiteSpeed_Cache_Config::OPID_LOGIN_COOKIE ;
626
+
627
+ // Need to keep this due to different behavior of OLS when handling response vary header @Sep/22/2018
628
  if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
629
  if ( ! empty( $cfg[ $id ] ) ) {
630
  $cfg[ $id ] .= ',wp-postpass_' . COOKIEHASH ;
632
  else {
633
  $cfg[ $id ] = 'wp-postpass_' . COOKIEHASH ;
634
  }
635
+ }
636
 
637
+ $tp_cookies = apply_filters( 'litespeed_cache_api_vary', array() ) ;
638
+ if ( ! empty( $tp_cookies ) && is_array( $tp_cookies ) ) {
639
+ if ( ! empty( $cfg[ $id ] ) ) {
640
  $cfg[ $id ] .= ',' . implode( ',', $tp_cookies ) ;
641
  }
642
+ else {
643
+ $cfg[ $id ] = implode( ',', $tp_cookies ) ;
644
+ }
645
  }
646
  // frontend and backend
647
  if ( ! empty( $cfg[ $id ] ) ) {
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -573,8 +573,9 @@ class LiteSpeed_Cache_Admin_Settings
573
  foreach ( $ori_list as $k => $v ) {
574
  $tmp = parse_url( $v ) ;
575
  if ( ! empty( $tmp[ 'scheme' ] ) ) {
576
- $ori_list[ $k ] = str_replace( $tmp[ 'scheme' ] . ':', '', $v ) ;
577
  }
 
578
  }
579
  $this->_options[ $id ] = implode( ',', $ori_list ) ;
580
  }
573
  foreach ( $ori_list as $k => $v ) {
574
  $tmp = parse_url( $v ) ;
575
  if ( ! empty( $tmp[ 'scheme' ] ) ) {
576
+ $v = str_replace( $tmp[ 'scheme' ] . ':', '', $v ) ;
577
  }
578
+ $ori_list[ $k ] = trim( $v ) ;
579
  }
580
  $this->_options[ $id ] = implode( ',', $ori_list ) ;
581
  }
admin/tpl/setting/settings_optimize.php CHANGED
@@ -34,16 +34,6 @@ $last_critical_css_generated = LiteSpeed_Cache_CSS::get_summary() ;
34
  </td>
35
  </tr>
36
 
37
- <tr>
38
- <th><?php echo __( 'Inline CSS Minify', 'litespeed-cache' ) ; ?></th>
39
- <td>
40
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_INLINE_MINIFY ) ; ?>
41
- <div class="litespeed-desc">
42
- <?php echo __( 'Minify inline CSS code.', 'litespeed-cache' ) ; ?>
43
- </div>
44
- </td>
45
- </tr>
46
-
47
  <tr>
48
  <th><?php echo __( 'CSS Combine', 'litespeed-cache' ) ; ?></th>
49
  <td>
@@ -75,16 +65,6 @@ $last_critical_css_generated = LiteSpeed_Cache_CSS::get_summary() ;
75
  </td>
76
  </tr>
77
 
78
- <tr>
79
- <th><?php echo __( 'Inline JS Minify', 'litespeed-cache' ) ; ?></th>
80
- <td>
81
- <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_INLINE_MINIFY ) ; ?>
82
- <div class="litespeed-desc">
83
- <?php echo __( 'Minify inline JS code.', 'litespeed-cache' ) ; ?>
84
- </div>
85
- </td>
86
- </tr>
87
-
88
  <tr>
89
  <th><?php echo __( 'JS Combine', 'litespeed-cache' ) ; ?></th>
90
  <td>
@@ -128,6 +108,26 @@ $last_critical_css_generated = LiteSpeed_Cache_CSS::get_summary() ;
128
  </td>
129
  </tr>
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  <tr>
132
  <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
133
  <td>
34
  </td>
35
  </tr>
36
 
 
 
 
 
 
 
 
 
 
 
37
  <tr>
38
  <th><?php echo __( 'CSS Combine', 'litespeed-cache' ) ; ?></th>
39
  <td>
65
  </td>
66
  </tr>
67
 
 
 
 
 
 
 
 
 
 
 
68
  <tr>
69
  <th><?php echo __( 'JS Combine', 'litespeed-cache' ) ; ?></th>
70
  <td>
108
  </td>
109
  </tr>
110
 
111
+ <tr>
112
+ <th class="litespeed-padding-left"><?php echo __( 'Inline CSS Minify', 'litespeed-cache' ) ; ?></th>
113
+ <td>
114
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_CSS_INLINE_MINIFY ) ; ?>
115
+ <div class="litespeed-desc">
116
+ <?php echo __( 'Minify inline CSS code.', 'litespeed-cache' ) ; ?>
117
+ </div>
118
+ </td>
119
+ </tr>
120
+
121
+ <tr>
122
+ <th class="litespeed-padding-left"><?php echo __( 'Inline JS Minify', 'litespeed-cache' ) ; ?></th>
123
+ <td>
124
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_JS_INLINE_MINIFY ) ; ?>
125
+ <div class="litespeed-desc">
126
+ <?php echo __( 'Minify inline JS code.', 'litespeed-cache' ) ; ?>
127
+ </div>
128
+ </td>
129
+ </tr>
130
+
131
  <tr>
132
  <th><?php echo __( 'Load CSS Asynchronously', 'litespeed-cache' ) ; ?></th>
133
  <td>
inc/api.class.php CHANGED
@@ -37,6 +37,18 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
37
  const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
  const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * Start a to-be-removed html wrapper
42
  *
@@ -203,7 +215,7 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
203
  }
204
 
205
  /**
206
- * Add vary
207
  *
208
  * @since 1.1.3
209
  * @access public
@@ -213,6 +225,33 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
213
  LiteSpeed_Cache_Vary::add($vary) ;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Purge all action
218
  *
@@ -343,6 +382,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
343
  add_filter( 'litespeed_vary', $hook ) ;
344
  }
345
 
 
 
 
 
 
 
 
 
 
 
 
346
  /**
347
  * Hook purge tags appending to purge
348
  *
@@ -449,12 +499,28 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
449
  * @access public
450
  * @param string $control Cache control tag
451
  */
452
- public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false )
453
  {
454
  if ( $control === 'default' ) {
455
  $control = 'private,no-vary' ;
456
  }
457
- return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  }
459
 
460
  /**
37
  const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
  const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
 
40
+ /**
41
+ * Force to set an option
42
+ * Note: it will only affect the AFTER usage of that option
43
+ *
44
+ * @since 2.6
45
+ * @access public
46
+ */
47
+ public static function force_option( $k, $v )
48
+ {
49
+ LiteSpeed_Cache_Config::get_instance()->force_option( $k, $v ) ;
50
+ }
51
+
52
  /**
53
  * Start a to-be-removed html wrapper
54
  *
215
  }
216
 
217
  /**
218
+ * Add a new vary cookie
219
  *
220
  * @since 1.1.3
221
  * @access public
225
  LiteSpeed_Cache_Vary::add($vary) ;
226
  }
227
 
228
+ /**
229
+ * Alter default vary cookie value
230
+ *
231
+ * Default vary cookie is an array before finalization, after that it will be combined to a string and store as default vary cookie name
232
+ *
233
+ * @since 2.6
234
+ * @access public
235
+ */
236
+ public static function vary( $k, $v, $default = null )
237
+ {
238
+ if ( $v === $default ) {
239
+ return ;
240
+ }
241
+ LiteSpeed_Cache_Vary::append( $k, $v ) ;
242
+ }
243
+
244
+ /**
245
+ * Force finalize vary even if its in an AJAX call
246
+ *
247
+ * @since 2.6
248
+ * @access public
249
+ */
250
+ public static function force_vary()
251
+ {
252
+ LiteSpeed_Cache_Vary::can_ajax_vary() ;
253
+ }
254
+
255
  /**
256
  * Purge all action
257
  *
382
  add_filter( 'litespeed_vary', $hook ) ;
383
  }
384
 
385
+ /**
386
+ * Hook new vary cookies to vary finialization
387
+ *
388
+ * @since 2.6
389
+ * @access public
390
+ */
391
+ public static function hook_vary_add( $hook )
392
+ {
393
+ add_action( 'litespeed_vary_add', $hook ) ;
394
+ }
395
+
396
  /**
397
  * Hook purge tags appending to purge
398
  *
499
  * @access public
500
  * @param string $control Cache control tag
501
  */
502
+ public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false, $preserved = false, $svar = false, $inline_val = false )
503
  {
504
  if ( $control === 'default' ) {
505
  $control = 'private,no-vary' ;
506
  }
507
+ return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence, $preserved, $svar, $inline_val ) ;
508
+ }
509
+
510
+ /**
511
+ * Easiest way to replace WP nonce to an ESI widget
512
+ *
513
+ * @since 2.6
514
+ * @access public
515
+ */
516
+ public static function nonce( $action = -1, $defence_for_html_filter = true )
517
+ {
518
+ if ( ! self::esi_enabled() ) {
519
+ return wp_create_nonce( $action ) ;
520
+ }
521
+
522
+ // Replace it to ESI
523
+ return self::esi_url( 'lscwp_nonce_esi', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
524
  }
525
 
526
  /**
inc/cdn.class.php CHANGED
@@ -575,17 +575,17 @@ class LiteSpeed_Cache_CDN
575
 
576
  // load wp's jq version
577
  global $wp_scripts ;
578
- if ( isset( $wp_scripts->registered[ 'jquery' ]->ver ) ) {
579
- $v = $wp_scripts->registered[ 'jquery' ]->ver ;
580
  }
581
 
582
  $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" ;
583
 
584
  LiteSpeed_Cache_Log::debug2( '[CDN] load_jquery_remotely: ' . $src ) ;
585
 
586
- wp_deregister_script( 'jquery' ) ;
587
 
588
- wp_register_script( 'jquery', $src, false, $v ) ;
589
  }
590
 
591
  /**
575
 
576
  // load wp's jq version
577
  global $wp_scripts ;
578
+ if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
579
+ $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
580
  }
581
 
582
  $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" ;
583
 
584
  LiteSpeed_Cache_Log::debug2( '[CDN] load_jquery_remotely: ' . $src ) ;
585
 
586
+ wp_deregister_script( 'jquery-core' ) ;
587
 
588
+ wp_register_script( 'jquery-core', $src, false, $v ) ;
589
  }
590
 
591
  /**
inc/config.class.php CHANGED
@@ -67,6 +67,42 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
67
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
67
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
68
  }
69
 
70
+ // Hook to options
71
+ add_action( 'litespeed_init', array( $this, 'hook_options' ) ) ;
72
+
73
+ }
74
+
75
+ /**
76
+ * Give an API to change all options val
77
+ * All hooks need to be added before `after_setup_theme`
78
+ *
79
+ * @since 2.6
80
+ * @access public
81
+ */
82
+ public function hook_options()
83
+ {
84
+ foreach ( $this->options as $k => $v ) {
85
+ $new_v = apply_filters( "litespeed_option_$k", $v ) ;
86
+
87
+ if ( $new_v !== $v ) {
88
+ LiteSpeed_Cache_Log::debug( "[Conf] ** $k changed by hook [litespeed_option_$k] from " . var_export( $v, true ) . ' to ' . var_export( $new_v, true ) ) ;
89
+ $this->options[ $k ] = $new_v ;
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Force an option to a certain value
96
+ *
97
+ * @since 2.6
98
+ * @access public
99
+ */
100
+ public function force_option( $k, $v )
101
+ {
102
+ if ( array_key_exists( $k, $this->options ) ) {
103
+ LiteSpeed_Cache_Log::debug( "[Conf] ** $k forced value to " . var_export( $v, true ) ) ;
104
+ $this->options[ $k ] = $v ;
105
+ }
106
  }
107
 
108
  /**
inc/esi.class.php CHANGED
@@ -21,6 +21,7 @@ class LiteSpeed_Cache_ESI
21
 
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
 
24
 
25
  const QS_ACTION = 'lsesi' ;
26
  const POSTTYPE = 'lswcp' ;
@@ -47,6 +48,9 @@ class LiteSpeed_Cache_ESI
47
  add_action( 'load-widgets.php', 'LiteSpeed_Cache_Purge::purge_widget' ) ;
48
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
49
 
 
 
 
50
  /**
51
  * Recover REQUEST_URI
52
  * @since 1.8.1
@@ -118,6 +122,8 @@ class LiteSpeed_Cache_ESI
118
  add_action('litespeed_cache_load_esi_block-widget', array($this, 'load_widget_block')) ;
119
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
120
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
 
 
121
  }
122
 
123
  /**
@@ -162,9 +168,12 @@ class LiteSpeed_Cache_ESI
162
  * @param array $params The esi parameters.
163
  * @param string $control The cache control attribute if any.
164
  * @param bool $silence If generate wrapper comment or not
165
- * @return bool|string False on error, the output otherwise.
 
 
 
166
  */
167
- public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false )
168
  {
169
  if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
170
  return false ;
@@ -194,6 +203,9 @@ class LiteSpeed_Cache_ESI
194
  if ( ! empty( $control ) ) {
195
  $output .= " cache-control='$control'" ;
196
  }
 
 
 
197
  $output .= " />" ;
198
 
199
  if ( ! $silence ) {
@@ -201,8 +213,20 @@ class LiteSpeed_Cache_ESI
201
  }
202
 
203
  LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
 
204
 
205
  self::set_has_esi() ;
 
 
 
 
 
 
 
 
 
 
 
206
  return $output ;
207
  }
208
 
@@ -488,6 +512,28 @@ class LiteSpeed_Cache_ESI
488
  }
489
  }
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  /**
492
  * Hooked to the comment_form_defaults filter.
493
  * Stores the default comment form settings.
@@ -568,6 +614,30 @@ class LiteSpeed_Cache_ESI
568
  echo LiteSpeed_Cache_GUI::clean_wrapper_end() ;
569
  }
570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  /**
572
  * Get the current instance object.
573
  *
21
 
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 POSTTYPE = 'lswcp' ;
48
  add_action( 'load-widgets.php', 'LiteSpeed_Cache_Purge::purge_widget' ) ;
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 ) ;
53
+
54
  /**
55
  * Recover REQUEST_URI
56
  * @since 1.8.1
122
  add_action('litespeed_cache_load_esi_block-widget', array($this, 'load_widget_block')) ;
123
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
124
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
125
+
126
+ add_action('litespeed_cache_load_esi_block-lscwp_nonce_esi', array( $this, 'load_nonce_block' ) ) ;
127
  }
128
 
129
  /**
168
  * @param array $params The esi parameters.
169
  * @param string $control The cache control attribute if any.
170
  * @param bool $silence If generate wrapper comment or not
171
+ * @param bool $preserved If this ESI block is used in any filter, need to temporarily convert it to a string to avoid the HTML tag being removed/filtered.
172
+ * @param bool $svar If store the value in memory or not, in memory wil be faster
173
+ * @param bool $inline_val If show the current value for current request( this can avoid multiple esi requests in first time cache generating process ) -- Not used yet
174
+ * @return bool|string False on error, the output otherwise.
175
  */
176
+ public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_val = false )
177
  {
178
  if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
179
  return false ;
203
  if ( ! empty( $control ) ) {
204
  $output .= " cache-control='$control'" ;
205
  }
206
+ if ( $svar ) {
207
+ $output .= " as-var='1'" ;
208
+ }
209
  $output .= " />" ;
210
 
211
  if ( ! $silence ) {
213
  }
214
 
215
  LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
216
+ LiteSpeed_Cache_Log::debug2( $output ) ;
217
 
218
  self::set_has_esi() ;
219
+
220
+ // Convert to string to avoid html chars filter when using
221
+ // Will reverse the buffer when output in self::finalize()
222
+ if ( $preserved ) {
223
+ $hash = md5( $output ) ;
224
+ self::get_instance()->_esi_preserve_list[ $hash ] = $output ;
225
+ LiteSpeed_Cache_Log::debug( "[ESI] Preserved to $hash" ) ;
226
+
227
+ return $hash ;
228
+ }
229
+
230
  return $output ;
231
  }
232
 
512
  }
513
  }
514
 
515
+ /**
516
+ * Generate nonce for certain action
517
+ *
518
+ * @access public
519
+ * @since 2.6
520
+ */
521
+ public function load_nonce_block( $params )
522
+ {
523
+ $action = $params[ 'action' ] ;
524
+
525
+ LiteSpeed_Cache_Log::debug( '[ESI] load_nonce_block [action] ' . $action ) ;
526
+
527
+ // set nonce TTL to half day
528
+ LiteSpeed_Cache_Control::set_custom_ttl( 43200 ) ;
529
+
530
+ if ( LiteSpeed_Cache_Router::is_logged_in() ) {
531
+ LiteSpeed_Cache_Control::set_private() ;
532
+ }
533
+
534
+ echo wp_create_nonce( $action ) ;
535
+ }
536
+
537
  /**
538
  * Hooked to the comment_form_defaults filter.
539
  * Stores the default comment form settings.
614
  echo LiteSpeed_Cache_GUI::clean_wrapper_end() ;
615
  }
616
 
617
+ /**
618
+ * Replace preseved blocks
619
+ *
620
+ * @since 2.6
621
+ * @access public
622
+ */
623
+ public static function finalize( $buffer )
624
+ {
625
+ $instance = self::get_instance() ;
626
+
627
+ // Bypass if no preserved list to be replaced
628
+ if ( ! $instance->_esi_preserve_list ) {
629
+ return $buffer ;
630
+ }
631
+
632
+ $keys = array_keys( $instance->_esi_preserve_list ) ;
633
+
634
+ LiteSpeed_Cache_Log::debug( '[ESI] replacing preserved blocks', $keys ) ;
635
+
636
+ $buffer = str_replace( $keys , $instance->_esi_preserve_list, $buffer ) ;
637
+
638
+ return $buffer ;
639
+ }
640
+
641
  /**
642
  * Get the current instance object.
643
  *
inc/litespeed-cache.class.php CHANGED
@@ -25,7 +25,7 @@ class LiteSpeed_Cache
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
- const PLUGIN_VERSION = '2.5.1' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
@@ -152,6 +152,7 @@ class LiteSpeed_Cache
152
  /**
153
  * Added hook before init
154
  * @since 1.6.6
 
155
  */
156
  do_action( 'litespeed_init' ) ;
157
 
@@ -468,6 +469,9 @@ class LiteSpeed_Cache
468
  {
469
  $this->_check_is_html( $buffer ) ;
470
 
 
 
 
471
  // Image lazy load check
472
  $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
473
 
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
+ const PLUGIN_VERSION = '2.6' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
152
  /**
153
  * Added hook before init
154
  * @since 1.6.6
155
+ * @since 2.6 Added filter to all config values in LiteSpeed_Cache_Config
156
  */
157
  do_action( 'litespeed_init' ) ;
158
 
469
  {
470
  $this->_check_is_html( $buffer ) ;
471
 
472
+ // Replace ESI preserved list
473
+ $buffer = LiteSpeed_Cache_ESI::finalize( $buffer ) ;
474
+
475
  // Image lazy load check
476
  $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
477
 
inc/optimize.class.php CHANGED
@@ -30,7 +30,6 @@ class LiteSpeed_Cache_Optimize
30
  private $cfg_css_combine ;
31
  private $cfg_js_minify ;
32
  private $cfg_js_combine ;
33
- private $cfg_html_minify ;
34
  private $cfg_css_async ;
35
  private $cfg_js_defer ;
36
  private $cfg_js_defer_exc = false ;
@@ -61,20 +60,9 @@ class LiteSpeed_Cache_Optimize
61
  */
62
  private function __construct()
63
  {
64
- $this->cfg_http2_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ;
65
- $this->cfg_http2_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ;
66
- $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
67
- $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
68
- $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
69
- $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
70
- $this->cfg_html_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ;
71
  $this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
72
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
73
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
74
- $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
75
- $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
76
- $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
77
- $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
78
 
79
  $this->_static_request_check() ;
80
 
@@ -167,8 +155,14 @@ class LiteSpeed_Cache_Optimize
167
  */
168
  private function _static_request_check()
169
  {
 
 
 
 
 
 
170
  // This request is for js/css_async.js
171
- if ( ( $this->cfg_css_async || $this->cfg_ggfonts_async ) && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
172
  LiteSpeed_Cache_Log::debug( '[Optm] start serving static file' ) ;
173
 
174
  $content = Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) ;
@@ -355,6 +349,17 @@ class LiteSpeed_Cache_Optimize
355
  */
356
  private function _optimize()
357
  {
 
 
 
 
 
 
 
 
 
 
 
358
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
359
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
360
  return ;
@@ -627,7 +632,7 @@ class LiteSpeed_Cache_Optimize
627
  }
628
 
629
  // HTML minify
630
- if ( $this->cfg_html_minify ) {
631
  $this->content = LiteSpeed_Cache_Optimizer::get_instance()->html_min( $this->content ) ;
632
  }
633
 
30
  private $cfg_css_combine ;
31
  private $cfg_js_minify ;
32
  private $cfg_js_combine ;
 
33
  private $cfg_css_async ;
34
  private $cfg_js_defer ;
35
  private $cfg_js_defer_exc = false ;
60
  */
61
  private function __construct()
62
  {
 
 
 
 
 
 
 
63
  $this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
64
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
65
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
 
 
 
 
66
 
67
  $this->_static_request_check() ;
68
 
155
  */
156
  private function _static_request_check()
157
  {
158
+ $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
159
+ $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
160
+ $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
161
+ $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
162
+ $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
163
+
164
  // This request is for js/css_async.js
165
+ if ( strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
166
  LiteSpeed_Cache_Log::debug( '[Optm] start serving static file' ) ;
167
 
168
  $content = Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) ;
349
  */
350
  private function _optimize()
351
  {
352
+ $this->cfg_http2_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ;
353
+ $this->cfg_http2_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ;
354
+ $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
355
+ $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
356
+ $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
357
+ $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
358
+ $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
359
+ $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
360
+ $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
361
+ $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
362
+
363
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
364
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
365
  return ;
632
  }
633
 
634
  // HTML minify
635
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ) {
636
  $this->content = LiteSpeed_Cache_Optimizer::get_instance()->html_min( $this->content ) ;
637
  }
638
 
inc/vary.class.php CHANGED
@@ -18,6 +18,7 @@ class LiteSpeed_Cache_Vary
18
 
19
  private static $_vary_name = '_lscache_vary' ; // this default vary cookie is used for logged in status check
20
  private static $_vary_cookies = array() ; // vary header only!
 
21
 
22
  /**
23
  * Adds the actions used for setting up cookies on log in/out.
@@ -205,7 +206,7 @@ class LiteSpeed_Cache_Vary
205
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
206
  * @since 2.2.2
207
  */
208
- $this->can_ajax_vary() ;
209
 
210
  // If the cookie is lost somehow, set it
211
  $this->_update_default_vary( $uid, $expire ) ;
@@ -226,7 +227,7 @@ class LiteSpeed_Cache_Vary
226
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
227
  * @since 2.2.2
228
  */
229
- $this->can_ajax_vary() ;
230
 
231
  // Force update vary to remove login status
232
  $this->_update_default_vary( -1 ) ;
@@ -236,9 +237,10 @@ class LiteSpeed_Cache_Vary
236
  * Allow vary can be changed for ajax calls
237
  *
238
  * @since 2.2.2
 
239
  * @access public
240
  */
241
- public function can_ajax_vary()
242
  {
243
  LiteSpeed_Cache_Log::debug( '[Vary] litespeed_ajax_vary -> true' ) ;
244
  add_filter( 'litespeed_ajax_vary', '__return_true' ) ;
@@ -336,7 +338,7 @@ class LiteSpeed_Cache_Vary
336
  */
337
  public function finalize_default_vary( $uid = false )
338
  {
339
- $vary = array() ;
340
 
341
  if ( ! $uid ) {
342
  $uid = LiteSpeed_Cache_Router::get_uid() ;
@@ -470,28 +472,6 @@ class LiteSpeed_Cache_Vary
470
  return $path ;
471
  }
472
 
473
- /**
474
- * Gets vary cookies that are already added for the current page.
475
- *
476
- * @since 1.0.13
477
- * @access private
478
- * @return array An array of all vary cookies currently added.
479
- */
480
- private function _format_vary_cookies()
481
- {
482
- if ( empty(self::$_vary_cookies) ) {
483
- return false ;
484
- }
485
- $cookies = array_filter(array_unique(self::$_vary_cookies)) ;
486
- if ( empty($cookies) ) {
487
- return false ;
488
- }
489
- foreach ($cookies as $key => $val) {
490
- $cookies[$key] = 'cookie=' . $val ;
491
- }
492
- return $cookies ;
493
- }
494
-
495
  /**
496
  * Builds the vary header.
497
  *
@@ -545,8 +525,34 @@ class LiteSpeed_Cache_Vary
545
 
546
  }
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  /**
549
  * Adds vary to the list of vary cookies for the current page.
 
550
  *
551
  * @since 1.0.13
552
  * @access public
@@ -558,9 +564,22 @@ class LiteSpeed_Cache_Vary
558
  $vary = array($vary) ;
559
  }
560
 
 
 
561
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
562
  }
563
 
 
 
 
 
 
 
 
 
 
 
 
564
  /**
565
  * Set the vary cookie.
566
  *
18
 
19
  private static $_vary_name = '_lscache_vary' ; // this default vary cookie is used for logged in status check
20
  private static $_vary_cookies = array() ; // vary header only!
21
+ private static $_default_vary_val = array() ;
22
 
23
  /**
24
  * Adds the actions used for setting up cookies on log in/out.
206
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
207
  * @since 2.2.2
208
  */
209
+ self::can_ajax_vary() ;
210
 
211
  // If the cookie is lost somehow, set it
212
  $this->_update_default_vary( $uid, $expire ) ;
227
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
228
  * @since 2.2.2
229
  */
230
+ self::can_ajax_vary() ;
231
 
232
  // Force update vary to remove login status
233
  $this->_update_default_vary( -1 ) ;
237
  * Allow vary can be changed for ajax calls
238
  *
239
  * @since 2.2.2
240
+ * @since 2.6 Changed to static
241
  * @access public
242
  */
243
+ public static function can_ajax_vary()
244
  {
245
  LiteSpeed_Cache_Log::debug( '[Vary] litespeed_ajax_vary -> true' ) ;
246
  add_filter( 'litespeed_ajax_vary', '__return_true' ) ;
338
  */
339
  public function finalize_default_vary( $uid = false )
340
  {
341
+ $vary = self::$_default_vary_val ;
342
 
343
  if ( ! $uid ) {
344
  $uid = LiteSpeed_Cache_Router::get_uid() ;
472
  return $path ;
473
  }
474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  /**
476
  * Builds the vary header.
477
  *
525
 
526
  }
527
 
528
+ /**
529
+ * Gets vary cookies that are already added for the current page.
530
+ *
531
+ * @since 1.0.13
532
+ * @access private
533
+ * @return array An array of all vary cookies currently added.
534
+ */
535
+ private function _format_vary_cookies()
536
+ {
537
+ // To add new varys, use hook `API::hook_vary_add()` before here
538
+ do_action( 'litespeed_vary_add' ) ;
539
+
540
+ if ( empty(self::$_vary_cookies) ) {
541
+ return false ;
542
+ }
543
+ $cookies = array_filter(array_unique(self::$_vary_cookies)) ;
544
+ if ( empty($cookies) ) {
545
+ return false ;
546
+ }
547
+ foreach ($cookies as $key => $val) {
548
+ $cookies[$key] = 'cookie=' . $val ;
549
+ }
550
+ return $cookies ;
551
+ }
552
+
553
  /**
554
  * Adds vary to the list of vary cookies for the current page.
555
+ * This is to add a new vary cookie
556
  *
557
  * @since 1.0.13
558
  * @access public
564
  $vary = array($vary) ;
565
  }
566
 
567
+ LiteSpeed_Cache_Log::debug( '[Vary] Add new vary ', $vary ) ;
568
+
569
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
570
  }
571
 
572
+ /**
573
+ * Append child value to default vary
574
+ *
575
+ * @since 2.6
576
+ * @access public
577
+ */
578
+ public static function append( $name, $val )
579
+ {
580
+ self::$_default_vary_val[ $name ] = $val ;
581
+ }
582
+
583
  /**
584
  * Set the vary cookie.
585
  *
includes/litespeed-cache-api.class.php CHANGED
@@ -37,6 +37,18 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
37
  const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
  const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  /**
41
  * Start a to-be-removed html wrapper
42
  *
@@ -203,7 +215,7 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
203
  }
204
 
205
  /**
206
- * Add vary
207
  *
208
  * @since 1.1.3
209
  * @access public
@@ -213,6 +225,33 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
213
  LiteSpeed_Cache_Vary::add($vary) ;
214
  }
215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
216
  /**
217
  * Purge all action
218
  *
@@ -343,6 +382,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
343
  add_filter( 'litespeed_vary', $hook ) ;
344
  }
345
 
 
 
 
 
 
 
 
 
 
 
 
346
  /**
347
  * Hook purge tags appending to purge
348
  *
@@ -449,12 +499,28 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
449
  * @access public
450
  * @param string $control Cache control tag
451
  */
452
- public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false )
453
  {
454
  if ( $control === 'default' ) {
455
  $control = 'private,no-vary' ;
456
  }
457
- return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
  }
459
 
460
  /**
37
  const WIDGET_OPID_ESIENABLE = LiteSpeed_Cache_ESI::WIDGET_OPID_ESIENABLE ;
38
  const WIDGET_OPID_TTL = LiteSpeed_Cache_ESI::WIDGET_OPID_TTL ;
39
 
40
+ /**
41
+ * Force to set an option
42
+ * Note: it will only affect the AFTER usage of that option
43
+ *
44
+ * @since 2.6
45
+ * @access public
46
+ */
47
+ public static function force_option( $k, $v )
48
+ {
49
+ LiteSpeed_Cache_Config::get_instance()->force_option( $k, $v ) ;
50
+ }
51
+
52
  /**
53
  * Start a to-be-removed html wrapper
54
  *
215
  }
216
 
217
  /**
218
+ * Add a new vary cookie
219
  *
220
  * @since 1.1.3
221
  * @access public
225
  LiteSpeed_Cache_Vary::add($vary) ;
226
  }
227
 
228
+ /**
229
+ * Alter default vary cookie value
230
+ *
231
+ * Default vary cookie is an array before finalization, after that it will be combined to a string and store as default vary cookie name
232
+ *
233
+ * @since 2.6
234
+ * @access public
235
+ */
236
+ public static function vary( $k, $v, $default = null )
237
+ {
238
+ if ( $v === $default ) {
239
+ return ;
240
+ }
241
+ LiteSpeed_Cache_Vary::append( $k, $v ) ;
242
+ }
243
+
244
+ /**
245
+ * Force finalize vary even if its in an AJAX call
246
+ *
247
+ * @since 2.6
248
+ * @access public
249
+ */
250
+ public static function force_vary()
251
+ {
252
+ LiteSpeed_Cache_Vary::can_ajax_vary() ;
253
+ }
254
+
255
  /**
256
  * Purge all action
257
  *
382
  add_filter( 'litespeed_vary', $hook ) ;
383
  }
384
 
385
+ /**
386
+ * Hook new vary cookies to vary finialization
387
+ *
388
+ * @since 2.6
389
+ * @access public
390
+ */
391
+ public static function hook_vary_add( $hook )
392
+ {
393
+ add_action( 'litespeed_vary_add', $hook ) ;
394
+ }
395
+
396
  /**
397
  * Hook purge tags appending to purge
398
  *
499
  * @access public
500
  * @param string $control Cache control tag
501
  */
502
+ public static function esi_url( $block_id, $wrapper, $params = array(), $control = 'default', $silence = false, $preserved = false, $svar = false, $inline_val = false )
503
  {
504
  if ( $control === 'default' ) {
505
  $control = 'private,no-vary' ;
506
  }
507
+ return LiteSpeed_Cache_ESI::sub_esi_block( $block_id, $wrapper, $params, $control, $silence, $preserved, $svar, $inline_val ) ;
508
+ }
509
+
510
+ /**
511
+ * Easiest way to replace WP nonce to an ESI widget
512
+ *
513
+ * @since 2.6
514
+ * @access public
515
+ */
516
+ public static function nonce( $action = -1, $defence_for_html_filter = true )
517
+ {
518
+ if ( ! self::esi_enabled() ) {
519
+ return wp_create_nonce( $action ) ;
520
+ }
521
+
522
+ // Replace it to ESI
523
+ return self::esi_url( 'lscwp_nonce_esi', 'LSCWP Nonce ESI ' . $action, array( 'action' => $action ), '', true, $defence_for_html_filter, true ) ;
524
  }
525
 
526
  /**
includes/litespeed-cache-cdn.class.php CHANGED
@@ -575,17 +575,17 @@ class LiteSpeed_Cache_CDN
575
 
576
  // load wp's jq version
577
  global $wp_scripts ;
578
- if ( isset( $wp_scripts->registered[ 'jquery' ]->ver ) ) {
579
- $v = $wp_scripts->registered[ 'jquery' ]->ver ;
580
  }
581
 
582
  $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" ;
583
 
584
  LiteSpeed_Cache_Log::debug2( '[CDN] load_jquery_remotely: ' . $src ) ;
585
 
586
- wp_deregister_script( 'jquery' ) ;
587
 
588
- wp_register_script( 'jquery', $src, false, $v ) ;
589
  }
590
 
591
  /**
575
 
576
  // load wp's jq version
577
  global $wp_scripts ;
578
+ if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
579
+ $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
580
  }
581
 
582
  $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" ;
583
 
584
  LiteSpeed_Cache_Log::debug2( '[CDN] load_jquery_remotely: ' . $src ) ;
585
 
586
+ wp_deregister_script( 'jquery-core' ) ;
587
 
588
+ wp_register_script( 'jquery-core', $src, false, $v ) ;
589
  }
590
 
591
  /**
includes/litespeed-cache-config.class.php CHANGED
@@ -67,6 +67,42 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
67
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
68
  }
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  /**
67
  $this->update_options( array( self::HASH => Litespeed_String::rrand( 32 ) ) ) ;
68
  }
69
 
70
+ // Hook to options
71
+ add_action( 'litespeed_init', array( $this, 'hook_options' ) ) ;
72
+
73
+ }
74
+
75
+ /**
76
+ * Give an API to change all options val
77
+ * All hooks need to be added before `after_setup_theme`
78
+ *
79
+ * @since 2.6
80
+ * @access public
81
+ */
82
+ public function hook_options()
83
+ {
84
+ foreach ( $this->options as $k => $v ) {
85
+ $new_v = apply_filters( "litespeed_option_$k", $v ) ;
86
+
87
+ if ( $new_v !== $v ) {
88
+ LiteSpeed_Cache_Log::debug( "[Conf] ** $k changed by hook [litespeed_option_$k] from " . var_export( $v, true ) . ' to ' . var_export( $new_v, true ) ) ;
89
+ $this->options[ $k ] = $new_v ;
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Force an option to a certain value
96
+ *
97
+ * @since 2.6
98
+ * @access public
99
+ */
100
+ public function force_option( $k, $v )
101
+ {
102
+ if ( array_key_exists( $k, $this->options ) ) {
103
+ LiteSpeed_Cache_Log::debug( "[Conf] ** $k forced value to " . var_export( $v, true ) ) ;
104
+ $this->options[ $k ] = $v ;
105
+ }
106
  }
107
 
108
  /**
includes/litespeed-cache-esi.class.php CHANGED
@@ -21,6 +21,7 @@ class LiteSpeed_Cache_ESI
21
 
22
  private static $has_esi = false ;
23
  private $esi_args = null ;
 
24
 
25
  const QS_ACTION = 'lsesi' ;
26
  const POSTTYPE = 'lswcp' ;
@@ -47,6 +48,9 @@ class LiteSpeed_Cache_ESI
47
  add_action( 'load-widgets.php', 'LiteSpeed_Cache_Purge::purge_widget' ) ;
48
  add_action( 'wp_update_comment_count', 'LiteSpeed_Cache_Purge::purge_comment_widget' ) ;
49
 
 
 
 
50
  /**
51
  * Recover REQUEST_URI
52
  * @since 1.8.1
@@ -118,6 +122,8 @@ class LiteSpeed_Cache_ESI
118
  add_action('litespeed_cache_load_esi_block-widget', array($this, 'load_widget_block')) ;
119
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
120
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
 
 
121
  }
122
 
123
  /**
@@ -162,9 +168,12 @@ class LiteSpeed_Cache_ESI
162
  * @param array $params The esi parameters.
163
  * @param string $control The cache control attribute if any.
164
  * @param bool $silence If generate wrapper comment or not
165
- * @return bool|string False on error, the output otherwise.
 
 
 
166
  */
167
- public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false )
168
  {
169
  if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
170
  return false ;
@@ -194,6 +203,9 @@ class LiteSpeed_Cache_ESI
194
  if ( ! empty( $control ) ) {
195
  $output .= " cache-control='$control'" ;
196
  }
 
 
 
197
  $output .= " />" ;
198
 
199
  if ( ! $silence ) {
@@ -201,8 +213,20 @@ class LiteSpeed_Cache_ESI
201
  }
202
 
203
  LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
 
204
 
205
  self::set_has_esi() ;
 
 
 
 
 
 
 
 
 
 
 
206
  return $output ;
207
  }
208
 
@@ -488,6 +512,28 @@ class LiteSpeed_Cache_ESI
488
  }
489
  }
490
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  /**
492
  * Hooked to the comment_form_defaults filter.
493
  * Stores the default comment form settings.
@@ -568,6 +614,30 @@ class LiteSpeed_Cache_ESI
568
  echo LiteSpeed_Cache_GUI::clean_wrapper_end() ;
569
  }
570
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
  /**
572
  * Get the current instance object.
573
  *
21
 
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 POSTTYPE = 'lswcp' ;
48
  add_action( 'load-widgets.php', 'LiteSpeed_Cache_Purge::purge_widget' ) ;
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 ) ;
53
+
54
  /**
55
  * Recover REQUEST_URI
56
  * @since 1.8.1
122
  add_action('litespeed_cache_load_esi_block-widget', array($this, 'load_widget_block')) ;
123
  add_action('litespeed_cache_load_esi_block-admin-bar', array($this, 'load_admin_bar_block')) ;
124
  add_action('litespeed_cache_load_esi_block-comment-form', array($this, 'load_comment_form_block')) ;
125
+
126
+ add_action('litespeed_cache_load_esi_block-lscwp_nonce_esi', array( $this, 'load_nonce_block' ) ) ;
127
  }
128
 
129
  /**
168
  * @param array $params The esi parameters.
169
  * @param string $control The cache control attribute if any.
170
  * @param bool $silence If generate wrapper comment or not
171
+ * @param bool $preserved If this ESI block is used in any filter, need to temporarily convert it to a string to avoid the HTML tag being removed/filtered.
172
+ * @param bool $svar If store the value in memory or not, in memory wil be faster
173
+ * @param bool $inline_val If show the current value for current request( this can avoid multiple esi requests in first time cache generating process ) -- Not used yet
174
+ * @return bool|string False on error, the output otherwise.
175
  */
176
+ public static function sub_esi_block( $block_id, $wrapper, $params = array(), $control = 'private,no-vary', $silence = false, $preserved = false, $svar = false, $inline_val = false )
177
  {
178
  if ( empty($block_id) || ! is_array($params) || preg_match('/[^\w-]/', $block_id) ) {
179
  return false ;
203
  if ( ! empty( $control ) ) {
204
  $output .= " cache-control='$control'" ;
205
  }
206
+ if ( $svar ) {
207
+ $output .= " as-var='1'" ;
208
+ }
209
  $output .= " />" ;
210
 
211
  if ( ! $silence ) {
213
  }
214
 
215
  LiteSpeed_Cache_Log::debug( "ESI: \t\t[block ID] $block_id \t\t\t[wrapper] $wrapper \t\t\t[Control] $control" ) ;
216
+ LiteSpeed_Cache_Log::debug2( $output ) ;
217
 
218
  self::set_has_esi() ;
219
+
220
+ // Convert to string to avoid html chars filter when using
221
+ // Will reverse the buffer when output in self::finalize()
222
+ if ( $preserved ) {
223
+ $hash = md5( $output ) ;
224
+ self::get_instance()->_esi_preserve_list[ $hash ] = $output ;
225
+ LiteSpeed_Cache_Log::debug( "[ESI] Preserved to $hash" ) ;
226
+
227
+ return $hash ;
228
+ }
229
+
230
  return $output ;
231
  }
232
 
512
  }
513
  }
514
 
515
+ /**
516
+ * Generate nonce for certain action
517
+ *
518
+ * @access public
519
+ * @since 2.6
520
+ */
521
+ public function load_nonce_block( $params )
522
+ {
523
+ $action = $params[ 'action' ] ;
524
+
525
+ LiteSpeed_Cache_Log::debug( '[ESI] load_nonce_block [action] ' . $action ) ;
526
+
527
+ // set nonce TTL to half day
528
+ LiteSpeed_Cache_Control::set_custom_ttl( 43200 ) ;
529
+
530
+ if ( LiteSpeed_Cache_Router::is_logged_in() ) {
531
+ LiteSpeed_Cache_Control::set_private() ;
532
+ }
533
+
534
+ echo wp_create_nonce( $action ) ;
535
+ }
536
+
537
  /**
538
  * Hooked to the comment_form_defaults filter.
539
  * Stores the default comment form settings.
614
  echo LiteSpeed_Cache_GUI::clean_wrapper_end() ;
615
  }
616
 
617
+ /**
618
+ * Replace preseved blocks
619
+ *
620
+ * @since 2.6
621
+ * @access public
622
+ */
623
+ public static function finalize( $buffer )
624
+ {
625
+ $instance = self::get_instance() ;
626
+
627
+ // Bypass if no preserved list to be replaced
628
+ if ( ! $instance->_esi_preserve_list ) {
629
+ return $buffer ;
630
+ }
631
+
632
+ $keys = array_keys( $instance->_esi_preserve_list ) ;
633
+
634
+ LiteSpeed_Cache_Log::debug( '[ESI] replacing preserved blocks', $keys ) ;
635
+
636
+ $buffer = str_replace( $keys , $instance->_esi_preserve_list, $buffer ) ;
637
+
638
+ return $buffer ;
639
+ }
640
+
641
  /**
642
  * Get the current instance object.
643
  *
includes/litespeed-cache-optimize.class.php CHANGED
@@ -30,7 +30,6 @@ class LiteSpeed_Cache_Optimize
30
  private $cfg_css_combine ;
31
  private $cfg_js_minify ;
32
  private $cfg_js_combine ;
33
- private $cfg_html_minify ;
34
  private $cfg_css_async ;
35
  private $cfg_js_defer ;
36
  private $cfg_js_defer_exc = false ;
@@ -61,20 +60,9 @@ class LiteSpeed_Cache_Optimize
61
  */
62
  private function __construct()
63
  {
64
- $this->cfg_http2_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ;
65
- $this->cfg_http2_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ;
66
- $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
67
- $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
68
- $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
69
- $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
70
- $this->cfg_html_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ;
71
  $this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
72
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
73
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
74
- $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
75
- $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
76
- $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
77
- $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
78
 
79
  $this->_static_request_check() ;
80
 
@@ -167,8 +155,14 @@ class LiteSpeed_Cache_Optimize
167
  */
168
  private function _static_request_check()
169
  {
 
 
 
 
 
 
170
  // This request is for js/css_async.js
171
- if ( ( $this->cfg_css_async || $this->cfg_ggfonts_async ) && strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
172
  LiteSpeed_Cache_Log::debug( '[Optm] start serving static file' ) ;
173
 
174
  $content = Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) ;
@@ -355,6 +349,17 @@ class LiteSpeed_Cache_Optimize
355
  */
356
  private function _optimize()
357
  {
 
 
 
 
 
 
 
 
 
 
 
358
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
359
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
360
  return ;
@@ -627,7 +632,7 @@ class LiteSpeed_Cache_Optimize
627
  }
628
 
629
  // HTML minify
630
- if ( $this->cfg_html_minify ) {
631
  $this->content = LiteSpeed_Cache_Optimizer::get_instance()->html_min( $this->content ) ;
632
  }
633
 
30
  private $cfg_css_combine ;
31
  private $cfg_js_minify ;
32
  private $cfg_js_combine ;
 
33
  private $cfg_css_async ;
34
  private $cfg_js_defer ;
35
  private $cfg_js_defer_exc = false ;
60
  */
61
  private function __construct()
62
  {
 
 
 
 
 
 
 
63
  $this->cfg_css_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_CSS_ASYNC ) ;
64
  $this->cfg_js_defer = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_JS_DEFER ) ;
65
  $this->cfg_qs_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_QS_RM ) ;
 
 
 
 
66
 
67
  $this->_static_request_check() ;
68
 
155
  */
156
  private function _static_request_check()
157
  {
158
+ $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
159
+ $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
160
+ $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
161
+ $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
162
+ $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
163
+
164
  // This request is for js/css_async.js
165
+ if ( strpos( $_SERVER[ 'REQUEST_URI' ], self::CSS_ASYNC_LIB ) !== false ) {
166
  LiteSpeed_Cache_Log::debug( '[Optm] start serving static file' ) ;
167
 
168
  $content = Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) ;
349
  */
350
  private function _optimize()
351
  {
352
+ $this->cfg_http2_css = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_HTTP2 ) ;
353
+ $this->cfg_http2_js = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_HTTP2 ) ;
354
+ $this->cfg_css_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_MINIFY ) ;
355
+ $this->cfg_css_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CSS_COMBINE ) ;
356
+ $this->cfg_js_minify = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_MINIFY ) ;
357
+ $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
358
+ $this->cfg_exc_jquery = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_EXC_JQUERY ) ;
359
+ $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
360
+ $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
361
+ $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
362
+
363
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
364
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
365
  return ;
632
  }
633
 
634
  // HTML minify
635
+ if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_HTML_MINIFY ) ) {
636
  $this->content = LiteSpeed_Cache_Optimizer::get_instance()->html_min( $this->content ) ;
637
  }
638
 
includes/litespeed-cache-vary.class.php CHANGED
@@ -18,6 +18,7 @@ class LiteSpeed_Cache_Vary
18
 
19
  private static $_vary_name = '_lscache_vary' ; // this default vary cookie is used for logged in status check
20
  private static $_vary_cookies = array() ; // vary header only!
 
21
 
22
  /**
23
  * Adds the actions used for setting up cookies on log in/out.
@@ -205,7 +206,7 @@ class LiteSpeed_Cache_Vary
205
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
206
  * @since 2.2.2
207
  */
208
- $this->can_ajax_vary() ;
209
 
210
  // If the cookie is lost somehow, set it
211
  $this->_update_default_vary( $uid, $expire ) ;
@@ -226,7 +227,7 @@ class LiteSpeed_Cache_Vary
226
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
227
  * @since 2.2.2
228
  */
229
- $this->can_ajax_vary() ;
230
 
231
  // Force update vary to remove login status
232
  $this->_update_default_vary( -1 ) ;
@@ -236,9 +237,10 @@ class LiteSpeed_Cache_Vary
236
  * Allow vary can be changed for ajax calls
237
  *
238
  * @since 2.2.2
 
239
  * @access public
240
  */
241
- public function can_ajax_vary()
242
  {
243
  LiteSpeed_Cache_Log::debug( '[Vary] litespeed_ajax_vary -> true' ) ;
244
  add_filter( 'litespeed_ajax_vary', '__return_true' ) ;
@@ -336,7 +338,7 @@ class LiteSpeed_Cache_Vary
336
  */
337
  public function finalize_default_vary( $uid = false )
338
  {
339
- $vary = array() ;
340
 
341
  if ( ! $uid ) {
342
  $uid = LiteSpeed_Cache_Router::get_uid() ;
@@ -470,28 +472,6 @@ class LiteSpeed_Cache_Vary
470
  return $path ;
471
  }
472
 
473
- /**
474
- * Gets vary cookies that are already added for the current page.
475
- *
476
- * @since 1.0.13
477
- * @access private
478
- * @return array An array of all vary cookies currently added.
479
- */
480
- private function _format_vary_cookies()
481
- {
482
- if ( empty(self::$_vary_cookies) ) {
483
- return false ;
484
- }
485
- $cookies = array_filter(array_unique(self::$_vary_cookies)) ;
486
- if ( empty($cookies) ) {
487
- return false ;
488
- }
489
- foreach ($cookies as $key => $val) {
490
- $cookies[$key] = 'cookie=' . $val ;
491
- }
492
- return $cookies ;
493
- }
494
-
495
  /**
496
  * Builds the vary header.
497
  *
@@ -545,8 +525,34 @@ class LiteSpeed_Cache_Vary
545
 
546
  }
547
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  /**
549
  * Adds vary to the list of vary cookies for the current page.
 
550
  *
551
  * @since 1.0.13
552
  * @access public
@@ -558,9 +564,22 @@ class LiteSpeed_Cache_Vary
558
  $vary = array($vary) ;
559
  }
560
 
 
 
561
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
562
  }
563
 
 
 
 
 
 
 
 
 
 
 
 
564
  /**
565
  * Set the vary cookie.
566
  *
18
 
19
  private static $_vary_name = '_lscache_vary' ; // this default vary cookie is used for logged in status check
20
  private static $_vary_cookies = array() ; // vary header only!
21
+ private static $_default_vary_val = array() ;
22
 
23
  /**
24
  * Adds the actions used for setting up cookies on log in/out.
206
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
207
  * @since 2.2.2
208
  */
209
+ self::can_ajax_vary() ;
210
 
211
  // If the cookie is lost somehow, set it
212
  $this->_update_default_vary( $uid, $expire ) ;
227
  * NOTE: Run before `$this->_update_default_vary()` to make vary changeable
228
  * @since 2.2.2
229
  */
230
+ self::can_ajax_vary() ;
231
 
232
  // Force update vary to remove login status
233
  $this->_update_default_vary( -1 ) ;
237
  * Allow vary can be changed for ajax calls
238
  *
239
  * @since 2.2.2
240
+ * @since 2.6 Changed to static
241
  * @access public
242
  */
243
+ public static function can_ajax_vary()
244
  {
245
  LiteSpeed_Cache_Log::debug( '[Vary] litespeed_ajax_vary -> true' ) ;
246
  add_filter( 'litespeed_ajax_vary', '__return_true' ) ;
338
  */
339
  public function finalize_default_vary( $uid = false )
340
  {
341
+ $vary = self::$_default_vary_val ;
342
 
343
  if ( ! $uid ) {
344
  $uid = LiteSpeed_Cache_Router::get_uid() ;
472
  return $path ;
473
  }
474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
475
  /**
476
  * Builds the vary header.
477
  *
525
 
526
  }
527
 
528
+ /**
529
+ * Gets vary cookies that are already added for the current page.
530
+ *
531
+ * @since 1.0.13
532
+ * @access private
533
+ * @return array An array of all vary cookies currently added.
534
+ */
535
+ private function _format_vary_cookies()
536
+ {
537
+ // To add new varys, use hook `API::hook_vary_add()` before here
538
+ do_action( 'litespeed_vary_add' ) ;
539
+
540
+ if ( empty(self::$_vary_cookies) ) {
541
+ return false ;
542
+ }
543
+ $cookies = array_filter(array_unique(self::$_vary_cookies)) ;
544
+ if ( empty($cookies) ) {
545
+ return false ;
546
+ }
547
+ foreach ($cookies as $key => $val) {
548
+ $cookies[$key] = 'cookie=' . $val ;
549
+ }
550
+ return $cookies ;
551
+ }
552
+
553
  /**
554
  * Adds vary to the list of vary cookies for the current page.
555
+ * This is to add a new vary cookie
556
  *
557
  * @since 1.0.13
558
  * @access public
564
  $vary = array($vary) ;
565
  }
566
 
567
+ LiteSpeed_Cache_Log::debug( '[Vary] Add new vary ', $vary ) ;
568
+
569
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
570
  }
571
 
572
+ /**
573
+ * Append child value to default vary
574
+ *
575
+ * @since 2.6
576
+ * @access public
577
+ */
578
+ public static function append( $name, $val )
579
+ {
580
+ self::$_default_vary_val[ $name ] = $val ;
581
+ }
582
+
583
  /**
584
  * Set the vary cookie.
585
  *
includes/litespeed-cache.class.php CHANGED
@@ -25,7 +25,7 @@ class LiteSpeed_Cache
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
- const PLUGIN_VERSION = '2.5.1' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
@@ -152,6 +152,7 @@ class LiteSpeed_Cache
152
  /**
153
  * Added hook before init
154
  * @since 1.6.6
 
155
  */
156
  do_action( 'litespeed_init' ) ;
157
 
@@ -468,6 +469,9 @@ class LiteSpeed_Cache
468
  {
469
  $this->_check_is_html( $buffer ) ;
470
 
 
 
 
471
  // Image lazy load check
472
  $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
473
 
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
+ const PLUGIN_VERSION = '2.6' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
152
  /**
153
  * Added hook before init
154
  * @since 1.6.6
155
+ * @since 2.6 Added filter to all config values in LiteSpeed_Cache_Config
156
  */
157
  do_action( 'litespeed_init' ) ;
158
 
469
  {
470
  $this->_check_is_html( $buffer ) ;
471
 
472
+ // Replace ESI preserved list
473
+ $buffer = LiteSpeed_Cache_ESI::finalize( $buffer ) ;
474
+
475
  // Image lazy load check
476
  $buffer = LiteSpeed_Cache_Media::finalize( $buffer ) ;
477
 
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.5.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2018-09-11 17:24:06+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -428,13 +428,13 @@ msgstr ""
428
  msgid "Failed to push to LiteSpeed server: %s"
429
  msgstr ""
430
 
431
- #: admin/litespeed-cache-admin-rules.class.php:908
432
  msgid ""
433
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
434
  "%2$s"
435
  msgstr ""
436
 
437
- #: admin/litespeed-cache-admin-rules.class.php:1010
438
  msgid "File Saved."
439
  msgstr ""
440
 
@@ -455,7 +455,7 @@ msgid "Site options saved."
455
  msgstr ""
456
 
457
  #: admin/litespeed-cache-admin-settings.class.php:357
458
- #: admin/litespeed-cache-admin-settings.class.php:1052
459
  msgid "Default Public Cache"
460
  msgstr ""
461
 
@@ -471,30 +471,30 @@ msgstr ""
471
  msgid "Feed"
472
  msgstr ""
473
 
474
- #: admin/litespeed-cache-admin-settings.class.php:890
475
  #: admin/tpl/setting/settings_debug.php:88
476
  msgid "Log File Size Limit"
477
  msgstr ""
478
 
479
- #: admin/litespeed-cache-admin-settings.class.php:975
480
  #: admin/tpl/setting/settings_crawler.php:13
481
  msgid "Delay"
482
  msgstr ""
483
 
484
- #: admin/litespeed-cache-admin-settings.class.php:976
485
  #: admin/tpl/setting/settings_crawler.php:37
486
  msgid "Run Duration"
487
  msgstr ""
488
 
489
- #: admin/litespeed-cache-admin-settings.class.php:977
490
  msgid "Cron Interval"
491
  msgstr ""
492
 
493
- #: admin/litespeed-cache-admin-settings.class.php:978
494
  msgid "Whole Interval"
495
  msgstr ""
496
 
497
- #: admin/litespeed-cache-admin-settings.class.php:979
498
  #: admin/tpl/setting/settings_crawler.php:73
499
  msgid "Threads"
500
  msgstr ""
@@ -814,7 +814,7 @@ msgstr ""
814
  #: admin/tpl/setting/settings_general.php:140
815
  #: admin/tpl/setting/settings_inc.cache_browser.php:24
816
  #: admin/tpl/setting/settings_inc.cache_object.php:63
817
- #: admin/tpl/setting/settings_optimize.php:113
818
  msgid "seconds"
819
  msgstr ""
820
 
@@ -873,7 +873,7 @@ msgstr ""
873
  msgid "Rate %s on %s"
874
  msgstr ""
875
 
876
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.5.1) #-#-#-#-#
877
  #. Plugin Name of the plugin/theme
878
  #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:353
879
  #: includes/litespeed-cache-gui.class.php:353
@@ -3450,89 +3450,89 @@ msgid "Minify CSS files."
3450
  msgstr ""
3451
 
3452
  #: admin/tpl/setting/settings_optimize.php:38
3453
- msgid "Inline CSS Minify"
3454
- msgstr ""
3455
-
3456
- #: admin/tpl/setting/settings_optimize.php:42
3457
- msgid "Minify inline CSS code."
3458
- msgstr ""
3459
-
3460
- #: admin/tpl/setting/settings_optimize.php:48
3461
  msgid "CSS Combine"
3462
  msgstr ""
3463
 
3464
- #: admin/tpl/setting/settings_optimize.php:52
3465
  msgid "Combine CSS files."
3466
  msgstr ""
3467
 
3468
- #: admin/tpl/setting/settings_optimize.php:53
3469
- #: admin/tpl/setting/settings_optimize.php:94
3470
  msgid "How to Fix Problems Caused by CSS/JS Optimization."
3471
  msgstr ""
3472
 
3473
- #: admin/tpl/setting/settings_optimize.php:59
3474
  msgid "CSS HTTP/2 Push"
3475
  msgstr ""
3476
 
3477
- #: admin/tpl/setting/settings_optimize.php:63
3478
  msgid ""
3479
  "Pre-send internal CSS files to the browser before they are requested. "
3480
  "(Requires the HTTP/2 protocol)"
3481
  msgstr ""
3482
 
3483
- #: admin/tpl/setting/settings_optimize.php:69
3484
  msgid "JS Minify"
3485
  msgstr ""
3486
 
3487
- #: admin/tpl/setting/settings_optimize.php:73
3488
  msgid "Minify JS files."
3489
  msgstr ""
3490
 
3491
- #: admin/tpl/setting/settings_optimize.php:79
3492
- msgid "Inline JS Minify"
3493
- msgstr ""
3494
-
3495
- #: admin/tpl/setting/settings_optimize.php:83
3496
- msgid "Minify inline JS code."
3497
- msgstr ""
3498
-
3499
- #: admin/tpl/setting/settings_optimize.php:89
3500
  #: admin/tpl/setting/settings_optimize.php:223
3501
  msgid "JS Combine"
3502
  msgstr ""
3503
 
3504
- #: admin/tpl/setting/settings_optimize.php:93
3505
  msgid "Combine JS files."
3506
  msgstr ""
3507
 
3508
- #: admin/tpl/setting/settings_optimize.php:100
3509
  msgid "JS HTTP/2 Push"
3510
  msgstr ""
3511
 
3512
- #: admin/tpl/setting/settings_optimize.php:104
3513
  msgid ""
3514
  "Pre-send internal JS files to the browser before they are requested. "
3515
  "(Requires the HTTP/2 protocol)"
3516
  msgstr ""
3517
 
3518
- #: admin/tpl/setting/settings_optimize.php:110
3519
  msgid "CSS/JS Cache TTL"
3520
  msgstr ""
3521
 
3522
- #: admin/tpl/setting/settings_optimize.php:115
3523
  msgid ""
3524
  "Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s "
3525
  "seconds."
3526
  msgstr ""
3527
 
3528
- #: admin/tpl/setting/settings_optimize.php:122
3529
  msgid "HTML Minify"
3530
  msgstr ""
3531
 
3532
- #: admin/tpl/setting/settings_optimize.php:126
3533
  msgid "Minify HTML content."
3534
  msgstr ""
3535
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3536
  #: admin/tpl/setting/settings_optimize.php:132
3537
  #: admin/tpl/setting/settings_optimize.php:153
3538
  #: admin/tpl/setting/settings_tuning.php:134
@@ -4168,15 +4168,15 @@ msgstr ""
4168
  msgid "Imported setting file %s successfully."
4169
  msgstr ""
4170
 
4171
- #: inc/litespeed-cache.class.php:269 includes/litespeed-cache.class.php:269
4172
  msgid "Crawler blacklist is saved."
4173
  msgstr ""
4174
 
4175
- #: inc/litespeed-cache.class.php:280 includes/litespeed-cache.class.php:280
4176
  msgid "Notified LiteSpeed Web Server to purge everything."
4177
  msgstr ""
4178
 
4179
- #: inc/litespeed-cache.class.php:290 includes/litespeed-cache.class.php:290
4180
  msgid "Notified LiteSpeed Web Server to purge the list."
4181
  msgstr ""
4182
 
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.6\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2018-09-22 19:04:46+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
428
  msgid "Failed to push to LiteSpeed server: %s"
429
  msgstr ""
430
 
431
+ #: admin/litespeed-cache-admin-rules.class.php:904
432
  msgid ""
433
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
434
  "%2$s"
435
  msgstr ""
436
 
437
+ #: admin/litespeed-cache-admin-rules.class.php:1006
438
  msgid "File Saved."
439
  msgstr ""
440
 
455
  msgstr ""
456
 
457
  #: admin/litespeed-cache-admin-settings.class.php:357
458
+ #: admin/litespeed-cache-admin-settings.class.php:1053
459
  msgid "Default Public Cache"
460
  msgstr ""
461
 
471
  msgid "Feed"
472
  msgstr ""
473
 
474
+ #: admin/litespeed-cache-admin-settings.class.php:891
475
  #: admin/tpl/setting/settings_debug.php:88
476
  msgid "Log File Size Limit"
477
  msgstr ""
478
 
479
+ #: admin/litespeed-cache-admin-settings.class.php:976
480
  #: admin/tpl/setting/settings_crawler.php:13
481
  msgid "Delay"
482
  msgstr ""
483
 
484
+ #: admin/litespeed-cache-admin-settings.class.php:977
485
  #: admin/tpl/setting/settings_crawler.php:37
486
  msgid "Run Duration"
487
  msgstr ""
488
 
489
+ #: admin/litespeed-cache-admin-settings.class.php:978
490
  msgid "Cron Interval"
491
  msgstr ""
492
 
493
+ #: admin/litespeed-cache-admin-settings.class.php:979
494
  msgid "Whole Interval"
495
  msgstr ""
496
 
497
+ #: admin/litespeed-cache-admin-settings.class.php:980
498
  #: admin/tpl/setting/settings_crawler.php:73
499
  msgid "Threads"
500
  msgstr ""
814
  #: admin/tpl/setting/settings_general.php:140
815
  #: admin/tpl/setting/settings_inc.cache_browser.php:24
816
  #: admin/tpl/setting/settings_inc.cache_object.php:63
817
+ #: admin/tpl/setting/settings_optimize.php:93
818
  msgid "seconds"
819
  msgstr ""
820
 
873
  msgid "Rate %s on %s"
874
  msgstr ""
875
 
876
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.6) #-#-#-#-#
877
  #. Plugin Name of the plugin/theme
878
  #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:353
879
  #: includes/litespeed-cache-gui.class.php:353
3450
  msgstr ""
3451
 
3452
  #: admin/tpl/setting/settings_optimize.php:38
 
 
 
 
 
 
 
 
3453
  msgid "CSS Combine"
3454
  msgstr ""
3455
 
3456
+ #: admin/tpl/setting/settings_optimize.php:42
3457
  msgid "Combine CSS files."
3458
  msgstr ""
3459
 
3460
+ #: admin/tpl/setting/settings_optimize.php:43
3461
+ #: admin/tpl/setting/settings_optimize.php:74
3462
  msgid "How to Fix Problems Caused by CSS/JS Optimization."
3463
  msgstr ""
3464
 
3465
+ #: admin/tpl/setting/settings_optimize.php:49
3466
  msgid "CSS HTTP/2 Push"
3467
  msgstr ""
3468
 
3469
+ #: admin/tpl/setting/settings_optimize.php:53
3470
  msgid ""
3471
  "Pre-send internal CSS files to the browser before they are requested. "
3472
  "(Requires the HTTP/2 protocol)"
3473
  msgstr ""
3474
 
3475
+ #: admin/tpl/setting/settings_optimize.php:59
3476
  msgid "JS Minify"
3477
  msgstr ""
3478
 
3479
+ #: admin/tpl/setting/settings_optimize.php:63
3480
  msgid "Minify JS files."
3481
  msgstr ""
3482
 
3483
+ #: admin/tpl/setting/settings_optimize.php:69
 
 
 
 
 
 
 
 
3484
  #: admin/tpl/setting/settings_optimize.php:223
3485
  msgid "JS Combine"
3486
  msgstr ""
3487
 
3488
+ #: admin/tpl/setting/settings_optimize.php:73
3489
  msgid "Combine JS files."
3490
  msgstr ""
3491
 
3492
+ #: admin/tpl/setting/settings_optimize.php:80
3493
  msgid "JS HTTP/2 Push"
3494
  msgstr ""
3495
 
3496
+ #: admin/tpl/setting/settings_optimize.php:84
3497
  msgid ""
3498
  "Pre-send internal JS files to the browser before they are requested. "
3499
  "(Requires the HTTP/2 protocol)"
3500
  msgstr ""
3501
 
3502
+ #: admin/tpl/setting/settings_optimize.php:90
3503
  msgid "CSS/JS Cache TTL"
3504
  msgstr ""
3505
 
3506
+ #: admin/tpl/setting/settings_optimize.php:95
3507
  msgid ""
3508
  "Specify how long, in seconds, CSS/JS files are cached. Minimum is %1$s "
3509
  "seconds."
3510
  msgstr ""
3511
 
3512
+ #: admin/tpl/setting/settings_optimize.php:102
3513
  msgid "HTML Minify"
3514
  msgstr ""
3515
 
3516
+ #: admin/tpl/setting/settings_optimize.php:106
3517
  msgid "Minify HTML content."
3518
  msgstr ""
3519
 
3520
+ #: admin/tpl/setting/settings_optimize.php:112
3521
+ msgid "Inline CSS Minify"
3522
+ msgstr ""
3523
+
3524
+ #: admin/tpl/setting/settings_optimize.php:116
3525
+ msgid "Minify inline CSS code."
3526
+ msgstr ""
3527
+
3528
+ #: admin/tpl/setting/settings_optimize.php:122
3529
+ msgid "Inline JS Minify"
3530
+ msgstr ""
3531
+
3532
+ #: admin/tpl/setting/settings_optimize.php:126
3533
+ msgid "Minify inline JS code."
3534
+ msgstr ""
3535
+
3536
  #: admin/tpl/setting/settings_optimize.php:132
3537
  #: admin/tpl/setting/settings_optimize.php:153
3538
  #: admin/tpl/setting/settings_tuning.php:134
4168
  msgid "Imported setting file %s successfully."
4169
  msgstr ""
4170
 
4171
+ #: inc/litespeed-cache.class.php:270 includes/litespeed-cache.class.php:270
4172
  msgid "Crawler blacklist is saved."
4173
  msgstr ""
4174
 
4175
+ #: inc/litespeed-cache.class.php:281 includes/litespeed-cache.class.php:281
4176
  msgid "Notified LiteSpeed Web Server to purge everything."
4177
  msgstr ""
4178
 
4179
+ #: inc/litespeed-cache.class.php:291 includes/litespeed-cache.class.php:291
4180
  msgid "Notified LiteSpeed Web Server to purge the list."
4181
  msgstr ""
4182
 
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.5.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.6
19
  * Author: LiteSpeed Technologies
20
  * Author URI: https://www.litespeedtech.com
21
  * License: GPLv3
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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: 4.9.8
6
- Stable tag: 2.5.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -119,7 +119,7 @@ LSCWP supports WordPress Multisite and is compatible with most popular plugins,
119
 
120
  == Third Party Compatibility ==
121
 
122
- The vast majority of plugins and themes are compatible with LSCache. [Our API](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api) is available for those that are not.
123
 
124
  == Privacy ==
125
 
@@ -202,6 +202,14 @@ Please see [our API wiki](https://www.litespeedtech.com/support/wiki/doku.php/li
202
 
203
  Not automatically. LSCWP v1.6+ can optimize your images by request. Navigate to **LiteSpeed Cache > Image Optimization**.
204
 
 
 
 
 
 
 
 
 
205
  = How do I get WP-PostViews to display an updating view count? =
206
 
207
  1. Use: `<div id="postviews_lscwp"></div>`
@@ -267,10 +275,24 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
267
 
268
  == Changelog ==
269
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270
  = 2.5.1 - Sep 11 2018 =
271
  * 🆕 Responsive placeholder. (@szmigieldesign)
272
  * Changed CSS::ccss_realpath function scope to private.
273
- * <strong>BUGFIX</strong> Detected JS filetype before optimizing to avoid PHP source conflict. (@closte #50)
274
 
275
  = 2.5 - Sep 6 2018 =
276
  * [IMPROVEMENT] <strong>CLI</strong> can now execute Remove Original Image Backups. (@Shon)
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: 4.9.8
6
+ Stable tag: 2.6
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
119
 
120
  == Third Party Compatibility ==
121
 
122
+ The vast majority of plugins and themes are compatible with LSCache. [Our API](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api) is available for those that are not. Use the API to customize smart purging, customize cache rules, create cache varies, and make WP nonce cacheable, among other things.
123
 
124
  == Privacy ==
125
 
202
 
203
  Not automatically. LSCWP v1.6+ can optimize your images by request. Navigate to **LiteSpeed Cache > Image Optimization**.
204
 
205
+ = How do I make a WP nonce cacheable in my third-party plugin? =
206
+
207
+ Our API includes a function that uses ESI to "punch a hole" in a cached page for a nonce. This allows the nonce to be cached for 12 hours, regardless of the TTL of the page it is on.
208
+
209
+ Quick start: replace `wp_create_nonce( 'example' )` with `method_exists( 'LiteSpeed_Cache_API', 'nonce' ) ? LiteSpeed_Cache_API::nonce( 'example' ) : wp_create_nonce( 'example' )`.
210
+
211
+ Learn more on [our API wiki](https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:api#nonce_issues).
212
+
213
  = How do I get WP-PostViews to display an updating view count? =
214
 
215
  1. Use: `<div id="postviews_lscwp"></div>`
275
 
276
  == Changelog ==
277
 
278
+ = 2.6 - Sep 22 2018 =
279
+ * <strong>Vary</strong>: Moved `litespeed_cache_api_vary` hook outside of OLS condition for .htaccess generation.
280
+ * <strong>CDN</strong>: Trim spaces in original URL of CDN setting.
281
+ * <strong>API</strong>: New filter `litespeed_option_` to change all options dynamically.
282
+ * <strong>API</strong>: New `LiteSpeed_Cache_API::force_option()` to change all options dynamically.
283
+ * <strong>API</strong>: New `LiteSpeed_Cache_API::vary()` to set default vary directly for easier compaitiblity with WPML WooCommerce Multilingual.
284
+ * <strong>API</strong>: New `LiteSpeed_Cache_API::nonce()` to safely and easily allow caching of wp-nonce.
285
+ * <strong>API</strong>: New `LiteSpeed_Cache_API::hook_vary_add()` to add new vary.
286
+ * <strong>Optm</strong>: Changed HTML/JS/CSS optimization options assignment position from constructor to `finalize()`.
287
+ * <strong>Doc</strong>: Added nonce to FAQ and mentioned nonce in 3rd Party Compatibility section.
288
+ * <strong>GUI</strong>: Moved inline minify to under html minify due to the dependency.
289
+ * <strong>3rd</strong>: Cached Aelia CurrencySwitcher by default.
290
+ * 🐞: Fixed issue where enabling remote JQuery caused missing jquery-migrate library error.
291
+
292
  = 2.5.1 - Sep 11 2018 =
293
  * 🆕 Responsive placeholder. (@szmigieldesign)
294
  * Changed CSS::ccss_realpath function scope to private.
295
+ * 🐞 Detected JS filetype before optimizing to avoid PHP source conflict. (@closte #50)
296
 
297
  = 2.5 - Sep 6 2018 =
298
  * [IMPROVEMENT] <strong>CLI</strong> can now execute Remove Original Image Backups. (@Shon)
thirdparty/lscwp-3rd-aelia-currencyswitcher.cls.php CHANGED
@@ -4,6 +4,7 @@
4
  * The Third Party integration with the Aelia CurrencySwitcher plugin.
5
  *
6
  * @since 1.0.13
 
7
  * @package LiteSpeed_Cache
8
  * @subpackage LiteSpeed_Cache/thirdparty
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
@@ -33,8 +34,8 @@ class LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher
33
  public static function detect()
34
  {
35
  if ( defined('WOOCOMMERCE_VERSION') && isset($GLOBALS['woocommerce-aelia-currencyswitcher']) && is_object($GLOBALS['woocommerce-aelia-currencyswitcher']) ) {
36
- LiteSpeed_Cache_API::hook_control('LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher::check_cookies') ;
37
- LiteSpeed_Cache_API::hook_vary('LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher::get_vary') ;
38
  }
39
  }
40
 
@@ -56,34 +57,6 @@ class LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher
56
  return ;
57
  }
58
 
59
- if ( isset($_COOKIE) && ! empty($_COOKIE) ) {
60
- foreach (self::$_cookies as $cookie) {
61
- if ( ! empty($_COOKIE[$cookie]) ) {
62
- LiteSpeed_Cache_API::vary_add(self::$_cookies) ;
63
- return ;
64
- }
65
- }
66
- }
67
-
68
- LiteSpeed_Cache_API::set_nocache() ;
69
- }
70
-
71
- /**
72
- * Hooked to the litespeed_cache_get_vary filter.
73
- *
74
- * If Aelia Currency Switcher is enabled, will need to add their cookies
75
- * to the vary array.
76
- *
77
- * @since 1.0.14
78
- * @access public
79
- * @param array $vary_arr The current list of vary cookies.
80
- * @return array The updated list of vary cookies.
81
- */
82
- public static function get_vary($vary_arr)
83
- {
84
- if ( ! is_array($vary_arr) ) {
85
- return $vary_arr ;
86
- }
87
- return array_merge($vary_arr, self::$_cookies) ;
88
  }
89
  }
4
  * The Third Party integration with the Aelia CurrencySwitcher plugin.
5
  *
6
  * @since 1.0.13
7
+ * @since 2.6 Removed hook_vary as OLS supports vary header already
8
  * @package LiteSpeed_Cache
9
  * @subpackage LiteSpeed_Cache/thirdparty
10
  * @author LiteSpeed Technologies <info@litespeedtech.com>
34
  public static function detect()
35
  {
36
  if ( defined('WOOCOMMERCE_VERSION') && isset($GLOBALS['woocommerce-aelia-currencyswitcher']) && is_object($GLOBALS['woocommerce-aelia-currencyswitcher']) ) {
37
+ // Not all pages need to add vary, so need to use this API to set conditions
38
+ LiteSpeed_Cache_API::hook_vary_add( 'LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher::check_cookies' ) ;
39
  }
40
  }
41
 
57
  return ;
58
  }
59
 
60
+ LiteSpeed_Cache_API::vary_add( self::$_cookies ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
  }