LiteSpeed Cache - Version 2.7.3

Version Description

  • Nov 26 2018 =
  • Optm: Improved page render speed with Web Font Loader JS library for Load Google Fonts Asynchronously.
  • Optm: Directly used JS library files in plugin folder instead of short links /min/.
  • Optm: Handled exceptions in JS optimization when meeting badly formatted JS.
  • 3rd: Added Adobe Lightroom support for NextGen Gallery.
  • 3rd: Improved Postman app support for POST JSON requests.
  • IAPI: US3 server IP changed to 68.183.60.185.
Download this release

Release Info

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

Code changes from version 2.7 to 2.7.3

Files changed (42) hide show
  1. admin/litespeed-cache-admin-rules.class.php +7 -1
  2. admin/litespeed-cache-admin-settings.class.php +101 -39
  3. admin/litespeed-cache-admin.class.php +7 -4
  4. admin/tpl/setting/network_settings_general.php +2 -0
  5. admin/tpl/setting/settings_cdn.php +1 -11
  6. admin/tpl/setting/settings_general.php +4 -0
  7. admin/tpl/setting/settings_inc.auto_upgrade.php +14 -0
  8. admin/tpl/setting/settings_tuning.php +2 -1
  9. cli/litespeed-cache-cli-admin.class.php +46 -12
  10. data/const.default.ini +41 -0
  11. inc/activation.class.php +59 -5
  12. inc/api.class.php +56 -37
  13. inc/cdn.class.php +6 -2
  14. inc/config.class.php +40 -43
  15. inc/const.cls.php +53 -3
  16. inc/crawler.class.php +1 -2
  17. inc/img_optm.class.php +2 -1
  18. inc/import.class.php +4 -9
  19. inc/litespeed-cache.class.php +49 -9
  20. inc/media.class.php +5 -59
  21. inc/object.class.php +2 -2
  22. inc/optimize.class.php +102 -68
  23. inc/purge.class.php +4 -0
  24. inc/router.class.php +8 -0
  25. inc/vary.class.php +22 -8
  26. includes/litespeed-cache-activation.class.php +59 -5
  27. includes/litespeed-cache-api.class.php +56 -37
  28. includes/litespeed-cache-cdn.class.php +6 -2
  29. includes/litespeed-cache-config.class.php +40 -43
  30. includes/litespeed-cache-crawler.class.php +1 -2
  31. includes/litespeed-cache-optimize.class.php +102 -68
  32. includes/litespeed-cache-purge.class.php +4 -0
  33. includes/litespeed-cache-router.class.php +8 -0
  34. includes/litespeed-cache-vary.class.php +22 -8
  35. includes/litespeed-cache.class.php +49 -9
  36. js/webfontloader.js +17 -0
  37. js/webfontloader.min.js +1 -0
  38. languages/litespeed-cache.pot +123 -113
  39. lib/js_min.class.php +4 -4
  40. litespeed-cache.php +1 -1
  41. readme.txt +28 -2
  42. thirdparty/lscwp-3rd-nextgengallery.cls.php +10 -0
admin/litespeed-cache-admin-rules.class.php CHANGED
@@ -438,8 +438,14 @@ class LiteSpeed_Cache_Admin_Rules
438
  if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
439
  return false ;
440
  }
 
 
441
 
442
- return substr($rule, strlen('RewriteRule .? - [E='), -1) ;//todo:user trim('"')
 
 
 
 
443
  }
444
 
445
  /**
438
  if( substr($rule, 0, strlen('RewriteRule .? - [E=')) !== 'RewriteRule .? - [E=' ) {//todo: use regex
439
  return false ;
440
  }
441
+
442
+ $rule_cookie = substr( $rule, strlen( 'RewriteRule .? - [E=' ), -1 ) ;
443
 
444
+ if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) {
445
+ return trim( $rule_cookie, '"' ) ;
446
+ }
447
+
448
+ return $rule_cookie ;
449
  }
450
 
451
  /**
admin/litespeed-cache-admin-settings.class.php CHANGED
@@ -43,8 +43,13 @@ class LiteSpeed_Cache_Admin_Settings
43
  * @param array $input The configuration selected by the admin when clicking save.
44
  * @return array The updated configuration options.
45
  */
46
- public function validate_plugin_settings( $input )
47
  {
 
 
 
 
 
48
  LiteSpeed_Cache_Log::debug( '[Settings] validate_plugin_settings called' ) ;
49
  $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
50
 
@@ -133,8 +138,41 @@ class LiteSpeed_Cache_Admin_Settings
133
  */
134
  private function _validate_singlesite()
135
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
137
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  // Parse rewrite rule settings
140
  $new_options = $this->_validate_rewrite_settings() ;
@@ -157,11 +195,11 @@ class LiteSpeed_Cache_Admin_Settings
157
  }
158
 
159
  /**
160
- * Validate Object Cache
161
- * @since 1.8
162
  */
163
- $new_options = $this->_validate_object_cache() ;
164
- $this->_options = array_merge( $this->_options, $new_options ) ;
165
 
166
  }
167
 
@@ -171,40 +209,60 @@ class LiteSpeed_Cache_Admin_Settings
171
  * @since 1.0.4
172
  * @access public
173
  */
174
- public function validate_network_settings()
175
  {
176
- $input = array_map( 'LiteSpeed_Cache_Admin::cleanup_text', $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ;
177
- $this->_input = $input ;
 
 
 
 
178
 
179
  $options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
180
 
 
 
 
 
 
 
 
 
 
 
 
181
  $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
182
  $network_enabled = self::parse_onoff( $this->_input, $id ) ;
183
- if ( $options[ $id ] != $network_enabled ) {
184
- $options[ $id ] = $network_enabled ;
185
- if ( $network_enabled ) {
186
- $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
187
- if ( $ret !== true ) {
188
- $this->_err[] = $ret ;
189
- }
190
- }
191
- else {
192
- LiteSpeed_Cache_Purge::purge_all( 'Network enable changed' ) ;
193
  }
194
  }
195
-
196
- $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
197
- $orig_primary = $options[ $id ] ;
198
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
199
- if ( $orig_primary != $options[ $id ] ) {
200
- LiteSpeed_Cache_Purge::purge_all( 'Network use_primary changed' ) ;
201
  }
202
 
203
- $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
204
- $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
 
205
 
206
  $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
207
  $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
208
 
209
  // Parse rewrite settings from input
210
  $new_options = $this->_validate_rewrite_settings() ;
@@ -217,6 +275,7 @@ class LiteSpeed_Cache_Admin_Settings
217
  // Need to set cachePublicOn in case subblogs turn on cache manually
218
  $disable_lscache_detail_rules = true ;
219
  }
 
220
  $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options, $disable_lscache_detail_rules ) ;
221
  if ( $res !== true ) {
222
  if ( ! is_array( $res ) ) {
@@ -227,12 +286,18 @@ class LiteSpeed_Cache_Admin_Settings
227
  }
228
  }
229
 
230
- /**
231
- * Validate Object Cache
232
- * @since 1.8
233
- */
234
- $new_options = $this->_validate_object_cache() ;
235
- $options = array_merge( $options, $new_options ) ;
 
 
 
 
 
 
236
 
237
  if ( ! empty( $this->_err ) ) {
238
  LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $this->_err ) ;
@@ -241,7 +306,6 @@ class LiteSpeed_Cache_Admin_Settings
241
 
242
  LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __( 'Site options saved.', 'litespeed-cache' ) ) ;
243
  update_site_option( LiteSpeed_Cache_Config::OPTION_NAME, $options ) ;
244
- return $options ;
245
  }
246
 
247
  /**
@@ -283,8 +347,7 @@ class LiteSpeed_Cache_Admin_Settings
283
  );
284
  $item_options = array() ;
285
  foreach ( $ids as $id ) {
286
- $item_options[ $id ] = ! empty( $this->_input[ $id ] ) ? LiteSpeed_Cache_Utility::sanitize_lines( $this->_input[ $id ] ) : '' ;
287
- update_option( $id, $item_options[ $id ] ) ;
288
  }
289
 
290
  /**
@@ -1115,10 +1178,7 @@ class LiteSpeed_Cache_Admin_Settings
1115
  }
1116
 
1117
  // Save vary group settings
1118
- $vary_groups = $_POST[ LiteSpeed_Cache_Config::VARY_GROUP ] ;
1119
- $vary_groups = array_map( 'trim', $vary_groups ) ;
1120
- $vary_groups = array_filter( $vary_groups ) ;
1121
- update_option( LiteSpeed_Cache_Config::VARY_GROUP, $vary_groups ) ;
1122
  }
1123
 
1124
  /**
@@ -1327,6 +1387,8 @@ class LiteSpeed_Cache_Admin_Settings
1327
  }
1328
 
1329
  update_option( $id, $val ) ;
 
 
1330
  }
1331
 
1332
  /**
43
  * @param array $input The configuration selected by the admin when clicking save.
44
  * @return array The updated configuration options.
45
  */
46
+ public function validate_plugin_settings( $input, $revert_options_to_input = false )
47
  {
48
+ // Revert options to initial input
49
+ if ( $revert_options_to_input ) {
50
+ $input = LiteSpeed_Cache_Config::convert_options_to_input( $input ) ;
51
+ }
52
+
53
  LiteSpeed_Cache_Log::debug( '[Settings] validate_plugin_settings called' ) ;
54
  $this->_options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
55
 
138
  */
139
  private function _validate_singlesite()
140
  {
141
+ /**
142
+ * Handle files:
143
+ * 1) wp-config.php;
144
+ * 2) adv-cache.php;
145
+ * 3) object-cache.php;
146
+ * 4) .htaccess;
147
+ */
148
+
149
+ /* 1) wp-config.php; */
150
+ $id = LiteSpeed_Cache_Config::OPID_ENABLED_RADIO ;
151
+ if ( $this->_options[ $id ] ) {// todo: If not enabled, may need to remove cache var?
152
+ $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
153
+ if ( $ret !== true ) {
154
+ $this->_err[] = $ret ;
155
+ }
156
+ }
157
+
158
+ /* 2) adv-cache.php; */
159
+
160
  $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
161
  $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
162
+ if ( $this->_options[ $id ] ) {
163
+ LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;
164
+ }
165
+
166
+ /* 3) object-cache.php; */
167
+
168
+ /**
169
+ * Validate Object Cache
170
+ * @since 1.8
171
+ */
172
+ $new_options = $this->_validate_object_cache() ;
173
+ $this->_options = array_merge( $this->_options, $new_options ) ;
174
+
175
+ /* 4) .htaccess; */
176
 
177
  // Parse rewrite rule settings
178
  $new_options = $this->_validate_rewrite_settings() ;
195
  }
196
 
197
  /**
198
+ * Keep self up-to-date
199
+ * @since 2.7.2
200
  */
201
+ $id = LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ;
202
+ $this->_options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
203
 
204
  }
205
 
209
  * @since 1.0.4
210
  * @access public
211
  */
212
+ public function validate_network_settings( $input, $revert_options_to_input = false )
213
  {
214
+ // Revert options to initial input
215
+ if ( $revert_options_to_input ) {
216
+ $input = LiteSpeed_Cache_Config::convert_options_to_input( $input ) ;
217
+ }
218
+
219
+ $this->_input = LiteSpeed_Cache_Admin::cleanup_text( $input ) ;
220
 
221
  $options = LiteSpeed_Cache_Config::get_instance()->get_site_options() ;
222
 
223
+
224
+ /**
225
+ * Handle files:
226
+ * 1) wp-config.php;
227
+ * 2) adv-cache.php;
228
+ * 3) object-cache.php;
229
+ * 4) .htaccess;
230
+ */
231
+
232
+ /* 1) wp-config.php; */
233
+
234
  $id = LiteSpeed_Cache_Config::NETWORK_OPID_ENABLED ;
235
  $network_enabled = self::parse_onoff( $this->_input, $id ) ;
236
+ if ( $network_enabled ) {
237
+ $ret = LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
238
+ if ( $ret !== true ) {
239
+ $this->_err[] = $ret ;
 
 
 
 
 
 
240
  }
241
  }
242
+ elseif ( $options[ $id ] != $network_enabled ) {
243
+ LiteSpeed_Cache_Purge::purge_all( 'Network enable changed' ) ;
 
 
 
 
244
  }
245
 
246
+ $options[ $id ] = $network_enabled ;
247
+
248
+ /* 2) adv-cache.php; */
249
 
250
  $id = LiteSpeed_Cache_Config::OPID_CHECK_ADVANCEDCACHE ;
251
  $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
252
+ if ( $options[ $id ] ) {
253
+ LiteSpeed_Cache_Activation::try_copy_advanced_cache() ;
254
+ }
255
+
256
+ /* 3) object-cache.php; */
257
+
258
+ /**
259
+ * Validate Object Cache
260
+ * @since 1.8
261
+ */
262
+ $new_options = $this->_validate_object_cache() ;
263
+ $options = array_merge( $options, $new_options ) ;
264
+
265
+ /* 4) .htaccess; */
266
 
267
  // Parse rewrite settings from input
268
  $new_options = $this->_validate_rewrite_settings() ;
275
  // Need to set cachePublicOn in case subblogs turn on cache manually
276
  $disable_lscache_detail_rules = true ;
277
  }
278
+ // NOTE: Network admin still need to make a lscache wrapper to avoid subblogs cache not work
279
  $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options, $disable_lscache_detail_rules ) ;
280
  if ( $res !== true ) {
281
  if ( ! is_array( $res ) ) {
286
  }
287
  }
288
 
289
+ $id = LiteSpeed_Cache_Config::NETWORK_OPID_USE_PRIMARY ;
290
+ $orig_primary = $options[ $id ] ;
291
+ $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
292
+ if ( $orig_primary != $options[ $id ] ) {
293
+ LiteSpeed_Cache_Purge::purge_all( 'Network use_primary changed' ) ;
294
+ }
295
+
296
+ $id = LiteSpeed_Cache_Config::OPID_PURGE_ON_UPGRADE ;
297
+ $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
298
+
299
+ $id = LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ;
300
+ $options[ $id ] = self::parse_onoff( $this->_input, $id ) ;
301
 
302
  if ( ! empty( $this->_err ) ) {
303
  LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_RED, $this->_err ) ;
306
 
307
  LiteSpeed_Cache_Admin_Display::add_notice( LiteSpeed_Cache_Admin_Display::NOTICE_GREEN, __( 'Site options saved.', 'litespeed-cache' ) ) ;
308
  update_site_option( LiteSpeed_Cache_Config::OPTION_NAME, $options ) ;
 
309
  }
310
 
311
  /**
347
  );
348
  $item_options = array() ;
349
  foreach ( $ids as $id ) {
350
+ $item_options[ $id ] = $this->_save_item( $id ) ;
 
351
  }
352
 
353
  /**
1178
  }
1179
 
1180
  // Save vary group settings
1181
+ $this->_save_item( LiteSpeed_Cache_Config::VARY_GROUP ) ;
 
 
 
1182
  }
1183
 
1184
  /**
1387
  }
1388
 
1389
  update_option( $id, $val ) ;
1390
+
1391
+ return $val ;
1392
  }
1393
 
1394
  /**
admin/litespeed-cache-admin.class.php CHANGED
@@ -182,8 +182,7 @@ class LiteSpeed_Cache_Admin
182
 
183
  // Save network settings
184
  case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
185
- $options = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings() ;// todo: use wp network setting saving
186
- // LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report($options) ; // As we don't save env report, no need this anymore
187
  break ;
188
 
189
  default:
@@ -240,9 +239,13 @@ class LiteSpeed_Cache_Admin
240
  * @param string $input The input string to clean.
241
  * @return string The cleaned up input.
242
  */
243
- public static function cleanup_text($input)
244
  {
245
- return stripslashes(trim($input)) ;
 
 
 
 
246
  }
247
 
248
  /**
182
 
183
  // Save network settings
184
  case LiteSpeed_Cache::ACTION_SAVE_SETTINGS_NETWORK:
185
+ LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $_POST[ LiteSpeed_Cache_Config::OPTION_NAME ] ) ;// todo: use wp network setting saving
 
186
  break ;
187
 
188
  default:
239
  * @param string $input The input string to clean.
240
  * @return string The cleaned up input.
241
  */
242
+ public static function cleanup_text( $input )
243
  {
244
+ if ( is_array( $input ) ) {
245
+ return array_map( 'LiteSpeed_Cache_Admin::cleanup_text', $input ) ;
246
+ }
247
+
248
+ return stripslashes( trim( $input ) ) ;
249
  }
250
 
251
  /**
admin/tpl/setting/network_settings_general.php CHANGED
@@ -30,5 +30,7 @@ if (!defined('WPINC')) die;
30
  </td>
31
  </tr>
32
 
 
 
33
  </tbody></table>
34
 
30
  </td>
31
  </tr>
32
 
33
+ <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.auto_upgrade.php' ; ?>
34
+
35
  </tbody></table>
36
 
admin/tpl/setting/settings_cdn.php CHANGED
@@ -6,17 +6,7 @@ $parsed = parse_url( $home_url ) ;
6
  $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url ) ;
7
  $cdn_url = 'https://cdn.' . substr( $home_url, 2 ) ;
8
 
9
- $cdn_mapping = get_option( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING, array() ) ;
10
- if ( ! $cdn_mapping ) {
11
- // generate one by default
12
- $cdn_mapping = array( array(
13
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL => '',
14
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG => false,
15
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS => false,
16
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS => false,
17
- LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE => ".aac\n.css\n.eot\n.gif\n.jpeg\n.js\n.jpg\n.less\n.mp3\n.mp4\n.ogg\n.otf\n.pdf\n.png\n.svg\n.ttf\n.woff",
18
- ) ) ;
19
- }
20
 
21
  ?>
22
 
6
  $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url ) ;
7
  $cdn_url = 'https://cdn.' . substr( $home_url, 2 ) ;
8
 
9
+ $cdn_mapping = $this->config->get_item( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) ;
 
 
 
 
 
 
 
 
 
 
10
 
11
  ?>
12
 
admin/tpl/setting/settings_general.php CHANGED
@@ -146,5 +146,9 @@ if (!defined('WPINC')) die;
146
  </td>
147
  </tr>
148
 
 
 
 
 
149
  </tbody></table>
150
 
146
  </td>
147
  </tr>
148
 
149
+ <?php if ( ! is_multisite() ) : ?>
150
+ <?php require LSCWP_DIR . 'admin/tpl/setting/settings_inc.auto_upgrade.php'; ?>
151
+ <?php endif ; ?>
152
+
153
  </tbody></table>
154
 
admin/tpl/setting/settings_inc.auto_upgrade.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if (!defined('WPINC')) die;
3
+
4
+ ?>
5
+ <!-- build_setting_auto_upgrade -->
6
+ <tr>
7
+ <th><?php echo __( 'Automatically Upgrade', 'litespeed-cache' ) ; ?></th>
8
+ <td>
9
+ <?php $this->build_switch( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ; ?>
10
+ <div class="litespeed-desc">
11
+ <?php echo __( 'Turn this option ON to have LiteSpeed Cache updated automatically, whenever a new version is released. If OFF, update manually as usual.', 'litespeed-cache' ) ; ?>
12
+ </div>
13
+ </td>
14
+ </tr>
admin/tpl/setting/settings_tuning.php CHANGED
@@ -110,8 +110,9 @@ if ( ! defined( 'WPINC' ) ) die ;
110
  <td>
111
  <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ; ?>
112
  <div class="litespeed-desc">
113
- <?php echo __( 'This is useful if you only want to load Google Fonts asynchronously while leave other CSS intact.', 'litespeed-cache' ) ; ?>
114
  <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ) ; ?>
 
115
  </div>
116
  </td>
117
  </tr>
110
  <td>
111
  <?php $this->build_switch( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ; ?>
112
  <div class="litespeed-desc">
113
+ <?php echo __( 'Use Web Font Loader library to load Google Fonts asynchronously while leave other CSS intact.', 'litespeed-cache' ) ; ?>
114
  <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ) ; ?>
115
+ <?php $this->learn_more( 'https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:tuning:google-fonts' ) ; ?>
116
  </div>
117
  </td>
118
  </tr>
cli/litespeed-cache-cli-admin.class.php CHANGED
@@ -51,18 +51,28 @@ class LiteSpeed_Cache_Cli_Admin
51
  */
52
  public function set_option($args, $assoc_args)
53
  {
 
 
 
54
  $key = $args[0] ;
55
  $val = $args[1] ;
56
 
57
- $options = LiteSpeed_Cache_Config::get_instance()->get_options() ;
 
 
58
  // Get items
59
- $cfg_items = LiteSpeed_Cache_Config::get_instance()->stored_items() ;
60
  foreach ( $cfg_items as $v ) {
61
- $options[ $v ] = get_option( $v ) ;
62
  }
63
 
64
-
65
- if ( ! isset($options) || ( ! isset($options[$key]) && ! isset(self::$purges[$key])) ) {
 
 
 
 
 
66
  WP_CLI::error('The options array is empty or the key is not valid.') ;
67
  return ;
68
  }
@@ -84,7 +94,7 @@ class LiteSpeed_Cache_Cli_Admin
84
  case in_array( $key, self::$checkboxes ) :
85
  //checkbox
86
  if ( $val === 'true' ) {
87
- $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
88
  }
89
  elseif ( $val === 'false' ) {
90
  unset($options[$key]) ;
@@ -103,6 +113,30 @@ class LiteSpeed_Cache_Cli_Admin
103
  $options[$key] = $val ;
104
  break ;
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  default:
107
  if ( substr($key, 0, 6) === 'purge_' ) {
108
  if ( $val === 'true' ) {
@@ -296,12 +330,12 @@ class LiteSpeed_Cache_Cli_Admin
296
 
297
  $ret = LiteSpeed_Cache_Config::get_instance()->update_options($output) ;
298
 
299
- if ( $ret ) {
300
- WP_CLI::success('Options updated. Please purge the cache. New options: ' . var_export($output, true)) ;
301
- }
302
- else {
303
- WP_CLI::error('No options updated.') ;
304
- }
305
  }
306
  }
307
 
51
  */
52
  public function set_option($args, $assoc_args)
53
  {
54
+ /**
55
+ * Note: If the value is multiple dimensions like cdn_mapping, need to specially handle it both here and in default.ini
56
+ */
57
  $key = $args[0] ;
58
  $val = $args[1] ;
59
 
60
+ $__cfg = LiteSpeed_Cache_Config::get_instance() ;
61
+
62
+ $options = $__cfg->get_options() ;
63
  // Get items
64
+ $cfg_items = $__cfg->stored_items() ;
65
  foreach ( $cfg_items as $v ) {
66
+ $options[ $v ] = $__cfg->get_item( $v ) ;
67
  }
68
 
69
+ /**
70
+ * For CDN mapping, allow:
71
+ * `set_option litespeed-cache-cdn_mapping[url][0] https://the1st_cdn_url`
72
+ * `set_option litespeed-cache-cdn_mapping[inc_img][0] true`
73
+ * @since 2.7.1
74
+ */
75
+ if ( ! isset($options) || ( ! isset($options[$key]) && ! isset(self::$purges[$key]) && strpos( $key, LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) !== 0 ) ) {
76
  WP_CLI::error('The options array is empty or the key is not valid.') ;
77
  return ;
78
  }
94
  case in_array( $key, self::$checkboxes ) :
95
  //checkbox
96
  if ( $val === 'true' ) {
97
+ $options[$key] = LiteSpeed_Cache_Config::VAL_ON ;
98
  }
99
  elseif ( $val === 'false' ) {
100
  unset($options[$key]) ;
113
  $options[$key] = $val ;
114
  break ;
115
 
116
+ /**
117
+ * Special handler for cdn mapping settings
118
+ *
119
+ * $options is already converted to input format
120
+ *
121
+ * `set_option litespeed-cache-cdn_mapping[url][0] https://the1st_cdn_url`
122
+ * `set_option litespeed-cache-cdn_mapping[inc_img][0] true`
123
+ */
124
+ case strpos( $key, LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) === 0 :
125
+
126
+ preg_match( '|\[(\w+)\]\[(\d*)\]|U', $key, $child_key ) ;
127
+
128
+ // Handle switch value
129
+ if ( in_array( $child_key[ 1 ], array(
130
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
131
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
132
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
133
+ ) ) ) {
134
+ $val = $val === 'true' ? LiteSpeed_Cache_Config::VAL_ON : LiteSpeed_Cache_Config::VAL_OFF ;
135
+ }
136
+
137
+ $options[ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ][ $child_key[ 1 ] ][ $child_key[ 2 ] ] = $val ;
138
+ break ;
139
+
140
  default:
141
  if ( substr($key, 0, 6) === 'purge_' ) {
142
  if ( $val === 'true' ) {
330
 
331
  $ret = LiteSpeed_Cache_Config::get_instance()->update_options($output) ;
332
 
333
+ WP_CLI::success('Options/Terms updated. Please purge the cache. New options: ' . var_export($options, true)) ;
334
+ // if ( $ret ) {
335
+ // }
336
+ // else {
337
+ // WP_CLI::error('No options updated.') ;
338
+ // }
339
  }
340
  }
341
 
data/const.default.ini CHANGED
@@ -23,3 +23,44 @@ cache_browser_ttl = 2592000
23
  ; OPID_PUBLIC_TTL
24
  public_ttl = 604800
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  ; OPID_PUBLIC_TTL
24
  public_ttl = 604800
25
 
26
+ ; ------------------------------CDN Mapping Example BEGIN-------------------------------
27
+ ; Need to add the section mark `[litespeed-cache-cdn_mapping]` before list
28
+ ;
29
+ ; NOTE 1) Need to set all child options to make all resources to be replaced without missing
30
+ ; NOTE 2) `url[n]` option must have to enable the row setting of `n`
31
+ ;
32
+ ; To enable the 2nd mapping record by default, please remove the `;;` in the related lines
33
+
34
+ [litespeed-cache-cdn_mapping]
35
+
36
+ url[0] = ''
37
+
38
+ inc_js[0] = true
39
+
40
+ inc_css[0] = true
41
+
42
+ inc_img[0] = true
43
+
44
+ filetype[0] = '.aac
45
+ .css
46
+ .eot
47
+ .gif
48
+ .jpeg
49
+ .js
50
+ .jpg
51
+ .less
52
+ .mp3
53
+ .mp4
54
+ .ogg
55
+ .otf
56
+ .pdf
57
+ .png
58
+ .svg
59
+ .ttf
60
+ .woff'
61
+
62
+ ;;url[1] = 'https://2nd_CDN_url.com/'
63
+
64
+ ;;filetype[1] = '.webm'
65
+
66
+ ; ------------------------------CDN Mapping Example END-------------------------------
inc/activation.class.php CHANGED
@@ -31,9 +31,6 @@ class LiteSpeed_Cache_Activation
31
  $count = 0 ;
32
  ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
33
 
34
- self::try_copy_advanced_cache() ;
35
- LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
36
-
37
  if ( is_multisite() ) {
38
  $count = self::get_network_count() ;
39
  if ( $count !== false ) {
@@ -41,9 +38,66 @@ class LiteSpeed_Cache_Activation
41
  set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
42
  }
43
  }
 
44
  do_action( 'litespeed_cache_api_load_thirdparty' ) ;
45
- LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
46
- // LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
49
  set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
31
  $count = 0 ;
32
  ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
33
 
 
 
 
34
  if ( is_multisite() ) {
35
  $count = self::get_network_count() ;
36
  if ( $count !== false ) {
38
  set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
39
  }
40
  }
41
+
42
  do_action( 'litespeed_cache_api_load_thirdparty' ) ;
43
+
44
+ $__cfg = LiteSpeed_Cache_Config::get_instance() ;
45
+
46
+ // Bcos we may ask clients to deactivate for debug temporarily, we need to keep the current cfg in deactivation, hence we need to only try adding default cfg when activating.
47
+ $res = add_option( LiteSpeed_Cache_Config::OPTION_NAME, $__cfg->get_default_options() ) ;
48
+
49
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( "[Cfg] plugin_activation update option = " . var_export( $res, true ) ) ;
50
+
51
+ /**
52
+ * Handle files:
53
+ * 1) wp-config.php;
54
+ * 2) adv-cache.php;
55
+ * 3) object-cache.php;
56
+ * 4) .htaccess;
57
+ */
58
+
59
+ /* Network file handler */
60
+
61
+ if ( is_multisite() ) {
62
+
63
+ if ( ! is_network_admin() ) {
64
+ if ( $count === 1 ) {
65
+ // Only itself is activated, set .htaccess with only CacheLookUp
66
+ LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
67
+ }
68
+ return ;
69
+ }
70
+
71
+ // All .htaccess & OC related options are in site, so only need these options
72
+ $options = $__cfg->get_site_options() ;
73
+
74
+ $ids = array(
75
+ LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS,
76
+ LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
77
+ );
78
+ foreach ( $ids as $id ) {
79
+ $options[ $id ] = $__cfg->get_item( $id ) ;
80
+ }
81
+
82
+ LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $options, true ) ;
83
+ return ;
84
+ }
85
+
86
+ /* Single site file handler */
87
+
88
+ $options = $__cfg->get_options() ;
89
+
90
+ // Add items
91
+ $cfg_items = $__cfg->stored_items() ;
92
+ foreach ( $cfg_items as $v ) {
93
+ $options[ $v ] = $__cfg->get_item( $v ) ;
94
+ }
95
+
96
+ /**
97
+ * Go through all settings to generate related files
98
+ * @since 2.7.1
99
+ */
100
+ LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
101
 
102
  if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
103
  set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
inc/api.class.php CHANGED
@@ -214,15 +214,44 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
214
  LiteSpeed_Cache_Tag::add_private( $tags ) ;
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * Add a new vary cookie
219
  *
220
  * @since 1.1.3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  * @access public
222
  */
223
- public static function vary_add($vary)
224
  {
225
- LiteSpeed_Cache_Vary::add($vary) ;
226
  }
227
 
228
  /**
@@ -241,6 +270,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
241
  LiteSpeed_Cache_Vary::append( $k, $v ) ;
242
  }
243
 
 
 
 
 
 
 
 
 
 
 
 
244
  /**
245
  * Force finalize vary even if its in an AJAX call
246
  *
@@ -252,6 +292,20 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
252
  LiteSpeed_Cache_Vary::can_ajax_vary() ;
253
  }
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  /**
256
  * Purge all action
257
  *
@@ -358,41 +412,6 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
358
  add_action('litespeed_cache_api_tag', $hook) ;
359
  }
360
 
361
- /**
362
- * Hook vary appending to vary
363
- *
364
- * NOTE: This will add vary to rewrite rule
365
- *
366
- * @since 1.1.3
367
- * @access public
368
- */
369
- public static function hook_vary($hook)
370
- {
371
- add_action('litespeed_cache_api_vary', $hook) ;
372
- }
373
-
374
- /**
375
- * Hook vary tags to vary finialization
376
- *
377
- * @since 1.7.2
378
- * @access public
379
- */
380
- public static function hook_vary_finalize( $hook )
381
- {
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
  *
214
  LiteSpeed_Cache_Tag::add_private( $tags ) ;
215
  }
216
 
217
+ /**
218
+ * Hook new vary cookies to vary finialization
219
+ *
220
+ * @since 2.6
221
+ * @access public
222
+ */
223
+ public static function hook_vary_add( $hook )
224
+ {
225
+ add_action( 'litespeed_vary_add', $hook ) ;
226
+ }
227
+
228
  /**
229
  * Add a new vary cookie
230
  *
231
  * @since 1.1.3
232
+ * @since 2.7.1 Changed to filter hook instead of `LiteSpeed_Cache_Vary::add()`
233
+ * @access public
234
+ */
235
+ public static function vary_add( $vary, $priority = 10 )
236
+ {
237
+ add_filter( 'litespeed_vary_cookies', function( $cookies ) use( $vary ) {
238
+ if ( ! is_array( $vary ) ) {
239
+ $vary = array( $vary ) ;
240
+ }
241
+ $cookies = array_merge( $cookies, $vary ) ;
242
+ return $cookies ;
243
+ }, $priority ) ;
244
+ }
245
+
246
+ /**
247
+ * Hook vary cookies to vary finialization
248
+ *
249
+ * @since 2.7.1
250
  * @access public
251
  */
252
+ public static function filter_vary_cookies( $hook, $priority = 10 )
253
  {
254
+ add_filter( 'litespeed_vary_cookies', $hook, $priority ) ;
255
  }
256
 
257
  /**
270
  LiteSpeed_Cache_Vary::append( $k, $v ) ;
271
  }
272
 
273
+ /**
274
+ * Hook vary tags to default vary finialization
275
+ *
276
+ * @since 1.7.2
277
+ * @access public
278
+ */
279
+ public static function hook_vary_finalize( $hook )
280
+ {
281
+ add_filter( 'litespeed_vary', $hook ) ;
282
+ }
283
+
284
  /**
285
  * Force finalize vary even if its in an AJAX call
286
  *
292
  LiteSpeed_Cache_Vary::can_ajax_vary() ;
293
  }
294
 
295
+ /**
296
+ * Hook vary appending to vary
297
+ *
298
+ * NOTE: This will add vary to rewrite rule
299
+ *
300
+ * @since 1.1.3
301
+ * @since 2.7.1 This didn't work in 2.7- due to used add_action not filter
302
+ * @access public
303
+ */
304
+ public static function hook_vary( $hook )
305
+ {
306
+ add_filter( 'litespeed_cache_api_vary', $hook ) ;
307
+ }
308
+
309
  /**
310
  * Purge all action
311
  *
412
  add_action('litespeed_cache_api_tag', $hook) ;
413
  }
414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  /**
416
  * Hook purge tags appending to purge
417
  *
inc/cdn.class.php CHANGED
@@ -30,6 +30,8 @@ class LiteSpeed_Cache_CDN
30
 
31
  private $cdn_mapping_hosts = array() ;
32
 
 
 
33
  /**
34
  * Init
35
  *
@@ -65,8 +67,10 @@ class LiteSpeed_Cache_CDN
65
  return ;
66
  }
67
 
 
 
68
  $this->_cfg_url_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_ORI ) ;
69
- $cfg_cdn_url = get_option( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING, array() ) ;
70
  // Parse cdn mapping data to array( 'filetype' => 'url' )
71
  $mapping_to_check = array(
72
  LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
@@ -118,7 +122,7 @@ class LiteSpeed_Cache_CDN
118
  return ;
119
  }
120
 
121
- $this->_cfg_ori_dir = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR ) ;
122
  // In case user customized upload path
123
  if ( defined( 'UPLOADS' ) ) {
124
  $this->_cfg_ori_dir[] = UPLOADS ;
30
 
31
  private $cdn_mapping_hosts = array() ;
32
 
33
+ private $__cfg ;// cfg instance
34
+
35
  /**
36
  * Init
37
  *
67
  return ;
68
  }
69
 
70
+ $this->__cfg = LiteSpeed_Cache_Config::get_instance() ;
71
+
72
  $this->_cfg_url_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_ORI ) ;
73
+ $cfg_cdn_url = $this->__cfg->get_item( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) ;
74
  // Parse cdn mapping data to array( 'filetype' => 'url' )
75
  $mapping_to_check = array(
76
  LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
122
  return ;
123
  }
124
 
125
+ $this->_cfg_ori_dir = $this->__cfg->get_item( LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR ) ;
126
  // In case user customized upload path
127
  if ( defined( 'UPLOADS' ) ) {
128
  $this->_cfg_ori_dir[] = UPLOADS ;
inc/config.class.php CHANGED
@@ -37,7 +37,10 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
37
  $options = $this->construct_multisite_options() ;
38
  }
39
  else {
40
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
 
 
 
41
 
42
  // Check advanced_cache set
43
  $this->_define_adv_cache( $options ) ;
@@ -147,7 +150,10 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
147
 
148
  $this->_define_adv_cache( $site_options ) ;
149
 
150
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
 
 
 
151
 
152
  /**
153
  * In case this is called outside the admin page
@@ -397,7 +403,11 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
397
  */
398
  public function get_item( $k, $return_string = false )
399
  {
400
- $val = get_option( $k, $this->default_item( $k ) ) ;
 
 
 
 
401
 
402
  if ( ! $return_string && ! is_array( $val ) ) {
403
  $val = $val ? explode( "\n", $val ) : array() ;
@@ -464,6 +474,33 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
464
  }
465
  }
466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  return $options ;
468
  }
469
 
@@ -661,47 +698,7 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
661
  */
662
  public function plugin_activation( $count )
663
  {
664
- $errors = array() ;
665
-
666
- $res = add_option( self::OPTION_NAME, $this->get_default_options() ) ;
667
-
668
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( "[Cfg] plugin_activation update option = " . var_export( $res, true ) ) ;
669
-
670
- $disable_lscache = false ;
671
-
672
- if ( is_multisite() ) {
673
-
674
- if ( ! is_network_admin() ) {
675
- if ( $count === 1 ) {
676
- // Only itself is activated, set .htaccess with only CacheLookUp
677
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
678
- }
679
- return ;
680
- }
681
-
682
- $options = $this->get_site_options() ;
683
-
684
- if ( ! $options[ self::NETWORK_OPID_ENABLED ] ) {
685
- // NOTE: Network admin still need to make a lscache wrapper to avoid subblogs cache not work
686
- $disable_lscache = true ;
687
- }
688
-
689
- }
690
- else {
691
- $options = $this->get_options() ;
692
- if ( ! $options[ self::OPID_ENABLED_RADIO ] ) {
693
- $disable_lscache = true ;
694
- }
695
- }
696
-
697
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options, $disable_lscache ) ;
698
 
699
- if ( $res !== true ) {
700
- if ( ! is_array( $res ) ) {
701
- exit( $res ) ;
702
- }
703
- exit( implode( "\n", $res ) ) ;
704
- }
705
 
706
  }
707
 
37
  $options = $this->construct_multisite_options() ;
38
  }
39
  else {
40
+ $options = get_option( self::OPTION_NAME ) ;
41
+ if ( ! $options ) {
42
+ $options = $this->get_default_options() ;
43
+ }
44
 
45
  // Check advanced_cache set
46
  $this->_define_adv_cache( $options ) ;
150
 
151
  $this->_define_adv_cache( $site_options ) ;
152
 
153
+ $options = get_option( self::OPTION_NAME ) ;
154
+ if ( ! $options ) {
155
+ $options = $this->get_default_options() ;
156
+ }
157
 
158
  /**
159
  * In case this is called outside the admin page
403
  */
404
  public function get_item( $k, $return_string = false )
405
  {
406
+ $val = get_option( $k ) ;
407
+ // Separately call default_item() to improve performance
408
+ if ( ! $val ) {
409
+ $val = $this->default_item( $k ) ;
410
+ }
411
 
412
  if ( ! $return_string && ! is_array( $val ) ) {
413
  $val = $val ? explode( "\n", $val ) : array() ;
474
  }
475
  }
476
 
477
+ // Convert CDN settings
478
+ $mapping_fields = array(
479
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL,
480
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
481
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
482
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
483
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE
484
+ ) ;
485
+ $cdn_mapping = array() ;
486
+ if ( isset( $options[ self::ITEM_CDN_MAPPING ] ) && is_array( $options[ self::ITEM_CDN_MAPPING ] ) ) {
487
+ foreach ( $options[ self::ITEM_CDN_MAPPING ] as $k => $v ) {// $k is numeric
488
+ foreach ( $mapping_fields as $v2 ) {
489
+ if ( empty( $cdn_mapping[ $v2 ] ) ) {
490
+ $cdn_mapping[ $v2 ] = array() ;
491
+ }
492
+ $cdn_mapping[ $v2 ][ $k ] = ! empty( $v[ $v2 ] ) ? $v[ $v2 ] : false ;
493
+ }
494
+ }
495
+ }
496
+ if ( empty( $cdn_mapping ) ) {
497
+ // At least it has one item same as in setting page
498
+ foreach ( $mapping_fields as $v2 ) {
499
+ $cdn_mapping[ $v2 ] = array( 0 => false ) ;
500
+ }
501
+ }
502
+ $options[ self::ITEM_CDN_MAPPING ] = $cdn_mapping ;
503
+
504
  return $options ;
505
  }
506
 
698
  */
699
  public function plugin_activation( $count )
700
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
 
 
 
 
 
 
 
702
 
703
  }
704
 
inc/const.cls.php CHANGED
@@ -67,6 +67,7 @@ class LiteSpeed_Cache_Const
67
  const OPID_VERSION = 'version' ;
68
  const OPID_ENABLED_RADIO = 'radio_select' ;
69
 
 
70
  const OPID_CACHE_PRIV = 'cache_priv' ;
71
  const OPID_CACHE_COMMENTER = 'cache_commenter' ;
72
  const OPID_CACHE_REST = 'cache_rest' ;
@@ -273,9 +274,53 @@ class LiteSpeed_Cache_Const
273
  * @since 1.8
274
  * @access public
275
  */
276
- public function default_item( $k )
277
  {
278
- switch ( $k ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  case self::ITEM_OBJECT_GLOBAL_GROUPS :
280
  return "users\nuserlogins\nusermeta\nuser_meta\nsite-transient\nsite-options\nsite-lookup\nblog-lookup\nblog-details\nrss\nglobal-posts\nblog-id-cache" ;
281
 
@@ -321,6 +366,7 @@ class LiteSpeed_Cache_Const
321
  self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
322
  self::NETWORK_OPID_ENABLED => false,
323
  self::NETWORK_OPID_USE_PRIMARY => false,
 
324
  self::OPID_PURGE_ON_UPGRADE => true,
325
  self::OPID_CACHE_FAVICON => true,
326
  self::OPID_CACHE_RES => true,
@@ -381,6 +427,7 @@ class LiteSpeed_Cache_Const
381
  $default_options = array(
382
  self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
383
  self::OPID_ENABLED_RADIO => $default_radio,
 
384
  self::OPID_PURGE_ON_UPGRADE => true,
385
  self::OPID_CACHE_PRIV => true,
386
  self::OPID_CACHE_COMMENTER => true,
@@ -519,7 +566,7 @@ class LiteSpeed_Cache_Const
519
 
520
  // Load default.ini
521
  if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
522
- $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini' ) ;
523
  foreach ( $default_options as $k => $v ) {
524
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
525
  continue ;
@@ -537,6 +584,9 @@ class LiteSpeed_Cache_Const
537
 
538
  $default_options[ $k ] = $ini_v ;
539
  }
 
 
 
540
  }
541
 
542
  if ( ! $include_thirdparty ) {
67
  const OPID_VERSION = 'version' ;
68
  const OPID_ENABLED_RADIO = 'radio_select' ;
69
 
70
+ const OPT_AUTO_UPGRADE = 'auto_upgrade' ;
71
  const OPID_CACHE_PRIV = 'cache_priv' ;
72
  const OPID_CACHE_COMMENTER = 'cache_commenter' ;
73
  const OPID_CACHE_REST = 'cache_rest' ;
274
  * @since 1.8
275
  * @access public
276
  */
277
+ public function default_item( $item )
278
  {
279
+ /**
280
+ * Allow terms default value
281
+ * @since 2.7.1
282
+ */
283
+ if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
284
+ $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true ) ;
285
+
286
+ if ( ! empty( $default_ini_cfg[ $item ] ) ) {
287
+
288
+ /**
289
+ * Special handler for CDN_mapping
290
+ *
291
+ * format in .ini:
292
+ * [litespeed-cache-cdn_mapping]
293
+ * url[0] = 'https://example.com/'
294
+ * inc_js[0] = true
295
+ *
296
+ * format out:
297
+ * [0] = [ 'url' => 'https://example.com', 'inc_js' => true ]
298
+ */
299
+ if ( $item == self::ITEM_CDN_MAPPING ) {
300
+ $mapping_fields = array(
301
+ self::ITEM_CDN_MAPPING_URL,
302
+ self::ITEM_CDN_MAPPING_INC_IMG,
303
+ self::ITEM_CDN_MAPPING_INC_CSS,
304
+ self::ITEM_CDN_MAPPING_INC_JS,
305
+ self::ITEM_CDN_MAPPING_FILETYPE
306
+ ) ;
307
+ $cdn_mapping = array() ;
308
+ foreach ( $default_ini_cfg[ $item ][ self::ITEM_CDN_MAPPING_URL ] as $k => $v ) {// $k is numeric
309
+ $this_row = array() ;
310
+ foreach ( $mapping_fields as $v2 ) {
311
+ $this_row[ $v2 ] = ! empty( $default_ini_cfg[ $item ][ $v2 ][ $k ] ) ? $default_ini_cfg[ $item ][ $v2 ][ $k ] : false ;
312
+ }
313
+ $cdn_mapping[ $k ] = $this_row ;
314
+ }
315
+
316
+ return $cdn_mapping ;
317
+ }
318
+
319
+ return $default_ini_cfg[ $item ] ;
320
+ }
321
+ }
322
+
323
+ switch ( $item ) {
324
  case self::ITEM_OBJECT_GLOBAL_GROUPS :
325
  return "users\nuserlogins\nusermeta\nuser_meta\nsite-transient\nsite-options\nsite-lookup\nblog-lookup\nblog-details\nrss\nglobal-posts\nblog-id-cache" ;
326
 
366
  self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
367
  self::NETWORK_OPID_ENABLED => false,
368
  self::NETWORK_OPID_USE_PRIMARY => false,
369
+ self::OPT_AUTO_UPGRADE => false,
370
  self::OPID_PURGE_ON_UPGRADE => true,
371
  self::OPID_CACHE_FAVICON => true,
372
  self::OPID_CACHE_RES => true,
427
  $default_options = array(
428
  self::OPID_VERSION => LiteSpeed_Cache::PLUGIN_VERSION,
429
  self::OPID_ENABLED_RADIO => $default_radio,
430
+ self::OPT_AUTO_UPGRADE => false,
431
  self::OPID_PURGE_ON_UPGRADE => true,
432
  self::OPID_CACHE_PRIV => true,
433
  self::OPID_CACHE_COMMENTER => true,
566
 
567
  // Load default.ini
568
  if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
569
+ $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true ) ;
570
  foreach ( $default_options as $k => $v ) {
571
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
572
  continue ;
584
 
585
  $default_options[ $k ] = $ini_v ;
586
  }
587
+
588
+ // Handle items in $this->default_item()
589
+
590
  }
591
 
592
  if ( ! $include_thirdparty ) {
inc/crawler.class.php CHANGED
@@ -488,8 +488,7 @@ class LiteSpeed_Cache_Crawler
488
  public function list_crawlers( $count_only = false )
489
  {
490
  // Get roles set
491
- $roles = get_option( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ) ;
492
- $roles = $roles ? explode( "\n", $roles ) : array() ;
493
 
494
  // WebP on/off
495
  $webp = LiteSpeed_Cache_Media::webp_enabled() ;
488
  public function list_crawlers( $count_only = false )
489
  {
490
  // Get roles set
491
+ $roles = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ) ;
 
492
 
493
  // WebP on/off
494
  $webp = LiteSpeed_Cache_Media::webp_enabled() ;
inc/img_optm.class.php CHANGED
@@ -1251,7 +1251,7 @@ class LiteSpeed_Cache_Img_Optm
1251
  'src' => $v->src,
1252
  'srcpath_md5' => $v->srcpath_md5,
1253
  'src_md5' => $v->src_md5,
1254
- 'server' => $v->server,
1255
  ) ;
1256
  }
1257
  }
@@ -1434,6 +1434,7 @@ class LiteSpeed_Cache_Img_Optm
1434
 
1435
  // Clear credit info
1436
  delete_option( self::DB_IMG_OPTM_SUMMARY ) ;
 
1437
 
1438
  exit( 'ok' ) ;
1439
  }
1251
  'src' => $v->src,
1252
  'srcpath_md5' => $v->srcpath_md5,
1253
  'src_md5' => $v->src_md5,
1254
+ 'server_info' => $v->server_info,
1255
  ) ;
1256
  }
1257
  }
1434
 
1435
  // Clear credit info
1436
  delete_option( self::DB_IMG_OPTM_SUMMARY ) ;
1437
+ delete_option( LiteSpeed_Cache_Config::ITEM_IMG_OPTM_NEED_PULL ) ;
1438
 
1439
  exit( 'ok' ) ;
1440
  }
inc/import.class.php CHANGED
@@ -94,7 +94,7 @@ class LiteSpeed_Cache_Import
94
 
95
  $data = array() ;
96
  foreach ( $this->_cfg_items as $v ) {
97
- $data[ $v ] = get_option( $v ) ;
98
  }
99
 
100
  $data = base64_encode( serialize( $data ) ) ;
@@ -184,9 +184,7 @@ class LiteSpeed_Cache_Import
184
  $options[ $v ] = $data[ $v ] ;
185
  }
186
 
187
- $options = LiteSpeed_Cache_Config::convert_options_to_input( $options ) ;
188
-
189
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options ) ;
190
 
191
  global $wp_settings_errors ;
192
  if ( ! empty( $wp_settings_errors ) ) {
@@ -233,14 +231,11 @@ class LiteSpeed_Cache_Import
233
  {
234
  $options = $this->__cfg->get_default_options() ;
235
  // Get items
236
- $cfg_items = $this->__cfg->stored_items() ;
237
- foreach ( $cfg_items as $v ) {
238
  $options[ $v ] = $this->__cfg->default_item( $v ) ;
239
  }
240
 
241
- $options = LiteSpeed_Cache_Config::convert_options_to_input( $options ) ;
242
-
243
- $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options ) ;
244
 
245
  $ret = $this->__cfg->update_options( $output ) ;
246
 
94
 
95
  $data = array() ;
96
  foreach ( $this->_cfg_items as $v ) {
97
+ $data[ $v ] = get_option( $v ) ;// Here doesn't need the default_item value so no need to call `LiteSpeed_Cache_Config::get_instance()->get_item()`
98
  }
99
 
100
  $data = base64_encode( serialize( $data ) ) ;
184
  $options[ $v ] = $data[ $v ] ;
185
  }
186
 
187
+ $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
 
 
188
 
189
  global $wp_settings_errors ;
190
  if ( ! empty( $wp_settings_errors ) ) {
231
  {
232
  $options = $this->__cfg->get_default_options() ;
233
  // Get items
234
+ foreach ( $this->_cfg_items as $v ) {
 
235
  $options[ $v ] = $this->__cfg->default_item( $v ) ;
236
  }
237
 
238
+ $output = LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
 
 
239
 
240
  $ret = $this->__cfg->update_options( $output ) ;
241
 
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.7' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
@@ -104,14 +104,18 @@ class LiteSpeed_Cache
104
  define( 'LITESPEED_DISABLE_ALL', true ) ;
105
  }
106
 
107
- // Register plugin activate/deactivate/uninstall hooks
108
- // NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
109
- if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
110
- $plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
111
- register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
112
- register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
113
- register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
114
- }
 
 
 
 
115
 
116
  add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
117
 
@@ -156,6 +160,9 @@ class LiteSpeed_Cache
156
  */
157
  do_action( 'litespeed_init' ) ;
158
 
 
 
 
159
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
160
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
161
  }
@@ -223,6 +230,39 @@ class LiteSpeed_Cache
223
 
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  /**
227
  * Run frontend actions
228
  *
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
+ const PLUGIN_VERSION = '2.7.3' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
104
  define( 'LITESPEED_DISABLE_ALL', true ) ;
105
  }
106
 
107
+ /**
108
+ * Register plugin activate/deactivate/uninstall hooks
109
+ * NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
110
+ *
111
+ * @since 2.7.1 Disabled admin&CLI check to make frontend able to enable cache too
112
+ */
113
+ // if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
114
+ $plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
115
+ register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
116
+ register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
117
+ register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
118
+ // }
119
 
120
  add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
121
 
160
  */
161
  do_action( 'litespeed_init' ) ;
162
 
163
+ // in `after_setup_theme`, before `init` hook
164
+ $this->_auto_update() ;
165
+
166
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
167
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
168
  }
230
 
231
  }
232
 
233
+ /**
234
+ * Handle auto update
235
+ *
236
+ * @since 2.7.2
237
+ * @access private
238
+ */
239
+ private function _auto_update()
240
+ {
241
+ if ( ! self::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
242
+ return ;
243
+ }
244
+
245
+ add_filter( 'auto_update_plugin', function( $update, $item ) {
246
+ if ( $item->slug == 'litespeed-cache' ) {
247
+ // Check latest stable version allowed to upgrade
248
+ $url = 'https://wp.api.litespeedtech.com/auto_upgrade_v' ;
249
+ $response = wp_remote_get( $url, array( 'timeout' => 15 ) ) ;
250
+ if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
251
+ return false ;
252
+ }
253
+ $auto_v = $response[ 'body' ] ;
254
+
255
+ if ( empty( $item->new_version ) || $auto_v !== $item->new_version ) {
256
+ return false ;
257
+ }
258
+
259
+ return true ;
260
+ }
261
+
262
+ return $update; // Else, use the normal API response to decide whether to update or not
263
+ }, 10, 2 ) ;
264
+ }
265
+
266
  /**
267
  * Run frontend actions
268
  *
inc/media.class.php CHANGED
@@ -17,7 +17,7 @@ class LiteSpeed_Cache_Media
17
  {
18
  private static $_instance ;
19
 
20
- const LAZY_LIB = '/min/lazyload.js' ;
21
 
22
  const TYPE_GENERATE_PLACEHOLDER = 'generate_placeholder' ;
23
  const DB_PLACEHOLDER_SUMMARY = 'litespeed-media-placeholder-summary' ;
@@ -45,8 +45,6 @@ class LiteSpeed_Cache_Media
45
  $this->wp_upload_dir = wp_upload_dir() ;
46
 
47
  if ( $this->can_media() ) {
48
- $this->_static_request_check() ;
49
-
50
  $this->_cfg_img_webp = self::webp_enabled() ;
51
 
52
  // Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
@@ -308,56 +306,6 @@ eot;
308
  return false ;
309
  }
310
 
311
- /**
312
- * Check if the request is for static file
313
- *
314
- * @since 1.4
315
- * @access private
316
- * @return string The static file content
317
- */
318
- private function _static_request_check()
319
- {
320
- // This request is for js/css_async.js
321
- if ( strpos( $_SERVER[ 'REQUEST_URI' ], self::LAZY_LIB ) !== false ) {
322
- LiteSpeed_Cache_Log::debug( '[Media] run lazyload lib' ) ;
323
-
324
- $content = $this->_get_lazyload_lib_content() ;
325
-
326
- $static_file = LSCWP_CONTENT_DIR . '/cache/js/lazyload.js' ;
327
-
328
- // Save to cache folder to enable directly usage by .htacess
329
- if ( ! file_exists( $static_file ) ) {
330
- Litespeed_File::save( $static_file, $content, true ) ;
331
- LiteSpeed_Cache_Log::debug( '[Media] save lazyload lib to ' . $static_file ) ;
332
- }
333
-
334
- LiteSpeed_Cache_Control::set_cacheable() ;
335
- LiteSpeed_Cache_Control::set_public_forced( 'OPTM: lazyload js' ) ;
336
- LiteSpeed_Cache_Control::set_no_vary() ;
337
- LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
338
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_LAZY' ) ;
339
-
340
- header( 'Content-Length: ' . strlen( $content ) ) ;
341
- header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
342
-
343
- echo $content ;
344
- exit ;
345
- }
346
- }
347
-
348
- /**
349
- * Read lazyload js lib content
350
- *
351
- * @since 2.4.3
352
- * @access private
353
- */
354
- private function _get_lazyload_lib_content()
355
- {
356
- $file = LSCWP_DIR . 'js/lazyload.min.js' ;
357
-
358
- return Litespeed_File::read( $file ) ;
359
- }
360
-
361
  /**
362
  * Run lazy load process
363
  * NOTE: As this is after cache finalized, can NOT set any cache control anymore
@@ -462,9 +410,9 @@ eot;
462
  // Include lazyload lib js and init lazyload
463
  if ( $cfg_img_lazy || $cfg_iframe_lazy ) {
464
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZYJS_INLINE ) ) {
465
- $lazy_lib = '<script type="text/javascript">' . $this->_get_lazyload_lib_content() . '</script>' ;
466
  } else {
467
- $lazy_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::LAZY_LIB ) ;
468
  $lazy_lib = '<script src="' . $lazy_lib_url . '"></script>' ;
469
  }
470
 
@@ -559,11 +507,9 @@ eot;
559
  /**
560
  * Exclude list
561
  * @since 1.5
 
562
  */
563
- $excludes = apply_filters( 'litespeed_cache_media_lazy_img_excludes', get_option( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ) ) ;
564
- if ( $excludes ) {
565
- $excludes = explode( "\n", $excludes ) ;
566
- }
567
 
568
  $src_list = array() ;
569
  $html_list = array() ;
17
  {
18
  private static $_instance ;
19
 
20
+ const LIB_FILE_IMG_LAZYLOAD = 'js/lazyload.min.js' ;
21
 
22
  const TYPE_GENERATE_PLACEHOLDER = 'generate_placeholder' ;
23
  const DB_PLACEHOLDER_SUMMARY = 'litespeed-media-placeholder-summary' ;
45
  $this->wp_upload_dir = wp_upload_dir() ;
46
 
47
  if ( $this->can_media() ) {
 
 
48
  $this->_cfg_img_webp = self::webp_enabled() ;
49
 
50
  // Due to ajax call doesn't send correct accept header, have to limit webp to HTML only
306
  return false ;
307
  }
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  /**
310
  * Run lazy load process
311
  * NOTE: As this is after cache finalized, can NOT set any cache control anymore
410
  // Include lazyload lib js and init lazyload
411
  if ( $cfg_img_lazy || $cfg_iframe_lazy ) {
412
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_MEDIA_IMG_LAZYJS_INLINE ) ) {
413
+ $lazy_lib = '<script type="text/javascript">' . Litespeed_File::read( LSCWP_DIR . self::LIB_FILE_IMG_LAZYLOAD ) . '</script>' ;
414
  } else {
415
+ $lazy_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_IMG_LAZYLOAD ;
416
  $lazy_lib = '<script src="' . $lazy_lib_url . '"></script>' ;
417
  }
418
 
507
  /**
508
  * Exclude list
509
  * @since 1.5
510
+ * @since 2.7.1 Changed to array
511
  */
512
+ $excludes = apply_filters( 'litespeed_cache_media_lazy_img_excludes', LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_MEDIA_LAZY_IMG_EXC ) ) ;
 
 
 
513
 
514
  $src_list = array() ;
515
  $html_list = array() ;
inc/object.class.php CHANGED
@@ -92,8 +92,8 @@ class LiteSpeed_Cache_Object
92
  $this->_cfg_db = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_DB_ID ) ;
93
  $this->_cfg_user = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_USER ) ;
94
  $this->_cfg_pswd = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PSWD ) ;
95
- $this->_global_groups = explode( "\n", get_option( LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS ) ) ;
96
- $this->_non_persistent_groups = explode( "\n", get_option( LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS ) ) ;
97
 
98
  if ( $this->_cfg_method ) {
99
  $this->_oc_driver = 'Redis' ;
92
  $this->_cfg_db = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_DB_ID ) ;
93
  $this->_cfg_user = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_USER ) ;
94
  $this->_cfg_pswd = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CACHE_OBJECT_PSWD ) ;
95
+ $this->_global_groups = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS ) ;
96
+ $this->_non_persistent_groups = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS ) ;
97
 
98
  if ( $this->_cfg_method ) {
99
  $this->_oc_driver = 'Redis' ;
inc/optimize.class.php CHANGED
@@ -18,8 +18,8 @@ class LiteSpeed_Cache_Optimize
18
  private static $_instance ;
19
 
20
  const DIR_MIN = '/min' ;
21
- const CSS_ASYNC_LIB = '/min/css_async.js' ;
22
- const CSS_ASYNC_LIB_FILE = 'js/css_async.min.js' ;
23
 
24
  private $content ;
25
  private $http2_headers = array() ;
@@ -38,12 +38,13 @@ class LiteSpeed_Cache_Optimize
38
  private $cfg_ggfonts_async ;
39
  private $cfg_optm_max_size ;
40
  private $cfg_ttl ;
 
41
 
42
  private $dns_prefetch ;
 
43
 
44
  private $html_foot = '' ; // The html info append to <body>
45
  private $html_head = '' ; // The html info prepend to <body>
46
- private $css_to_be_removed = array() ;
47
 
48
  private $minify_cache ;
49
  private $minify_minify ;
@@ -90,10 +91,7 @@ class LiteSpeed_Cache_Optimize
90
  * @since 1.5
91
  */
92
  if ( $this->cfg_js_defer ) {
93
- $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', get_option( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ) ;
94
- if ( $this->cfg_js_defer_exc ) {
95
- $this->cfg_js_defer_exc = explode( "\n", $this->cfg_js_defer_exc ) ;
96
- }
97
  }
98
 
99
  /**
@@ -161,33 +159,6 @@ class LiteSpeed_Cache_Optimize
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 ) ;
169
-
170
- $static_file = LSCWP_CONTENT_DIR . '/cache/js/css_async.js' ;
171
-
172
- // Save to cache folder to enable directly usage by .htacess
173
- if ( ! file_exists( $static_file ) ) {
174
- Litespeed_File::save( $static_file, $content, true ) ;
175
- LiteSpeed_Cache_Log::debug( '[Optm] save css_async lib to ' . $static_file ) ;
176
- }
177
-
178
- LiteSpeed_Cache_Control::set_cacheable() ;
179
- LiteSpeed_Cache_Control::set_public_forced( 'OPTM: css async js' ) ;
180
- LiteSpeed_Cache_Control::set_no_vary() ;
181
- LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
182
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_CSS_ASYNC' ) ;
183
-
184
- header( 'Content-Length: ' . strlen( $content ) ) ;
185
- header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
186
-
187
- echo $content ;
188
- exit ;
189
- }
190
-
191
  // If not turn on min files
192
  if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
193
  return ;
@@ -359,6 +330,7 @@ class LiteSpeed_Cache_Optimize
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' ) ;
@@ -368,12 +340,7 @@ class LiteSpeed_Cache_Optimize
368
  do_action( 'litespeed_optm' ) ;
369
 
370
  // Parse css from content
371
- $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
372
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
373
- // To remove google fonts
374
- if ( $ggfonts_rm ) {
375
- $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
376
- }
377
  list( $src_list, $html_list ) = $this->_handle_css() ;
378
  }
379
 
@@ -457,23 +424,6 @@ class LiteSpeed_Cache_Optimize
457
 
458
  }
459
 
460
- // Handle google fonts async
461
- if ( ! $this->cfg_css_async && $this->cfg_ggfonts_async ) {
462
- foreach ( $html_list as $k => $v ) {
463
- if ( strpos( $src_list[ $k ], 'fonts.googleapis.com' ) === false ) {
464
- unset( $html_list[ $k ] ) ;
465
- continue ;
466
- }
467
-
468
- LiteSpeed_Cache_Log::debug( '[Optm] google fonts async loading: ' . $src_list[ $k ] ) ;
469
- }
470
- // async html
471
- $html_list_async = $this->_async_css_list( $html_list ) ;
472
-
473
- // Replace async css
474
- $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
475
- }
476
-
477
  // Parse js from buffer as needed
478
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
479
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
@@ -597,21 +547,23 @@ class LiteSpeed_Cache_Optimize
597
 
598
 
599
  // Append async compatibility lib to head
600
- if ( $this->cfg_css_async || $this->cfg_ggfonts_async ) {
601
  // Inline css async lib
602
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE ) ) {
603
- $this->html_head .= '<script id="litespeed-css-async-lib" type="text/javascript">' . Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) . '</script>' ;
604
  }
605
  else {
606
- $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
607
  $this->html_head .= "<script id='litespeed-css-async-lib' src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
608
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
609
  }
610
  }
611
 
612
- if ( $this->cfg_ggfonts_async ) {
613
- $this->html_head .= '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
614
- }
 
 
615
 
616
  // Replace html head part
617
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
@@ -642,6 +594,69 @@ class LiteSpeed_Cache_Optimize
642
 
643
  }
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  /**
646
  * Prefetch DNS
647
  *
@@ -650,7 +665,7 @@ class LiteSpeed_Cache_Optimize
650
  */
651
  private function _dns_prefetch_init()
652
  {
653
- $this->dns_prefetch = get_option( LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ) ;
654
  if ( ! $this->dns_prefetch ) {
655
  return ;
656
  }
@@ -675,7 +690,7 @@ class LiteSpeed_Cache_Optimize
675
  return $urls ;
676
  }
677
 
678
- foreach ( explode( "\n", $this->dns_prefetch ) as $v ) {
679
  if ( $v ) {
680
  $urls[] = $v ;
681
  }
@@ -692,7 +707,7 @@ class LiteSpeed_Cache_Optimize
692
  */
693
  public function dns_prefetch_output()
694
  {
695
- foreach ( explode( "\n", $this->dns_prefetch ) as $v ) {
696
  if ( $v ) {
697
  $this->html_head .= "<link rel='dns-prefetch' href='$v' />" ;
698
  }
@@ -988,7 +1003,7 @@ class LiteSpeed_Cache_Optimize
988
  $excludes = explode( "\n", $excludes ) ;
989
  }
990
 
991
- $this->css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', $this->css_to_be_removed ) ;
992
 
993
  $src_list = array() ;
994
  $html_list = array() ;
@@ -1024,13 +1039,32 @@ class LiteSpeed_Cache_Optimize
1024
  }
1025
 
1026
  // Check if need to remove this css
1027
- if ( $this->css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $this->css_to_be_removed ) ) {
1028
  LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] ) ;
1029
  // Delete this css snippet from orig html
1030
  $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
 
1031
  continue ;
1032
  }
1033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1034
  // to avoid multiple replacement
1035
  if ( in_array( $match[ 0 ], $html_list ) ) {
1036
  continue ;
18
  private static $_instance ;
19
 
20
  const DIR_MIN = '/min' ;
21
+ const LIB_FILE_CSS_ASYNC = 'js/css_async.min.js' ;
22
+ const LIB_FILE_WEBFONTLOADER = 'js/webfontloader.min.js' ;
23
 
24
  private $content ;
25
  private $http2_headers = array() ;
38
  private $cfg_ggfonts_async ;
39
  private $cfg_optm_max_size ;
40
  private $cfg_ttl ;
41
+ private $cfg_ggfonts_rm ;
42
 
43
  private $dns_prefetch ;
44
+ private $_ggfonts_urls = array() ;
45
 
46
  private $html_foot = '' ; // The html info append to <body>
47
  private $html_head = '' ; // The html info prepend to <body>
 
48
 
49
  private $minify_cache ;
50
  private $minify_minify ;
91
  * @since 1.5
92
  */
93
  if ( $this->cfg_js_defer ) {
94
+ $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ) ;
 
 
 
95
  }
96
 
97
  /**
159
  $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
160
  $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  // If not turn on min files
163
  if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
164
  return ;
330
  $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
331
  $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
332
  $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
333
+ $this->cfg_ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
334
 
335
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
336
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
340
  do_action( 'litespeed_optm' ) ;
341
 
342
  // Parse css from content
343
+ if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $this->cfg_ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
 
 
 
 
 
344
  list( $src_list, $html_list ) = $this->_handle_css() ;
345
  }
346
 
424
 
425
  }
426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  // Parse js from buffer as needed
428
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
429
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
547
 
548
 
549
  // Append async compatibility lib to head
550
+ if ( $this->cfg_css_async ) {
551
  // Inline css async lib
552
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE ) ) {
553
+ $this->html_head .= '<script id="litespeed-css-async-lib" type="text/javascript">' . Litespeed_File::read( LSCWP_DIR . self::LIB_FILE_CSS_ASYNC ) . '</script>' ;
554
  }
555
  else {
556
+ $css_async_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_CSS_ASYNC ;
557
  $this->html_head .= "<script id='litespeed-css-async-lib' src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
558
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
559
  }
560
  }
561
 
562
+ /**
563
+ * Handle google fonts async
564
+ * This will result in a JS snippet in head, so need to put it in the end to avoid being replaced by JS parser
565
+ */
566
+ $this->_async_ggfonts() ;
567
 
568
  // Replace html head part
569
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
594
 
595
  }
596
 
597
+ /**
598
+ * Google font async
599
+ *
600
+ * @since 2.7.3
601
+ * @access private
602
+ */
603
+ private function _async_ggfonts()
604
+ {
605
+ if ( ! $this->cfg_ggfonts_async || ! $this->_ggfonts_urls ) {
606
+ return ;
607
+ }
608
+
609
+ LiteSpeed_Cache_Log::debug( '[Optm] google fonts async found: ', $this->_ggfonts_urls ) ;
610
+
611
+ $html = '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
612
+
613
+ /**
614
+ * Append fonts
615
+ *
616
+ * Could be multiple fonts
617
+ *
618
+ * <link rel='stylesheet' href='//fonts.googleapis.com/css?family=Open+Sans%3A400%2C600%2C700%2C800%2C300&#038;ver=4.9.8' type='text/css' media='all' />
619
+ * <link rel='stylesheet' href='//fonts.googleapis.com/css?family=PT+Sans%3A400%2C700%7CPT+Sans+Narrow%3A400%7CMontserrat%3A600&#038;subset=latin&#038;ver=4.9.8' type='text/css' media='all' />
620
+ * -> family: PT Sans:400,700|PT Sans Narrow:400|Montserrat:600
621
+ * <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600,700,900&#038;subset=latin%2Clatin-ext' />
622
+ */
623
+ $html .='<script type="text/javascript">WebFontConfig={google:{families:[' ;
624
+
625
+ $families = array() ;
626
+ foreach ( $this->_ggfonts_urls as $v ) {
627
+ $qs = wp_specialchars_decode( $v ) ;
628
+ $qs = urldecode( $qs ) ;
629
+ $qs = parse_url( $qs, PHP_URL_QUERY ) ;
630
+ parse_str( $qs, $qs ) ;
631
+
632
+ if ( empty( $qs[ 'family' ] ) ) {
633
+ LiteSpeed_Cache_Log::debug( '[Optm] ERR ggfonts failed to find family: ' . $v ) ;
634
+ continue ;
635
+ }
636
+
637
+ $subset = empty( $qs[ 'subset' ] ) ? '' : ':' . $qs[ 'subset' ] ;
638
+
639
+ foreach ( array_filter( explode( '|', $qs[ 'family' ] ) ) as $v2 ) {
640
+ $families[] = $v2 . $subset ;
641
+ }
642
+
643
+ }
644
+
645
+ $html .= "'" . implode( "','", $families ) . "'" ;
646
+
647
+ $html .= ']}};</script>' ;
648
+
649
+ // https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js
650
+ $webfont_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_WEBFONTLOADER ;
651
+
652
+ $html .= '<script id="litespeed-webfont-lib" src="' . $webfont_lib_url . '" async></script>' ;
653
+ $this->append_http2( $webfont_lib_url, 'js' ) ; // async lib will be http/2 pushed always
654
+
655
+ // Put this in the very beginning for preconnect
656
+ $this->html_head = $html . $this->html_head ;
657
+
658
+ }
659
+
660
  /**
661
  * Prefetch DNS
662
  *
665
  */
666
  private function _dns_prefetch_init()
667
  {
668
+ $this->dns_prefetch = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ) ;
669
  if ( ! $this->dns_prefetch ) {
670
  return ;
671
  }
690
  return $urls ;
691
  }
692
 
693
+ foreach ( $this->dns_prefetch as $v ) {
694
  if ( $v ) {
695
  $urls[] = $v ;
696
  }
707
  */
708
  public function dns_prefetch_output()
709
  {
710
+ foreach ( $this->dns_prefetch as $v ) {
711
  if ( $v ) {
712
  $this->html_head .= "<link rel='dns-prefetch' href='$v' />" ;
713
  }
1003
  $excludes = explode( "\n", $excludes ) ;
1004
  }
1005
 
1006
+ $css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', array() ) ;
1007
 
1008
  $src_list = array() ;
1009
  $html_list = array() ;
1039
  }
1040
 
1041
  // Check if need to remove this css
1042
+ if ( $css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $css_to_be_removed ) ) {
1043
  LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] ) ;
1044
  // Delete this css snippet from orig html
1045
  $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1046
+
1047
  continue ;
1048
  }
1049
 
1050
+ // Check Google fonts hit
1051
+ if ( $this->cfg_ggfonts_rm || $this->cfg_ggfonts_async ) {
1052
+ if ( strpos( $attrs[ 'href' ], 'fonts.googleapis.com' ) !== false ) {
1053
+ LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet [Google fonts] ' . $attrs[ 'href' ] ) ;
1054
+ $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1055
+
1056
+ /**
1057
+ * For async gg fonts, will add webfont into head, hence remove it from buffer and store the matches to use later
1058
+ * @since 2.7.3
1059
+ */
1060
+ if ( $this->cfg_ggfonts_async ) {
1061
+ $this->_ggfonts_urls[] = $attrs[ 'href' ] ;
1062
+ }
1063
+
1064
+ continue ;
1065
+ }
1066
+ }
1067
+
1068
  // to avoid multiple replacement
1069
  if ( in_array( $match[ 0 ], $html_list ) ) {
1070
  continue ;
inc/purge.class.php CHANGED
@@ -927,6 +927,7 @@ class LiteSpeed_Cache_Purge
927
 
928
  // for archive of categories|tags|custom tax
929
  global $post ;
 
930
  $post = get_post($post_id) ;
931
  $post_type = $post->post_type ;
932
 
@@ -1012,6 +1013,9 @@ class LiteSpeed_Cache_Purge
1012
  $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
1013
  }
1014
 
 
 
 
1015
  return array_unique($purge_tags) ;
1016
  }
1017
 
927
 
928
  // for archive of categories|tags|custom tax
929
  global $post ;
930
+ $original_post = $post ;
931
  $post = get_post($post_id) ;
932
  $post_type = $post->post_type ;
933
 
1013
  $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
1014
  }
1015
 
1016
+ // Set back to original post as $post_id might affecting the global $post value
1017
+ $post = $original_post ;
1018
+
1019
  return array_unique($purge_tags) ;
1020
  }
1021
 
inc/router.class.php CHANGED
@@ -108,6 +108,14 @@ class LiteSpeed_Cache_Router
108
  $can = false ;
109
  }
110
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Bypass login/reg page
113
  * @since 1.6
108
  $can = false ;
109
  }
110
 
111
+ /**
112
+ * Bypass cron to avoid deregister jq notice `Do not deregister the <code>jquery-core</code> script in the administration area.`
113
+ * @since 2.7.2
114
+ */
115
+ if ( defined( 'DOING_CRON' ) ) {
116
+ $can = false ;
117
+ }
118
+
119
  /**
120
  * Bypass login/reg page
121
  * @since 1.6
inc/vary.class.php CHANGED
@@ -534,19 +534,32 @@ class LiteSpeed_Cache_Vary
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
 
@@ -555,16 +568,17 @@ class LiteSpeed_Cache_Vary
555
  * This is to add a new vary cookie
556
  *
557
  * @since 1.0.13
 
558
  * @access public
559
  * @param mixed $vary A string or array of vary cookies to add to the current list.
560
  */
561
- public static function add($vary)
562
  {
563
- if ( ! is_array($vary) ) {
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
  }
534
  */
535
  private function _format_vary_cookies()
536
  {
537
+ /**
538
+ * To add new varys, use hook `API::filter_vary_cookies()` before here
539
+ */
540
  do_action( 'litespeed_vary_add' ) ;
541
 
542
+ /**
543
+ * Give a filter to manipulate vary
544
+ * @since 2.7.1
545
+ */
546
+ $cookies = apply_filters( 'litespeed_vary_cookies', self::$_vary_cookies ) ;
547
+ if ( $cookies !== self::$_vary_cookies ) {
548
+ LiteSpeed_Cache_Log::debug( '[Vary] vary changed by filter [Old] ' . var_export( self::$_vary_cookies, true ) . ' [New] ' . var_export( $cookies, true ) ) ;
549
  }
550
+
551
+ if ( ! empty( $cookies ) ) {
552
+ $cookies = array_filter( array_unique( $cookies ) ) ;
553
+ }
554
+
555
  if ( empty($cookies) ) {
556
  return false ;
557
  }
558
+
559
  foreach ($cookies as $key => $val) {
560
  $cookies[$key] = 'cookie=' . $val ;
561
  }
562
+
563
  return $cookies ;
564
  }
565
 
568
  * This is to add a new vary cookie
569
  *
570
  * @since 1.0.13
571
+ * @deprecated 2.7.1 Use filter `litespeed_vary_cookies` instead.
572
  * @access public
573
  * @param mixed $vary A string or array of vary cookies to add to the current list.
574
  */
575
+ public static function add( $vary )
576
  {
577
+ if ( ! is_array( $vary ) ) {
578
+ $vary = array( $vary ) ;
579
  }
580
 
581
+ error_log( 'Deprecated since LSCWP 2.7.1! [Vary] Add new vary ' . var_export( $vary, true ) ) ;
582
 
583
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
584
  }
includes/litespeed-cache-activation.class.php CHANGED
@@ -31,9 +31,6 @@ class LiteSpeed_Cache_Activation
31
  $count = 0 ;
32
  ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
33
 
34
- self::try_copy_advanced_cache() ;
35
- LiteSpeed_Cache_Config::wp_cache_var_setter( true ) ;
36
-
37
  if ( is_multisite() ) {
38
  $count = self::get_network_count() ;
39
  if ( $count !== false ) {
@@ -41,9 +38,66 @@ class LiteSpeed_Cache_Activation
41
  set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
42
  }
43
  }
 
44
  do_action( 'litespeed_cache_api_load_thirdparty' ) ;
45
- LiteSpeed_Cache_Config::get_instance()->plugin_activation( $count ) ;
46
- // LiteSpeed_Cache_Admin_Report::get_instance()->generate_environment_report() ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
  if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
49
  set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
31
  $count = 0 ;
32
  ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', 'Activate_' . get_current_blog_id() ) ;
33
 
 
 
 
34
  if ( is_multisite() ) {
35
  $count = self::get_network_count() ;
36
  if ( $count !== false ) {
38
  set_site_transient( self::NETWORK_TRANSIENT_COUNT, $count, DAY_IN_SECONDS ) ;
39
  }
40
  }
41
+
42
  do_action( 'litespeed_cache_api_load_thirdparty' ) ;
43
+
44
+ $__cfg = LiteSpeed_Cache_Config::get_instance() ;
45
+
46
+ // Bcos we may ask clients to deactivate for debug temporarily, we need to keep the current cfg in deactivation, hence we need to only try adding default cfg when activating.
47
+ $res = add_option( LiteSpeed_Cache_Config::OPTION_NAME, $__cfg->get_default_options() ) ;
48
+
49
+ defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( "[Cfg] plugin_activation update option = " . var_export( $res, true ) ) ;
50
+
51
+ /**
52
+ * Handle files:
53
+ * 1) wp-config.php;
54
+ * 2) adv-cache.php;
55
+ * 3) object-cache.php;
56
+ * 4) .htaccess;
57
+ */
58
+
59
+ /* Network file handler */
60
+
61
+ if ( is_multisite() ) {
62
+
63
+ if ( ! is_network_admin() ) {
64
+ if ( $count === 1 ) {
65
+ // Only itself is activated, set .htaccess with only CacheLookUp
66
+ LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
67
+ }
68
+ return ;
69
+ }
70
+
71
+ // All .htaccess & OC related options are in site, so only need these options
72
+ $options = $__cfg->get_site_options() ;
73
+
74
+ $ids = array(
75
+ LiteSpeed_Cache_Config::ITEM_OBJECT_GLOBAL_GROUPS,
76
+ LiteSpeed_Cache_Config::ITEM_OBJECT_NON_PERSISTENT_GROUPS,
77
+ );
78
+ foreach ( $ids as $id ) {
79
+ $options[ $id ] = $__cfg->get_item( $id ) ;
80
+ }
81
+
82
+ LiteSpeed_Cache_Admin_Settings::get_instance()->validate_network_settings( $options, true ) ;
83
+ return ;
84
+ }
85
+
86
+ /* Single site file handler */
87
+
88
+ $options = $__cfg->get_options() ;
89
+
90
+ // Add items
91
+ $cfg_items = $__cfg->stored_items() ;
92
+ foreach ( $cfg_items as $v ) {
93
+ $options[ $v ] = $__cfg->get_item( $v ) ;
94
+ }
95
+
96
+ /**
97
+ * Go through all settings to generate related files
98
+ * @since 2.7.1
99
+ */
100
+ LiteSpeed_Cache_Admin_Settings::get_instance()->validate_plugin_settings( $options, true ) ;
101
 
102
  if ( defined( 'LSCWP_PLUGIN_NAME' ) ) {
103
  set_transient( LiteSpeed_Cache::WHM_TRANSIENT, LiteSpeed_Cache::WHM_TRANSIENT_VAL ) ;
includes/litespeed-cache-api.class.php CHANGED
@@ -214,15 +214,44 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
214
  LiteSpeed_Cache_Tag::add_private( $tags ) ;
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * Add a new vary cookie
219
  *
220
  * @since 1.1.3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221
  * @access public
222
  */
223
- public static function vary_add($vary)
224
  {
225
- LiteSpeed_Cache_Vary::add($vary) ;
226
  }
227
 
228
  /**
@@ -241,6 +270,17 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
241
  LiteSpeed_Cache_Vary::append( $k, $v ) ;
242
  }
243
 
 
 
 
 
 
 
 
 
 
 
 
244
  /**
245
  * Force finalize vary even if its in an AJAX call
246
  *
@@ -252,6 +292,20 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
252
  LiteSpeed_Cache_Vary::can_ajax_vary() ;
253
  }
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  /**
256
  * Purge all action
257
  *
@@ -358,41 +412,6 @@ class LiteSpeed_Cache_API extends LiteSpeed_Cache_Const
358
  add_action('litespeed_cache_api_tag', $hook) ;
359
  }
360
 
361
- /**
362
- * Hook vary appending to vary
363
- *
364
- * NOTE: This will add vary to rewrite rule
365
- *
366
- * @since 1.1.3
367
- * @access public
368
- */
369
- public static function hook_vary($hook)
370
- {
371
- add_action('litespeed_cache_api_vary', $hook) ;
372
- }
373
-
374
- /**
375
- * Hook vary tags to vary finialization
376
- *
377
- * @since 1.7.2
378
- * @access public
379
- */
380
- public static function hook_vary_finalize( $hook )
381
- {
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
  *
214
  LiteSpeed_Cache_Tag::add_private( $tags ) ;
215
  }
216
 
217
+ /**
218
+ * Hook new vary cookies to vary finialization
219
+ *
220
+ * @since 2.6
221
+ * @access public
222
+ */
223
+ public static function hook_vary_add( $hook )
224
+ {
225
+ add_action( 'litespeed_vary_add', $hook ) ;
226
+ }
227
+
228
  /**
229
  * Add a new vary cookie
230
  *
231
  * @since 1.1.3
232
+ * @since 2.7.1 Changed to filter hook instead of `LiteSpeed_Cache_Vary::add()`
233
+ * @access public
234
+ */
235
+ public static function vary_add( $vary, $priority = 10 )
236
+ {
237
+ add_filter( 'litespeed_vary_cookies', function( $cookies ) use( $vary ) {
238
+ if ( ! is_array( $vary ) ) {
239
+ $vary = array( $vary ) ;
240
+ }
241
+ $cookies = array_merge( $cookies, $vary ) ;
242
+ return $cookies ;
243
+ }, $priority ) ;
244
+ }
245
+
246
+ /**
247
+ * Hook vary cookies to vary finialization
248
+ *
249
+ * @since 2.7.1
250
  * @access public
251
  */
252
+ public static function filter_vary_cookies( $hook, $priority = 10 )
253
  {
254
+ add_filter( 'litespeed_vary_cookies', $hook, $priority ) ;
255
  }
256
 
257
  /**
270
  LiteSpeed_Cache_Vary::append( $k, $v ) ;
271
  }
272
 
273
+ /**
274
+ * Hook vary tags to default vary finialization
275
+ *
276
+ * @since 1.7.2
277
+ * @access public
278
+ */
279
+ public static function hook_vary_finalize( $hook )
280
+ {
281
+ add_filter( 'litespeed_vary', $hook ) ;
282
+ }
283
+
284
  /**
285
  * Force finalize vary even if its in an AJAX call
286
  *
292
  LiteSpeed_Cache_Vary::can_ajax_vary() ;
293
  }
294
 
295
+ /**
296
+ * Hook vary appending to vary
297
+ *
298
+ * NOTE: This will add vary to rewrite rule
299
+ *
300
+ * @since 1.1.3
301
+ * @since 2.7.1 This didn't work in 2.7- due to used add_action not filter
302
+ * @access public
303
+ */
304
+ public static function hook_vary( $hook )
305
+ {
306
+ add_filter( 'litespeed_cache_api_vary', $hook ) ;
307
+ }
308
+
309
  /**
310
  * Purge all action
311
  *
412
  add_action('litespeed_cache_api_tag', $hook) ;
413
  }
414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
415
  /**
416
  * Hook purge tags appending to purge
417
  *
includes/litespeed-cache-cdn.class.php CHANGED
@@ -30,6 +30,8 @@ class LiteSpeed_Cache_CDN
30
 
31
  private $cdn_mapping_hosts = array() ;
32
 
 
 
33
  /**
34
  * Init
35
  *
@@ -65,8 +67,10 @@ class LiteSpeed_Cache_CDN
65
  return ;
66
  }
67
 
 
 
68
  $this->_cfg_url_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_ORI ) ;
69
- $cfg_cdn_url = get_option( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING, array() ) ;
70
  // Parse cdn mapping data to array( 'filetype' => 'url' )
71
  $mapping_to_check = array(
72
  LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
@@ -118,7 +122,7 @@ class LiteSpeed_Cache_CDN
118
  return ;
119
  }
120
 
121
- $this->_cfg_ori_dir = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR ) ;
122
  // In case user customized upload path
123
  if ( defined( 'UPLOADS' ) ) {
124
  $this->_cfg_ori_dir[] = UPLOADS ;
30
 
31
  private $cdn_mapping_hosts = array() ;
32
 
33
+ private $__cfg ;// cfg instance
34
+
35
  /**
36
  * Init
37
  *
67
  return ;
68
  }
69
 
70
+ $this->__cfg = LiteSpeed_Cache_Config::get_instance() ;
71
+
72
  $this->_cfg_url_ori = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_CDN_ORI ) ;
73
+ $cfg_cdn_url = $this->__cfg->get_item( LiteSpeed_Cache_Config::ITEM_CDN_MAPPING ) ;
74
  // Parse cdn mapping data to array( 'filetype' => 'url' )
75
  $mapping_to_check = array(
76
  LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
122
  return ;
123
  }
124
 
125
+ $this->_cfg_ori_dir = $this->__cfg->get_item( LiteSpeed_Cache_Config::ITEM_CDN_ORI_DIR ) ;
126
  // In case user customized upload path
127
  if ( defined( 'UPLOADS' ) ) {
128
  $this->_cfg_ori_dir[] = UPLOADS ;
includes/litespeed-cache-config.class.php CHANGED
@@ -37,7 +37,10 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
37
  $options = $this->construct_multisite_options() ;
38
  }
39
  else {
40
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
 
 
 
41
 
42
  // Check advanced_cache set
43
  $this->_define_adv_cache( $options ) ;
@@ -147,7 +150,10 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
147
 
148
  $this->_define_adv_cache( $site_options ) ;
149
 
150
- $options = get_option( self::OPTION_NAME, $this->get_default_options() ) ;
 
 
 
151
 
152
  /**
153
  * In case this is called outside the admin page
@@ -397,7 +403,11 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
397
  */
398
  public function get_item( $k, $return_string = false )
399
  {
400
- $val = get_option( $k, $this->default_item( $k ) ) ;
 
 
 
 
401
 
402
  if ( ! $return_string && ! is_array( $val ) ) {
403
  $val = $val ? explode( "\n", $val ) : array() ;
@@ -464,6 +474,33 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
464
  }
465
  }
466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  return $options ;
468
  }
469
 
@@ -661,47 +698,7 @@ class LiteSpeed_Cache_Config extends LiteSpeed_Cache_Const
661
  */
662
  public function plugin_activation( $count )
663
  {
664
- $errors = array() ;
665
-
666
- $res = add_option( self::OPTION_NAME, $this->get_default_options() ) ;
667
-
668
- defined( 'LSCWP_LOG' ) && LiteSpeed_Cache_Log::debug( "[Cfg] plugin_activation update option = " . var_export( $res, true ) ) ;
669
-
670
- $disable_lscache = false ;
671
-
672
- if ( is_multisite() ) {
673
-
674
- if ( ! is_network_admin() ) {
675
- if ( $count === 1 ) {
676
- // Only itself is activated, set .htaccess with only CacheLookUp
677
- LiteSpeed_Cache_Admin_Rules::get_instance()->insert_ls_wrapper() ;
678
- }
679
- return ;
680
- }
681
-
682
- $options = $this->get_site_options() ;
683
-
684
- if ( ! $options[ self::NETWORK_OPID_ENABLED ] ) {
685
- // NOTE: Network admin still need to make a lscache wrapper to avoid subblogs cache not work
686
- $disable_lscache = true ;
687
- }
688
-
689
- }
690
- else {
691
- $options = $this->get_options() ;
692
- if ( ! $options[ self::OPID_ENABLED_RADIO ] ) {
693
- $disable_lscache = true ;
694
- }
695
- }
696
-
697
- $res = LiteSpeed_Cache_Admin_Rules::get_instance()->update( $options, $disable_lscache ) ;
698
 
699
- if ( $res !== true ) {
700
- if ( ! is_array( $res ) ) {
701
- exit( $res ) ;
702
- }
703
- exit( implode( "\n", $res ) ) ;
704
- }
705
 
706
  }
707
 
37
  $options = $this->construct_multisite_options() ;
38
  }
39
  else {
40
+ $options = get_option( self::OPTION_NAME ) ;
41
+ if ( ! $options ) {
42
+ $options = $this->get_default_options() ;
43
+ }
44
 
45
  // Check advanced_cache set
46
  $this->_define_adv_cache( $options ) ;
150
 
151
  $this->_define_adv_cache( $site_options ) ;
152
 
153
+ $options = get_option( self::OPTION_NAME ) ;
154
+ if ( ! $options ) {
155
+ $options = $this->get_default_options() ;
156
+ }
157
 
158
  /**
159
  * In case this is called outside the admin page
403
  */
404
  public function get_item( $k, $return_string = false )
405
  {
406
+ $val = get_option( $k ) ;
407
+ // Separately call default_item() to improve performance
408
+ if ( ! $val ) {
409
+ $val = $this->default_item( $k ) ;
410
+ }
411
 
412
  if ( ! $return_string && ! is_array( $val ) ) {
413
  $val = $val ? explode( "\n", $val ) : array() ;
474
  }
475
  }
476
 
477
+ // Convert CDN settings
478
+ $mapping_fields = array(
479
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_URL,
480
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_IMG,
481
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_CSS,
482
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_INC_JS,
483
+ LiteSpeed_Cache_Config::ITEM_CDN_MAPPING_FILETYPE
484
+ ) ;
485
+ $cdn_mapping = array() ;
486
+ if ( isset( $options[ self::ITEM_CDN_MAPPING ] ) && is_array( $options[ self::ITEM_CDN_MAPPING ] ) ) {
487
+ foreach ( $options[ self::ITEM_CDN_MAPPING ] as $k => $v ) {// $k is numeric
488
+ foreach ( $mapping_fields as $v2 ) {
489
+ if ( empty( $cdn_mapping[ $v2 ] ) ) {
490
+ $cdn_mapping[ $v2 ] = array() ;
491
+ }
492
+ $cdn_mapping[ $v2 ][ $k ] = ! empty( $v[ $v2 ] ) ? $v[ $v2 ] : false ;
493
+ }
494
+ }
495
+ }
496
+ if ( empty( $cdn_mapping ) ) {
497
+ // At least it has one item same as in setting page
498
+ foreach ( $mapping_fields as $v2 ) {
499
+ $cdn_mapping[ $v2 ] = array( 0 => false ) ;
500
+ }
501
+ }
502
+ $options[ self::ITEM_CDN_MAPPING ] = $cdn_mapping ;
503
+
504
  return $options ;
505
  }
506
 
698
  */
699
  public function plugin_activation( $count )
700
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
701
 
 
 
 
 
 
 
702
 
703
  }
704
 
includes/litespeed-cache-crawler.class.php CHANGED
@@ -488,8 +488,7 @@ class LiteSpeed_Cache_Crawler
488
  public function list_crawlers( $count_only = false )
489
  {
490
  // Get roles set
491
- $roles = get_option( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ) ;
492
- $roles = $roles ? explode( "\n", $roles ) : array() ;
493
 
494
  // WebP on/off
495
  $webp = LiteSpeed_Cache_Media::webp_enabled() ;
488
  public function list_crawlers( $count_only = false )
489
  {
490
  // Get roles set
491
+ $roles = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_CRWL_AS_UIDS ) ;
 
492
 
493
  // WebP on/off
494
  $webp = LiteSpeed_Cache_Media::webp_enabled() ;
includes/litespeed-cache-optimize.class.php CHANGED
@@ -18,8 +18,8 @@ class LiteSpeed_Cache_Optimize
18
  private static $_instance ;
19
 
20
  const DIR_MIN = '/min' ;
21
- const CSS_ASYNC_LIB = '/min/css_async.js' ;
22
- const CSS_ASYNC_LIB_FILE = 'js/css_async.min.js' ;
23
 
24
  private $content ;
25
  private $http2_headers = array() ;
@@ -38,12 +38,13 @@ class LiteSpeed_Cache_Optimize
38
  private $cfg_ggfonts_async ;
39
  private $cfg_optm_max_size ;
40
  private $cfg_ttl ;
 
41
 
42
  private $dns_prefetch ;
 
43
 
44
  private $html_foot = '' ; // The html info append to <body>
45
  private $html_head = '' ; // The html info prepend to <body>
46
- private $css_to_be_removed = array() ;
47
 
48
  private $minify_cache ;
49
  private $minify_minify ;
@@ -90,10 +91,7 @@ class LiteSpeed_Cache_Optimize
90
  * @since 1.5
91
  */
92
  if ( $this->cfg_js_defer ) {
93
- $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', get_option( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ) ;
94
- if ( $this->cfg_js_defer_exc ) {
95
- $this->cfg_js_defer_exc = explode( "\n", $this->cfg_js_defer_exc ) ;
96
- }
97
  }
98
 
99
  /**
@@ -161,33 +159,6 @@ class LiteSpeed_Cache_Optimize
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 ) ;
169
-
170
- $static_file = LSCWP_CONTENT_DIR . '/cache/js/css_async.js' ;
171
-
172
- // Save to cache folder to enable directly usage by .htacess
173
- if ( ! file_exists( $static_file ) ) {
174
- Litespeed_File::save( $static_file, $content, true ) ;
175
- LiteSpeed_Cache_Log::debug( '[Optm] save css_async lib to ' . $static_file ) ;
176
- }
177
-
178
- LiteSpeed_Cache_Control::set_cacheable() ;
179
- LiteSpeed_Cache_Control::set_public_forced( 'OPTM: css async js' ) ;
180
- LiteSpeed_Cache_Control::set_no_vary() ;
181
- LiteSpeed_Cache_Control::set_custom_ttl( 8640000 ) ;
182
- LiteSpeed_Cache_Tag::add( LiteSpeed_Cache_Tag::TYPE_MIN . '_CSS_ASYNC' ) ;
183
-
184
- header( 'Content-Length: ' . strlen( $content ) ) ;
185
- header( 'Content-Type: application/x-javascript; charset=utf-8' ) ;
186
-
187
- echo $content ;
188
- exit ;
189
- }
190
-
191
  // If not turn on min files
192
  if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
193
  return ;
@@ -359,6 +330,7 @@ class LiteSpeed_Cache_Optimize
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' ) ;
@@ -368,12 +340,7 @@ class LiteSpeed_Cache_Optimize
368
  do_action( 'litespeed_optm' ) ;
369
 
370
  // Parse css from content
371
- $ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
372
- if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
373
- // To remove google fonts
374
- if ( $ggfonts_rm ) {
375
- $this->css_to_be_removed[] = 'fonts.googleapis.com' ;
376
- }
377
  list( $src_list, $html_list ) = $this->_handle_css() ;
378
  }
379
 
@@ -457,23 +424,6 @@ class LiteSpeed_Cache_Optimize
457
 
458
  }
459
 
460
- // Handle google fonts async
461
- if ( ! $this->cfg_css_async && $this->cfg_ggfonts_async ) {
462
- foreach ( $html_list as $k => $v ) {
463
- if ( strpos( $src_list[ $k ], 'fonts.googleapis.com' ) === false ) {
464
- unset( $html_list[ $k ] ) ;
465
- continue ;
466
- }
467
-
468
- LiteSpeed_Cache_Log::debug( '[Optm] google fonts async loading: ' . $src_list[ $k ] ) ;
469
- }
470
- // async html
471
- $html_list_async = $this->_async_css_list( $html_list ) ;
472
-
473
- // Replace async css
474
- $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
475
- }
476
-
477
  // Parse js from buffer as needed
478
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
479
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
@@ -597,21 +547,23 @@ class LiteSpeed_Cache_Optimize
597
 
598
 
599
  // Append async compatibility lib to head
600
- if ( $this->cfg_css_async || $this->cfg_ggfonts_async ) {
601
  // Inline css async lib
602
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE ) ) {
603
- $this->html_head .= '<script id="litespeed-css-async-lib" type="text/javascript">' . Litespeed_File::read( LSCWP_DIR . self::CSS_ASYNC_LIB_FILE ) . '</script>' ;
604
  }
605
  else {
606
- $css_async_lib_url = LiteSpeed_Cache_Utility::get_permalink_url( self::CSS_ASYNC_LIB ) ;
607
  $this->html_head .= "<script id='litespeed-css-async-lib' src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
608
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
609
  }
610
  }
611
 
612
- if ( $this->cfg_ggfonts_async ) {
613
- $this->html_head .= '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
614
- }
 
 
615
 
616
  // Replace html head part
617
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
@@ -642,6 +594,69 @@ class LiteSpeed_Cache_Optimize
642
 
643
  }
644
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
645
  /**
646
  * Prefetch DNS
647
  *
@@ -650,7 +665,7 @@ class LiteSpeed_Cache_Optimize
650
  */
651
  private function _dns_prefetch_init()
652
  {
653
- $this->dns_prefetch = get_option( LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ) ;
654
  if ( ! $this->dns_prefetch ) {
655
  return ;
656
  }
@@ -675,7 +690,7 @@ class LiteSpeed_Cache_Optimize
675
  return $urls ;
676
  }
677
 
678
- foreach ( explode( "\n", $this->dns_prefetch ) as $v ) {
679
  if ( $v ) {
680
  $urls[] = $v ;
681
  }
@@ -692,7 +707,7 @@ class LiteSpeed_Cache_Optimize
692
  */
693
  public function dns_prefetch_output()
694
  {
695
- foreach ( explode( "\n", $this->dns_prefetch ) as $v ) {
696
  if ( $v ) {
697
  $this->html_head .= "<link rel='dns-prefetch' href='$v' />" ;
698
  }
@@ -988,7 +1003,7 @@ class LiteSpeed_Cache_Optimize
988
  $excludes = explode( "\n", $excludes ) ;
989
  }
990
 
991
- $this->css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', $this->css_to_be_removed ) ;
992
 
993
  $src_list = array() ;
994
  $html_list = array() ;
@@ -1024,13 +1039,32 @@ class LiteSpeed_Cache_Optimize
1024
  }
1025
 
1026
  // Check if need to remove this css
1027
- if ( $this->css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $this->css_to_be_removed ) ) {
1028
  LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] ) ;
1029
  // Delete this css snippet from orig html
1030
  $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
 
1031
  continue ;
1032
  }
1033
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1034
  // to avoid multiple replacement
1035
  if ( in_array( $match[ 0 ], $html_list ) ) {
1036
  continue ;
18
  private static $_instance ;
19
 
20
  const DIR_MIN = '/min' ;
21
+ const LIB_FILE_CSS_ASYNC = 'js/css_async.min.js' ;
22
+ const LIB_FILE_WEBFONTLOADER = 'js/webfontloader.min.js' ;
23
 
24
  private $content ;
25
  private $http2_headers = array() ;
38
  private $cfg_ggfonts_async ;
39
  private $cfg_optm_max_size ;
40
  private $cfg_ttl ;
41
+ private $cfg_ggfonts_rm ;
42
 
43
  private $dns_prefetch ;
44
+ private $_ggfonts_urls = array() ;
45
 
46
  private $html_foot = '' ; // The html info append to <body>
47
  private $html_head = '' ; // The html info prepend to <body>
 
48
 
49
  private $minify_cache ;
50
  private $minify_minify ;
91
  * @since 1.5
92
  */
93
  if ( $this->cfg_js_defer ) {
94
+ $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_OPTM_JS_DEFER_EXC ) ) ;
 
 
 
95
  }
96
 
97
  /**
159
  $this->cfg_js_combine = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_JS_COMBINE ) ;
160
  $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
161
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  // If not turn on min files
163
  if ( ! $this->cfg_css_minify && ! $this->cfg_css_combine && ! $this->cfg_js_minify && ! $this->cfg_js_combine ) {
164
  return ;
330
  $this->cfg_ggfonts_async = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_ASYNC ) ;
331
  $this->cfg_ttl = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTIMIZE_TTL ) ;
332
  $this->cfg_optm_max_size = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_MAX_SIZE ) * 1000000 ;
333
+ $this->cfg_ggfonts_rm = LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPID_OPTM_GGFONTS_RM ) ;
334
 
335
  if ( ! LiteSpeed_Cache_Router::can_optm() ) {
336
  LiteSpeed_Cache_Log::debug( '[Optm] bypass: admin/feed/preview' ) ;
340
  do_action( 'litespeed_optm' ) ;
341
 
342
  // Parse css from content
343
+ if ( $this->cfg_css_minify || $this->cfg_css_combine || $this->cfg_http2_css || $this->cfg_ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async ) {
 
 
 
 
 
344
  list( $src_list, $html_list ) = $this->_handle_css() ;
345
  }
346
 
424
 
425
  }
426
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  // Parse js from buffer as needed
428
  if ( $this->cfg_js_minify || $this->cfg_js_combine || $this->cfg_http2_js || $this->cfg_js_defer ) {
429
  list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
547
 
548
 
549
  // Append async compatibility lib to head
550
+ if ( $this->cfg_css_async ) {
551
  // Inline css async lib
552
  if ( LiteSpeed_Cache::config( LiteSpeed_Cache_Config::OPT_OPTM_CSS_ASYNC_INLINE ) ) {
553
+ $this->html_head .= '<script id="litespeed-css-async-lib" type="text/javascript">' . Litespeed_File::read( LSCWP_DIR . self::LIB_FILE_CSS_ASYNC ) . '</script>' ;
554
  }
555
  else {
556
+ $css_async_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_CSS_ASYNC ;
557
  $this->html_head .= "<script id='litespeed-css-async-lib' src='" . $css_async_lib_url . "' " . ( $this->cfg_js_defer ? 'defer' : '' ) . "></script>" ;// Don't exclude it from defer for now
558
  $this->append_http2( $css_async_lib_url, 'js' ) ; // async lib will be http/2 pushed always
559
  }
560
  }
561
 
562
+ /**
563
+ * Handle google fonts async
564
+ * This will result in a JS snippet in head, so need to put it in the end to avoid being replaced by JS parser
565
+ */
566
+ $this->_async_ggfonts() ;
567
 
568
  // Replace html head part
569
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head ) ;
594
 
595
  }
596
 
597
+ /**
598
+ * Google font async
599
+ *
600
+ * @since 2.7.3
601
+ * @access private
602
+ */
603
+ private function _async_ggfonts()
604
+ {
605
+ if ( ! $this->cfg_ggfonts_async || ! $this->_ggfonts_urls ) {
606
+ return ;
607
+ }
608
+
609
+ LiteSpeed_Cache_Log::debug( '[Optm] google fonts async found: ', $this->_ggfonts_urls ) ;
610
+
611
+ $html = '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
612
+
613
+ /**
614
+ * Append fonts
615
+ *
616
+ * Could be multiple fonts
617
+ *
618
+ * <link rel='stylesheet' href='//fonts.googleapis.com/css?family=Open+Sans%3A400%2C600%2C700%2C800%2C300&#038;ver=4.9.8' type='text/css' media='all' />
619
+ * <link rel='stylesheet' href='//fonts.googleapis.com/css?family=PT+Sans%3A400%2C700%7CPT+Sans+Narrow%3A400%7CMontserrat%3A600&#038;subset=latin&#038;ver=4.9.8' type='text/css' media='all' />
620
+ * -> family: PT Sans:400,700|PT Sans Narrow:400|Montserrat:600
621
+ * <link rel='stylesheet' href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,300italic,400italic,600,700,900&#038;subset=latin%2Clatin-ext' />
622
+ */
623
+ $html .='<script type="text/javascript">WebFontConfig={google:{families:[' ;
624
+
625
+ $families = array() ;
626
+ foreach ( $this->_ggfonts_urls as $v ) {
627
+ $qs = wp_specialchars_decode( $v ) ;
628
+ $qs = urldecode( $qs ) ;
629
+ $qs = parse_url( $qs, PHP_URL_QUERY ) ;
630
+ parse_str( $qs, $qs ) ;
631
+
632
+ if ( empty( $qs[ 'family' ] ) ) {
633
+ LiteSpeed_Cache_Log::debug( '[Optm] ERR ggfonts failed to find family: ' . $v ) ;
634
+ continue ;
635
+ }
636
+
637
+ $subset = empty( $qs[ 'subset' ] ) ? '' : ':' . $qs[ 'subset' ] ;
638
+
639
+ foreach ( array_filter( explode( '|', $qs[ 'family' ] ) ) as $v2 ) {
640
+ $families[] = $v2 . $subset ;
641
+ }
642
+
643
+ }
644
+
645
+ $html .= "'" . implode( "','", $families ) . "'" ;
646
+
647
+ $html .= ']}};</script>' ;
648
+
649
+ // https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js
650
+ $webfont_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_WEBFONTLOADER ;
651
+
652
+ $html .= '<script id="litespeed-webfont-lib" src="' . $webfont_lib_url . '" async></script>' ;
653
+ $this->append_http2( $webfont_lib_url, 'js' ) ; // async lib will be http/2 pushed always
654
+
655
+ // Put this in the very beginning for preconnect
656
+ $this->html_head = $html . $this->html_head ;
657
+
658
+ }
659
+
660
  /**
661
  * Prefetch DNS
662
  *
665
  */
666
  private function _dns_prefetch_init()
667
  {
668
+ $this->dns_prefetch = LiteSpeed_Cache_Config::get_instance()->get_item( LiteSpeed_Cache_Config::ITEM_DNS_PREFETCH ) ;
669
  if ( ! $this->dns_prefetch ) {
670
  return ;
671
  }
690
  return $urls ;
691
  }
692
 
693
+ foreach ( $this->dns_prefetch as $v ) {
694
  if ( $v ) {
695
  $urls[] = $v ;
696
  }
707
  */
708
  public function dns_prefetch_output()
709
  {
710
+ foreach ( $this->dns_prefetch as $v ) {
711
  if ( $v ) {
712
  $this->html_head .= "<link rel='dns-prefetch' href='$v' />" ;
713
  }
1003
  $excludes = explode( "\n", $excludes ) ;
1004
  }
1005
 
1006
+ $css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', array() ) ;
1007
 
1008
  $src_list = array() ;
1009
  $html_list = array() ;
1039
  }
1040
 
1041
  // Check if need to remove this css
1042
+ if ( $css_to_be_removed && LiteSpeed_Cache_Utility::str_hit_array( $attrs[ 'href' ], $css_to_be_removed ) ) {
1043
  LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] ) ;
1044
  // Delete this css snippet from orig html
1045
  $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1046
+
1047
  continue ;
1048
  }
1049
 
1050
+ // Check Google fonts hit
1051
+ if ( $this->cfg_ggfonts_rm || $this->cfg_ggfonts_async ) {
1052
+ if ( strpos( $attrs[ 'href' ], 'fonts.googleapis.com' ) !== false ) {
1053
+ LiteSpeed_Cache_Log::debug( '[Optm] rm css snippet [Google fonts] ' . $attrs[ 'href' ] ) ;
1054
+ $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1055
+
1056
+ /**
1057
+ * For async gg fonts, will add webfont into head, hence remove it from buffer and store the matches to use later
1058
+ * @since 2.7.3
1059
+ */
1060
+ if ( $this->cfg_ggfonts_async ) {
1061
+ $this->_ggfonts_urls[] = $attrs[ 'href' ] ;
1062
+ }
1063
+
1064
+ continue ;
1065
+ }
1066
+ }
1067
+
1068
  // to avoid multiple replacement
1069
  if ( in_array( $match[ 0 ], $html_list ) ) {
1070
  continue ;
includes/litespeed-cache-purge.class.php CHANGED
@@ -927,6 +927,7 @@ class LiteSpeed_Cache_Purge
927
 
928
  // for archive of categories|tags|custom tax
929
  global $post ;
 
930
  $post = get_post($post_id) ;
931
  $post_type = $post->post_type ;
932
 
@@ -1012,6 +1013,9 @@ class LiteSpeed_Cache_Purge
1012
  $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
1013
  }
1014
 
 
 
 
1015
  return array_unique($purge_tags) ;
1016
  }
1017
 
927
 
928
  // for archive of categories|tags|custom tax
929
  global $post ;
930
+ $original_post = $post ;
931
  $post = get_post($post_id) ;
932
  $post_type = $post->post_type ;
933
 
1013
  $purge_tags[] = LiteSpeed_Cache_Tag::TYPE_ARCHIVE_DATE . date('Y', $date) ;
1014
  }
1015
 
1016
+ // Set back to original post as $post_id might affecting the global $post value
1017
+ $post = $original_post ;
1018
+
1019
  return array_unique($purge_tags) ;
1020
  }
1021
 
includes/litespeed-cache-router.class.php CHANGED
@@ -108,6 +108,14 @@ class LiteSpeed_Cache_Router
108
  $can = false ;
109
  }
110
 
 
 
 
 
 
 
 
 
111
  /**
112
  * Bypass login/reg page
113
  * @since 1.6
108
  $can = false ;
109
  }
110
 
111
+ /**
112
+ * Bypass cron to avoid deregister jq notice `Do not deregister the <code>jquery-core</code> script in the administration area.`
113
+ * @since 2.7.2
114
+ */
115
+ if ( defined( 'DOING_CRON' ) ) {
116
+ $can = false ;
117
+ }
118
+
119
  /**
120
  * Bypass login/reg page
121
  * @since 1.6
includes/litespeed-cache-vary.class.php CHANGED
@@ -534,19 +534,32 @@ class LiteSpeed_Cache_Vary
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
 
@@ -555,16 +568,17 @@ class LiteSpeed_Cache_Vary
555
  * This is to add a new vary cookie
556
  *
557
  * @since 1.0.13
 
558
  * @access public
559
  * @param mixed $vary A string or array of vary cookies to add to the current list.
560
  */
561
- public static function add($vary)
562
  {
563
- if ( ! is_array($vary) ) {
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
  }
534
  */
535
  private function _format_vary_cookies()
536
  {
537
+ /**
538
+ * To add new varys, use hook `API::filter_vary_cookies()` before here
539
+ */
540
  do_action( 'litespeed_vary_add' ) ;
541
 
542
+ /**
543
+ * Give a filter to manipulate vary
544
+ * @since 2.7.1
545
+ */
546
+ $cookies = apply_filters( 'litespeed_vary_cookies', self::$_vary_cookies ) ;
547
+ if ( $cookies !== self::$_vary_cookies ) {
548
+ LiteSpeed_Cache_Log::debug( '[Vary] vary changed by filter [Old] ' . var_export( self::$_vary_cookies, true ) . ' [New] ' . var_export( $cookies, true ) ) ;
549
  }
550
+
551
+ if ( ! empty( $cookies ) ) {
552
+ $cookies = array_filter( array_unique( $cookies ) ) ;
553
+ }
554
+
555
  if ( empty($cookies) ) {
556
  return false ;
557
  }
558
+
559
  foreach ($cookies as $key => $val) {
560
  $cookies[$key] = 'cookie=' . $val ;
561
  }
562
+
563
  return $cookies ;
564
  }
565
 
568
  * This is to add a new vary cookie
569
  *
570
  * @since 1.0.13
571
+ * @deprecated 2.7.1 Use filter `litespeed_vary_cookies` instead.
572
  * @access public
573
  * @param mixed $vary A string or array of vary cookies to add to the current list.
574
  */
575
+ public static function add( $vary )
576
  {
577
+ if ( ! is_array( $vary ) ) {
578
+ $vary = array( $vary ) ;
579
  }
580
 
581
+ error_log( 'Deprecated since LSCWP 2.7.1! [Vary] Add new vary ' . var_export( $vary, true ) ) ;
582
 
583
  self::$_vary_cookies = array_merge(self::$_vary_cookies, $vary) ;
584
  }
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.7' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
@@ -104,14 +104,18 @@ class LiteSpeed_Cache
104
  define( 'LITESPEED_DISABLE_ALL', true ) ;
105
  }
106
 
107
- // Register plugin activate/deactivate/uninstall hooks
108
- // NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
109
- if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
110
- $plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
111
- register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
112
- register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
113
- register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
114
- }
 
 
 
 
115
 
116
  add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
117
 
@@ -156,6 +160,9 @@ class LiteSpeed_Cache
156
  */
157
  do_action( 'litespeed_init' ) ;
158
 
 
 
 
159
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
160
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
161
  }
@@ -223,6 +230,39 @@ class LiteSpeed_Cache
223
 
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  /**
227
  * Run frontend actions
228
  *
25
 
26
  const NAME = 'LiteSpeed Cache' ;
27
  const PLUGIN_NAME = 'litespeed-cache' ;
28
+ const PLUGIN_VERSION = '2.7.3' ;
29
 
30
  const PAGE_EDIT_HTACCESS = 'lscache-edit-htaccess' ;
31
 
104
  define( 'LITESPEED_DISABLE_ALL', true ) ;
105
  }
106
 
107
+ /**
108
+ * Register plugin activate/deactivate/uninstall hooks
109
+ * NOTE: this can't be moved under after_setup_theme, otherwise activation will be bypassed somehow
110
+ *
111
+ * @since 2.7.1 Disabled admin&CLI check to make frontend able to enable cache too
112
+ */
113
+ // if( is_admin() || defined( 'LITESPEED_CLI' ) ) {
114
+ $plugin_file = LSCWP_DIR . 'litespeed-cache.php' ;
115
+ register_activation_hook( $plugin_file, array( 'LiteSpeed_Cache_Activation', 'register_activation' ) ) ;
116
+ register_deactivation_hook( $plugin_file, array('LiteSpeed_Cache_Activation', 'register_deactivation' ) ) ;
117
+ register_uninstall_hook( $plugin_file, 'LiteSpeed_Cache_Activation::uninstall_litespeed_cache' ) ;
118
+ // }
119
 
120
  add_action( 'after_setup_theme', array( $this, 'init' ) ) ;
121
 
160
  */
161
  do_action( 'litespeed_init' ) ;
162
 
163
+ // in `after_setup_theme`, before `init` hook
164
+ $this->_auto_update() ;
165
+
166
  if ( ! self::config( LiteSpeed_Cache_Config::OPID_HEARTBEAT ) ) {
167
  add_action( 'init', 'LiteSpeed_Cache_Log::disable_heartbeat', 1 ) ;
168
  }
230
 
231
  }
232
 
233
+ /**
234
+ * Handle auto update
235
+ *
236
+ * @since 2.7.2
237
+ * @access private
238
+ */
239
+ private function _auto_update()
240
+ {
241
+ if ( ! self::config( LiteSpeed_Cache_Config::OPT_AUTO_UPGRADE ) ) {
242
+ return ;
243
+ }
244
+
245
+ add_filter( 'auto_update_plugin', function( $update, $item ) {
246
+ if ( $item->slug == 'litespeed-cache' ) {
247
+ // Check latest stable version allowed to upgrade
248
+ $url = 'https://wp.api.litespeedtech.com/auto_upgrade_v' ;
249
+ $response = wp_remote_get( $url, array( 'timeout' => 15 ) ) ;
250
+ if ( ! is_array( $response ) || empty( $response[ 'body' ] ) ) {
251
+ return false ;
252
+ }
253
+ $auto_v = $response[ 'body' ] ;
254
+
255
+ if ( empty( $item->new_version ) || $auto_v !== $item->new_version ) {
256
+ return false ;
257
+ }
258
+
259
+ return true ;
260
+ }
261
+
262
+ return $update; // Else, use the normal API response to decide whether to update or not
263
+ }, 10, 2 ) ;
264
+ }
265
+
266
  /**
267
  * Run frontend actions
268
  *
js/webfontloader.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Web Font Loader v1.6.28 - (c) Adobe Systems, Google. License: Apache 2.0 */(function(){function aa(a,b,c){return a.call.apply(a.bind,arguments)}function ba(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}}function p(a,b,c){p=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?aa:ba;return p.apply(null,arguments)}var q=Date.now||function(){return+new Date};function ca(a,b){this.a=a;this.o=b||a;this.c=this.o.document}var da=!!window.FontFace;function t(a,b,c,d){b=a.c.createElement(b);if(c)for(var e in c)c.hasOwnProperty(e)&&("style"==e?b.style.cssText=c[e]:b.setAttribute(e,c[e]));d&&b.appendChild(a.c.createTextNode(d));return b}function u(a,b,c){a=a.c.getElementsByTagName(b)[0];a||(a=document.documentElement);a.insertBefore(c,a.lastChild)}function v(a){a.parentNode&&a.parentNode.removeChild(a)}
2
+ function w(a,b,c){b=b||[];c=c||[];for(var d=a.className.split(/\s+/),e=0;e<b.length;e+=1){for(var f=!1,g=0;g<d.length;g+=1)if(b[e]===d[g]){f=!0;break}f||d.push(b[e])}b=[];for(e=0;e<d.length;e+=1){f=!1;for(g=0;g<c.length;g+=1)if(d[e]===c[g]){f=!0;break}f||b.push(d[e])}a.className=b.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function y(a,b){for(var c=a.className.split(/\s+/),d=0,e=c.length;d<e;d++)if(c[d]==b)return!0;return!1}
3
+ function ea(a){return a.o.location.hostname||a.a.location.hostname}function z(a,b,c){function d(){m&&e&&f&&(m(g),m=null)}b=t(a,"link",{rel:"stylesheet",href:b,media:"all"});var e=!1,f=!0,g=null,m=c||null;da?(b.onload=function(){e=!0;d()},b.onerror=function(){e=!0;g=Error("Stylesheet failed to load");d()}):setTimeout(function(){e=!0;d()},0);u(a,"head",b)}
4
+ function A(a,b,c,d){var e=a.c.getElementsByTagName("head")[0];if(e){var f=t(a,"script",{src:b}),g=!1;f.onload=f.onreadystatechange=function(){g||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(g=!0,c&&c(null),f.onload=f.onreadystatechange=null,"HEAD"==f.parentNode.tagName&&e.removeChild(f))};e.appendChild(f);setTimeout(function(){g||(g=!0,c&&c(Error("Script load timeout")))},d||5E3);return f}return null};function B(){this.a=0;this.c=null}function C(a){a.a++;return function(){a.a--;D(a)}}function E(a,b){a.c=b;D(a)}function D(a){0==a.a&&a.c&&(a.c(),a.c=null)};function F(a){this.a=a||"-"}F.prototype.c=function(a){for(var b=[],c=0;c<arguments.length;c++)b.push(arguments[c].replace(/[\W_]+/g,"").toLowerCase());return b.join(this.a)};function G(a,b){this.c=a;this.f=4;this.a="n";var c=(b||"n4").match(/^([nio])([1-9])$/i);c&&(this.a=c[1],this.f=parseInt(c[2],10))}function fa(a){return H(a)+" "+(a.f+"00")+" 300px "+I(a.c)}function I(a){var b=[];a=a.split(/,\s*/);for(var c=0;c<a.length;c++){var d=a[c].replace(/['"]/g,"");-1!=d.indexOf(" ")||/^\d/.test(d)?b.push("'"+d+"'"):b.push(d)}return b.join(",")}function J(a){return a.a+a.f}function H(a){var b="normal";"o"===a.a?b="oblique":"i"===a.a&&(b="italic");return b}
5
+ function ga(a){var b=4,c="n",d=null;a&&((d=a.match(/(normal|oblique|italic)/i))&&d[1]&&(c=d[1].substr(0,1).toLowerCase()),(d=a.match(/([1-9]00|normal|bold)/i))&&d[1]&&(/bold/i.test(d[1])?b=7:/[1-9]00/.test(d[1])&&(b=parseInt(d[1].substr(0,1),10))));return c+b};function ha(a,b){this.c=a;this.f=a.o.document.documentElement;this.h=b;this.a=new F("-");this.j=!1!==b.events;this.g=!1!==b.classes}function ia(a){a.g&&w(a.f,[a.a.c("wf","loading")]);K(a,"loading")}function L(a){if(a.g){var b=y(a.f,a.a.c("wf","active")),c=[],d=[a.a.c("wf","loading")];b||c.push(a.a.c("wf","inactive"));w(a.f,c,d)}K(a,"inactive")}function K(a,b,c){if(a.j&&a.h[b])if(c)a.h[b](c.c,J(c));else a.h[b]()};function ja(){this.c={}}function ka(a,b,c){var d=[],e;for(e in b)if(b.hasOwnProperty(e)){var f=a.c[e];f&&d.push(f(b[e],c))}return d};function M(a,b){this.c=a;this.f=b;this.a=t(this.c,"span",{"aria-hidden":"true"},this.f)}function N(a){u(a.c,"body",a.a)}function O(a){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+I(a.c)+";"+("font-style:"+H(a)+";font-weight:"+(a.f+"00")+";")};function P(a,b,c,d,e,f){this.g=a;this.j=b;this.a=d;this.c=c;this.f=e||3E3;this.h=f||void 0}P.prototype.start=function(){var a=this.c.o.document,b=this,c=q(),d=new Promise(function(d,e){function f(){q()-c>=b.f?e():a.fonts.load(fa(b.a),b.h).then(function(a){1<=a.length?d():setTimeout(f,25)},function(){e()})}f()}),e=null,f=new Promise(function(a,d){e=setTimeout(d,b.f)});Promise.race([f,d]).then(function(){e&&(clearTimeout(e),e=null);b.g(b.a)},function(){b.j(b.a)})};function Q(a,b,c,d,e,f,g){this.v=a;this.B=b;this.c=c;this.a=d;this.s=g||"BESbswy";this.f={};this.w=e||3E3;this.u=f||null;this.m=this.j=this.h=this.g=null;this.g=new M(this.c,this.s);this.h=new M(this.c,this.s);this.j=new M(this.c,this.s);this.m=new M(this.c,this.s);a=new G(this.a.c+",serif",J(this.a));a=O(a);this.g.a.style.cssText=a;a=new G(this.a.c+",sans-serif",J(this.a));a=O(a);this.h.a.style.cssText=a;a=new G("serif",J(this.a));a=O(a);this.j.a.style.cssText=a;a=new G("sans-serif",J(this.a));a=
6
+ O(a);this.m.a.style.cssText=a;N(this.g);N(this.h);N(this.j);N(this.m)}var R={D:"serif",C:"sans-serif"},S=null;function T(){if(null===S){var a=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);S=!!a&&(536>parseInt(a[1],10)||536===parseInt(a[1],10)&&11>=parseInt(a[2],10))}return S}Q.prototype.start=function(){this.f.serif=this.j.a.offsetWidth;this.f["sans-serif"]=this.m.a.offsetWidth;this.A=q();U(this)};
7
+ function la(a,b,c){for(var d in R)if(R.hasOwnProperty(d)&&b===a.f[R[d]]&&c===a.f[R[d]])return!0;return!1}function U(a){var b=a.g.a.offsetWidth,c=a.h.a.offsetWidth,d;(d=b===a.f.serif&&c===a.f["sans-serif"])||(d=T()&&la(a,b,c));d?q()-a.A>=a.w?T()&&la(a,b,c)&&(null===a.u||a.u.hasOwnProperty(a.a.c))?V(a,a.v):V(a,a.B):ma(a):V(a,a.v)}function ma(a){setTimeout(p(function(){U(this)},a),50)}function V(a,b){setTimeout(p(function(){v(this.g.a);v(this.h.a);v(this.j.a);v(this.m.a);b(this.a)},a),0)};function W(a,b,c){this.c=a;this.a=b;this.f=0;this.m=this.j=!1;this.s=c}var X=null;W.prototype.g=function(a){var b=this.a;b.g&&w(b.f,[b.a.c("wf",a.c,J(a).toString(),"active")],[b.a.c("wf",a.c,J(a).toString(),"loading"),b.a.c("wf",a.c,J(a).toString(),"inactive")]);K(b,"fontactive",a);this.m=!0;na(this)};
8
+ W.prototype.h=function(a){var b=this.a;if(b.g){var c=y(b.f,b.a.c("wf",a.c,J(a).toString(),"active")),d=[],e=[b.a.c("wf",a.c,J(a).toString(),"loading")];c||d.push(b.a.c("wf",a.c,J(a).toString(),"inactive"));w(b.f,d,e)}K(b,"fontinactive",a);na(this)};function na(a){0==--a.f&&a.j&&(a.m?(a=a.a,a.g&&w(a.f,[a.a.c("wf","active")],[a.a.c("wf","loading"),a.a.c("wf","inactive")]),K(a,"active")):L(a.a))};function oa(a){this.j=a;this.a=new ja;this.h=0;this.f=this.g=!0}oa.prototype.load=function(a){this.c=new ca(this.j,a.context||this.j);this.g=!1!==a.events;this.f=!1!==a.classes;pa(this,new ha(this.c,a),a)};
9
+ function qa(a,b,c,d,e){var f=0==--a.h;(a.f||a.g)&&setTimeout(function(){var a=e||null,m=d||null||{};if(0===c.length&&f)L(b.a);else{b.f+=c.length;f&&(b.j=f);var h,l=[];for(h=0;h<c.length;h++){var k=c[h],n=m[k.c],r=b.a,x=k;r.g&&w(r.f,[r.a.c("wf",x.c,J(x).toString(),"loading")]);K(r,"fontloading",x);r=null;if(null===X)if(window.FontFace){var x=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),xa=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);
10
+ X=x?42<parseInt(x[1],10):xa?!1:!0}else X=!1;X?r=new P(p(b.g,b),p(b.h,b),b.c,k,b.s,n):r=new Q(p(b.g,b),p(b.h,b),b.c,k,b.s,a,n);l.push(r)}for(h=0;h<l.length;h++)l[h].start()}},0)}function pa(a,b,c){var d=[],e=c.timeout;ia(b);var d=ka(a.a,c,a.c),f=new W(a.c,b,e);a.h=d.length;b=0;for(c=d.length;b<c;b++)d[b].load(function(b,d,c){qa(a,f,b,d,c)})};function ra(a,b){this.c=a;this.a=b}
11
+ ra.prototype.load=function(a){function b(){if(f["__mti_fntLst"+d]){var c=f["__mti_fntLst"+d](),e=[],h;if(c)for(var l=0;l<c.length;l++){var k=c[l].fontfamily;void 0!=c[l].fontStyle&&void 0!=c[l].fontWeight?(h=c[l].fontStyle+c[l].fontWeight,e.push(new G(k,h))):e.push(new G(k))}a(e)}else setTimeout(function(){b()},50)}var c=this,d=c.a.projectId,e=c.a.version;if(d){var f=c.c.o;A(this.c,(c.a.api||"https://fast.fonts.net/jsapi")+"/"+d+".js"+(e?"?v="+e:""),function(e){e?a([]):(f["__MonotypeConfiguration__"+
12
+ d]=function(){return c.a},b())}).id="__MonotypeAPIScript__"+d}else a([])};function sa(a,b){this.c=a;this.a=b}sa.prototype.load=function(a){var b,c,d=this.a.urls||[],e=this.a.families||[],f=this.a.testStrings||{},g=new B;b=0;for(c=d.length;b<c;b++)z(this.c,d[b],C(g));var m=[];b=0;for(c=e.length;b<c;b++)if(d=e[b].split(":"),d[1])for(var h=d[1].split(","),l=0;l<h.length;l+=1)m.push(new G(d[0],h[l]));else m.push(new G(d[0]));E(g,function(){a(m,f)})};function ta(a,b){a?this.c=a:this.c=ua;this.a=[];this.f=[];this.g=b||""}var ua="https://fonts.googleapis.com/css";function va(a,b){for(var c=b.length,d=0;d<c;d++){var e=b[d].split(":");3==e.length&&a.f.push(e.pop());var f="";2==e.length&&""!=e[1]&&(f=":");a.a.push(e.join(f))}}
13
+ function wa(a){if(0==a.a.length)throw Error("No fonts to load!");if(-1!=a.c.indexOf("kit="))return a.c;for(var b=a.a.length,c=[],d=0;d<b;d++)c.push(a.a[d].replace(/ /g,"+"));b=a.c+"?family="+c.join("%7C");0<a.f.length&&(b+="&subset="+a.f.join(","));0<a.g.length&&(b+="&text="+encodeURIComponent(a.g));return b};function ya(a){this.f=a;this.a=[];this.c={}}
14
+ var za={latin:"BESbswy","latin-ext":"\u00e7\u00f6\u00fc\u011f\u015f",cyrillic:"\u0439\u044f\u0416",greek:"\u03b1\u03b2\u03a3",khmer:"\u1780\u1781\u1782",Hanuman:"\u1780\u1781\u1782"},Aa={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},Ba={i:"i",italic:"i",n:"n",normal:"n"},
15
+ Ca=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;
16
+ function Da(a){for(var b=a.f.length,c=0;c<b;c++){var d=a.f[c].split(":"),e=d[0].replace(/\+/g," "),f=["n4"];if(2<=d.length){var g;var m=d[1];g=[];if(m)for(var m=m.split(","),h=m.length,l=0;l<h;l++){var k;k=m[l];if(k.match(/^[\w-]+$/)){var n=Ca.exec(k.toLowerCase());if(null==n)k="";else{k=n[2];k=null==k||""==k?"n":Ba[k];n=n[1];if(null==n||""==n)n="4";else var r=Aa[n],n=r?r:isNaN(n)?"4":n.substr(0,1);k=[k,n].join("")}}else k="";k&&g.push(k)}0<g.length&&(f=g);3==d.length&&(d=d[2],g=[],d=d?d.split(","):
17
+ g,0<d.length&&(d=za[d[0]])&&(a.c[e]=d))}a.c[e]||(d=za[e])&&(a.c[e]=d);for(d=0;d<f.length;d+=1)a.a.push(new G(e,f[d]))}};function Ea(a,b){this.c=a;this.a=b}var Fa={Arimo:!0,Cousine:!0,Tinos:!0};Ea.prototype.load=function(a){var b=new B,c=this.c,d=new ta(this.a.api,this.a.text),e=this.a.families;va(d,e);var f=new ya(e);Da(f);z(c,wa(d),C(b));E(b,function(){a(f.a,f.c,Fa)})};function Ga(a,b){this.c=a;this.a=b}Ga.prototype.load=function(a){var b=this.a.id,c=this.c.o;b?A(this.c,(this.a.api||"https://use.typekit.net")+"/"+b+".js",function(b){if(b)a([]);else if(c.Typekit&&c.Typekit.config&&c.Typekit.config.fn){b=c.Typekit.config.fn;for(var e=[],f=0;f<b.length;f+=2)for(var g=b[f],m=b[f+1],h=0;h<m.length;h++)e.push(new G(g,m[h]));try{c.Typekit.load({events:!1,classes:!1,async:!0})}catch(l){}a(e)}},2E3):a([])};function Ha(a,b){this.c=a;this.f=b;this.a=[]}Ha.prototype.load=function(a){var b=this.f.id,c=this.c.o,d=this;b?(c.__webfontfontdeckmodule__||(c.__webfontfontdeckmodule__={}),c.__webfontfontdeckmodule__[b]=function(b,c){for(var g=0,m=c.fonts.length;g<m;++g){var h=c.fonts[g];d.a.push(new G(h.name,ga("font-weight:"+h.weight+";font-style:"+h.style)))}a(d.a)},A(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+ea(this.c)+"/"+b+".js",function(b){b&&a([])})):a([])};var Y=new oa(window);Y.a.c.custom=function(a,b){return new sa(b,a)};Y.a.c.fontdeck=function(a,b){return new Ha(b,a)};Y.a.c.monotype=function(a,b){return new ra(b,a)};Y.a.c.typekit=function(a,b){return new Ga(b,a)};Y.a.c.google=function(a,b){return new Ea(b,a)};var Z={load:p(Y.load,Y)};"function"===typeof define&&define.amd?define(function(){return Z}):"undefined"!==typeof module&&module.exports?module.exports=Z:(window.WebFont=Z,window.WebFontConfig&&Y.load(window.WebFontConfig));}());
js/webfontloader.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(){function e(t,n,i){return t.call.apply(t.bind,arguments)}function o(n,i,t){if(!n)throw Error();if(2<arguments.length){var e=Array.prototype.slice.call(arguments,2);return function(){var t=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(t,e),n.apply(i,t)}}return function(){return n.apply(i,arguments)}}function d(t,n,i){return(d=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?e:o).apply(null,arguments)}var r=Date.now||function(){return+new Date};function n(t,n){this.a=t,this.o=n||t,this.c=this.o.document}var f=!!window.FontFace;function c(t,n,i,e){if(n=t.c.createElement(n),i)for(var o in i)i.hasOwnProperty(o)&&("style"==o?n.style.cssText=i[o]:n.setAttribute(o,i[o]));return e&&n.appendChild(t.c.createTextNode(e)),n}function h(t,n,i){(t=t.c.getElementsByTagName(n)[0])||(t=document.documentElement),t.insertBefore(i,t.lastChild)}function i(t){t.parentNode&&t.parentNode.removeChild(t)}function g(t,n,i){n=n||[],i=i||[];for(var e=t.className.split(/\s+/),o=0;o<n.length;o+=1){for(var a=!1,s=0;s<e.length;s+=1)if(n[o]===e[s]){a=!0;break}a||e.push(n[o])}for(n=[],o=0;o<e.length;o+=1){for(a=!1,s=0;s<i.length;s+=1)if(e[o]===i[s]){a=!0;break}a||n.push(e[o])}t.className=n.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function a(t,n){for(var i=t.className.split(/\s+/),e=0,o=i.length;e<o;e++)if(i[e]==n)return!0;return!1}function l(t,n,i){function e(){s&&o&&(s(a),s=null)}n=c(t,"link",{rel:"stylesheet",href:n,media:"all"});var o=!1,a=null,s=i||null;f?(n.onload=function(){o=!0,e()},n.onerror=function(){o=!0,a=Error("Stylesheet failed to load"),e()}):setTimeout(function(){o=!0,e()},0),h(t,"head",n)}function u(t,n,i,e){var o=t.c.getElementsByTagName("head")[0];if(o){var a=c(t,"script",{src:n}),s=!1;return a.onload=a.onreadystatechange=function(){s||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(s=!0,i&&i(null),a.onload=a.onreadystatechange=null,"HEAD"==a.parentNode.tagName&&o.removeChild(a))},o.appendChild(a),setTimeout(function(){s||(s=!0,i&&i(Error("Script load timeout")))},e||5e3),a}return null}function p(){this.a=0,this.c=null}function v(t){return t.a++,function(){t.a--,s(t)}}function w(t,n){t.c=n,s(t)}function s(t){0==t.a&&t.c&&(t.c(),t.c=null)}function m(t){this.a=t||"-"}function y(t,n){this.c=t,this.f=4,this.a="n";var i=(n||"n4").match(/^([nio])([1-9])$/i);i&&(this.a=i[1],this.f=parseInt(i[2],10))}function b(t){var n=[];t=t.split(/,\s*/);for(var i=0;i<t.length;i++){var e=t[i].replace(/['"]/g,"");-1!=e.indexOf(" ")||/^\d/.test(e)?n.push("'"+e+"'"):n.push(e)}return n.join(",")}function x(t){return t.a+t.f}function j(t){var n="normal";return"o"===t.a?n="oblique":"i"===t.a&&(n="italic"),n}function _(t,n){this.c=t,this.f=t.o.document.documentElement,this.h=n,this.a=new m("-"),this.j=!1!==n.events,this.g=!1!==n.classes}function k(t){if(t.g){var n=a(t.f,t.a.c("wf","active")),i=[],e=[t.a.c("wf","loading")];n||i.push(t.a.c("wf","inactive")),g(t.f,i,e)}T(t,"inactive")}function T(t,n,i){t.j&&t.h[n]&&(i?t.h[n](i.c,x(i)):t.h[n]())}function S(){this.c={}}function C(t,n){this.c=t,this.f=n,this.a=c(this.c,"span",{"aria-hidden":"true"},this.f)}function A(t){h(t.c,"body",t.a)}function N(t){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+b(t.c)+";font-style:"+j(t)+";font-weight:"+t.f+"00;"}function E(t,n,i,e,o,a){this.g=t,this.j=n,this.a=e,this.c=i,this.f=o||3e3,this.h=a||void 0}function W(t,n,i,e,o,a,s){this.v=t,this.B=n,this.c=i,this.a=e,this.s=s||"BESbswy",this.f={},this.w=o||3e3,this.u=a||null,this.m=this.j=this.h=this.g=null,this.g=new C(this.c,this.s),this.h=new C(this.c,this.s),this.j=new C(this.c,this.s),this.m=new C(this.c,this.s),t=N(t=new y(this.a.c+",serif",x(this.a))),this.g.a.style.cssText=t,t=N(t=new y(this.a.c+",sans-serif",x(this.a))),this.h.a.style.cssText=t,t=N(t=new y("serif",x(this.a))),this.j.a.style.cssText=t,t=N(t=new y("sans-serif",x(this.a))),this.m.a.style.cssText=t,A(this.g),A(this.h),A(this.j),A(this.m)}m.prototype.c=function(t){for(var n=[],i=0;i<arguments.length;i++)n.push(arguments[i].replace(/[\W_]+/g,"").toLowerCase());return n.join(this.a)},E.prototype.start=function(){var o=this.c.o.document,a=this,s=r(),t=new Promise(function(i,e){!function n(){var t;r()-s>=a.f?e():o.fonts.load((t=a.a,j(t)+" "+t.f+"00 300px "+b(t.c)),a.h).then(function(t){1<=t.length?i():setTimeout(n,25)},function(){e()})}()}),i=null,n=new Promise(function(t,n){i=setTimeout(n,a.f)});Promise.race([n,t]).then(function(){i&&(clearTimeout(i),i=null),a.g(a.a)},function(){a.j(a.a)})};var F={D:"serif",C:"sans-serif"},I=null;function O(){if(null===I){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);I=!!t&&(parseInt(t[1],10)<536||536===parseInt(t[1],10)&&parseInt(t[2],10)<=11)}return I}function P(t,n,i){for(var e in F)if(F.hasOwnProperty(e)&&n===t.f[F[e]]&&i===t.f[F[e]])return!0;return!1}function B(t){var n,i=t.g.a.offsetWidth,e=t.h.a.offsetWidth;(n=i===t.f.serif&&e===t.f["sans-serif"])||(n=O()&&P(t,i,e)),n?r()-t.A>=t.w?O()&&P(t,i,e)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?L(t,t.v):L(t,t.B):setTimeout(d(function(){B(this)},t),50):L(t,t.v)}function L(t,n){setTimeout(d(function(){i(this.g.a),i(this.h.a),i(this.j.a),i(this.m.a),n(this.a)},t),0)}function D(t,n,i){this.c=t,this.a=n,this.f=0,this.m=this.j=!1,this.s=i}W.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=r(),B(this)};var $=null;function q(t){0==--t.f&&t.j&&(t.m?((t=t.a).g&&g(t.f,[t.a.c("wf","active")],[t.a.c("wf","loading"),t.a.c("wf","inactive")]),T(t,"active")):k(t.a))}function t(t){this.j=t,this.a=new S,this.h=0,this.f=this.g=!0}function H(t,n){this.c=t,this.a=n}function M(t,n){this.c=t,this.a=n}function z(t,n){this.c=t||"https://fonts.googleapis.com/css",this.a=[],this.f=[],this.g=n||""}D.prototype.g=function(t){var n=this.a;n.g&&g(n.f,[n.a.c("wf",t.c,x(t).toString(),"active")],[n.a.c("wf",t.c,x(t).toString(),"loading"),n.a.c("wf",t.c,x(t).toString(),"inactive")]),T(n,"fontactive",t),this.m=!0,q(this)},D.prototype.h=function(t){var n=this.a;if(n.g){var i=a(n.f,n.a.c("wf",t.c,x(t).toString(),"active")),e=[],o=[n.a.c("wf",t.c,x(t).toString(),"loading")];i||e.push(n.a.c("wf",t.c,x(t).toString(),"inactive")),g(n.f,e,o)}T(n,"fontinactive",t),q(this)},t.prototype.load=function(t){this.c=new n(this.j,t.context||this.j),this.g=!1!==t.events,this.f=!1!==t.classes,function(o,t,n){var i=[],e=n.timeout;a=t,a.g&&g(a.f,[a.a.c("wf","loading")]),T(a,"loading");var a;var i=function(t,n,i){var e,o=[];for(e in n)if(n.hasOwnProperty(e)){var a=t.c[e];a&&o.push(a(n[e],i))}return o}(o.a,n,o.c),s=new D(o.c,t,e);for(o.h=i.length,t=0,n=i.length;t<n;t++)i[t].load(function(t,n,i){var e,c,h,l,u,p;c=s,h=t,l=n,u=i,p=0==--(e=o).h,(e.f||e.g)&&setTimeout(function(){var t=u||null,n=l||{};if(0===h.length&&p)k(c.a);else{c.f+=h.length,p&&(c.j=p);var i,e=[];for(i=0;i<h.length;i++){var o=h[i],a=n[o.c],s=c.a,r=o;if(s.g&&g(s.f,[s.a.c("wf",r.c,x(r).toString(),"loading")]),T(s,"fontloading",r),(s=null)===$)if(window.FontFace){var r=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent),f=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);$=r?42<parseInt(r[1],10):!f}else $=!1;s=$?new E(d(c.g,c),d(c.h,c),c.c,o,c.s,a):new W(d(c.g,c),d(c.h,c),c.c,o,c.s,t,a),e.push(s)}for(i=0;i<e.length;i++)e[i].start()}},0)})}(this,new _(this.c,t),t)},H.prototype.load=function(s){var n=this,r=n.a.projectId,t=n.a.version;if(r){var f=n.c.o;u(this.c,(n.a.api||"https://fast.fonts.net/jsapi")+"/"+r+".js"+(t?"?v="+t:""),function(t){t?s([]):(f["__MonotypeConfiguration__"+r]=function(){return n.a},function t(){if(f["__mti_fntLst"+r]){var n,i=f["__mti_fntLst"+r](),e=[];if(i)for(var o=0;o<i.length;o++){var a=i[o].fontfamily;null!=i[o].fontStyle&&null!=i[o].fontWeight?(n=i[o].fontStyle+i[o].fontWeight,e.push(new y(a,n))):e.push(new y(a))}s(e)}else setTimeout(function(){t()},50)}())}).id="__MonotypeAPIScript__"+r}else s([])},M.prototype.load=function(t){var n,i,e=this.a.urls||[],o=this.a.families||[],a=this.a.testStrings||{},s=new p;for(n=0,i=e.length;n<i;n++)l(this.c,e[n],v(s));var r=[];for(n=0,i=o.length;n<i;n++)if((e=o[n].split(":"))[1])for(var f=e[1].split(","),c=0;c<f.length;c+=1)r.push(new y(e[0],f[c]));else r.push(new y(e[0]));w(s,function(){t(r,a)})};function G(t){this.f=t,this.a=[],this.c={}}var K={latin:"BESbswy","latin-ext":"çöüğş",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},R={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},U={i:"i",italic:"i",n:"n",normal:"n"},V=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;function X(t,n){this.c=t,this.a=n}var J={Arimo:!0,Cousine:!0,Tinos:!0};function Q(t,n){this.c=t,this.a=n}function Y(t,n){this.c=t,this.f=n,this.a=[]}X.prototype.load=function(t){var n=new p,i=this.c,e=new z(this.a.api,this.a.text),o=this.a.families;!function(t,n){for(var i=n.length,e=0;e<i;e++){var o=n[e].split(":");3==o.length&&t.f.push(o.pop());var a="";2==o.length&&""!=o[1]&&(a=":"),t.a.push(o.join(a))}}(e,o);var a=new G(o);!function(t){for(var n=t.f.length,i=0;i<n;i++){var e=t.f[i].split(":"),o=e[0].replace(/\+/g," "),a=["n4"];if(2<=e.length){var s;if(s=[],r=e[1])for(var r,f=(r=r.split(",")).length,c=0;c<f;c++){var h;if((h=r[c]).match(/^[\w-]+$/))if(null==(u=V.exec(h.toLowerCase())))h="";else{if(h=null==(h=u[2])||""==h?"n":U[h],null==(u=u[1])||""==u)u="4";else var l=R[u],u=l||(isNaN(u)?"4":u.substr(0,1));h=[h,u].join("")}else h="";h&&s.push(h)}0<s.length&&(a=s),3==e.length&&(s=[],0<(e=(e=e[2])?e.split(","):s).length&&(e=K[e[0]])&&(t.c[o]=e))}for(t.c[o]||(e=K[o])&&(t.c[o]=e),e=0;e<a.length;e+=1)t.a.push(new y(o,a[e]))}}(a),l(i,function(t){if(0==t.a.length)throw Error("No fonts to load!");if(-1!=t.c.indexOf("kit="))return t.c;for(var n=t.a.length,i=[],e=0;e<n;e++)i.push(t.a[e].replace(/ /g,"+"));return n=t.c+"?family="+i.join("%7C"),0<t.f.length&&(n+="&subset="+t.f.join(",")),0<t.g.length&&(n+="&text="+encodeURIComponent(t.g)),n}(e),v(n)),w(n,function(){t(a.a,a.c,J)})},Q.prototype.load=function(s){var t=this.a.id,r=this.c.o;t?u(this.c,(this.a.api||"https://use.typekit.net")+"/"+t+".js",function(t){if(t)s([]);else if(r.Typekit&&r.Typekit.config&&r.Typekit.config.fn){t=r.Typekit.config.fn;for(var n=[],i=0;i<t.length;i+=2)for(var e=t[i],o=t[i+1],a=0;a<o.length;a++)n.push(new y(e,o[a]));try{r.Typekit.load({events:!1,classes:!1,async:!0})}catch(t){}s(n)}},2e3):s([])},Y.prototype.load=function(c){var t,n=this.f.id,i=this.c.o,h=this;n?(i.__webfontfontdeckmodule__||(i.__webfontfontdeckmodule__={}),i.__webfontfontdeckmodule__[n]=function(t,n){for(var i=0,e=n.fonts.length;i<e;++i){var o=n.fonts[i];h.a.push(new y(o.name,(a="font-weight:"+o.weight+";font-style:"+o.style,f=r=s=void 0,s=4,r="n",f=null,a&&((f=a.match(/(normal|oblique|italic)/i))&&f[1]&&(r=f[1].substr(0,1).toLowerCase()),(f=a.match(/([1-9]00|normal|bold)/i))&&f[1]&&(/bold/i.test(f[1])?s=7:/[1-9]00/.test(f[1])&&(s=parseInt(f[1].substr(0,1),10)))),r+s)))}var a,s,r,f;c(h.a)},u(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+((t=this.c).o.location.hostname||t.a.location.hostname)+"/"+n+".js",function(t){t&&c([])})):c([])};var Z=new t(window);Z.a.c.custom=function(t,n){return new M(n,t)},Z.a.c.fontdeck=function(t,n){return new Y(n,t)},Z.a.c.monotype=function(t,n){return new H(n,t)},Z.a.c.typekit=function(t,n){return new Q(n,t)},Z.a.c.google=function(t,n){return new X(n,t)};var tt={load:d(Z.load,Z)};"function"==typeof define&&define.amd?define(function(){return tt}):"undefined"!=typeof module&&module.exports?module.exports=tt:(window.WebFont=tt,window.WebFontConfig&&Z.load(window.WebFontConfig))}();
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.6.4.1\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2018-11-01 21:26:55+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -54,7 +54,7 @@ msgid "Settings"
54
  msgstr ""
55
 
56
  #: admin/litespeed-cache-admin-display.class.php:157
57
- #: admin/tpl/setting/settings_cdn.php:240 inc/gui.class.php:361
58
  #: includes/litespeed-cache-gui.class.php:361
59
  msgid "Manage"
60
  msgstr ""
@@ -106,7 +106,7 @@ msgstr ""
106
 
107
  #: admin/litespeed-cache-admin-display.class.php:815
108
  #: admin/litespeed-cache-admin-display.class.php:903
109
- #: admin/tpl/setting/settings_cdn.php:35 admin/tpl/setting/settings_cdn.php:169
110
  #: admin/tpl/setting/settings_debug.php:29
111
  #: admin/tpl/setting/settings_inc.cache_object.php:149
112
  #: admin/tpl/setting/settings_media.php:93
@@ -128,7 +128,7 @@ msgstr ""
128
  #: admin/tpl/setting/settings_tuning.php:40
129
  #: admin/tpl/setting/settings_tuning.php:60
130
  #: admin/tpl/setting/settings_tuning.php:76
131
- #: admin/tpl/setting/settings_tuning.php:148
132
  msgid "API"
133
  msgstr ""
134
 
@@ -137,7 +137,7 @@ msgid "Server variable(s) %s available to override this setting."
137
  msgstr ""
138
 
139
  #: admin/litespeed-cache-admin-display.class.php:968
140
- #: admin/litespeed-cache-admin.class.php:229
141
  #: admin/tpl/inc/check_cache_disabled.php:49
142
  #: admin/tpl/inc/img_optm.initialize.php:29
143
  #: admin/tpl/inc/img_optm.summary.php:165 admin/tpl/manage/manage_cdn.php:60
@@ -147,7 +147,7 @@ msgstr ""
147
  #: admin/tpl/setting/settings_advanced.php:63
148
  #: admin/tpl/setting/settings_cache.php:7
149
  #: admin/tpl/setting/settings_cache.php:79
150
- #: admin/tpl/setting/settings_cdn.php:25
151
  #: admin/tpl/setting/settings_crawler.php:8
152
  #: admin/tpl/setting/settings_debug.php:8 admin/tpl/setting/settings_esi.php:8
153
  #: admin/tpl/setting/settings_excludes.php:7
@@ -186,9 +186,9 @@ msgstr ""
186
  #: admin/litespeed-cache-admin-display.class.php:984
187
  #: admin/tpl/manage/manage_purge.php:152
188
  #: admin/tpl/setting/settings_cache.php:83
189
- #: admin/tpl/setting/settings_cdn.php:117
190
- #: admin/tpl/setting/settings_cdn.php:145
191
- #: admin/tpl/setting/settings_cdn.php:157
192
  #: admin/tpl/setting/settings_crawler.php:132
193
  #: admin/tpl/setting/settings_excludes.php:43
194
  #: admin/tpl/setting/settings_excludes.php:66
@@ -202,7 +202,7 @@ msgstr ""
202
  #: admin/tpl/setting/settings_purge.php:85
203
  #: admin/tpl/setting/settings_tuning.php:38
204
  #: admin/tpl/setting/settings_tuning.php:74
205
- #: admin/tpl/setting/settings_tuning.php:146
206
  msgid "One per line."
207
  msgstr ""
208
 
@@ -466,42 +466,42 @@ msgstr ""
466
  msgid "Failed to push to LiteSpeed server: %s"
467
  msgstr ""
468
 
469
- #: admin/litespeed-cache-admin-rules.class.php:919
470
  msgid ""
471
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
472
  "%2$s"
473
  msgstr ""
474
 
475
- #: admin/litespeed-cache-admin-rules.class.php:1021
476
  msgid "File Saved."
477
  msgstr ""
478
 
479
- #: admin/litespeed-cache-admin-settings.class.php:52
480
  msgid "'Use primary site settings' set by Network Administrator."
481
  msgstr ""
482
 
483
- #: admin/litespeed-cache-admin-settings.class.php:242
484
  msgid "Site options saved."
485
  msgstr ""
486
 
487
- #: admin/litespeed-cache-admin.class.php:221
488
  msgid ""
489
  "If this is the case, the network admin may uncheck \"Check Advanced Cache\" "
490
  "in LiteSpeed Cache Advanced settings."
491
  msgstr ""
492
 
493
- #: admin/litespeed-cache-admin.class.php:223
494
  msgid ""
495
  "If this is the case, please uncheck \"Check Advanced Cache\" in LiteSpeed "
496
  "Cache Advanced settings."
497
  msgstr ""
498
 
499
- #: admin/litespeed-cache-admin.class.php:225
500
  msgid ""
501
  "LiteSpeed has detected another plugin using the \"Advanced Cache\" file."
502
  msgstr ""
503
 
504
- #: admin/litespeed-cache-admin.class.php:226
505
  msgid ""
506
  "LiteSpeed Cache does work with other optimization plugins, but only if "
507
  "functionality is not duplicated. Only one full-page cache may be activated."
@@ -531,7 +531,7 @@ msgstr ""
531
  msgid "Or"
532
  msgstr ""
533
 
534
- #: admin/tpl/api/quic.login.php:30 admin/tpl/setting/settings_cdn.php:221
535
  msgid "User API Key"
536
  msgstr ""
537
 
@@ -862,7 +862,7 @@ msgstr ""
862
  msgid "Are you sure to reset all settings to default settings?"
863
  msgstr ""
864
 
865
- #: admin/tpl/import_export.php:61 inc/media.class.php:243
866
  msgid "Reset"
867
  msgstr ""
868
 
@@ -874,7 +874,7 @@ msgstr ""
874
  msgid "Rate %s on %s"
875
  msgstr ""
876
 
877
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.6.4.1) #-#-#-#-#
878
  #. Plugin Name of the plugin/theme
879
  #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:353
880
  #: includes/litespeed-cache-gui.class.php:353
@@ -1278,7 +1278,7 @@ msgstr ""
1278
 
1279
  #: admin/tpl/inc/img_optm.summary.php:306
1280
  #: admin/tpl/setting/settings_advanced.php:65
1281
- #: admin/tpl/setting/settings_cdn.php:98
1282
  #: admin/tpl/setting/settings_crawler.php:22
1283
  #: admin/tpl/setting/settings_crawler.php:95
1284
  #: admin/tpl/setting/settings_crawler.php:100
@@ -1723,7 +1723,7 @@ msgstr ""
1723
  msgid "DB Optimizer"
1724
  msgstr ""
1725
 
1726
- #: admin/tpl/manage.php:10 admin/tpl/setting/settings_cdn.php:240
1727
  #: admin/tpl/settings.php:12
1728
  msgid "CDN"
1729
  msgstr ""
@@ -1980,183 +1980,183 @@ msgstr ""
1980
  msgid "For example, to drop parameters beginning with %s, %s can be used here."
1981
  msgstr ""
1982
 
1983
- #: admin/tpl/setting/settings_cdn.php:24
1984
  msgid "CDN Settings"
1985
  msgstr ""
1986
 
1987
- #: admin/tpl/setting/settings_cdn.php:30
1988
  msgid "Enable CDN"
1989
  msgstr ""
1990
 
1991
- #: admin/tpl/setting/settings_cdn.php:34
1992
  msgid "Enable Content Delivery Network use."
1993
  msgstr ""
1994
 
1995
- #: admin/tpl/setting/settings_cdn.php:35
1996
  msgid ""
1997
  "If using Cloudflare, leave this setting %s and use Cloudflare API setting "
1998
  "below."
1999
  msgstr ""
2000
 
2001
- #: admin/tpl/setting/settings_cdn.php:41
2002
  msgid "CDN Mapping"
2003
  msgstr ""
2004
 
2005
- #: admin/tpl/setting/settings_cdn.php:47
2006
  msgid "CDN URL"
2007
  msgstr ""
2008
 
2009
- #: admin/tpl/setting/settings_cdn.php:56
2010
  msgid "CDN URL to be used. For example, %s"
2011
  msgstr ""
2012
 
2013
- #: admin/tpl/setting/settings_cdn.php:62 admin/tpl/setting/settings_cdn.php:103
2014
  msgid "Include Images"
2015
  msgstr ""
2016
 
2017
- #: admin/tpl/setting/settings_cdn.php:69 admin/tpl/setting/settings_cdn.php:107
2018
  msgid "Include CSS"
2019
  msgstr ""
2020
 
2021
- #: admin/tpl/setting/settings_cdn.php:76 admin/tpl/setting/settings_cdn.php:111
2022
  msgid "Include JS"
2023
  msgstr ""
2024
 
2025
- #: admin/tpl/setting/settings_cdn.php:86 admin/tpl/setting/settings_cdn.php:115
2026
  msgid "Include File Types"
2027
  msgstr ""
2028
 
2029
- #: admin/tpl/setting/settings_cdn.php:99
2030
  msgid ""
2031
  "To randomize CDN hostname, define multiple hostnames for the same resources."
2032
  msgstr ""
2033
 
2034
- #: admin/tpl/setting/settings_cdn.php:104
2035
  msgid ""
2036
  "Serve all image files through the CDN. This will affect all attachments, "
2037
  "HTML %s tags, and CSS %s attributes."
2038
  msgstr ""
2039
 
2040
- #: admin/tpl/setting/settings_cdn.php:108
2041
  msgid ""
2042
  "Serve all CSS files through the CDN. This will affect all enqueued WP CSS "
2043
  "files."
2044
  msgstr ""
2045
 
2046
- #: admin/tpl/setting/settings_cdn.php:112
2047
  msgid ""
2048
  "Serve all JavaScript files through the CDN. This will affect all enqueued WP "
2049
  "JavaScript files."
2050
  msgstr ""
2051
 
2052
- #: admin/tpl/setting/settings_cdn.php:116
2053
  msgid "Static file type links to be replaced by CDN links."
2054
  msgstr ""
2055
 
2056
- #: admin/tpl/setting/settings_cdn.php:118
2057
  msgid "This will affect all tags containing attributes: %s %s %s."
2058
  msgstr ""
2059
 
2060
- #: admin/tpl/setting/settings_cdn.php:119
2061
  msgid "Default value"
2062
  msgstr ""
2063
 
2064
- #: admin/tpl/setting/settings_cdn.php:126
2065
  msgid "Original URLs"
2066
  msgstr ""
2067
 
2068
- #: admin/tpl/setting/settings_cdn.php:130
2069
  msgid ""
2070
  "Site URL to be served through the CDN. Beginning with %1$s. For example, "
2071
  "%2$s."
2072
  msgstr ""
2073
 
2074
- #: admin/tpl/setting/settings_cdn.php:131
2075
  msgid ""
2076
  "Wildcard %1$s supported (match zero or more characters). For example, to "
2077
  "match %2$s and %3$s, use %4$s."
2078
  msgstr ""
2079
 
2080
- #: admin/tpl/setting/settings_cdn.php:132
2081
  msgid "Separate multiple original URLs with a %s."
2082
  msgstr ""
2083
 
2084
- #: admin/tpl/setting/settings_cdn.php:138
2085
  msgid "Included Directories"
2086
  msgstr ""
2087
 
2088
- #: admin/tpl/setting/settings_cdn.php:144
2089
  msgid "Only files within these directories will be pointed to the CDN."
2090
  msgstr ""
2091
 
2092
- #: admin/tpl/setting/settings_cdn.php:151
2093
  msgid "Exclude Path"
2094
  msgstr ""
2095
 
2096
- #: admin/tpl/setting/settings_cdn.php:156
2097
  msgid "Paths containing these strings will not be served from the CDN."
2098
  msgstr ""
2099
 
2100
- #: admin/tpl/setting/settings_cdn.php:163
2101
  msgid "Load JQuery Remotely"
2102
  msgstr ""
2103
 
2104
- #: admin/tpl/setting/settings_cdn.php:185
2105
  msgid ""
2106
  "Improve page load time by loading jQuery from a remote CDN service instead "
2107
  "of locally."
2108
  msgstr ""
2109
 
2110
- #: admin/tpl/setting/settings_cdn.php:191
2111
  msgid "Quic Cloud API"
2112
  msgstr ""
2113
 
2114
- #: admin/tpl/setting/settings_cdn.php:195
2115
- #: admin/tpl/setting/settings_cdn.php:239
2116
  msgid "Use %s API functionality."
2117
  msgstr ""
2118
 
2119
- #: admin/tpl/setting/settings_cdn.php:212
2120
- #: admin/tpl/setting/settings_cdn.php:244
2121
  msgid "Email Address"
2122
  msgstr ""
2123
 
2124
- #: admin/tpl/setting/settings_cdn.php:216
2125
- #: admin/tpl/setting/settings_cdn.php:248
2126
  msgid "Your Email address on %s."
2127
  msgstr ""
2128
 
2129
- #: admin/tpl/setting/settings_cdn.php:225
2130
- #: admin/tpl/setting/settings_cdn.php:257
2131
  msgid "Your API key is used to access %s APIs."
2132
  msgstr ""
2133
 
2134
- #: admin/tpl/setting/settings_cdn.php:226
2135
- #: admin/tpl/setting/settings_cdn.php:258
2136
  msgid "Get it from <a %1$s>%2$s</a>."
2137
  msgstr ""
2138
 
2139
- #: admin/tpl/setting/settings_cdn.php:235
2140
  msgid "Cloudflare API"
2141
  msgstr ""
2142
 
2143
- #: admin/tpl/setting/settings_cdn.php:240
2144
  msgid "This can be managed from <a %2$s>%1$s</a>."
2145
  msgstr ""
2146
 
2147
- #: admin/tpl/setting/settings_cdn.php:253
2148
  msgid "Global API Key"
2149
  msgstr ""
2150
 
2151
- #: admin/tpl/setting/settings_cdn.php:263
2152
  msgid "Domain"
2153
  msgstr ""
2154
 
2155
- #: admin/tpl/setting/settings_cdn.php:271
2156
  msgid "You can just type part of the domain."
2157
  msgstr ""
2158
 
2159
- #: admin/tpl/setting/settings_cdn.php:272
2160
  msgid ""
2161
  "Once saved, it will be matched with the current list and completed "
2162
  "automatically."
@@ -2759,6 +2759,16 @@ msgstr ""
2759
  msgid "If this is set to a number less than 30, 500 pages will not be cached."
2760
  msgstr ""
2761
 
 
 
 
 
 
 
 
 
 
 
2762
  #: admin/tpl/setting/settings_inc.cache_browser.php:6
2763
  msgid "Browser Cache"
2764
  msgstr ""
@@ -3163,14 +3173,14 @@ msgstr ""
3163
  #: admin/tpl/setting/settings_media.php:35
3164
  #: admin/tpl/setting/settings_tuning.php:37
3165
  #: admin/tpl/setting/settings_tuning.php:73
3166
- #: admin/tpl/setting/settings_tuning.php:145
3167
  msgid "Both full URLs and partial strings can be used."
3168
  msgstr ""
3169
 
3170
  #: admin/tpl/setting/settings_media.php:39
3171
  #: admin/tpl/setting/settings_tuning.php:41
3172
  #: admin/tpl/setting/settings_tuning.php:77
3173
- #: admin/tpl/setting/settings_tuning.php:149
3174
  msgid "Filter %s is supported."
3175
  msgstr ""
3176
 
@@ -3178,7 +3188,7 @@ msgstr ""
3178
  #: admin/tpl/setting/settings_optimize.php:141
3179
  #: admin/tpl/setting/settings_tuning.php:42
3180
  #: admin/tpl/setting/settings_tuning.php:78
3181
- #: admin/tpl/setting/settings_tuning.php:150
3182
  msgid "Elements with attribute %s in html code will be excluded."
3183
  msgstr ""
3184
 
@@ -3287,7 +3297,7 @@ msgstr ""
3287
  #: admin/tpl/setting/settings_optimize.php:238
3288
  #: admin/tpl/setting/settings_optimize.php:276
3289
  #: admin/tpl/setting/settings_tuning.php:103
3290
- #: admin/tpl/setting/settings_tuning.php:162
3291
  msgid ""
3292
  "This can improve your speed score in services like Pingdom, GTmetrix and "
3293
  "PageSpeed."
@@ -3504,7 +3514,7 @@ msgstr ""
3504
 
3505
  #: admin/tpl/setting/settings_optimize.php:132
3506
  #: admin/tpl/setting/settings_optimize.php:153
3507
- #: admin/tpl/setting/settings_tuning.php:134
3508
  msgid "Load CSS Asynchronously"
3509
  msgstr ""
3510
 
@@ -3826,8 +3836,8 @@ msgstr ""
3826
 
3827
  #: admin/tpl/setting/settings_tuning.php:113
3828
  msgid ""
3829
- "This is useful if you only want to load Google Fonts asynchronously while "
3830
- "leave other CSS intact."
3831
  msgstr ""
3832
 
3833
  #: admin/tpl/setting/settings_tuning.php:114
@@ -3836,53 +3846,53 @@ msgid ""
3836
  "downloading."
3837
  msgstr ""
3838
 
3839
- #: admin/tpl/setting/settings_tuning.php:120
3840
  msgid "Remove Google Fonts"
3841
  msgstr ""
3842
 
3843
- #: admin/tpl/setting/settings_tuning.php:124
3844
  msgid "Prevent google fonts from loading on all your pages."
3845
  msgstr ""
3846
 
3847
- #: admin/tpl/setting/settings_tuning.php:130
3848
  msgid "Critical CSS Rules"
3849
  msgstr ""
3850
 
3851
- #: admin/tpl/setting/settings_tuning.php:134
3852
  msgid "Specify critical CSS rules for above-the-fold content when enabling %s."
3853
  msgstr ""
3854
 
3855
- #: admin/tpl/setting/settings_tuning.php:140
3856
  msgid "JS Deferred Excludes"
3857
  msgstr ""
3858
 
3859
- #: admin/tpl/setting/settings_tuning.php:144
3860
  msgid "Listed JS files will not be deferred."
3861
  msgstr ""
3862
 
3863
- #: admin/tpl/setting/settings_tuning.php:157
3864
  msgid "Remove WordPress Emoji"
3865
  msgstr ""
3866
 
3867
- #: admin/tpl/setting/settings_tuning.php:161
3868
  msgid ""
3869
  "Stop loading wordpress.org emoji. Browser default emoji will be displayed "
3870
  "instead."
3871
  msgstr ""
3872
 
3873
- #: admin/tpl/setting/settings_tuning.php:168
3874
  msgid "URI Excludes"
3875
  msgstr ""
3876
 
3877
- #: admin/tpl/setting/settings_tuning.php:172
3878
  msgid "Prevent any optimization of listed pages."
3879
  msgstr ""
3880
 
3881
- #: admin/tpl/setting/settings_tuning.php:179
3882
  msgid "Role Excludes"
3883
  msgstr ""
3884
 
3885
- #: admin/tpl/setting/settings_tuning.php:185
3886
  msgid "Selected roles will be excluded from all optimizations."
3887
  msgstr ""
3888
 
@@ -3997,9 +4007,9 @@ msgstr ""
3997
  msgid "Crawler %s reached end of sitemap file."
3998
  msgstr ""
3999
 
4000
- #: inc/crawler.class.php:506 inc/crawler.class.php:510
4001
- #: includes/litespeed-cache-crawler.class.php:506
4002
- #: includes/litespeed-cache-crawler.class.php:510
4003
  msgid "Guest"
4004
  msgstr ""
4005
 
@@ -4086,8 +4096,8 @@ msgstr ""
4086
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4087
  msgstr ""
4088
 
4089
- #: inc/img_optm.class.php:166 inc/img_optm.class.php:1468
4090
- #: inc/img_optm.class.php:1533
4091
  msgid "No image found."
4092
  msgstr ""
4093
 
@@ -4122,37 +4132,37 @@ msgstr ""
4122
  msgid "Destroy unfinished data successfully."
4123
  msgstr ""
4124
 
4125
- #: inc/img_optm.class.php:1571
4126
  msgid ""
4127
  "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
4128
  "accepted %3$s groups with %4$s images."
4129
  msgstr ""
4130
 
4131
- #: inc/img_optm.class.php:1747
4132
  msgid "Removed %1$s images and saved %2$s successfully."
4133
  msgstr ""
4134
 
4135
- #: inc/img_optm.class.php:1942
4136
  msgid "Switched images successfully."
4137
  msgstr ""
4138
 
4139
- #: inc/img_optm.class.php:1973
4140
  msgid "Disabled WebP file successfully."
4141
  msgstr ""
4142
 
4143
- #: inc/img_optm.class.php:1979
4144
  msgid "Enabled WebP file successfully."
4145
  msgstr ""
4146
 
4147
- #: inc/img_optm.class.php:1995
4148
  msgid "Restored original file successfully."
4149
  msgstr ""
4150
 
4151
- #: inc/img_optm.class.php:2002
4152
  msgid "Switched to optimized file successfully."
4153
  msgstr ""
4154
 
4155
- #: inc/img_optm.class.php:2062
4156
  msgid "Reset the optimized data successfully."
4157
  msgstr ""
4158
 
@@ -4160,51 +4170,51 @@ msgstr ""
4160
  msgid "Import failed due to file error."
4161
  msgstr ""
4162
 
4163
- #: inc/import.class.php:203
4164
  msgid "Imported setting file %s successfully."
4165
  msgstr ""
4166
 
4167
- #: inc/import.class.php:249
4168
  msgid "Reset 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
 
4183
- #: inc/media.class.php:149
4184
  msgid "LiteSpeed Optimization"
4185
  msgstr ""
4186
 
4187
- #: inc/media.class.php:175
4188
  msgid "WebP saved %s"
4189
  msgstr ""
4190
 
4191
- #: inc/media.class.php:182
4192
  msgid "Click to Disable WebP"
4193
  msgstr ""
4194
 
4195
- #: inc/media.class.php:187
4196
  msgid "Click to Enable WebP"
4197
  msgstr ""
4198
 
4199
- #: inc/media.class.php:208
4200
  msgid "Original saved %s"
4201
  msgstr ""
4202
 
4203
- #: inc/media.class.php:219
4204
  msgid "Click to Restore Original File"
4205
  msgstr ""
4206
 
4207
- #: inc/media.class.php:224
4208
  msgid "Click to Switch To Optimized File"
4209
  msgstr ""
4210
 
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.7.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2018-11-26 17:25:39+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
54
  msgstr ""
55
 
56
  #: admin/litespeed-cache-admin-display.class.php:157
57
+ #: admin/tpl/setting/settings_cdn.php:230 inc/gui.class.php:361
58
  #: includes/litespeed-cache-gui.class.php:361
59
  msgid "Manage"
60
  msgstr ""
106
 
107
  #: admin/litespeed-cache-admin-display.class.php:815
108
  #: admin/litespeed-cache-admin-display.class.php:903
109
+ #: admin/tpl/setting/settings_cdn.php:25 admin/tpl/setting/settings_cdn.php:159
110
  #: admin/tpl/setting/settings_debug.php:29
111
  #: admin/tpl/setting/settings_inc.cache_object.php:149
112
  #: admin/tpl/setting/settings_media.php:93
128
  #: admin/tpl/setting/settings_tuning.php:40
129
  #: admin/tpl/setting/settings_tuning.php:60
130
  #: admin/tpl/setting/settings_tuning.php:76
131
+ #: admin/tpl/setting/settings_tuning.php:149
132
  msgid "API"
133
  msgstr ""
134
 
137
  msgstr ""
138
 
139
  #: admin/litespeed-cache-admin-display.class.php:968
140
+ #: admin/litespeed-cache-admin.class.php:228
141
  #: admin/tpl/inc/check_cache_disabled.php:49
142
  #: admin/tpl/inc/img_optm.initialize.php:29
143
  #: admin/tpl/inc/img_optm.summary.php:165 admin/tpl/manage/manage_cdn.php:60
147
  #: admin/tpl/setting/settings_advanced.php:63
148
  #: admin/tpl/setting/settings_cache.php:7
149
  #: admin/tpl/setting/settings_cache.php:79
150
+ #: admin/tpl/setting/settings_cdn.php:15
151
  #: admin/tpl/setting/settings_crawler.php:8
152
  #: admin/tpl/setting/settings_debug.php:8 admin/tpl/setting/settings_esi.php:8
153
  #: admin/tpl/setting/settings_excludes.php:7
186
  #: admin/litespeed-cache-admin-display.class.php:984
187
  #: admin/tpl/manage/manage_purge.php:152
188
  #: admin/tpl/setting/settings_cache.php:83
189
+ #: admin/tpl/setting/settings_cdn.php:107
190
+ #: admin/tpl/setting/settings_cdn.php:135
191
+ #: admin/tpl/setting/settings_cdn.php:147
192
  #: admin/tpl/setting/settings_crawler.php:132
193
  #: admin/tpl/setting/settings_excludes.php:43
194
  #: admin/tpl/setting/settings_excludes.php:66
202
  #: admin/tpl/setting/settings_purge.php:85
203
  #: admin/tpl/setting/settings_tuning.php:38
204
  #: admin/tpl/setting/settings_tuning.php:74
205
+ #: admin/tpl/setting/settings_tuning.php:147
206
  msgid "One per line."
207
  msgstr ""
208
 
466
  msgid "Failed to push to LiteSpeed server: %s"
467
  msgstr ""
468
 
469
+ #: admin/litespeed-cache-admin-rules.class.php:925
470
  msgid ""
471
  "<p>Please add/replace the following codes into the beginning of %1$s:</p> "
472
  "%2$s"
473
  msgstr ""
474
 
475
+ #: admin/litespeed-cache-admin-rules.class.php:1027
476
  msgid "File Saved."
477
  msgstr ""
478
 
479
+ #: admin/litespeed-cache-admin-settings.class.php:57
480
  msgid "'Use primary site settings' set by Network Administrator."
481
  msgstr ""
482
 
483
+ #: admin/litespeed-cache-admin-settings.class.php:308
484
  msgid "Site options saved."
485
  msgstr ""
486
 
487
+ #: admin/litespeed-cache-admin.class.php:220
488
  msgid ""
489
  "If this is the case, the network admin may uncheck \"Check Advanced Cache\" "
490
  "in LiteSpeed Cache Advanced settings."
491
  msgstr ""
492
 
493
+ #: admin/litespeed-cache-admin.class.php:222
494
  msgid ""
495
  "If this is the case, please uncheck \"Check Advanced Cache\" in LiteSpeed "
496
  "Cache Advanced settings."
497
  msgstr ""
498
 
499
+ #: admin/litespeed-cache-admin.class.php:224
500
  msgid ""
501
  "LiteSpeed has detected another plugin using the \"Advanced Cache\" file."
502
  msgstr ""
503
 
504
+ #: admin/litespeed-cache-admin.class.php:225
505
  msgid ""
506
  "LiteSpeed Cache does work with other optimization plugins, but only if "
507
  "functionality is not duplicated. Only one full-page cache may be activated."
531
  msgid "Or"
532
  msgstr ""
533
 
534
+ #: admin/tpl/api/quic.login.php:30 admin/tpl/setting/settings_cdn.php:211
535
  msgid "User API Key"
536
  msgstr ""
537
 
862
  msgid "Are you sure to reset all settings to default settings?"
863
  msgstr ""
864
 
865
+ #: admin/tpl/import_export.php:61 inc/media.class.php:241
866
  msgid "Reset"
867
  msgstr ""
868
 
874
  msgid "Rate %s on %s"
875
  msgstr ""
876
 
877
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 2.7.3) #-#-#-#-#
878
  #. Plugin Name of the plugin/theme
879
  #: admin/tpl/inc/admin_footer.php:6 inc/gui.class.php:353
880
  #: includes/litespeed-cache-gui.class.php:353
1278
 
1279
  #: admin/tpl/inc/img_optm.summary.php:306
1280
  #: admin/tpl/setting/settings_advanced.php:65
1281
+ #: admin/tpl/setting/settings_cdn.php:88
1282
  #: admin/tpl/setting/settings_crawler.php:22
1283
  #: admin/tpl/setting/settings_crawler.php:95
1284
  #: admin/tpl/setting/settings_crawler.php:100
1723
  msgid "DB Optimizer"
1724
  msgstr ""
1725
 
1726
+ #: admin/tpl/manage.php:10 admin/tpl/setting/settings_cdn.php:230
1727
  #: admin/tpl/settings.php:12
1728
  msgid "CDN"
1729
  msgstr ""
1980
  msgid "For example, to drop parameters beginning with %s, %s can be used here."
1981
  msgstr ""
1982
 
1983
+ #: admin/tpl/setting/settings_cdn.php:14
1984
  msgid "CDN Settings"
1985
  msgstr ""
1986
 
1987
+ #: admin/tpl/setting/settings_cdn.php:20
1988
  msgid "Enable CDN"
1989
  msgstr ""
1990
 
1991
+ #: admin/tpl/setting/settings_cdn.php:24
1992
  msgid "Enable Content Delivery Network use."
1993
  msgstr ""
1994
 
1995
+ #: admin/tpl/setting/settings_cdn.php:25
1996
  msgid ""
1997
  "If using Cloudflare, leave this setting %s and use Cloudflare API setting "
1998
  "below."
1999
  msgstr ""
2000
 
2001
+ #: admin/tpl/setting/settings_cdn.php:31
2002
  msgid "CDN Mapping"
2003
  msgstr ""
2004
 
2005
+ #: admin/tpl/setting/settings_cdn.php:37
2006
  msgid "CDN URL"
2007
  msgstr ""
2008
 
2009
+ #: admin/tpl/setting/settings_cdn.php:46
2010
  msgid "CDN URL to be used. For example, %s"
2011
  msgstr ""
2012
 
2013
+ #: admin/tpl/setting/settings_cdn.php:52 admin/tpl/setting/settings_cdn.php:93
2014
  msgid "Include Images"
2015
  msgstr ""
2016
 
2017
+ #: admin/tpl/setting/settings_cdn.php:59 admin/tpl/setting/settings_cdn.php:97
2018
  msgid "Include CSS"
2019
  msgstr ""
2020
 
2021
+ #: admin/tpl/setting/settings_cdn.php:66 admin/tpl/setting/settings_cdn.php:101
2022
  msgid "Include JS"
2023
  msgstr ""
2024
 
2025
+ #: admin/tpl/setting/settings_cdn.php:76 admin/tpl/setting/settings_cdn.php:105
2026
  msgid "Include File Types"
2027
  msgstr ""
2028
 
2029
+ #: admin/tpl/setting/settings_cdn.php:89
2030
  msgid ""
2031
  "To randomize CDN hostname, define multiple hostnames for the same resources."
2032
  msgstr ""
2033
 
2034
+ #: admin/tpl/setting/settings_cdn.php:94
2035
  msgid ""
2036
  "Serve all image files through the CDN. This will affect all attachments, "
2037
  "HTML %s tags, and CSS %s attributes."
2038
  msgstr ""
2039
 
2040
+ #: admin/tpl/setting/settings_cdn.php:98
2041
  msgid ""
2042
  "Serve all CSS files through the CDN. This will affect all enqueued WP CSS "
2043
  "files."
2044
  msgstr ""
2045
 
2046
+ #: admin/tpl/setting/settings_cdn.php:102
2047
  msgid ""
2048
  "Serve all JavaScript files through the CDN. This will affect all enqueued WP "
2049
  "JavaScript files."
2050
  msgstr ""
2051
 
2052
+ #: admin/tpl/setting/settings_cdn.php:106
2053
  msgid "Static file type links to be replaced by CDN links."
2054
  msgstr ""
2055
 
2056
+ #: admin/tpl/setting/settings_cdn.php:108
2057
  msgid "This will affect all tags containing attributes: %s %s %s."
2058
  msgstr ""
2059
 
2060
+ #: admin/tpl/setting/settings_cdn.php:109
2061
  msgid "Default value"
2062
  msgstr ""
2063
 
2064
+ #: admin/tpl/setting/settings_cdn.php:116
2065
  msgid "Original URLs"
2066
  msgstr ""
2067
 
2068
+ #: admin/tpl/setting/settings_cdn.php:120
2069
  msgid ""
2070
  "Site URL to be served through the CDN. Beginning with %1$s. For example, "
2071
  "%2$s."
2072
  msgstr ""
2073
 
2074
+ #: admin/tpl/setting/settings_cdn.php:121
2075
  msgid ""
2076
  "Wildcard %1$s supported (match zero or more characters). For example, to "
2077
  "match %2$s and %3$s, use %4$s."
2078
  msgstr ""
2079
 
2080
+ #: admin/tpl/setting/settings_cdn.php:122
2081
  msgid "Separate multiple original URLs with a %s."
2082
  msgstr ""
2083
 
2084
+ #: admin/tpl/setting/settings_cdn.php:128
2085
  msgid "Included Directories"
2086
  msgstr ""
2087
 
2088
+ #: admin/tpl/setting/settings_cdn.php:134
2089
  msgid "Only files within these directories will be pointed to the CDN."
2090
  msgstr ""
2091
 
2092
+ #: admin/tpl/setting/settings_cdn.php:141
2093
  msgid "Exclude Path"
2094
  msgstr ""
2095
 
2096
+ #: admin/tpl/setting/settings_cdn.php:146
2097
  msgid "Paths containing these strings will not be served from the CDN."
2098
  msgstr ""
2099
 
2100
+ #: admin/tpl/setting/settings_cdn.php:153
2101
  msgid "Load JQuery Remotely"
2102
  msgstr ""
2103
 
2104
+ #: admin/tpl/setting/settings_cdn.php:175
2105
  msgid ""
2106
  "Improve page load time by loading jQuery from a remote CDN service instead "
2107
  "of locally."
2108
  msgstr ""
2109
 
2110
+ #: admin/tpl/setting/settings_cdn.php:181
2111
  msgid "Quic Cloud API"
2112
  msgstr ""
2113
 
2114
+ #: admin/tpl/setting/settings_cdn.php:185
2115
+ #: admin/tpl/setting/settings_cdn.php:229
2116
  msgid "Use %s API functionality."
2117
  msgstr ""
2118
 
2119
+ #: admin/tpl/setting/settings_cdn.php:202
2120
+ #: admin/tpl/setting/settings_cdn.php:234
2121
  msgid "Email Address"
2122
  msgstr ""
2123
 
2124
+ #: admin/tpl/setting/settings_cdn.php:206
2125
+ #: admin/tpl/setting/settings_cdn.php:238
2126
  msgid "Your Email address on %s."
2127
  msgstr ""
2128
 
2129
+ #: admin/tpl/setting/settings_cdn.php:215
2130
+ #: admin/tpl/setting/settings_cdn.php:247
2131
  msgid "Your API key is used to access %s APIs."
2132
  msgstr ""
2133
 
2134
+ #: admin/tpl/setting/settings_cdn.php:216
2135
+ #: admin/tpl/setting/settings_cdn.php:248
2136
  msgid "Get it from <a %1$s>%2$s</a>."
2137
  msgstr ""
2138
 
2139
+ #: admin/tpl/setting/settings_cdn.php:225
2140
  msgid "Cloudflare API"
2141
  msgstr ""
2142
 
2143
+ #: admin/tpl/setting/settings_cdn.php:230
2144
  msgid "This can be managed from <a %2$s>%1$s</a>."
2145
  msgstr ""
2146
 
2147
+ #: admin/tpl/setting/settings_cdn.php:243
2148
  msgid "Global API Key"
2149
  msgstr ""
2150
 
2151
+ #: admin/tpl/setting/settings_cdn.php:253
2152
  msgid "Domain"
2153
  msgstr ""
2154
 
2155
+ #: admin/tpl/setting/settings_cdn.php:261
2156
  msgid "You can just type part of the domain."
2157
  msgstr ""
2158
 
2159
+ #: admin/tpl/setting/settings_cdn.php:262
2160
  msgid ""
2161
  "Once saved, it will be matched with the current list and completed "
2162
  "automatically."
2759
  msgid "If this is set to a number less than 30, 500 pages will not be cached."
2760
  msgstr ""
2761
 
2762
+ #: admin/tpl/setting/settings_inc.auto_upgrade.php:7
2763
+ msgid "Automatically Upgrade"
2764
+ msgstr ""
2765
+
2766
+ #: admin/tpl/setting/settings_inc.auto_upgrade.php:11
2767
+ msgid ""
2768
+ "Turn this option ON to have LiteSpeed Cache updated automatically, whenever "
2769
+ "a new version is released. If OFF, update manually as usual."
2770
+ msgstr ""
2771
+
2772
  #: admin/tpl/setting/settings_inc.cache_browser.php:6
2773
  msgid "Browser Cache"
2774
  msgstr ""
3173
  #: admin/tpl/setting/settings_media.php:35
3174
  #: admin/tpl/setting/settings_tuning.php:37
3175
  #: admin/tpl/setting/settings_tuning.php:73
3176
+ #: admin/tpl/setting/settings_tuning.php:146
3177
  msgid "Both full URLs and partial strings can be used."
3178
  msgstr ""
3179
 
3180
  #: admin/tpl/setting/settings_media.php:39
3181
  #: admin/tpl/setting/settings_tuning.php:41
3182
  #: admin/tpl/setting/settings_tuning.php:77
3183
+ #: admin/tpl/setting/settings_tuning.php:150
3184
  msgid "Filter %s is supported."
3185
  msgstr ""
3186
 
3188
  #: admin/tpl/setting/settings_optimize.php:141
3189
  #: admin/tpl/setting/settings_tuning.php:42
3190
  #: admin/tpl/setting/settings_tuning.php:78
3191
+ #: admin/tpl/setting/settings_tuning.php:151
3192
  msgid "Elements with attribute %s in html code will be excluded."
3193
  msgstr ""
3194
 
3297
  #: admin/tpl/setting/settings_optimize.php:238
3298
  #: admin/tpl/setting/settings_optimize.php:276
3299
  #: admin/tpl/setting/settings_tuning.php:103
3300
+ #: admin/tpl/setting/settings_tuning.php:163
3301
  msgid ""
3302
  "This can improve your speed score in services like Pingdom, GTmetrix and "
3303
  "PageSpeed."
3514
 
3515
  #: admin/tpl/setting/settings_optimize.php:132
3516
  #: admin/tpl/setting/settings_optimize.php:153
3517
+ #: admin/tpl/setting/settings_tuning.php:135
3518
  msgid "Load CSS Asynchronously"
3519
  msgstr ""
3520
 
3836
 
3837
  #: admin/tpl/setting/settings_tuning.php:113
3838
  msgid ""
3839
+ "Use Web Font Loader library to load Google Fonts asynchronously while leave "
3840
+ "other CSS intact."
3841
  msgstr ""
3842
 
3843
  #: admin/tpl/setting/settings_tuning.php:114
3846
  "downloading."
3847
  msgstr ""
3848
 
3849
+ #: admin/tpl/setting/settings_tuning.php:121
3850
  msgid "Remove Google Fonts"
3851
  msgstr ""
3852
 
3853
+ #: admin/tpl/setting/settings_tuning.php:125
3854
  msgid "Prevent google fonts from loading on all your pages."
3855
  msgstr ""
3856
 
3857
+ #: admin/tpl/setting/settings_tuning.php:131
3858
  msgid "Critical CSS Rules"
3859
  msgstr ""
3860
 
3861
+ #: admin/tpl/setting/settings_tuning.php:135
3862
  msgid "Specify critical CSS rules for above-the-fold content when enabling %s."
3863
  msgstr ""
3864
 
3865
+ #: admin/tpl/setting/settings_tuning.php:141
3866
  msgid "JS Deferred Excludes"
3867
  msgstr ""
3868
 
3869
+ #: admin/tpl/setting/settings_tuning.php:145
3870
  msgid "Listed JS files will not be deferred."
3871
  msgstr ""
3872
 
3873
+ #: admin/tpl/setting/settings_tuning.php:158
3874
  msgid "Remove WordPress Emoji"
3875
  msgstr ""
3876
 
3877
+ #: admin/tpl/setting/settings_tuning.php:162
3878
  msgid ""
3879
  "Stop loading wordpress.org emoji. Browser default emoji will be displayed "
3880
  "instead."
3881
  msgstr ""
3882
 
3883
+ #: admin/tpl/setting/settings_tuning.php:169
3884
  msgid "URI Excludes"
3885
  msgstr ""
3886
 
3887
+ #: admin/tpl/setting/settings_tuning.php:173
3888
  msgid "Prevent any optimization of listed pages."
3889
  msgstr ""
3890
 
3891
+ #: admin/tpl/setting/settings_tuning.php:180
3892
  msgid "Role Excludes"
3893
  msgstr ""
3894
 
3895
+ #: admin/tpl/setting/settings_tuning.php:186
3896
  msgid "Selected roles will be excluded from all optimizations."
3897
  msgstr ""
3898
 
4007
  msgid "Crawler %s reached end of sitemap file."
4008
  msgstr ""
4009
 
4010
+ #: inc/crawler.class.php:505 inc/crawler.class.php:509
4011
+ #: includes/litespeed-cache-crawler.class.php:505
4012
+ #: includes/litespeed-cache-crawler.class.php:509
4013
  msgid "Guest"
4014
  msgstr ""
4015
 
4096
  msgid "Communicated with LiteSpeed Image Optimization Server successfully."
4097
  msgstr ""
4098
 
4099
+ #: inc/img_optm.class.php:166 inc/img_optm.class.php:1469
4100
+ #: inc/img_optm.class.php:1534
4101
  msgid "No image found."
4102
  msgstr ""
4103
 
4132
  msgid "Destroy unfinished data successfully."
4133
  msgstr ""
4134
 
4135
+ #: inc/img_optm.class.php:1572
4136
  msgid ""
4137
  "Pushed %1$s groups with %2$s images to LiteSpeed optimization server, "
4138
  "accepted %3$s groups with %4$s images."
4139
  msgstr ""
4140
 
4141
+ #: inc/img_optm.class.php:1748
4142
  msgid "Removed %1$s images and saved %2$s successfully."
4143
  msgstr ""
4144
 
4145
+ #: inc/img_optm.class.php:1943
4146
  msgid "Switched images successfully."
4147
  msgstr ""
4148
 
4149
+ #: inc/img_optm.class.php:1974
4150
  msgid "Disabled WebP file successfully."
4151
  msgstr ""
4152
 
4153
+ #: inc/img_optm.class.php:1980
4154
  msgid "Enabled WebP file successfully."
4155
  msgstr ""
4156
 
4157
+ #: inc/img_optm.class.php:1996
4158
  msgid "Restored original file successfully."
4159
  msgstr ""
4160
 
4161
+ #: inc/img_optm.class.php:2003
4162
  msgid "Switched to optimized file successfully."
4163
  msgstr ""
4164
 
4165
+ #: inc/img_optm.class.php:2063
4166
  msgid "Reset the optimized data successfully."
4167
  msgstr ""
4168
 
4170
  msgid "Import failed due to file error."
4171
  msgstr ""
4172
 
4173
+ #: inc/import.class.php:201
4174
  msgid "Imported setting file %s successfully."
4175
  msgstr ""
4176
 
4177
+ #: inc/import.class.php:244
4178
  msgid "Reset successfully."
4179
  msgstr ""
4180
 
4181
+ #: inc/litespeed-cache.class.php:310 includes/litespeed-cache.class.php:310
4182
  msgid "Crawler blacklist is saved."
4183
  msgstr ""
4184
 
4185
+ #: inc/litespeed-cache.class.php:321 includes/litespeed-cache.class.php:321
4186
  msgid "Notified LiteSpeed Web Server to purge everything."
4187
  msgstr ""
4188
 
4189
+ #: inc/litespeed-cache.class.php:331 includes/litespeed-cache.class.php:331
4190
  msgid "Notified LiteSpeed Web Server to purge the list."
4191
  msgstr ""
4192
 
4193
+ #: inc/media.class.php:147
4194
  msgid "LiteSpeed Optimization"
4195
  msgstr ""
4196
 
4197
+ #: inc/media.class.php:173
4198
  msgid "WebP saved %s"
4199
  msgstr ""
4200
 
4201
+ #: inc/media.class.php:180
4202
  msgid "Click to Disable WebP"
4203
  msgstr ""
4204
 
4205
+ #: inc/media.class.php:185
4206
  msgid "Click to Enable WebP"
4207
  msgstr ""
4208
 
4209
+ #: inc/media.class.php:206
4210
  msgid "Original saved %s"
4211
  msgstr ""
4212
 
4213
+ #: inc/media.class.php:217
4214
  msgid "Click to Restore Original File"
4215
  msgstr ""
4216
 
4217
+ #: inc/media.class.php:222
4218
  msgid "Click to Switch To Optimized File"
4219
  msgstr ""
4220
 
lib/js_min.class.php CHANGED
@@ -210,7 +210,7 @@ class JSMin
210
  }
211
  if ($this->isEOF($this->a)) {
212
  $byte = $this->inputIndex - 1;
213
- throw new Exception(
214
  "JSMin: Unterminated String at byte {$byte}: {$str}");
215
  }
216
  $str .= $this->a;
@@ -247,7 +247,7 @@ class JSMin
247
  $pattern .= $this->a;
248
  }
249
  if ($this->isEOF($this->a)) {
250
- throw new Exception(
251
  "JSMin: Unterminated set in RegExp at byte "
252
  . $this->inputIndex .": {$pattern}");
253
  }
@@ -262,7 +262,7 @@ class JSMin
262
  $pattern .= $this->a;
263
  } elseif ($this->isEOF($this->a)) {
264
  $byte = $this->inputIndex - 1;
265
- throw new Exception(
266
  "JSMin: Unterminated RegExp at byte {$byte}: {$pattern}");
267
  }
268
  $this->output .= $this->a;
@@ -424,7 +424,7 @@ class JSMin
424
  return;
425
  }
426
  } elseif ($get === null) {
427
- throw new Exception(
428
  "JSMin: Unterminated comment at byte {$this->inputIndex}: /*{$comment}");
429
  }
430
  $comment .= $get;
210
  }
211
  if ($this->isEOF($this->a)) {
212
  $byte = $this->inputIndex - 1;
213
+ throw new \Exception(
214
  "JSMin: Unterminated String at byte {$byte}: {$str}");
215
  }
216
  $str .= $this->a;
247
  $pattern .= $this->a;
248
  }
249
  if ($this->isEOF($this->a)) {
250
+ throw new \Exception(
251
  "JSMin: Unterminated set in RegExp at byte "
252
  . $this->inputIndex .": {$pattern}");
253
  }
262
  $pattern .= $this->a;
263
  } elseif ($this->isEOF($this->a)) {
264
  $byte = $this->inputIndex - 1;
265
+ throw new \Exception(
266
  "JSMin: Unterminated RegExp at byte {$byte}: {$pattern}");
267
  }
268
  $this->output .= $this->a;
424
  return;
425
  }
426
  } elseif ($get === null) {
427
+ throw new \Exception(
428
  "JSMin: Unterminated comment at byte {$this->inputIndex}: /*{$comment}");
429
  }
430
  $comment .= $get;
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.7
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.7.3
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.7
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -276,13 +276,39 @@ Click on the `Advanced View` link at the top of the page, and several more tabs
276
 
277
  == Changelog ==
278
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  = 2.7 - Nov 2 2018 =
280
  * 🌱: Separate Purge log for better debugging.
281
  * <strong>3rd</strong>: Now fully compatible with WPML.
282
  * <strong>IAPI</strong>: Sped up Image Optimization workflow.
283
  * <strong>GUI</strong>: Current IP now shows in Debug settings.
284
  * <strong>GUI</strong>: Space separated placeholder queue list for better look.
285
- * <strong>EU3 server IP Changed to 165.227.131.98</strong>.
286
 
287
  = 2.6.4.1 - Oct 25 2018 =
288
  * 🔥🐞<strong>Media</strong>: Fixed a bug where the wrong table was used in the Image Optimization process.
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.7.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
276
 
277
  == Changelog ==
278
 
279
+ = 2.7.3 - Nov 26 2018 =
280
+ * <strong>Optm</strong>: Improved page render speed with Web Font Loader JS library for Load Google Fonts Asynchronously.
281
+ * <strong>Optm</strong>: Directly used JS library files in plugin folder instead of short links `/min/`.
282
+ * <strong>Optm</strong>: Handled exceptions in JS optimization when meeting badly formatted JS.
283
+ * <strong>3rd</strong>: Added Adobe Lightroom support for NextGen Gallery.
284
+ * <strong>3rd</strong>: Improved Postman app support for POST JSON requests.
285
+ * <strong>IAPI</strong>: <strong>US3 server IP changed to 68.183.60.185</strong>.
286
+
287
+ = 2.7.2 - Nov 19 2018 =
288
+ * 🌱: Auto Upgrade feature.
289
+ * <strong>CDN</strong>: Bypass CDN for cron to avoid WP jQuery deregister warning.
290
+
291
+ = 2.7.1 - Nov 15 2018 =
292
+ * 🌱<strong>CLI</strong>: Ability to set CDN mapping by `set_option litespeed-cache-cdn_mapping[url][0] https://url`.
293
+ * 🌱<strong>CDN</strong>: Ability to customize default CDN mapping data in default.ini.
294
+ * 🌱<strong>API</strong>: Default.ini now supports both text-area items and on/off options.
295
+ * <strong>Vary</strong>: Refactored Vary and related API.
296
+ * <strong>Vary</strong>: New hook to manipulate vary cookies value.
297
+ * <strong>Core</strong>: Activation now can generate Object Cache file.
298
+ * <strong>Core</strong>: Unified Object Cache/rewrite rules generation process across activation/import/reset/CLI.
299
+ * <strong>Core</strong>: Always hook activation to make activation available through the front end.
300
+ * 🐞<strong>IAPI</strong>: Fixed a bug where environment report gave incorrect image optimization data.
301
+ * 🐞<strong>OLS</strong>: Fixed a bug where login cookie kept showing a warning on OpenLiteSpeed.
302
+ * 🐞<strong>Core</strong>: Fixed a bug where Import/Activation/CLI was missing CDN mapping settings.
303
+ * <strong>API</strong>: <strong>Filters `litespeed_cache_media_lazy_img_excludes/litespeed_optm_js_defer_exc` passed-in parameter is changed from string to array.</strong>
304
+
305
  = 2.7 - Nov 2 2018 =
306
  * 🌱: Separate Purge log for better debugging.
307
  * <strong>3rd</strong>: Now fully compatible with WPML.
308
  * <strong>IAPI</strong>: Sped up Image Optimization workflow.
309
  * <strong>GUI</strong>: Current IP now shows in Debug settings.
310
  * <strong>GUI</strong>: Space separated placeholder queue list for better look.
311
+ * <strong>IAPI</strong>: <strong>EU3 server IP changed to 165.227.131.98</strong>.
312
 
313
  = 2.6.4.1 - Oct 25 2018 =
314
  * 🔥🐞<strong>Media</strong>: Fixed a bug where the wrong table was used in the Image Optimization process.
thirdparty/lscwp-3rd-nextgengallery.cls.php CHANGED
@@ -77,6 +77,16 @@ class LiteSpeed_Cache_ThirdParty_NextGenGallery
77
  return ;
78
  }
79
 
 
 
 
 
 
 
 
 
 
 
80
  if ( isset($_POST['id']) ) {
81
  $id = $_POST['id'] ;
82
  }
77
  return ;
78
  }
79
 
80
+ if ( isset( $_POST[ 'task_list' ] ) ) {
81
+ $task_list = str_replace( '\\', '', $_POST[ 'task_list' ] ) ;
82
+ $task_list = json_decode( $task_list, true ) ;
83
+
84
+ if ( ! empty( $task_list[ 0 ][ 'query' ][ 'id' ] ) ) {
85
+ LiteSpeed_Cache_API::purge( self::CACHETAG_GALLERIES . $task_list[ 0 ][ 'query' ][ 'id' ] ) ;
86
+ return ;
87
+ }
88
+ }
89
+
90
  if ( isset($_POST['id']) ) {
91
  $id = $_POST['id'] ;
92
  }