LiteSpeed Cache - Version 3.3

Version Description

  • Aug 6 2020 =
  • Page Optimize Added a new setting, Inline JS Deferred Excludes. (@ankit)
  • Page Optimize CSS/JS Combine/Minify file versions will be differentiated by query string hash instead of new filename to reduce DB/file system storage.
  • Page Optimize Added the ability to use local copies of external JS files for better control over page score impacts.
  • Page Optimize Improved combination of CSS media queries. (@galbaras)
  • Page Optimize Reprioritized Inline JS Defer to be optimized before encoding, for a significantly smaller result.
  • LQIP Detect if the file exists before sending LQIP request to QUIC.cloud.
  • CCSS Sped up CCSS process significantly by sending HTML and CSS in request.
  • CCSS Improvements to mobile CSS support in CCSS.
  • CCSS Minimize CCSS failures by attempting to automatically fix CSS syntax errors.
  • Cloud Domain Key will be deleted after QUIC.cloud site_not_registered error to avoid endless repeated requests.
  • CDN CDN Original URL will default to WP Site URL if not set. (@ruikai)
  • CLI Global output format --format=json/yaml/dump and --json support in CLI. (@alya1992)
  • CDN Improved handling of non-image CSS url() sources in CDN. (@daniel McD)
  • CDN Fixed CDN replacement conflict w/ JS/CSS Optimize. (@ankit)
  • Crawler Only reset Crawler waiting queues when crawling begins. (@ruikai)
  • Network Network Enable Cache is no longer reset to ON Use Network Settings in enabled. (@RavanH)
  • Activation Fixed a PHP warning that appeared during uninstall. (@RavanH)
  • Debug Automatically omit long strings when dumping an array to debug log.
  • Report Subsites report now shows overwritten values along w/ original values. (#52593959)
  • REST Improved WP5.5 REST compatibility. (@oldrup)
  • GUI Server IP setting moved from Crawler menu to General menu.
  • GUI Localize resources moved to Localization tab.
  • Config News option now defaults to ON.
Download this release

Release Info

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

Code changes from version 3.2.4 to 3.3

Files changed (84) hide show
  1. cli/online.cls.php +22 -4
  2. cli/option.cls.php +78 -79
  3. data/const.default.ini +41 -1
  4. data/esi.nonce.txt +7 -1
  5. lang/litespeed-cache.pot +596 -477
  6. litespeed-cache.php +2 -2
  7. readme.txt +32 -5
  8. src/admin-display.cls.php +204 -266
  9. src/admin-settings.cls.php +0 -13
  10. src/base.cls.php +190 -208
  11. src/cdn.cls.php +131 -138
  12. src/cdn/cloudflare.cls.php +113 -122
  13. src/cloud.cls.php +40 -62
  14. src/conf.cls.php +10 -1
  15. src/control.cls.php +185 -215
  16. src/core.cls.php +11 -22
  17. src/crawler-map.cls.php +16 -32
  18. src/crawler.cls.php +75 -62
  19. src/css.cls.php +150 -88
  20. src/data.cls.php +2 -2
  21. src/db-optm.cls.php +8 -16
  22. src/debug2.cls.php +136 -140
  23. src/doc.cls.php +32 -22
  24. src/error.cls.php +22 -21
  25. src/file.cls.php +138 -136
  26. src/gui.cls.php +24 -6
  27. src/lang.cls.php +3 -0
  28. src/localization.cls.php +89 -0
  29. src/optimize.cls.php +406 -380
  30. src/optimizer.cls.php +110 -98
  31. src/placeholder.cls.php +132 -142
  32. src/purge.cls.php +119 -109
  33. src/report.cls.php +10 -2
  34. src/rest.cls.php +7 -0
  35. src/router.cls.php +6 -2
  36. src/str.cls.php +26 -28
  37. src/tag.cls.php +32 -32
  38. src/task.cls.php +7 -14
  39. src/utility.cls.php +20 -2
  40. thirdparty/woocommerce.content.tpl.php +24 -23
  41. tpl/cache/network_settings-advanced.tpl.php +1 -1
  42. tpl/cache/network_settings-cache.tpl.php +1 -1
  43. tpl/cache/network_settings-excludes.tpl.php +1 -1
  44. tpl/cache/network_settings-purge.tpl.php +1 -1
  45. tpl/cache/settings-advanced.tpl.php +3 -3
  46. tpl/cache/settings-cache.tpl.php +1 -1
  47. tpl/cache/settings-esi.tpl.php +4 -4
  48. tpl/cache/settings-excludes.tpl.php +1 -1
  49. tpl/cache/settings-purge.tpl.php +7 -7
  50. tpl/cache/settings-ttl.tpl.php +1 -1
  51. tpl/cache/settings_inc.browser.tpl.php +2 -2
  52. tpl/cache/settings_inc.cache_dropquery.tpl.php +1 -1
  53. tpl/cache/settings_inc.cache_mobile.tpl.php +19 -19
  54. tpl/cache/settings_inc.object.tpl.php +4 -4
  55. tpl/cdn/settings.tpl.php +90 -90
  56. tpl/crawler/blacklist.tpl.php +1 -1
  57. tpl/crawler/map.tpl.php +1 -1
  58. tpl/crawler/settings-general.tpl.php +1 -20
  59. tpl/crawler/settings-simulation.tpl.php +2 -2
  60. tpl/crawler/settings-sitemap.tpl.php +1 -1
  61. tpl/crawler/summary.tpl.php +1 -1
  62. tpl/db_optm/manage.tpl.php +1 -1
  63. tpl/db_optm/settings.tpl.php +1 -1
  64. tpl/general/network_settings.tpl.php +1 -1
  65. tpl/general/settings.tpl.php +27 -8
  66. tpl/img_optm/network_settings.tpl.php +6 -6
  67. tpl/img_optm/settings.tpl.php +58 -58
  68. tpl/page_optm/entry.tpl.php +1 -1
  69. tpl/page_optm/settings_css.tpl.php +3 -3
  70. tpl/page_optm/settings_discussion.tpl.php +0 -86
  71. tpl/page_optm/settings_html.tpl.php +62 -63
  72. tpl/page_optm/settings_js.tpl.php +30 -30
  73. tpl/page_optm/settings_localization.tpl.php +140 -0
  74. tpl/page_optm/settings_media.tpl.php +4 -4
  75. tpl/page_optm/settings_media_exc.tpl.php +41 -41
  76. tpl/page_optm/settings_tuning.tpl.php +85 -71
  77. tpl/toolbox/beta_test.tpl.php +4 -4
  78. tpl/toolbox/edit_htaccess.tpl.php +1 -1
  79. tpl/toolbox/heartbeat.tpl.php +44 -44
  80. tpl/toolbox/import_export.tpl.php +17 -17
  81. tpl/toolbox/log_viewer.tpl.php +12 -12
  82. tpl/toolbox/purge.tpl.php +11 -2
  83. tpl/toolbox/report.tpl.php +1 -1
  84. tpl/toolbox/settings-debug.tpl.php +49 -49
cli/online.cls.php CHANGED
@@ -50,10 +50,15 @@ class Online
50
  * $ wp litespeed-online sync
51
  *
52
  */
53
- public function sync()
54
  {
55
  $json = $this->__cloud->sync_usage();
56
 
 
 
 
 
 
57
  WP_CLI::success( 'Sync successfully' );
58
 
59
  $list = array();
@@ -81,8 +86,13 @@ class Online
81
  * $ wp litespeed-online services
82
  *
83
  */
84
- public function services()
85
  {
 
 
 
 
 
86
  $list = array();
87
  foreach ( Cloud::$SERVICES as $v ) {
88
  $list[] = array(
@@ -104,16 +114,24 @@ class Online
104
  * $ wp litespeed-online nodes
105
  *
106
  */
107
- public function nodes()
108
  {
109
  $json = Cloud::get_summary();
110
 
111
  $list = array();
 
112
  foreach ( Cloud::$SERVICES as $v ) {
 
113
  $list[] = array(
114
  'service' => $v,
115
- 'server' => ! empty( $json[ 'server.' . $v ] ) ? $json[ 'server.' . $v ] : '',
116
  );
 
 
 
 
 
 
117
  }
118
 
119
  WP_CLI\Utils\format_items( 'table', $list, array( 'service', 'server' ) );
50
  * $ wp litespeed-online sync
51
  *
52
  */
53
+ public function sync( $args, $assoc_args )
54
  {
55
  $json = $this->__cloud->sync_usage();
56
 
57
+ if ( ! empty( $assoc_args[ 'format' ] ) ) {
58
+ WP_CLI::print_value( $json, $assoc_args );
59
+ return;
60
+ }
61
+
62
  WP_CLI::success( 'Sync successfully' );
63
 
64
  $list = array();
86
  * $ wp litespeed-online services
87
  *
88
  */
89
+ public function services( $args, $assoc_args )
90
  {
91
+ if ( ! empty( $assoc_args[ 'format' ] ) ) {
92
+ WP_CLI::print_value( Cloud::$SERVICES, $assoc_args );
93
+ return;
94
+ }
95
+
96
  $list = array();
97
  foreach ( Cloud::$SERVICES as $v ) {
98
  $list[] = array(
114
  * $ wp litespeed-online nodes
115
  *
116
  */
117
+ public function nodes( $args, $assoc_args )
118
  {
119
  $json = Cloud::get_summary();
120
 
121
  $list = array();
122
+ $json_output = array();
123
  foreach ( Cloud::$SERVICES as $v ) {
124
+ $server = ! empty( $json[ 'server.' . $v ] ) ? $json[ 'server.' . $v ] : '';
125
  $list[] = array(
126
  'service' => $v,
127
+ 'server' => $server,
128
  );
129
+ $json_output[] = array( $v => $server );
130
+ }
131
+
132
+ if ( ! empty( $assoc_args[ 'format' ] ) ) {
133
+ WP_CLI::print_value( $json_output, $assoc_args );
134
+ return;
135
  }
136
 
137
  WP_CLI\Utils\format_items( 'table', $list, array( 'service', 'server' ) );
cli/option.cls.php CHANGED
@@ -14,12 +14,10 @@ use WP_CLI;
14
  /**
15
  * LiteSpeed Cache option Interface
16
  */
17
- class Option extends Base
18
- {
19
  private $__cfg;
20
 
21
- public function __construct()
22
- {
23
  $this->__cfg = Conf::get_instance();
24
  }
25
 
@@ -41,8 +39,7 @@ class Option extends Base
41
  * $ wp litespeed-option set 'cdn-mapping[url][0]' https://cdn.EXAMPLE.com
42
  *
43
  */
44
- public function set( $args, $assoc_args )
45
- {
46
  /**
47
  * Note: If the value is multiple dimensions like cdn-mapping, need to specially handle it both here and in `const.default.ini`
48
  *
@@ -54,8 +51,8 @@ class Option extends Base
54
  * `set cdn-mapping[inc_js][0] ''`
55
  * `set cdn-mapping[filetype][0] ''`
56
  */
57
- $key = $args[ 0 ] ;
58
- $val = $args[ 1 ] ;
59
 
60
  /**
61
  * For CDN mapping, allow:
@@ -72,20 +69,20 @@ class Option extends Base
72
  // Build raw data
73
  $raw_data = array(
74
  Admin_Settings::ENROLL => array( $key ),
75
- ) ;
76
 
77
  // Contains child set
78
  if ( strpos( $key, '[' ) ) {
79
- parse_str( $key . '=' . $val , $key2 ) ;
80
- $raw_data = array_merge( $raw_data, $key2 ) ;
81
  }
82
  else {
83
- $raw_data[ $key ] = $val ;
84
  }
85
 
86
- Admin_Settings::get_instance()->save( $raw_data ) ;
87
- WP_CLI::line( "$key:" ) ;
88
- $this->get( $args, $assoc_args ) ;
89
 
90
  }
91
 
@@ -98,15 +95,21 @@ class Option extends Base
98
  *
99
  * # Get all options
100
  * $ wp litespeed-option all
 
101
  *
102
  */
103
- public function all( $args, $assoc_args )
104
- {
105
- $options = $this->__cfg->get_options() ;
106
- $option_out = array() ;
107
 
108
- $buf = WP_CLI::colorize("%CThe list of options:%n") ;
109
- WP_CLI::line($buf) ;
 
 
 
 
 
 
 
110
 
111
  foreach( $options as $k => $v ) {
112
  if ( $k == self::O_CDN_MAPPING || $k == self::O_CRAWLER_COOKIES ) {
@@ -114,42 +117,42 @@ class Option extends Base
114
  if ( is_array( $v2 ) ) {
115
  foreach ( $v2 as $k3 => $v3 ) { // $k3 = 'url/inc_img/name/vals'
116
  if ( is_array( $v3 ) ) {
117
- $option_out[] = array( 'key' => '', 'value' => '' ) ;
118
  foreach ( $v3 as $k4 => $v4 ) {
119
- $option_out[] = array( 'key' => $k4 == 0 ? "{$k}[$k3][$k2]" : '', 'value' => $v4 ) ;
120
  }
121
- $option_out[] = array( 'key' => '', 'value' => '' ) ;
122
  }
123
  else {
124
- $option_out[] = array( 'key' => "{$k}[$k3][$k2]", 'value' => $v3 ) ;
125
  }
126
  }
127
  }
128
  }
129
- continue ;
130
  }
131
  elseif ( is_array( $v ) && $v ) {
132
- // $v = implode( PHP_EOL, $v ) ;
133
- $option_out[] = array( 'key' => '', 'value' => '' ) ;
134
  foreach ( $v as $k2 => $v2 ) {
135
- $option_out[] = array( 'key' => $k2 == 0 ? $k : '', 'value' => $v2 ) ;
136
  }
137
- $option_out[] = array( 'key' => '', 'value' => '' ) ;
138
- continue ;
139
  }
140
 
141
  if ( array_key_exists( $k, self::$_default_options ) && is_bool( self::$_default_options[ $k ] ) && ! $v ) {
142
- $v = 0 ;
143
  }
144
 
145
  if ( $v === '' || $v === array() ) {
146
- $v = "''" ;
147
  }
148
 
149
- $option_out[] = array( 'key' => $k, 'value' => $v ) ;
150
  }
151
 
152
- WP_CLI\Utils\format_items('table', $option_out, array('key', 'value')) ;
153
  }
154
 
155
  /**
@@ -164,25 +167,24 @@ class Option extends Base
164
  * $ wp litespeed-option get 'cdn-mapping[url][0]'
165
  *
166
  */
167
- public function get( $args, $assoc_args )
168
- {
169
- $id = $args[ 0 ] ;
170
 
171
- $child = false ;
172
  if ( strpos( $id, '[' ) ) {
173
- parse_str( $id, $id2 ) ;
174
- Utility::compatibility() ;
175
- $id = array_key_first( $id2 ) ;
176
 
177
- $child = array_key_first( $id2[ $id ] ) ; // `url`
178
  if ( ! $child ) {
179
- WP_CLI::error( 'Wrong child key' ) ;
180
- return ;
181
  }
182
- $numeric = array_key_first( $id2[ $id ][ $child ] ) ; // `0`
183
  if ( $numeric === null ) {
184
- WP_CLI::error( 'Wrong 2nd level numeric key' ) ;
185
- return ;
186
  }
187
  }
188
 
@@ -191,7 +193,7 @@ class Option extends Base
191
  return;
192
  }
193
 
194
- $v = Conf::val( $id ) ;
195
  $default_v = self::$_default_options[ $id ];
196
 
197
  /**
@@ -208,8 +210,8 @@ class Option extends Base
208
  self::CDN_MAPPING_INC_JS,
209
  self::CDN_MAPPING_FILETYPE,
210
  ) ) ) {
211
- WP_CLI::error( 'Wrong child key' ) ;
212
- return ;
213
  }
214
  }
215
  if ( $id == self::O_CRAWLER_COOKIES ) {
@@ -217,14 +219,14 @@ class Option extends Base
217
  self::CRWL_COOKIE_NAME,
218
  self::CRWL_COOKIE_VALS,
219
  ) ) ) {
220
- WP_CLI::error( 'Wrong child key' ) ;
221
- return ;
222
  }
223
  }
224
 
225
  if ( $id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES ) {
226
  if ( ! empty( $v[ $numeric ][ $child ] ) ) {
227
- $v = $v[ $numeric ][ $child ] ;
228
  }
229
  else {
230
  if ( $id == self::O_CDN_MAPPING ) {
@@ -233,32 +235,32 @@ class Option extends Base
233
  self::CDN_MAPPING_INC_CSS,
234
  self::CDN_MAPPING_INC_JS,
235
  ) ) ) {
236
- $v = 0 ;
237
  }
238
  else {
239
- $v = "''" ;
240
  }
241
  }
242
  else {
243
- $v = "''" ;
244
  }
245
  }
246
  }
247
 
248
  if ( is_array( $v ) ) {
249
- $v = implode( PHP_EOL , $v ) ;
250
  }
251
 
252
  if ( ! $v && $id != self::O_CDN_MAPPING && $id != self::O_CRAWLER_COOKIES ) { // empty array for CDN/crawler has been handled
253
  if ( is_bool( $default_v ) ) {
254
- $v = 0 ;
255
  }
256
  elseif ( ! is_array( $default_v ) ) {
257
- $v = "''" ;
258
  }
259
  }
260
 
261
- WP_CLI::line( $v ) ;
262
  }
263
 
264
  /**
@@ -276,27 +278,26 @@ class Option extends Base
276
  * $ wp litespeed-option export
277
  *
278
  */
279
- public function export( $args, $assoc_args )
280
- {
281
  if ( isset($assoc_args['filename']) ) {
282
- $file = $assoc_args['filename'] ;
283
  }
284
  else {
285
- $file = getcwd() . '/litespeed_options_' . date('d_m_Y-His') . '.data' ;
286
  }
287
 
288
  if ( ! is_writable(dirname($file)) ) {
289
- WP_CLI::error('Directory not writable.') ;
290
- return ;
291
  }
292
 
293
  $data = Import::get_instance()->export( true );
294
 
295
  if ( file_put_contents( $file, $data ) === false ) {
296
- WP_CLI::error( 'Failed to create file.' ) ;
297
  }
298
  else {
299
- WP_CLI::success('Created file ' . $file) ;
300
  }
301
  }
302
 
@@ -319,20 +320,19 @@ class Option extends Base
319
  * $ wp litespeed-option import options.txt
320
  *
321
  */
322
- public function import( $args, $assoc_args )
323
- {
324
- $file = $args[0] ;
325
  if ( ! file_exists($file) || ! is_readable($file) ) {
326
- WP_CLI::error('File does not exist or is not readable.') ;
327
  }
328
 
329
- $res = Import::get_instance()->import( $file ) ;
330
 
331
  if ( ! $res ) {
332
- WP_CLI::error( 'Failed to parse serialized data from file.' ) ;
333
  }
334
 
335
- WP_CLI::success( 'Options imported. [File] ' . $file ) ;
336
  }
337
 
338
  /**
@@ -344,9 +344,8 @@ class Option extends Base
344
  * $ wp litespeed-option reset
345
  *
346
  */
347
- public function reset()
348
- {
349
- Import::get_instance()->reset() ;
350
  }
351
 
352
  }
14
  /**
15
  * LiteSpeed Cache option Interface
16
  */
17
+ class Option extends Base {
 
18
  private $__cfg;
19
 
20
+ public function __construct() {
 
21
  $this->__cfg = Conf::get_instance();
22
  }
23
 
39
  * $ wp litespeed-option set 'cdn-mapping[url][0]' https://cdn.EXAMPLE.com
40
  *
41
  */
42
+ public function set( $args, $assoc_args ) {
 
43
  /**
44
  * Note: If the value is multiple dimensions like cdn-mapping, need to specially handle it both here and in `const.default.ini`
45
  *
51
  * `set cdn-mapping[inc_js][0] ''`
52
  * `set cdn-mapping[filetype][0] ''`
53
  */
54
+ $key = $args[ 0 ];
55
+ $val = $args[ 1 ];
56
 
57
  /**
58
  * For CDN mapping, allow:
69
  // Build raw data
70
  $raw_data = array(
71
  Admin_Settings::ENROLL => array( $key ),
72
+ );
73
 
74
  // Contains child set
75
  if ( strpos( $key, '[' ) ) {
76
+ parse_str( $key . '=' . $val , $key2 );
77
+ $raw_data = array_merge( $raw_data, $key2 );
78
  }
79
  else {
80
+ $raw_data[ $key ] = $val;
81
  }
82
 
83
+ Admin_Settings::get_instance()->save( $raw_data );
84
+ WP_CLI::line( "$key:" );
85
+ $this->get( $args, $assoc_args );
86
 
87
  }
88
 
95
  *
96
  * # Get all options
97
  * $ wp litespeed-option all
98
+ * $ wp litespeed-option all --json
99
  *
100
  */
101
+ public function all( $args, $assoc_args ) {
102
+ $options = $this->__cfg->get_options();
 
 
103
 
104
+ if ( ! empty( $assoc_args[ 'format' ] ) ) {
105
+ WP_CLI::print_value( $options, $assoc_args );
106
+ return;
107
+ }
108
+
109
+ $option_out = array();
110
+
111
+ $buf = WP_CLI::colorize("%CThe list of options:%n");
112
+ WP_CLI::line($buf);
113
 
114
  foreach( $options as $k => $v ) {
115
  if ( $k == self::O_CDN_MAPPING || $k == self::O_CRAWLER_COOKIES ) {
117
  if ( is_array( $v2 ) ) {
118
  foreach ( $v2 as $k3 => $v3 ) { // $k3 = 'url/inc_img/name/vals'
119
  if ( is_array( $v3 ) ) {
120
+ $option_out[] = array( 'key' => '', 'value' => '' );
121
  foreach ( $v3 as $k4 => $v4 ) {
122
+ $option_out[] = array( 'key' => $k4 == 0 ? "{$k}[$k3][$k2]" : '', 'value' => $v4 );
123
  }
124
+ $option_out[] = array( 'key' => '', 'value' => '' );
125
  }
126
  else {
127
+ $option_out[] = array( 'key' => "{$k}[$k3][$k2]", 'value' => $v3 );
128
  }
129
  }
130
  }
131
  }
132
+ continue;
133
  }
134
  elseif ( is_array( $v ) && $v ) {
135
+ // $v = implode( PHP_EOL, $v );
136
+ $option_out[] = array( 'key' => '', 'value' => '' );
137
  foreach ( $v as $k2 => $v2 ) {
138
+ $option_out[] = array( 'key' => $k2 == 0 ? $k : '', 'value' => $v2 );
139
  }
140
+ $option_out[] = array( 'key' => '', 'value' => '' );
141
+ continue;
142
  }
143
 
144
  if ( array_key_exists( $k, self::$_default_options ) && is_bool( self::$_default_options[ $k ] ) && ! $v ) {
145
+ $v = 0;
146
  }
147
 
148
  if ( $v === '' || $v === array() ) {
149
+ $v = "''";
150
  }
151
 
152
+ $option_out[] = array( 'key' => $k, 'value' => $v );
153
  }
154
 
155
+ WP_CLI\Utils\format_items('table', $option_out, array('key', 'value'));
156
  }
157
 
158
  /**
167
  * $ wp litespeed-option get 'cdn-mapping[url][0]'
168
  *
169
  */
170
+ public function get( $args, $assoc_args ) {
171
+ $id = $args[ 0 ];
 
172
 
173
+ $child = false;
174
  if ( strpos( $id, '[' ) ) {
175
+ parse_str( $id, $id2 );
176
+ Utility::compatibility();
177
+ $id = array_key_first( $id2 );
178
 
179
+ $child = array_key_first( $id2[ $id ] ); // `url`
180
  if ( ! $child ) {
181
+ WP_CLI::error( 'Wrong child key' );
182
+ return;
183
  }
184
+ $numeric = array_key_first( $id2[ $id ][ $child ] ); // `0`
185
  if ( $numeric === null ) {
186
+ WP_CLI::error( 'Wrong 2nd level numeric key' );
187
+ return;
188
  }
189
  }
190
 
193
  return;
194
  }
195
 
196
+ $v = Conf::val( $id );
197
  $default_v = self::$_default_options[ $id ];
198
 
199
  /**
210
  self::CDN_MAPPING_INC_JS,
211
  self::CDN_MAPPING_FILETYPE,
212
  ) ) ) {
213
+ WP_CLI::error( 'Wrong child key' );
214
+ return;
215
  }
216
  }
217
  if ( $id == self::O_CRAWLER_COOKIES ) {
219
  self::CRWL_COOKIE_NAME,
220
  self::CRWL_COOKIE_VALS,
221
  ) ) ) {
222
+ WP_CLI::error( 'Wrong child key' );
223
+ return;
224
  }
225
  }
226
 
227
  if ( $id == self::O_CDN_MAPPING || $id == self::O_CRAWLER_COOKIES ) {
228
  if ( ! empty( $v[ $numeric ][ $child ] ) ) {
229
+ $v = $v[ $numeric ][ $child ];
230
  }
231
  else {
232
  if ( $id == self::O_CDN_MAPPING ) {
235
  self::CDN_MAPPING_INC_CSS,
236
  self::CDN_MAPPING_INC_JS,
237
  ) ) ) {
238
+ $v = 0;
239
  }
240
  else {
241
+ $v = "''";
242
  }
243
  }
244
  else {
245
+ $v = "''";
246
  }
247
  }
248
  }
249
 
250
  if ( is_array( $v ) ) {
251
+ $v = implode( PHP_EOL , $v );
252
  }
253
 
254
  if ( ! $v && $id != self::O_CDN_MAPPING && $id != self::O_CRAWLER_COOKIES ) { // empty array for CDN/crawler has been handled
255
  if ( is_bool( $default_v ) ) {
256
+ $v = 0;
257
  }
258
  elseif ( ! is_array( $default_v ) ) {
259
+ $v = "''";
260
  }
261
  }
262
 
263
+ WP_CLI::line( $v );
264
  }
265
 
266
  /**
278
  * $ wp litespeed-option export
279
  *
280
  */
281
+ public function export( $args, $assoc_args ) {
 
282
  if ( isset($assoc_args['filename']) ) {
283
+ $file = $assoc_args['filename'];
284
  }
285
  else {
286
+ $file = getcwd() . '/litespeed_options_' . date('d_m_Y-His') . '.data';
287
  }
288
 
289
  if ( ! is_writable(dirname($file)) ) {
290
+ WP_CLI::error('Directory not writable.');
291
+ return;
292
  }
293
 
294
  $data = Import::get_instance()->export( true );
295
 
296
  if ( file_put_contents( $file, $data ) === false ) {
297
+ WP_CLI::error( 'Failed to create file.' );
298
  }
299
  else {
300
+ WP_CLI::success('Created file ' . $file);
301
  }
302
  }
303
 
320
  * $ wp litespeed-option import options.txt
321
  *
322
  */
323
+ public function import( $args, $assoc_args ) {
324
+ $file = $args[0];
 
325
  if ( ! file_exists($file) || ! is_readable($file) ) {
326
+ WP_CLI::error('File does not exist or is not readable.');
327
  }
328
 
329
+ $res = Import::get_instance()->import( $file );
330
 
331
  if ( ! $res ) {
332
+ WP_CLI::error( 'Failed to parse serialized data from file.' );
333
  }
334
 
335
+ WP_CLI::success( 'Options imported. [File] ' . $file );
336
  }
337
 
338
  /**
344
  * $ wp litespeed-option reset
345
  *
346
  */
347
+ public function reset() {
348
+ Import::get_instance()->reset();
 
349
  }
350
 
351
  }
data/const.default.ini CHANGED
@@ -20,7 +20,7 @@ api_key = ''
20
  server_ip = ''
21
 
22
  ; O_NEWS
23
- news = false
24
 
25
 
26
  ;; -------------------------------------------------- ;;
@@ -372,6 +372,46 @@ discuss-avatar_cron = false
372
  ; O_DISCUSS_AVATAR_CACHE_TTL
373
  discuss-avatar_cache_ttl = 604800
374
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
 
376
 
377
 
20
  server_ip = ''
21
 
22
  ; O_NEWS
23
+ news = true
24
 
25
 
26
  ;; -------------------------------------------------- ;;
372
  ; O_DISCUSS_AVATAR_CACHE_TTL
373
  discuss-avatar_cache_ttl = 604800
374
 
375
+ ; O_OPTM_LOCALIZE
376
+ optm-localize = false
377
+
378
+ ; O_OPTM_LOCALIZE_DOMAINS
379
+ optm-localize_domains = '### some CDNs
380
+ https://ajax.aspnetcdn.com
381
+ https://ajax.cloudflare.com/
382
+ https://ajax.googleapis.com/ajax/
383
+ https://cdn.jsdelivr.net/
384
+ https://cdnjs.com/
385
+ https://cdnjs.cloudflare.com/
386
+ https://code.jquery.com/
387
+ https://maxcdn.bootstrapcdn.com/
388
+ https://netdna.bootstrapcdn.com/
389
+ https://oss.maxcdn.com/
390
+ https://stackpath.bootstrapcdn.com/
391
+ ### Popular scripts ###
392
+ https://a.optmnstr.com/app/js/
393
+ https://cdn.onesignal.com/sdks/
394
+ https://cdn.optimizely.com/
395
+ https://cdn.shopify.com/s/
396
+ https://css3-mediaqueries-js.googlecode.com/svn/
397
+ https://html5shim.googlecode.com/svn/
398
+ https://html5shiv.googlecode.com/svn/
399
+ https://maps.google.com/maps/api/js
400
+ https://maps.googleapis.com/maps/api/js
401
+ https://pagead2.googlesyndication.com/pagead/js/
402
+ https://platform.twitter.com/widgets.js
403
+ https://platform-api.sharethis.com/js/
404
+ https://s7.addthis.com/js/
405
+ https://stats.wp.com/
406
+ https://ws.sharethis.com/button/
407
+ https://www.google.com/recaptcha/api.js
408
+ https://www.google-analytics.com/analytics.js
409
+ https://www.googletagmanager.com/gtag/js
410
+ https://www.googletagmanager.com/gtm.js
411
+ https://www.googletagservices.com/tag/js/gpt.js
412
+ https://connect.facebook.net/en_US/fbevents.js
413
+ https://connect.facebook.net/signals/config/'
414
+
415
 
416
 
417
 
data/esi.nonce.txt CHANGED
@@ -27,4 +27,10 @@ cmreg_registration_nonce private
27
  role_nonce private
28
 
29
  # WooCommerce Delivery Area Pro #16843635
30
- wdap-call-nonce private
 
 
 
 
 
 
27
  role_nonce private
28
 
29
  # WooCommerce Delivery Area Pro #16843635
30
+ wdap-call-nonce private
31
+
32
+ # SEOpress Cookie Consent
33
+ seopress_cookies_user_consent_nonce
34
+
35
+ #SearchWP Metrics
36
+ swpmtxnonce
lang/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 3.2.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
- "POT-Creation-Date: 2020-06-18 16:41:21+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -36,63 +36,63 @@ msgstr ""
36
  msgid "Upgraded successfully."
37
  msgstr ""
38
 
39
- #: src/admin-display.cls.php:154 tpl/dash/entry.tpl.php:6
40
  msgid "Dashboard"
41
  msgstr ""
42
 
43
- #: src/admin-display.cls.php:156
44
  msgid "General"
45
  msgstr ""
46
 
47
- #: src/admin-display.cls.php:158 tpl/cache/entry.tpl.php:6
48
  #: tpl/cache/entry_network.tpl.php:6
49
  msgid "Cache"
50
  msgstr ""
51
 
52
- #: src/admin-display.cls.php:160 tpl/cdn/settings.tpl.php:253
53
  msgid "CDN"
54
  msgstr ""
55
 
56
- #: src/admin-display.cls.php:162 src/gui.cls.php:611
57
  #: tpl/dash/dashboard.tpl.php:52 tpl/dash/network_dash.tpl.php:27
58
  msgid "Image Optimization"
59
  msgstr ""
60
 
61
- #: src/admin-display.cls.php:164
62
  msgid "Page Optimization"
63
  msgstr ""
64
 
65
- #: src/admin-display.cls.php:166
66
  msgid "Database"
67
  msgstr ""
68
 
69
- #: src/admin-display.cls.php:168 src/lang.cls.php:210
70
  msgid "Crawler"
71
  msgstr ""
72
 
73
- #: src/admin-display.cls.php:170
74
  msgid "Toolbox"
75
  msgstr ""
76
 
77
- #: src/admin-display.cls.php:259 src/gui.cls.php:602
78
  msgid "Settings"
79
  msgstr ""
80
 
81
- #: src/admin-display.cls.php:279
82
  msgid ""
83
  "It is recommended that LiteSpeed Cache be purged after updating a plugin."
84
  msgstr ""
85
 
86
- #: src/admin-display.cls.php:674
87
  msgid "Save Changes"
88
  msgstr ""
89
 
90
- #: src/admin-display.cls.php:795 src/admin-display.cls.php:831
91
- #: src/admin-display.cls.php:883 tpl/cache/settings-cache.tpl.php:19
92
  #: tpl/cache/settings_inc.cache_mobile.tpl.php:70 tpl/cdn/settings.tpl.php:49
93
- #: tpl/page_optm/settings_css.tpl.php:54 tpl/page_optm/settings_css.tpl.php:92
94
- #: tpl/page_optm/settings_css.tpl.php:109
95
- #: tpl/page_optm/settings_css.tpl.php:110 tpl/page_optm/settings_js.tpl.php:89
96
  #: tpl/page_optm/settings_media.tpl.php:156
97
  #: tpl/page_optm/settings_tuning.tpl.php:36
98
  #: tpl/page_optm/settings_tuning.tpl.php:78
@@ -100,11 +100,12 @@ msgstr ""
100
  msgid "ON"
101
  msgstr ""
102
 
103
- #: src/admin-display.cls.php:796 src/admin-display.cls.php:830
104
- #: src/admin-display.cls.php:883 tpl/cache/settings-cache.tpl.php:19
105
  #: tpl/cache/settings_inc.object.tpl.php:210 tpl/cdn/settings.tpl.php:49
106
- #: tpl/cdn/settings.tpl.php:237 tpl/page_optm/settings_css.tpl.php:109
107
- #: tpl/page_optm/settings_css.tpl.php:124
 
108
  #: tpl/page_optm/settings_media.tpl.php:159
109
  #: tpl/page_optm/settings_tuning.tpl.php:33
110
  #: tpl/page_optm/settings_tuning.tpl.php:75
@@ -112,67 +113,67 @@ msgstr ""
112
  msgid "OFF"
113
  msgstr ""
114
 
115
- #: src/admin-display.cls.php:895
116
  msgid "This setting is overwritten by the PHP constant %s"
117
  msgstr ""
118
 
119
- #: src/admin-display.cls.php:897
120
  msgid "This setting is overwritten by the primary site setting"
121
  msgstr ""
122
 
123
- #: src/admin-display.cls.php:900
124
  msgid "currently set to %s"
125
  msgstr ""
126
 
127
- #: src/admin-display.cls.php:911 tpl/cache/settings_inc.object.tpl.php:103
128
  #: tpl/crawler/settings-general.tpl.php:60
129
  #: tpl/crawler/settings-general.tpl.php:74
130
  #: tpl/crawler/settings-general.tpl.php:89 tpl/esi_widget_edit.php:70
131
  msgid "seconds"
132
  msgstr ""
133
 
134
- #: src/admin-display.cls.php:934 src/admin-display.cls.php:939
135
  msgid "Recommended value"
136
  msgstr ""
137
 
138
- #: src/admin-display.cls.php:964
139
  msgid "Invalid rewrite rule"
140
  msgstr ""
141
 
142
- #: src/admin-display.cls.php:982
143
  msgid "Path must end with %s"
144
  msgstr ""
145
 
146
- #: src/admin-display.cls.php:1001
147
  msgid "Minimum value"
148
  msgstr ""
149
 
150
- #: src/admin-display.cls.php:1004
151
  msgid "Maximum value"
152
  msgstr ""
153
 
154
- #: src/admin-display.cls.php:1016
155
  msgid "Zero, or"
156
  msgstr ""
157
 
158
- #: src/admin-display.cls.php:1023
159
  msgid "Larger than"
160
  msgstr ""
161
 
162
- #: src/admin-display.cls.php:1026
163
  msgid "Smaller than"
164
  msgstr ""
165
 
166
- #: src/admin-display.cls.php:1029
167
  msgid "Value range"
168
  msgstr ""
169
 
170
- #: src/admin-display.cls.php:1055
171
  msgid "Invalid IP"
172
  msgstr ""
173
 
174
- #: src/admin-display.cls.php:1076 tpl/page_optm/settings_css.tpl.php:94
175
- #: tpl/page_optm/settings_html.tpl.php:127
176
  #: tpl/page_optm/settings_media_exc.tpl.php:25
177
  #: tpl/page_optm/settings_tuning.tpl.php:39
178
  #: tpl/page_optm/settings_tuning.tpl.php:58
@@ -182,173 +183,176 @@ msgstr ""
182
  msgid "API"
183
  msgstr ""
184
 
185
- #: src/admin-display.cls.php:1077
186
  msgid "Server variable(s) %s available to override this setting."
187
  msgstr ""
188
 
189
- #: src/admin-display.cls.php:1095 src/doc.cls.php:38 src/doc.cls.php:62
190
- #: tpl/cdn/manage.tpl.php:66 tpl/dash/dashboard.tpl.php:46
191
- #: tpl/img_optm/summary.tpl.php:56 tpl/img_optm/summary.tpl.php:96
192
- #: tpl/inc/check_cache_disabled.php:42
193
- msgid "Learn More"
194
- msgstr ""
195
-
196
- #: src/admin-display.cls.php:1111
197
  msgid "The URLs will be compared to the REQUEST_URI server variable."
198
  msgstr ""
199
 
200
- #: src/admin-display.cls.php:1112
201
  msgid "For example, for %s, %s can be used here."
202
  msgstr ""
203
 
204
- #: src/admin-display.cls.php:1114
205
  msgid "To match the beginning, add %s to the beginning of the item."
206
  msgstr ""
207
 
208
- #: src/admin-display.cls.php:1115
209
  msgid "To do an exact match, add %s to the end of the URL."
210
  msgstr ""
211
 
212
- #: src/admin-display.cls.php:1116 src/doc.cls.php:49
213
  msgid "One per line."
214
  msgstr ""
215
 
216
- #: src/admin-display.cls.php:1131
217
  msgid "%s groups"
218
  msgstr ""
219
 
220
- #: src/admin-display.cls.php:1134
221
  msgid "%s images"
222
  msgstr ""
223
 
224
- #: src/admin-display.cls.php:1144
225
  msgid "%s group"
226
  msgstr ""
227
 
228
- #: src/admin-display.cls.php:1147
229
  msgid "%s image"
230
  msgstr ""
231
 
232
- #: src/admin-settings.cls.php:281 src/admin-settings.cls.php:316
233
  msgid "Options saved."
234
  msgstr ""
235
 
236
- #: src/cdn/cloudflare.cls.php:121
237
  msgid "Notified Cloudflare to set development mode to %s successfully."
238
  msgstr ""
239
 
240
- #: src/cdn/cloudflare.cls.php:139
241
  msgid "Cloudflare API is set to off."
242
  msgstr ""
243
 
244
- #: src/cdn/cloudflare.cls.php:155
245
  msgid "Notified Cloudflare to purge all successfully."
246
  msgstr ""
247
 
248
- #: src/cdn/cloudflare.cls.php:170
249
  msgid "No available Cloudflare zone"
250
  msgstr ""
251
 
252
- #: src/cdn/cloudflare.cls.php:258
253
  msgid "Communicated with Cloudflare successfully."
254
  msgstr ""
255
 
256
- #: src/cdn/cloudflare.cls.php:267
257
  msgid "Failed to communicate with Cloudflare"
258
  msgstr ""
259
 
260
- #: src/cloud.cls.php:320 src/cloud.cls.php:339 src/cloud.cls.php:376
261
- #: src/cloud.cls.php:484
262
  msgid "Cloud Error"
263
  msgstr ""
264
 
265
- #: src/cloud.cls.php:376
266
  msgid "No available Cloud Node."
267
  msgstr ""
268
 
269
- #: src/cloud.cls.php:484
270
  msgid "Please try after %1$s for service %2$s."
271
  msgstr ""
272
 
273
- #: src/cloud.cls.php:570 src/cloud.cls.php:582
274
  msgid "Failed to request via WordPress"
275
  msgstr ""
276
 
277
- #: src/cloud.cls.php:592
278
  msgid ""
279
  "We are working hard to improve your online service experience. The service "
280
  "will be unavailable while we work. We apologize for any inconvenience."
281
  msgstr ""
282
 
283
- #: src/cloud.cls.php:601 src/cloud.cls.php:609 src/cloud.cls.php:853
284
  msgid "Message from QUIC.cloud server"
285
  msgstr ""
286
 
287
- #: src/cloud.cls.php:617
288
  msgid "Good news from QUIC.cloud server"
289
  msgstr ""
290
 
291
- #: src/cloud.cls.php:626
292
  msgid "%1$s plugin version %2$s required for this action."
293
  msgstr ""
294
 
295
- #: src/cloud.cls.php:668 src/cloud.cls.php:842
296
  msgid "Failed to communicate with QUIC.cloud server"
297
  msgstr ""
298
 
299
- #: src/cloud.cls.php:817
 
 
 
 
 
 
 
 
 
 
300
  msgid "CLoud Error"
301
  msgstr ""
302
 
303
- #: src/cloud.cls.php:861
304
  msgid ""
305
  "Applied for Domain key successfully. Please wait for result. Domain key will "
306
  "be automatically sent to your WordPress."
307
  msgstr ""
308
 
309
- #: src/cloud.cls.php:914
310
  msgid ""
311
  "Congratulations, your Domain Key has been approved! The setting has been "
312
  "updated accordingly."
313
  msgstr ""
314
 
315
- #: src/cloud.cls.php:989
316
  msgid "Domain key hash mismatch"
317
  msgstr ""
318
 
319
- #: src/cloud.cls.php:1077
320
  msgid "Sync credit allowance with Cloud Server successfully."
321
  msgstr ""
322
 
323
- #: src/conf.cls.php:727
324
  msgid "Changed setting successfully."
325
  msgstr ""
326
 
327
- #: src/core.cls.php:260
328
  msgid "Notified LiteSpeed Web Server to purge everything."
329
  msgstr ""
330
 
331
- #: src/core.cls.php:265
332
  msgid "Notified LiteSpeed Web Server to purge the list."
333
  msgstr ""
334
 
335
- #: src/crawler-map.cls.php:277
336
  msgid "Sitemap cleaned successfully"
337
  msgstr ""
338
 
339
- #: src/crawler-map.cls.php:331
340
  msgid "Sitemap created successfully: %d items"
341
  msgstr ""
342
 
343
- #: src/crawler.cls.php:751
344
  msgid "Guest"
345
  msgstr ""
346
 
347
- #: src/crawler.cls.php:894
348
  msgid "Manually added to blacklist"
349
  msgstr ""
350
 
351
- #: src/crawler.cls.php:897
352
  msgid "Previously existed in blacklist"
353
  msgstr ""
354
 
@@ -358,55 +362,55 @@ msgid ""
358
  "will disappear once upgrade is complete."
359
  msgstr ""
360
 
361
- #: src/db-optm.cls.php:136
362
  msgid "Clean all successfully."
363
  msgstr ""
364
 
365
- #: src/db-optm.cls.php:163
366
  msgid "Clean post revisions successfully."
367
  msgstr ""
368
 
369
- #: src/db-optm.cls.php:167
370
  msgid "Clean auto drafts successfully."
371
  msgstr ""
372
 
373
- #: src/db-optm.cls.php:171
374
  msgid "Clean trashed posts and pages successfully."
375
  msgstr ""
376
 
377
- #: src/db-optm.cls.php:175
378
  msgid "Clean spam comments successfully."
379
  msgstr ""
380
 
381
- #: src/db-optm.cls.php:179
382
  msgid "Clean trashed comments successfully."
383
  msgstr ""
384
 
385
- #: src/db-optm.cls.php:183
386
  msgid "Clean trackbacks and pingbacks successfully."
387
  msgstr ""
388
 
389
- #: src/db-optm.cls.php:187
390
  msgid "Clean expired transients successfully."
391
  msgstr ""
392
 
393
- #: src/db-optm.cls.php:191
394
  msgid "Clean all transients successfully."
395
  msgstr ""
396
 
397
- #: src/db-optm.cls.php:201
398
  msgid "Optimized all tables."
399
  msgstr ""
400
 
401
- #: src/db-optm.cls.php:208
402
  msgid "Clean all CSS/JS optimizer data successfully."
403
  msgstr ""
404
 
405
- #: src/db-optm.cls.php:262
406
  msgid "Converted to InnoDB successfully."
407
  msgstr ""
408
 
409
- #: src/doc.cls.php:26
410
  msgid ""
411
  "This site utilizes caching in order to facilitate a faster response time and "
412
  "better user experience. Caching potentially stores a duplicate copy of every "
@@ -417,166 +421,172 @@ msgid ""
417
  "admin before their natural expiration, if necessary."
418
  msgstr ""
419
 
420
- #: src/doc.cls.php:61
 
 
 
 
 
 
421
  msgid "This setting will edit the .htaccess file."
422
  msgstr ""
423
 
424
- #: src/doc.cls.php:75
425
  msgid ""
426
  "For online services to work correctly, you must whitelist all online server "
427
  "IPs."
428
  msgstr ""
429
 
430
- #: src/doc.cls.php:76
431
  msgid ""
432
  "Before generating key, please verify all IPs on this list are whitelisted"
433
  msgstr ""
434
 
435
- #: src/doc.cls.php:77 tpl/general/settings.tpl.php:89
436
  msgid "Current Online Server IPs"
437
  msgstr ""
438
 
439
- #: src/error.cls.php:45
440
  msgid "The setting %s is currently enabled."
441
  msgstr ""
442
 
443
- #: src/error.cls.php:46
444
- msgid "<a %s>Click here to change</a>."
445
  msgstr ""
446
 
447
- #: src/error.cls.php:50
448
  msgid "You will need to set %s to use the online services."
449
  msgstr ""
450
 
451
- #: src/error.cls.php:51
452
- msgid "<a %s>Click here to set</a>."
453
- msgstr ""
454
-
455
- #: src/error.cls.php:55
456
  msgid "You don't have enough quota for current service left this month."
457
  msgstr ""
458
 
459
- #: src/error.cls.php:59
460
  msgid "You have too many requested images, please try again in a few minutes."
461
  msgstr ""
462
 
463
- #: src/error.cls.php:63
464
  msgid ""
465
  "You have too many notified images, please pull down notified images first."
466
  msgstr ""
467
 
468
- #: src/error.cls.php:67
469
  msgid "The image list is empty."
470
  msgstr ""
471
 
472
- #: src/error.cls.php:71
473
  msgid "Not enough parameters. Please check if the domain key is set correctly"
474
  msgstr ""
475
 
476
- #: src/error.cls.php:75
477
  msgid "There is proceeding queue not pulled yet."
478
  msgstr ""
479
 
480
- #: src/error.cls.php:79
481
  msgid "There is proceeding queue not pulled yet. Queue info: %s."
482
  msgstr ""
483
 
484
- #: src/error.cls.php:83
 
 
 
 
485
  msgid ""
486
  "The domain key is not correct. Please try to sync your domain key again."
487
  msgstr ""
488
 
489
- #: src/error.cls.php:87
490
  msgid "Credits are not enough to proceed the current request."
491
  msgstr ""
492
 
493
- #: src/error.cls.php:91 src/error.cls.php:115
494
  msgid "%s file not writable."
495
  msgstr ""
496
 
497
- #: src/error.cls.php:99
498
  msgid "Could not find %1$s in %2$s."
499
  msgstr ""
500
 
501
- #: src/error.cls.php:103
502
  msgid "Invalid login cookie. Please check the %s file."
503
  msgstr ""
504
 
505
- #: src/error.cls.php:107
506
  msgid "Failed to back up %s file, aborted changes."
507
  msgstr ""
508
 
509
- #: src/error.cls.php:111
510
  msgid "%s file not readable."
511
  msgstr ""
512
 
513
- #: src/error.cls.php:119
514
  msgid "Failed to get %s file contents."
515
  msgstr ""
516
 
517
- #: src/error.cls.php:123
518
  msgid "Failed to create table %s! SQL: %s."
519
  msgstr ""
520
 
521
- #: src/error.cls.php:127
522
  msgid "Crawler disabled by the server admin."
523
  msgstr ""
524
 
525
- #: src/error.cls.php:132
526
  msgid "Previous request too recent. Please try again later."
527
  msgstr ""
528
 
529
- #: src/error.cls.php:136
530
  msgid "Previous request too recent. Please try again after %s."
531
  msgstr ""
532
 
533
- #: src/error.cls.php:140
534
  msgid "Your application is waiting for approval."
535
  msgstr ""
536
 
537
- #: src/error.cls.php:144
538
  msgid "The callback validation to your domain failed due to hash mismatch."
539
  msgstr ""
540
 
541
- #: src/error.cls.php:148
542
  msgid ""
543
  "The callback validation to your domain failed. Please make sure there is no "
544
  "firewall blocking our servers."
545
  msgstr ""
546
 
547
- #: src/error.cls.php:152
548
  msgid ""
549
  "The callback validation to your domain failed. Please make sure there is no "
550
  "firewall blocking our servers. Response code: "
551
  msgstr ""
552
 
553
- #: src/error.cls.php:156
554
  msgid ""
555
  "Your domain has been forbidden from using our services due to a previous "
556
  "policy violation."
557
  msgstr ""
558
 
559
- #: src/error.cls.php:160
560
  msgid "Unknown error"
561
  msgstr ""
562
 
563
- #: src/file.cls.php:131
564
  msgid "Folder does not exist: %s"
565
  msgstr ""
566
 
567
- #: src/file.cls.php:140
568
  msgid "Can not create folder: %1$s. Error: %2$s"
569
  msgstr ""
570
 
571
- #: src/file.cls.php:148
572
  msgid "Folder is not writable: %s."
573
  msgstr ""
574
 
575
- #: src/file.cls.php:155 src/file.cls.php:160
576
  msgid "File %s is not writable."
577
  msgstr ""
578
 
579
- #: src/file.cls.php:167
580
  msgid "Failed to write to %s."
581
  msgstr ""
582
 
@@ -596,118 +606,123 @@ msgstr ""
596
  msgid "Private Cache Hits"
597
  msgstr ""
598
 
599
- #: src/gui.cls.php:420
600
  msgid "Purge this page"
601
  msgstr ""
602
 
603
- #: src/gui.cls.php:428
604
  msgid "Mark this page as "
605
  msgstr ""
606
 
607
- #: src/gui.cls.php:440
608
  msgid "Forced cacheable"
609
  msgstr ""
610
 
611
- #: src/gui.cls.php:451
612
  msgid "Non cacheable"
613
  msgstr ""
614
 
615
- #: src/gui.cls.php:462
616
  msgid "Private cache"
617
  msgstr ""
618
 
619
- #: src/gui.cls.php:473
620
  msgid "No optimization"
621
  msgstr ""
622
 
623
- #: src/gui.cls.php:481
624
  msgid "More settings"
625
  msgstr ""
626
 
627
- #: src/gui.cls.php:488 src/gui.cls.php:496 src/gui.cls.php:504
628
- #: src/gui.cls.php:513 src/gui.cls.php:523 src/gui.cls.php:533
629
- #: src/gui.cls.php:543 src/gui.cls.php:553 src/gui.cls.php:620
630
- #: src/gui.cls.php:628 src/gui.cls.php:636 src/gui.cls.php:645
631
- #: src/gui.cls.php:655 src/gui.cls.php:665 src/gui.cls.php:675
632
- #: src/gui.cls.php:685 src/gui.cls.php:695 tpl/toolbox/purge.tpl.php:39
 
633
  #: tpl/toolbox/purge.tpl.php:45 tpl/toolbox/purge.tpl.php:54
634
  #: tpl/toolbox/purge.tpl.php:63 tpl/toolbox/purge.tpl.php:72
635
  #: tpl/toolbox/purge.tpl.php:81 tpl/toolbox/purge.tpl.php:90
636
- #: tpl/toolbox/purge.tpl.php:99
637
  msgid "Purge All"
638
  msgstr ""
639
 
640
- #: src/gui.cls.php:496 src/gui.cls.php:578 src/gui.cls.php:628
641
  msgid "LSCache"
642
  msgstr ""
643
 
644
- #: src/gui.cls.php:504 src/gui.cls.php:636 tpl/toolbox/purge.tpl.php:45
645
  msgid "CSS/JS Cache"
646
  msgstr ""
647
 
648
- #: src/gui.cls.php:513 src/gui.cls.php:655 src/lang.cls.php:79
649
  #: tpl/dash/dashboard.tpl.php:361 tpl/toolbox/purge.tpl.php:54
650
  msgid "Object Cache"
651
  msgstr ""
652
 
653
- #: src/gui.cls.php:523 src/gui.cls.php:665 tpl/toolbox/purge.tpl.php:63
654
  msgid "Opcode Cache"
655
  msgstr ""
656
 
657
- #: src/gui.cls.php:533 src/gui.cls.php:675 tpl/dash/dashboard.tpl.php:53
658
  #: tpl/dash/dashboard.tpl.php:402 tpl/toolbox/purge.tpl.php:72
659
  msgid "Critical CSS"
660
  msgstr ""
661
 
662
- #: src/gui.cls.php:543 src/gui.cls.php:685 tpl/toolbox/purge.tpl.php:81
 
 
 
 
663
  msgid "LQIP Cache"
664
  msgstr ""
665
 
666
- #: src/gui.cls.php:553 src/gui.cls.php:695 src/lang.cls.php:142
667
- #: tpl/toolbox/purge.tpl.php:90
668
  msgid "Gravatar Cache"
669
  msgstr ""
670
 
671
- #: src/gui.cls.php:578
672
  msgid "LiteSpeed Cache Purge All"
673
  msgstr ""
674
 
675
- #: src/gui.cls.php:594 tpl/cdn/entry.tpl.php:7 tpl/cdn/settings.tpl.php:253
676
  #: tpl/db_optm/entry.tpl.php:6
677
  msgid "Manage"
678
  msgstr ""
679
 
680
- #: src/gui.cls.php:645 tpl/cdn/manage.tpl.php:17
681
  msgid "Cloudflare"
682
  msgstr ""
683
 
684
- #: src/gui.cls.php:715 tpl/img_optm/summary.tpl.php:169
685
  msgid "Remove all previous unfinished image optimization requests."
686
  msgstr ""
687
 
688
- #: src/gui.cls.php:716 tpl/img_optm/summary.tpl.php:171
689
  msgid "Clean Up Unfinished Data"
690
  msgstr ""
691
 
692
- #: src/gui.cls.php:735
693
  msgid "Install %s"
694
  msgstr ""
695
 
696
- #: src/gui.cls.php:736
697
  msgid "Install Now"
698
  msgstr ""
699
 
700
- #: src/gui.cls.php:756
701
  msgid ""
702
  "<a href=\"%1$s\" %2$s>View version %3$s details</a> or <a href=\"%4$s\" %5$s "
703
  "target=\"_blank\">update now</a>."
704
  msgstr ""
705
 
706
- #: src/gui.cls.php:759
707
  msgid "View %1$s version %2$s details"
708
  msgstr ""
709
 
710
- #: src/gui.cls.php:764
711
  msgid "Update %s now"
712
  msgstr ""
713
 
@@ -1074,483 +1089,507 @@ msgid "CSS Combine"
1074
  msgstr ""
1075
 
1076
  #: src/lang.cls.php:106
1077
- msgid "Unique CSS"
1078
  msgstr ""
1079
 
1080
  #: src/lang.cls.php:107
1081
- msgid "CSS HTTP/2 Push"
1082
  msgstr ""
1083
 
1084
  #: src/lang.cls.php:108
 
 
 
 
 
 
 
 
 
 
 
 
1085
  msgid "JS Minify"
1086
  msgstr ""
1087
 
1088
- #: src/lang.cls.php:109 tpl/page_optm/settings_js.tpl.php:92
1089
  msgid "JS Combine"
1090
  msgstr ""
1091
 
1092
- #: src/lang.cls.php:110
1093
  msgid "JS HTTP/2 Push"
1094
  msgstr ""
1095
 
1096
- #: src/lang.cls.php:111
1097
  msgid "CSS/JS Cache TTL"
1098
  msgstr ""
1099
 
1100
- #: src/lang.cls.php:112
1101
  msgid "HTML Minify"
1102
  msgstr ""
1103
 
1104
- #: src/lang.cls.php:113
1105
  msgid "Inline CSS Minify"
1106
  msgstr ""
1107
 
1108
- #: src/lang.cls.php:114
1109
  msgid "Inline JS Minify"
1110
  msgstr ""
1111
 
1112
- #: src/lang.cls.php:115 tpl/page_optm/settings_css.tpl.php:110
1113
  #: tpl/page_optm/settings_tuning.tpl.php:131
1114
  msgid "Load CSS Asynchronously"
1115
  msgstr ""
1116
 
1117
- #: src/lang.cls.php:116
1118
  msgid "Generate Critical CSS"
1119
  msgstr ""
1120
 
1121
- #: src/lang.cls.php:117
1122
  msgid "Generate Critical CSS In Background"
1123
  msgstr ""
1124
 
1125
- #: src/lang.cls.php:118
1126
  msgid "Separate CCSS Cache Post Types"
1127
  msgstr ""
1128
 
1129
- #: src/lang.cls.php:119
1130
  msgid "Separate CCSS Cache URIs"
1131
  msgstr ""
1132
 
1133
- #: src/lang.cls.php:120
1134
  msgid "Inline CSS Async Lib"
1135
  msgstr ""
1136
 
1137
- #: src/lang.cls.php:121
1138
  msgid "Font Display Optimization"
1139
  msgstr ""
1140
 
1141
- #: src/lang.cls.php:122
1142
  msgid "Load JS Deferred"
1143
  msgstr ""
1144
 
1145
- #: src/lang.cls.php:123
1146
  msgid "Load Inline JS"
1147
  msgstr ""
1148
 
1149
- #: src/lang.cls.php:124
 
 
 
 
 
 
 
 
1150
  msgid "Exclude JQuery"
1151
  msgstr ""
1152
 
1153
- #: src/lang.cls.php:125
1154
  msgid "DNS Prefetch"
1155
  msgstr ""
1156
 
1157
- #: src/lang.cls.php:126
1158
  msgid "DNS Prefetch Control"
1159
  msgstr ""
1160
 
1161
- #: src/lang.cls.php:127
1162
  msgid "Remove Comments"
1163
  msgstr ""
1164
 
1165
- #: src/lang.cls.php:128
1166
  msgid "Combined CSS Priority"
1167
  msgstr ""
1168
 
1169
- #: src/lang.cls.php:129
1170
  msgid "CSS Excludes"
1171
  msgstr ""
1172
 
1173
- #: src/lang.cls.php:130
1174
  msgid "Combined JS Priority"
1175
  msgstr ""
1176
 
1177
- #: src/lang.cls.php:131
1178
  msgid "JS Excludes"
1179
  msgstr ""
1180
 
1181
- #: src/lang.cls.php:132
1182
  msgid "Max Combined File Size"
1183
  msgstr ""
1184
 
1185
- #: src/lang.cls.php:133
1186
  msgid "Remove Query Strings"
1187
  msgstr ""
1188
 
1189
- #: src/lang.cls.php:134
1190
  msgid "Load Google Fonts Asynchronously"
1191
  msgstr ""
1192
 
1193
- #: src/lang.cls.php:135
1194
  msgid "Remove Google Fonts"
1195
  msgstr ""
1196
 
1197
- #: src/lang.cls.php:136
1198
  msgid "Critical CSS Rules"
1199
  msgstr ""
1200
 
1201
- #: src/lang.cls.php:137
1202
  msgid "JS Deferred Excludes"
1203
  msgstr ""
1204
 
1205
- #: src/lang.cls.php:138
 
 
 
 
1206
  msgid "Remove WordPress Emoji"
1207
  msgstr ""
1208
 
1209
- #: src/lang.cls.php:139
1210
  msgid "URI Excludes"
1211
  msgstr ""
1212
 
1213
- #: src/lang.cls.php:140
1214
  msgid "Role Excludes"
1215
  msgstr ""
1216
 
1217
- #: src/lang.cls.php:143
1218
  msgid "Gravatar Cache Cron"
1219
  msgstr ""
1220
 
1221
- #: src/lang.cls.php:144
1222
  msgid "Gravatar Cache TTL"
1223
  msgstr ""
1224
 
1225
- #: src/lang.cls.php:146
1226
  msgid "Lazy Load Images"
1227
  msgstr ""
1228
 
1229
- #: src/lang.cls.php:147
1230
  msgid "Lazy Load Image Excludes"
1231
  msgstr ""
1232
 
1233
- #: src/lang.cls.php:148
1234
  msgid "Lazy Load Image Class Name Excludes"
1235
  msgstr ""
1236
 
1237
- #: src/lang.cls.php:149
1238
  msgid "Lazy Load Image Parent Class Name Excludes"
1239
  msgstr ""
1240
 
1241
- #: src/lang.cls.php:150
1242
  msgid "Lazy Load Iframe Class Name Excludes"
1243
  msgstr ""
1244
 
1245
- #: src/lang.cls.php:151
1246
  msgid "Lazy Load Iframe Parent Class Name Excludes"
1247
  msgstr ""
1248
 
1249
- #: src/lang.cls.php:152
1250
  msgid "Lazy Load URI Excludes"
1251
  msgstr ""
1252
 
1253
- #: src/lang.cls.php:153
1254
  msgid "Basic Image Placeholder"
1255
  msgstr ""
1256
 
1257
- #: src/lang.cls.php:154
1258
  msgid "Responsive Placeholder"
1259
  msgstr ""
1260
 
1261
- #: src/lang.cls.php:155
1262
  msgid "Responsive Placeholder Color"
1263
  msgstr ""
1264
 
1265
- #: src/lang.cls.php:156
1266
  msgid "Responsive Placeholder SVG"
1267
  msgstr ""
1268
 
1269
- #: src/lang.cls.php:157
1270
  msgid "LQIP Cloud Generator"
1271
  msgstr ""
1272
 
1273
- #: src/lang.cls.php:158
1274
  msgid "LQIP Quality"
1275
  msgstr ""
1276
 
1277
- #: src/lang.cls.php:159
1278
  msgid "LQIP Minimum Dimensions"
1279
  msgstr ""
1280
 
1281
- #: src/lang.cls.php:161
1282
  msgid "Generate LQIP In Background"
1283
  msgstr ""
1284
 
1285
- #: src/lang.cls.php:162
1286
  msgid "Lazy Load Iframes"
1287
  msgstr ""
1288
 
1289
- #: src/lang.cls.php:163
1290
  msgid "Inline Lazy Load Images Library"
1291
  msgstr ""
1292
 
1293
- #: src/lang.cls.php:164
1294
  msgid "Auto Request Cron"
1295
  msgstr ""
1296
 
1297
- #: src/lang.cls.php:165
1298
  msgid "Auto Pull Cron"
1299
  msgstr ""
1300
 
1301
- #: src/lang.cls.php:166
1302
  msgid "Optimize Original Images"
1303
  msgstr ""
1304
 
1305
- #: src/lang.cls.php:167
1306
  msgid "Remove Original Backups"
1307
  msgstr ""
1308
 
1309
- #: src/lang.cls.php:168
1310
  msgid "Create WebP Versions"
1311
  msgstr ""
1312
 
1313
- #: src/lang.cls.php:169
1314
  msgid "Optimize Losslessly"
1315
  msgstr ""
1316
 
1317
- #: src/lang.cls.php:170
1318
  msgid "Preserve EXIF/XMP data"
1319
  msgstr ""
1320
 
1321
- #: src/lang.cls.php:171
1322
  msgid "WebP Attribute To Replace"
1323
  msgstr ""
1324
 
1325
- #: src/lang.cls.php:172
1326
  msgid "WebP For Extra srcset"
1327
  msgstr ""
1328
 
1329
- #: src/lang.cls.php:173
1330
  msgid "WordPress Image Quality Control"
1331
  msgstr ""
1332
 
1333
- #: src/lang.cls.php:174 tpl/esi_widget_edit.php:36
1334
  msgid "Enable ESI"
1335
  msgstr ""
1336
 
1337
- #: src/lang.cls.php:175
1338
  msgid "Cache Admin Bar"
1339
  msgstr ""
1340
 
1341
- #: src/lang.cls.php:176
1342
  msgid "Cache Comment Form"
1343
  msgstr ""
1344
 
1345
- #: src/lang.cls.php:177
1346
- msgid "ESI Nonce"
1347
  msgstr ""
1348
 
1349
- #: src/lang.cls.php:178
1350
  msgid "Vary Group"
1351
  msgstr ""
1352
 
1353
- #: src/lang.cls.php:179
1354
  msgid "Purge All Hooks"
1355
  msgstr ""
1356
 
1357
- #: src/lang.cls.php:180
1358
  msgid "Improve HTTP/HTTPS Compatibility"
1359
  msgstr ""
1360
 
1361
- #: src/lang.cls.php:181
1362
  msgid "Instant Click"
1363
  msgstr ""
1364
 
1365
- #: src/lang.cls.php:182
1366
  msgid "Do Not Cache Cookies"
1367
  msgstr ""
1368
 
1369
- #: src/lang.cls.php:183
1370
  msgid "Do Not Cache User Agents"
1371
  msgstr ""
1372
 
1373
- #: src/lang.cls.php:184
1374
  msgid "Login Cookie"
1375
  msgstr ""
1376
 
1377
- #: src/lang.cls.php:185
1378
  msgid "Image WebP Replacement"
1379
  msgstr ""
1380
 
1381
- #: src/lang.cls.php:187
1382
  msgid "Frontend .htaccess Path"
1383
  msgstr ""
1384
 
1385
- #: src/lang.cls.php:188
1386
  msgid "Backend .htaccess Path"
1387
  msgstr ""
1388
 
1389
- #: src/lang.cls.php:189
1390
  msgid "Frontend Heartbeat Control"
1391
  msgstr ""
1392
 
1393
- #: src/lang.cls.php:190
1394
  msgid "Frontend Heartbeat TTL"
1395
  msgstr ""
1396
 
1397
- #: src/lang.cls.php:191
1398
  msgid "Backend Heartbeat Control"
1399
  msgstr ""
1400
 
1401
- #: src/lang.cls.php:192
1402
  msgid "Backend Heartbeat TTL"
1403
  msgstr ""
1404
 
1405
- #: src/lang.cls.php:193
1406
  msgid "Editor Heartbeat"
1407
  msgstr ""
1408
 
1409
- #: src/lang.cls.php:194
1410
  msgid "Editor Heartbeat TTL"
1411
  msgstr ""
1412
 
1413
- #: src/lang.cls.php:196
1414
  msgid "QUIC.cloud CDN"
1415
  msgstr ""
1416
 
1417
- #: src/lang.cls.php:197
1418
  msgid "Use CDN Mapping"
1419
  msgstr ""
1420
 
1421
- #: src/lang.cls.php:198
1422
  msgid "CDN URL"
1423
  msgstr ""
1424
 
1425
- #: src/lang.cls.php:199
1426
  msgid "Include Images"
1427
  msgstr ""
1428
 
1429
- #: src/lang.cls.php:200
1430
  msgid "Include CSS"
1431
  msgstr ""
1432
 
1433
- #: src/lang.cls.php:201
1434
  msgid "Include JS"
1435
  msgstr ""
1436
 
1437
- #: src/lang.cls.php:202 tpl/cdn/settings.tpl.php:148
1438
  msgid "Include File Types"
1439
  msgstr ""
1440
 
1441
- #: src/lang.cls.php:203
1442
  msgid "HTML Attribute To Replace"
1443
  msgstr ""
1444
 
1445
- #: src/lang.cls.php:204
1446
  msgid "Original URLs"
1447
  msgstr ""
1448
 
1449
- #: src/lang.cls.php:205
1450
  msgid "Included Directories"
1451
  msgstr ""
1452
 
1453
- #: src/lang.cls.php:206
1454
  msgid "Exclude Path"
1455
  msgstr ""
1456
 
1457
- #: src/lang.cls.php:207
1458
  msgid "Load JQuery Remotely"
1459
  msgstr ""
1460
 
1461
- #: src/lang.cls.php:208
1462
  msgid "Cloudflare API"
1463
  msgstr ""
1464
 
1465
- #: src/lang.cls.php:211
1466
  msgid "Delay"
1467
  msgstr ""
1468
 
1469
- #: src/lang.cls.php:212
1470
  msgid "Run Duration"
1471
  msgstr ""
1472
 
1473
- #: src/lang.cls.php:213
1474
  msgid "Interval Between Runs"
1475
  msgstr ""
1476
 
1477
- #: src/lang.cls.php:214
1478
  msgid "Crawl Interval"
1479
  msgstr ""
1480
 
1481
- #: src/lang.cls.php:215
1482
  msgid "Threads"
1483
  msgstr ""
1484
 
1485
- #: src/lang.cls.php:216
1486
  msgid "Timeout"
1487
  msgstr ""
1488
 
1489
- #: src/lang.cls.php:217
1490
  msgid "Server Load Limit"
1491
  msgstr ""
1492
 
1493
- #: src/lang.cls.php:218
1494
  msgid "Role Simulation"
1495
  msgstr ""
1496
 
1497
- #: src/lang.cls.php:219
1498
  msgid "Cookie Simulation"
1499
  msgstr ""
1500
 
1501
- #: src/lang.cls.php:220 tpl/crawler/settings-sitemap.tpl.php:115
1502
  msgid "Custom Sitemap"
1503
  msgstr ""
1504
 
1505
- #: src/lang.cls.php:221
1506
  msgid "Drop Domain from Sitemap"
1507
  msgstr ""
1508
 
1509
- #: src/lang.cls.php:222
1510
  msgid "Sitemap Timeout"
1511
  msgstr ""
1512
 
1513
- #: src/lang.cls.php:224 tpl/inc/disabled_all.php:5
1514
  msgid "Disable All Features"
1515
  msgstr ""
1516
 
1517
- #: src/lang.cls.php:225 tpl/toolbox/log_viewer.tpl.php:7
1518
  msgid "Debug Log"
1519
  msgstr ""
1520
 
1521
- #: src/lang.cls.php:226
1522
  msgid "Admin IPs"
1523
  msgstr ""
1524
 
1525
- #: src/lang.cls.php:227
1526
  msgid "Debug Level"
1527
  msgstr ""
1528
 
1529
- #: src/lang.cls.php:228
1530
  msgid "Log File Size Limit"
1531
  msgstr ""
1532
 
1533
- #: src/lang.cls.php:229
1534
  msgid "Log Cookies"
1535
  msgstr ""
1536
 
1537
- #: src/lang.cls.php:230
1538
  msgid "Collapse Query Strings"
1539
  msgstr ""
1540
 
1541
- #: src/lang.cls.php:231
1542
  msgid "Debug URI Includes"
1543
  msgstr ""
1544
 
1545
- #: src/lang.cls.php:232
1546
  msgid "Debug URI Excludes"
1547
  msgstr ""
1548
 
1549
- #: src/lang.cls.php:234
1550
  msgid "Revisions Max Number"
1551
  msgstr ""
1552
 
1553
- #: src/lang.cls.php:235
1554
  msgid "Revisions Max Age"
1555
  msgstr ""
1556
 
@@ -1643,83 +1682,87 @@ msgstr ""
1643
  msgid "Restore from backup"
1644
  msgstr ""
1645
 
1646
- #: src/placeholder.cls.php:87 tpl/dash/network_dash.tpl.php:30
1647
  msgid "LQIP"
1648
  msgstr ""
1649
 
1650
- #: src/placeholder.cls.php:147
1651
  msgid "LQIP image preview for size %s"
1652
  msgstr ""
1653
 
1654
- #: src/purge.cls.php:195
1655
  msgid "Purged all caches successfully."
1656
  msgstr ""
1657
 
1658
- #: src/purge.cls.php:215
1659
  msgid "Notified LiteSpeed Web Server to purge all LSCache entries."
1660
  msgstr ""
1661
 
1662
- #: src/purge.cls.php:231
1663
  msgid "Cleaned all critical CSS files."
1664
  msgstr ""
1665
 
1666
- #: src/purge.cls.php:247
1667
  msgid "Cleaned all LQIP files."
1668
  msgstr ""
1669
 
1670
- #: src/purge.cls.php:263
1671
  msgid "Cleaned all gravatar files."
1672
  msgstr ""
1673
 
1674
- #: src/purge.cls.php:284
 
 
 
 
1675
  msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
1676
  msgstr ""
1677
 
1678
- #: src/purge.cls.php:301
1679
  msgid "Opcode cache is not enabled."
1680
  msgstr ""
1681
 
1682
- #: src/purge.cls.php:313
1683
  msgid "Reset the entire opcode cache successfully."
1684
  msgstr ""
1685
 
1686
- #: src/purge.cls.php:332
1687
  msgid "Object cache is not enabled."
1688
  msgstr ""
1689
 
1690
- #: src/purge.cls.php:342
1691
  msgid "Purge all object caches successfully."
1692
  msgstr ""
1693
 
1694
- #: src/purge.cls.php:505
1695
  msgid "Notified LiteSpeed Web Server to purge the front page."
1696
  msgstr ""
1697
 
1698
- #: src/purge.cls.php:519
1699
  msgid "Notified LiteSpeed Web Server to purge pages."
1700
  msgstr ""
1701
 
1702
- #: src/purge.cls.php:539
1703
  msgid "Notified LiteSpeed Web Server to purge error pages."
1704
  msgstr ""
1705
 
1706
- #: src/purge.cls.php:567
1707
  msgid "Purge category %s"
1708
  msgstr ""
1709
 
1710
- #: src/purge.cls.php:595
1711
  msgid "Purge tag %s"
1712
  msgstr ""
1713
 
1714
- #: src/purge.cls.php:627
1715
  msgid "Purge url %s"
1716
  msgstr ""
1717
 
1718
- #: src/task.cls.php:125
1719
  msgid "Every Minute"
1720
  msgstr ""
1721
 
1722
- #: src/task.cls.php:145
1723
  msgid "LiteSpeed Crawler Cron"
1724
  msgstr ""
1725
 
@@ -1735,90 +1778,90 @@ msgstr ""
1735
  msgid " %s ago"
1736
  msgstr ""
1737
 
1738
- #: src/utility.cls.php:859
1739
  msgid "&laquo;"
1740
  msgstr ""
1741
 
1742
- #: src/utility.cls.php:860
1743
  msgid "&raquo;"
1744
  msgstr ""
1745
 
1746
- #: thirdparty/woocommerce.content.tpl.php:13
1747
  msgid "WooCommerce Settings"
1748
  msgstr ""
1749
 
1750
- #: thirdparty/woocommerce.content.tpl.php:18
1751
  #: tpl/cache/settings-advanced.tpl.php:12
1752
  #: tpl/cache/settings_inc.browser.tpl.php:12 tpl/toolbox/heartbeat.tpl.php:14
1753
  #: tpl/toolbox/report.tpl.php:29
1754
  msgid "NOTICE:"
1755
  msgstr ""
1756
 
1757
- #: thirdparty/woocommerce.content.tpl.php:19
1758
  msgid "After verifying that the cache works in general, please test the cart."
1759
  msgstr ""
1760
 
1761
- #: thirdparty/woocommerce.content.tpl.php:20
1762
  msgid "To test the cart, visit the <a %s>FAQ</a>."
1763
  msgstr ""
1764
 
1765
- #: thirdparty/woocommerce.content.tpl.php:27
1766
  msgid "Product Update Interval"
1767
  msgstr ""
1768
 
1769
- #: thirdparty/woocommerce.content.tpl.php:32
1770
  msgid "Purge product on changes to the quantity or stock status."
1771
  msgstr ""
1772
 
1773
- #: thirdparty/woocommerce.content.tpl.php:32
1774
  msgid "Purge categories only when stock status changes."
1775
  msgstr ""
1776
 
1777
- #: thirdparty/woocommerce.content.tpl.php:33
1778
  msgid "Purge product and categories only when the stock status changes."
1779
  msgstr ""
1780
 
1781
- #: thirdparty/woocommerce.content.tpl.php:34
1782
  msgid "Purge product only when the stock status changes."
1783
  msgstr ""
1784
 
1785
- #: thirdparty/woocommerce.content.tpl.php:34
1786
  msgid "Do not purge categories on changes to the quantity or stock status."
1787
  msgstr ""
1788
 
1789
- #: thirdparty/woocommerce.content.tpl.php:35
1790
  msgid ""
1791
  "Always purge both product and categories on changes to the quantity or stock "
1792
  "status."
1793
  msgstr ""
1794
 
1795
- #: thirdparty/woocommerce.content.tpl.php:48
1796
  msgid ""
1797
  "Determines how changes in product quantity and product stock status affect "
1798
  "product pages and their associated category pages."
1799
  msgstr ""
1800
 
1801
- #: thirdparty/woocommerce.content.tpl.php:56
1802
  msgid "Use Front Page TTL for the Shop Page"
1803
  msgstr ""
1804
 
1805
- #: thirdparty/woocommerce.content.tpl.php:61
1806
  msgid ""
1807
  "Checking this option will force the shop page to use the front page TTL "
1808
  "setting."
1809
  msgstr ""
1810
 
1811
- #: thirdparty/woocommerce.content.tpl.php:62
1812
  msgid ""
1813
  "For example, if the homepage for the site is located at %1$s, the shop page "
1814
  "may be located at %2$s."
1815
  msgstr ""
1816
 
1817
- #: thirdparty/woocommerce.content.tpl.php:70
1818
  msgid "Privately Cache Cart"
1819
  msgstr ""
1820
 
1821
- #: thirdparty/woocommerce.content.tpl.php:75
1822
  msgid "Privately cache cart when not empty."
1823
  msgstr ""
1824
 
@@ -1854,7 +1897,7 @@ msgstr ""
1854
  msgid "Dismiss this notice"
1855
  msgstr ""
1856
 
1857
- #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 3.2.3) #-#-#-#-#
1858
  #. Plugin Name of the plugin/theme
1859
  #: tpl/banner/new_version.php:59 tpl/banner/new_version_dev.tpl.php:12
1860
  #: tpl/cache/more_settings_tip.tpl.php:15 tpl/inc/admin_footer.php:8
@@ -1890,50 +1933,50 @@ msgstr ""
1890
  msgid "New developer version %s is available now."
1891
  msgstr ""
1892
 
1893
- #: tpl/banner/score.php:73
1894
  msgid "Thank You for Using the LiteSpeed Cache Plugin!"
1895
  msgstr ""
1896
 
1897
- #: tpl/banner/score.php:77 tpl/dash/dashboard.tpl.php:153
1898
  msgid "Page Load Time"
1899
  msgstr ""
1900
 
1901
- #: tpl/banner/score.php:83 tpl/banner/score.php:123
1902
  #: tpl/dash/dashboard.tpl.php:166 tpl/dash/dashboard.tpl.php:225
1903
  msgid "Before"
1904
  msgstr ""
1905
 
1906
- #: tpl/banner/score.php:94 tpl/banner/score.php:133
1907
  #: tpl/dash/dashboard.tpl.php:175 tpl/dash/dashboard.tpl.php:233
1908
  msgid "After"
1909
  msgstr ""
1910
 
1911
- #: tpl/banner/score.php:104 tpl/banner/score.php:143
1912
  #: tpl/dash/dashboard.tpl.php:183 tpl/dash/dashboard.tpl.php:241
1913
  msgid "Improved by"
1914
  msgstr ""
1915
 
1916
- #: tpl/banner/score.php:117 tpl/dash/dashboard.tpl.php:210
1917
  msgid "PageSpeed Score"
1918
  msgstr ""
1919
 
1920
- #: tpl/banner/score.php:162
1921
  msgid "Sure I'd love to review!"
1922
  msgstr ""
1923
 
1924
- #: tpl/banner/score.php:166
1925
  msgid "I've already left a review"
1926
  msgstr ""
1927
 
1928
- #: tpl/banner/score.php:167
1929
  msgid "Maybe later"
1930
  msgstr ""
1931
 
1932
- #: tpl/banner/score.php:171
1933
- msgid "Created with ❤️ by LiteSpeed team."
1934
  msgstr ""
1935
 
1936
- #: tpl/banner/score.php:173
1937
  msgid "<a %s>Support forum</a> | <a %s>Submit a ticket</a>"
1938
  msgstr ""
1939
 
@@ -1958,7 +2001,7 @@ msgid "TTL"
1958
  msgstr ""
1959
 
1960
  #: tpl/cache/entry.tpl.php:8 tpl/cache/entry_network.tpl.php:7
1961
- #: tpl/toolbox/entry.tpl.php:6 tpl/toolbox/purge.tpl.php:126
1962
  msgid "Purge"
1963
  msgstr ""
1964
 
@@ -1995,8 +2038,8 @@ msgstr ""
1995
  #: tpl/cache/settings-excludes.tpl.php:62
1996
  #: tpl/cache/settings-excludes.tpl.php:98 tpl/cdn/settings.tpl.php:124
1997
  #: tpl/crawler/settings-general.tpl.php:39
1998
- #: tpl/crawler/settings-general.tpl.php:159
1999
- #: tpl/crawler/settings-general.tpl.php:164
2000
  msgid "NOTE"
2001
  msgstr ""
2002
 
@@ -2176,8 +2219,8 @@ msgstr ""
2176
  #: tpl/cache/settings-esi.tpl.php:35 tpl/cdn/manage.tpl.php:21
2177
  #: tpl/crawler/summary.tpl.php:48 tpl/inc/check_cache_disabled.php:31
2178
  #: tpl/inc/check_if_network_disable_all.php:19 tpl/page_optm/entry.tpl.php:31
2179
- #: tpl/page_optm/settings_css.tpl.php:86
2180
- #: tpl/page_optm/settings_discussion.tpl.php:11
2181
  msgid "WARNING"
2182
  msgstr ""
2183
 
@@ -2203,12 +2246,12 @@ msgid "Cache the built-in Comment Form ESI block."
2203
  msgstr ""
2204
 
2205
  #: tpl/cache/settings-esi.tpl.php:91
2206
- msgid "Fetch Latest Predefined Nonce"
2207
  msgstr ""
2208
 
2209
  #: tpl/cache/settings-esi.tpl.php:93
2210
  msgid ""
2211
- "This will append any new predefined nonce found from the latest list source"
2212
  msgstr ""
2213
 
2214
  #: tpl/cache/settings-esi.tpl.php:98
@@ -2445,6 +2488,10 @@ msgstr ""
2445
  msgid "OpenLiteSpeed users please check this"
2446
  msgstr ""
2447
 
 
 
 
 
2448
  #: tpl/cache/settings_inc.browser.tpl.php:27
2449
  msgid ""
2450
  "Browser caching stores static files locally in the user's browser. Turn on "
@@ -2910,7 +2957,7 @@ msgid "Total"
2910
  msgstr ""
2911
 
2912
  #: tpl/crawler/blacklist.tpl.php:31 tpl/crawler/map.tpl.php:43
2913
- #: tpl/toolbox/purge.tpl.php:208
2914
  msgid "URL"
2915
  msgstr ""
2916
 
@@ -3042,43 +3089,17 @@ msgstr ""
3042
 
3043
  #: tpl/crawler/settings-general.tpl.php:135
3044
  msgid ""
3045
- "Enter this site's IP address to allow cloud services directly call IP "
3046
- "instead of domain name. This eliminates the overhead of DNS and CDN lookups."
3047
- msgstr ""
3048
-
3049
- #: tpl/crawler/settings-general.tpl.php:136
3050
- msgid "Your server IP is"
3051
- msgstr ""
3052
-
3053
- #: tpl/crawler/settings-general.tpl.php:136
3054
- msgid "Check my public IP from"
3055
- msgstr ""
3056
-
3057
- #: tpl/crawler/settings-general.tpl.php:138 tpl/general/settings.tpl.php:85
3058
- #: tpl/general/settings.tpl.php:96 tpl/general/settings.tpl.php:117
3059
- msgid "Notice"
3060
- msgstr ""
3061
-
3062
- #: tpl/crawler/settings-general.tpl.php:138
3063
- msgid ""
3064
- "the auto-detected IP may not be accurate if you have an additional outgoing "
3065
- "IP set, or you have multiple IPs configured on your server. Please make sure "
3066
- "this IP is the correct one for visiting your site."
3067
- msgstr ""
3068
-
3069
- #: tpl/crawler/settings-general.tpl.php:154
3070
- msgid ""
3071
  "The maximum average server load allowed while crawling. The number of "
3072
  "crawler threads in use will be actively reduced until average server load "
3073
  "falls under this limit. If this cannot be achieved with a single thread, the "
3074
  "current crawler run will be terminated."
3075
  msgstr ""
3076
 
3077
- #: tpl/crawler/settings-general.tpl.php:160
3078
  msgid "Server enforced value"
3079
  msgstr ""
3080
 
3081
- #: tpl/crawler/settings-general.tpl.php:165
3082
  msgid "Server allowed max value"
3083
  msgstr ""
3084
 
@@ -3403,7 +3424,8 @@ msgid "Current closest Cloud server is %s.&#10;Click to redetect."
3403
  msgstr ""
3404
 
3405
  #: tpl/dash/dashboard.tpl.php:202 tpl/img_optm/summary.tpl.php:51
3406
- #: tpl/page_optm/settings_css.tpl.php:140
 
3407
  #: tpl/page_optm/settings_media.tpl.php:172
3408
  msgid "Are you sure to redetect the closest cloud server for this service?"
3409
  msgstr ""
@@ -3449,7 +3471,7 @@ msgid "Cache Stats"
3449
  msgstr ""
3450
 
3451
  #: tpl/dash/dashboard.tpl.php:407 tpl/dash/dashboard.tpl.php:438
3452
- #: tpl/page_optm/settings_css.tpl.php:132
3453
  #: tpl/page_optm/settings_media.tpl.php:167
3454
  msgid "Last generated"
3455
  msgstr ""
@@ -3726,6 +3748,11 @@ msgstr ""
3726
  msgid "Link to QUIC.cloud"
3727
  msgstr ""
3728
 
 
 
 
 
 
3729
  #: tpl/general/settings.tpl.php:86
3730
  msgid ""
3731
  "There is a problem receiving your domain key. Please click the %s button to "
@@ -3814,6 +3841,27 @@ msgstr ""
3814
 
3815
  #: tpl/general/settings.tpl.php:158
3816
  msgid ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3817
  "Turn this option ON to show latest news automatically, including hotfixes, "
3818
  "new releases, available beta versions, and promotions."
3819
  msgstr ""
@@ -3904,7 +3952,8 @@ msgstr ""
3904
  msgid "The image compression quality setting of WordPress out of 100."
3905
  msgstr ""
3906
 
3907
- #: tpl/img_optm/summary.tpl.php:51 tpl/page_optm/settings_css.tpl.php:140
 
3908
  #: tpl/page_optm/settings_media.tpl.php:172
3909
  msgid "Current closest Cloud server is %s.&#10; Click to redetect."
3910
  msgstr ""
@@ -3999,7 +4048,7 @@ msgid "Delete all backups of the original images"
3999
  msgstr ""
4000
 
4001
  #: tpl/img_optm/summary.tpl.php:239
4002
- #: tpl/page_optm/settings_discussion.tpl.php:51
4003
  msgid "Last ran"
4004
  msgstr ""
4005
 
@@ -4272,7 +4321,7 @@ msgid ""
4272
  "dismissed. (<a %3$s>Learn More</a>)"
4273
  msgstr ""
4274
 
4275
- #: tpl/page_optm/entry.tpl.php:6 tpl/page_optm/settings_css.tpl.php:11
4276
  msgid "CSS Settings"
4277
  msgstr ""
4278
 
@@ -4292,8 +4341,9 @@ msgstr ""
4292
  msgid "Media Excludes"
4293
  msgstr ""
4294
 
4295
- #: tpl/page_optm/entry.tpl.php:11 tpl/page_optm/settings_discussion.tpl.php:17
4296
- msgid "Discussion Settings"
 
4297
  msgstr ""
4298
 
4299
  #: tpl/page_optm/entry.tpl.php:12 tpl/page_optm/settings_tuning.tpl.php:18
@@ -4316,56 +4366,78 @@ msgid ""
4316
  "Minify/Combine settings, please do a Purge All action."
4317
  msgstr ""
4318
 
4319
- #: tpl/page_optm/settings_css.tpl.php:25
4320
  msgid "Minify CSS files."
4321
  msgstr ""
4322
 
4323
- #: tpl/page_optm/settings_css.tpl.php:38
4324
  msgid "Combine CSS files."
4325
  msgstr ""
4326
 
4327
- #: tpl/page_optm/settings_css.tpl.php:39 tpl/page_optm/settings_js.tpl.php:35
4328
  msgid "How to Fix Problems Caused by CSS/JS Optimization."
4329
  msgstr ""
4330
 
4331
- #: tpl/page_optm/settings_css.tpl.php:52
4332
  msgid ""
4333
  "When having %1$s %2$s, enabling this will get one combined CSS file for each "
4334
  "URI, regardless of the setting %3$s."
4335
  msgstr ""
4336
 
4337
- #: tpl/page_optm/settings_css.tpl.php:58
4338
  msgid ""
4339
  "This is useful when you want to refine/lint your CSS and further drop the "
4340
  "unused CSS per page."
4341
  msgstr ""
4342
 
4343
- #: tpl/page_optm/settings_css.tpl.php:71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4344
  msgid ""
4345
  "Pre-send internal CSS files to the browser before they are requested. "
4346
  "(Requires the HTTP/2 protocol)"
4347
  msgstr ""
4348
 
4349
- #: tpl/page_optm/settings_css.tpl.php:90
4350
  msgid "Optimize CSS delivery."
4351
  msgstr ""
4352
 
4353
- #: tpl/page_optm/settings_css.tpl.php:91
4354
  #: tpl/page_optm/settings_html.tpl.php:107
4355
- #: tpl/page_optm/settings_html.tpl.php:121
4356
- #: tpl/page_optm/settings_html.tpl.php:171 tpl/page_optm/settings_js.tpl.php:62
4357
  #: tpl/page_optm/settings_media.tpl.php:214
4358
  msgid ""
4359
  "This can improve your speed score in services like Pingdom, GTmetrix and "
4360
  "PageSpeed."
4361
  msgstr ""
4362
 
4363
- #: tpl/page_optm/settings_css.tpl.php:92
4364
  msgid ""
4365
  "When this option is turned %s, it will also load Google Fonts asynchronously."
4366
  msgstr ""
4367
 
4368
- #: tpl/page_optm/settings_css.tpl.php:95
4369
  #: tpl/page_optm/settings_media_exc.tpl.php:27
4370
  #: tpl/page_optm/settings_tuning.tpl.php:60
4371
  #: tpl/page_optm/settings_tuning.tpl.php:102
@@ -4373,109 +4445,72 @@ msgstr ""
4373
  msgid "Elements with attribute %s in html code will be excluded."
4374
  msgstr ""
4375
 
4376
- #: tpl/page_optm/settings_css.tpl.php:109
4377
  msgid ""
4378
  "Leave this option %1$s to allow communication with QUIC.cloud CCSS service. "
4379
  "If set to %2$s, Critical CSS will not be generated."
4380
  msgstr ""
4381
 
4382
- #: tpl/page_optm/settings_css.tpl.php:110
4383
  msgid "This option only works if %1$s is %2$s."
4384
  msgstr ""
4385
 
4386
- #: tpl/page_optm/settings_css.tpl.php:123
4387
  msgid ""
4388
  "Automatically generate critical CSS in the background via a cron-based queue."
4389
  msgstr ""
4390
 
4391
- #: tpl/page_optm/settings_css.tpl.php:124
4392
- #: tpl/page_optm/settings_media.tpl.php:159
4393
- msgid ""
4394
- "If set to %s this is done in the foreground, which may slow down page load."
4395
- msgstr ""
4396
-
4397
- #: tpl/page_optm/settings_css.tpl.php:135
4398
- msgid "Last requested cost"
4399
- msgstr ""
4400
-
4401
- #: tpl/page_optm/settings_css.tpl.php:145
4402
  msgid "URL list in queue waiting for cron"
4403
  msgstr ""
4404
 
4405
- #: tpl/page_optm/settings_css.tpl.php:156
4406
- #: tpl/page_optm/settings_discussion.tpl.php:62
4407
  #: tpl/page_optm/settings_media.tpl.php:183
4408
  msgid "Run Queue Manually"
4409
  msgstr ""
4410
 
4411
- #: tpl/page_optm/settings_css.tpl.php:172
4412
  msgid ""
4413
  "List post types where each item of that type should have its own CCSS "
4414
  "generated."
4415
  msgstr ""
4416
 
4417
- #: tpl/page_optm/settings_css.tpl.php:173
4418
  msgid ""
4419
  "For example, if every Page on the site has different formatting, enter %s in "
4420
  "the box. Separate critical CSS files will be stored for every Page on the "
4421
  "site."
4422
  msgstr ""
4423
 
4424
- #: tpl/page_optm/settings_css.tpl.php:187
4425
  msgid ""
4426
  "Separate critical CSS files will be generated for paths containing these "
4427
  "strings."
4428
  msgstr ""
4429
 
4430
- #: tpl/page_optm/settings_css.tpl.php:201
4431
  msgid "This will inline the asynchronous CSS library to avoid render blocking."
4432
  msgstr ""
4433
 
4434
- #: tpl/page_optm/settings_css.tpl.php:212 tpl/page_optm/settings_js.tpl.php:73
4435
  msgid "Default"
4436
  msgstr ""
4437
 
4438
- #: tpl/page_optm/settings_css.tpl.php:214
4439
  msgid ""
4440
  "Set this to append %1$s to all %2$s rules before caching CSS to specify how "
4441
  "fonts should be displayed while being downloaded."
4442
  msgstr ""
4443
 
4444
- #: tpl/page_optm/settings_css.tpl.php:215
4445
  msgid "%s is recommended."
4446
  msgstr ""
4447
 
4448
- #: tpl/page_optm/settings_css.tpl.php:215
4449
  msgid "Swap"
4450
  msgstr ""
4451
 
4452
- #: tpl/page_optm/settings_discussion.tpl.php:12
4453
- msgid ""
4454
- "Failed to create Avatar table. Please follow <a %s>Table Creation guidance "
4455
- "from LiteSpeed Wiki</a> to finish setup."
4456
- msgstr ""
4457
-
4458
- #: tpl/page_optm/settings_discussion.tpl.php:30
4459
- msgid "Store Gravatar locally."
4460
- msgstr ""
4461
-
4462
- #: tpl/page_optm/settings_discussion.tpl.php:31
4463
- msgid ""
4464
- "Accelerates the speed by caching Gravatar (Globally Recognized Avatars)."
4465
- msgstr ""
4466
-
4467
- #: tpl/page_optm/settings_discussion.tpl.php:44
4468
- msgid "Refresh Gravatar cache by cron."
4469
- msgstr ""
4470
-
4471
- #: tpl/page_optm/settings_discussion.tpl.php:57
4472
- msgid "Avatar list in queue waiting for update"
4473
- msgstr ""
4474
-
4475
- #: tpl/page_optm/settings_discussion.tpl.php:79
4476
- msgid "Specify how long, in seconds, Gravatar files are cached."
4477
- msgstr ""
4478
-
4479
  #: tpl/page_optm/settings_html.tpl.php:21
4480
  msgid "Specify how long, in seconds, CSS/JS files are cached."
4481
  msgstr ""
@@ -4497,6 +4532,7 @@ msgid "Prefetching DNS can reduce latency for visitors."
4497
  msgstr ""
4498
 
4499
  #: tpl/page_optm/settings_html.tpl.php:76
 
4500
  msgid "For example"
4501
  msgstr ""
4502
 
@@ -4518,31 +4554,31 @@ msgstr ""
4518
  msgid "Remove query strings from static resources."
4519
  msgstr ""
4520
 
4521
- #: tpl/page_optm/settings_html.tpl.php:124
4522
  msgid "Google reCAPTCHA will be bypassed automatically."
4523
  msgstr ""
4524
 
4525
- #: tpl/page_optm/settings_html.tpl.php:128
4526
  msgid "Append query string %s to the resources to bypass this action."
4527
  msgstr ""
4528
 
4529
- #: tpl/page_optm/settings_html.tpl.php:142
4530
  msgid ""
4531
  "Use Web Font Loader library to load Google Fonts asynchronously while "
4532
  "leaving other CSS intact."
4533
  msgstr ""
4534
 
4535
- #: tpl/page_optm/settings_html.tpl.php:143
4536
  msgid ""
4537
  "This will also add a preconnect to Google for faster Google Fonts "
4538
  "downloading."
4539
  msgstr ""
4540
 
4541
- #: tpl/page_optm/settings_html.tpl.php:157
4542
  msgid "Prevent Google Fonts from loading on all pages."
4543
  msgstr ""
4544
 
4545
- #: tpl/page_optm/settings_html.tpl.php:170
4546
  msgid ""
4547
  "Stop loading WordPress.org emoji. Browser default emoji will be displayed "
4548
  "instead."
@@ -4598,6 +4634,81 @@ msgid ""
4598
  "this option."
4599
  msgstr ""
4600
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4601
  #: tpl/page_optm/settings_media.tpl.php:25
4602
  msgid "Load images only when they enter the viewport."
4603
  msgstr ""
@@ -4826,10 +4937,14 @@ msgid "Listed JS files will not be deferred."
4826
  msgstr ""
4827
 
4828
  #: tpl/page_optm/settings_tuning.tpl.php:164
 
 
 
 
4829
  msgid "Prevent any optimization of listed pages."
4830
  msgstr ""
4831
 
4832
- #: tpl/page_optm/settings_tuning.tpl.php:177
4833
  msgid "Selected roles will be excluded from all optimizations."
4834
  msgstr ""
4835
 
@@ -5102,87 +5217,91 @@ msgid "This will delete all generated critical CSS files"
5102
  msgstr ""
5103
 
5104
  #: tpl/toolbox/purge.tpl.php:82
5105
- msgid "This will delete all generated image LQIP placeholder files"
5106
  msgstr ""
5107
 
5108
  #: tpl/toolbox/purge.tpl.php:91
5109
- msgid "This will delete all cached Gravatar files"
5110
  msgstr ""
5111
 
5112
  #: tpl/toolbox/purge.tpl.php:100
 
 
 
 
5113
  msgid ""
5114
  "Purge the cache entries created by this plugin except for Critical CSS & "
5115
  "LQIP caches"
5116
  msgstr ""
5117
 
5118
- #: tpl/toolbox/purge.tpl.php:109
5119
  msgid "Empty Entire Cache"
5120
  msgstr ""
5121
 
5122
- #: tpl/toolbox/purge.tpl.php:110
5123
  msgid ""
5124
  "Clears all cache entries related to this site, <i>including other web "
5125
  "applications</i>."
5126
  msgstr ""
5127
 
5128
- #: tpl/toolbox/purge.tpl.php:111
5129
  msgid "This action should only be used if things are cached incorrectly."
5130
  msgstr ""
5131
 
5132
- #: tpl/toolbox/purge.tpl.php:115
5133
  msgid "This will clear EVERYTHING inside the cache."
5134
  msgstr ""
5135
 
5136
- #: tpl/toolbox/purge.tpl.php:116
5137
  msgid "This may cause heavy load on the server."
5138
  msgstr ""
5139
 
5140
- #: tpl/toolbox/purge.tpl.php:117
5141
  msgid "If only the WordPress site should be purged, use purge all."
5142
  msgstr ""
5143
 
5144
- #: tpl/toolbox/purge.tpl.php:161
5145
  msgid "Purge By..."
5146
  msgstr ""
5147
 
5148
- #: tpl/toolbox/purge.tpl.php:163
5149
  msgid "Select below for \"Purge by\" options."
5150
  msgstr ""
5151
 
5152
- #: tpl/toolbox/purge.tpl.php:190
5153
  msgid "Category"
5154
  msgstr ""
5155
 
5156
- #: tpl/toolbox/purge.tpl.php:196
5157
  msgid "Post ID"
5158
  msgstr ""
5159
 
5160
- #: tpl/toolbox/purge.tpl.php:202
5161
  msgid "Tag"
5162
  msgstr ""
5163
 
5164
- #: tpl/toolbox/purge.tpl.php:214
5165
  msgid ""
5166
  "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
5167
  msgstr ""
5168
 
5169
- #: tpl/toolbox/purge.tpl.php:219
5170
  msgid "Purge pages by post ID."
5171
  msgstr ""
5172
 
5173
- #: tpl/toolbox/purge.tpl.php:223
5174
  msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
5175
  msgstr ""
5176
 
5177
- #: tpl/toolbox/purge.tpl.php:228
5178
  msgid "Purge pages by relative or full URL."
5179
  msgstr ""
5180
 
5181
- #: tpl/toolbox/purge.tpl.php:229
5182
  msgid "e.g. Use %s or %s."
5183
  msgstr ""
5184
 
5185
- #: tpl/toolbox/purge.tpl.php:242
5186
  msgid "Purge List"
5187
  msgstr ""
5188
 
2
  # This file is distributed under the same license as the LiteSpeed Cache package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: LiteSpeed Cache 3.3\n"
6
  "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/litespeed-cache\n"
7
+ "POT-Creation-Date: 2020-08-06 17:29:54+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
36
  msgid "Upgraded successfully."
37
  msgstr ""
38
 
39
+ #: src/admin-display.cls.php:149 tpl/dash/entry.tpl.php:6
40
  msgid "Dashboard"
41
  msgstr ""
42
 
43
+ #: src/admin-display.cls.php:151
44
  msgid "General"
45
  msgstr ""
46
 
47
+ #: src/admin-display.cls.php:153 tpl/cache/entry.tpl.php:6
48
  #: tpl/cache/entry_network.tpl.php:6
49
  msgid "Cache"
50
  msgstr ""
51
 
52
+ #: src/admin-display.cls.php:155 tpl/cdn/settings.tpl.php:253
53
  msgid "CDN"
54
  msgstr ""
55
 
56
+ #: src/admin-display.cls.php:157 src/gui.cls.php:604
57
  #: tpl/dash/dashboard.tpl.php:52 tpl/dash/network_dash.tpl.php:27
58
  msgid "Image Optimization"
59
  msgstr ""
60
 
61
+ #: src/admin-display.cls.php:159
62
  msgid "Page Optimization"
63
  msgstr ""
64
 
65
+ #: src/admin-display.cls.php:161
66
  msgid "Database"
67
  msgstr ""
68
 
69
+ #: src/admin-display.cls.php:163 src/lang.cls.php:216
70
  msgid "Crawler"
71
  msgstr ""
72
 
73
+ #: src/admin-display.cls.php:165
74
  msgid "Toolbox"
75
  msgstr ""
76
 
77
+ #: src/admin-display.cls.php:251 src/gui.cls.php:595
78
  msgid "Settings"
79
  msgstr ""
80
 
81
+ #: src/admin-display.cls.php:270
82
  msgid ""
83
  "It is recommended that LiteSpeed Cache be purged after updating a plugin."
84
  msgstr ""
85
 
86
+ #: src/admin-display.cls.php:639
87
  msgid "Save Changes"
88
  msgstr ""
89
 
90
+ #: src/admin-display.cls.php:764 src/admin-display.cls.php:799
91
+ #: src/admin-display.cls.php:850 tpl/cache/settings-cache.tpl.php:19
92
  #: tpl/cache/settings_inc.cache_mobile.tpl.php:70 tpl/cdn/settings.tpl.php:49
93
+ #: tpl/page_optm/settings_css.tpl.php:58 tpl/page_optm/settings_css.tpl.php:155
94
+ #: tpl/page_optm/settings_css.tpl.php:172
95
+ #: tpl/page_optm/settings_css.tpl.php:173 tpl/page_optm/settings_js.tpl.php:89
96
  #: tpl/page_optm/settings_media.tpl.php:156
97
  #: tpl/page_optm/settings_tuning.tpl.php:36
98
  #: tpl/page_optm/settings_tuning.tpl.php:78
100
  msgid "ON"
101
  msgstr ""
102
 
103
+ #: src/admin-display.cls.php:765 src/admin-display.cls.php:798
104
+ #: src/admin-display.cls.php:850 tpl/cache/settings-cache.tpl.php:19
105
  #: tpl/cache/settings_inc.object.tpl.php:210 tpl/cdn/settings.tpl.php:49
106
+ #: tpl/cdn/settings.tpl.php:237 tpl/page_optm/settings_css.tpl.php:89
107
+ #: tpl/page_optm/settings_css.tpl.php:172
108
+ #: tpl/page_optm/settings_css.tpl.php:187
109
  #: tpl/page_optm/settings_media.tpl.php:159
110
  #: tpl/page_optm/settings_tuning.tpl.php:33
111
  #: tpl/page_optm/settings_tuning.tpl.php:75
113
  msgid "OFF"
114
  msgstr ""
115
 
116
+ #: src/admin-display.cls.php:862
117
  msgid "This setting is overwritten by the PHP constant %s"
118
  msgstr ""
119
 
120
+ #: src/admin-display.cls.php:864
121
  msgid "This setting is overwritten by the primary site setting"
122
  msgstr ""
123
 
124
+ #: src/admin-display.cls.php:867
125
  msgid "currently set to %s"
126
  msgstr ""
127
 
128
+ #: src/admin-display.cls.php:877 tpl/cache/settings_inc.object.tpl.php:103
129
  #: tpl/crawler/settings-general.tpl.php:60
130
  #: tpl/crawler/settings-general.tpl.php:74
131
  #: tpl/crawler/settings-general.tpl.php:89 tpl/esi_widget_edit.php:70
132
  msgid "seconds"
133
  msgstr ""
134
 
135
+ #: src/admin-display.cls.php:908 src/admin-display.cls.php:913
136
  msgid "Recommended value"
137
  msgstr ""
138
 
139
+ #: src/admin-display.cls.php:937
140
  msgid "Invalid rewrite rule"
141
  msgstr ""
142
 
143
+ #: src/admin-display.cls.php:954
144
  msgid "Path must end with %s"
145
  msgstr ""
146
 
147
+ #: src/admin-display.cls.php:972
148
  msgid "Minimum value"
149
  msgstr ""
150
 
151
+ #: src/admin-display.cls.php:975
152
  msgid "Maximum value"
153
  msgstr ""
154
 
155
+ #: src/admin-display.cls.php:987
156
  msgid "Zero, or"
157
  msgstr ""
158
 
159
+ #: src/admin-display.cls.php:994
160
  msgid "Larger than"
161
  msgstr ""
162
 
163
+ #: src/admin-display.cls.php:997
164
  msgid "Smaller than"
165
  msgstr ""
166
 
167
+ #: src/admin-display.cls.php:1000
168
  msgid "Value range"
169
  msgstr ""
170
 
171
+ #: src/admin-display.cls.php:1025
172
  msgid "Invalid IP"
173
  msgstr ""
174
 
175
+ #: src/admin-display.cls.php:1045 tpl/page_optm/settings_css.tpl.php:157
176
+ #: tpl/page_optm/settings_html.tpl.php:126
177
  #: tpl/page_optm/settings_media_exc.tpl.php:25
178
  #: tpl/page_optm/settings_tuning.tpl.php:39
179
  #: tpl/page_optm/settings_tuning.tpl.php:58
183
  msgid "API"
184
  msgstr ""
185
 
186
+ #: src/admin-display.cls.php:1046
187
  msgid "Server variable(s) %s available to override this setting."
188
  msgstr ""
189
 
190
+ #: src/admin-display.cls.php:1058
 
 
 
 
 
 
 
191
  msgid "The URLs will be compared to the REQUEST_URI server variable."
192
  msgstr ""
193
 
194
+ #: src/admin-display.cls.php:1059
195
  msgid "For example, for %s, %s can be used here."
196
  msgstr ""
197
 
198
+ #: src/admin-display.cls.php:1061
199
  msgid "To match the beginning, add %s to the beginning of the item."
200
  msgstr ""
201
 
202
+ #: src/admin-display.cls.php:1062
203
  msgid "To do an exact match, add %s to the end of the URL."
204
  msgstr ""
205
 
206
+ #: src/admin-display.cls.php:1063 src/doc.cls.php:61
207
  msgid "One per line."
208
  msgstr ""
209
 
210
+ #: src/admin-display.cls.php:1077
211
  msgid "%s groups"
212
  msgstr ""
213
 
214
+ #: src/admin-display.cls.php:1080
215
  msgid "%s images"
216
  msgstr ""
217
 
218
+ #: src/admin-display.cls.php:1090
219
  msgid "%s group"
220
  msgstr ""
221
 
222
+ #: src/admin-display.cls.php:1093
223
  msgid "%s image"
224
  msgstr ""
225
 
226
+ #: src/admin-settings.cls.php:268 src/admin-settings.cls.php:303
227
  msgid "Options saved."
228
  msgstr ""
229
 
230
+ #: src/cdn/cloudflare.cls.php:117
231
  msgid "Notified Cloudflare to set development mode to %s successfully."
232
  msgstr ""
233
 
234
+ #: src/cdn/cloudflare.cls.php:134
235
  msgid "Cloudflare API is set to off."
236
  msgstr ""
237
 
238
+ #: src/cdn/cloudflare.cls.php:150
239
  msgid "Notified Cloudflare to purge all successfully."
240
  msgstr ""
241
 
242
+ #: src/cdn/cloudflare.cls.php:164
243
  msgid "No available Cloudflare zone"
244
  msgstr ""
245
 
246
+ #: src/cdn/cloudflare.cls.php:250
247
  msgid "Communicated with Cloudflare successfully."
248
  msgstr ""
249
 
250
+ #: src/cdn/cloudflare.cls.php:259
251
  msgid "Failed to communicate with Cloudflare"
252
  msgstr ""
253
 
254
+ #: src/cloud.cls.php:310 src/cloud.cls.php:329 src/cloud.cls.php:366
255
+ #: src/cloud.cls.php:471
256
  msgid "Cloud Error"
257
  msgstr ""
258
 
259
+ #: src/cloud.cls.php:366
260
  msgid "No available Cloud Node."
261
  msgstr ""
262
 
263
+ #: src/cloud.cls.php:471
264
  msgid "Please try after %1$s for service %2$s."
265
  msgstr ""
266
 
267
+ #: src/cloud.cls.php:554 src/cloud.cls.php:566
268
  msgid "Failed to request via WordPress"
269
  msgstr ""
270
 
271
+ #: src/cloud.cls.php:576
272
  msgid ""
273
  "We are working hard to improve your online service experience. The service "
274
  "will be unavailable while we work. We apologize for any inconvenience."
275
  msgstr ""
276
 
277
+ #: src/cloud.cls.php:585 src/cloud.cls.php:593 src/cloud.cls.php:840
278
  msgid "Message from QUIC.cloud server"
279
  msgstr ""
280
 
281
+ #: src/cloud.cls.php:601
282
  msgid "Good news from QUIC.cloud server"
283
  msgstr ""
284
 
285
+ #: src/cloud.cls.php:610
286
  msgid "%1$s plugin version %2$s required for this action."
287
  msgstr ""
288
 
289
+ #: src/cloud.cls.php:652 src/cloud.cls.php:829
290
  msgid "Failed to communicate with QUIC.cloud server"
291
  msgstr ""
292
 
293
+ #: src/cloud.cls.php:660
294
+ msgid ""
295
+ "Site not recognized. Domain Key has been automatically removed. Please "
296
+ "request a new one."
297
+ msgstr ""
298
+
299
+ #: src/cloud.cls.php:661 src/error.cls.php:48
300
+ msgid "Click here to set."
301
+ msgstr ""
302
+
303
+ #: src/cloud.cls.php:804
304
  msgid "CLoud Error"
305
  msgstr ""
306
 
307
+ #: src/cloud.cls.php:848
308
  msgid ""
309
  "Applied for Domain key successfully. Please wait for result. Domain key will "
310
  "be automatically sent to your WordPress."
311
  msgstr ""
312
 
313
+ #: src/cloud.cls.php:899
314
  msgid ""
315
  "Congratulations, your Domain Key has been approved! The setting has been "
316
  "updated accordingly."
317
  msgstr ""
318
 
319
+ #: src/cloud.cls.php:970
320
  msgid "Domain key hash mismatch"
321
  msgstr ""
322
 
323
+ #: src/cloud.cls.php:1055
324
  msgid "Sync credit allowance with Cloud Server successfully."
325
  msgstr ""
326
 
327
+ #: src/conf.cls.php:741
328
  msgid "Changed setting successfully."
329
  msgstr ""
330
 
331
+ #: src/core.cls.php:257
332
  msgid "Notified LiteSpeed Web Server to purge everything."
333
  msgstr ""
334
 
335
+ #: src/core.cls.php:262
336
  msgid "Notified LiteSpeed Web Server to purge the list."
337
  msgstr ""
338
 
339
+ #: src/crawler-map.cls.php:268
340
  msgid "Sitemap cleaned successfully"
341
  msgstr ""
342
 
343
+ #: src/crawler-map.cls.php:319
344
  msgid "Sitemap created successfully: %d items"
345
  msgstr ""
346
 
347
+ #: src/crawler.cls.php:767
348
  msgid "Guest"
349
  msgstr ""
350
 
351
+ #: src/crawler.cls.php:906
352
  msgid "Manually added to blacklist"
353
  msgstr ""
354
 
355
+ #: src/crawler.cls.php:909
356
  msgid "Previously existed in blacklist"
357
  msgstr ""
358
 
362
  "will disappear once upgrade is complete."
363
  msgstr ""
364
 
365
+ #: src/db-optm.cls.php:132
366
  msgid "Clean all successfully."
367
  msgstr ""
368
 
369
+ #: src/db-optm.cls.php:159
370
  msgid "Clean post revisions successfully."
371
  msgstr ""
372
 
373
+ #: src/db-optm.cls.php:163
374
  msgid "Clean auto drafts successfully."
375
  msgstr ""
376
 
377
+ #: src/db-optm.cls.php:167
378
  msgid "Clean trashed posts and pages successfully."
379
  msgstr ""
380
 
381
+ #: src/db-optm.cls.php:171
382
  msgid "Clean spam comments successfully."
383
  msgstr ""
384
 
385
+ #: src/db-optm.cls.php:175
386
  msgid "Clean trashed comments successfully."
387
  msgstr ""
388
 
389
+ #: src/db-optm.cls.php:179
390
  msgid "Clean trackbacks and pingbacks successfully."
391
  msgstr ""
392
 
393
+ #: src/db-optm.cls.php:183
394
  msgid "Clean expired transients successfully."
395
  msgstr ""
396
 
397
+ #: src/db-optm.cls.php:187
398
  msgid "Clean all transients successfully."
399
  msgstr ""
400
 
401
+ #: src/db-optm.cls.php:197
402
  msgid "Optimized all tables."
403
  msgstr ""
404
 
405
+ #: src/db-optm.cls.php:204
406
  msgid "Clean all CSS/JS optimizer data successfully."
407
  msgstr ""
408
 
409
+ #: src/db-optm.cls.php:256
410
  msgid "Converted to InnoDB successfully."
411
  msgstr ""
412
 
413
+ #: src/doc.cls.php:24
414
  msgid ""
415
  "This site utilizes caching in order to facilitate a faster response time and "
416
  "better user experience. Caching potentially stores a duplicate copy of every "
421
  "admin before their natural expiration, if necessary."
422
  msgstr ""
423
 
424
+ #: src/doc.cls.php:40 src/doc.cls.php:73 tpl/cdn/manage.tpl.php:66
425
+ #: tpl/dash/dashboard.tpl.php:46 tpl/img_optm/summary.tpl.php:56
426
+ #: tpl/img_optm/summary.tpl.php:96 tpl/inc/check_cache_disabled.php:42
427
+ msgid "Learn More"
428
+ msgstr ""
429
+
430
+ #: src/doc.cls.php:72
431
  msgid "This setting will edit the .htaccess file."
432
  msgstr ""
433
 
434
+ #: src/doc.cls.php:85
435
  msgid ""
436
  "For online services to work correctly, you must whitelist all online server "
437
  "IPs."
438
  msgstr ""
439
 
440
+ #: src/doc.cls.php:86
441
  msgid ""
442
  "Before generating key, please verify all IPs on this list are whitelisted"
443
  msgstr ""
444
 
445
+ #: src/doc.cls.php:87 tpl/general/settings.tpl.php:89
446
  msgid "Current Online Server IPs"
447
  msgstr ""
448
 
449
+ #: src/error.cls.php:42
450
  msgid "The setting %s is currently enabled."
451
  msgstr ""
452
 
453
+ #: src/error.cls.php:43
454
+ msgid "Click here to change."
455
  msgstr ""
456
 
457
+ #: src/error.cls.php:47
458
  msgid "You will need to set %s to use the online services."
459
  msgstr ""
460
 
461
+ #: src/error.cls.php:52
 
 
 
 
462
  msgid "You don't have enough quota for current service left this month."
463
  msgstr ""
464
 
465
+ #: src/error.cls.php:56
466
  msgid "You have too many requested images, please try again in a few minutes."
467
  msgstr ""
468
 
469
+ #: src/error.cls.php:60
470
  msgid ""
471
  "You have too many notified images, please pull down notified images first."
472
  msgstr ""
473
 
474
+ #: src/error.cls.php:64
475
  msgid "The image list is empty."
476
  msgstr ""
477
 
478
+ #: src/error.cls.php:68
479
  msgid "Not enough parameters. Please check if the domain key is set correctly"
480
  msgstr ""
481
 
482
+ #: src/error.cls.php:72
483
  msgid "There is proceeding queue not pulled yet."
484
  msgstr ""
485
 
486
+ #: src/error.cls.php:76
487
  msgid "There is proceeding queue not pulled yet. Queue info: %s."
488
  msgstr ""
489
 
490
+ #: src/error.cls.php:80
491
+ msgid "The site is not registered on QUIC.cloud."
492
+ msgstr ""
493
+
494
+ #: src/error.cls.php:84
495
  msgid ""
496
  "The domain key is not correct. Please try to sync your domain key again."
497
  msgstr ""
498
 
499
+ #: src/error.cls.php:88
500
  msgid "Credits are not enough to proceed the current request."
501
  msgstr ""
502
 
503
+ #: src/error.cls.php:92 src/error.cls.php:116
504
  msgid "%s file not writable."
505
  msgstr ""
506
 
507
+ #: src/error.cls.php:100
508
  msgid "Could not find %1$s in %2$s."
509
  msgstr ""
510
 
511
+ #: src/error.cls.php:104
512
  msgid "Invalid login cookie. Please check the %s file."
513
  msgstr ""
514
 
515
+ #: src/error.cls.php:108
516
  msgid "Failed to back up %s file, aborted changes."
517
  msgstr ""
518
 
519
+ #: src/error.cls.php:112
520
  msgid "%s file not readable."
521
  msgstr ""
522
 
523
+ #: src/error.cls.php:120
524
  msgid "Failed to get %s file contents."
525
  msgstr ""
526
 
527
+ #: src/error.cls.php:124
528
  msgid "Failed to create table %s! SQL: %s."
529
  msgstr ""
530
 
531
+ #: src/error.cls.php:128
532
  msgid "Crawler disabled by the server admin."
533
  msgstr ""
534
 
535
+ #: src/error.cls.php:133
536
  msgid "Previous request too recent. Please try again later."
537
  msgstr ""
538
 
539
+ #: src/error.cls.php:137
540
  msgid "Previous request too recent. Please try again after %s."
541
  msgstr ""
542
 
543
+ #: src/error.cls.php:141
544
  msgid "Your application is waiting for approval."
545
  msgstr ""
546
 
547
+ #: src/error.cls.php:145
548
  msgid "The callback validation to your domain failed due to hash mismatch."
549
  msgstr ""
550
 
551
+ #: src/error.cls.php:149
552
  msgid ""
553
  "The callback validation to your domain failed. Please make sure there is no "
554
  "firewall blocking our servers."
555
  msgstr ""
556
 
557
+ #: src/error.cls.php:153
558
  msgid ""
559
  "The callback validation to your domain failed. Please make sure there is no "
560
  "firewall blocking our servers. Response code: "
561
  msgstr ""
562
 
563
+ #: src/error.cls.php:157
564
  msgid ""
565
  "Your domain has been forbidden from using our services due to a previous "
566
  "policy violation."
567
  msgstr ""
568
 
569
+ #: src/error.cls.php:161
570
  msgid "Unknown error"
571
  msgstr ""
572
 
573
+ #: src/file.cls.php:140
574
  msgid "Folder does not exist: %s"
575
  msgstr ""
576
 
577
+ #: src/file.cls.php:149
578
  msgid "Can not create folder: %1$s. Error: %2$s"
579
  msgstr ""
580
 
581
+ #: src/file.cls.php:157
582
  msgid "Folder is not writable: %s."
583
  msgstr ""
584
 
585
+ #: src/file.cls.php:164 src/file.cls.php:169
586
  msgid "File %s is not writable."
587
  msgstr ""
588
 
589
+ #: src/file.cls.php:176
590
  msgid "Failed to write to %s."
591
  msgstr ""
592
 
606
  msgid "Private Cache Hits"
607
  msgstr ""
608
 
609
+ #: src/gui.cls.php:404
610
  msgid "Purge this page"
611
  msgstr ""
612
 
613
+ #: src/gui.cls.php:412
614
  msgid "Mark this page as "
615
  msgstr ""
616
 
617
+ #: src/gui.cls.php:424
618
  msgid "Forced cacheable"
619
  msgstr ""
620
 
621
+ #: src/gui.cls.php:435
622
  msgid "Non cacheable"
623
  msgstr ""
624
 
625
+ #: src/gui.cls.php:446
626
  msgid "Private cache"
627
  msgstr ""
628
 
629
+ #: src/gui.cls.php:457
630
  msgid "No optimization"
631
  msgstr ""
632
 
633
+ #: src/gui.cls.php:465
634
  msgid "More settings"
635
  msgstr ""
636
 
637
+ #: src/gui.cls.php:472 src/gui.cls.php:480 src/gui.cls.php:488
638
+ #: src/gui.cls.php:497 src/gui.cls.php:507 src/gui.cls.php:517
639
+ #: src/gui.cls.php:527 src/gui.cls.php:537 src/gui.cls.php:547
640
+ #: src/gui.cls.php:613 src/gui.cls.php:621 src/gui.cls.php:629
641
+ #: src/gui.cls.php:638 src/gui.cls.php:648 src/gui.cls.php:658
642
+ #: src/gui.cls.php:668 src/gui.cls.php:678 src/gui.cls.php:688
643
+ #: src/gui.cls.php:698 tpl/toolbox/purge.tpl.php:39
644
  #: tpl/toolbox/purge.tpl.php:45 tpl/toolbox/purge.tpl.php:54
645
  #: tpl/toolbox/purge.tpl.php:63 tpl/toolbox/purge.tpl.php:72
646
  #: tpl/toolbox/purge.tpl.php:81 tpl/toolbox/purge.tpl.php:90
647
+ #: tpl/toolbox/purge.tpl.php:99 tpl/toolbox/purge.tpl.php:108
648
  msgid "Purge All"
649
  msgstr ""
650
 
651
+ #: src/gui.cls.php:480 src/gui.cls.php:571 src/gui.cls.php:621
652
  msgid "LSCache"
653
  msgstr ""
654
 
655
+ #: src/gui.cls.php:488 src/gui.cls.php:629 tpl/toolbox/purge.tpl.php:45
656
  msgid "CSS/JS Cache"
657
  msgstr ""
658
 
659
+ #: src/gui.cls.php:497 src/gui.cls.php:648 src/lang.cls.php:79
660
  #: tpl/dash/dashboard.tpl.php:361 tpl/toolbox/purge.tpl.php:54
661
  msgid "Object Cache"
662
  msgstr ""
663
 
664
+ #: src/gui.cls.php:507 src/gui.cls.php:658 tpl/toolbox/purge.tpl.php:63
665
  msgid "Opcode Cache"
666
  msgstr ""
667
 
668
+ #: src/gui.cls.php:517 src/gui.cls.php:668 tpl/dash/dashboard.tpl.php:53
669
  #: tpl/dash/dashboard.tpl.php:402 tpl/toolbox/purge.tpl.php:72
670
  msgid "Critical CSS"
671
  msgstr ""
672
 
673
+ #: src/gui.cls.php:527 src/gui.cls.php:678 tpl/toolbox/purge.tpl.php:81
674
+ msgid "Localized Resources"
675
+ msgstr ""
676
+
677
+ #: src/gui.cls.php:537 src/gui.cls.php:688 tpl/toolbox/purge.tpl.php:90
678
  msgid "LQIP Cache"
679
  msgstr ""
680
 
681
+ #: src/gui.cls.php:547 src/gui.cls.php:698 src/lang.cls.php:148
682
+ #: tpl/toolbox/purge.tpl.php:99
683
  msgid "Gravatar Cache"
684
  msgstr ""
685
 
686
+ #: src/gui.cls.php:571
687
  msgid "LiteSpeed Cache Purge All"
688
  msgstr ""
689
 
690
+ #: src/gui.cls.php:587 tpl/cdn/entry.tpl.php:7 tpl/cdn/settings.tpl.php:253
691
  #: tpl/db_optm/entry.tpl.php:6
692
  msgid "Manage"
693
  msgstr ""
694
 
695
+ #: src/gui.cls.php:638 tpl/cdn/manage.tpl.php:17
696
  msgid "Cloudflare"
697
  msgstr ""
698
 
699
+ #: src/gui.cls.php:718 tpl/img_optm/summary.tpl.php:169
700
  msgid "Remove all previous unfinished image optimization requests."
701
  msgstr ""
702
 
703
+ #: src/gui.cls.php:719 tpl/img_optm/summary.tpl.php:171
704
  msgid "Clean Up Unfinished Data"
705
  msgstr ""
706
 
707
+ #: src/gui.cls.php:738
708
  msgid "Install %s"
709
  msgstr ""
710
 
711
+ #: src/gui.cls.php:739
712
  msgid "Install Now"
713
  msgstr ""
714
 
715
+ #: src/gui.cls.php:759
716
  msgid ""
717
  "<a href=\"%1$s\" %2$s>View version %3$s details</a> or <a href=\"%4$s\" %5$s "
718
  "target=\"_blank\">update now</a>."
719
  msgstr ""
720
 
721
+ #: src/gui.cls.php:762
722
  msgid "View %1$s version %2$s details"
723
  msgstr ""
724
 
725
+ #: src/gui.cls.php:767
726
  msgid "Update %s now"
727
  msgstr ""
728
 
1089
  msgstr ""
1090
 
1091
  #: src/lang.cls.php:106
1092
+ msgid "Unique CSS File"
1093
  msgstr ""
1094
 
1095
  #: src/lang.cls.php:107
1096
+ msgid "Generate UCSS"
1097
  msgstr ""
1098
 
1099
  #: src/lang.cls.php:108
1100
+ msgid "Generate UCSS in Background"
1101
+ msgstr ""
1102
+
1103
+ #: src/lang.cls.php:109
1104
+ msgid "UCSS Whitelist Selector"
1105
+ msgstr ""
1106
+
1107
+ #: src/lang.cls.php:110
1108
+ msgid "CSS HTTP/2 Push"
1109
+ msgstr ""
1110
+
1111
+ #: src/lang.cls.php:111
1112
  msgid "JS Minify"
1113
  msgstr ""
1114
 
1115
+ #: src/lang.cls.php:112 tpl/page_optm/settings_js.tpl.php:92
1116
  msgid "JS Combine"
1117
  msgstr ""
1118
 
1119
+ #: src/lang.cls.php:113
1120
  msgid "JS HTTP/2 Push"
1121
  msgstr ""
1122
 
1123
+ #: src/lang.cls.php:114
1124
  msgid "CSS/JS Cache TTL"
1125
  msgstr ""
1126
 
1127
+ #: src/lang.cls.php:115
1128
  msgid "HTML Minify"
1129
  msgstr ""
1130
 
1131
+ #: src/lang.cls.php:116
1132
  msgid "Inline CSS Minify"
1133
  msgstr ""
1134
 
1135
+ #: src/lang.cls.php:117
1136
  msgid "Inline JS Minify"
1137
  msgstr ""
1138
 
1139
+ #: src/lang.cls.php:118 tpl/page_optm/settings_css.tpl.php:173
1140
  #: tpl/page_optm/settings_tuning.tpl.php:131
1141
  msgid "Load CSS Asynchronously"
1142
  msgstr ""
1143
 
1144
+ #: src/lang.cls.php:119
1145
  msgid "Generate Critical CSS"
1146
  msgstr ""
1147
 
1148
+ #: src/lang.cls.php:120
1149
  msgid "Generate Critical CSS In Background"
1150
  msgstr ""
1151
 
1152
+ #: src/lang.cls.php:121
1153
  msgid "Separate CCSS Cache Post Types"
1154
  msgstr ""
1155
 
1156
+ #: src/lang.cls.php:122
1157
  msgid "Separate CCSS Cache URIs"
1158
  msgstr ""
1159
 
1160
+ #: src/lang.cls.php:123
1161
  msgid "Inline CSS Async Lib"
1162
  msgstr ""
1163
 
1164
+ #: src/lang.cls.php:124
1165
  msgid "Font Display Optimization"
1166
  msgstr ""
1167
 
1168
+ #: src/lang.cls.php:125
1169
  msgid "Load JS Deferred"
1170
  msgstr ""
1171
 
1172
+ #: src/lang.cls.php:126
1173
  msgid "Load Inline JS"
1174
  msgstr ""
1175
 
1176
+ #: src/lang.cls.php:127
1177
+ msgid "Localize Resources"
1178
+ msgstr ""
1179
+
1180
+ #: src/lang.cls.php:128
1181
+ msgid "Localization Domains"
1182
+ msgstr ""
1183
+
1184
+ #: src/lang.cls.php:129
1185
  msgid "Exclude JQuery"
1186
  msgstr ""
1187
 
1188
+ #: src/lang.cls.php:130
1189
  msgid "DNS Prefetch"
1190
  msgstr ""
1191
 
1192
+ #: src/lang.cls.php:131
1193
  msgid "DNS Prefetch Control"
1194
  msgstr ""
1195
 
1196
+ #: src/lang.cls.php:132
1197
  msgid "Remove Comments"
1198
  msgstr ""
1199
 
1200
+ #: src/lang.cls.php:133
1201
  msgid "Combined CSS Priority"
1202
  msgstr ""
1203
 
1204
+ #: src/lang.cls.php:134
1205
  msgid "CSS Excludes"
1206
  msgstr ""
1207
 
1208
+ #: src/lang.cls.php:135
1209
  msgid "Combined JS Priority"
1210
  msgstr ""
1211
 
1212
+ #: src/lang.cls.php:136
1213
  msgid "JS Excludes"
1214
  msgstr ""
1215
 
1216
+ #: src/lang.cls.php:137
1217
  msgid "Max Combined File Size"
1218
  msgstr ""
1219
 
1220
+ #: src/lang.cls.php:138
1221
  msgid "Remove Query Strings"
1222
  msgstr ""
1223
 
1224
+ #: src/lang.cls.php:139
1225
  msgid "Load Google Fonts Asynchronously"
1226
  msgstr ""
1227
 
1228
+ #: src/lang.cls.php:140
1229
  msgid "Remove Google Fonts"
1230
  msgstr ""
1231
 
1232
+ #: src/lang.cls.php:141
1233
  msgid "Critical CSS Rules"
1234
  msgstr ""
1235
 
1236
+ #: src/lang.cls.php:142
1237
  msgid "JS Deferred Excludes"
1238
  msgstr ""
1239
 
1240
+ #: src/lang.cls.php:143
1241
+ msgid "Inline JS Deferred Excludes"
1242
+ msgstr ""
1243
+
1244
+ #: src/lang.cls.php:144
1245
  msgid "Remove WordPress Emoji"
1246
  msgstr ""
1247
 
1248
+ #: src/lang.cls.php:145
1249
  msgid "URI Excludes"
1250
  msgstr ""
1251
 
1252
+ #: src/lang.cls.php:146
1253
  msgid "Role Excludes"
1254
  msgstr ""
1255
 
1256
+ #: src/lang.cls.php:149
1257
  msgid "Gravatar Cache Cron"
1258
  msgstr ""
1259
 
1260
+ #: src/lang.cls.php:150
1261
  msgid "Gravatar Cache TTL"
1262
  msgstr ""
1263
 
1264
+ #: src/lang.cls.php:152
1265
  msgid "Lazy Load Images"
1266
  msgstr ""
1267
 
1268
+ #: src/lang.cls.php:153
1269
  msgid "Lazy Load Image Excludes"
1270
  msgstr ""
1271
 
1272
+ #: src/lang.cls.php:154
1273
  msgid "Lazy Load Image Class Name Excludes"
1274
  msgstr ""
1275
 
1276
+ #: src/lang.cls.php:155
1277
  msgid "Lazy Load Image Parent Class Name Excludes"
1278
  msgstr ""
1279
 
1280
+ #: src/lang.cls.php:156
1281
  msgid "Lazy Load Iframe Class Name Excludes"
1282
  msgstr ""
1283
 
1284
+ #: src/lang.cls.php:157
1285
  msgid "Lazy Load Iframe Parent Class Name Excludes"
1286
  msgstr ""
1287
 
1288
+ #: src/lang.cls.php:158
1289
  msgid "Lazy Load URI Excludes"
1290
  msgstr ""
1291
 
1292
+ #: src/lang.cls.php:159
1293
  msgid "Basic Image Placeholder"
1294
  msgstr ""
1295
 
1296
+ #: src/lang.cls.php:160
1297
  msgid "Responsive Placeholder"
1298
  msgstr ""
1299
 
1300
+ #: src/lang.cls.php:161
1301
  msgid "Responsive Placeholder Color"
1302
  msgstr ""
1303
 
1304
+ #: src/lang.cls.php:162
1305
  msgid "Responsive Placeholder SVG"
1306
  msgstr ""
1307
 
1308
+ #: src/lang.cls.php:163
1309
  msgid "LQIP Cloud Generator"
1310
  msgstr ""
1311
 
1312
+ #: src/lang.cls.php:164
1313
  msgid "LQIP Quality"
1314
  msgstr ""
1315
 
1316
+ #: src/lang.cls.php:165
1317
  msgid "LQIP Minimum Dimensions"
1318
  msgstr ""
1319
 
1320
+ #: src/lang.cls.php:167
1321
  msgid "Generate LQIP In Background"
1322
  msgstr ""
1323
 
1324
+ #: src/lang.cls.php:168
1325
  msgid "Lazy Load Iframes"
1326
  msgstr ""
1327
 
1328
+ #: src/lang.cls.php:169
1329
  msgid "Inline Lazy Load Images Library"
1330
  msgstr ""
1331
 
1332
+ #: src/lang.cls.php:170
1333
  msgid "Auto Request Cron"
1334
  msgstr ""
1335
 
1336
+ #: src/lang.cls.php:171
1337
  msgid "Auto Pull Cron"
1338
  msgstr ""
1339
 
1340
+ #: src/lang.cls.php:172
1341
  msgid "Optimize Original Images"
1342
  msgstr ""
1343
 
1344
+ #: src/lang.cls.php:173
1345
  msgid "Remove Original Backups"
1346
  msgstr ""
1347
 
1348
+ #: src/lang.cls.php:174
1349
  msgid "Create WebP Versions"
1350
  msgstr ""
1351
 
1352
+ #: src/lang.cls.php:175
1353
  msgid "Optimize Losslessly"
1354
  msgstr ""
1355
 
1356
+ #: src/lang.cls.php:176
1357
  msgid "Preserve EXIF/XMP data"
1358
  msgstr ""
1359
 
1360
+ #: src/lang.cls.php:177
1361
  msgid "WebP Attribute To Replace"
1362
  msgstr ""
1363
 
1364
+ #: src/lang.cls.php:178
1365
  msgid "WebP For Extra srcset"
1366
  msgstr ""
1367
 
1368
+ #: src/lang.cls.php:179
1369
  msgid "WordPress Image Quality Control"
1370
  msgstr ""
1371
 
1372
+ #: src/lang.cls.php:180 tpl/esi_widget_edit.php:36
1373
  msgid "Enable ESI"
1374
  msgstr ""
1375
 
1376
+ #: src/lang.cls.php:181
1377
  msgid "Cache Admin Bar"
1378
  msgstr ""
1379
 
1380
+ #: src/lang.cls.php:182
1381
  msgid "Cache Comment Form"
1382
  msgstr ""
1383
 
1384
+ #: src/lang.cls.php:183
1385
+ msgid "ESI Nonces"
1386
  msgstr ""
1387
 
1388
+ #: src/lang.cls.php:184
1389
  msgid "Vary Group"
1390
  msgstr ""
1391
 
1392
+ #: src/lang.cls.php:185
1393
  msgid "Purge All Hooks"
1394
  msgstr ""
1395
 
1396
+ #: src/lang.cls.php:186
1397
  msgid "Improve HTTP/HTTPS Compatibility"
1398
  msgstr ""
1399
 
1400
+ #: src/lang.cls.php:187
1401
  msgid "Instant Click"
1402
  msgstr ""
1403
 
1404
+ #: src/lang.cls.php:188
1405
  msgid "Do Not Cache Cookies"
1406
  msgstr ""
1407
 
1408
+ #: src/lang.cls.php:189
1409
  msgid "Do Not Cache User Agents"
1410
  msgstr ""
1411
 
1412
+ #: src/lang.cls.php:190
1413
  msgid "Login Cookie"
1414
  msgstr ""
1415
 
1416
+ #: src/lang.cls.php:191
1417
  msgid "Image WebP Replacement"
1418
  msgstr ""
1419
 
1420
+ #: src/lang.cls.php:193
1421
  msgid "Frontend .htaccess Path"
1422
  msgstr ""
1423
 
1424
+ #: src/lang.cls.php:194
1425
  msgid "Backend .htaccess Path"
1426
  msgstr ""
1427
 
1428
+ #: src/lang.cls.php:195
1429
  msgid "Frontend Heartbeat Control"
1430
  msgstr ""
1431
 
1432
+ #: src/lang.cls.php:196
1433
  msgid "Frontend Heartbeat TTL"
1434
  msgstr ""
1435
 
1436
+ #: src/lang.cls.php:197
1437
  msgid "Backend Heartbeat Control"
1438
  msgstr ""
1439
 
1440
+ #: src/lang.cls.php:198
1441
  msgid "Backend Heartbeat TTL"
1442
  msgstr ""
1443
 
1444
+ #: src/lang.cls.php:199
1445
  msgid "Editor Heartbeat"
1446
  msgstr ""
1447
 
1448
+ #: src/lang.cls.php:200
1449
  msgid "Editor Heartbeat TTL"
1450
  msgstr ""
1451
 
1452
+ #: src/lang.cls.php:202
1453
  msgid "QUIC.cloud CDN"
1454
  msgstr ""
1455
 
1456
+ #: src/lang.cls.php:203
1457
  msgid "Use CDN Mapping"
1458
  msgstr ""
1459
 
1460
+ #: src/lang.cls.php:204
1461
  msgid "CDN URL"
1462
  msgstr ""
1463
 
1464
+ #: src/lang.cls.php:205
1465
  msgid "Include Images"
1466
  msgstr ""
1467
 
1468
+ #: src/lang.cls.php:206
1469
  msgid "Include CSS"
1470
  msgstr ""
1471
 
1472
+ #: src/lang.cls.php:207
1473
  msgid "Include JS"
1474
  msgstr ""
1475
 
1476
+ #: src/lang.cls.php:208 tpl/cdn/settings.tpl.php:148
1477
  msgid "Include File Types"
1478
  msgstr ""
1479
 
1480
+ #: src/lang.cls.php:209
1481
  msgid "HTML Attribute To Replace"
1482
  msgstr ""
1483
 
1484
+ #: src/lang.cls.php:210
1485
  msgid "Original URLs"
1486
  msgstr ""
1487
 
1488
+ #: src/lang.cls.php:211
1489
  msgid "Included Directories"
1490
  msgstr ""
1491
 
1492
+ #: src/lang.cls.php:212
1493
  msgid "Exclude Path"
1494
  msgstr ""
1495
 
1496
+ #: src/lang.cls.php:213
1497
  msgid "Load JQuery Remotely"
1498
  msgstr ""
1499
 
1500
+ #: src/lang.cls.php:214
1501
  msgid "Cloudflare API"
1502
  msgstr ""
1503
 
1504
+ #: src/lang.cls.php:217
1505
  msgid "Delay"
1506
  msgstr ""
1507
 
1508
+ #: src/lang.cls.php:218
1509
  msgid "Run Duration"
1510
  msgstr ""
1511
 
1512
+ #: src/lang.cls.php:219
1513
  msgid "Interval Between Runs"
1514
  msgstr ""
1515
 
1516
+ #: src/lang.cls.php:220
1517
  msgid "Crawl Interval"
1518
  msgstr ""
1519
 
1520
+ #: src/lang.cls.php:221
1521
  msgid "Threads"
1522
  msgstr ""
1523
 
1524
+ #: src/lang.cls.php:222
1525
  msgid "Timeout"
1526
  msgstr ""
1527
 
1528
+ #: src/lang.cls.php:223
1529
  msgid "Server Load Limit"
1530
  msgstr ""
1531
 
1532
+ #: src/lang.cls.php:224
1533
  msgid "Role Simulation"
1534
  msgstr ""
1535
 
1536
+ #: src/lang.cls.php:225
1537
  msgid "Cookie Simulation"
1538
  msgstr ""
1539
 
1540
+ #: src/lang.cls.php:226 tpl/crawler/settings-sitemap.tpl.php:115
1541
  msgid "Custom Sitemap"
1542
  msgstr ""
1543
 
1544
+ #: src/lang.cls.php:227
1545
  msgid "Drop Domain from Sitemap"
1546
  msgstr ""
1547
 
1548
+ #: src/lang.cls.php:228
1549
  msgid "Sitemap Timeout"
1550
  msgstr ""
1551
 
1552
+ #: src/lang.cls.php:230 tpl/inc/disabled_all.php:5
1553
  msgid "Disable All Features"
1554
  msgstr ""
1555
 
1556
+ #: src/lang.cls.php:231 tpl/toolbox/log_viewer.tpl.php:7
1557
  msgid "Debug Log"
1558
  msgstr ""
1559
 
1560
+ #: src/lang.cls.php:232
1561
  msgid "Admin IPs"
1562
  msgstr ""
1563
 
1564
+ #: src/lang.cls.php:233
1565
  msgid "Debug Level"
1566
  msgstr ""
1567
 
1568
+ #: src/lang.cls.php:234
1569
  msgid "Log File Size Limit"
1570
  msgstr ""
1571
 
1572
+ #: src/lang.cls.php:235
1573
  msgid "Log Cookies"
1574
  msgstr ""
1575
 
1576
+ #: src/lang.cls.php:236
1577
  msgid "Collapse Query Strings"
1578
  msgstr ""
1579
 
1580
+ #: src/lang.cls.php:237
1581
  msgid "Debug URI Includes"
1582
  msgstr ""
1583
 
1584
+ #: src/lang.cls.php:238
1585
  msgid "Debug URI Excludes"
1586
  msgstr ""
1587
 
1588
+ #: src/lang.cls.php:240
1589
  msgid "Revisions Max Number"
1590
  msgstr ""
1591
 
1592
+ #: src/lang.cls.php:241
1593
  msgid "Revisions Max Age"
1594
  msgstr ""
1595
 
1682
  msgid "Restore from backup"
1683
  msgstr ""
1684
 
1685
+ #: src/placeholder.cls.php:82 tpl/dash/network_dash.tpl.php:30
1686
  msgid "LQIP"
1687
  msgstr ""
1688
 
1689
+ #: src/placeholder.cls.php:140
1690
  msgid "LQIP image preview for size %s"
1691
  msgstr ""
1692
 
1693
+ #: src/purge.cls.php:193
1694
  msgid "Purged all caches successfully."
1695
  msgstr ""
1696
 
1697
+ #: src/purge.cls.php:213
1698
  msgid "Notified LiteSpeed Web Server to purge all LSCache entries."
1699
  msgstr ""
1700
 
1701
+ #: src/purge.cls.php:229
1702
  msgid "Cleaned all critical CSS files."
1703
  msgstr ""
1704
 
1705
+ #: src/purge.cls.php:245
1706
  msgid "Cleaned all LQIP files."
1707
  msgstr ""
1708
 
1709
+ #: src/purge.cls.php:260
1710
  msgid "Cleaned all gravatar files."
1711
  msgstr ""
1712
 
1713
+ #: src/purge.cls.php:275
1714
+ msgid "Notified LiteSpeed Web Server to purge localized resource entries."
1715
+ msgstr ""
1716
+
1717
+ #: src/purge.cls.php:295
1718
  msgid "Notified LiteSpeed Web Server to purge CSS/JS entries."
1719
  msgstr ""
1720
 
1721
+ #: src/purge.cls.php:311
1722
  msgid "Opcode cache is not enabled."
1723
  msgstr ""
1724
 
1725
+ #: src/purge.cls.php:323
1726
  msgid "Reset the entire opcode cache successfully."
1727
  msgstr ""
1728
 
1729
+ #: src/purge.cls.php:342
1730
  msgid "Object cache is not enabled."
1731
  msgstr ""
1732
 
1733
+ #: src/purge.cls.php:352
1734
  msgid "Purge all object caches successfully."
1735
  msgstr ""
1736
 
1737
+ #: src/purge.cls.php:515
1738
  msgid "Notified LiteSpeed Web Server to purge the front page."
1739
  msgstr ""
1740
 
1741
+ #: src/purge.cls.php:529
1742
  msgid "Notified LiteSpeed Web Server to purge pages."
1743
  msgstr ""
1744
 
1745
+ #: src/purge.cls.php:549
1746
  msgid "Notified LiteSpeed Web Server to purge error pages."
1747
  msgstr ""
1748
 
1749
+ #: src/purge.cls.php:577
1750
  msgid "Purge category %s"
1751
  msgstr ""
1752
 
1753
+ #: src/purge.cls.php:605
1754
  msgid "Purge tag %s"
1755
  msgstr ""
1756
 
1757
+ #: src/purge.cls.php:637
1758
  msgid "Purge url %s"
1759
  msgstr ""
1760
 
1761
+ #: src/task.cls.php:119
1762
  msgid "Every Minute"
1763
  msgstr ""
1764
 
1765
+ #: src/task.cls.php:138
1766
  msgid "LiteSpeed Crawler Cron"
1767
  msgstr ""
1768
 
1778
  msgid " %s ago"
1779
  msgstr ""
1780
 
1781
+ #: src/utility.cls.php:877
1782
  msgid "&laquo;"
1783
  msgstr ""
1784
 
1785
+ #: src/utility.cls.php:878
1786
  msgid "&raquo;"
1787
  msgstr ""
1788
 
1789
+ #: thirdparty/woocommerce.content.tpl.php:14
1790
  msgid "WooCommerce Settings"
1791
  msgstr ""
1792
 
1793
+ #: thirdparty/woocommerce.content.tpl.php:19
1794
  #: tpl/cache/settings-advanced.tpl.php:12
1795
  #: tpl/cache/settings_inc.browser.tpl.php:12 tpl/toolbox/heartbeat.tpl.php:14
1796
  #: tpl/toolbox/report.tpl.php:29
1797
  msgid "NOTICE:"
1798
  msgstr ""
1799
 
1800
+ #: thirdparty/woocommerce.content.tpl.php:20
1801
  msgid "After verifying that the cache works in general, please test the cart."
1802
  msgstr ""
1803
 
1804
+ #: thirdparty/woocommerce.content.tpl.php:21
1805
  msgid "To test the cart, visit the <a %s>FAQ</a>."
1806
  msgstr ""
1807
 
1808
+ #: thirdparty/woocommerce.content.tpl.php:28
1809
  msgid "Product Update Interval"
1810
  msgstr ""
1811
 
1812
+ #: thirdparty/woocommerce.content.tpl.php:33
1813
  msgid "Purge product on changes to the quantity or stock status."
1814
  msgstr ""
1815
 
1816
+ #: thirdparty/woocommerce.content.tpl.php:33
1817
  msgid "Purge categories only when stock status changes."
1818
  msgstr ""
1819
 
1820
+ #: thirdparty/woocommerce.content.tpl.php:34
1821
  msgid "Purge product and categories only when the stock status changes."
1822
  msgstr ""
1823
 
1824
+ #: thirdparty/woocommerce.content.tpl.php:35
1825
  msgid "Purge product only when the stock status changes."
1826
  msgstr ""
1827
 
1828
+ #: thirdparty/woocommerce.content.tpl.php:35
1829
  msgid "Do not purge categories on changes to the quantity or stock status."
1830
  msgstr ""
1831
 
1832
+ #: thirdparty/woocommerce.content.tpl.php:36
1833
  msgid ""
1834
  "Always purge both product and categories on changes to the quantity or stock "
1835
  "status."
1836
  msgstr ""
1837
 
1838
+ #: thirdparty/woocommerce.content.tpl.php:49
1839
  msgid ""
1840
  "Determines how changes in product quantity and product stock status affect "
1841
  "product pages and their associated category pages."
1842
  msgstr ""
1843
 
1844
+ #: thirdparty/woocommerce.content.tpl.php:57
1845
  msgid "Use Front Page TTL for the Shop Page"
1846
  msgstr ""
1847
 
1848
+ #: thirdparty/woocommerce.content.tpl.php:62
1849
  msgid ""
1850
  "Checking this option will force the shop page to use the front page TTL "
1851
  "setting."
1852
  msgstr ""
1853
 
1854
+ #: thirdparty/woocommerce.content.tpl.php:63
1855
  msgid ""
1856
  "For example, if the homepage for the site is located at %1$s, the shop page "
1857
  "may be located at %2$s."
1858
  msgstr ""
1859
 
1860
+ #: thirdparty/woocommerce.content.tpl.php:71
1861
  msgid "Privately Cache Cart"
1862
  msgstr ""
1863
 
1864
+ #: thirdparty/woocommerce.content.tpl.php:76
1865
  msgid "Privately cache cart when not empty."
1866
  msgstr ""
1867
 
1897
  msgid "Dismiss this notice"
1898
  msgstr ""
1899
 
1900
+ #. #-#-#-#-# litespeed-cache.pot (LiteSpeed Cache 3.3) #-#-#-#-#
1901
  #. Plugin Name of the plugin/theme
1902
  #: tpl/banner/new_version.php:59 tpl/banner/new_version_dev.tpl.php:12
1903
  #: tpl/cache/more_settings_tip.tpl.php:15 tpl/inc/admin_footer.php:8
1933
  msgid "New developer version %s is available now."
1934
  msgstr ""
1935
 
1936
+ #: tpl/banner/score.php:24
1937
  msgid "Thank You for Using the LiteSpeed Cache Plugin!"
1938
  msgstr ""
1939
 
1940
+ #: tpl/banner/score.php:28 tpl/dash/dashboard.tpl.php:153
1941
  msgid "Page Load Time"
1942
  msgstr ""
1943
 
1944
+ #: tpl/banner/score.php:34 tpl/banner/score.php:74
1945
  #: tpl/dash/dashboard.tpl.php:166 tpl/dash/dashboard.tpl.php:225
1946
  msgid "Before"
1947
  msgstr ""
1948
 
1949
+ #: tpl/banner/score.php:45 tpl/banner/score.php:84
1950
  #: tpl/dash/dashboard.tpl.php:175 tpl/dash/dashboard.tpl.php:233
1951
  msgid "After"
1952
  msgstr ""
1953
 
1954
+ #: tpl/banner/score.php:55 tpl/banner/score.php:94
1955
  #: tpl/dash/dashboard.tpl.php:183 tpl/dash/dashboard.tpl.php:241
1956
  msgid "Improved by"
1957
  msgstr ""
1958
 
1959
+ #: tpl/banner/score.php:68 tpl/dash/dashboard.tpl.php:210
1960
  msgid "PageSpeed Score"
1961
  msgstr ""
1962
 
1963
+ #: tpl/banner/score.php:113
1964
  msgid "Sure I'd love to review!"
1965
  msgstr ""
1966
 
1967
+ #: tpl/banner/score.php:117
1968
  msgid "I've already left a review"
1969
  msgstr ""
1970
 
1971
+ #: tpl/banner/score.php:118
1972
  msgid "Maybe later"
1973
  msgstr ""
1974
 
1975
+ #: tpl/banner/score.php:122
1976
+ msgid "Created with ❤️ by LiteSpeed team."
1977
  msgstr ""
1978
 
1979
+ #: tpl/banner/score.php:124
1980
  msgid "<a %s>Support forum</a> | <a %s>Submit a ticket</a>"
1981
  msgstr ""
1982
 
2001
  msgstr ""
2002
 
2003
  #: tpl/cache/entry.tpl.php:8 tpl/cache/entry_network.tpl.php:7
2004
+ #: tpl/toolbox/entry.tpl.php:6 tpl/toolbox/purge.tpl.php:135
2005
  msgid "Purge"
2006
  msgstr ""
2007
 
2038
  #: tpl/cache/settings-excludes.tpl.php:62
2039
  #: tpl/cache/settings-excludes.tpl.php:98 tpl/cdn/settings.tpl.php:124
2040
  #: tpl/crawler/settings-general.tpl.php:39
2041
+ #: tpl/crawler/settings-general.tpl.php:140
2042
+ #: tpl/crawler/settings-general.tpl.php:145
2043
  msgid "NOTE"
2044
  msgstr ""
2045
 
2219
  #: tpl/cache/settings-esi.tpl.php:35 tpl/cdn/manage.tpl.php:21
2220
  #: tpl/crawler/summary.tpl.php:48 tpl/inc/check_cache_disabled.php:31
2221
  #: tpl/inc/check_if_network_disable_all.php:19 tpl/page_optm/entry.tpl.php:31
2222
+ #: tpl/page_optm/settings_css.tpl.php:149
2223
+ #: tpl/page_optm/settings_localization.tpl.php:11
2224
  msgid "WARNING"
2225
  msgstr ""
2226
 
2246
  msgstr ""
2247
 
2248
  #: tpl/cache/settings-esi.tpl.php:91
2249
+ msgid "Fetch Latest Predefined Nonces"
2250
  msgstr ""
2251
 
2252
  #: tpl/cache/settings-esi.tpl.php:93
2253
  msgid ""
2254
+ "This will append any new predefined nonces found from the latest list source"
2255
  msgstr ""
2256
 
2257
  #: tpl/cache/settings-esi.tpl.php:98
2488
  msgid "OpenLiteSpeed users please check this"
2489
  msgstr ""
2490
 
2491
+ #: tpl/cache/settings_inc.browser.tpl.php:14
2492
+ msgid "Setting Up Custom Headers"
2493
+ msgstr ""
2494
+
2495
  #: tpl/cache/settings_inc.browser.tpl.php:27
2496
  msgid ""
2497
  "Browser caching stores static files locally in the user's browser. Turn on "
2957
  msgstr ""
2958
 
2959
  #: tpl/crawler/blacklist.tpl.php:31 tpl/crawler/map.tpl.php:43
2960
+ #: tpl/toolbox/purge.tpl.php:217
2961
  msgid "URL"
2962
  msgstr ""
2963
 
3089
 
3090
  #: tpl/crawler/settings-general.tpl.php:135
3091
  msgid ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3092
  "The maximum average server load allowed while crawling. The number of "
3093
  "crawler threads in use will be actively reduced until average server load "
3094
  "falls under this limit. If this cannot be achieved with a single thread, the "
3095
  "current crawler run will be terminated."
3096
  msgstr ""
3097
 
3098
+ #: tpl/crawler/settings-general.tpl.php:141
3099
  msgid "Server enforced value"
3100
  msgstr ""
3101
 
3102
+ #: tpl/crawler/settings-general.tpl.php:146
3103
  msgid "Server allowed max value"
3104
  msgstr ""
3105
 
3424
  msgstr ""
3425
 
3426
  #: tpl/dash/dashboard.tpl.php:202 tpl/img_optm/summary.tpl.php:51
3427
+ #: tpl/page_optm/settings_css.tpl.php:104
3428
+ #: tpl/page_optm/settings_css.tpl.php:203
3429
  #: tpl/page_optm/settings_media.tpl.php:172
3430
  msgid "Are you sure to redetect the closest cloud server for this service?"
3431
  msgstr ""
3471
  msgstr ""
3472
 
3473
  #: tpl/dash/dashboard.tpl.php:407 tpl/dash/dashboard.tpl.php:438
3474
+ #: tpl/page_optm/settings_css.tpl.php:96 tpl/page_optm/settings_css.tpl.php:195
3475
  #: tpl/page_optm/settings_media.tpl.php:167
3476
  msgid "Last generated"
3477
  msgstr ""
3748
  msgid "Link to QUIC.cloud"
3749
  msgstr ""
3750
 
3751
+ #: tpl/general/settings.tpl.php:85 tpl/general/settings.tpl.php:96
3752
+ #: tpl/general/settings.tpl.php:117 tpl/general/settings.tpl.php:161
3753
+ msgid "Notice"
3754
+ msgstr ""
3755
+
3756
  #: tpl/general/settings.tpl.php:86
3757
  msgid ""
3758
  "There is a problem receiving your domain key. Please click the %s button to "
3841
 
3842
  #: tpl/general/settings.tpl.php:158
3843
  msgid ""
3844
+ "Enter this site's IP address to allow cloud services directly call IP "
3845
+ "instead of domain name. This eliminates the overhead of DNS and CDN lookups."
3846
+ msgstr ""
3847
+
3848
+ #: tpl/general/settings.tpl.php:159
3849
+ msgid "Your server IP is"
3850
+ msgstr ""
3851
+
3852
+ #: tpl/general/settings.tpl.php:159
3853
+ msgid "Check my public IP from"
3854
+ msgstr ""
3855
+
3856
+ #: tpl/general/settings.tpl.php:161
3857
+ msgid ""
3858
+ "the auto-detected IP may not be accurate if you have an additional outgoing "
3859
+ "IP set, or you have multiple IPs configured on your server. Please make sure "
3860
+ "this IP is the correct one for visiting your site."
3861
+ msgstr ""
3862
+
3863
+ #: tpl/general/settings.tpl.php:177
3864
+ msgid ""
3865
  "Turn this option ON to show latest news automatically, including hotfixes, "
3866
  "new releases, available beta versions, and promotions."
3867
  msgstr ""
3952
  msgid "The image compression quality setting of WordPress out of 100."
3953
  msgstr ""
3954
 
3955
+ #: tpl/img_optm/summary.tpl.php:51 tpl/page_optm/settings_css.tpl.php:104
3956
+ #: tpl/page_optm/settings_css.tpl.php:203
3957
  #: tpl/page_optm/settings_media.tpl.php:172
3958
  msgid "Current closest Cloud server is %s.&#10; Click to redetect."
3959
  msgstr ""
4048
  msgstr ""
4049
 
4050
  #: tpl/img_optm/summary.tpl.php:239
4051
+ #: tpl/page_optm/settings_localization.tpl.php:51
4052
  msgid "Last ran"
4053
  msgstr ""
4054
 
4321
  "dismissed. (<a %3$s>Learn More</a>)"
4322
  msgstr ""
4323
 
4324
+ #: tpl/page_optm/entry.tpl.php:6 tpl/page_optm/settings_css.tpl.php:15
4325
  msgid "CSS Settings"
4326
  msgstr ""
4327
 
4341
  msgid "Media Excludes"
4342
  msgstr ""
4343
 
4344
+ #: tpl/page_optm/entry.tpl.php:11
4345
+ #: tpl/page_optm/settings_localization.tpl.php:17
4346
+ msgid "Localization Settings"
4347
  msgstr ""
4348
 
4349
  #: tpl/page_optm/entry.tpl.php:12 tpl/page_optm/settings_tuning.tpl.php:18
4366
  "Minify/Combine settings, please do a Purge All action."
4367
  msgstr ""
4368
 
4369
+ #: tpl/page_optm/settings_css.tpl.php:29
4370
  msgid "Minify CSS files."
4371
  msgstr ""
4372
 
4373
+ #: tpl/page_optm/settings_css.tpl.php:42
4374
  msgid "Combine CSS files."
4375
  msgstr ""
4376
 
4377
+ #: tpl/page_optm/settings_css.tpl.php:43 tpl/page_optm/settings_js.tpl.php:35
4378
  msgid "How to Fix Problems Caused by CSS/JS Optimization."
4379
  msgstr ""
4380
 
4381
+ #: tpl/page_optm/settings_css.tpl.php:56
4382
  msgid ""
4383
  "When having %1$s %2$s, enabling this will get one combined CSS file for each "
4384
  "URI, regardless of the setting %3$s."
4385
  msgstr ""
4386
 
4387
+ #: tpl/page_optm/settings_css.tpl.php:62
4388
  msgid ""
4389
  "This is useful when you want to refine/lint your CSS and further drop the "
4390
  "unused CSS per page."
4391
  msgstr ""
4392
 
4393
+ #: tpl/page_optm/settings_css.tpl.php:75
4394
+ msgid "Use QUIC.cloud online service to generate unique CSS."
4395
+ msgstr ""
4396
+
4397
+ #: tpl/page_optm/settings_css.tpl.php:88
4398
+ msgid "Generate unique CSS in the background via a cron-based queue."
4399
+ msgstr ""
4400
+
4401
+ #: tpl/page_optm/settings_css.tpl.php:89 tpl/page_optm/settings_css.tpl.php:187
4402
+ #: tpl/page_optm/settings_media.tpl.php:159
4403
+ msgid ""
4404
+ "If set to %s this is done in the foreground, which may slow down page load."
4405
+ msgstr ""
4406
+
4407
+ #: tpl/page_optm/settings_css.tpl.php:99 tpl/page_optm/settings_css.tpl.php:198
4408
+ msgid "Last requested cost"
4409
+ msgstr ""
4410
+
4411
+ #: tpl/page_optm/settings_css.tpl.php:121
4412
+ msgid ""
4413
+ "List the CSS selector that its style should be always contained in UCSS."
4414
+ msgstr ""
4415
+
4416
+ #: tpl/page_optm/settings_css.tpl.php:134
4417
  msgid ""
4418
  "Pre-send internal CSS files to the browser before they are requested. "
4419
  "(Requires the HTTP/2 protocol)"
4420
  msgstr ""
4421
 
4422
+ #: tpl/page_optm/settings_css.tpl.php:153
4423
  msgid "Optimize CSS delivery."
4424
  msgstr ""
4425
 
4426
+ #: tpl/page_optm/settings_css.tpl.php:154
4427
  #: tpl/page_optm/settings_html.tpl.php:107
4428
+ #: tpl/page_optm/settings_html.tpl.php:170 tpl/page_optm/settings_js.tpl.php:62
 
4429
  #: tpl/page_optm/settings_media.tpl.php:214
4430
  msgid ""
4431
  "This can improve your speed score in services like Pingdom, GTmetrix and "
4432
  "PageSpeed."
4433
  msgstr ""
4434
 
4435
+ #: tpl/page_optm/settings_css.tpl.php:155
4436
  msgid ""
4437
  "When this option is turned %s, it will also load Google Fonts asynchronously."
4438
  msgstr ""
4439
 
4440
+ #: tpl/page_optm/settings_css.tpl.php:158
4441
  #: tpl/page_optm/settings_media_exc.tpl.php:27
4442
  #: tpl/page_optm/settings_tuning.tpl.php:60
4443
  #: tpl/page_optm/settings_tuning.tpl.php:102
4445
  msgid "Elements with attribute %s in html code will be excluded."
4446
  msgstr ""
4447
 
4448
+ #: tpl/page_optm/settings_css.tpl.php:172
4449
  msgid ""
4450
  "Leave this option %1$s to allow communication with QUIC.cloud CCSS service. "
4451
  "If set to %2$s, Critical CSS will not be generated."
4452
  msgstr ""
4453
 
4454
+ #: tpl/page_optm/settings_css.tpl.php:173
4455
  msgid "This option only works if %1$s is %2$s."
4456
  msgstr ""
4457
 
4458
+ #: tpl/page_optm/settings_css.tpl.php:186
4459
  msgid ""
4460
  "Automatically generate critical CSS in the background via a cron-based queue."
4461
  msgstr ""
4462
 
4463
+ #: tpl/page_optm/settings_css.tpl.php:208
 
 
 
 
 
 
 
 
 
 
4464
  msgid "URL list in queue waiting for cron"
4465
  msgstr ""
4466
 
4467
+ #: tpl/page_optm/settings_css.tpl.php:219
4468
+ #: tpl/page_optm/settings_localization.tpl.php:62
4469
  #: tpl/page_optm/settings_media.tpl.php:183
4470
  msgid "Run Queue Manually"
4471
  msgstr ""
4472
 
4473
+ #: tpl/page_optm/settings_css.tpl.php:235
4474
  msgid ""
4475
  "List post types where each item of that type should have its own CCSS "
4476
  "generated."
4477
  msgstr ""
4478
 
4479
+ #: tpl/page_optm/settings_css.tpl.php:236
4480
  msgid ""
4481
  "For example, if every Page on the site has different formatting, enter %s in "
4482
  "the box. Separate critical CSS files will be stored for every Page on the "
4483
  "site."
4484
  msgstr ""
4485
 
4486
+ #: tpl/page_optm/settings_css.tpl.php:250
4487
  msgid ""
4488
  "Separate critical CSS files will be generated for paths containing these "
4489
  "strings."
4490
  msgstr ""
4491
 
4492
+ #: tpl/page_optm/settings_css.tpl.php:264
4493
  msgid "This will inline the asynchronous CSS library to avoid render blocking."
4494
  msgstr ""
4495
 
4496
+ #: tpl/page_optm/settings_css.tpl.php:275 tpl/page_optm/settings_js.tpl.php:73
4497
  msgid "Default"
4498
  msgstr ""
4499
 
4500
+ #: tpl/page_optm/settings_css.tpl.php:277
4501
  msgid ""
4502
  "Set this to append %1$s to all %2$s rules before caching CSS to specify how "
4503
  "fonts should be displayed while being downloaded."
4504
  msgstr ""
4505
 
4506
+ #: tpl/page_optm/settings_css.tpl.php:278
4507
  msgid "%s is recommended."
4508
  msgstr ""
4509
 
4510
+ #: tpl/page_optm/settings_css.tpl.php:278
4511
  msgid "Swap"
4512
  msgstr ""
4513
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4514
  #: tpl/page_optm/settings_html.tpl.php:21
4515
  msgid "Specify how long, in seconds, CSS/JS files are cached."
4516
  msgstr ""
4532
  msgstr ""
4533
 
4534
  #: tpl/page_optm/settings_html.tpl.php:76
4535
+ #: tpl/page_optm/settings_localization.tpl.php:131
4536
  msgid "For example"
4537
  msgstr ""
4538
 
4554
  msgid "Remove query strings from static resources."
4555
  msgstr ""
4556
 
4557
+ #: tpl/page_optm/settings_html.tpl.php:123
4558
  msgid "Google reCAPTCHA will be bypassed automatically."
4559
  msgstr ""
4560
 
4561
+ #: tpl/page_optm/settings_html.tpl.php:127
4562
  msgid "Append query string %s to the resources to bypass this action."
4563
  msgstr ""
4564
 
4565
+ #: tpl/page_optm/settings_html.tpl.php:141
4566
  msgid ""
4567
  "Use Web Font Loader library to load Google Fonts asynchronously while "
4568
  "leaving other CSS intact."
4569
  msgstr ""
4570
 
4571
+ #: tpl/page_optm/settings_html.tpl.php:142
4572
  msgid ""
4573
  "This will also add a preconnect to Google for faster Google Fonts "
4574
  "downloading."
4575
  msgstr ""
4576
 
4577
+ #: tpl/page_optm/settings_html.tpl.php:156
4578
  msgid "Prevent Google Fonts from loading on all pages."
4579
  msgstr ""
4580
 
4581
+ #: tpl/page_optm/settings_html.tpl.php:169
4582
  msgid ""
4583
  "Stop loading WordPress.org emoji. Browser default emoji will be displayed "
4584
  "instead."
4634
  "this option."
4635
  msgstr ""
4636
 
4637
+ #: tpl/page_optm/settings_localization.tpl.php:12
4638
+ msgid ""
4639
+ "Failed to create Avatar table. Please follow <a %s>Table Creation guidance "
4640
+ "from LiteSpeed Wiki</a> to finish setup."
4641
+ msgstr ""
4642
+
4643
+ #: tpl/page_optm/settings_localization.tpl.php:30
4644
+ msgid "Store Gravatar locally."
4645
+ msgstr ""
4646
+
4647
+ #: tpl/page_optm/settings_localization.tpl.php:31
4648
+ msgid ""
4649
+ "Accelerates the speed by caching Gravatar (Globally Recognized Avatars)."
4650
+ msgstr ""
4651
+
4652
+ #: tpl/page_optm/settings_localization.tpl.php:44
4653
+ msgid "Refresh Gravatar cache by cron."
4654
+ msgstr ""
4655
+
4656
+ #: tpl/page_optm/settings_localization.tpl.php:57
4657
+ msgid "Avatar list in queue waiting for update"
4658
+ msgstr ""
4659
+
4660
+ #: tpl/page_optm/settings_localization.tpl.php:79
4661
+ msgid "Specify how long, in seconds, Gravatar files are cached."
4662
+ msgstr ""
4663
+
4664
+ #: tpl/page_optm/settings_localization.tpl.php:94
4665
+ msgid "Localize external resources."
4666
+ msgstr ""
4667
+
4668
+ #: tpl/page_optm/settings_localization.tpl.php:116
4669
+ msgid ""
4670
+ "Resources from the domains listed here will be copied and replaced with "
4671
+ "local URLs."
4672
+ msgstr ""
4673
+
4674
+ #: tpl/page_optm/settings_localization.tpl.php:117
4675
+ msgid "HTTPS sources only."
4676
+ msgstr ""
4677
+
4678
+ #: tpl/page_optm/settings_localization.tpl.php:119
4679
+ msgid "List as file format (optional) + URL, separated by a space."
4680
+ msgstr ""
4681
+
4682
+ #: tpl/page_optm/settings_localization.tpl.php:122
4683
+ msgid ""
4684
+ "Comments are supported. Start a line with a %s to turn it into a comment "
4685
+ "line."
4686
+ msgstr ""
4687
+
4688
+ #: tpl/page_optm/settings_localization.tpl.php:125
4689
+ msgid "If format is not specified, %s is assumed."
4690
+ msgstr ""
4691
+
4692
+ #: tpl/page_optm/settings_localization.tpl.php:126
4693
+ msgid "Currently format supports"
4694
+ msgstr ""
4695
+
4696
+ #: tpl/page_optm/settings_localization.tpl.php:128
4697
+ msgid "%s format will be added in a future version."
4698
+ msgstr ""
4699
+
4700
+ #: tpl/page_optm/settings_localization.tpl.php:129
4701
+ msgid "The format will affect the response content type header."
4702
+ msgstr ""
4703
+
4704
+ #: tpl/page_optm/settings_localization.tpl.php:131
4705
+ msgid "or"
4706
+ msgstr ""
4707
+
4708
+ #: tpl/page_optm/settings_localization.tpl.php:134
4709
+ msgid "Example 2"
4710
+ msgstr ""
4711
+
4712
  #: tpl/page_optm/settings_media.tpl.php:25
4713
  msgid "Load images only when they enter the viewport."
4714
  msgstr ""
4937
  msgstr ""
4938
 
4939
  #: tpl/page_optm/settings_tuning.tpl.php:164
4940
+ msgid "Inline JS codes including the above fragments will not be deferred."
4941
+ msgstr ""
4942
+
4943
+ #: tpl/page_optm/settings_tuning.tpl.php:178
4944
  msgid "Prevent any optimization of listed pages."
4945
  msgstr ""
4946
 
4947
+ #: tpl/page_optm/settings_tuning.tpl.php:191
4948
  msgid "Selected roles will be excluded from all optimizations."
4949
  msgstr ""
4950
 
5217
  msgstr ""
5218
 
5219
  #: tpl/toolbox/purge.tpl.php:82
5220
+ msgid "This will delete all localized resources"
5221
  msgstr ""
5222
 
5223
  #: tpl/toolbox/purge.tpl.php:91
5224
+ msgid "This will delete all generated image LQIP placeholder files"
5225
  msgstr ""
5226
 
5227
  #: tpl/toolbox/purge.tpl.php:100
5228
+ msgid "This will delete all cached Gravatar files"
5229
+ msgstr ""
5230
+
5231
+ #: tpl/toolbox/purge.tpl.php:109
5232
  msgid ""
5233
  "Purge the cache entries created by this plugin except for Critical CSS & "
5234
  "LQIP caches"
5235
  msgstr ""
5236
 
5237
+ #: tpl/toolbox/purge.tpl.php:118
5238
  msgid "Empty Entire Cache"
5239
  msgstr ""
5240
 
5241
+ #: tpl/toolbox/purge.tpl.php:119
5242
  msgid ""
5243
  "Clears all cache entries related to this site, <i>including other web "
5244
  "applications</i>."
5245
  msgstr ""
5246
 
5247
+ #: tpl/toolbox/purge.tpl.php:120
5248
  msgid "This action should only be used if things are cached incorrectly."
5249
  msgstr ""
5250
 
5251
+ #: tpl/toolbox/purge.tpl.php:124
5252
  msgid "This will clear EVERYTHING inside the cache."
5253
  msgstr ""
5254
 
5255
+ #: tpl/toolbox/purge.tpl.php:125
5256
  msgid "This may cause heavy load on the server."
5257
  msgstr ""
5258
 
5259
+ #: tpl/toolbox/purge.tpl.php:126
5260
  msgid "If only the WordPress site should be purged, use purge all."
5261
  msgstr ""
5262
 
5263
+ #: tpl/toolbox/purge.tpl.php:170
5264
  msgid "Purge By..."
5265
  msgstr ""
5266
 
5267
+ #: tpl/toolbox/purge.tpl.php:172
5268
  msgid "Select below for \"Purge by\" options."
5269
  msgstr ""
5270
 
5271
+ #: tpl/toolbox/purge.tpl.php:199
5272
  msgid "Category"
5273
  msgstr ""
5274
 
5275
+ #: tpl/toolbox/purge.tpl.php:205
5276
  msgid "Post ID"
5277
  msgstr ""
5278
 
5279
+ #: tpl/toolbox/purge.tpl.php:211
5280
  msgid "Tag"
5281
  msgstr ""
5282
 
5283
+ #: tpl/toolbox/purge.tpl.php:223
5284
  msgid ""
5285
  "Purge pages by category name - e.g. %2$s should be used for the URL %1$s."
5286
  msgstr ""
5287
 
5288
+ #: tpl/toolbox/purge.tpl.php:228
5289
  msgid "Purge pages by post ID."
5290
  msgstr ""
5291
 
5292
+ #: tpl/toolbox/purge.tpl.php:232
5293
  msgid "Purge pages by tag name - e.g. %2$s should be used for the URL %1$s."
5294
  msgstr ""
5295
 
5296
+ #: tpl/toolbox/purge.tpl.php:237
5297
  msgid "Purge pages by relative or full URL."
5298
  msgstr ""
5299
 
5300
+ #: tpl/toolbox/purge.tpl.php:238
5301
  msgid "e.g. Use %s or %s."
5302
  msgstr ""
5303
 
5304
+ #: tpl/toolbox/purge.tpl.php:251
5305
  msgid "Purge List"
5306
  msgstr ""
5307
 
litespeed-cache.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: LiteSpeed Cache
4
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
5
  * Description: High-performance page caching and site optimization from LiteSpeed
6
- * Version: 3.2.4
7
  * Author: LiteSpeed Technologies
8
  * Author URI: https://www.litespeedtech.com
9
  * License: GPLv3
@@ -33,7 +33,7 @@ if ( class_exists( 'LiteSpeed\Core' ) || defined( 'LSCWP_DIR' ) ) {
33
  return;
34
  }
35
 
36
- ! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '3.2.4' );
37
 
38
  ! defined( 'LSCWP_CONTENT_DIR' ) && define( 'LSCWP_CONTENT_DIR', WP_CONTENT_DIR ) ;
39
  ! defined( 'LSCWP_DIR' ) && define( 'LSCWP_DIR', __DIR__ . '/' ) ;// Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
3
  * Plugin Name: LiteSpeed Cache
4
  * Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
5
  * Description: High-performance page caching and site optimization from LiteSpeed
6
+ * Version: 3.3
7
  * Author: LiteSpeed Technologies
8
  * Author URI: https://www.litespeedtech.com
9
  * License: GPLv3
33
  return;
34
  }
35
 
36
+ ! defined( 'LSCWP_V' ) && define( 'LSCWP_V', '3.3' );
37
 
38
  ! defined( 'LSCWP_CONTENT_DIR' ) && define( 'LSCWP_CONTENT_DIR', WP_CONTENT_DIR ) ;
39
  ! defined( 'LSCWP_DIR' ) && define( 'LSCWP_DIR', __DIR__ . '/' ) ;// Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
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: 5.4.2
6
- Stable tag: 3.2.4
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
@@ -25,7 +25,7 @@ LSCWP supports WordPress Multisite and is compatible with most popular plugins,
25
  = General Features =
26
 
27
  * Free QUIC.cloud CDN Cache
28
- * Object Cache (Memcached/LSMCD/Redis)
29
  * Image Optimization (Lossless/Lossy)
30
  * Minify CSS, JavaScript, and HTML
31
  * Minify inline CSS/JS
@@ -33,12 +33,12 @@ LSCWP supports WordPress Multisite and is compatible with most popular plugins,
33
  * Automatically generate Critical CSS
34
  * Lazyload images/iframes
35
  * Responsive Image Placeholders
36
- * Multiple CDN support
37
  * Load CSS/JS Asynchronously
38
- * Browser Cache
39
  * Database Cleaner and Optimizer
40
  * PageSpeed score optimization
41
- * OPcode Cache
42
  * HTTP/2 Push for CSS/JS (on web servers that support it)
43
  * DNS Prefetch
44
  * Cloudflare API
@@ -48,6 +48,8 @@ LSCWP supports WordPress Multisite and is compatible with most popular plugins,
48
  * WebP image format support
49
  * Heartbeat control
50
 
 
 
51
  = LiteSpeed Exclusive Features =
52
 
53
  * Automatic page caching to greatly improve site performance
@@ -243,6 +245,31 @@ The vast majority of plugins and themes are compatible with LiteSpeed Cache. The
243
 
244
  == Changelog ==
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  = 3.2.4 - Jul 8 2020 =
247
  * **Object** New installations no longer get custom data.ini reset, as this could cause lost configuration. (@Eric)
248
  * **ESI** Now using `svar` to load nonces more quickly. (@Lauren)
3
  Tags: caching, optimize, performance, pagespeed, seo, speed, image optimize, compress, object cache, redis, memcached, database cleaner
4
  Requires at least: 4.0
5
  Tested up to: 5.4.2
6
+ Stable tag: 3.3
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl.html
9
 
25
  = General Features =
26
 
27
  * Free QUIC.cloud CDN Cache
28
+ * Object Cache (Memcached/LSMCD/Redis) Support<sup>+</sup>
29
  * Image Optimization (Lossless/Lossy)
30
  * Minify CSS, JavaScript, and HTML
31
  * Minify inline CSS/JS
33
  * Automatically generate Critical CSS
34
  * Lazyload images/iframes
35
  * Responsive Image Placeholders
36
+ * Multiple CDN Support<sup>+</sup>
37
  * Load CSS/JS Asynchronously
38
+ * Browser Cache Support<sup>+</sup>
39
  * Database Cleaner and Optimizer
40
  * PageSpeed score optimization
41
+ * OPcode Cache Support<sup>+</sup>
42
  * HTTP/2 Push for CSS/JS (on web servers that support it)
43
  * DNS Prefetch
44
  * Cloudflare API
48
  * WebP image format support
49
  * Heartbeat control
50
 
51
+ <sup>+</sup> This service is not provided by the LSCache plugin, nor is it guaranteed to be installed by your service provider. However, the plugin is compatible with the service if it is in use on your site.
52
+
53
  = LiteSpeed Exclusive Features =
54
 
55
  * Automatic page caching to greatly improve site performance
245
 
246
  == Changelog ==
247
 
248
+ = 3.3 - Aug 6 2020 =
249
+ * 🌱**Page Optimize** Added a new setting, Inline JS Deferred Excludes. (@ankit)
250
+ * **Page Optimize** CSS/JS Combine/Minify file versions will be differentiated by query string hash instead of new filename to reduce DB/file system storage.
251
+ * **Page Optimize** Added the ability to use local copies of external JS files for better control over page score impacts.
252
+ * **Page Optimize** Improved combination of CSS media queries. (@galbaras)
253
+ * **Page Optimize** Reprioritized Inline JS Defer to be optimized before encoding, for a significantly smaller result.
254
+ * **LQIP** Detect if the file exists before sending LQIP request to QUIC.cloud.
255
+ * **CCSS** Sped up CCSS process significantly by sending HTML and CSS in request.
256
+ * **CCSS** Improvements to mobile CSS support in CCSS.
257
+ * **CCSS** Minimize CCSS failures by attempting to automatically fix CSS syntax errors.
258
+ * **Cloud** Domain Key will be deleted after QUIC.cloud site_not_registered error to avoid endless repeated requests.
259
+ * **CDN** CDN Original URL will default to WP Site URL if not set. (@ruikai)
260
+ * **CLI** Global output format `--format=json/yaml/dump` and `--json` support in CLI. (@alya1992)
261
+ * **CDN** Improved handling of non-image CSS `url()` sources in CDN. (@daniel McD)
262
+ * 🐞**CDN** Fixed CDN replacement conflict w/ JS/CSS Optimize. (@ankit)
263
+ * **Crawler** Only reset Crawler waiting queues when crawling begins. (@ruikai)
264
+ * **Network** Network Enable Cache is no longer reset to ON Use Network Settings in enabled. (@RavanH)
265
+ * 🐞**Activation** Fixed a PHP warning that appeared during uninstall. (@RavanH)
266
+ * **Debug** Automatically omit long strings when dumping an array to debug log.
267
+ * **Report** Subsites report now shows overwritten values along w/ original values. (#52593959)
268
+ * **REST** Improved WP5.5 REST compatibility. (@oldrup)
269
+ * **GUI** Server IP setting moved from Crawler menu to General menu.
270
+ * **GUI** Localize resources moved to Localization tab.
271
+ * **Config** News option now defaults to ON.
272
+
273
  = 3.2.4 - Jul 8 2020 =
274
  * **Object** New installations no longer get custom data.ini reset, as this could cause lost configuration. (@Eric)
275
  * **ESI** Now using `svar` to load nonces more quickly. (@Lauren)
src/admin-display.cls.php CHANGED
@@ -8,35 +8,34 @@
8
  * @subpackage LiteSpeed/admin
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
- namespace LiteSpeed ;
12
 
13
- defined( 'WPINC' ) || exit ;
14
 
15
- class Admin_Display extends Base
16
- {
17
- protected static $_instance ;
18
 
19
- const NOTICE_BLUE = 'notice notice-info' ;
20
- const NOTICE_GREEN = 'notice notice-success' ;
21
- const NOTICE_RED = 'notice notice-error' ;
22
- const NOTICE_YELLOW = 'notice notice-warning' ;
23
- const DB_MSG = 'messages' ;
24
 
25
- const PURGEBY_CAT = '0' ;
26
- const PURGEBY_PID = '1' ;
27
- const PURGEBY_TAG = '2' ;
28
- const PURGEBY_URL = '3' ;
29
 
30
- const PURGEBYOPT_SELECT = 'purgeby' ;
31
- const PURGEBYOPT_LIST = 'purgebylist' ;
32
 
33
- const DB_DISMISS_MSG = 'dismiss' ;
34
- const RULECONFLICT_ON = 'ExpiresDefault_1' ;
35
- const RULECONFLICT_DISMISSED = 'ExpiresDefault_0' ;
36
 
37
- protected $__cfg ;
38
- protected $messages = array() ;
39
- protected $default_settings = array() ;
40
  protected $_is_network_admin = false;
41
  protected $_is_multisite = false;
42
 
@@ -46,36 +45,35 @@ class Admin_Display extends Base
46
  * @since 1.0.7
47
  * @access protected
48
  */
49
- protected function __construct()
50
- {
51
  // load assets
52
  if( ! empty( $_GET[ 'page' ] ) && ( strpos( $_GET[ 'page' ], 'litespeed-' ) === 0 || $_GET[ 'page' ] == 'litespeed' ) ) {
53
- add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) ) ;
54
  }
55
 
56
  // main css
57
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ) ) ;
58
  // Main js
59
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ) ;
60
 
61
- $this->_is_network_admin = is_network_admin() ;
62
- $this->_is_multisite = is_multisite() ;
63
 
64
  // Quick access menu
65
  if ( is_multisite() && $this->_is_network_admin ) {
66
- $manage = 'manage_network_options' ;
67
  }
68
  else {
69
- $manage = 'manage_options' ;
70
  }
71
  if ( current_user_can( $manage ) ) {
72
  if ( ! defined( 'LITESPEED_DISABLE_ALL' ) ) {
73
- add_action( 'wp_before_admin_bar_render', array( GUI::get_instance(), 'backend_shortcut' ) ) ;
74
  }
75
 
76
  // `admin_notices` is after `admin_enqueue_scripts`
77
  // @see wp-admin/admin-header.php
78
- add_action( $this->_is_network_admin ? 'network_admin_notices' : 'admin_notices', array( $this, 'display_messages' ) ) ;
79
  }
80
 
81
  /**
@@ -84,18 +82,18 @@ class Admin_Display extends Base
84
  * @since 2.0
85
  */
86
  if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
87
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' ) ;
88
  }
89
 
90
  // add menus ( Also check for mu-plugins)
91
  if ( $this->_is_network_admin && ( is_plugin_active_for_network( LSCWP_BASENAME ) || defined( 'LSCWP_MU_PLUGIN' ) ) ) {
92
- add_action( 'network_admin_menu', array( $this, 'register_admin_menu' ) ) ;
93
  }
94
  else {
95
- add_action( 'admin_menu', array( $this, 'register_admin_menu' ) ) ;
96
  }
97
 
98
- $this->__cfg = Conf::get_instance() ;
99
  }
100
 
101
  /**
@@ -105,24 +103,23 @@ class Admin_Display extends Base
105
  * @access public
106
  * @param array $hook WP hook
107
  */
108
- public function load_assets($hook)
109
- {
110
  // Admin footer
111
- add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1) ;
112
 
113
  if( defined( 'LITESPEED_ON' ) ) {
114
  // Help tab
115
- $this->add_help_tabs() ;
116
 
117
- global $pagenow ;
118
  if ( $pagenow === 'plugins.php' ) {//todo: check if work
119
- add_action('wp_default_scripts', array($this, 'set_update_text'), 0) ;
120
- add_action('wp_default_scripts', array($this, 'unset_update_text'), 20) ;
121
  }
122
  }
123
 
124
- wp_register_script( Core::PLUGIN_NAME . '-lib-vue', LSWCP_PLUGIN_URL . 'assets/js/vue.min.js', array(), Core::VER, false ) ;
125
- wp_enqueue_script( Core::PLUGIN_NAME . '-lib-vue' ) ;
126
  }
127
 
128
  /**
@@ -131,9 +128,8 @@ class Admin_Display extends Base
131
  * @since 3.0
132
  * @access public
133
  */
134
- public function title( $id )
135
- {
136
- echo Lang::title( $id ) ;
137
  }
138
 
139
  /**
@@ -142,8 +138,7 @@ class Admin_Display extends Base
142
  * @since 1.0.0
143
  * @access public
144
  */
145
- public function register_admin_menu()
146
- {
147
  $capability = $this->_is_network_admin ? 'manage_network_options' : 'manage_options';
148
  if ( current_user_can( $capability ) ) {
149
 
@@ -183,8 +178,7 @@ class Admin_Display extends Base
183
  * @param string $menu_slug The slug of the page.
184
  * @param string $callback The callback to call if selected.
185
  */
186
- private function _add_submenu( $menu_title, $menu_slug, $callback )
187
- {
188
  add_submenu_page( 'litespeed', $menu_title, $menu_title, 'manage_options', $menu_slug, array( $this, $callback ) );
189
  }
190
 
@@ -194,9 +188,8 @@ class Admin_Display extends Base
194
  * @since 1.0.14
195
  * @access public
196
  */
197
- public function enqueue_style()
198
- {
199
- wp_enqueue_style(Core::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'assets/css/litespeed.css', array(), Core::VER, 'all') ;
200
  }
201
 
202
  /**
@@ -225,9 +218,9 @@ class Admin_Display extends Base
225
  $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo;
226
  }
227
 
228
- // If on crawler page, append getIP link
229
  global $pagenow;
230
- if ( $pagenow == 'admin.php' && ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'litespeed-crawler' ) {
231
  $localize_data[ 'ajax_url_getIP' ] = function_exists( 'get_rest_url' ) ? get_rest_url( null, 'litespeed/v1/tool/check_ip' ) : '/';
232
  $localize_data[ 'nonce' ] = wp_create_nonce( 'wp_rest' );
233
  }
@@ -253,8 +246,7 @@ class Admin_Display extends Base
253
  * @param array $links Previously added links from other plugins.
254
  * @return array Links array with the litespeed cache one appended.
255
  */
256
- public function add_plugin_links($links)
257
- {
258
  // $links[] = '<a href="' . admin_url('options-general.php?page=litespeed-cache') . '">' . __('Settings', 'litespeed-cache') . '</a>';
259
  $links[] = '<a href="' . admin_url('admin.php?page=litespeed-cache') . '">' . __('Settings', 'litespeed-cache') . '</a>';
260
 
@@ -270,8 +262,7 @@ class Admin_Display extends Base
270
  * @param string $text
271
  * @return string
272
  */
273
- public function add_update_text($translations, $text)
274
- {
275
  if ( $text !== 'Updated!' ) {
276
  return $translations;
277
  }
@@ -285,8 +276,7 @@ class Admin_Display extends Base
285
  * @since 1.0.8.1
286
  * @access public
287
  */
288
- public function set_update_text()
289
- {
290
  add_filter('gettext', array($this, 'add_update_text'), 10, 2);
291
  }
292
 
@@ -296,8 +286,7 @@ class Admin_Display extends Base
296
  * @since 1.0.8.1
297
  * @access public
298
  */
299
- public function unset_update_text()
300
- {
301
  remove_filter('gettext', array($this, 'add_update_text'));
302
  }
303
 
@@ -308,11 +297,10 @@ class Admin_Display extends Base
308
  * @param string $footer_text
309
  * @return string
310
  */
311
- public function admin_footer_text($footer_text)
312
- {
313
- require_once LSCWP_DIR . 'tpl/inc/admin_footer.php' ;
314
 
315
- return $footer_text ;
316
  }
317
 
318
  /**
@@ -321,9 +309,8 @@ class Admin_Display extends Base
321
  * @since 1.0.0
322
  * @access public
323
  */
324
- public function add_help_tabs()
325
- {
326
- require_once LSCWP_DIR . 'tpl/inc/help_tabs.php' ;
327
  }
328
 
329
  /**
@@ -335,9 +322,8 @@ class Admin_Display extends Base
335
  * @param string $str The notice message.
336
  * @return string The built notice html.
337
  */
338
- public static function build_notice($color, $str)
339
- {
340
- return '<div class="' . $color . ' is-dismissible"><p>'. $str . '</p></div>' ;
341
  }
342
 
343
  /**
@@ -346,8 +332,7 @@ class Admin_Display extends Base
346
  * @since 1.6.5
347
  * @access public
348
  */
349
- public static function info( $msg, $echo = false )
350
- {
351
  self::add_notice( self::NOTICE_BLUE, $msg, $echo );
352
  }
353
 
@@ -357,8 +342,7 @@ class Admin_Display extends Base
357
  * @since 1.6.5
358
  * @access public
359
  */
360
- public static function note( $msg, $echo = false )
361
- {
362
  self::add_notice( self::NOTICE_YELLOW, $msg, $echo );
363
  }
364
 
@@ -368,8 +352,7 @@ class Admin_Display extends Base
368
  * @since 1.6
369
  * @access public
370
  */
371
- public static function succeed( $msg, $echo = false )
372
- {
373
  self::add_notice( self::NOTICE_GREEN, $msg, $echo );
374
  }
375
 
@@ -379,8 +362,7 @@ class Admin_Display extends Base
379
  * @since 1.6
380
  * @access public
381
  */
382
- public static function error( $msg, $echo = false )
383
- {
384
  self::add_notice( self::NOTICE_RED, $msg, $echo );
385
  }
386
 
@@ -390,8 +372,7 @@ class Admin_Display extends Base
390
  * @since 1.0.7
391
  * @access public
392
  */
393
- public static function add_notice( $color, $msg, $echo = false )
394
- {
395
  // Bypass adding for CLI or cron
396
  if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
397
  // WP CLI will show the info directly
@@ -495,8 +476,7 @@ class Admin_Display extends Base
495
  * @since 1.1.0
496
  * @access public
497
  */
498
- public function show_widget_edit($widget, $return, $instance)
499
- {
500
  require LSCWP_DIR . 'tpl/esi_widget_edit.php';
501
  }
502
 
@@ -506,9 +486,8 @@ class Admin_Display extends Base
506
  * @since 3.0
507
  * @access public
508
  */
509
- public function show_menu_dash()
510
- {
511
- require_once LSCWP_DIR . 'tpl/dash/entry.tpl.php' ;
512
  }
513
 
514
  /**
@@ -517,9 +496,8 @@ class Admin_Display extends Base
517
  * @since 3.0
518
  * @access public
519
  */
520
- public function show_menu_general()
521
- {
522
- require_once LSCWP_DIR . 'tpl/general/entry.tpl.php' ;
523
  }
524
 
525
  /**
@@ -528,9 +506,8 @@ class Admin_Display extends Base
528
  * @since 3.0
529
  * @access public
530
  */
531
- public function show_menu_cdn()
532
- {
533
- require_once LSCWP_DIR . 'tpl/cdn/entry.tpl.php' ;
534
  }
535
 
536
  /**
@@ -539,13 +516,12 @@ class Admin_Display extends Base
539
  * @since 1.0.0
540
  * @access public
541
  */
542
- public function show_menu_cache()
543
- {
544
  if ( $this->_is_network_admin ) {
545
- require_once LSCWP_DIR . 'tpl/cache/entry_network.tpl.php' ;
546
  }
547
  else {
548
- require_once LSCWP_DIR . 'tpl/cache/entry.tpl.php' ;
549
  }
550
  }
551
 
@@ -555,9 +531,8 @@ class Admin_Display extends Base
555
  * @since 3.0
556
  * @access public
557
  */
558
- public function show_toolbox()
559
- {
560
- require_once LSCWP_DIR . 'tpl/toolbox/entry.tpl.php' ;
561
  }
562
 
563
  /**
@@ -566,9 +541,8 @@ class Admin_Display extends Base
566
  * @since 1.1.0
567
  * @access public
568
  */
569
- public function show_crawler()
570
- {
571
- require_once LSCWP_DIR . 'tpl/crawler/entry.tpl.php' ;
572
  }
573
 
574
  /**
@@ -577,9 +551,8 @@ class Admin_Display extends Base
577
  * @since 1.6
578
  * @access public
579
  */
580
- public function show_img_optm()
581
- {
582
- require_once LSCWP_DIR . 'tpl/img_optm/entry.tpl.php' ;
583
  }
584
 
585
  /**
@@ -588,9 +561,8 @@ class Admin_Display extends Base
588
  * @since 3.0
589
  * @access public
590
  */
591
- public function show_page_optm()
592
- {
593
- require_once LSCWP_DIR . 'tpl/page_optm/entry.tpl.php' ;
594
  }
595
 
596
  /**
@@ -599,9 +571,8 @@ class Admin_Display extends Base
599
  * @since 3.0
600
  * @access public
601
  */
602
- public function show_db_optm()
603
- {
604
- require_once LSCWP_DIR . 'tpl/db_optm/entry.tpl.php' ;
605
  }
606
 
607
  /**
@@ -611,9 +582,8 @@ class Admin_Display extends Base
611
  * @since 1.0.12
612
  * @access public
613
  */
614
- public function show_display_installed()
615
- {
616
- require_once LSCWP_DIR . 'tpl/inc/show_display_installed.php' ;
617
  }
618
 
619
  /**
@@ -622,9 +592,8 @@ class Admin_Display extends Base
622
  * @since 1.0.12
623
  * @access public
624
  */
625
- public static function show_error_cookie()
626
- {
627
- require_once LSCWP_DIR . 'tpl/inc/show_error_cookie.php' ;
628
  }
629
 
630
  /**
@@ -633,9 +602,8 @@ class Admin_Display extends Base
633
  * @since 2.1
634
  * @access public
635
  */
636
- public function cache_disabled_warning()
637
- {
638
- include LSCWP_DIR . "tpl/inc/check_cache_disabled.php" ;
639
  }
640
 
641
  /**
@@ -644,21 +612,20 @@ class Admin_Display extends Base
644
  * @since 3.0
645
  * @access public
646
  */
647
- public function form_action( $action = false, $type = false, $has_upload = false )
648
- {
649
  if ( ! $action ) {
650
  $action = Router::ACTION_SAVE_SETTINGS;
651
  }
652
 
653
- $has_upload = $has_upload ? 'enctype="multipart/form-data"' : '' ;
654
 
655
- echo '<form method="post" action="' . wp_unslash( $_SERVER[ 'REQUEST_URI' ] ) . '" class="litespeed-relative" ' . $has_upload . '>' ;
656
 
657
- echo '<input type="hidden" name="' . Router::ACTION . '" value="' . $action . '" />' ;
658
  if ( $type ) {
659
- echo '<input type="hidden" name="' . Router::TYPE . '" value="' . $type . '" />' ;
660
  }
661
- wp_nonce_field( $action, Router::NONCE ) ;
662
  }
663
 
664
  /**
@@ -667,12 +634,11 @@ class Admin_Display extends Base
667
  * @since 3.0
668
  * @access public
669
  */
670
- public function form_end( $disable_reset = false )
671
- {
672
- echo "<div class='litespeed-top20'></div>" ;
673
- submit_button( __( 'Save Changes', 'litespeed-cache' ), 'primary litespeed-duplicate-float', 'litespeed-submit' ) ;
674
 
675
- echo '</form>' ;
676
  }
677
 
678
  /**
@@ -681,9 +647,8 @@ class Admin_Display extends Base
681
  * @since 3.0
682
  * @access public
683
  */
684
- public function enroll( $id )
685
- {
686
- echo '<input type="hidden" name="' . Admin_Settings::ENROLL . '[]" value="' . $id . '" />' ;
687
  }
688
 
689
  /**
@@ -727,8 +692,7 @@ class Admin_Display extends Base
727
  * @since 1.1.0
728
  * @access public
729
  */
730
- public function build_input( $id, $cls = null, $val = null, $type = 'text', $disabled = false )
731
- {
732
  if ( $val === null ) {
733
  $val = Conf::val( $id, true );
734
 
@@ -764,25 +728,24 @@ class Admin_Display extends Base
764
  * @param string $title
765
  * @param bool $checked
766
  */
767
- public function build_checkbox( $id, $title, $checked = null, $value = 1 )
768
- {
769
  if ( $checked === null && Conf::val( $id, true ) ) {
770
  $checked = true;
771
  }
772
  $checked = $checked ? ' checked ' : '';
773
 
774
- $label_id = preg_replace( '|\W|', '', $id ) ;
775
 
776
  if ( $value !== 1 ) {
777
- $label_id .= '_' . $value ;
778
  }
779
 
780
- $this->enroll( $id ) ;
781
 
782
  echo "<div class='litespeed-tick'>
783
  <input type='checkbox' name='$id' id='input_checkbox_$label_id' value='$value' $checked />
784
  <label for='input_checkbox_$label_id'>$title</label>
785
- </div>" ;
786
 
787
  $this->_check_overwritten( $id );
788
  }
@@ -792,20 +755,19 @@ class Admin_Display extends Base
792
  *
793
  * @since 1.7
794
  */
795
- public function build_toggle( $id, $checked = null, $title_on = null, $title_off = null )
796
- {
797
  if ( $checked === null && Conf::val( $id, true ) ) {
798
- $checked = true ;
799
  }
800
 
801
  if ( $title_on === null ) {
802
- $title_on = __( 'ON', 'litespeed-cache' ) ;
803
- $title_off = __( 'OFF', 'litespeed-cache' ) ;
804
  }
805
 
806
- $cls = $checked ? 'primary' : 'default litespeed-toggleoff' ;
807
 
808
- $this->enroll( $id ) ;
809
 
810
  echo "<div class='litespeed-toggle litespeed-toggle-btn litespeed-toggle-btn-$cls' data-litespeed-toggle-on='primary' data-litespeed-toggle-off='default'>
811
  <input name='$id' type='hidden' value='$checked' />
@@ -814,7 +776,7 @@ class Admin_Display extends Base
814
  <label class='litespeed-toggle-btn litespeed-toggle-btn-default litespeed-toggle-active litespeed-toggle-off'>$title_off</label>
815
  <span class='litespeed-toggle-handle litespeed-toggle-btn litespeed-toggle-btn-default'></span>
816
  </div>
817
- </div>" ;
818
 
819
  $this->_check_overwritten( $id );
820
  }
@@ -826,8 +788,7 @@ class Admin_Display extends Base
826
  * @since 1.7 removed param $disable
827
  * @access public
828
  */
829
- public function build_switch( $id, $title_list = false )
830
- {
831
  $this->enroll( $id );
832
 
833
  echo '<div class="litespeed-switch">';
@@ -854,20 +815,19 @@ class Admin_Display extends Base
854
  * @since 1.1.0
855
  * @access private
856
  */
857
- private function _build_radio( $id, $val, $txt )
858
- {
859
- $id_attr = 'input_radio_' . preg_replace( '|\W|', '', $id ) . '_' . $val ;
860
 
861
  $default = isset( self::$_default_options[ $id ] ) ? self::$_default_options[ $id ] : self::$_default_site_options[ $id ];
862
 
863
  if ( ! is_string( $default ) ) {
864
- $checked = (int) Conf::val( $id, true ) === (int) $val ? ' checked ' : '' ;
865
  }
866
  else {
867
- $checked = Conf::val( $id, true ) === $val ? ' checked ' : '' ;
868
  }
869
 
870
- echo "<input type='radio' autocomplete='off' name='$id' id='$id_attr' value='$val' $checked /> <label for='$id_attr'>$txt</label>" ;
871
  }
872
 
873
  /**
@@ -913,10 +873,9 @@ class Admin_Display extends Base
913
  * @since 3.0
914
  * @access public
915
  */
916
- public function readable_seconds()
917
- {
918
- echo __( 'seconds', 'litespeed-cache' ) ;
919
- echo ' <span data-litespeed-readable=""></span>' ;
920
  }
921
 
922
  /**
@@ -924,28 +883,36 @@ class Admin_Display extends Base
924
  *
925
  * @since 1.1.1
926
  * @access public
927
- * @param string $id The setting tag
928
  */
929
- public function recommended( $id )
930
- {
931
  if ( ! $this->default_settings ) {
932
- $this->default_settings = $this->__cfg->load_default_vals() ;
933
  }
934
 
935
- $val = $this->default_settings[ $id ] ;
936
 
937
  if ( $val ) {
938
  if ( is_array( $val ) ) {
939
- $val = implode( "\n", $val ) ;
940
- $val = esc_textarea( $val ) ;
941
- $val = '<div class="litespeed-desc">'.__( 'Recommended value', 'litespeed-cache' ) . ':</div>'."<textarea readonly rows='5' cols='30'>$val</textarea>" ;
 
 
 
 
 
 
 
 
 
 
942
  }
943
  else {
944
- $val = esc_textarea( $val ) ;
945
- $val = "<code>$val</code>" ;
946
  $val = __( 'Recommended value', 'litespeed-cache' ) . ': '.$val;
947
  }
948
- echo $val ;
949
  }
950
  }
951
 
@@ -954,21 +921,20 @@ class Admin_Display extends Base
954
  *
955
  * @since 3.0
956
  */
957
- protected function _validate_syntax( $id )
958
- {
959
- $val = Conf::val( $id, true ) ;
960
 
961
  if ( ! $val ) {
962
- return ;
963
  }
964
 
965
  if ( ! is_array( $val ) ) {
966
- $val = array( $val ) ;
967
  }
968
 
969
  foreach ( $val as $v ) {
970
  if ( ! Utility::syntax_checker( $v ) ) {
971
- echo '<br /><font class="litespeed-warning"> ❌ ' . __( 'Invalid rewrite rule', 'litespeed-cache' ) . ': <code>' . $v . '</code></font>' ;
972
  }
973
  }
974
  }
@@ -978,8 +944,7 @@ class Admin_Display extends Base
978
  *
979
  * @since 3.0
980
  */
981
- protected function _validate_htaccess_path( $id )
982
- {
983
  $val = Conf::val( $id, true );
984
  if ( ! $val ) {
985
  return;
@@ -995,45 +960,44 @@ class Admin_Display extends Base
995
  *
996
  * @since 3.0
997
  */
998
- protected function _validate_ttl( $id, $min = false, $max = false, $allow_zero = false )
999
- {
1000
- $val = Conf::val( $id, true ) ;
1001
 
1002
  if ( $allow_zero && ! $val ) {
1003
- // return ;
1004
  }
1005
 
1006
- $tip = array() ;
1007
  if ( $min && $val < $min && ( ! $allow_zero || $val != 0 ) ) {
1008
- $tip[] = __( 'Minimum value', 'litespeed-cache' ) . ': <code>' . $min . '</code>.' ;
1009
  }
1010
  if ( $max && $val > $max ) {
1011
- $tip[] = __( 'Maximum value', 'litespeed-cache' ) . ': <code>' . $max . '</code>.' ;
1012
  }
1013
 
1014
- echo '<br />' ;
1015
 
1016
  if ( $tip ) {
1017
- echo '<font class="litespeed-warning"> ❌ ' . implode( ' ', $tip ) . '</font>' ;
1018
  }
1019
 
1020
- $range = '' ;
1021
 
1022
  if ( $allow_zero ) {
1023
- $range .= __( 'Zero, or', 'litespeed-cache' ) . ' ' ;
1024
  }
1025
 
1026
  if ( $min && $max ) {
1027
- $range .= $min . ' - ' . $max ;
1028
  }
1029
  elseif ( $min ) {
1030
- $range .= __( 'Larger than', 'litespeed-cache' ) . ' ' . $min ;
1031
  }
1032
  elseif ( $max ) {
1033
- $range .= __( 'Smaller than', 'litespeed-cache' ) . ' ' . $max ;
1034
  }
1035
 
1036
- echo __( 'Value range', 'litespeed-cache' ) . ': <code>' . $range . '</code>' ;
1037
  }
1038
 
1039
  /**
@@ -1041,30 +1005,29 @@ class Admin_Display extends Base
1041
  *
1042
  * @since 3.0
1043
  */
1044
- protected function _validate_ip( $id )
1045
- {
1046
- $val = Conf::val( $id, true ) ;
1047
  if ( ! $val ) {
1048
- return ;
1049
  }
1050
 
1051
  if ( ! is_array( $val ) ) {
1052
- $val = array( $val ) ;
1053
  }
1054
 
1055
- $tip = array() ;
1056
  foreach ( $val as $v ) {
1057
  if ( ! $v ) {
1058
- continue ;
1059
  }
1060
 
1061
  if ( ! \WP_Http::is_ip_address( $v ) ) {
1062
- $tip[] = __( 'Invalid IP', 'litespeed-cache' ) . ': <code>' . $v . '</code>.' ;
1063
  }
1064
  }
1065
 
1066
  if ( $tip ) {
1067
- echo '<br /><font class="litespeed-warning"> ❌ ' . implode( ' ', $tip ) . '</font>' ;
1068
  }
1069
  }
1070
 
@@ -1074,37 +1037,15 @@ class Admin_Display extends Base
1074
  * @since 1.8.3
1075
  * @access protected
1076
  */
1077
- protected function _api_env_var()
1078
- {
1079
- $args = func_get_args() ;
1080
- $s = '<code>' . implode( '</code>, <code>', $args ) . '</code>' ;
1081
 
1082
  echo '<font class="litespeed-success"> '
1083
  . __( 'API', 'litespeed-cache' ) . ': '
1084
- . sprintf( __( 'Server variable(s) %s available to override this setting.', 'litespeed-cache' ), $s ) ;
1085
-
1086
- $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#limiting-the-crawler' ) ;
1087
- }
1088
-
1089
- /**
1090
- * Display learn more link
1091
- *
1092
- * @since 2.6.1
1093
- * @access public
1094
- */
1095
- public function learn_more( $link, $title = false, $class = false, $self = false )
1096
- {
1097
- if ( $class ) {
1098
- $class = " class='$class' " ;
1099
- }
1100
-
1101
- if ( ! $title ) {
1102
- $title = __( 'Learn More', 'litespeed-cache' ) ;
1103
- }
1104
-
1105
- $self = $self ? '' : "target='_blank'";
1106
 
1107
- echo " <a href='$link' $self $class>$title</a>" ;
1108
  }
1109
 
1110
  /**
@@ -1113,15 +1054,14 @@ class Admin_Display extends Base
1113
  * @since 2.6.1
1114
  * @access protected
1115
  */
1116
- protected function _uri_usage_example()
1117
- {
1118
- echo __( 'The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache' ) ;
1119
- echo ' ' . sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' ) ;
1120
- echo '<br /><i>' ;
1121
- echo sprintf( __( 'To match the beginning, add %s to the beginning of the item.', 'litespeed-cache' ), '<code>^</code>' ) ;
1122
- echo ' ' . sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' ) ;
1123
- echo ' ' . __( 'One per line.', 'litespeed-cache' ) ;
1124
- echo '</i>' ;
1125
  }
1126
 
1127
  /**
@@ -1130,31 +1070,30 @@ class Admin_Display extends Base
1130
  * @since 2.0
1131
  * @access public
1132
  */
1133
- public static function print_plural( $num, $kind = 'group' )
1134
- {
1135
  if ( $num > 1 ) {
1136
  switch ( $kind ) {
1137
  case 'group' :
1138
- return sprintf( __( '%s groups', 'litespeed-cache' ), $num ) ;
1139
 
1140
  case 'image' :
1141
- return sprintf( __( '%s images', 'litespeed-cache' ), $num ) ;
1142
 
1143
  default:
1144
- return $num ;
1145
  }
1146
 
1147
  }
1148
 
1149
  switch ( $kind ) {
1150
  case 'group' :
1151
- return sprintf( __( '%s group', 'litespeed-cache' ), $num ) ;
1152
 
1153
  case 'image' :
1154
- return sprintf( __( '%s image', 'litespeed-cache' ), $num ) ;
1155
 
1156
  default:
1157
- return $num ;
1158
  }
1159
  }
1160
 
@@ -1164,30 +1103,29 @@ class Admin_Display extends Base
1164
  * @since 2.0
1165
  * @access public
1166
  */
1167
- public static function guidance( $title, $steps, $current_step )
1168
- {
1169
  if ( $current_step === 'done' ) {
1170
- $current_step = count( $steps ) + 1 ;
1171
  }
1172
 
1173
- $percentage = ' (' . floor( ( $current_step - 1 ) * 100 / count( $steps ) ) . '%)' ;
1174
 
1175
  $html = '<div class="litespeed-guide">'
1176
  . '<h2>' . $title . $percentage . '</h2>'
1177
- . '<ol>' ;
1178
  foreach ( $steps as $k => $v ) {
1179
- $step = $k + 1 ;
1180
  if ( $current_step > $step ) {
1181
- $html .= '<li class="litespeed-guide-done">' ;
1182
  }
1183
  else {
1184
- $html .= '<li>' ;
1185
  }
1186
- $html .= $v . '</li>' ;
1187
  }
1188
 
1189
- $html .= '</ol></div>' ;
1190
 
1191
- return $html ;
1192
  }
1193
  }
8
  * @subpackage LiteSpeed/admin
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
+ namespace LiteSpeed;
12
 
13
+ defined( 'WPINC' ) || exit;
14
 
15
+ class Admin_Display extends Base {
16
+ protected static $_instance;
 
17
 
18
+ const NOTICE_BLUE = 'notice notice-info';
19
+ const NOTICE_GREEN = 'notice notice-success';
20
+ const NOTICE_RED = 'notice notice-error';
21
+ const NOTICE_YELLOW = 'notice notice-warning';
22
+ const DB_MSG = 'messages';
23
 
24
+ const PURGEBY_CAT = '0';
25
+ const PURGEBY_PID = '1';
26
+ const PURGEBY_TAG = '2';
27
+ const PURGEBY_URL = '3';
28
 
29
+ const PURGEBYOPT_SELECT = 'purgeby';
30
+ const PURGEBYOPT_LIST = 'purgebylist';
31
 
32
+ const DB_DISMISS_MSG = 'dismiss';
33
+ const RULECONFLICT_ON = 'ExpiresDefault_1';
34
+ const RULECONFLICT_DISMISSED = 'ExpiresDefault_0';
35
 
36
+ protected $__cfg;
37
+ protected $messages = array();
38
+ protected $default_settings = array();
39
  protected $_is_network_admin = false;
40
  protected $_is_multisite = false;
41
 
45
  * @since 1.0.7
46
  * @access protected
47
  */
48
+ protected function __construct() {
 
49
  // load assets
50
  if( ! empty( $_GET[ 'page' ] ) && ( strpos( $_GET[ 'page' ], 'litespeed-' ) === 0 || $_GET[ 'page' ] == 'litespeed' ) ) {
51
+ add_action( 'admin_enqueue_scripts', array( $this, 'load_assets' ) );
52
  }
53
 
54
  // main css
55
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ) );
56
  // Main js
57
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
58
 
59
+ $this->_is_network_admin = is_network_admin();
60
+ $this->_is_multisite = is_multisite();
61
 
62
  // Quick access menu
63
  if ( is_multisite() && $this->_is_network_admin ) {
64
+ $manage = 'manage_network_options';
65
  }
66
  else {
67
+ $manage = 'manage_options';
68
  }
69
  if ( current_user_can( $manage ) ) {
70
  if ( ! defined( 'LITESPEED_DISABLE_ALL' ) ) {
71
+ add_action( 'wp_before_admin_bar_render', array( GUI::get_instance(), 'backend_shortcut' ) );
72
  }
73
 
74
  // `admin_notices` is after `admin_enqueue_scripts`
75
  // @see wp-admin/admin-header.php
76
+ add_action( $this->_is_network_admin ? 'network_admin_notices' : 'admin_notices', array( $this, 'display_messages' ) );
77
  }
78
 
79
  /**
82
  * @since 2.0
83
  */
84
  if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
85
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
86
  }
87
 
88
  // add menus ( Also check for mu-plugins)
89
  if ( $this->_is_network_admin && ( is_plugin_active_for_network( LSCWP_BASENAME ) || defined( 'LSCWP_MU_PLUGIN' ) ) ) {
90
+ add_action( 'network_admin_menu', array( $this, 'register_admin_menu' ) );
91
  }
92
  else {
93
+ add_action( 'admin_menu', array( $this, 'register_admin_menu' ) );
94
  }
95
 
96
+ $this->__cfg = Conf::get_instance();
97
  }
98
 
99
  /**
103
  * @access public
104
  * @param array $hook WP hook
105
  */
106
+ public function load_assets($hook) {
 
107
  // Admin footer
108
+ add_filter('admin_footer_text', array($this, 'admin_footer_text'), 1);
109
 
110
  if( defined( 'LITESPEED_ON' ) ) {
111
  // Help tab
112
+ $this->add_help_tabs();
113
 
114
+ global $pagenow;
115
  if ( $pagenow === 'plugins.php' ) {//todo: check if work
116
+ add_action('wp_default_scripts', array($this, 'set_update_text'), 0);
117
+ add_action('wp_default_scripts', array($this, 'unset_update_text'), 20);
118
  }
119
  }
120
 
121
+ wp_register_script( Core::PLUGIN_NAME . '-lib-vue', LSWCP_PLUGIN_URL . 'assets/js/vue.min.js', array(), Core::VER, false );
122
+ wp_enqueue_script( Core::PLUGIN_NAME . '-lib-vue' );
123
  }
124
 
125
  /**
128
  * @since 3.0
129
  * @access public
130
  */
131
+ public function title( $id ) {
132
+ echo Lang::title( $id );
 
133
  }
134
 
135
  /**
138
  * @since 1.0.0
139
  * @access public
140
  */
141
+ public function register_admin_menu() {
 
142
  $capability = $this->_is_network_admin ? 'manage_network_options' : 'manage_options';
143
  if ( current_user_can( $capability ) ) {
144
 
178
  * @param string $menu_slug The slug of the page.
179
  * @param string $callback The callback to call if selected.
180
  */
181
+ private function _add_submenu( $menu_title, $menu_slug, $callback ) {
 
182
  add_submenu_page( 'litespeed', $menu_title, $menu_title, 'manage_options', $menu_slug, array( $this, $callback ) );
183
  }
184
 
188
  * @since 1.0.14
189
  * @access public
190
  */
191
+ public function enqueue_style() {
192
+ wp_enqueue_style(Core::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'assets/css/litespeed.css', array(), Core::VER, 'all');
 
193
  }
194
 
195
  /**
218
  $localize_data[ 'ajax_url_promo' ] = $ajax_url_promo;
219
  }
220
 
221
+ // If on Server IP setting page, append getIP link
222
  global $pagenow;
223
+ if ( $pagenow == 'admin.php' && ! empty( $_GET[ 'page' ] ) && $_GET[ 'page' ] == 'litespeed-general' ) {
224
  $localize_data[ 'ajax_url_getIP' ] = function_exists( 'get_rest_url' ) ? get_rest_url( null, 'litespeed/v1/tool/check_ip' ) : '/';
225
  $localize_data[ 'nonce' ] = wp_create_nonce( 'wp_rest' );
226
  }
246
  * @param array $links Previously added links from other plugins.
247
  * @return array Links array with the litespeed cache one appended.
248
  */
249
+ public function add_plugin_links($links) {
 
250
  // $links[] = '<a href="' . admin_url('options-general.php?page=litespeed-cache') . '">' . __('Settings', 'litespeed-cache') . '</a>';
251
  $links[] = '<a href="' . admin_url('admin.php?page=litespeed-cache') . '">' . __('Settings', 'litespeed-cache') . '</a>';
252
 
262
  * @param string $text
263
  * @return string
264
  */
265
+ public function add_update_text($translations, $text) {
 
266
  if ( $text !== 'Updated!' ) {
267
  return $translations;
268
  }
276
  * @since 1.0.8.1
277
  * @access public
278
  */
279
+ public function set_update_text() {
 
280
  add_filter('gettext', array($this, 'add_update_text'), 10, 2);
281
  }
282
 
286
  * @since 1.0.8.1
287
  * @access public
288
  */
289
+ public function unset_update_text() {
 
290
  remove_filter('gettext', array($this, 'add_update_text'));
291
  }
292
 
297
  * @param string $footer_text
298
  * @return string
299
  */
300
+ public function admin_footer_text($footer_text) {
301
+ require_once LSCWP_DIR . 'tpl/inc/admin_footer.php';
 
302
 
303
+ return $footer_text;
304
  }
305
 
306
  /**
309
  * @since 1.0.0
310
  * @access public
311
  */
312
+ public function add_help_tabs() {
313
+ require_once LSCWP_DIR . 'tpl/inc/help_tabs.php';
 
314
  }
315
 
316
  /**
322
  * @param string $str The notice message.
323
  * @return string The built notice html.
324
  */
325
+ public static function build_notice($color, $str) {
326
+ return '<div class="' . $color . ' is-dismissible"><p>'. $str . '</p></div>';
 
327
  }
328
 
329
  /**
332
  * @since 1.6.5
333
  * @access public
334
  */
335
+ public static function info( $msg, $echo = false ) {
 
336
  self::add_notice( self::NOTICE_BLUE, $msg, $echo );
337
  }
338
 
342
  * @since 1.6.5
343
  * @access public
344
  */
345
+ public static function note( $msg, $echo = false ) {
 
346
  self::add_notice( self::NOTICE_YELLOW, $msg, $echo );
347
  }
348
 
352
  * @since 1.6
353
  * @access public
354
  */
355
+ public static function succeed( $msg, $echo = false ) {
 
356
  self::add_notice( self::NOTICE_GREEN, $msg, $echo );
357
  }
358
 
362
  * @since 1.6
363
  * @access public
364
  */
365
+ public static function error( $msg, $echo = false ) {
 
366
  self::add_notice( self::NOTICE_RED, $msg, $echo );
367
  }
368
 
372
  * @since 1.0.7
373
  * @access public
374
  */
375
+ public static function add_notice( $color, $msg, $echo = false ) {
 
376
  // Bypass adding for CLI or cron
377
  if ( defined( 'LITESPEED_CLI' ) || defined( 'DOING_CRON' ) ) {
378
  // WP CLI will show the info directly
476
  * @since 1.1.0
477
  * @access public
478
  */
479
+ public function show_widget_edit($widget, $return, $instance) {
 
480
  require LSCWP_DIR . 'tpl/esi_widget_edit.php';
481
  }
482
 
486
  * @since 3.0
487
  * @access public
488
  */
489
+ public function show_menu_dash() {
490
+ require_once LSCWP_DIR . 'tpl/dash/entry.tpl.php';
 
491
  }
492
 
493
  /**
496
  * @since 3.0
497
  * @access public
498
  */
499
+ public function show_menu_general() {
500
+ require_once LSCWP_DIR . 'tpl/general/entry.tpl.php';
 
501
  }
502
 
503
  /**
506
  * @since 3.0
507
  * @access public
508
  */
509
+ public function show_menu_cdn() {
510
+ require_once LSCWP_DIR . 'tpl/cdn/entry.tpl.php';
 
511
  }
512
 
513
  /**
516
  * @since 1.0.0
517
  * @access public
518
  */
519
+ public function show_menu_cache() {
 
520
  if ( $this->_is_network_admin ) {
521
+ require_once LSCWP_DIR . 'tpl/cache/entry_network.tpl.php';
522
  }
523
  else {
524
+ require_once LSCWP_DIR . 'tpl/cache/entry.tpl.php';
525
  }
526
  }
527
 
531
  * @since 3.0
532
  * @access public
533
  */
534
+ public function show_toolbox() {
535
+ require_once LSCWP_DIR . 'tpl/toolbox/entry.tpl.php';
 
536
  }
537
 
538
  /**
541
  * @since 1.1.0
542
  * @access public
543
  */
544
+ public function show_crawler() {
545
+ require_once LSCWP_DIR . 'tpl/crawler/entry.tpl.php';
 
546
  }
547
 
548
  /**
551
  * @since 1.6
552
  * @access public
553
  */
554
+ public function show_img_optm() {
555
+ require_once LSCWP_DIR . 'tpl/img_optm/entry.tpl.php';
 
556
  }
557
 
558
  /**
561
  * @since 3.0
562
  * @access public
563
  */
564
+ public function show_page_optm() {
565
+ require_once LSCWP_DIR . 'tpl/page_optm/entry.tpl.php';
 
566
  }
567
 
568
  /**
571
  * @since 3.0
572
  * @access public
573
  */
574
+ public function show_db_optm() {
575
+ require_once LSCWP_DIR . 'tpl/db_optm/entry.tpl.php';
 
576
  }
577
 
578
  /**
582
  * @since 1.0.12
583
  * @access public
584
  */
585
+ public function show_display_installed() {
586
+ require_once LSCWP_DIR . 'tpl/inc/show_display_installed.php';
 
587
  }
588
 
589
  /**
592
  * @since 1.0.12
593
  * @access public
594
  */
595
+ public static function show_error_cookie() {
596
+ require_once LSCWP_DIR . 'tpl/inc/show_error_cookie.php';
 
597
  }
598
 
599
  /**
602
  * @since 2.1
603
  * @access public
604
  */
605
+ public function cache_disabled_warning() {
606
+ include LSCWP_DIR . "tpl/inc/check_cache_disabled.php";
 
607
  }
608
 
609
  /**
612
  * @since 3.0
613
  * @access public
614
  */
615
+ public function form_action( $action = false, $type = false, $has_upload = false ) {
 
616
  if ( ! $action ) {
617
  $action = Router::ACTION_SAVE_SETTINGS;
618
  }
619
 
620
+ $has_upload = $has_upload ? 'enctype="multipart/form-data"' : '';
621
 
622
+ echo '<form method="post" action="' . wp_unslash( $_SERVER[ 'REQUEST_URI' ] ) . '" class="litespeed-relative" ' . $has_upload . '>';
623
 
624
+ echo '<input type="hidden" name="' . Router::ACTION . '" value="' . $action . '" />';
625
  if ( $type ) {
626
+ echo '<input type="hidden" name="' . Router::TYPE . '" value="' . $type . '" />';
627
  }
628
+ wp_nonce_field( $action, Router::NONCE );
629
  }
630
 
631
  /**
634
  * @since 3.0
635
  * @access public
636
  */
637
+ public function form_end( $disable_reset = false ) {
638
+ echo "<div class='litespeed-top20'></div>";
639
+ submit_button( __( 'Save Changes', 'litespeed-cache' ), 'primary litespeed-duplicate-float', 'litespeed-submit' );
 
640
 
641
+ echo '</form>';
642
  }
643
 
644
  /**
647
  * @since 3.0
648
  * @access public
649
  */
650
+ public function enroll( $id ) {
651
+ echo '<input type="hidden" name="' . Admin_Settings::ENROLL . '[]" value="' . $id . '" />';
 
652
  }
653
 
654
  /**
692
  * @since 1.1.0
693
  * @access public
694
  */
695
+ public function build_input( $id, $cls = null, $val = null, $type = 'text', $disabled = false ) {
 
696
  if ( $val === null ) {
697
  $val = Conf::val( $id, true );
698
 
728
  * @param string $title
729
  * @param bool $checked
730
  */
731
+ public function build_checkbox( $id, $title, $checked = null, $value = 1 ) {
 
732
  if ( $checked === null && Conf::val( $id, true ) ) {
733
  $checked = true;
734
  }
735
  $checked = $checked ? ' checked ' : '';
736
 
737
+ $label_id = preg_replace( '|\W|', '', $id );
738
 
739
  if ( $value !== 1 ) {
740
+ $label_id .= '_' . $value;
741
  }
742
 
743
+ $this->enroll( $id );
744
 
745
  echo "<div class='litespeed-tick'>
746
  <input type='checkbox' name='$id' id='input_checkbox_$label_id' value='$value' $checked />
747
  <label for='input_checkbox_$label_id'>$title</label>
748
+ </div>";
749
 
750
  $this->_check_overwritten( $id );
751
  }
755
  *
756
  * @since 1.7
757
  */
758
+ public function build_toggle( $id, $checked = null, $title_on = null, $title_off = null ) {
 
759
  if ( $checked === null && Conf::val( $id, true ) ) {
760
+ $checked = true;
761
  }
762
 
763
  if ( $title_on === null ) {
764
+ $title_on = __( 'ON', 'litespeed-cache' );
765
+ $title_off = __( 'OFF', 'litespeed-cache' );
766
  }
767
 
768
+ $cls = $checked ? 'primary' : 'default litespeed-toggleoff';
769
 
770
+ $this->enroll( $id );
771
 
772
  echo "<div class='litespeed-toggle litespeed-toggle-btn litespeed-toggle-btn-$cls' data-litespeed-toggle-on='primary' data-litespeed-toggle-off='default'>
773
  <input name='$id' type='hidden' value='$checked' />
776
  <label class='litespeed-toggle-btn litespeed-toggle-btn-default litespeed-toggle-active litespeed-toggle-off'>$title_off</label>
777
  <span class='litespeed-toggle-handle litespeed-toggle-btn litespeed-toggle-btn-default'></span>
778
  </div>
779
+ </div>";
780
 
781
  $this->_check_overwritten( $id );
782
  }
788
  * @since 1.7 removed param $disable
789
  * @access public
790
  */
791
+ public function build_switch( $id, $title_list = false ) {
 
792
  $this->enroll( $id );
793
 
794
  echo '<div class="litespeed-switch">';
815
  * @since 1.1.0
816
  * @access private
817
  */
818
+ private function _build_radio( $id, $val, $txt ) {
819
+ $id_attr = 'input_radio_' . preg_replace( '|\W|', '', $id ) . '_' . $val;
 
820
 
821
  $default = isset( self::$_default_options[ $id ] ) ? self::$_default_options[ $id ] : self::$_default_site_options[ $id ];
822
 
823
  if ( ! is_string( $default ) ) {
824
+ $checked = (int) Conf::val( $id, true ) === (int) $val ? ' checked ' : '';
825
  }
826
  else {
827
+ $checked = Conf::val( $id, true ) === $val ? ' checked ' : '';
828
  }
829
 
830
+ echo "<input type='radio' autocomplete='off' name='$id' id='$id_attr' value='$val' $checked /> <label for='$id_attr'>$txt</label>";
831
  }
832
 
833
  /**
873
  * @since 3.0
874
  * @access public
875
  */
876
+ public function readable_seconds() {
877
+ echo __( 'seconds', 'litespeed-cache' );
878
+ echo ' <span data-litespeed-readable=""></span>';
 
879
  }
880
 
881
  /**
883
  *
884
  * @since 1.1.1
885
  * @access public
 
886
  */
887
+ public function recommended( $id ) {
 
888
  if ( ! $this->default_settings ) {
889
+ $this->default_settings = $this->__cfg->load_default_vals();
890
  }
891
 
892
+ $val = $this->default_settings[ $id ];
893
 
894
  if ( $val ) {
895
  if ( is_array( $val ) ) {
896
+ $rows = 5;
897
+ $cols = 30;
898
+ // Flexible rows/cols
899
+ $lines = count( $val ) + 1;
900
+ $rows = min( max( $lines, $rows ), 40 );
901
+ foreach ( $val as $v ) {
902
+ $cols = max( strlen( $v ), $cols );
903
+ }
904
+ $cols = min( $cols, 150 );
905
+
906
+ $val = implode( "\n", $val );
907
+ $val = esc_textarea( $val );
908
+ $val = '<div class="litespeed-desc">' . __( 'Recommended value', 'litespeed-cache' ) . ':</div>' . "<textarea readonly rows='$rows' cols='$cols'>$val</textarea>";
909
  }
910
  else {
911
+ $val = esc_textarea( $val );
912
+ $val = "<code>$val</code>";
913
  $val = __( 'Recommended value', 'litespeed-cache' ) . ': '.$val;
914
  }
915
+ echo $val;
916
  }
917
  }
918
 
921
  *
922
  * @since 3.0
923
  */
924
+ protected function _validate_syntax( $id ) {
925
+ $val = Conf::val( $id, true );
 
926
 
927
  if ( ! $val ) {
928
+ return;
929
  }
930
 
931
  if ( ! is_array( $val ) ) {
932
+ $val = array( $val );
933
  }
934
 
935
  foreach ( $val as $v ) {
936
  if ( ! Utility::syntax_checker( $v ) ) {
937
+ echo '<br /><font class="litespeed-warning"> ❌ ' . __( 'Invalid rewrite rule', 'litespeed-cache' ) . ': <code>' . $v . '</code></font>';
938
  }
939
  }
940
  }
944
  *
945
  * @since 3.0
946
  */
947
+ protected function _validate_htaccess_path( $id ) {
 
948
  $val = Conf::val( $id, true );
949
  if ( ! $val ) {
950
  return;
960
  *
961
  * @since 3.0
962
  */
963
+ protected function _validate_ttl( $id, $min = false, $max = false, $allow_zero = false ) {
964
+ $val = Conf::val( $id, true );
 
965
 
966
  if ( $allow_zero && ! $val ) {
967
+ // return;
968
  }
969
 
970
+ $tip = array();
971
  if ( $min && $val < $min && ( ! $allow_zero || $val != 0 ) ) {
972
+ $tip[] = __( 'Minimum value', 'litespeed-cache' ) . ': <code>' . $min . '</code>.';
973
  }
974
  if ( $max && $val > $max ) {
975
+ $tip[] = __( 'Maximum value', 'litespeed-cache' ) . ': <code>' . $max . '</code>.';
976
  }
977
 
978
+ echo '<br />';
979
 
980
  if ( $tip ) {
981
+ echo '<font class="litespeed-warning"> ❌ ' . implode( ' ', $tip ) . '</font>';
982
  }
983
 
984
+ $range = '';
985
 
986
  if ( $allow_zero ) {
987
+ $range .= __( 'Zero, or', 'litespeed-cache' ) . ' ';
988
  }
989
 
990
  if ( $min && $max ) {
991
+ $range .= $min . ' - ' . $max;
992
  }
993
  elseif ( $min ) {
994
+ $range .= __( 'Larger than', 'litespeed-cache' ) . ' ' . $min;
995
  }
996
  elseif ( $max ) {
997
+ $range .= __( 'Smaller than', 'litespeed-cache' ) . ' ' . $max;
998
  }
999
 
1000
+ echo __( 'Value range', 'litespeed-cache' ) . ': <code>' . $range . '</code>';
1001
  }
1002
 
1003
  /**
1005
  *
1006
  * @since 3.0
1007
  */
1008
+ protected function _validate_ip( $id ) {
1009
+ $val = Conf::val( $id, true );
 
1010
  if ( ! $val ) {
1011
+ return;
1012
  }
1013
 
1014
  if ( ! is_array( $val ) ) {
1015
+ $val = array( $val );
1016
  }
1017
 
1018
+ $tip = array();
1019
  foreach ( $val as $v ) {
1020
  if ( ! $v ) {
1021
+ continue;
1022
  }
1023
 
1024
  if ( ! \WP_Http::is_ip_address( $v ) ) {
1025
+ $tip[] = __( 'Invalid IP', 'litespeed-cache' ) . ': <code>' . $v . '</code>.';
1026
  }
1027
  }
1028
 
1029
  if ( $tip ) {
1030
+ echo '<br /><font class="litespeed-warning"> ❌ ' . implode( ' ', $tip ) . '</font>';
1031
  }
1032
  }
1033
 
1037
  * @since 1.8.3
1038
  * @access protected
1039
  */
1040
+ protected function _api_env_var() {
1041
+ $args = func_get_args();
1042
+ $s = '<code>' . implode( '</code>, <code>', $args ) . '</code>';
 
1043
 
1044
  echo '<font class="litespeed-success"> '
1045
  . __( 'API', 'litespeed-cache' ) . ': '
1046
+ . sprintf( __( 'Server variable(s) %s available to override this setting.', 'litespeed-cache' ), $s );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1047
 
1048
+ Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#limiting-the-crawler' );
1049
  }
1050
 
1051
  /**
1054
  * @since 2.6.1
1055
  * @access protected
1056
  */
1057
+ protected function _uri_usage_example() {
1058
+ echo __( 'The URLs will be compared to the REQUEST_URI server variable.', 'litespeed-cache' );
1059
+ echo ' ' . sprintf( __( 'For example, for %s, %s can be used here.', 'litespeed-cache' ), '<code>/mypath/mypage?aa=bb</code>', '<code>mypage?aa=</code>' );
1060
+ echo '<br /><i>';
1061
+ echo sprintf( __( 'To match the beginning, add %s to the beginning of the item.', 'litespeed-cache' ), '<code>^</code>' );
1062
+ echo ' ' . sprintf( __( 'To do an exact match, add %s to the end of the URL.', 'litespeed-cache' ), '<code>$</code>' );
1063
+ echo ' ' . __( 'One per line.', 'litespeed-cache' );
1064
+ echo '</i>';
 
1065
  }
1066
 
1067
  /**
1070
  * @since 2.0
1071
  * @access public
1072
  */
1073
+ public static function print_plural( $num, $kind = 'group' ) {
 
1074
  if ( $num > 1 ) {
1075
  switch ( $kind ) {
1076
  case 'group' :
1077
+ return sprintf( __( '%s groups', 'litespeed-cache' ), $num );
1078
 
1079
  case 'image' :
1080
+ return sprintf( __( '%s images', 'litespeed-cache' ), $num );
1081
 
1082
  default:
1083
+ return $num;
1084
  }
1085
 
1086
  }
1087
 
1088
  switch ( $kind ) {
1089
  case 'group' :
1090
+ return sprintf( __( '%s group', 'litespeed-cache' ), $num );
1091
 
1092
  case 'image' :
1093
+ return sprintf( __( '%s image', 'litespeed-cache' ), $num );
1094
 
1095
  default:
1096
+ return $num;
1097
  }
1098
  }
1099
 
1103
  * @since 2.0
1104
  * @access public
1105
  */
1106
+ public static function guidance( $title, $steps, $current_step ) {
 
1107
  if ( $current_step === 'done' ) {
1108
+ $current_step = count( $steps ) + 1;
1109
  }
1110
 
1111
+ $percentage = ' (' . floor( ( $current_step - 1 ) * 100 / count( $steps ) ) . '%)';
1112
 
1113
  $html = '<div class="litespeed-guide">'
1114
  . '<h2>' . $title . $percentage . '</h2>'
1115
+ . '<ol>';
1116
  foreach ( $steps as $k => $v ) {
1117
+ $step = $k + 1;
1118
  if ( $current_step > $step ) {
1119
+ $html .= '<li class="litespeed-guide-done">';
1120
  }
1121
  else {
1122
+ $html .= '<li>';
1123
  }
1124
+ $html .= $v . '</li>';
1125
  }
1126
 
1127
+ $html .= '</ol></div>';
1128
 
1129
+ return $html;
1130
  }
1131
  }
src/admin-settings.cls.php CHANGED
@@ -206,19 +206,6 @@ class Admin_Settings extends Base
206
  $data = $data2;
207
  break;
208
 
209
- // `Original URLs`
210
- case self::O_CDN_ORI:
211
- $data = Utility::sanitize_lines( $data );
212
- // Trip scheme
213
- foreach ( $data as $k => $v ) {
214
- $tmp = parse_url( trim( $v ) );
215
- if ( ! empty( $tmp[ 'scheme' ] ) ) {
216
- $v = str_replace( $tmp[ 'scheme' ] . ':', '', $v );
217
- }
218
- $data[ $k ] = trim( $v );
219
- }
220
- break;
221
-
222
  // `Sitemap Generation` -> `Exclude Custom Post Types`
223
  case self::O_CRAWLER_EXC_CPT:
224
  if ( $data ) {
206
  $data = $data2;
207
  break;
208
 
 
 
 
 
 
 
 
 
 
 
 
 
 
209
  // `Sitemap Generation` -> `Exclude Custom Post Types`
210
  case self::O_CRAWLER_EXC_CPT:
211
  if ( $data ) {
src/base.cls.php CHANGED
@@ -7,9 +7,9 @@
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
- namespace LiteSpeed ;
11
 
12
- defined( 'WPINC' ) || exit ;
13
 
14
  class Base extends Instance {
15
  protected static $_instance;
@@ -132,162 +132,165 @@ class Base extends Instance {
132
  const O_OPTM_CSS_EXC = 'optm-css_exc';
133
  const O_OPTM_JS_MIN = 'optm-js_min';
134
  const O_OPTM_JS_INLINE_MIN = 'optm-js_inline_min';
135
- const O_OPTM_JS_COMB = 'optm-js_comb' ;
136
- const O_OPTM_JS_COMB_PRIO = 'optm-js_comb_priority' ;
137
- const O_OPTM_JS_HTTP2 = 'optm-js_http2' ;
138
- const O_OPTM_JS_EXC = 'optm-js_exc' ;
139
- const O_OPTM_TTL = 'optm-ttl' ;
140
- const O_OPTM_HTML_MIN = 'optm-html_min' ;
141
- const O_OPTM_QS_RM = 'optm-qs_rm' ;
142
- const O_OPTM_GGFONTS_RM = 'optm-ggfonts_rm' ;
143
- const O_OPTM_CSS_ASYNC = 'optm-css_async' ;
144
- const O_OPTM_CCSS_GEN = 'optm-ccss_gen' ;
145
- const O_OPTM_CCSS_ASYNC = 'optm-ccss_async' ;
146
- const O_OPTM_CSS_ASYNC_INLINE = 'optm-css_async_inline' ;
147
- const O_OPTM_CSS_FONT_DISPLAY = 'optm-css_font_display' ;
148
- const O_OPTM_JS_DEFER = 'optm-js_defer' ;
149
- const O_OPTM_JS_INLINE_DEFER = 'optm-js_inline_defer' ;
150
- const O_OPTM_EMOJI_RM = 'optm-emoji_rm' ;
151
- const O_OPTM_EXC_JQ = 'optm-exc_jq' ;
152
- const O_OPTM_GGFONTS_ASYNC = 'optm-ggfonts_async' ;
153
- const O_OPTM_MAX_SIZE = 'optm-max_size' ;
154
- const O_OPTM_RM_COMMENT = 'optm-rm_comment' ;
155
- const O_OPTM_EXC_ROLES = 'optm-exc_roles' ;
156
- const O_OPTM_CCSS_CON = 'optm-ccss_con' ;
157
- const O_OPTM_JS_DEFER_EXC = 'optm-js_defer_exc' ;
158
- const O_OPTM_DNS_PREFETCH = 'optm-dns_prefetch' ;
159
- const O_OPTM_DNS_PREFETCH_CTRL = 'optm-dns_prefetch_ctrl' ;
160
- const O_OPTM_EXC = 'optm-exc' ;
161
- const O_OPTM_CCSS_SEP_POSTTYPE = 'optm-ccss_sep_posttype' ;
162
- const O_OPTM_CCSS_SEP_URI = 'optm-ccss_sep_uri' ;
 
 
 
163
 
164
  ## -------------------------------------------------- ##
165
  ## -------------- Object Cache ----------------- ##
166
  ## -------------------------------------------------- ##
167
- const O_OBJECT = 'object' ;
168
- const O_OBJECT_KIND = 'object-kind' ;
169
- const O_OBJECT_HOST = 'object-host' ;
170
- const O_OBJECT_PORT = 'object-port' ;
171
- const O_OBJECT_LIFE = 'object-life' ;
172
- const O_OBJECT_PERSISTENT = 'object-persistent' ;
173
- const O_OBJECT_ADMIN = 'object-admin' ;
174
- const O_OBJECT_TRANSIENTS = 'object-transients' ;
175
- const O_OBJECT_DB_ID = 'object-db_id' ;
176
- const O_OBJECT_USER = 'object-user' ;
177
- const O_OBJECT_PSWD = 'object-pswd' ;
178
- const O_OBJECT_GLOBAL_GROUPS = 'object-global_groups' ;
179
- const O_OBJECT_NON_PERSISTENT_GROUPS = 'object-non_persistent_groups' ;
180
 
181
  ## -------------------------------------------------- ##
182
  ## -------------- Discussion ----------------- ##
183
  ## -------------------------------------------------- ##
184
- const O_DISCUSS_AVATAR_CACHE = 'discuss-avatar_cache' ;
185
- const O_DISCUSS_AVATAR_CRON = 'discuss-avatar_cron' ;
186
- const O_DISCUSS_AVATAR_CACHE_TTL = 'discuss-avatar_cache_ttl' ;
187
 
188
  ## -------------------------------------------------- ##
189
  ## -------------- Media ----------------- ##
190
  ## -------------------------------------------------- ##
191
- const O_MEDIA_LAZY = 'media-lazy' ;
192
- const O_MEDIA_LAZY_PLACEHOLDER = 'media-lazy_placeholder' ;
193
- const O_MEDIA_PLACEHOLDER_RESP = 'media-placeholder_resp' ;
194
- const O_MEDIA_PLACEHOLDER_RESP_COLOR = 'media-placeholder_resp_color' ;
195
- const O_MEDIA_PLACEHOLDER_RESP_SVG = 'media-placeholder_resp_svg' ;
196
- const O_MEDIA_LQIP = 'media-lqip' ;
197
- const O_MEDIA_LQIP_QUAL = 'media-lqip_qual' ;
198
  const O_MEDIA_LQIP_MIN_W = 'media-lqip_min_w';
199
  const O_MEDIA_LQIP_MIN_H = 'media-lqip_min_h';
200
- const O_MEDIA_PLACEHOLDER_RESP_ASYNC = 'media-placeholder_resp_async' ;
201
- const O_MEDIA_IFRAME_LAZY = 'media-iframe_lazy' ;
202
- const O_MEDIA_LAZYJS_INLINE = 'media-lazyjs_inline' ;
203
- const O_MEDIA_LAZY_EXC = 'media-lazy_exc' ;
204
- const O_MEDIA_LAZY_CLS_EXC = 'media-lazy_cls_exc' ;
205
- const O_MEDIA_LAZY_PARENT_CLS_EXC = 'media-lazy_parent_cls_exc' ;
206
- const O_MEDIA_IFRAME_LAZY_CLS_EXC = 'media-iframe_lazy_cls_exc' ;
207
- const O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC = 'media-iframe_lazy_parent_cls_exc' ;
208
- const O_MEDIA_LAZY_URI_EXC = 'media-lazy_uri_exc' ;
209
 
210
  ## -------------------------------------------------- ##
211
  ## -------------- Image Optm ----------------- ##
212
  ## -------------------------------------------------- ##
213
- const O_IMG_OPTM_AUTO = 'img_optm-auto' ;
214
- const O_IMG_OPTM_CRON = 'img_optm-cron' ;
215
- const O_IMG_OPTM_ORI = 'img_optm-ori' ;
216
- const O_IMG_OPTM_RM_BKUP = 'img_optm-rm_bkup' ;
217
- const O_IMG_OPTM_WEBP = 'img_optm-webp' ;
218
- const O_IMG_OPTM_LOSSLESS = 'img_optm-lossless' ;
219
- const O_IMG_OPTM_EXIF = 'img_optm-exif' ;
220
- const O_IMG_OPTM_WEBP_REPLACE = 'img_optm-webp_replace' ;
221
- const O_IMG_OPTM_WEBP_ATTR = 'img_optm-webp_attr' ;
222
- const O_IMG_OPTM_WEBP_REPLACE_SRCSET = 'img_optm-webp_replace_srcset' ;
223
- const O_IMG_OPTM_JPG_QUALITY = 'img_optm-jpg_quality' ;
224
 
225
  ## -------------------------------------------------- ##
226
  ## -------------- Crawler ----------------- ##
227
  ## -------------------------------------------------- ##
228
- const O_CRAWLER = 'crawler' ;
229
- const O_CRAWLER_POSTS = 'crawler-inc_posts' ;
230
- const O_CRAWLER_PAGES = 'crawler-inc_pages' ;
231
- const O_CRAWLER_CATS = 'crawler-inc_cats' ;
232
- const O_CRAWLER_TAGS = 'crawler-inc_tags' ;
233
- const O_CRAWLER_EXC_CPT = 'crawler-exc_cpt' ;
234
- const O_CRAWLER_ORDER_LINKS = 'crawler-order_links' ;
235
- const O_CRAWLER_USLEEP = 'crawler-usleep' ;
236
- const O_CRAWLER_RUN_DURATION = 'crawler-run_duration' ;
237
- const O_CRAWLER_RUN_INTERVAL = 'crawler-run_interval' ;
238
- const O_CRAWLER_CRAWL_INTERVAL = 'crawler-crawl_interval' ;
239
- const O_CRAWLER_THREADS = 'crawler-threads' ;
240
- const O_CRAWLER_TIMEOUT = 'crawler-timeout' ;
241
- const O_CRAWLER_LOAD_LIMIT = 'crawler-load_limit' ;
242
  const O_CRAWLER_SITEMAP = 'crawler-sitemap';
243
  const O_CRAWLER_DROP_DOMAIN = 'crawler-drop_domain';
244
  const O_CRAWLER_MAP_TIMEOUT = 'crawler-map_timeout';
245
- const O_CRAWLER_ROLES = 'crawler-roles' ;
246
- const O_CRAWLER_COOKIES = 'crawler-cookies' ;
247
 
248
  ## -------------------------------------------------- ##
249
  ## -------------- Misc ----------------- ##
250
  ## -------------------------------------------------- ##
251
- const O_MISC_HTACCESS_FRONT = 'misc-htaccess_front' ;
252
- const O_MISC_HTACCESS_BACK = 'misc-htaccess_back' ;
253
- const O_MISC_HEARTBEAT_FRONT = 'misc-heartbeat_front' ;
254
- const O_MISC_HEARTBEAT_FRONT_TTL = 'misc-heartbeat_front_ttl' ;
255
- const O_MISC_HEARTBEAT_BACK = 'misc-heartbeat_back' ;
256
- const O_MISC_HEARTBEAT_BACK_TTL = 'misc-heartbeat_back_ttl' ;
257
- const O_MISC_HEARTBEAT_EDITOR = 'misc-heartbeat_editor' ;
258
- const O_MISC_HEARTBEAT_EDITOR_TTL = 'misc-heartbeat_editor_ttl' ;
259
 
260
  ## -------------------------------------------------- ##
261
  ## -------------- CDN ----------------- ##
262
  ## -------------------------------------------------- ##
263
- const O_CDN = 'cdn' ;
264
- const O_CDN_ORI = 'cdn-ori' ;
265
- const O_CDN_ORI_DIR = 'cdn-ori_dir' ;
266
- const O_CDN_EXC = 'cdn-exc' ;
267
- const O_CDN_REMOTE_JQ = 'cdn-remote_jq' ;
268
- const O_CDN_QUIC = 'cdn-quic' ;
269
- const O_CDN_CLOUDFLARE = 'cdn-cloudflare' ;
270
- const O_CDN_CLOUDFLARE_EMAIL= 'cdn-cloudflare_email' ;
271
- const O_CDN_CLOUDFLARE_KEY = 'cdn-cloudflare_key' ;
272
- const O_CDN_CLOUDFLARE_NAME = 'cdn-cloudflare_name' ;
273
- const O_CDN_CLOUDFLARE_ZONE = 'cdn-cloudflare_zone' ;
274
  const O_CDN_MAPPING = 'cdn-mapping';
275
  const O_CDN_ATTR = 'cdn-attr';
276
 
277
- const NETWORK_O_USE_PRIMARY = 'use_primary_settings' ;
278
 
279
  /*** Other consts ***/
280
- const O_GUIDE = 'litespeed-guide' ; // Array of each guidance tag as key, step as val //xx todo: may need to remove
281
 
282
  // Server variables
283
- const ENV_CRAWLER_USLEEP = 'CRAWLER_USLEEP' ;
284
- const ENV_CRAWLER_LOAD_LIMIT = 'CRAWLER_LOAD_LIMIT' ;
285
- const ENV_CRAWLER_LOAD_LIMIT_ENFORCE = 'CRAWLER_LOAD_LIMIT_ENFORCE' ;
286
 
287
- // const O_FAVICON = 'litespeed-cache-favicon' ;
288
 
289
- const CRWL_COOKIE_NAME = 'name' ;
290
- const CRWL_COOKIE_VALS = 'vals' ;
291
 
292
  const CDN_MAPPING_URL = 'url';
293
  const CDN_MAPPING_INC_IMG = 'inc_img';
@@ -295,15 +298,15 @@ class Base extends Instance {
295
  const CDN_MAPPING_INC_JS = 'inc_js';
296
  const CDN_MAPPING_FILETYPE = 'filetype';
297
 
298
- const VAL_OFF = 0 ;
299
- const VAL_ON = 1 ;
300
- const VAL_ON2 = 2 ;
301
 
302
  /* This is for API hook usage */
303
- const IMG_OPTM_BM_ORI = 1 ;
304
- const IMG_OPTM_BM_WEBP = 2 ;
305
- const IMG_OPTM_BM_LOSSLESS = 4 ;
306
- const IMG_OPTM_BM_EXIF = 8 ;
307
 
308
  /* Site related options (Will not overwrite other sites' config) */
309
  protected static $SINGLE_SITE_OPTIONS = array(
@@ -324,14 +327,14 @@ class Base extends Instance {
324
  self::O_CDN_CLOUDFLARE_ZONE,
325
  self::O_CDN_MAPPING,
326
  self::O_CDN_ATTR,
327
- ) ;
328
 
329
  public static $CSS_FONT_DISPLAY_SET = array(
330
  1 => 'block',
331
  2 => 'swap',
332
  3 => 'fallback',
333
  4 => 'optional',
334
- ) ;
335
 
336
  protected static $_default_options = array(
337
  self::_VER => '',
@@ -452,6 +455,7 @@ class Base extends Instance {
452
  self::O_OPTM_EXC_ROLES => array(),
453
  self::O_OPTM_CCSS_CON => '',
454
  self::O_OPTM_JS_DEFER_EXC => array(),
 
455
  self::O_OPTM_DNS_PREFETCH => array(),
456
  self::O_OPTM_DNS_PREFETCH_CTRL => false,
457
  self::O_OPTM_EXC => array(),
@@ -477,6 +481,8 @@ class Base extends Instance {
477
  self::O_DISCUSS_AVATAR_CACHE => false,
478
  self::O_DISCUSS_AVATAR_CRON => false,
479
  self::O_DISCUSS_AVATAR_CACHE_TTL => 0,
 
 
480
 
481
  // Media
482
  self::O_MEDIA_LAZY => false,
@@ -557,7 +563,7 @@ class Base extends Instance {
557
  self::O_CDN_MAPPING => array(),
558
  self::O_CDN_ATTR => array(),
559
 
560
- ) ;
561
 
562
  protected static $_default_site_options = array(
563
  self::_VER => '',
@@ -607,7 +613,7 @@ class Base extends Instance {
607
  self::O_MISC_HTACCESS_FRONT => '',
608
  self::O_MISC_HTACCESS_BACK => '',
609
 
610
- ) ;
611
 
612
  // NOTE: all the val of following items will be int while not bool
613
  protected static $_multi_switch_list = array(
@@ -616,7 +622,7 @@ class Base extends Instance {
616
  self::O_OPTM_CSS_FONT_DISPLAY => 4,
617
  self::O_OPTM_JS_INLINE_DEFER => 2,
618
  self::O_CRAWLER_ORDER_LINKS => 3,
619
- ) ;
620
 
621
 
622
  /**
@@ -626,8 +632,7 @@ class Base extends Instance {
626
  *
627
  * @since 3.0.3
628
  */
629
- protected function type_casting( $val, $id, $is_site_conf = false )
630
- {
631
  $default_v = ! $is_site_conf ? self::$_default_options[ $id ] : self::$_default_site_options[ $id ];
632
  if ( is_bool( $default_v ) ) {
633
  if ( $val === 'true' ) {
@@ -668,14 +673,13 @@ class Base extends Instance {
668
  *
669
  * @since 3.0
670
  */
671
- protected function load_default_site_vals()
672
- {
673
  // Load network_default.ini
674
  if ( file_exists( LSCWP_DIR . 'data/const.network_default.ini' ) ) {
675
- $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.network_default.ini', true ) ;
676
  foreach ( self::$_default_site_options as $k => $v ) {
677
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
678
- continue ;
679
  }
680
 
681
  // Parse value in ini file
@@ -690,9 +694,9 @@ class Base extends Instance {
690
  }
691
  }
692
 
693
- self::$_default_site_options[ self::_VER ] = Core::VER ;
694
 
695
- return self::$_default_site_options ;
696
  }
697
 
698
  /**
@@ -701,14 +705,13 @@ class Base extends Instance {
701
  * @since 3.0
702
  * @access public
703
  */
704
- public function load_default_vals()
705
- {
706
  // Load default.ini
707
  if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
708
- $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true ) ;
709
  foreach ( self::$_default_options as $k => $v ) {
710
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
711
- continue ;
712
  }
713
 
714
  // Parse value in ini file
@@ -763,23 +766,23 @@ class Base extends Instance {
763
 
764
  // Load internal default vals
765
  // Setting the default bool to int is also to avoid type casting override it back to bool
766
- self::$_default_options[ self::O_CACHE ] = is_multisite() ? self::VAL_ON2 : self::VAL_ON ; //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
767
 
768
  // Load default vals containing variables
769
  if ( ! self::$_default_options[ self::O_CDN_ORI_DIR ] ) {
770
- self::$_default_options[ self::O_CDN_ORI_DIR ] = LSCWP_CONTENT_FOLDER . "\nwp-includes" ;
771
- self::$_default_options[ self::O_CDN_ORI_DIR ] = explode( "\n", self::$_default_options[ self::O_CDN_ORI_DIR ] ) ;
772
- self::$_default_options[ self::O_CDN_ORI_DIR ] = array_map( 'trim', self::$_default_options[ self::O_CDN_ORI_DIR ] ) ;
773
  }
774
 
775
  // Set security key if not initialized yet
776
  if ( ! self::$_default_options[ self::HASH ] ) {
777
- self::$_default_options[ self::HASH ] = Str::rrand( 32 ) ;
778
  }
779
 
780
- self::$_default_options[ self::_VER ] = Core::VER ;
781
 
782
- return self::$_default_options ;
783
  }
784
 
785
  /**
@@ -787,8 +790,7 @@ class Base extends Instance {
787
  *
788
  * @since 3.0
789
  */
790
- protected function _conf_string_val( $id, $val )
791
- {
792
  return $val;
793
  }
794
 
@@ -797,8 +799,7 @@ class Base extends Instance {
797
  *
798
  * @since 3.0
799
  */
800
- protected function _conf_multi_switch( $id )
801
- {
802
  if ( ! empty( self::$_multi_switch_list[ $id ] ) ) {
803
  return self::$_multi_switch_list[ $id ];
804
  }
@@ -815,9 +816,8 @@ class Base extends Instance {
815
  *
816
  * @since 3.0
817
  */
818
- public static function set_multi_switch( $id, $v )
819
- {
820
- self::$_multi_switch_list[ $id ] = $v ;
821
  }
822
 
823
  /**
@@ -825,8 +825,7 @@ class Base extends Instance {
825
  *
826
  * @since 3.0
827
  */
828
- public static function conf_const( $id )
829
- {
830
  return 'LITESPEED_CONF__' . strtoupper( str_replace( '-', '__', $id ) );
831
  }
832
 
@@ -835,8 +834,7 @@ class Base extends Instance {
835
  *
836
  * @since 3.0
837
  */
838
- protected function _conf_filter( $id )
839
- {
840
  $filters = array(
841
  self::O_MEDIA_LAZY_EXC => 'uri',
842
  self::O_DEBUG_INC => 'relative',
@@ -853,6 +851,8 @@ class Base extends Instance {
853
  self::O_OPTM_JS_DEFER_EXC => 'uri',
854
  self::O_OPTM_DNS_PREFETCH => 'domain',
855
  self::O_OPTM_CCSS_SEP_URI => 'uri',
 
 
856
  // self:: => '',
857
  // self:: => '',
858
  );
@@ -869,8 +869,7 @@ class Base extends Instance {
869
  *
870
  * @since 3.0
871
  */
872
- protected function _conf_purge( $id )
873
- {
874
  $check_ids = array(
875
  self::O_MEDIA_LAZY_URI_EXC,
876
  self::O_OPTM_EXC,
@@ -889,8 +888,7 @@ class Base extends Instance {
889
  *
890
  * @since 3.0
891
  */
892
- protected function _conf_purge_all( $id )
893
- {
894
  $check_ids = array(
895
  self::O_CACHE,
896
  self::O_ESI,
@@ -906,8 +904,7 @@ class Base extends Instance {
906
  *
907
  * @since 3.0
908
  */
909
- protected function _conf_pswd( $id )
910
- {
911
  $check_ids = array(
912
  self::O_CDN_CLOUDFLARE_KEY,
913
  self::O_OBJECT_PSWD,
@@ -922,8 +919,7 @@ class Base extends Instance {
922
  *
923
  * @since 3.0
924
  */
925
- protected function _conf_cron( $id )
926
- {
927
  $check_ids = array(
928
  self::O_IMG_OPTM_CRON,
929
  self::O_OPTM_CCSS_ASYNC,
@@ -941,8 +937,7 @@ class Base extends Instance {
941
  *
942
  * @since 3.0
943
  */
944
- protected function _conf_purge_tag( $id )
945
- {
946
  $check_ids = array(
947
  self::O_CACHE_PAGE_LOGIN => Tag::TYPE_LOGIN,
948
  );
@@ -959,8 +954,7 @@ class Base extends Instance {
959
  *
960
  * @since 3.0
961
  */
962
- public static function name( $id )
963
- {
964
  $cls = new \ReflectionClass( get_called_class() );
965
  return 'litespeed.' . strtolower( $cls->getShortName() ) . '.' . $id;
966
  }
@@ -970,9 +964,8 @@ class Base extends Instance {
970
  *
971
  * @since 3.0
972
  */
973
- public static function get_option( $id, $default_v = false )
974
- {
975
- return get_option( self::name( $id ), $default_v ) ;
976
  }
977
 
978
  /**
@@ -980,9 +973,8 @@ class Base extends Instance {
980
  *
981
  * @since 3.0
982
  */
983
- public static function get_site_option( $id, $default_v = false )
984
- {
985
- return get_site_option( self::name( $id ), $default_v ) ;
986
  }
987
 
988
  /**
@@ -990,9 +982,8 @@ class Base extends Instance {
990
  *
991
  * @since 3.0
992
  */
993
- public static function get_blog_option( $blog_id, $id, $default_v = false )
994
- {
995
- return get_blog_option( $blog_id, self::name( $id ), $default_v ) ;
996
  }
997
 
998
  /**
@@ -1000,9 +991,8 @@ class Base extends Instance {
1000
  *
1001
  * @since 3.0
1002
  */
1003
- public static function add_option( $id, $v )
1004
- {
1005
- add_option( self::name( $id ), $v ) ;
1006
  }
1007
 
1008
  /**
@@ -1010,9 +1000,8 @@ class Base extends Instance {
1010
  *
1011
  * @since 3.0
1012
  */
1013
- public static function add_site_option( $id, $v )
1014
- {
1015
- add_site_option( self::name( $id ), $v ) ;
1016
  }
1017
 
1018
  /**
@@ -1020,9 +1009,8 @@ class Base extends Instance {
1020
  *
1021
  * @since 3.0
1022
  */
1023
- public static function update_option( $id, $v )
1024
- {
1025
- update_option( self::name( $id ), $v ) ;
1026
  }
1027
 
1028
  /**
@@ -1030,9 +1018,8 @@ class Base extends Instance {
1030
  *
1031
  * @since 3.0
1032
  */
1033
- public static function update_site_option( $id, $v )
1034
- {
1035
- update_site_option( self::name( $id ), $v ) ;
1036
  }
1037
 
1038
  /**
@@ -1040,9 +1027,8 @@ class Base extends Instance {
1040
  *
1041
  * @since 3.0
1042
  */
1043
- public static function delete_option( $id )
1044
- {
1045
- delete_option( self::name( $id ) ) ;
1046
  }
1047
 
1048
  /**
@@ -1050,9 +1036,8 @@ class Base extends Instance {
1050
  *
1051
  * @since 3.0
1052
  */
1053
- public static function delete_site_option( $id )
1054
- {
1055
- delete_site_option( self::name( $id ) ) ;
1056
  }
1057
 
1058
  /**
@@ -1061,8 +1046,7 @@ class Base extends Instance {
1061
  * @since 3.0
1062
  * @access public
1063
  */
1064
- public static function get_summary( $field = false )
1065
- {
1066
  $summary = self::get_option( '_summary', array() );
1067
 
1068
  if ( ! is_array( $summary ) ) {
@@ -1086,13 +1070,12 @@ class Base extends Instance {
1086
  * @since 3.0
1087
  * @access public
1088
  */
1089
- public static function save_summary( $data = null )
1090
- {
1091
  if ( $data === null ) {
1092
  $data = static::get_instance()->_summary;
1093
  }
1094
 
1095
- self::update_option( '_summary', $data ) ;
1096
  }
1097
 
1098
  /**
@@ -1100,8 +1083,7 @@ class Base extends Instance {
1100
  *
1101
  * @since 2.4.1
1102
  */
1103
- public function server_vars()
1104
- {
1105
  $consts = array(
1106
  'WP_SITEURL',
1107
  'WP_HOME',
@@ -1117,13 +1099,13 @@ class Base extends Instance {
1117
  'LITESPEED_ON',
1118
  'LSWCP_TAG_PREFIX',
1119
  'COOKIEHASH',
1120
- ) ;
1121
- $server_vars = array() ;
1122
  foreach ( $consts as $v ) {
1123
- $server_vars[ $v ] = defined( $v ) ? constant( $v ) : NULL ;
1124
  }
1125
 
1126
- return $server_vars ;
1127
  }
1128
 
1129
  }
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
+ namespace LiteSpeed;
11
 
12
+ defined( 'WPINC' ) || exit;
13
 
14
  class Base extends Instance {
15
  protected static $_instance;
132
  const O_OPTM_CSS_EXC = 'optm-css_exc';
133
  const O_OPTM_JS_MIN = 'optm-js_min';
134
  const O_OPTM_JS_INLINE_MIN = 'optm-js_inline_min';
135
+ const O_OPTM_JS_COMB = 'optm-js_comb';
136
+ const O_OPTM_JS_COMB_PRIO = 'optm-js_comb_priority';
137
+ const O_OPTM_JS_HTTP2 = 'optm-js_http2';
138
+ const O_OPTM_JS_EXC = 'optm-js_exc';
139
+ const O_OPTM_TTL = 'optm-ttl';
140
+ const O_OPTM_HTML_MIN = 'optm-html_min';
141
+ const O_OPTM_QS_RM = 'optm-qs_rm';
142
+ const O_OPTM_GGFONTS_RM = 'optm-ggfonts_rm';
143
+ const O_OPTM_CSS_ASYNC = 'optm-css_async';
144
+ const O_OPTM_CCSS_GEN = 'optm-ccss_gen';
145
+ const O_OPTM_CCSS_ASYNC = 'optm-ccss_async';
146
+ const O_OPTM_CSS_ASYNC_INLINE = 'optm-css_async_inline';
147
+ const O_OPTM_CSS_FONT_DISPLAY = 'optm-css_font_display';
148
+ const O_OPTM_JS_DEFER = 'optm-js_defer';
149
+ const O_OPTM_JS_INLINE_DEFER = 'optm-js_inline_defer';
150
+ const O_OPTM_LOCALIZE = 'optm-localize';
151
+ const O_OPTM_LOCALIZE_DOMAINS = 'optm-localize_domains';
152
+ const O_OPTM_EMOJI_RM = 'optm-emoji_rm';
153
+ const O_OPTM_EXC_JQ = 'optm-exc_jq';
154
+ const O_OPTM_GGFONTS_ASYNC = 'optm-ggfonts_async';
155
+ const O_OPTM_MAX_SIZE = 'optm-max_size';
156
+ const O_OPTM_RM_COMMENT = 'optm-rm_comment';
157
+ const O_OPTM_EXC_ROLES = 'optm-exc_roles';
158
+ const O_OPTM_CCSS_CON = 'optm-ccss_con';
159
+ const O_OPTM_JS_DEFER_EXC = 'optm-js_defer_exc';
160
+ const O_OPTM_JS_INLINE_DEFER_EXC = 'optm-js_inline_defer_exc';
161
+ const O_OPTM_DNS_PREFETCH = 'optm-dns_prefetch';
162
+ const O_OPTM_DNS_PREFETCH_CTRL = 'optm-dns_prefetch_ctrl';
163
+ const O_OPTM_EXC = 'optm-exc';
164
+ const O_OPTM_CCSS_SEP_POSTTYPE = 'optm-ccss_sep_posttype';
165
+ const O_OPTM_CCSS_SEP_URI = 'optm-ccss_sep_uri';
166
 
167
  ## -------------------------------------------------- ##
168
  ## -------------- Object Cache ----------------- ##
169
  ## -------------------------------------------------- ##
170
+ const O_OBJECT = 'object';
171
+ const O_OBJECT_KIND = 'object-kind';
172
+ const O_OBJECT_HOST = 'object-host';
173
+ const O_OBJECT_PORT = 'object-port';
174
+ const O_OBJECT_LIFE = 'object-life';
175
+ const O_OBJECT_PERSISTENT = 'object-persistent';
176
+ const O_OBJECT_ADMIN = 'object-admin';
177
+ const O_OBJECT_TRANSIENTS = 'object-transients';
178
+ const O_OBJECT_DB_ID = 'object-db_id';
179
+ const O_OBJECT_USER = 'object-user';
180
+ const O_OBJECT_PSWD = 'object-pswd';
181
+ const O_OBJECT_GLOBAL_GROUPS = 'object-global_groups';
182
+ const O_OBJECT_NON_PERSISTENT_GROUPS = 'object-non_persistent_groups';
183
 
184
  ## -------------------------------------------------- ##
185
  ## -------------- Discussion ----------------- ##
186
  ## -------------------------------------------------- ##
187
+ const O_DISCUSS_AVATAR_CACHE = 'discuss-avatar_cache';
188
+ const O_DISCUSS_AVATAR_CRON = 'discuss-avatar_cron';
189
+ const O_DISCUSS_AVATAR_CACHE_TTL = 'discuss-avatar_cache_ttl';
190
 
191
  ## -------------------------------------------------- ##
192
  ## -------------- Media ----------------- ##
193
  ## -------------------------------------------------- ##
194
+ const O_MEDIA_LAZY = 'media-lazy';
195
+ const O_MEDIA_LAZY_PLACEHOLDER = 'media-lazy_placeholder';
196
+ const O_MEDIA_PLACEHOLDER_RESP = 'media-placeholder_resp';
197
+ const O_MEDIA_PLACEHOLDER_RESP_COLOR = 'media-placeholder_resp_color';
198
+ const O_MEDIA_PLACEHOLDER_RESP_SVG = 'media-placeholder_resp_svg';
199
+ const O_MEDIA_LQIP = 'media-lqip';
200
+ const O_MEDIA_LQIP_QUAL = 'media-lqip_qual';
201
  const O_MEDIA_LQIP_MIN_W = 'media-lqip_min_w';
202
  const O_MEDIA_LQIP_MIN_H = 'media-lqip_min_h';
203
+ const O_MEDIA_PLACEHOLDER_RESP_ASYNC = 'media-placeholder_resp_async';
204
+ const O_MEDIA_IFRAME_LAZY = 'media-iframe_lazy';
205
+ const O_MEDIA_LAZYJS_INLINE = 'media-lazyjs_inline';
206
+ const O_MEDIA_LAZY_EXC = 'media-lazy_exc';
207
+ const O_MEDIA_LAZY_CLS_EXC = 'media-lazy_cls_exc';
208
+ const O_MEDIA_LAZY_PARENT_CLS_EXC = 'media-lazy_parent_cls_exc';
209
+ const O_MEDIA_IFRAME_LAZY_CLS_EXC = 'media-iframe_lazy_cls_exc';
210
+ const O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC = 'media-iframe_lazy_parent_cls_exc';
211
+ const O_MEDIA_LAZY_URI_EXC = 'media-lazy_uri_exc';
212
 
213
  ## -------------------------------------------------- ##
214
  ## -------------- Image Optm ----------------- ##
215
  ## -------------------------------------------------- ##
216
+ const O_IMG_OPTM_AUTO = 'img_optm-auto';
217
+ const O_IMG_OPTM_CRON = 'img_optm-cron';
218
+ const O_IMG_OPTM_ORI = 'img_optm-ori';
219
+ const O_IMG_OPTM_RM_BKUP = 'img_optm-rm_bkup';
220
+ const O_IMG_OPTM_WEBP = 'img_optm-webp';
221
+ const O_IMG_OPTM_LOSSLESS = 'img_optm-lossless';
222
+ const O_IMG_OPTM_EXIF = 'img_optm-exif';
223
+ const O_IMG_OPTM_WEBP_REPLACE = 'img_optm-webp_replace';
224
+ const O_IMG_OPTM_WEBP_ATTR = 'img_optm-webp_attr';
225
+ const O_IMG_OPTM_WEBP_REPLACE_SRCSET = 'img_optm-webp_replace_srcset';
226
+ const O_IMG_OPTM_JPG_QUALITY = 'img_optm-jpg_quality';
227
 
228
  ## -------------------------------------------------- ##
229
  ## -------------- Crawler ----------------- ##
230
  ## -------------------------------------------------- ##
231
+ const O_CRAWLER = 'crawler';
232
+ const O_CRAWLER_POSTS = 'crawler-inc_posts';
233
+ const O_CRAWLER_PAGES = 'crawler-inc_pages';
234
+ const O_CRAWLER_CATS = 'crawler-inc_cats';
235
+ const O_CRAWLER_TAGS = 'crawler-inc_tags';
236
+ const O_CRAWLER_EXC_CPT = 'crawler-exc_cpt';
237
+ const O_CRAWLER_ORDER_LINKS = 'crawler-order_links';
238
+ const O_CRAWLER_USLEEP = 'crawler-usleep';
239
+ const O_CRAWLER_RUN_DURATION = 'crawler-run_duration';
240
+ const O_CRAWLER_RUN_INTERVAL = 'crawler-run_interval';
241
+ const O_CRAWLER_CRAWL_INTERVAL = 'crawler-crawl_interval';
242
+ const O_CRAWLER_THREADS = 'crawler-threads';
243
+ const O_CRAWLER_TIMEOUT = 'crawler-timeout';
244
+ const O_CRAWLER_LOAD_LIMIT = 'crawler-load_limit';
245
  const O_CRAWLER_SITEMAP = 'crawler-sitemap';
246
  const O_CRAWLER_DROP_DOMAIN = 'crawler-drop_domain';
247
  const O_CRAWLER_MAP_TIMEOUT = 'crawler-map_timeout';
248
+ const O_CRAWLER_ROLES = 'crawler-roles';
249
+ const O_CRAWLER_COOKIES = 'crawler-cookies';
250
 
251
  ## -------------------------------------------------- ##
252
  ## -------------- Misc ----------------- ##
253
  ## -------------------------------------------------- ##
254
+ const O_MISC_HTACCESS_FRONT = 'misc-htaccess_front';
255
+ const O_MISC_HTACCESS_BACK = 'misc-htaccess_back';
256
+ const O_MISC_HEARTBEAT_FRONT = 'misc-heartbeat_front';
257
+ const O_MISC_HEARTBEAT_FRONT_TTL = 'misc-heartbeat_front_ttl';
258
+ const O_MISC_HEARTBEAT_BACK = 'misc-heartbeat_back';
259
+ const O_MISC_HEARTBEAT_BACK_TTL = 'misc-heartbeat_back_ttl';
260
+ const O_MISC_HEARTBEAT_EDITOR = 'misc-heartbeat_editor';
261
+ const O_MISC_HEARTBEAT_EDITOR_TTL = 'misc-heartbeat_editor_ttl';
262
 
263
  ## -------------------------------------------------- ##
264
  ## -------------- CDN ----------------- ##
265
  ## -------------------------------------------------- ##
266
+ const O_CDN = 'cdn';
267
+ const O_CDN_ORI = 'cdn-ori';
268
+ const O_CDN_ORI_DIR = 'cdn-ori_dir';
269
+ const O_CDN_EXC = 'cdn-exc';
270
+ const O_CDN_REMOTE_JQ = 'cdn-remote_jq';
271
+ const O_CDN_QUIC = 'cdn-quic';
272
+ const O_CDN_CLOUDFLARE = 'cdn-cloudflare';
273
+ const O_CDN_CLOUDFLARE_EMAIL= 'cdn-cloudflare_email';
274
+ const O_CDN_CLOUDFLARE_KEY = 'cdn-cloudflare_key';
275
+ const O_CDN_CLOUDFLARE_NAME = 'cdn-cloudflare_name';
276
+ const O_CDN_CLOUDFLARE_ZONE = 'cdn-cloudflare_zone';
277
  const O_CDN_MAPPING = 'cdn-mapping';
278
  const O_CDN_ATTR = 'cdn-attr';
279
 
280
+ const NETWORK_O_USE_PRIMARY = 'use_primary_settings';
281
 
282
  /*** Other consts ***/
283
+ const O_GUIDE = 'litespeed-guide'; // Array of each guidance tag as key, step as val //xx todo: may need to remove
284
 
285
  // Server variables
286
+ const ENV_CRAWLER_USLEEP = 'CRAWLER_USLEEP';
287
+ const ENV_CRAWLER_LOAD_LIMIT = 'CRAWLER_LOAD_LIMIT';
288
+ const ENV_CRAWLER_LOAD_LIMIT_ENFORCE = 'CRAWLER_LOAD_LIMIT_ENFORCE';
289
 
290
+ // const O_FAVICON = 'litespeed-cache-favicon';
291
 
292
+ const CRWL_COOKIE_NAME = 'name';
293
+ const CRWL_COOKIE_VALS = 'vals';
294
 
295
  const CDN_MAPPING_URL = 'url';
296
  const CDN_MAPPING_INC_IMG = 'inc_img';
298
  const CDN_MAPPING_INC_JS = 'inc_js';
299
  const CDN_MAPPING_FILETYPE = 'filetype';
300
 
301
+ const VAL_OFF = 0;
302
+ const VAL_ON = 1;
303
+ const VAL_ON2 = 2;
304
 
305
  /* This is for API hook usage */
306
+ const IMG_OPTM_BM_ORI = 1;
307
+ const IMG_OPTM_BM_WEBP = 2;
308
+ const IMG_OPTM_BM_LOSSLESS = 4;
309
+ const IMG_OPTM_BM_EXIF = 8;
310
 
311
  /* Site related options (Will not overwrite other sites' config) */
312
  protected static $SINGLE_SITE_OPTIONS = array(
327
  self::O_CDN_CLOUDFLARE_ZONE,
328
  self::O_CDN_MAPPING,
329
  self::O_CDN_ATTR,
330
+ );
331
 
332
  public static $CSS_FONT_DISPLAY_SET = array(
333
  1 => 'block',
334
  2 => 'swap',
335
  3 => 'fallback',
336
  4 => 'optional',
337
+ );
338
 
339
  protected static $_default_options = array(
340
  self::_VER => '',
455
  self::O_OPTM_EXC_ROLES => array(),
456
  self::O_OPTM_CCSS_CON => '',
457
  self::O_OPTM_JS_DEFER_EXC => array(),
458
+ self::O_OPTM_JS_INLINE_DEFER_EXC => array(),
459
  self::O_OPTM_DNS_PREFETCH => array(),
460
  self::O_OPTM_DNS_PREFETCH_CTRL => false,
461
  self::O_OPTM_EXC => array(),
481
  self::O_DISCUSS_AVATAR_CACHE => false,
482
  self::O_DISCUSS_AVATAR_CRON => false,
483
  self::O_DISCUSS_AVATAR_CACHE_TTL => 0,
484
+ self::O_OPTM_LOCALIZE => false,
485
+ self::O_OPTM_LOCALIZE_DOMAINS => array(),
486
 
487
  // Media
488
  self::O_MEDIA_LAZY => false,
563
  self::O_CDN_MAPPING => array(),
564
  self::O_CDN_ATTR => array(),
565
 
566
+ );
567
 
568
  protected static $_default_site_options = array(
569
  self::_VER => '',
613
  self::O_MISC_HTACCESS_FRONT => '',
614
  self::O_MISC_HTACCESS_BACK => '',
615
 
616
+ );
617
 
618
  // NOTE: all the val of following items will be int while not bool
619
  protected static $_multi_switch_list = array(
622
  self::O_OPTM_CSS_FONT_DISPLAY => 4,
623
  self::O_OPTM_JS_INLINE_DEFER => 2,
624
  self::O_CRAWLER_ORDER_LINKS => 3,
625
+ );
626
 
627
 
628
  /**
632
  *
633
  * @since 3.0.3
634
  */
635
+ protected function type_casting( $val, $id, $is_site_conf = false ) {
 
636
  $default_v = ! $is_site_conf ? self::$_default_options[ $id ] : self::$_default_site_options[ $id ];
637
  if ( is_bool( $default_v ) ) {
638
  if ( $val === 'true' ) {
673
  *
674
  * @since 3.0
675
  */
676
+ public function load_default_site_vals() {
 
677
  // Load network_default.ini
678
  if ( file_exists( LSCWP_DIR . 'data/const.network_default.ini' ) ) {
679
+ $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.network_default.ini', true );
680
  foreach ( self::$_default_site_options as $k => $v ) {
681
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
682
+ continue;
683
  }
684
 
685
  // Parse value in ini file
694
  }
695
  }
696
 
697
+ self::$_default_site_options[ self::_VER ] = Core::VER;
698
 
699
+ return self::$_default_site_options;
700
  }
701
 
702
  /**
705
  * @since 3.0
706
  * @access public
707
  */
708
+ public function load_default_vals() {
 
709
  // Load default.ini
710
  if ( file_exists( LSCWP_DIR . 'data/const.default.ini' ) ) {
711
+ $default_ini_cfg = parse_ini_file( LSCWP_DIR . 'data/const.default.ini', true );
712
  foreach ( self::$_default_options as $k => $v ) {
713
  if ( ! array_key_exists( $k, $default_ini_cfg ) ) {
714
+ continue;
715
  }
716
 
717
  // Parse value in ini file
766
 
767
  // Load internal default vals
768
  // Setting the default bool to int is also to avoid type casting override it back to bool
769
+ self::$_default_options[ self::O_CACHE ] = is_multisite() ? self::VAL_ON2 : self::VAL_ON; //For multi site, default is 2 (Use Network Admin Settings). For single site, default is 1 (Enabled).
770
 
771
  // Load default vals containing variables
772
  if ( ! self::$_default_options[ self::O_CDN_ORI_DIR ] ) {
773
+ self::$_default_options[ self::O_CDN_ORI_DIR ] = LSCWP_CONTENT_FOLDER . "\nwp-includes";
774
+ self::$_default_options[ self::O_CDN_ORI_DIR ] = explode( "\n", self::$_default_options[ self::O_CDN_ORI_DIR ] );
775
+ self::$_default_options[ self::O_CDN_ORI_DIR ] = array_map( 'trim', self::$_default_options[ self::O_CDN_ORI_DIR ] );
776
  }
777
 
778
  // Set security key if not initialized yet
779
  if ( ! self::$_default_options[ self::HASH ] ) {
780
+ self::$_default_options[ self::HASH ] = Str::rrand( 32 );
781
  }
782
 
783
+ self::$_default_options[ self::_VER ] = Core::VER;
784
 
785
+ return self::$_default_options;
786
  }
787
 
788
  /**
790
  *
791
  * @since 3.0
792
  */
793
+ protected function _conf_string_val( $id, $val ) {
 
794
  return $val;
795
  }
796
 
799
  *
800
  * @since 3.0
801
  */
802
+ protected function _conf_multi_switch( $id ) {
 
803
  if ( ! empty( self::$_multi_switch_list[ $id ] ) ) {
804
  return self::$_multi_switch_list[ $id ];
805
  }
816
  *
817
  * @since 3.0
818
  */
819
+ public static function set_multi_switch( $id, $v ) {
820
+ self::$_multi_switch_list[ $id ] = $v;
 
821
  }
822
 
823
  /**
825
  *
826
  * @since 3.0
827
  */
828
+ public static function conf_const( $id ) {
 
829
  return 'LITESPEED_CONF__' . strtoupper( str_replace( '-', '__', $id ) );
830
  }
831
 
834
  *
835
  * @since 3.0
836
  */
837
+ protected function _conf_filter( $id ) {
 
838
  $filters = array(
839
  self::O_MEDIA_LAZY_EXC => 'uri',
840
  self::O_DEBUG_INC => 'relative',
851
  self::O_OPTM_JS_DEFER_EXC => 'uri',
852
  self::O_OPTM_DNS_PREFETCH => 'domain',
853
  self::O_OPTM_CCSS_SEP_URI => 'uri',
854
+ self::O_CDN_ORI => 'noprotocol', // `Original URLs`
855
+ // self::O_OPTM_LOCALIZE_DOMAINS => 'noprotocol', // `Localize Resources`
856
  // self:: => '',
857
  // self:: => '',
858
  );
869
  *
870
  * @since 3.0
871
  */
872
+ protected function _conf_purge( $id ) {
 
873
  $check_ids = array(
874
  self::O_MEDIA_LAZY_URI_EXC,
875
  self::O_OPTM_EXC,
888
  *
889
  * @since 3.0
890
  */
891
+ protected function _conf_purge_all( $id ) {
 
892
  $check_ids = array(
893
  self::O_CACHE,
894
  self::O_ESI,
904
  *
905
  * @since 3.0
906
  */
907
+ protected function _conf_pswd( $id ) {
 
908
  $check_ids = array(
909
  self::O_CDN_CLOUDFLARE_KEY,
910
  self::O_OBJECT_PSWD,
919
  *
920
  * @since 3.0
921
  */
922
+ protected function _conf_cron( $id ) {
 
923
  $check_ids = array(
924
  self::O_IMG_OPTM_CRON,
925
  self::O_OPTM_CCSS_ASYNC,
937
  *
938
  * @since 3.0
939
  */
940
+ protected function _conf_purge_tag( $id ) {
 
941
  $check_ids = array(
942
  self::O_CACHE_PAGE_LOGIN => Tag::TYPE_LOGIN,
943
  );
954
  *
955
  * @since 3.0
956
  */
957
+ public static function name( $id ) {
 
958
  $cls = new \ReflectionClass( get_called_class() );
959
  return 'litespeed.' . strtolower( $cls->getShortName() ) . '.' . $id;
960
  }
964
  *
965
  * @since 3.0
966
  */
967
+ public static function get_option( $id, $default_v = false ) {
968
+ return get_option( self::name( $id ), $default_v );
 
969
  }
970
 
971
  /**
973
  *
974
  * @since 3.0
975
  */
976
+ public static function get_site_option( $id, $default_v = false ) {
977
+ return get_site_option( self::name( $id ), $default_v );
 
978
  }
979
 
980
  /**
982
  *
983
  * @since 3.0
984
  */
985
+ public static function get_blog_option( $blog_id, $id, $default_v = false ) {
986
+ return get_blog_option( $blog_id, self::name( $id ), $default_v );
 
987
  }
988
 
989
  /**
991
  *
992
  * @since 3.0
993
  */
994
+ public static function add_option( $id, $v ) {
995
+ add_option( self::name( $id ), $v );
 
996
  }
997
 
998
  /**
1000
  *
1001
  * @since 3.0
1002
  */
1003
+ public static function add_site_option( $id, $v ) {
1004
+ add_site_option( self::name( $id ), $v );
 
1005
  }
1006
 
1007
  /**
1009
  *
1010
  * @since 3.0
1011
  */
1012
+ public static function update_option( $id, $v ) {
1013
+ update_option( self::name( $id ), $v );
 
1014
  }
1015
 
1016
  /**
1018
  *
1019
  * @since 3.0
1020
  */
1021
+ public static function update_site_option( $id, $v ) {
1022
+ update_site_option( self::name( $id ), $v );
 
1023
  }
1024
 
1025
  /**
1027
  *
1028
  * @since 3.0
1029
  */
1030
+ public static function delete_option( $id ) {
1031
+ delete_option( self::name( $id ) );
 
1032
  }
1033
 
1034
  /**
1036
  *
1037
  * @since 3.0
1038
  */
1039
+ public static function delete_site_option( $id ) {
1040
+ delete_site_option( self::name( $id ) );
 
1041
  }
1042
 
1043
  /**
1046
  * @since 3.0
1047
  * @access public
1048
  */
1049
+ public static function get_summary( $field = false ) {
 
1050
  $summary = self::get_option( '_summary', array() );
1051
 
1052
  if ( ! is_array( $summary ) ) {
1070
  * @since 3.0
1071
  * @access public
1072
  */
1073
+ public static function save_summary( $data = null ) {
 
1074
  if ( $data === null ) {
1075
  $data = static::get_instance()->_summary;
1076
  }
1077
 
1078
+ self::update_option( '_summary', $data );
1079
  }
1080
 
1081
  /**
1083
  *
1084
  * @since 2.4.1
1085
  */
1086
+ public function server_vars() {
 
1087
  $consts = array(
1088
  'WP_SITEURL',
1089
  'WP_HOME',
1099
  'LITESPEED_ON',
1100
  'LSWCP_TAG_PREFIX',
1101
  'COOKIEHASH',
1102
+ );
1103
+ $server_vars = array();
1104
  foreach ( $consts as $v ) {
1105
+ $server_vars[ $v ] = defined( $v ) ? constant( $v ) : NULL;
1106
  }
1107
 
1108
+ return $server_vars;
1109
  }
1110
 
1111
  }
src/cdn.cls.php CHANGED
@@ -8,28 +8,27 @@
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
- namespace LiteSpeed ;
12
 
13
- defined( 'WPINC' ) || exit ;
14
 
15
- class CDN extends Instance
16
- {
17
- protected static $_instance ;
18
 
19
- const BYPASS = 'LITESPEED_BYPASS_CDN' ;
20
 
21
- private $content ;
22
 
23
- private $_cfg_cdn ;
24
- private $_cfg_url_ori ;
25
- private $_cfg_ori_dir ;
26
- private $_cfg_cdn_mapping = array() ;
27
- private $_cfg_cdn_exclude ;
28
- private $_cfg_cdn_remote_jquery ;
29
 
30
- private $cdn_mapping_hosts = array() ;
31
 
32
- private $__cfg ;// cfg instance
33
 
34
  /**
35
  * Init
@@ -158,19 +157,18 @@ class CDN extends Instance
158
  * @since 2.0
159
  * @access private
160
  */
161
- private function _append_cdn_mapping( $filetype, $url )
162
- {
163
  // If filetype to url is one to many, make url be an array
164
  if ( empty( $this->_cfg_cdn_mapping[ $filetype ] ) ) {
165
- $this->_cfg_cdn_mapping[ $filetype ] = $url ;
166
  }
167
  elseif ( is_array( $this->_cfg_cdn_mapping[ $filetype ] ) ) {
168
  // Append url to filetype
169
- $this->_cfg_cdn_mapping[ $filetype ][] = $url ;
170
  }
171
  else {
172
  // Convert _cfg_cdn_mapping from string to array
173
- $this->_cfg_cdn_mapping[ $filetype ] = array( $this->_cfg_cdn_mapping[ $filetype ], $url ) ;
174
  }
175
  }
176
 
@@ -180,19 +178,18 @@ class CDN extends Instance
180
  * @since 1.7.2
181
  * @access public
182
  */
183
- public static function handler()
184
- {
185
- $instance = self::get_instance() ;
186
 
187
- $type = Router::verify_type() ;
188
 
189
  switch ( $type ) {
190
 
191
  default:
192
- break ;
193
  }
194
 
195
- Admin::redirect() ;
196
  }
197
 
198
  /**
@@ -201,19 +198,18 @@ class CDN extends Instance
201
  * @since 1.6.2.1
202
  * @return bool true if included in CDN
203
  */
204
- public static function inc_type( $type )
205
- {
206
- $instance = self::get_instance() ;
207
 
208
  if ( $type == 'css' && ! empty( $instance->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_CSS ] ) ) {
209
- return true ;
210
  }
211
 
212
  if ( $type == 'js' && ! empty( $instance->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_JS ] ) ) {
213
- return true ;
214
  }
215
 
216
- return false ;
217
  }
218
 
219
  /**
@@ -224,13 +220,12 @@ class CDN extends Instance
224
  * @access public
225
  * @return string The content that is after optimization
226
  */
227
- public static function finalize( $content )
228
- {
229
- $instance = self::get_instance() ;
230
- $instance->content = $content ;
231
 
232
- $instance->_finalize() ;
233
- return $instance->content ;
234
  }
235
 
236
  /**
@@ -239,23 +234,22 @@ class CDN extends Instance
239
  * @since 1.2.3
240
  * @access private
241
  */
242
- private function _finalize()
243
- {
244
  if ( defined( self::BYPASS ) ) {
245
- Debug2::debug2( 'CDN bypass' ) ;
246
- return ;
247
  }
248
 
249
- Debug2::debug( 'CDN _finalize' ) ;
250
 
251
  // Start replacing img src
252
  if ( ! empty( $this->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_IMG ] ) ) {
253
- $this->_replace_img() ;
254
- $this->_replace_inline_css() ;
255
  }
256
 
257
  if ( ! empty( $this->_cfg_cdn_mapping[ Base::CDN_MAPPING_FILETYPE ] ) ) {
258
- $this->_replace_file_types() ;
259
  }
260
 
261
  }
@@ -266,8 +260,7 @@ class CDN extends Instance
266
  * @since 1.2.3
267
  * @access private
268
  */
269
- private function _replace_file_types()
270
- {
271
  $ele_to_check = Conf::val( Base::O_CDN_ATTR );
272
 
273
  foreach ( $ele_to_check as $v ) {
@@ -294,12 +287,10 @@ class CDN extends Instance
294
  }
295
 
296
  foreach ( $matches[ $v[ 0 ] ? 3 : 2 ] as $k2 => $url ) {
297
- $url_parsed = parse_url( $url );
298
- if ( empty( $url_parsed[ 'path' ] ) ) {
299
- continue;
300
- }
301
- $postfix = substr( $url_parsed[ 'path' ], strrpos( $url_parsed[ 'path' ], '.' ) );
302
  if ( ! array_key_exists( $postfix, $this->_cfg_cdn_mapping ) ) {
 
303
  continue;
304
  }
305
 
@@ -321,17 +312,16 @@ class CDN extends Instance
321
  * @since 1.2.3
322
  * @access private
323
  */
324
- private function _replace_img()
325
- {
326
- preg_match_all( '#<img([^>]+?)src=([\'"\\\]*)([^\'"\s\\\>]+)([\'"\\\]*)([^>]*)>#i', $this->content, $matches ) ;
327
  foreach ( $matches[ 3 ] as $k => $url ) {
328
  // Check if is a DATA-URI
329
  if ( strpos( $url, 'data:image' ) !== false ) {
330
- continue ;
331
  }
332
 
333
  if ( ! $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
334
- continue ;
335
  }
336
 
337
  $html_snippet = sprintf(
@@ -339,8 +329,8 @@ class CDN extends Instance
339
  $matches[ 1 ][ $k ],
340
  $matches[ 2 ][ $k ] . $url2 . $matches[ 4 ][ $k ],
341
  $matches[ 5 ][ $k ]
342
- ) ;
343
- $this->content = str_replace( $matches[ 0 ][ $k ], $html_snippet, $this->content ) ;
344
  }
345
  }
346
 
@@ -350,9 +340,9 @@ class CDN extends Instance
350
  * @since 1.2.3
351
  * @access private
352
  */
353
- private function _replace_inline_css()
354
- {
355
- // preg_match_all( '/url\s*\(\s*(?!["\']?data:)(?![\'|\"]?[\#|\%|])([^)]+)\s*\)([^;},\s]*)/i', $this->content, $matches ) ;
356
 
357
  /**
358
  * Excludes `\` from URL matching
@@ -360,15 +350,26 @@ class CDN extends Instance
360
  * @see #685485
361
  * @since 3.0
362
  */
363
- preg_match_all( '#url\((?![\'"]?data)[\'"]?([^\)\'"\\\]+)[\'"]?\)#i', $this->content, $matches ) ;
364
  foreach ( $matches[ 1 ] as $k => $url ) {
365
- $url = str_replace( array( ' ', '\t', '\n', '\r', '\0', '\x0B', '"', "'", '&quot;', '&#039;' ), '', $url ) ;
366
 
367
- if ( ! $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
368
- continue ;
 
 
 
 
 
 
 
 
 
 
369
  }
370
- $attr = str_replace( $matches[ 1 ][ $k ], $url2, $matches[ 0 ][ $k ] ) ;
371
- $this->content = str_replace( $matches[ 0 ][ $k ], $attr, $this->content ) ;
 
372
  }
373
  }
374
 
@@ -381,12 +382,11 @@ class CDN extends Instance
381
  * @param array $img The URL of the attachment image src, the width, the height
382
  * @return array
383
  */
384
- public function attach_img_src( $img )
385
- {
386
  if ( $img && $url = $this->rewrite( $img[ 0 ], Base::CDN_MAPPING_INC_IMG ) ) {
387
- $img[ 0 ] = $url ;
388
  }
389
- return $img ;
390
  }
391
 
392
  /**
@@ -395,12 +395,11 @@ class CDN extends Instance
395
  * @since 1.7
396
  * @access public
397
  */
398
- public function url_img( $url )
399
- {
400
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
401
- $url = $url2 ;
402
  }
403
- return $url ;
404
  }
405
 
406
  /**
@@ -412,9 +411,9 @@ class CDN extends Instance
412
  public function url_css( $url )
413
  {
414
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_CSS ) ) {
415
- $url = $url2 ;
416
  }
417
- return $url ;
418
  }
419
 
420
  /**
@@ -423,12 +422,11 @@ class CDN extends Instance
423
  * @since 1.7
424
  * @access public
425
  */
426
- public function url_js( $url )
427
- {
428
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_JS ) ) {
429
- $url = $url2 ;
430
  }
431
- return $url ;
432
  }
433
 
434
  /**
@@ -440,17 +438,16 @@ class CDN extends Instance
440
  * @param array $srcs
441
  * @return array
442
  */
443
- public function srcset( $srcs )
444
- {
445
  if ( $srcs ) {
446
  foreach ( $srcs as $w => $data ) {
447
  if( ! $url = $this->rewrite( $data[ 'url' ], Base::CDN_MAPPING_INC_IMG ) ) {
448
- continue ;
449
  }
450
- $srcs[ $w ][ 'url' ] = $url ;
451
  }
452
  }
453
- return $srcs ;
454
  }
455
 
456
  /**
@@ -461,81 +458,80 @@ class CDN extends Instance
461
  * @param string $url
462
  * @return string Replaced URL
463
  */
464
- public function rewrite( $url, $mapping_kind, $postfix = false )
465
- {
466
- Debug2::debug2( '[CDN] rewrite ' . $url ) ;
467
- $url_parsed = parse_url( $url ) ;
468
 
469
  if ( empty( $url_parsed[ 'path' ] ) ) {
470
- Debug2::debug2( '[CDN] -rewrite bypassed: no path' ) ;
471
- return false ;
472
  }
473
 
474
  // Only images under wp-cotnent/wp-includes can be replaced
475
- $is_internal_folder = Utility::str_hit_array( $url_parsed[ 'path' ], $this->_cfg_ori_dir ) ;
476
  if ( ! $is_internal_folder ) {
477
- Debug2::debug2( '[CDN] -rewrite failed: path not match: ' . LSCWP_CONTENT_FOLDER ) ;
478
- return false ;
479
  }
480
 
481
  // Check if is external url
482
  if ( ! empty( $url_parsed[ 'host' ] ) ) {
483
  if ( ! Utility::internal( $url_parsed[ 'host' ] ) && ! $this->_is_ori_url( $url ) ) {
484
- Debug2::debug2( '[CDN] -rewrite failed: host not internal' ) ;
485
- return false ;
486
  }
487
  }
488
 
489
  if ( $this->_cfg_cdn_exclude ) {
490
- $exclude = Utility::str_hit_array( $url, $this->_cfg_cdn_exclude ) ;
491
  if ( $exclude ) {
492
- Debug2::debug2( '[CDN] -abort excludes ' . $exclude ) ;
493
- return false ;
494
  }
495
  }
496
 
497
  // Fill full url before replacement
498
  if ( empty( $url_parsed[ 'host' ] ) ) {
499
- $url = Utility::uri2url( $url ) ;
500
- Debug2::debug2( '[CDN] -fill before rewritten: ' . $url ) ;
501
 
502
- $url_parsed = parse_url( $url ) ;
503
  }
504
 
505
- $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
506
  if ( $scheme ) {
507
- // Debug2::debug2( '[CDN] -scheme from url: ' . $scheme ) ;
508
  }
509
 
510
  // Find the mapping url to be replaced to
511
  if ( empty( $this->_cfg_cdn_mapping[ $mapping_kind ] ) ) {
512
- return false ;
513
  }
514
  if ( $mapping_kind !== Base::CDN_MAPPING_FILETYPE ) {
515
- $final_url = $this->_cfg_cdn_mapping[ $mapping_kind ] ;
516
  }
517
  else {
518
  // select from file type
519
- $final_url = $this->_cfg_cdn_mapping[ $postfix ] ;
520
  }
521
 
522
  // If filetype to url is one to many, need to random one
523
  if ( is_array( $final_url ) ) {
524
- $final_url = $final_url[ mt_rand( 0, count( $final_url ) - 1 ) ] ;
525
  }
526
 
527
  // Now lets replace CDN url
528
  foreach ( $this->_cfg_url_ori as $v ) {
529
  if ( strpos( $v, '*' ) !== false ) {
530
- $url = preg_replace( '#' . $scheme . $v . '#iU', $final_url, $url ) ;
531
  }
532
  else {
533
- $url = str_replace( $scheme . $v, $final_url, $url ) ;
534
  }
535
  }
536
- Debug2::debug2( '[CDN] -rewritten: ' . $url ) ;
537
 
538
- return $url ;
539
  }
540
 
541
  /**
@@ -544,27 +540,26 @@ class CDN extends Instance
544
  * @since 2.1
545
  * @access private
546
  */
547
- private function _is_ori_url( $url )
548
- {
549
- $url_parsed = parse_url( $url ) ;
550
 
551
- $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '' ;
552
 
553
  foreach ( $this->_cfg_url_ori as $v ) {
554
- $needle = $scheme . $v ;
555
  if ( strpos( $v, '*' ) !== false ) {
556
  if( preg_match( '#' . $needle . '#iU', $url ) ) {
557
- return true ;
558
  }
559
  }
560
  else {
561
  if ( strpos( $url, $needle ) === 0 ) {
562
- return true ;
563
  }
564
  }
565
  }
566
 
567
- return false ;
568
  }
569
 
570
  /**
@@ -573,15 +568,14 @@ class CDN extends Instance
573
  * @since 1.2.3
574
  *
575
  */
576
- public static function internal( $host )
577
- {
578
  if ( defined( self::BYPASS ) ) {
579
- return false ;
580
  }
581
 
582
- $instance = self::get_instance() ;
583
 
584
- return in_array( $host, $instance->cdn_mapping_hosts ) ;// todo: can add $this->_is_ori_url() check in future
585
  }
586
 
587
  /**
@@ -591,25 +585,24 @@ class CDN extends Instance
591
  * @since 2.9.8 Changed to private
592
  * @access private
593
  */
594
- private function _load_jquery_remotely()
595
- {
596
  // default jq version
597
- $v = '1.12.4' ;
598
 
599
  // load wp's jq version
600
- global $wp_scripts ;
601
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
602
- $v = $wp_scripts->registered[ 'jquery-core' ]->ver ;
603
  // Remove all unexpected chars to fix WP5.2.1 jq version issue @see https://wordpress.org/support/topic/problem-with-wordpress-5-2-1/
604
- $v = preg_replace( '|[^\d\.]|', '', $v ) ;
605
  }
606
 
607
- $src = $this->_cfg_cdn_remote_jquery == Base::VAL_ON2 ? "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" : "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js" ;
608
 
609
- Debug2::debug2( '[CDN] load_jquery_remotely: ' . $src ) ;
610
 
611
- wp_deregister_script( 'jquery-core' ) ;
612
 
613
- wp_register_script( 'jquery-core', $src, false, $v ) ;
614
  }
615
  }
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
+ namespace LiteSpeed;
12
 
13
+ defined( 'WPINC' ) || exit;
14
 
15
+ class CDN extends Instance {
16
+ protected static $_instance;
 
17
 
18
+ const BYPASS = 'LITESPEED_BYPASS_CDN';
19
 
20
+ private $content;
21
 
22
+ private $_cfg_cdn;
23
+ private $_cfg_url_ori;
24
+ private $_cfg_ori_dir;
25
+ private $_cfg_cdn_mapping = array();
26
+ private $_cfg_cdn_exclude;
27
+ private $_cfg_cdn_remote_jquery;
28
 
29
+ private $cdn_mapping_hosts = array();
30
 
31
+ private $__cfg;// cfg instance
32
 
33
  /**
34
  * Init
157
  * @since 2.0
158
  * @access private
159
  */
160
+ private function _append_cdn_mapping( $filetype, $url ) {
 
161
  // If filetype to url is one to many, make url be an array
162
  if ( empty( $this->_cfg_cdn_mapping[ $filetype ] ) ) {
163
+ $this->_cfg_cdn_mapping[ $filetype ] = $url;
164
  }
165
  elseif ( is_array( $this->_cfg_cdn_mapping[ $filetype ] ) ) {
166
  // Append url to filetype
167
+ $this->_cfg_cdn_mapping[ $filetype ][] = $url;
168
  }
169
  else {
170
  // Convert _cfg_cdn_mapping from string to array
171
+ $this->_cfg_cdn_mapping[ $filetype ] = array( $this->_cfg_cdn_mapping[ $filetype ], $url );
172
  }
173
  }
174
 
178
  * @since 1.7.2
179
  * @access public
180
  */
181
+ public static function handler() {
182
+ $instance = self::get_instance();
 
183
 
184
+ $type = Router::verify_type();
185
 
186
  switch ( $type ) {
187
 
188
  default:
189
+ break;
190
  }
191
 
192
+ Admin::redirect();
193
  }
194
 
195
  /**
198
  * @since 1.6.2.1
199
  * @return bool true if included in CDN
200
  */
201
+ public static function inc_type( $type ) {
202
+ $instance = self::get_instance();
 
203
 
204
  if ( $type == 'css' && ! empty( $instance->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_CSS ] ) ) {
205
+ return true;
206
  }
207
 
208
  if ( $type == 'js' && ! empty( $instance->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_JS ] ) ) {
209
+ return true;
210
  }
211
 
212
+ return false;
213
  }
214
 
215
  /**
220
  * @access public
221
  * @return string The content that is after optimization
222
  */
223
+ public static function finalize( $content ) {
224
+ $instance = self::get_instance();
225
+ $instance->content = $content;
 
226
 
227
+ $instance->_finalize();
228
+ return $instance->content;
229
  }
230
 
231
  /**
234
  * @since 1.2.3
235
  * @access private
236
  */
237
+ private function _finalize() {
 
238
  if ( defined( self::BYPASS ) ) {
239
+ Debug2::debug2( 'CDN bypass' );
240
+ return;
241
  }
242
 
243
+ Debug2::debug( 'CDN _finalize' );
244
 
245
  // Start replacing img src
246
  if ( ! empty( $this->_cfg_cdn_mapping[ Base::CDN_MAPPING_INC_IMG ] ) ) {
247
+ $this->_replace_img();
248
+ $this->_replace_inline_css();
249
  }
250
 
251
  if ( ! empty( $this->_cfg_cdn_mapping[ Base::CDN_MAPPING_FILETYPE ] ) ) {
252
+ $this->_replace_file_types();
253
  }
254
 
255
  }
260
  * @since 1.2.3
261
  * @access private
262
  */
263
+ private function _replace_file_types() {
 
264
  $ele_to_check = Conf::val( Base::O_CDN_ATTR );
265
 
266
  foreach ( $ele_to_check as $v ) {
287
  }
288
 
289
  foreach ( $matches[ $v[ 0 ] ? 3 : 2 ] as $k2 => $url ) {
290
+ // Debug2::debug2( '[CDN] check ' . $url );
291
+ $postfix = '.' . pathinfo( parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
 
 
 
292
  if ( ! array_key_exists( $postfix, $this->_cfg_cdn_mapping ) ) {
293
+ // Debug2::debug2( '[CDN] non-existed postfix ' . $postfix );
294
  continue;
295
  }
296
 
312
  * @since 1.2.3
313
  * @access private
314
  */
315
+ private function _replace_img() {
316
+ preg_match_all( '#<img([^>]+?)src=([\'"\\\]*)([^\'"\s\\\>]+)([\'"\\\]*)([^>]*)>#i', $this->content, $matches );
 
317
  foreach ( $matches[ 3 ] as $k => $url ) {
318
  // Check if is a DATA-URI
319
  if ( strpos( $url, 'data:image' ) !== false ) {
320
+ continue;
321
  }
322
 
323
  if ( ! $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
324
+ continue;
325
  }
326
 
327
  $html_snippet = sprintf(
329
  $matches[ 1 ][ $k ],
330
  $matches[ 2 ][ $k ] . $url2 . $matches[ 4 ][ $k ],
331
  $matches[ 5 ][ $k ]
332
+ );
333
+ $this->content = str_replace( $matches[ 0 ][ $k ], $html_snippet, $this->content );
334
  }
335
  }
336
 
340
  * @since 1.2.3
341
  * @access private
342
  */
343
+ private function _replace_inline_css() {
344
+ // preg_match_all( '/url\s*\(\s*(?!["\']?data:)(?![\'|\"]?[\#|\%|])([^)]+)\s*\)([^;},\s]*)/i', $this->content, $matches );
345
+ Debug2::debug2( '[CDN] _replace_inline_css', $this->_cfg_cdn_mapping );
346
 
347
  /**
348
  * Excludes `\` from URL matching
350
  * @see #685485
351
  * @since 3.0
352
  */
353
+ preg_match_all( '#url\((?![\'"]?data)[\'"]?([^\)\'"\\\]+)[\'"]?\)#i', $this->content, $matches );
354
  foreach ( $matches[ 1 ] as $k => $url ) {
355
+ $url = str_replace( array( ' ', '\t', '\n', '\r', '\0', '\x0B', '"', "'", '&quot;', '&#039;' ), '', $url );
356
 
357
+ // Parse file postfix
358
+ $postfix = '.' . pathinfo( parse_url( $url, PHP_URL_PATH ), PATHINFO_EXTENSION );
359
+ if ( array_key_exists( $postfix, $this->_cfg_cdn_mapping ) ) {
360
+ Debug2::debug2( '[CDN] matched file_type ' . $postfix . ' : ' . $url );
361
+ if( ! $url2 = $this->rewrite( $url, Base::CDN_MAPPING_FILETYPE, $postfix ) ) {
362
+ continue;
363
+ }
364
+ }
365
+ else {
366
+ if ( ! $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
367
+ continue;
368
+ }
369
  }
370
+
371
+ $attr = str_replace( $matches[ 1 ][ $k ], $url2, $matches[ 0 ][ $k ] );
372
+ $this->content = str_replace( $matches[ 0 ][ $k ], $attr, $this->content );
373
  }
374
  }
375
 
382
  * @param array $img The URL of the attachment image src, the width, the height
383
  * @return array
384
  */
385
+ public function attach_img_src( $img ) {
 
386
  if ( $img && $url = $this->rewrite( $img[ 0 ], Base::CDN_MAPPING_INC_IMG ) ) {
387
+ $img[ 0 ] = $url;
388
  }
389
+ return $img;
390
  }
391
 
392
  /**
395
  * @since 1.7
396
  * @access public
397
  */
398
+ public function url_img( $url ) {
 
399
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_IMG ) ) {
400
+ $url = $url2;
401
  }
402
+ return $url;
403
  }
404
 
405
  /**
411
  public function url_css( $url )
412
  {
413
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_CSS ) ) {
414
+ $url = $url2;
415
  }
416
+ return $url;
417
  }
418
 
419
  /**
422
  * @since 1.7
423
  * @access public
424
  */
425
+ public function url_js( $url ) {
 
426
  if ( $url && $url2 = $this->rewrite( $url, Base::CDN_MAPPING_INC_JS ) ) {
427
+ $url = $url2;
428
  }
429
+ return $url;
430
  }
431
 
432
  /**
438
  * @param array $srcs
439
  * @return array
440
  */
441
+ public function srcset( $srcs ) {
 
442
  if ( $srcs ) {
443
  foreach ( $srcs as $w => $data ) {
444
  if( ! $url = $this->rewrite( $data[ 'url' ], Base::CDN_MAPPING_INC_IMG ) ) {
445
+ continue;
446
  }
447
+ $srcs[ $w ][ 'url' ] = $url;
448
  }
449
  }
450
+ return $srcs;
451
  }
452
 
453
  /**
458
  * @param string $url
459
  * @return string Replaced URL
460
  */
461
+ public function rewrite( $url, $mapping_kind, $postfix = false ) {
462
+ Debug2::debug2( '[CDN] rewrite ' . $url );
463
+ $url_parsed = parse_url( $url );
 
464
 
465
  if ( empty( $url_parsed[ 'path' ] ) ) {
466
+ Debug2::debug2( '[CDN] -rewrite bypassed: no path' );
467
+ return false;
468
  }
469
 
470
  // Only images under wp-cotnent/wp-includes can be replaced
471
+ $is_internal_folder = Utility::str_hit_array( $url_parsed[ 'path' ], $this->_cfg_ori_dir );
472
  if ( ! $is_internal_folder ) {
473
+ Debug2::debug2( '[CDN] -rewrite failed: path not match: ' . LSCWP_CONTENT_FOLDER );
474
+ return false;
475
  }
476
 
477
  // Check if is external url
478
  if ( ! empty( $url_parsed[ 'host' ] ) ) {
479
  if ( ! Utility::internal( $url_parsed[ 'host' ] ) && ! $this->_is_ori_url( $url ) ) {
480
+ Debug2::debug2( '[CDN] -rewrite failed: host not internal' );
481
+ return false;
482
  }
483
  }
484
 
485
  if ( $this->_cfg_cdn_exclude ) {
486
+ $exclude = Utility::str_hit_array( $url, $this->_cfg_cdn_exclude );
487
  if ( $exclude ) {
488
+ Debug2::debug2( '[CDN] -abort excludes ' . $exclude );
489
+ return false;
490
  }
491
  }
492
 
493
  // Fill full url before replacement
494
  if ( empty( $url_parsed[ 'host' ] ) ) {
495
+ $url = Utility::uri2url( $url );
496
+ Debug2::debug2( '[CDN] -fill before rewritten: ' . $url );
497
 
498
+ $url_parsed = parse_url( $url );
499
  }
500
 
501
+ $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '';
502
  if ( $scheme ) {
503
+ // Debug2::debug2( '[CDN] -scheme from url: ' . $scheme );
504
  }
505
 
506
  // Find the mapping url to be replaced to
507
  if ( empty( $this->_cfg_cdn_mapping[ $mapping_kind ] ) ) {
508
+ return false;
509
  }
510
  if ( $mapping_kind !== Base::CDN_MAPPING_FILETYPE ) {
511
+ $final_url = $this->_cfg_cdn_mapping[ $mapping_kind ];
512
  }
513
  else {
514
  // select from file type
515
+ $final_url = $this->_cfg_cdn_mapping[ $postfix ];
516
  }
517
 
518
  // If filetype to url is one to many, need to random one
519
  if ( is_array( $final_url ) ) {
520
+ $final_url = $final_url[ mt_rand( 0, count( $final_url ) - 1 ) ];
521
  }
522
 
523
  // Now lets replace CDN url
524
  foreach ( $this->_cfg_url_ori as $v ) {
525
  if ( strpos( $v, '*' ) !== false ) {
526
+ $url = preg_replace( '#' . $scheme . $v . '#iU', $final_url, $url );
527
  }
528
  else {
529
+ $url = str_replace( $scheme . $v, $final_url, $url );
530
  }
531
  }
532
+ Debug2::debug2( '[CDN] -rewritten: ' . $url );
533
 
534
+ return $url;
535
  }
536
 
537
  /**
540
  * @since 2.1
541
  * @access private
542
  */
543
+ private function _is_ori_url( $url ) {
544
+ $url_parsed = parse_url( $url );
 
545
 
546
+ $scheme = ! empty( $url_parsed[ 'scheme' ] ) ? $url_parsed[ 'scheme' ] . ':' : '';
547
 
548
  foreach ( $this->_cfg_url_ori as $v ) {
549
+ $needle = $scheme . $v;
550
  if ( strpos( $v, '*' ) !== false ) {
551
  if( preg_match( '#' . $needle . '#iU', $url ) ) {
552
+ return true;
553
  }
554
  }
555
  else {
556
  if ( strpos( $url, $needle ) === 0 ) {
557
+ return true;
558
  }
559
  }
560
  }
561
 
562
+ return false;
563
  }
564
 
565
  /**
568
  * @since 1.2.3
569
  *
570
  */
571
+ public static function internal( $host ) {
 
572
  if ( defined( self::BYPASS ) ) {
573
+ return false;
574
  }
575
 
576
+ $instance = self::get_instance();
577
 
578
+ return in_array( $host, $instance->cdn_mapping_hosts );// todo: can add $this->_is_ori_url() check in future
579
  }
580
 
581
  /**
585
  * @since 2.9.8 Changed to private
586
  * @access private
587
  */
588
+ private function _load_jquery_remotely() {
 
589
  // default jq version
590
+ $v = '1.12.4';
591
 
592
  // load wp's jq version
593
+ global $wp_scripts;
594
  if ( isset( $wp_scripts->registered[ 'jquery-core' ]->ver ) ) {
595
+ $v = $wp_scripts->registered[ 'jquery-core' ]->ver;
596
  // Remove all unexpected chars to fix WP5.2.1 jq version issue @see https://wordpress.org/support/topic/problem-with-wordpress-5-2-1/
597
+ $v = preg_replace( '|[^\d\.]|', '', $v );
598
  }
599
 
600
+ $src = $this->_cfg_cdn_remote_jquery == Base::VAL_ON2 ? "//cdnjs.cloudflare.com/ajax/libs/jquery/$v/jquery.min.js" : "//ajax.googleapis.com/ajax/libs/jquery/$v/jquery.min.js";
601
 
602
+ Debug2::debug2( '[CDN] load_jquery_remotely: ' . $src );
603
 
604
+ wp_deregister_script( 'jquery-core' );
605
 
606
+ wp_register_script( 'jquery-core', $src, false, $v );
607
  }
608
  }
src/cdn/cloudflare.cls.php CHANGED
@@ -7,28 +7,27 @@
7
  * @subpackage LiteSpeed/src/cdn
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
- namespace LiteSpeed\CDN ;
11
 
12
- use LiteSpeed\Core ;
13
- use LiteSpeed\Base ;
14
- use LiteSpeed\Conf ;
15
  use LiteSpeed\Debug2;
16
- use LiteSpeed\Router ;
17
- use LiteSpeed\Admin ;
18
- use LiteSpeed\Admin_Display ;
19
 
20
- defined( 'WPINC' ) || exit ;
21
 
22
- class Cloudflare extends Base
23
- {
24
- protected static $_instance ;
25
 
26
- const TYPE_PURGE_ALL = 'purge_all' ;
27
- const TYPE_GET_DEVMODE = 'get_devmode' ;
28
- const TYPE_SET_DEVMODE_ON = 'set_devmode_on' ;
29
- const TYPE_SET_DEVMODE_OFF = 'set_devmode_off' ;
30
 
31
- const ITEM_STATUS = 'status' ;
32
 
33
  /**
34
  * Update zone&name based on latest settings
@@ -36,25 +35,24 @@ class Cloudflare extends Base
36
  * @since 3.0
37
  * @access public
38
  */
39
- public static function try_refresh_zone()
40
- {
41
- $__cfg = Conf::get_instance() ;
42
 
43
  if ( ! Conf::val( Base::O_CDN_CLOUDFLARE ) ) {
44
- return ;
45
  }
46
 
47
- $zone = self::get_instance()->_fetch_zone() ;
48
  if ( $zone ) {
49
- $__cfg->update( Base::O_CDN_CLOUDFLARE_NAME, $zone[ 'name' ] ) ;
50
 
51
- $__cfg->update( Base::O_CDN_CLOUDFLARE_ZONE, $zone[ 'id' ] ) ;
52
 
53
- Debug2::debug( "[Cloudflare] Get zone successfully \t\t[ID] $zone[id]" ) ;
54
  }
55
  else {
56
- $__cfg->update( Base::O_CDN_CLOUDFLARE_ZONE, '' ) ;
57
- Debug2::debug( '[Cloudflare] ❌ Get zone failed, clean zone' ) ;
58
  }
59
 
60
  }
@@ -65,29 +63,28 @@ class Cloudflare extends Base
65
  * @since 1.7.2
66
  * @access private
67
  */
68
- private function _get_devmode( $show_msg = true )
69
- {
70
- Debug2::debug( '[Cloudflare] _get_devmode' ) ;
71
 
72
- $zone = $this->_zone() ;
73
  if ( ! $zone ) {
74
- return ;
75
  }
76
 
77
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
78
- $res = $this->_cloudflare_call( $url, 'GET', false, $show_msg ) ;
79
 
80
  if ( ! $res ) {
81
- return ;
82
  }
83
- Debug2::debug( '[Cloudflare] _get_devmode result ', $res ) ;
84
 
85
- $curr_status = self::get_option( self::ITEM_STATUS, array() ) ;
86
- $curr_status[ 'devmode' ] = $res[ 'value' ] ;
87
- $curr_status[ 'devmode_expired' ] = $res[ 'time_remaining' ] + time() ;
88
 
89
  // update status
90
- self::update_option( self::ITEM_STATUS, $curr_status ) ;
91
 
92
  }
93
 
@@ -97,29 +94,28 @@ class Cloudflare extends Base
97
  * @since 1.7.2
98
  * @access private
99
  */
100
- private function _set_devmode( $type )
101
- {
102
- Debug2::debug( '[Cloudflare] _set_devmode' ) ;
103
 
104
- $zone = $this->_zone() ;
105
  if ( ! $zone ) {
106
- return ;
107
  }
108
 
109
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode' ;
110
- $new_val = $type == self::TYPE_SET_DEVMODE_ON ? 'on' : 'off' ;
111
- $data = array( 'value' => $new_val ) ;
112
- $res = $this->_cloudflare_call( $url, 'PATCH', $data ) ;
113
 
114
  if ( ! $res ) {
115
- return ;
116
  }
117
 
118
- $res = $this->_get_devmode( false ) ;
119
 
120
  if ( $res ) {
121
- $msg = sprintf( __( 'Notified Cloudflare to set development mode to %s successfully.', 'litespeed-cache' ), strtoupper( $new_val ) ) ;
122
- Admin_Display::succeed( $msg ) ;
123
  }
124
 
125
  }
@@ -130,30 +126,29 @@ class Cloudflare extends Base
130
  * @since 1.7.2
131
  * @access private
132
  */
133
- private function _purge_all()
134
- {
135
- Debug2::debug( '[Cloudflare] _purge_all' ) ;
136
 
137
- $cf_on = Conf::val( Base::O_CDN_CLOUDFLARE ) ;
138
  if ( ! $cf_on ) {
139
- $msg = __( 'Cloudflare API is set to off.', 'litespeed-cache' ) ;
140
- Admin_Display::error( $msg ) ;
141
- return ;
142
  }
143
 
144
- $zone = $this->_zone() ;
145
  if ( ! $zone ) {
146
- return ;
147
  }
148
 
149
- $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/purge_cache' ;
150
- $data = array( 'purge_everything' => true ) ;
151
 
152
- $res = $this->_cloudflare_call( $url, 'DELETE', $data ) ;
153
 
154
  if ( $res ) {
155
- $msg = __( 'Notified Cloudflare to purge all successfully.', 'litespeed-cache' ) ;
156
- Admin_Display::succeed( $msg ) ;
157
  }
158
  }
159
 
@@ -163,16 +158,15 @@ class Cloudflare extends Base
163
  * @since 1.7.2
164
  * @access private
165
  */
166
- private function _zone()
167
- {
168
- $zone = Conf::val( Base::O_CDN_CLOUDFLARE_ZONE ) ;
169
  if ( ! $zone ) {
170
- $msg = __( 'No available Cloudflare zone', 'litespeed-cache' ) ;
171
- Admin_Display::error( $msg ) ;
172
- return false ;
173
  }
174
 
175
- return $zone ;
176
  }
177
 
178
  /**
@@ -181,44 +175,43 @@ class Cloudflare extends Base
181
  * @since 1.7.2
182
  * @access private
183
  */
184
- private function _fetch_zone()
185
- {
186
- $kw = Conf::val( Base::O_CDN_CLOUDFLARE_NAME ) ;
187
 
188
- $url = 'https://api.cloudflare.com/client/v4/zones?status=active&match=all' ;
189
 
190
  // Try exact match first
191
  if ( $kw && strpos( $kw, '.' ) ) {
192
- $zones = $this->_cloudflare_call( $url . '&name=' . $kw, 'GET', false, false ) ;
193
  if ( $zones ) {
194
- Debug2::debug( '[Cloudflare] fetch_zone exact matched' ) ;
195
- return $zones[ 0 ] ;
196
  }
197
  }
198
 
199
  // Can't find, try to get default one
200
- $zones = $this->_cloudflare_call( $url, 'GET', false, false ) ;
201
 
202
  if ( ! $zones ) {
203
- Debug2::debug( '[Cloudflare] fetch_zone no zone' ) ;
204
- return false ;
205
  }
206
 
207
  if ( ! $kw ) {
208
- Debug2::debug( '[Cloudflare] fetch_zone no set name, use first one by default' ) ;
209
- return $zones[ 0 ] ;
210
  }
211
 
212
  foreach ( $zones as $v ) {
213
  if ( strpos( $v[ 'name' ], $kw ) !== false ) {
214
- Debug2::debug( '[Cloudflare] fetch_zone matched ' . $kw . ' [name] ' . $v[ 'name' ] ) ;
215
- return $v ;
216
  }
217
  }
218
 
219
  // Can't match current name, return default one
220
- Debug2::debug( '[Cloudflare] fetch_zone failed match name, use first one by default' ) ;
221
- return $zones[ 0 ] ;
222
  }
223
 
224
  /**
@@ -227,48 +220,47 @@ class Cloudflare extends Base
227
  * @since 1.7.2
228
  * @access private
229
  */
230
- private function _cloudflare_call( $url, $method = 'GET', $data = false, $show_msg = true )
231
- {
232
- Debug2::debug( "[Cloudflare] _cloudflare_call \t\t[URL] $url" ) ;
233
 
234
  $header = array(
235
  'Content-Type: application/json',
236
  'X-Auth-Email: ' . Conf::val( Base::O_CDN_CLOUDFLARE_EMAIL ),
237
  'X-Auth-Key: ' . Conf::val( Base::O_CDN_CLOUDFLARE_KEY ),
238
- ) ;
239
 
240
- $ch = curl_init() ;
241
- curl_setopt( $ch, CURLOPT_URL, $url ) ;
242
- curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method ) ;
243
- curl_setopt( $ch, CURLOPT_HTTPHEADER, $header ) ;
244
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ) ;
245
  if ( $data ) {
246
  if ( is_array( $data ) ) {
247
- $data = json_encode( $data ) ;
248
  }
249
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $data ) ;
250
  }
251
- $result = curl_exec( $ch ) ;
252
 
253
- $json = json_decode( $result, true ) ;
254
 
255
  if ( $json && $json[ 'success' ] && $json[ 'result' ] ) {
256
- Debug2::debug( "[Cloudflare] _cloudflare_call called successfully" ) ;
257
  if ( $show_msg ) {
258
- $msg = __( 'Communicated with Cloudflare successfully.', 'litespeed-cache' ) ;
259
- Admin_Display::succeed( $msg ) ;
260
  }
261
 
262
- return $json[ 'result' ] ;
263
  }
264
 
265
- Debug2::debug( "[Cloudflare] _cloudflare_call called failed: $result" ) ;
266
  if ( $show_msg ) {
267
- $msg = __( 'Failed to communicate with Cloudflare', 'litespeed-cache' ) ;
268
- Admin_Display::error( $msg ) ;
269
  }
270
 
271
- return false ;
272
  }
273
 
274
  /**
@@ -277,31 +269,30 @@ class Cloudflare extends Base
277
  * @since 1.7.2
278
  * @access public
279
  */
280
- public static function handler()
281
- {
282
- $instance = self::get_instance() ;
283
 
284
- $type = Router::verify_type() ;
285
 
286
  switch ( $type ) {
287
  case self::TYPE_PURGE_ALL :
288
- $instance->_purge_all() ;
289
- break ;
290
 
291
  case self::TYPE_GET_DEVMODE :
292
- $instance->_get_devmode() ;
293
- break ;
294
 
295
  case self::TYPE_SET_DEVMODE_ON :
296
  case self::TYPE_SET_DEVMODE_OFF :
297
- $instance->_set_devmode( $type ) ;
298
- break ;
299
 
300
  default:
301
- break ;
302
  }
303
 
304
- Admin::redirect() ;
305
  }
306
 
307
  }
7
  * @subpackage LiteSpeed/src/cdn
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
+ namespace LiteSpeed\CDN;
11
 
12
+ use LiteSpeed\Core;
13
+ use LiteSpeed\Base;
14
+ use LiteSpeed\Conf;
15
  use LiteSpeed\Debug2;
16
+ use LiteSpeed\Router;
17
+ use LiteSpeed\Admin;
18
+ use LiteSpeed\Admin_Display;
19
 
20
+ defined( 'WPINC' ) || exit;
21
 
22
+ class Cloudflare extends Base {
23
+ protected static $_instance;
 
24
 
25
+ const TYPE_PURGE_ALL = 'purge_all';
26
+ const TYPE_GET_DEVMODE = 'get_devmode';
27
+ const TYPE_SET_DEVMODE_ON = 'set_devmode_on';
28
+ const TYPE_SET_DEVMODE_OFF = 'set_devmode_off';
29
 
30
+ const ITEM_STATUS = 'status';
31
 
32
  /**
33
  * Update zone&name based on latest settings
35
  * @since 3.0
36
  * @access public
37
  */
38
+ public static function try_refresh_zone() {
39
+ $__cfg = Conf::get_instance();
 
40
 
41
  if ( ! Conf::val( Base::O_CDN_CLOUDFLARE ) ) {
42
+ return;
43
  }
44
 
45
+ $zone = self::get_instance()->_fetch_zone();
46
  if ( $zone ) {
47
+ $__cfg->update( Base::O_CDN_CLOUDFLARE_NAME, $zone[ 'name' ] );
48
 
49
+ $__cfg->update( Base::O_CDN_CLOUDFLARE_ZONE, $zone[ 'id' ] );
50
 
51
+ Debug2::debug( "[Cloudflare] Get zone successfully \t\t[ID] $zone[id]" );
52
  }
53
  else {
54
+ $__cfg->update( Base::O_CDN_CLOUDFLARE_ZONE, '' );
55
+ Debug2::debug( '[Cloudflare] ❌ Get zone failed, clean zone' );
56
  }
57
 
58
  }
63
  * @since 1.7.2
64
  * @access private
65
  */
66
+ private function _get_devmode( $show_msg = true ) {
67
+ Debug2::debug( '[Cloudflare] _get_devmode' );
 
68
 
69
+ $zone = $this->_zone();
70
  if ( ! $zone ) {
71
+ return;
72
  }
73
 
74
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode';
75
+ $res = $this->_cloudflare_call( $url, 'GET', false, $show_msg );
76
 
77
  if ( ! $res ) {
78
+ return;
79
  }
80
+ Debug2::debug( '[Cloudflare] _get_devmode result ', $res );
81
 
82
+ $curr_status = self::get_option( self::ITEM_STATUS, array() );
83
+ $curr_status[ 'devmode' ] = $res[ 'value' ];
84
+ $curr_status[ 'devmode_expired' ] = $res[ 'time_remaining' ] + time();
85
 
86
  // update status
87
+ self::update_option( self::ITEM_STATUS, $curr_status );
88
 
89
  }
90
 
94
  * @since 1.7.2
95
  * @access private
96
  */
97
+ private function _set_devmode( $type ) {
98
+ Debug2::debug( '[Cloudflare] _set_devmode' );
 
99
 
100
+ $zone = $this->_zone();
101
  if ( ! $zone ) {
102
+ return;
103
  }
104
 
105
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/settings/development_mode';
106
+ $new_val = $type == self::TYPE_SET_DEVMODE_ON ? 'on' : 'off';
107
+ $data = array( 'value' => $new_val );
108
+ $res = $this->_cloudflare_call( $url, 'PATCH', $data );
109
 
110
  if ( ! $res ) {
111
+ return;
112
  }
113
 
114
+ $res = $this->_get_devmode( false );
115
 
116
  if ( $res ) {
117
+ $msg = sprintf( __( 'Notified Cloudflare to set development mode to %s successfully.', 'litespeed-cache' ), strtoupper( $new_val ) );
118
+ Admin_Display::succeed( $msg );
119
  }
120
 
121
  }
126
  * @since 1.7.2
127
  * @access private
128
  */
129
+ private function _purge_all() {
130
+ Debug2::debug( '[Cloudflare] _purge_all' );
 
131
 
132
+ $cf_on = Conf::val( Base::O_CDN_CLOUDFLARE );
133
  if ( ! $cf_on ) {
134
+ $msg = __( 'Cloudflare API is set to off.', 'litespeed-cache' );
135
+ Admin_Display::error( $msg );
136
+ return;
137
  }
138
 
139
+ $zone = $this->_zone();
140
  if ( ! $zone ) {
141
+ return;
142
  }
143
 
144
+ $url = 'https://api.cloudflare.com/client/v4/zones/' . $zone . '/purge_cache';
145
+ $data = array( 'purge_everything' => true );
146
 
147
+ $res = $this->_cloudflare_call( $url, 'DELETE', $data );
148
 
149
  if ( $res ) {
150
+ $msg = __( 'Notified Cloudflare to purge all successfully.', 'litespeed-cache' );
151
+ Admin_Display::succeed( $msg );
152
  }
153
  }
154
 
158
  * @since 1.7.2
159
  * @access private
160
  */
161
+ private function _zone() {
162
+ $zone = Conf::val( Base::O_CDN_CLOUDFLARE_ZONE );
 
163
  if ( ! $zone ) {
164
+ $msg = __( 'No available Cloudflare zone', 'litespeed-cache' );
165
+ Admin_Display::error( $msg );
166
+ return false;
167
  }
168
 
169
+ return $zone;
170
  }
171
 
172
  /**
175
  * @since 1.7.2
176
  * @access private
177
  */
178
+ private function _fetch_zone() {
179
+ $kw = Conf::val( Base::O_CDN_CLOUDFLARE_NAME );
 
180
 
181
+ $url = 'https://api.cloudflare.com/client/v4/zones?status=active&match=all';
182
 
183
  // Try exact match first
184
  if ( $kw && strpos( $kw, '.' ) ) {
185
+ $zones = $this->_cloudflare_call( $url . '&name=' . $kw, 'GET', false, false );
186
  if ( $zones ) {
187
+ Debug2::debug( '[Cloudflare] fetch_zone exact matched' );
188
+ return $zones[ 0 ];
189
  }
190
  }
191
 
192
  // Can't find, try to get default one
193
+ $zones = $this->_cloudflare_call( $url, 'GET', false, false );
194
 
195
  if ( ! $zones ) {
196
+ Debug2::debug( '[Cloudflare] fetch_zone no zone' );
197
+ return false;
198
  }
199
 
200
  if ( ! $kw ) {
201
+ Debug2::debug( '[Cloudflare] fetch_zone no set name, use first one by default' );
202
+ return $zones[ 0 ];
203
  }
204
 
205
  foreach ( $zones as $v ) {
206
  if ( strpos( $v[ 'name' ], $kw ) !== false ) {
207
+ Debug2::debug( '[Cloudflare] fetch_zone matched ' . $kw . ' [name] ' . $v[ 'name' ] );
208
+ return $v;
209
  }
210
  }
211
 
212
  // Can't match current name, return default one
213
+ Debug2::debug( '[Cloudflare] fetch_zone failed match name, use first one by default' );
214
+ return $zones[ 0 ];
215
  }
216
 
217
  /**
220
  * @since 1.7.2
221
  * @access private
222
  */
223
+ private function _cloudflare_call( $url, $method = 'GET', $data = false, $show_msg = true ) {
224
+ Debug2::debug( "[Cloudflare] _cloudflare_call \t\t[URL] $url" );
 
225
 
226
  $header = array(
227
  'Content-Type: application/json',
228
  'X-Auth-Email: ' . Conf::val( Base::O_CDN_CLOUDFLARE_EMAIL ),
229
  'X-Auth-Key: ' . Conf::val( Base::O_CDN_CLOUDFLARE_KEY ),
230
+ );
231
 
232
+ $ch = curl_init();
233
+ curl_setopt( $ch, CURLOPT_URL, $url );
234
+ curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, $method );
235
+ curl_setopt( $ch, CURLOPT_HTTPHEADER, $header );
236
+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
237
  if ( $data ) {
238
  if ( is_array( $data ) ) {
239
+ $data = json_encode( $data );
240
  }
241
+ curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
242
  }
243
+ $result = curl_exec( $ch );
244
 
245
+ $json = json_decode( $result, true );
246
 
247
  if ( $json && $json[ 'success' ] && $json[ 'result' ] ) {
248
+ Debug2::debug( "[Cloudflare] _cloudflare_call called successfully" );
249
  if ( $show_msg ) {
250
+ $msg = __( 'Communicated with Cloudflare successfully.', 'litespeed-cache' );
251
+ Admin_Display::succeed( $msg );
252
  }
253
 
254
+ return $json[ 'result' ];
255
  }
256
 
257
+ Debug2::debug( "[Cloudflare] _cloudflare_call called failed: $result" );
258
  if ( $show_msg ) {
259
+ $msg = __( 'Failed to communicate with Cloudflare', 'litespeed-cache' );
260
+ Admin_Display::error( $msg );
261
  }
262
 
263
+ return false;
264
  }
265
 
266
  /**
269
  * @since 1.7.2
270
  * @access public
271
  */
272
+ public static function handler() {
273
+ $instance = self::get_instance();
 
274
 
275
+ $type = Router::verify_type();
276
 
277
  switch ( $type ) {
278
  case self::TYPE_PURGE_ALL :
279
+ $instance->_purge_all();
280
+ break;
281
 
282
  case self::TYPE_GET_DEVMODE :
283
+ $instance->_get_devmode();
284
+ break;
285
 
286
  case self::TYPE_SET_DEVMODE_ON :
287
  case self::TYPE_SET_DEVMODE_OFF :
288
+ $instance->_set_devmode( $type );
289
+ break;
290
 
291
  default:
292
+ break;
293
  }
294
 
295
+ Admin::redirect();
296
  }
297
 
298
  }
src/cloud.cls.php CHANGED
@@ -7,8 +7,7 @@
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
- class Cloud extends Base
11
- {
12
  protected static $_instance;
13
 
14
  const CLOUD_SERVER = 'https://api.quic.cloud';
@@ -81,8 +80,7 @@ class Cloud extends Base
81
  *
82
  * @since 3.0
83
  */
84
- protected function __construct()
85
- {
86
  $this->_api_key = Conf::val( Base::O_API_KEY );
87
  $this->_summary = self::get_summary();
88
  }
@@ -92,8 +90,7 @@ class Cloud extends Base
92
  *
93
  * @since 3.0
94
  */
95
- public function check_dev_version()
96
- {
97
  if ( ! preg_match( '/[^\d\.]/', Core::VER ) ) {
98
  return;
99
  }
@@ -128,8 +125,7 @@ class Cloud extends Base
128
  * @since 2.9
129
  * @access public
130
  */
131
- public static function version_check( $src = false )
132
- {
133
  $req_data = array(
134
  'v' => defined( 'LSCWP_CUR_V' ) ? LSCWP_CUR_V : '',
135
  'src' => $src,
@@ -147,8 +143,7 @@ class Cloud extends Base
147
  *
148
  * @since 3.0
149
  */
150
- public function news()
151
- {
152
  $this->_update_news();
153
 
154
  if ( empty( $this->_summary[ 'news.new' ] ) ) {
@@ -167,8 +162,7 @@ class Cloud extends Base
167
  *
168
  * @since 2.9.9.1
169
  */
170
- private function _update_news()
171
- {
172
  if ( ! empty( $this->_summary[ 'news.utime' ] ) && time() - $this->_summary[ 'news.utime' ] < 86400 * 3 ) {
173
  return;
174
  }
@@ -209,8 +203,7 @@ class Cloud extends Base
209
  * @since 3.0
210
  * @access private
211
  */
212
- public function allowance( $service )
213
- {
214
  // Only auto sync usage at most one time per day
215
  if ( empty( $this->_summary[ 'last_request.' . self::SVC_D_USAGE ] ) || time() - $this->_summary[ 'last_request.' . self::SVC_D_USAGE ] > 86400 ) {
216
  $this->sync_usage();
@@ -256,8 +249,7 @@ class Cloud extends Base
256
  * @since 3.0
257
  * @access public
258
  */
259
- public function sync_usage()
260
- {
261
  $usage = $this->_post( self::SVC_D_USAGE );
262
  if ( ! $usage ) {
263
  return;
@@ -280,8 +272,7 @@ class Cloud extends Base
280
  * @since 3.0
281
  * @access public
282
  */
283
- public function clear_cloud()
284
- {
285
  foreach ( self::$SERVICES as $service ) {
286
  if ( isset( $this->_summary[ 'server.' . $service ] ) ) {
287
  unset( $this->_summary[ 'server.' . $service ] );
@@ -301,8 +292,7 @@ class Cloud extends Base
301
  * @since 3.0
302
  * @access public
303
  */
304
- public function detect_cloud( $service, $force = false )
305
- {
306
  if ( in_array( $service, self::$CENTER_SVC_SET ) ) {
307
  return self::CLOUD_SERVER;
308
  }
@@ -398,8 +388,7 @@ class Cloud extends Base
398
  * @since 3.0
399
  * @access public
400
  */
401
- public static function get( $service, $data = array() )
402
- {
403
  $instance = self::get_instance();
404
  return $instance->_get( $service, $data );
405
  }
@@ -410,8 +399,7 @@ class Cloud extends Base
410
  * @since 3.0
411
  * @access private
412
  */
413
- private function _get( $service, $data = false )
414
- {
415
  $service_tag = $service;
416
  if ( ! empty( $data[ 'action' ] ) ) {
417
  $service_tag .= '-' . $data[ 'action' ];
@@ -456,8 +444,7 @@ class Cloud extends Base
456
  * @since 3.0
457
  * @access private
458
  */
459
- private function _maybe_cloud( $service_tag )
460
- {
461
  // we don't want the `img_optm-taken` to fail at any given time
462
  if ( $service_tag == self::IMGOPTM_TAKEN ) {
463
  return true;
@@ -507,8 +494,7 @@ class Cloud extends Base
507
  * @since 3.0
508
  * @access public
509
  */
510
- public static function post( $service, $data = false, $time_out = false )
511
- {
512
  $instance = self::get_instance();
513
  return $instance->_post( $service, $data, $time_out );
514
  }
@@ -519,8 +505,7 @@ class Cloud extends Base
519
  * @since 3.0
520
  * @access private
521
  */
522
- private function _post( $service, $data = false, $time_out = false )
523
- {
524
  $service_tag = $service;
525
  if ( ! empty( $data[ 'action' ] ) ) {
526
  $service_tag .= '-' . $data[ 'action' ];
@@ -560,8 +545,7 @@ class Cloud extends Base
560
  *
561
  * @since 3.0
562
  */
563
- private function _parse_response( $response, $service, $service_tag, $server )
564
- {
565
  if ( is_wp_error( $response ) ) {
566
  $error_message = $response->get_error_message();
567
  Debug2::debug( '❄️ failed to request: ' . $error_message );
@@ -669,6 +653,15 @@ class Cloud extends Base
669
  $msg .= $this->_parse_link( $json );
670
  Admin_Display::error( $msg );
671
 
 
 
 
 
 
 
 
 
 
672
  return;
673
  }
674
 
@@ -698,8 +691,7 @@ class Cloud extends Base
698
  * @since 3.0
699
  * @access public
700
  */
701
- public function show_promo()
702
- {
703
  if ( ! $this->_api_key ) {
704
  Admin_Display::error( Error::msg( 'lack_of_api_key' ), true );
705
  }
@@ -717,8 +709,7 @@ class Cloud extends Base
717
  * @since 3.0
718
  * @access private
719
  */
720
- private function _clear_promo()
721
- {
722
  if ( count( $this->_summary[ 'promo' ] ) > 1 ) {
723
  array_shift( $this->_summary[ 'promo' ] );
724
  }
@@ -735,8 +726,7 @@ class Cloud extends Base
735
  * @since 1.6.7 Self clean the parameter
736
  * @access private
737
  */
738
- private function _parse_link( &$json )
739
- {
740
  $msg = '';
741
 
742
  if ( ! empty( $json[ '_links' ] ) ) {
@@ -756,8 +746,7 @@ class Cloud extends Base
756
  * @since 3.0
757
  * @access public
758
  */
759
- public function ip_validate()
760
- {
761
  if ( empty( $_POST[ 'hash' ] ) ) {
762
  Debug2::debug( '❄️ Lack of hash param' );
763
  return self::err( 'lack_of_param' );
@@ -788,8 +777,7 @@ class Cloud extends Base
788
  *
789
  * @since 3.0
790
  */
791
- public function can_token()
792
- {
793
  return empty( $this->_summary[ 'token_ts' ] ) || time() - $this->_summary[ 'token_ts' ] > self::EXPIRATION_TOKEN;
794
  }
795
 
@@ -799,8 +787,7 @@ class Cloud extends Base
799
  * @since 3.0
800
  * @access public
801
  */
802
- public function gen_key()
803
- {
804
  $data = array(
805
  'site_url' => home_url(),
806
  'rest' => function_exists( 'rest_get_url_prefix' ) ? rest_get_url_prefix() : apply_filters( 'rest_url_prefix', 'wp-json' ),
@@ -867,8 +854,7 @@ class Cloud extends Base
867
  * @since 3.0
868
  * @access public
869
  */
870
- public function token_validate()
871
- {
872
  try {
873
  $this->_validate_hash();
874
  } catch( \Exception $e ) {
@@ -888,8 +874,7 @@ class Cloud extends Base
888
  * @since 3.0
889
  * @access public
890
  */
891
- public function save_apikey()
892
- {
893
  // Validate token hash first
894
  if ( empty( $_POST[ 'domain_key' ] ) || ! isset( $_POST[ 'is_linked' ] ) ) {
895
  return self::err( 'lack_of_param' );
@@ -921,8 +906,7 @@ class Cloud extends Base
921
  *
922
  * @since 3.0
923
  */
924
- private function _validate_hash( $offset = 0 )
925
- {
926
  if ( empty( $_POST[ 'hash' ] ) ) {
927
  Debug2::debug( '❄️ Lack of hash param' );
928
  throw new \Exception( 'lack_of_param' );
@@ -944,8 +928,7 @@ class Cloud extends Base
944
  *
945
  * @since 3.0
946
  */
947
- public function can_link_qc()
948
- {
949
  return empty( $this->_summary[ 'is_linked' ] ) && $this->_api_key;
950
  }
951
 
@@ -954,8 +937,7 @@ class Cloud extends Base
954
  *
955
  * @since 3.0
956
  */
957
- private function _link_to_qc()
958
- {
959
  if ( ! $this->can_link_qc() ) {
960
  return;
961
  }
@@ -975,8 +957,7 @@ class Cloud extends Base
975
  *
976
  * @since 3.0
977
  */
978
- public function update_is_linked_status()
979
- {
980
  if ( empty( $_GET[ 'qc_res' ] ) || empty( $_GET[ 'domain_hash' ] ) ) {
981
  return;
982
  }
@@ -1020,8 +1001,7 @@ class Cloud extends Base
1020
  *
1021
  * @since 3.0
1022
  */
1023
- public static function ok( $data = array() )
1024
- {
1025
  $data[ '_res' ] = 'ok';
1026
  return $data;
1027
  }
@@ -1031,8 +1011,7 @@ class Cloud extends Base
1031
  *
1032
  * @since 3.0
1033
  */
1034
- public static function err( $code )
1035
- {
1036
  return array( '_res' => 'err', '_msg' => $code );
1037
  }
1038
 
@@ -1042,8 +1021,7 @@ class Cloud extends Base
1042
  * @since 3.0
1043
  * @access public
1044
  */
1045
- public static function handler()
1046
- {
1047
  $instance = self::get_instance();
1048
 
1049
  $type = Router::verify_type();
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
+ class Cloud extends Base {
 
11
  protected static $_instance;
12
 
13
  const CLOUD_SERVER = 'https://api.quic.cloud';
80
  *
81
  * @since 3.0
82
  */
83
+ protected function __construct() {
 
84
  $this->_api_key = Conf::val( Base::O_API_KEY );
85
  $this->_summary = self::get_summary();
86
  }
90
  *
91
  * @since 3.0
92
  */
93
+ public function check_dev_version() {
 
94
  if ( ! preg_match( '/[^\d\.]/', Core::VER ) ) {
95
  return;
96
  }
125
  * @since 2.9
126
  * @access public
127
  */
128
+ public static function version_check( $src = false ) {
 
129
  $req_data = array(
130
  'v' => defined( 'LSCWP_CUR_V' ) ? LSCWP_CUR_V : '',
131
  'src' => $src,
143
  *
144
  * @since 3.0
145
  */
146
+ public function news() {
 
147
  $this->_update_news();
148
 
149
  if ( empty( $this->_summary[ 'news.new' ] ) ) {
162
  *
163
  * @since 2.9.9.1
164
  */
165
+ private function _update_news() {
 
166
  if ( ! empty( $this->_summary[ 'news.utime' ] ) && time() - $this->_summary[ 'news.utime' ] < 86400 * 3 ) {
167
  return;
168
  }
203
  * @since 3.0
204
  * @access private
205
  */
206
+ public function allowance( $service ) {
 
207
  // Only auto sync usage at most one time per day
208
  if ( empty( $this->_summary[ 'last_request.' . self::SVC_D_USAGE ] ) || time() - $this->_summary[ 'last_request.' . self::SVC_D_USAGE ] > 86400 ) {
209
  $this->sync_usage();
249
  * @since 3.0
250
  * @access public
251
  */
252
+ public function sync_usage() {
 
253
  $usage = $this->_post( self::SVC_D_USAGE );
254
  if ( ! $usage ) {
255
  return;
272
  * @since 3.0
273
  * @access public
274
  */
275
+ public function clear_cloud() {
 
276
  foreach ( self::$SERVICES as $service ) {
277
  if ( isset( $this->_summary[ 'server.' . $service ] ) ) {
278
  unset( $this->_summary[ 'server.' . $service ] );
292
  * @since 3.0
293
  * @access public
294
  */
295
+ public function detect_cloud( $service, $force = false ) {
 
296
  if ( in_array( $service, self::$CENTER_SVC_SET ) ) {
297
  return self::CLOUD_SERVER;
298
  }
388
  * @since 3.0
389
  * @access public
390
  */
391
+ public static function get( $service, $data = array() ) {
 
392
  $instance = self::get_instance();
393
  return $instance->_get( $service, $data );
394
  }
399
  * @since 3.0
400
  * @access private
401
  */
402
+ private function _get( $service, $data = false ) {
 
403
  $service_tag = $service;
404
  if ( ! empty( $data[ 'action' ] ) ) {
405
  $service_tag .= '-' . $data[ 'action' ];
444
  * @since 3.0
445
  * @access private
446
  */
447
+ private function _maybe_cloud( $service_tag ) {
 
448
  // we don't want the `img_optm-taken` to fail at any given time
449
  if ( $service_tag == self::IMGOPTM_TAKEN ) {
450
  return true;
494
  * @since 3.0
495
  * @access public
496
  */
497
+ public static function post( $service, $data = false, $time_out = false ) {
 
498
  $instance = self::get_instance();
499
  return $instance->_post( $service, $data, $time_out );
500
  }
505
  * @since 3.0
506
  * @access private
507
  */
508
+ private function _post( $service, $data = false, $time_out = false ) {
 
509
  $service_tag = $service;
510
  if ( ! empty( $data[ 'action' ] ) ) {
511
  $service_tag .= '-' . $data[ 'action' ];
545
  *
546
  * @since 3.0
547
  */
548
+ private function _parse_response( $response, $service, $service_tag, $server ) {
 
549
  if ( is_wp_error( $response ) ) {
550
  $error_message = $response->get_error_message();
551
  Debug2::debug( '❄️ failed to request: ' . $error_message );
653
  $msg .= $this->_parse_link( $json );
654
  Admin_Display::error( $msg );
655
 
656
+ // Site not on QC, delete invalid domain key
657
+ if ( $json_msg == 'site_not_registered' ) {
658
+ Conf::get_instance()->update_confs( array( Base::O_API_KEY => '' ) );
659
+
660
+ $msg = __( 'Site not recognized. Domain Key has been automatically removed. Please request a new one.', 'litespeed-cache' );
661
+ $msg .= Doc::learn_more( admin_url( 'admin.php?page=litespeed-general' ), __( 'Click here to set.', 'litespeed-cache' ), true, false, true );
662
+ Admin_Display::error( $msg );
663
+ }
664
+
665
  return;
666
  }
667
 
691
  * @since 3.0
692
  * @access public
693
  */
694
+ public function show_promo() {
 
695
  if ( ! $this->_api_key ) {
696
  Admin_Display::error( Error::msg( 'lack_of_api_key' ), true );
697
  }
709
  * @since 3.0
710
  * @access private
711
  */
712
+ private function _clear_promo() {
 
713
  if ( count( $this->_summary[ 'promo' ] ) > 1 ) {
714
  array_shift( $this->_summary[ 'promo' ] );
715
  }
726
  * @since 1.6.7 Self clean the parameter
727
  * @access private
728
  */
729
+ private function _parse_link( &$json ) {
 
730
  $msg = '';
731
 
732
  if ( ! empty( $json[ '_links' ] ) ) {
746
  * @since 3.0
747
  * @access public
748
  */
749
+ public function ip_validate() {
 
750
  if ( empty( $_POST[ 'hash' ] ) ) {
751
  Debug2::debug( '❄️ Lack of hash param' );
752
  return self::err( 'lack_of_param' );
777
  *
778
  * @since 3.0
779
  */
780
+ public function can_token() {
 
781
  return empty( $this->_summary[ 'token_ts' ] ) || time() - $this->_summary[ 'token_ts' ] > self::EXPIRATION_TOKEN;
782
  }
783
 
787
  * @since 3.0
788
  * @access public
789
  */
790
+ public function gen_key() {
 
791
  $data = array(
792
  'site_url' => home_url(),
793
  'rest' => function_exists( 'rest_get_url_prefix' ) ? rest_get_url_prefix() : apply_filters( 'rest_url_prefix', 'wp-json' ),
854
  * @since 3.0
855
  * @access public
856
  */
857
+ public function token_validate() {
 
858
  try {
859
  $this->_validate_hash();
860
  } catch( \Exception $e ) {
874
  * @since 3.0
875
  * @access public
876
  */
877
+ public function save_apikey() {
 
878
  // Validate token hash first
879
  if ( empty( $_POST[ 'domain_key' ] ) || ! isset( $_POST[ 'is_linked' ] ) ) {
880
  return self::err( 'lack_of_param' );
906
  *
907
  * @since 3.0
908
  */
909
+ private function _validate_hash( $offset = 0 ) {
 
910
  if ( empty( $_POST[ 'hash' ] ) ) {
911
  Debug2::debug( '❄️ Lack of hash param' );
912
  throw new \Exception( 'lack_of_param' );
928
  *
929
  * @since 3.0
930
  */
931
+ public function can_link_qc() {
 
932
  return empty( $this->_summary[ 'is_linked' ] ) && $this->_api_key;
933
  }
934
 
937
  *
938
  * @since 3.0
939
  */
940
+ private function _link_to_qc() {
 
941
  if ( ! $this->can_link_qc() ) {
942
  return;
943
  }
957
  *
958
  * @since 3.0
959
  */
960
+ public function update_is_linked_status() {
 
961
  if ( empty( $_GET[ 'qc_res' ] ) || empty( $_GET[ 'domain_hash' ] ) ) {
962
  return;
963
  }
1001
  *
1002
  * @since 3.0
1003
  */
1004
+ public static function ok( $data = array() ) {
 
1005
  $data[ '_res' ] = 'ok';
1006
  return $data;
1007
  }
1011
  *
1012
  * @since 3.0
1013
  */
1014
+ public static function err( $code ) {
 
1015
  return array( '_res' => 'err', '_msg' => $code );
1016
  }
1017
 
1021
  * @since 3.0
1022
  * @access public
1023
  */
1024
+ public static function handler() {
 
1025
  $instance = self::get_instance();
1026
 
1027
  $type = Router::verify_type();
src/conf.cls.php CHANGED
@@ -210,7 +210,7 @@ class Conf extends Base
210
  // Overwrite single blog options with site options
211
  foreach ( self::$_default_options as $k => $v ) {
212
  if ( isset( $this->_site_options[ $k ] ) ) {
213
- $this->_options[ $k ] = $this->_site_options[ $k ];
214
  $this->_primary_options[ $k ] = $this->_site_options[ $k ];
215
  }
216
  }
@@ -579,6 +579,15 @@ class Conf extends Base
579
  return;
580
  }
581
 
 
 
 
 
 
 
 
 
 
582
  // Validate type
583
  $val = $this->type_casting( $val, $id );
584
 
210
  // Overwrite single blog options with site options
211
  foreach ( self::$_default_options as $k => $v ) {
212
  if ( isset( $this->_site_options[ $k ] ) ) {
213
+ // $this->_options[ $k ] = $this->_site_options[ $k ];
214
  $this->_primary_options[ $k ] = $this->_site_options[ $k ];
215
  }
216
  }
579
  return;
580
  }
581
 
582
+ // Special handler for CDN Original URLs
583
+ if ( $id == Base::O_CDN_ORI && ! $val ) {
584
+ $home_url = home_url( '/' );
585
+ $parsed = parse_url( $home_url );
586
+ $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url );
587
+
588
+ $val = $home_url;
589
+ }
590
+
591
  // Validate type
592
  $val = $this->type_casting( $val, $id );
593
 
src/control.cls.php CHANGED
@@ -8,29 +8,28 @@
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
- namespace LiteSpeed ;
12
 
13
- defined( 'WPINC' ) || exit ;
14
 
15
- class Control extends Instance
16
- {
17
- protected static $_instance ;
18
 
19
- const BM_CACHEABLE = 1 ;
20
- const BM_PRIVATE = 2 ;
21
- const BM_SHARED = 4 ;
22
- const BM_NO_VARY = 8 ;
23
- const BM_FORCED_CACHEABLE = 32 ;
24
- const BM_PUBLIC_FORCED = 64 ;
25
- const BM_STALE = 128 ;
26
- const BM_NOTCACHEABLE = 256 ;
27
 
28
- const X_HEADER = 'X-LiteSpeed-Cache-Control' ;
29
 
30
- protected static $_control = 0 ;
31
- protected static $_custom_ttl = 0 ;
32
 
33
- private $_response_header_ttls = array() ;
34
 
35
  /**
36
  * Init cache control
@@ -38,25 +37,24 @@ class Control extends Instance
38
  * @since 1.6.2
39
  * @access protected
40
  */
41
- protected function __construct()
42
- {
43
  /**
44
  * Add vary filter for Role Excludes
45
  * @since 1.6.2
46
  */
47
- add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) ) ;
48
 
49
  // 301 redirect hook
50
- add_filter( 'wp_redirect', array( $this, 'check_redirect' ), 10, 2 ) ;
51
 
52
  // Load response header conf
53
- $this->_response_header_ttls = Conf::val( Base::O_CACHE_TTL_STATUS ) ;
54
  foreach ( $this->_response_header_ttls as $k => $v ) {
55
- $v = explode( ' ', $v ) ;
56
  if ( empty( $v[ 0 ] ) || empty( $v[ 1 ] ) ) {
57
- continue ;
58
  }
59
- $this->_response_header_ttls[ $v[ 0 ] ] = $v[ 1 ] ;
60
  }
61
 
62
  if ( Conf::val( Base::O_PURGE_STALE ) ) {
@@ -70,8 +68,7 @@ class Control extends Instance
70
  * @since 1.6.2
71
  * @access public
72
  */
73
- public function vary_add_role_exclude( $vary )
74
- {
75
  if ( $this->in_cache_exc_roles() ) {
76
  $vary[ 'role_exclude_cache' ] = 1;
77
  }
@@ -88,18 +85,17 @@ class Control extends Instance
88
  * @param string $role The user role
89
  * @return int The set value if already set
90
  */
91
- public function in_cache_exc_roles( $role = null )
92
- {
93
  // Get user role
94
  if ( $role === null ) {
95
- $role = Router::get_role() ;
96
  }
97
 
98
  if ( ! $role ) {
99
- return false ;
100
  }
101
 
102
- return in_array( $role, Conf::val( Base::O_CACHE_EXC_ROLES ) ) ? $role : false ;
103
  }
104
 
105
  /**
@@ -109,30 +105,29 @@ class Control extends Instance
109
  * @since 1.1.3
110
  * @access public
111
  */
112
- public static function init_cacheable()
113
- {
114
  // Hook `wp` to mark default cacheable status
115
  // NOTE: Any process that does NOT run into `wp` hook will not get cacheable by default
116
- add_action( 'wp', __CLASS__ . '::set_cacheable', 5 ) ;
117
 
118
  // Hook WP REST to be cacheable
119
  if ( Conf::val( Base::O_CACHE_REST ) ) {
120
- add_action( 'rest_api_init', __CLASS__ . '::set_cacheable', 5 ) ;
121
  }
122
 
123
  // Cache resources
124
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
125
- $cache_res = Conf::val( Base::O_CACHE_RES ) ;
126
  if ( $cache_res ) {
127
- $uri = esc_url( $_SERVER["REQUEST_URI"] ) ;// todo: check if need esc_url()
128
- $pattern = '!' . LSCWP_CONTENT_FOLDER . Htaccess::RW_PATTERN_RES . '!' ;
129
  if ( preg_match( $pattern, $uri ) ) {
130
- add_action( 'wp_loaded', __CLASS__ . '::set_cacheable', 5 ) ;
131
  }
132
  }
133
 
134
  // Check error page
135
- add_filter( 'status_header', array( self::get_instance(), 'check_error_codes' ), 10, 2 ) ;
136
  }
137
 
138
 
@@ -145,22 +140,21 @@ class Control extends Instance
145
  * @param $code
146
  * @return $eror_status
147
  */
148
- public function check_error_codes( $status_header, $code )
149
- {
150
  if ( array_key_exists( $code, $this->_response_header_ttls ) ) {
151
  if ( self::is_cacheable() && ! $this->_response_header_ttls[ $code ] ) {
152
- self::set_nocache( '[Ctrl] TTL is set to no cache [status_header] ' . $code ) ;
153
  }
154
 
155
  // Set TTL
156
- self::set_custom_ttl( $this->_response_header_ttls[ $code ] ) ;
157
  }
158
 
159
  // Set cache tag
160
- Tag::add( Tag::TYPE_HTTP . $code ) ;
161
 
162
  // Give the default status_header back
163
- return $status_header ;
164
  }
165
 
166
  /**
@@ -169,13 +163,12 @@ class Control extends Instance
169
  * @access public
170
  * @since 1.1.3
171
  */
172
- public static function set_no_vary()
173
- {
174
  if ( self::is_no_vary() ) {
175
- return ;
176
  }
177
- self::$_control |= self::BM_NO_VARY ;
178
- Debug2::debug( '[Ctrl] X Cache_control -> no-vary', 3 ) ;
179
  }
180
 
181
  /**
@@ -184,9 +177,8 @@ class Control extends Instance
184
  * @access public
185
  * @since 1.1.3
186
  */
187
- public static function is_no_vary()
188
- {
189
- return self::$_control & self::BM_NO_VARY ;
190
  }
191
 
192
  /**
@@ -195,13 +187,12 @@ class Control extends Instance
195
  * @access public
196
  * @since 1.1.3
197
  */
198
- public static function set_stale()
199
- {
200
  if ( self::is_stale() ) {
201
- return ;
202
  }
203
- self::$_control |= self::BM_STALE ;
204
- Debug2::debug('[Ctrl] X Cache_control -> stale') ;
205
  }
206
 
207
  /**
@@ -210,9 +201,8 @@ class Control extends Instance
210
  * @access public
211
  * @since 1.1.3
212
  */
213
- public static function is_stale()
214
- {
215
- return self::$_control & self::BM_STALE ;
216
  }
217
 
218
  /**
@@ -222,22 +212,21 @@ class Control extends Instance
222
  * @since 1.1.3
223
  * @param string $reason The reason to no cache
224
  */
225
- public static function set_shared( $reason = false )
226
- {
227
  if ( self::is_shared() ) {
228
- return ;
229
  }
230
- self::$_control |= self::BM_SHARED ;
231
- self::set_private() ;
232
 
233
  if ( ! is_string( $reason ) ) {
234
- $reason = false ;
235
  }
236
 
237
  if ( $reason ) {
238
- $reason = "( $reason )" ;
239
  }
240
- Debug2::debug( '[Ctrl] X Cache_control -> shared ' . $reason ) ;
241
  }
242
 
243
  /**
@@ -246,9 +235,8 @@ class Control extends Instance
246
  * @access public
247
  * @since 1.1.3
248
  */
249
- public static function is_shared()
250
- {
251
- return (self::$_control & self::BM_SHARED) && self::is_private() ;
252
  }
253
 
254
  /**
@@ -257,21 +245,20 @@ class Control extends Instance
257
  * @access public
258
  * @since 1.7.1
259
  */
260
- public static function set_public_forced( $reason = false )
261
- {
262
  if ( self::is_public_forced() ) {
263
- return ;
264
  }
265
- self::$_control |= self::BM_PUBLIC_FORCED ;
266
 
267
  if ( ! is_string( $reason ) ) {
268
- $reason = false ;
269
  }
270
 
271
  if ( $reason ) {
272
- $reason = "( $reason )" ;
273
  }
274
- Debug2::debug( '[Ctrl] X Cache_control -> public forced ' . $reason ) ;
275
  }
276
 
277
  /**
@@ -280,9 +267,8 @@ class Control extends Instance
280
  * @access public
281
  * @since 1.7.1
282
  */
283
- public static function is_public_forced()
284
- {
285
- return self::$_control & self::BM_PUBLIC_FORCED ;
286
  }
287
 
288
  /**
@@ -292,21 +278,20 @@ class Control extends Instance
292
  * @since 1.1.3
293
  * @param string $reason The reason to no cache
294
  */
295
- public static function set_private( $reason = false )
296
- {
297
  if ( self::is_private() ) {
298
- return ;
299
  }
300
- self::$_control |= self::BM_PRIVATE ;
301
 
302
  if ( ! is_string( $reason ) ) {
303
- $reason = false ;
304
  }
305
 
306
  if ( $reason ) {
307
- $reason = "( $reason )" ;
308
  }
309
- Debug2::debug( '[Ctrl] X Cache_control -> private ' . $reason ) ;
310
  }
311
 
312
  /**
@@ -315,9 +300,8 @@ class Control extends Instance
315
  * @access public
316
  * @since 1.1.3
317
  */
318
- public static function is_private()
319
- {
320
- return self::$_control & self::BM_PRIVATE && ! self::is_public_forced() ;
321
  }
322
 
323
  /**
@@ -326,18 +310,17 @@ class Control extends Instance
326
  * @access public
327
  * @since 1.1.3
328
  */
329
- public static function set_cacheable( $reason = false )
330
- {
331
- self::$_control |= self::BM_CACHEABLE ;
332
 
333
  if ( ! is_string( $reason ) ) {
334
- $reason = false ;
335
  }
336
 
337
  if ( $reason ) {
338
- $reason = ' [reason] ' . $reason ;
339
  }
340
- Debug2::debug( '[Ctrl] X Cache_control init on' . $reason ) ;
341
  }
342
 
343
  /**
@@ -346,18 +329,17 @@ class Control extends Instance
346
  * @access public
347
  * @since 2.2
348
  */
349
- public static function force_cacheable( $reason = false )
350
- {
351
- self::$_control |= self::BM_FORCED_CACHEABLE ;
352
 
353
  if ( ! is_string( $reason ) ) {
354
- $reason = false ;
355
  }
356
 
357
  if ( $reason ) {
358
- $reason = ' [reason] ' . $reason ;
359
  }
360
- Debug2::debug( '[Ctrl] Forced cacheable' . $reason ) ;
361
  }
362
 
363
  /**
@@ -367,18 +349,17 @@ class Control extends Instance
367
  * @since 1.1.3
368
  * @param string $reason The reason to no cache
369
  */
370
- public static function set_nocache( $reason = false )
371
- {
372
- self::$_control |= self::BM_NOTCACHEABLE ;
373
 
374
  if ( ! is_string( $reason ) ) {
375
- $reason = false ;
376
  }
377
 
378
  if ( $reason ) {
379
- $reason = "( $reason )" ;
380
  }
381
- Debug2::debug( '[Ctrl] X Cache_control -> no Cache ' . $reason, 2 ) ;
382
  }
383
 
384
  /**
@@ -388,9 +369,8 @@ class Control extends Instance
388
  * @since 1.1.3
389
  * @return bool True if notcacheable bit is set, otherwise false.
390
  */
391
- public static function isset_notcacheable()
392
- {
393
- return self::$_control & self::BM_NOTCACHEABLE ;
394
  }
395
 
396
  /**
@@ -399,9 +379,8 @@ class Control extends Instance
399
  * @access public
400
  * @since 2.2
401
  */
402
- public static function is_forced_cacheable()
403
- {
404
- return self::$_control & self::BM_FORCED_CACHEABLE ;
405
  }
406
 
407
  /**
@@ -411,19 +390,18 @@ class Control extends Instance
411
  * @since 1.1.3
412
  * @return bool True if is still cacheable, otherwise false.
413
  */
414
- public static function is_cacheable()
415
- {
416
  // If its forced public cacheable
417
  if ( self::is_public_forced() ) {
418
- return true ;
419
  }
420
 
421
  // If its forced cacheable
422
  if ( self::is_forced_cacheable() ) {
423
- return true ;
424
  }
425
 
426
- return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE ;
427
  }
428
 
429
  /**
@@ -433,8 +411,7 @@ class Control extends Instance
433
  * @since 1.1.3
434
  * @param mixed $ttl An integer or string to use as the TTL. Must be numeric.
435
  */
436
- public static function set_custom_ttl( $ttl, $reason = false )
437
- {
438
  if ( is_numeric( $ttl ) ) {
439
  self::$_custom_ttl = $ttl;
440
  Debug2::debug( '[Ctrl] X Cache_control TTL -> ' . $ttl . ( $reason ? ' [reason] ' . $ttl : '' ) );
@@ -506,34 +483,33 @@ class Control extends Instance
506
  * @access public
507
  * @since 1.1.3
508
  */
509
- public function check_redirect( $location, $status )
510
- { // TODO: some env don't have SCRIPT_URI but only REQUEST_URI, need to be compatible
511
  if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
512
- Debug2::debug( "[Ctrl] 301 from " . $_SERVER[ 'SCRIPT_URI' ] ) ;
513
- Debug2::debug( "[Ctrl] 301 to $location" ) ;
514
 
515
  $to_check = array(
516
  PHP_URL_SCHEME,
517
  PHP_URL_HOST,
518
  PHP_URL_PATH,
519
- ) ;
520
 
521
- $is_same_redirect = true ;
522
 
523
  foreach ( $to_check as $v ) {
524
  if ( parse_url( $_SERVER[ 'SCRIPT_URI' ], $v ) != parse_url( $location, $v ) ) {
525
- $is_same_redirect = false ;
526
- Debug2::debug( "[Ctrl] 301 different redirection" ) ;
527
- break ;
528
  }
529
  }
530
 
531
  if ( $is_same_redirect ) {
532
- self::set_nocache( '301 to same url' ) ;
533
  }
534
  }
535
 
536
- return $location ;
537
  }
538
 
539
  /**
@@ -543,37 +519,36 @@ class Control extends Instance
543
  * @access public
544
  * @return string empty string if empty, otherwise the cache control header.
545
  */
546
- public static function output()
547
- {
548
- $esi_hdr = '' ;
549
  // Fix cli `uninstall --deactivate` fatal err
550
  if ( ESI::has_esi() ) {
551
- $esi_hdr = ',esi=on' ;
552
  }
553
 
554
- $hdr = self::X_HEADER . ': ' ;
555
 
556
  if ( ! self::is_cacheable() ) {
557
- $hdr .= 'no-cache' . $esi_hdr ;
558
- return $hdr ;
559
  }
560
 
561
  if ( self::is_shared() ) {
562
- $hdr .= 'shared,private' ;
563
  }
564
  elseif ( self::is_private() ) {
565
- $hdr .= 'private' ;
566
  }
567
  else {
568
- $hdr .= 'public' ;
569
  }
570
 
571
  if ( self::is_no_vary() ) {
572
- $hdr .= ',no-vary' ;
573
  }
574
 
575
- $hdr .= ',max-age=' . self::get_ttl() . $esi_hdr ;
576
- return $hdr ;
577
  }
578
 
579
  /**
@@ -582,34 +557,33 @@ class Control extends Instance
582
  * @access public
583
  * @since 1.1.3
584
  */
585
- public static function finalize()
586
- {
587
  // Check if URI is forced public cache
588
- $excludes = Conf::val( Base::O_CACHE_FORCE_PUB_URI ) ;
589
  if ( ! empty( $excludes ) ) {
590
- list( $result, $this_ttl ) = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true ) ;
591
  if ( $result ) {
592
- self::set_public_forced( 'Setting: ' . $result ) ;
593
- Debug2::debug( '[Ctrl] Forced public cacheable due to setting: ' . $result ) ;
594
  if ( $this_ttl ) {
595
- self::set_custom_ttl( $this_ttl ) ;
596
  }
597
  }
598
  }
599
 
600
  if ( self::is_public_forced() ) {
601
- return ;
602
  }
603
 
604
  // Check if URI is forced cache
605
- $excludes = Conf::val( Base::O_CACHE_FORCE_URI ) ;
606
  if ( ! empty( $excludes ) ) {
607
- list( $result, $this_ttl ) = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true ) ;
608
  if ( $result ) {
609
- self::force_cacheable() ;
610
- Debug2::debug( '[Ctrl] Forced cacheable due to setting: ' . $result ) ;
611
  if ( $this_ttl ) {
612
- self::set_custom_ttl( $this_ttl ) ;
613
  }
614
  }
615
  }
@@ -617,44 +591,44 @@ class Control extends Instance
617
  // if is not cacheable, terminate check
618
  // Even no need to run 3rd party hook
619
  if ( ! self::is_cacheable() ) {
620
- Debug2::debug( '[Ctrl] not cacheable before ctrl finalize' ) ;
621
- return ;
622
  }
623
 
624
  if ( defined('LSCACHE_NO_CACHE') && LSCACHE_NO_CACHE ) {
625
- self::set_nocache('LSCACHE_NO_CACHE constant defined') ;
626
- return ;
627
  }
628
 
629
- $instance = self::get_instance() ;
630
 
631
  // Apply 3rd party filter
632
  // NOTE: Hook always needs to run asap because some 3rd party set is_mobile in this hook
633
- do_action('litespeed_control_finalize', defined( 'LSCACHE_IS_ESI' ) ? LSCACHE_IS_ESI : false ) ; // Pass ESI block id
634
 
635
  // if is not cacheable, terminate check
636
  if ( ! self::is_cacheable() ) {
637
- Debug2::debug( '[Ctrl] not cacheable after api_control' ) ;
638
- return ;
639
  }
640
 
641
  if ( is_preview() ) {
642
- self::set_nocache( 'preview page' ) ;
643
- return ;
644
  }
645
 
646
  // Check litespeed setting to set cacheable status
647
  if ( ! $instance->_setting_cacheable() ) {
648
- self::set_nocache() ;
649
- return ;
650
  }
651
 
652
  // If user has password cookie, do not cache (moved from vary)
653
- global $post ;
654
  if ( ! empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
655
  // If user has password cookie, do not cache
656
- self::set_nocache('pswd cookie') ;
657
- return ;
658
  }
659
 
660
  // The following check to the end is ONLY for mobile
@@ -685,8 +659,7 @@ class Control extends Instance
685
  * @since 3.0
686
  * @access public
687
  */
688
- public static function is_mobile()
689
- {
690
  return wp_is_mobile();
691
  }
692
 
@@ -697,93 +670,92 @@ class Control extends Instance
697
  * @access private
698
  * @return boolean True if cacheable, false otherwise.
699
  */
700
- private function _setting_cacheable()
701
- {
702
  // logged_in users already excluded, no hook added
703
 
704
  if( ! empty( $_REQUEST[ Router::ACTION ] ) ) {
705
- return $this->_no_cache_for( 'Query String Action' ) ;
706
  }
707
 
708
  if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
709
- return $this->_no_cache_for('not GET method:' . $_SERVER["REQUEST_METHOD"]) ;
710
  }
711
 
712
  if ( is_feed() && Conf::val( Base::O_CACHE_TTL_FEED ) == 0 ) {
713
- return $this->_no_cache_for('feed') ;
714
  }
715
 
716
  if ( is_trackback() ) {
717
- return $this->_no_cache_for('trackback') ;
718
  }
719
 
720
  if ( is_search() ) {
721
- return $this->_no_cache_for('search') ;
722
  }
723
 
724
  // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
725
- // return $this->_no_cache_for('no theme used') ;
726
  // }
727
 
728
  // Check private cache URI setting
729
- $excludes = Conf::val( Base::O_CACHE_PRIV_URI ) ;
730
  if ( ! empty( $excludes ) ) {
731
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
732
  if ( $result ) {
733
- self::set_private( 'Admin cfg Private Cached URI: ' . $result ) ;
734
  }
735
  }
736
 
737
  if ( ! self::is_forced_cacheable() ) {
738
 
739
  // Check if URI is excluded from cache
740
- $excludes = Conf::val( Base::O_CACHE_EXC ) ;
741
  if ( ! empty( $excludes ) ) {
742
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
743
  if ( $result ) {
744
- return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result ) ;
745
  }
746
  }
747
 
748
  // Check QS excluded setting
749
- $excludes = Conf::val( Base::O_CACHE_EXC_QS ) ;
750
  if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( $excludes ) ) {
751
- return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs ) ;
752
  }
753
 
754
- $excludes = Conf::val( Base::O_CACHE_EXC_CAT ) ;
755
  if ( ! empty( $excludes ) && has_category( $excludes ) ) {
756
- return $this->_no_cache_for( 'Admin configured Category Do not cache.' ) ;
757
  }
758
 
759
- $excludes = Conf::val( Base::O_CACHE_EXC_TAG ) ;
760
  if ( ! empty( $excludes ) && has_tag( $excludes ) ) {
761
- return $this->_no_cache_for( 'Admin configured Tag Do not cache.' ) ;
762
  }
763
 
764
- $excludes = Conf::val( Base::O_CACHE_EXC_COOKIES ) ;
765
  if ( ! empty( $excludes ) && ! empty( $_COOKIE ) ) {
766
- $cookie_hit = array_intersect( array_keys( $_COOKIE ), $excludes ) ;
767
  if ( $cookie_hit ) {
768
- return $this->_no_cache_for( 'Admin configured Cookie Do not cache.' ) ;
769
  }
770
  }
771
 
772
- $excludes = Conf::val( Base::O_CACHE_EXC_USERAGENTS ) ;
773
  if ( ! empty( $excludes ) && isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
774
- $nummatches = preg_match( Utility::arr2regex( $excludes ), $_SERVER[ 'HTTP_USER_AGENT' ] ) ;
775
  if ( $nummatches ) {
776
- return $this->_no_cache_for('Admin configured User Agent Do not cache.') ;
777
  }
778
  }
779
 
780
  // Check if is exclude roles ( Need to set Vary too )
781
  if ( $result = $this->in_cache_exc_roles() ) {
782
- return $this->_no_cache_for( 'Role Excludes setting ' . $result ) ;
783
  }
784
  }
785
 
786
- return true ;
787
  }
788
 
789
  /**
@@ -794,10 +766,9 @@ class Control extends Instance
794
  * @param string $reason An explanation for why the page is not cacheable.
795
  * @return boolean Return false.
796
  */
797
- private function _no_cache_for( $reason )
798
- {
799
- Debug2::debug('[Ctrl] X Cache_control off - ' . $reason) ;
800
- return false ;
801
  }
802
 
803
  /**
@@ -808,12 +779,11 @@ class Control extends Instance
808
  * @param array $excludes QS excludes setting
809
  * @return boolean|string False if not excluded, otherwise the hit qs list
810
  */
811
- private function _is_qs_excluded( $excludes )
812
- {
813
  if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
814
- return implode( ',', $intersect ) ;
815
  }
816
- return false ;
817
  }
818
 
819
  }
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
+ namespace LiteSpeed;
12
 
13
+ defined( 'WPINC' ) || exit;
14
 
15
+ class Control extends Instance {
16
+ protected static $_instance;
 
17
 
18
+ const BM_CACHEABLE = 1;
19
+ const BM_PRIVATE = 2;
20
+ const BM_SHARED = 4;
21
+ const BM_NO_VARY = 8;
22
+ const BM_FORCED_CACHEABLE = 32;
23
+ const BM_PUBLIC_FORCED = 64;
24
+ const BM_STALE = 128;
25
+ const BM_NOTCACHEABLE = 256;
26
 
27
+ const X_HEADER = 'X-LiteSpeed-Cache-Control';
28
 
29
+ protected static $_control = 0;
30
+ protected static $_custom_ttl = 0;
31
 
32
+ private $_response_header_ttls = array();
33
 
34
  /**
35
  * Init cache control
37
  * @since 1.6.2
38
  * @access protected
39
  */
40
+ protected function __construct() {
 
41
  /**
42
  * Add vary filter for Role Excludes
43
  * @since 1.6.2
44
  */
45
+ add_filter( 'litespeed_vary', array( $this, 'vary_add_role_exclude' ) );
46
 
47
  // 301 redirect hook
48
+ add_filter( 'wp_redirect', array( $this, 'check_redirect' ), 10, 2 );
49
 
50
  // Load response header conf
51
+ $this->_response_header_ttls = Conf::val( Base::O_CACHE_TTL_STATUS );
52
  foreach ( $this->_response_header_ttls as $k => $v ) {
53
+ $v = explode( ' ', $v );
54
  if ( empty( $v[ 0 ] ) || empty( $v[ 1 ] ) ) {
55
+ continue;
56
  }
57
+ $this->_response_header_ttls[ $v[ 0 ] ] = $v[ 1 ];
58
  }
59
 
60
  if ( Conf::val( Base::O_PURGE_STALE ) ) {
68
  * @since 1.6.2
69
  * @access public
70
  */
71
+ public function vary_add_role_exclude( $vary ) {
 
72
  if ( $this->in_cache_exc_roles() ) {
73
  $vary[ 'role_exclude_cache' ] = 1;
74
  }
85
  * @param string $role The user role
86
  * @return int The set value if already set
87
  */
88
+ public function in_cache_exc_roles( $role = null ) {
 
89
  // Get user role
90
  if ( $role === null ) {
91
+ $role = Router::get_role();
92
  }
93
 
94
  if ( ! $role ) {
95
+ return false;
96
  }
97
 
98
+ return in_array( $role, Conf::val( Base::O_CACHE_EXC_ROLES ) ) ? $role : false;
99
  }
100
 
101
  /**
105
  * @since 1.1.3
106
  * @access public
107
  */
108
+ public static function init_cacheable() {
 
109
  // Hook `wp` to mark default cacheable status
110
  // NOTE: Any process that does NOT run into `wp` hook will not get cacheable by default
111
+ add_action( 'wp', __CLASS__ . '::set_cacheable', 5 );
112
 
113
  // Hook WP REST to be cacheable
114
  if ( Conf::val( Base::O_CACHE_REST ) ) {
115
+ add_action( 'rest_api_init', __CLASS__ . '::set_cacheable', 5 );
116
  }
117
 
118
  // Cache resources
119
  // NOTE: If any strange resource doesn't use normal WP logic `wp_loaded` hook, rewrite rule can handle it
120
+ $cache_res = Conf::val( Base::O_CACHE_RES );
121
  if ( $cache_res ) {
122
+ $uri = esc_url( $_SERVER["REQUEST_URI"] );// todo: check if need esc_url()
123
+ $pattern = '!' . LSCWP_CONTENT_FOLDER . Htaccess::RW_PATTERN_RES . '!';
124
  if ( preg_match( $pattern, $uri ) ) {
125
+ add_action( 'wp_loaded', __CLASS__ . '::set_cacheable', 5 );
126
  }
127
  }
128
 
129
  // Check error page
130
+ add_filter( 'status_header', array( self::get_instance(), 'check_error_codes' ), 10, 2 );
131
  }
132
 
133
 
140
  * @param $code
141
  * @return $eror_status
142
  */
143
+ public function check_error_codes( $status_header, $code ) {
 
144
  if ( array_key_exists( $code, $this->_response_header_ttls ) ) {
145
  if ( self::is_cacheable() && ! $this->_response_header_ttls[ $code ] ) {
146
+ self::set_nocache( '[Ctrl] TTL is set to no cache [status_header] ' . $code );
147
  }
148
 
149
  // Set TTL
150
+ self::set_custom_ttl( $this->_response_header_ttls[ $code ] );
151
  }
152
 
153
  // Set cache tag
154
+ Tag::add( Tag::TYPE_HTTP . $code );
155
 
156
  // Give the default status_header back
157
+ return $status_header;
158
  }
159
 
160
  /**
163
  * @access public
164
  * @since 1.1.3
165
  */
166
+ public static function set_no_vary() {
 
167
  if ( self::is_no_vary() ) {
168
+ return;
169
  }
170
+ self::$_control |= self::BM_NO_VARY;
171
+ Debug2::debug( '[Ctrl] X Cache_control -> no-vary', 3 );
172
  }
173
 
174
  /**
177
  * @access public
178
  * @since 1.1.3
179
  */
180
+ public static function is_no_vary() {
181
+ return self::$_control & self::BM_NO_VARY;
 
182
  }
183
 
184
  /**
187
  * @access public
188
  * @since 1.1.3
189
  */
190
+ public static function set_stale() {
 
191
  if ( self::is_stale() ) {
192
+ return;
193
  }
194
+ self::$_control |= self::BM_STALE;
195
+ Debug2::debug('[Ctrl] X Cache_control -> stale');
196
  }
197
 
198
  /**
201
  * @access public
202
  * @since 1.1.3
203
  */
204
+ public static function is_stale() {
205
+ return self::$_control & self::BM_STALE;
 
206
  }
207
 
208
  /**
212
  * @since 1.1.3
213
  * @param string $reason The reason to no cache
214
  */
215
+ public static function set_shared( $reason = false ) {
 
216
  if ( self::is_shared() ) {
217
+ return;
218
  }
219
+ self::$_control |= self::BM_SHARED;
220
+ self::set_private();
221
 
222
  if ( ! is_string( $reason ) ) {
223
+ $reason = false;
224
  }
225
 
226
  if ( $reason ) {
227
+ $reason = "( $reason )";
228
  }
229
+ Debug2::debug( '[Ctrl] X Cache_control -> shared ' . $reason );
230
  }
231
 
232
  /**
235
  * @access public
236
  * @since 1.1.3
237
  */
238
+ public static function is_shared() {
239
+ return (self::$_control & self::BM_SHARED) && self::is_private();
 
240
  }
241
 
242
  /**
245
  * @access public
246
  * @since 1.7.1
247
  */
248
+ public static function set_public_forced( $reason = false ) {
 
249
  if ( self::is_public_forced() ) {
250
+ return;
251
  }
252
+ self::$_control |= self::BM_PUBLIC_FORCED;
253
 
254
  if ( ! is_string( $reason ) ) {
255
+ $reason = false;
256
  }
257
 
258
  if ( $reason ) {
259
+ $reason = "( $reason )";
260
  }
261
+ Debug2::debug( '[Ctrl] X Cache_control -> public forced ' . $reason );
262
  }
263
 
264
  /**
267
  * @access public
268
  * @since 1.7.1
269
  */
270
+ public static function is_public_forced() {
271
+ return self::$_control & self::BM_PUBLIC_FORCED;
 
272
  }
273
 
274
  /**
278
  * @since 1.1.3
279
  * @param string $reason The reason to no cache
280
  */
281
+ public static function set_private( $reason = false ) {
 
282
  if ( self::is_private() ) {
283
+ return;
284
  }
285
+ self::$_control |= self::BM_PRIVATE;
286
 
287
  if ( ! is_string( $reason ) ) {
288
+ $reason = false;
289
  }
290
 
291
  if ( $reason ) {
292
+ $reason = "( $reason )";
293
  }
294
+ Debug2::debug( '[Ctrl] X Cache_control -> private ' . $reason );
295
  }
296
 
297
  /**
300
  * @access public
301
  * @since 1.1.3
302
  */
303
+ public static function is_private() {
304
+ return self::$_control & self::BM_PRIVATE && ! self::is_public_forced();
 
305
  }
306
 
307
  /**
310
  * @access public
311
  * @since 1.1.3
312
  */
313
+ public static function set_cacheable( $reason = false ) {
314
+ self::$_control |= self::BM_CACHEABLE;
 
315
 
316
  if ( ! is_string( $reason ) ) {
317
+ $reason = false;
318
  }
319
 
320
  if ( $reason ) {
321
+ $reason = ' [reason] ' . $reason;
322
  }
323
+ Debug2::debug( '[Ctrl] X Cache_control init on' . $reason );
324
  }
325
 
326
  /**
329
  * @access public
330
  * @since 2.2
331
  */
332
+ public static function force_cacheable( $reason = false ) {
333
+ self::$_control |= self::BM_FORCED_CACHEABLE;
 
334
 
335
  if ( ! is_string( $reason ) ) {
336
+ $reason = false;
337
  }
338
 
339
  if ( $reason ) {
340
+ $reason = ' [reason] ' . $reason;
341
  }
342
+ Debug2::debug( '[Ctrl] Forced cacheable' . $reason );
343
  }
344
 
345
  /**
349
  * @since 1.1.3
350
  * @param string $reason The reason to no cache
351
  */
352
+ public static function set_nocache( $reason = false ) {
353
+ self::$_control |= self::BM_NOTCACHEABLE;
 
354
 
355
  if ( ! is_string( $reason ) ) {
356
+ $reason = false;
357
  }
358
 
359
  if ( $reason ) {
360
+ $reason = "( $reason )";
361
  }
362
+ Debug2::debug( '[Ctrl] X Cache_control -> no Cache ' . $reason, 2 );
363
  }
364
 
365
  /**
369
  * @since 1.1.3
370
  * @return bool True if notcacheable bit is set, otherwise false.
371
  */
372
+ public static function isset_notcacheable() {
373
+ return self::$_control & self::BM_NOTCACHEABLE;
 
374
  }
375
 
376
  /**
379
  * @access public
380
  * @since 2.2
381
  */
382
+ public static function is_forced_cacheable() {
383
+ return self::$_control & self::BM_FORCED_CACHEABLE;
 
384
  }
385
 
386
  /**
390
  * @since 1.1.3
391
  * @return bool True if is still cacheable, otherwise false.
392
  */
393
+ public static function is_cacheable() {
 
394
  // If its forced public cacheable
395
  if ( self::is_public_forced() ) {
396
+ return true;
397
  }
398
 
399
  // If its forced cacheable
400
  if ( self::is_forced_cacheable() ) {
401
+ return true;
402
  }
403
 
404
+ return ! self::isset_notcacheable() && self::$_control & self::BM_CACHEABLE;
405
  }
406
 
407
  /**
411
  * @since 1.1.3
412
  * @param mixed $ttl An integer or string to use as the TTL. Must be numeric.
413
  */
414
+ public static function set_custom_ttl( $ttl, $reason = false ) {
 
415
  if ( is_numeric( $ttl ) ) {
416
  self::$_custom_ttl = $ttl;
417
  Debug2::debug( '[Ctrl] X Cache_control TTL -> ' . $ttl . ( $reason ? ' [reason] ' . $ttl : '' ) );
483
  * @access public
484
  * @since 1.1.3
485
  */
486
+ public function check_redirect( $location, $status ) { // TODO: some env don't have SCRIPT_URI but only REQUEST_URI, need to be compatible
 
487
  if ( ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ) { // dont check $status == '301' anymore
488
+ Debug2::debug( "[Ctrl] 301 from " . $_SERVER[ 'SCRIPT_URI' ] );
489
+ Debug2::debug( "[Ctrl] 301 to $location" );
490
 
491
  $to_check = array(
492
  PHP_URL_SCHEME,
493
  PHP_URL_HOST,
494
  PHP_URL_PATH,
495
+ );
496
 
497
+ $is_same_redirect = true;
498
 
499
  foreach ( $to_check as $v ) {
500
  if ( parse_url( $_SERVER[ 'SCRIPT_URI' ], $v ) != parse_url( $location, $v ) ) {
501
+ $is_same_redirect = false;
502
+ Debug2::debug( "[Ctrl] 301 different redirection" );
503
+ break;
504
  }
505
  }
506
 
507
  if ( $is_same_redirect ) {
508
+ self::set_nocache( '301 to same url' );
509
  }
510
  }
511
 
512
+ return $location;
513
  }
514
 
515
  /**
519
  * @access public
520
  * @return string empty string if empty, otherwise the cache control header.
521
  */
522
+ public static function output() {
523
+ $esi_hdr = '';
 
524
  // Fix cli `uninstall --deactivate` fatal err
525
  if ( ESI::has_esi() ) {
526
+ $esi_hdr = ',esi=on';
527
  }
528
 
529
+ $hdr = self::X_HEADER . ': ';
530
 
531
  if ( ! self::is_cacheable() ) {
532
+ $hdr .= 'no-cache' . $esi_hdr;
533
+ return $hdr;
534
  }
535
 
536
  if ( self::is_shared() ) {
537
+ $hdr .= 'shared,private';
538
  }
539
  elseif ( self::is_private() ) {
540
+ $hdr .= 'private';
541
  }
542
  else {
543
+ $hdr .= 'public';
544
  }
545
 
546
  if ( self::is_no_vary() ) {
547
+ $hdr .= ',no-vary';
548
  }
549
 
550
+ $hdr .= ',max-age=' . self::get_ttl() . $esi_hdr;
551
+ return $hdr;
552
  }
553
 
554
  /**
557
  * @access public
558
  * @since 1.1.3
559
  */
560
+ public static function finalize() {
 
561
  // Check if URI is forced public cache
562
+ $excludes = Conf::val( Base::O_CACHE_FORCE_PUB_URI );
563
  if ( ! empty( $excludes ) ) {
564
+ list( $result, $this_ttl ) = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true );
565
  if ( $result ) {
566
+ self::set_public_forced( 'Setting: ' . $result );
567
+ Debug2::debug( '[Ctrl] Forced public cacheable due to setting: ' . $result );
568
  if ( $this_ttl ) {
569
+ self::set_custom_ttl( $this_ttl );
570
  }
571
  }
572
  }
573
 
574
  if ( self::is_public_forced() ) {
575
+ return;
576
  }
577
 
578
  // Check if URI is forced cache
579
+ $excludes = Conf::val( Base::O_CACHE_FORCE_URI );
580
  if ( ! empty( $excludes ) ) {
581
+ list( $result, $this_ttl ) = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes, true );
582
  if ( $result ) {
583
+ self::force_cacheable();
584
+ Debug2::debug( '[Ctrl] Forced cacheable due to setting: ' . $result );
585
  if ( $this_ttl ) {
586
+ self::set_custom_ttl( $this_ttl );
587
  }
588
  }
589
  }
591
  // if is not cacheable, terminate check
592
  // Even no need to run 3rd party hook
593
  if ( ! self::is_cacheable() ) {
594
+ Debug2::debug( '[Ctrl] not cacheable before ctrl finalize' );
595
+ return;
596
  }
597
 
598
  if ( defined('LSCACHE_NO_CACHE') && LSCACHE_NO_CACHE ) {
599
+ self::set_nocache('LSCACHE_NO_CACHE constant defined');
600
+ return;
601
  }
602
 
603
+ $instance = self::get_instance();
604
 
605
  // Apply 3rd party filter
606
  // NOTE: Hook always needs to run asap because some 3rd party set is_mobile in this hook
607
+ do_action('litespeed_control_finalize', defined( 'LSCACHE_IS_ESI' ) ? LSCACHE_IS_ESI : false ); // Pass ESI block id
608
 
609
  // if is not cacheable, terminate check
610
  if ( ! self::is_cacheable() ) {
611
+ Debug2::debug( '[Ctrl] not cacheable after api_control' );
612
+ return;
613
  }
614
 
615
  if ( is_preview() ) {
616
+ self::set_nocache( 'preview page' );
617
+ return;
618
  }
619
 
620
  // Check litespeed setting to set cacheable status
621
  if ( ! $instance->_setting_cacheable() ) {
622
+ self::set_nocache();
623
+ return;
624
  }
625
 
626
  // If user has password cookie, do not cache (moved from vary)
627
+ global $post;
628
  if ( ! empty($post->post_password) && isset($_COOKIE['wp-postpass_' . COOKIEHASH]) ) {
629
  // If user has password cookie, do not cache
630
+ self::set_nocache('pswd cookie');
631
+ return;
632
  }
633
 
634
  // The following check to the end is ONLY for mobile
659
  * @since 3.0
660
  * @access public
661
  */
662
+ public static function is_mobile() {
 
663
  return wp_is_mobile();
664
  }
665
 
670
  * @access private
671
  * @return boolean True if cacheable, false otherwise.
672
  */
673
+ private function _setting_cacheable() {
 
674
  // logged_in users already excluded, no hook added
675
 
676
  if( ! empty( $_REQUEST[ Router::ACTION ] ) ) {
677
+ return $this->_no_cache_for( 'Query String Action' );
678
  }
679
 
680
  if ( $_SERVER["REQUEST_METHOD"] !== 'GET' ) {
681
+ return $this->_no_cache_for('not GET method:' . $_SERVER["REQUEST_METHOD"]);
682
  }
683
 
684
  if ( is_feed() && Conf::val( Base::O_CACHE_TTL_FEED ) == 0 ) {
685
+ return $this->_no_cache_for('feed');
686
  }
687
 
688
  if ( is_trackback() ) {
689
+ return $this->_no_cache_for('trackback');
690
  }
691
 
692
  if ( is_search() ) {
693
+ return $this->_no_cache_for('search');
694
  }
695
 
696
  // if ( !defined('WP_USE_THEMES') || !WP_USE_THEMES ) {
697
+ // return $this->_no_cache_for('no theme used');
698
  // }
699
 
700
  // Check private cache URI setting
701
+ $excludes = Conf::val( Base::O_CACHE_PRIV_URI );
702
  if ( ! empty( $excludes ) ) {
703
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes );
704
  if ( $result ) {
705
+ self::set_private( 'Admin cfg Private Cached URI: ' . $result );
706
  }
707
  }
708
 
709
  if ( ! self::is_forced_cacheable() ) {
710
 
711
  // Check if URI is excluded from cache
712
+ $excludes = Conf::val( Base::O_CACHE_EXC );
713
  if ( ! empty( $excludes ) ) {
714
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes );
715
  if ( $result ) {
716
+ return $this->_no_cache_for( 'Admin configured URI Do not cache: ' . $result );
717
  }
718
  }
719
 
720
  // Check QS excluded setting
721
+ $excludes = Conf::val( Base::O_CACHE_EXC_QS );
722
  if ( ! empty( $excludes ) && $qs = $this->_is_qs_excluded( $excludes ) ) {
723
+ return $this->_no_cache_for( 'Admin configured QS Do not cache: ' . $qs );
724
  }
725
 
726
+ $excludes = Conf::val( Base::O_CACHE_EXC_CAT );
727
  if ( ! empty( $excludes ) && has_category( $excludes ) ) {
728
+ return $this->_no_cache_for( 'Admin configured Category Do not cache.' );
729
  }
730
 
731
+ $excludes = Conf::val( Base::O_CACHE_EXC_TAG );
732
  if ( ! empty( $excludes ) && has_tag( $excludes ) ) {
733
+ return $this->_no_cache_for( 'Admin configured Tag Do not cache.' );
734
  }
735
 
736
+ $excludes = Conf::val( Base::O_CACHE_EXC_COOKIES );
737
  if ( ! empty( $excludes ) && ! empty( $_COOKIE ) ) {
738
+ $cookie_hit = array_intersect( array_keys( $_COOKIE ), $excludes );
739
  if ( $cookie_hit ) {
740
+ return $this->_no_cache_for( 'Admin configured Cookie Do not cache.' );
741
  }
742
  }
743
 
744
+ $excludes = Conf::val( Base::O_CACHE_EXC_USERAGENTS );
745
  if ( ! empty( $excludes ) && isset( $_SERVER[ 'HTTP_USER_AGENT' ] ) ) {
746
+ $nummatches = preg_match( Utility::arr2regex( $excludes ), $_SERVER[ 'HTTP_USER_AGENT' ] );
747
  if ( $nummatches ) {
748
+ return $this->_no_cache_for('Admin configured User Agent Do not cache.');
749
  }
750
  }
751
 
752
  // Check if is exclude roles ( Need to set Vary too )
753
  if ( $result = $this->in_cache_exc_roles() ) {
754
+ return $this->_no_cache_for( 'Role Excludes setting ' . $result );
755
  }
756
  }
757
 
758
+ return true;
759
  }
760
 
761
  /**
766
  * @param string $reason An explanation for why the page is not cacheable.
767
  * @return boolean Return false.
768
  */
769
+ private function _no_cache_for( $reason ) {
770
+ Debug2::debug('[Ctrl] X Cache_control off - ' . $reason);
771
+ return false;
 
772
  }
773
 
774
  /**
779
  * @param array $excludes QS excludes setting
780
  * @return boolean|string False if not excluded, otherwise the hit qs list
781
  */
782
+ private function _is_qs_excluded( $excludes ) {
 
783
  if ( ! empty( $_GET ) && $intersect = array_intersect( array_keys( $_GET ), $excludes ) ) {
784
+ return implode( ',', $intersect );
785
  }
786
+ return false;
787
  }
788
 
789
  }
src/core.cls.php CHANGED
@@ -7,8 +7,7 @@
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
- class Core extends Instance
11
- {
12
  protected static $_instance;
13
 
14
  const NAME = 'LiteSpeed Cache';
@@ -43,8 +42,7 @@ class Core extends Instance
43
  *
44
  * @since 1.0.0
45
  */
46
- protected function __construct()
47
- {
48
  $this->__cfg = Conf::get_instance();
49
  $this->__cfg->init();
50
 
@@ -107,8 +105,7 @@ class Core extends Instance
107
  * Plugin loaded hooks
108
  * @since 3.0
109
  */
110
- public function plugins_loaded()
111
- {
112
  load_plugin_textdomain( Core::PLUGIN_NAME, false, 'litespeed-cache/lang/' );
113
  }
114
 
@@ -122,8 +119,7 @@ class Core extends Instance
122
  * @since 1.0.0
123
  * @access public
124
  */
125
- public function init()
126
- {
127
  /**
128
  * Added hook before init
129
  * @since 1.6.6
@@ -188,8 +184,7 @@ class Core extends Instance
188
  * @since 2.9.8
189
  * @access public
190
  */
191
- public function after_user_init()
192
- {
193
  Router::get_instance()->is_role_simulation();
194
 
195
  if ( ! is_admin() && $result = $this->__cfg->in_optm_exc_roles() ) {
@@ -235,8 +230,7 @@ class Core extends Instance
235
  * @since 1.1.0
236
  * @access public
237
  */
238
- public function proceed_action( $action )
239
- {
240
  $msg = false;
241
  // handle actions
242
  switch ( $action ) {
@@ -295,8 +289,7 @@ class Core extends Instance
295
  * @since 1.0.5
296
  * @access public
297
  */
298
- public function load_thirdparty()
299
- {
300
  do_action( 'litespeed_load_thirdparty' );
301
  }
302
 
@@ -306,8 +299,7 @@ class Core extends Instance
306
  * @since 1.3
307
  * @access public
308
  */
309
- public function footer_hook()
310
- {
311
  Debug2::debug( '[Core] Footer hook called' );
312
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
313
  define( 'LITESPEED_FOOTER_CALLED', true );
@@ -320,8 +312,7 @@ class Core extends Instance
320
  * @since 1.3
321
  * @access private
322
  */
323
- private function _check_is_html( $buffer = null )
324
- {
325
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
326
  Debug2::debug2( '[Core] CHK html bypass: miss footer const' );
327
  return;
@@ -381,8 +372,7 @@ class Core extends Instance
381
  * @param string $buffer
382
  * @return string
383
  */
384
- public function send_headers_force( $buffer )
385
- {
386
  $this->_check_is_html( $buffer );
387
 
388
  // Hook to modify buffer before
@@ -463,8 +453,7 @@ class Core extends Instance
463
  * @access public
464
  * @param boolean $is_forced If the header is sent following our normal finalizing logic
465
  */
466
- public function send_headers( $is_forced = false )
467
- {
468
  // Make sure header output only run once
469
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
470
  define( 'LITESPEED_DID_' . __FUNCTION__, true );
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
+ class Core extends Instance {
 
11
  protected static $_instance;
12
 
13
  const NAME = 'LiteSpeed Cache';
42
  *
43
  * @since 1.0.0
44
  */
45
+ protected function __construct() {
 
46
  $this->__cfg = Conf::get_instance();
47
  $this->__cfg->init();
48
 
105
  * Plugin loaded hooks
106
  * @since 3.0
107
  */
108
+ public function plugins_loaded() {
 
109
  load_plugin_textdomain( Core::PLUGIN_NAME, false, 'litespeed-cache/lang/' );
110
  }
111
 
119
  * @since 1.0.0
120
  * @access public
121
  */
122
+ public function init() {
 
123
  /**
124
  * Added hook before init
125
  * @since 1.6.6
184
  * @since 2.9.8
185
  * @access public
186
  */
187
+ public function after_user_init() {
 
188
  Router::get_instance()->is_role_simulation();
189
 
190
  if ( ! is_admin() && $result = $this->__cfg->in_optm_exc_roles() ) {
230
  * @since 1.1.0
231
  * @access public
232
  */
233
+ public function proceed_action( $action ) {
 
234
  $msg = false;
235
  // handle actions
236
  switch ( $action ) {
289
  * @since 1.0.5
290
  * @access public
291
  */
292
+ public function load_thirdparty() {
 
293
  do_action( 'litespeed_load_thirdparty' );
294
  }
295
 
299
  * @since 1.3
300
  * @access public
301
  */
302
+ public function footer_hook() {
 
303
  Debug2::debug( '[Core] Footer hook called' );
304
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
305
  define( 'LITESPEED_FOOTER_CALLED', true );
312
  * @since 1.3
313
  * @access private
314
  */
315
+ private function _check_is_html( $buffer = null ) {
 
316
  if ( ! defined( 'LITESPEED_FOOTER_CALLED' ) ) {
317
  Debug2::debug2( '[Core] CHK html bypass: miss footer const' );
318
  return;
372
  * @param string $buffer
373
  * @return string
374
  */
375
+ public function send_headers_force( $buffer ) {
 
376
  $this->_check_is_html( $buffer );
377
 
378
  // Hook to modify buffer before
453
  * @access public
454
  * @param boolean $is_forced If the header is sent following our normal finalizing logic
455
  */
456
+ public function send_headers( $is_forced = false ) {
 
457
  // Make sure header output only run once
458
  if ( ! defined( 'LITESPEED_DID_' . __FUNCTION__ ) ) {
459
  define( 'LITESPEED_DID_' . __FUNCTION__, true );
src/crawler-map.cls.php CHANGED
@@ -7,8 +7,7 @@
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
- class Crawler_Map extends Instance
11
- {
12
  const BM_MISS = 1;
13
  const BM_HIT = 2;
14
  const BM_BLACKLIST = 4;
@@ -27,8 +26,7 @@ class Crawler_Map extends Instance
27
  * @since 1.1.0
28
  * @access protected
29
  */
30
- protected function __construct()
31
- {
32
  $this->_home_url = get_home_url();
33
  $this->__data = Data::get_instance();
34
  $this->_tb = $this->__data->tb( 'crawler' );
@@ -42,8 +40,7 @@ class Crawler_Map extends Instance
42
  * @since 3.0
43
  * @access public
44
  */
45
- public function save_map_status( $list, $curr_crawler )
46
- {
47
  global $wpdb;
48
  Utility::compatibility();
49
 
@@ -143,8 +140,7 @@ class Crawler_Map extends Instance
143
  * @since 3.0
144
  * @access public
145
  */
146
- public function blacklist_add( $id )
147
- {
148
  global $wpdb;
149
 
150
  $id = (int)$id;
@@ -183,8 +179,7 @@ class Crawler_Map extends Instance
183
  * @since 3.0
184
  * @access public
185
  */
186
- public function blacklist_del( $id )
187
- {
188
  global $wpdb;
189
 
190
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
@@ -206,8 +201,7 @@ class Crawler_Map extends Instance
206
  * @since 3.0
207
  * @access public
208
  */
209
- public function blacklist_empty()
210
- {
211
  global $wpdb;
212
 
213
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
@@ -227,8 +221,7 @@ class Crawler_Map extends Instance
227
  * @since 3.0
228
  * @access public
229
  */
230
- public function list_blacklist( $limit = false, $offset = false )
231
- {
232
  global $wpdb;
233
 
234
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
@@ -252,8 +245,7 @@ class Crawler_Map extends Instance
252
  /**
253
  * Count blacklist
254
  */
255
- public function count_blacklist()
256
- {
257
  global $wpdb;
258
 
259
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
@@ -270,8 +262,7 @@ class Crawler_Map extends Instance
270
  * @since 3.0
271
  * @access public
272
  */
273
- public function empty_map()
274
- {
275
  Data::get_instance()->tb_del( 'crawler' );
276
 
277
  $msg = __( 'Sitemap cleaned successfully', 'litespeed-cache' );
@@ -284,8 +275,7 @@ class Crawler_Map extends Instance
284
  * @since 3.0
285
  * @access public
286
  */
287
- public function list_map( $limit, $offset = false )
288
- {
289
  global $wpdb;
290
 
291
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
@@ -306,8 +296,7 @@ class Crawler_Map extends Instance
306
  /**
307
  * Count sitemap
308
  */
309
- public function count_map()
310
- {
311
  global $wpdb;
312
 
313
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
@@ -324,8 +313,7 @@ class Crawler_Map extends Instance
324
  * @since 1.1.0
325
  * @access public
326
  */
327
- public function gen()
328
- {
329
  $urls = $this->_gen();
330
 
331
  $msg = sprintf( __( 'Sitemap created successfully: %d items', 'litespeed-cache' ), $urls );
@@ -338,8 +326,7 @@ class Crawler_Map extends Instance
338
  * @since 1.1.0
339
  * @access private
340
  */
341
- private function _gen()
342
- {
343
  global $wpdb;
344
 
345
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
@@ -438,8 +425,7 @@ class Crawler_Map extends Instance
438
  * @since 3.0
439
  * @access private
440
  */
441
- private function _save( $data, $fields = 'url,res,reason' )
442
- {
443
  global $wpdb;
444
 
445
  if ( empty( $data ) ) {
@@ -461,8 +447,7 @@ class Crawler_Map extends Instance
461
  * @since 1.1.1
462
  * @access private
463
  */
464
- private function _parse( $sitemap, $return_detail = true )
465
- {
466
  /**
467
  * Read via wp func to avoid allow_url_fopen = off
468
  * @since 2.2.7
@@ -537,8 +522,7 @@ class Crawler_Map extends Instance
537
  * @since 1.1.0
538
  * @access private
539
  */
540
- private function _build($blacklist = array())
541
- {
542
  global $wpdb;
543
 
544
  $show_pages = Conf::val( Base::O_CRAWLER_PAGES );
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
+ class Crawler_Map extends Instance {
 
11
  const BM_MISS = 1;
12
  const BM_HIT = 2;
13
  const BM_BLACKLIST = 4;
26
  * @since 1.1.0
27
  * @access protected
28
  */
29
+ protected function __construct() {
 
30
  $this->_home_url = get_home_url();
31
  $this->__data = Data::get_instance();
32
  $this->_tb = $this->__data->tb( 'crawler' );
40
  * @since 3.0
41
  * @access public
42
  */
43
+ public function save_map_status( $list, $curr_crawler ) {
 
44
  global $wpdb;
45
  Utility::compatibility();
46
 
140
  * @since 3.0
141
  * @access public
142
  */
143
+ public function blacklist_add( $id ) {
 
144
  global $wpdb;
145
 
146
  $id = (int)$id;
179
  * @since 3.0
180
  * @access public
181
  */
182
+ public function blacklist_del( $id ) {
 
183
  global $wpdb;
184
 
185
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
201
  * @since 3.0
202
  * @access public
203
  */
204
+ public function blacklist_empty() {
 
205
  global $wpdb;
206
 
207
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
221
  * @since 3.0
222
  * @access public
223
  */
224
+ public function list_blacklist( $limit = false, $offset = false ) {
 
225
  global $wpdb;
226
 
227
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
245
  /**
246
  * Count blacklist
247
  */
248
+ public function count_blacklist() {
 
249
  global $wpdb;
250
 
251
  if ( ! $this->__data->tb_exist( 'crawler_blacklist' ) ) {
262
  * @since 3.0
263
  * @access public
264
  */
265
+ public function empty_map() {
 
266
  Data::get_instance()->tb_del( 'crawler' );
267
 
268
  $msg = __( 'Sitemap cleaned successfully', 'litespeed-cache' );
275
  * @since 3.0
276
  * @access public
277
  */
278
+ public function list_map( $limit, $offset = false ) {
 
279
  global $wpdb;
280
 
281
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
296
  /**
297
  * Count sitemap
298
  */
299
+ public function count_map() {
 
300
  global $wpdb;
301
 
302
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
313
  * @since 1.1.0
314
  * @access public
315
  */
316
+ public function gen() {
 
317
  $urls = $this->_gen();
318
 
319
  $msg = sprintf( __( 'Sitemap created successfully: %d items', 'litespeed-cache' ), $urls );
326
  * @since 1.1.0
327
  * @access private
328
  */
329
+ private function _gen() {
 
330
  global $wpdb;
331
 
332
  if ( ! $this->__data->tb_exist( 'crawler' ) ) {
425
  * @since 3.0
426
  * @access private
427
  */
428
+ private function _save( $data, $fields = 'url,res,reason' ) {
 
429
  global $wpdb;
430
 
431
  if ( empty( $data ) ) {
447
  * @since 1.1.1
448
  * @access private
449
  */
450
+ private function _parse( $sitemap, $return_detail = true ) {
 
451
  /**
452
  * Read via wp func to avoid allow_url_fopen = off
453
  * @since 2.2.7
522
  * @since 1.1.0
523
  * @access private
524
  */
525
+ private function _build($blacklist = array()) {
 
526
  global $wpdb;
527
 
528
  $show_pages = Conf::val( Base::O_CRAWLER_PAGES );
src/crawler.cls.php CHANGED
@@ -7,8 +7,7 @@
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
- class Crawler extends Base
11
- {
12
  const TYPE_REFRESH_MAP = 'refresh_map';
13
  const TYPE_EMPTY = 'empty';
14
  const TYPE_BLACKLIST_EMPTY = 'blacklist_empty';
@@ -53,8 +52,7 @@ class Crawler extends Base
53
  * @since 1.1.0
54
  * @access protected
55
  */
56
- protected function __construct()
57
- {
58
  if ( is_multisite() ) {
59
  $this->_sitemeta = 'meta' . get_current_blog_id() . '.data';
60
  }
@@ -76,8 +74,7 @@ class Crawler extends Base
76
  * @since 3.0
77
  * @access public
78
  */
79
- public static function get_summary( $field = false )
80
- {
81
  $_default = array(
82
  'list_size' => 0,
83
  'last_update_time' => 0,
@@ -119,8 +116,7 @@ class Crawler extends Base
119
  * @since 3.0
120
  * @access public
121
  */
122
- public static function save_summary( $data = null )
123
- {
124
  $instance = self::get_instance();
125
  $instance->_summary[ 'meta_save_time' ] = time();
126
 
@@ -139,8 +135,7 @@ class Crawler extends Base
139
  * @since 1.1.0
140
  * @access public
141
  */
142
- public static function start( $force = false )
143
- {
144
  if ( ! Router::can_crawl() ) {
145
  Debug2::debug( '🐞 ......crawler is NOT allowed by the server admin......' );
146
  return false;
@@ -159,8 +154,7 @@ class Crawler extends Base
159
  * @since 1.1.0
160
  * @access private
161
  */
162
- private function _crawl_data( $force )
163
- {
164
  Debug2::debug( '🐞 ......crawler started......' );
165
  // for the first time running
166
  if ( ! $this->_summary || ! Data::get_instance()->tb_exist( 'crawler' ) || ! Data::get_instance()->tb_exist( 'crawler_blacklist' ) ) {
@@ -199,8 +193,9 @@ class Crawler extends Base
199
  * @since 3.0
200
  * @access private
201
  */
202
- private function load_conf()
203
- {
 
204
  $current_crawler = $this->_crawlers[ $this->_summary[ 'curr_crawler' ] ];
205
 
206
  /**
@@ -244,8 +239,6 @@ class Crawler extends Base
244
  $this->_crawler_conf[ 'ua' ] = 'Mobile';
245
  }
246
 
247
- $this->_crawler_conf[ 'base' ] = home_url();
248
-
249
  /**
250
  * Limit delay to use server setting
251
  * @since 1.8.3
@@ -273,8 +266,7 @@ class Crawler extends Base
273
  * @since 1.1.0
274
  * @access private
275
  */
276
- private function _engine_start()
277
- {
278
  // check if is running
279
  if ( $this->_summary['is_running'] && time() - $this->_summary['is_running'] < $this->_crawler_conf[ 'run_duration' ] ) {
280
  $this->_end_reason = 'stopped';
@@ -323,8 +315,7 @@ class Crawler extends Base
323
  * @since 1.1.0
324
  * @access private
325
  */
326
- private function _adjust_current_threads()
327
- {
328
  /**
329
  * If server is windows, exit
330
  * @see https://wordpress.org/support/topic/crawler-keeps-causing-crashes/
@@ -387,8 +378,7 @@ class Crawler extends Base
387
  * @since 1.1.0
388
  * @access private
389
  */
390
- private function _prepare_running()
391
- {
392
  $this->_summary[ 'is_running' ] = time();
393
  $this->_summary[ 'done' ] = 0;// reset done status
394
  $this->_summary[ 'last_status' ] = 'prepare running';
@@ -399,10 +389,15 @@ class Crawler extends Base
399
  $this->_summary[ 'curr_crawler_beginning_time' ] = time();
400
  }
401
 
402
- if ( $this->_summary['curr_crawler'] == 0 && $this->_summary['last_pos'] == 0 ) {
403
- $this->_summary['this_full_beginning_time'] = time();
404
- $this->_summary['list_size'] = $this->__map->count_map();
 
 
 
 
405
  }
 
406
  self::save_summary();
407
  }
408
 
@@ -412,16 +407,15 @@ class Crawler extends Base
412
  * @since 1.1.0
413
  * @access private
414
  */
415
- private function _do_running()
416
- {
417
- $curlOptions = $this->_get_curl_options();
418
 
419
  while ( $urlChunks = $this->__map->list_map( self::CHUNKS, $this->_summary['last_pos'] ) ) {
420
  // start crawling
421
  $urlChunks = array_chunk( $urlChunks, $this->_cur_threads );
422
  foreach ( $urlChunks as $rows ) {
423
  // multi curl
424
- $rets = $this->_multi_request( $rows, $curlOptions );
425
 
426
  // check result headers
427
  foreach ( $rows as $row ) {
@@ -517,8 +511,7 @@ class Crawler extends Base
517
  * @since 1.1.0
518
  * @access private
519
  */
520
- private function _multi_request( $rows, $options )
521
- {
522
  $mh = curl_multi_init();
523
  $curls = array();
524
  foreach ( $rows as $row ) {
@@ -590,8 +583,7 @@ class Crawler extends Base
590
  * @since 2.0
591
  * @access private
592
  */
593
- private function _status_parse( $header, $code )
594
- {
595
  if ( $code == 201 ) {
596
  return 'H';
597
  }
@@ -624,8 +616,7 @@ class Crawler extends Base
624
  * @since 1.1.0
625
  * @access private
626
  */
627
- private function _get_curl_options()
628
- {
629
  $options = array(
630
  CURLOPT_RETURNTRANSFER => true,
631
  CURLOPT_HEADER => true,
@@ -650,21 +641,17 @@ class Crawler extends Base
650
  $options[ CURLOPT_HTTP_VERSION ] = CURL_HTTP_VERSION_1_1;
651
  // $options[ CURL_HTTP_VERSION_2 ] = 1;
652
 
653
- if ( strpos( $this->_crawler_conf[ 'ua' ], Crawler::FAST_USER_AGENT ) !== 0 ) {
654
- $this->_crawler_conf[ 'ua' ] = Crawler::FAST_USER_AGENT . ' ' . $this->_crawler_conf[ 'ua' ];
655
- }
656
- $options[ CURLOPT_USERAGENT ] = $this->_crawler_conf[ 'ua' ];
657
-
658
- if ( $ip = $this->_options[ Base::O_SERVER_IP ] ) {
659
  Utility::compatibility();
660
- if ( $this->_options[ Base::O_CRAWLER_DROP_DOMAIN ] && $this->_crawler_conf[ 'base' ] ) {
661
  // Resolve URL to IP
662
  $parsed_url = parse_url( $this->_crawler_conf[ 'base' ] );
663
 
664
  if ( ! empty( $parsed_url[ 'host' ] ) ) {
665
  $dom = $parsed_url[ 'host' ];
666
  $port = $parsed_url[ 'scheme' ] == 'https' ? '443' : '80';
667
- $url = $dom . ':' . $port . ':' . $ip;
668
 
669
  $options[ CURLOPT_RESOLVE ] = array( $url );
670
  $options[ CURLOPT_DNS_USE_GLOBAL_CACHE ] = false;
@@ -675,16 +662,28 @@ class Crawler extends Base
675
  // if is walker
676
  // $options[ CURLOPT_FRESH_CONNECT ] = true;
677
 
 
678
  if ( isset( $_SERVER[ 'HTTP_HOST' ] ) && isset( $_SERVER[ 'REQUEST_URI' ] ) ) {
679
  $options[ CURLOPT_REFERER ] = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
680
  }
681
 
 
 
 
 
 
 
 
 
682
  /**
683
  * Append hash to cookie for validation
684
  * @since 1.9.1
685
  */
686
- $this->_crawler_conf[ 'cookies' ][ 'litespeed_hash' ] = Router::get_hash();
 
 
687
 
 
688
  $cookies = array();
689
  foreach ( $this->_crawler_conf[ 'cookies' ] as $k => $v ) {
690
  if ( ! $v ) {
@@ -699,27 +698,48 @@ class Crawler extends Base
699
  return $options;
700
  }
701
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
702
  /**
703
  * Terminate crawling
704
  *
705
  * @since 1.1.0
706
  * @access private
707
  */
708
- private function _terminate_running()
709
- {
710
  $this->_map_status_list = $this->__map->save_map_status( $this->_map_status_list, $this->_summary[ 'curr_crawler' ] );
711
 
712
  if ( $this->_end_reason == 'end' ) { // Current crawler is fully done
713
  // $end_reason = sprintf( __( 'Crawler %s reached end of sitemap file.', 'litespeed-cache' ), '#' . ( $this->_summary['curr_crawler'] + 1 ) );
714
  $this->_summary[ 'curr_crawler' ]++; // Jump to next cralwer
715
- $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array();
716
  $this->_summary[ 'last_pos' ] = 0;// reset last position
717
  $this->_summary[ 'last_crawler_total_cost' ] = time() - $this->_summary[ 'curr_crawler_beginning_time' ];
718
  $count_crawlers = count( $this->list_crawlers() );
719
  if ( $this->_summary[ 'curr_crawler' ] >= $count_crawlers ) {
720
  Debug2::debug( '🐞 _terminate_running Touched end, whole crawled. Reload crawler!' );
721
  $this->_summary[ 'curr_crawler' ] = 0;
722
- $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array();
723
  $this->_summary[ 'done' ] = 'touchedEnd';// log done status
724
  $this->_summary[ 'last_full_time_cost' ] = time() - $this->_summary[ 'this_full_beginning_time' ];
725
  }
@@ -736,8 +756,7 @@ class Crawler extends Base
736
  * @since 1.9.1
737
  * @access public
738
  */
739
- public function list_crawlers()
740
- {
741
  if ( $this->_crawlers ) {
742
  return $this->_crawlers;
743
  }
@@ -800,8 +819,7 @@ class Crawler extends Base
800
  * @since 2.8
801
  * @access private
802
  */
803
- private function _recursive_build_crawler( $crawler_factors, $group = array(), $i = 0 )
804
- {
805
  $current_factor = array_keys( $crawler_factors );
806
  $current_factor = $current_factor[ $i ];
807
 
@@ -841,8 +859,7 @@ class Crawler extends Base
841
  * @since 1.1.0
842
  * @access public
843
  */
844
- public function json_path()
845
- {
846
  if ( ! file_exists( LITESPEED_STATIC_DIR . '/crawler/' . $this->_sitemeta ) ) {
847
  return false;
848
  }
@@ -857,8 +874,7 @@ class Crawler extends Base
857
  * @since 1.1.0
858
  * @access public
859
  */
860
- public function reset_pos()
861
- {
862
  File::save( $this->_resetfile, time() , true );
863
  }
864
 
@@ -868,8 +884,7 @@ class Crawler extends Base
868
  * @since 3.0
869
  * @access public
870
  */
871
- public function display_status( $status_row, $reason_set )
872
- {
873
  if ( ! $status_row ) {
874
  return '';
875
  }
@@ -909,8 +924,7 @@ class Crawler extends Base
909
  * @access protected
910
  * @param string $error Error info
911
  */
912
- protected function output($msg)
913
- {
914
  if ( defined('DOING_CRON') ) {
915
  echo $msg;
916
  // exit();
@@ -927,8 +941,7 @@ class Crawler extends Base
927
  * @since 3.0
928
  * @access public
929
  */
930
- public static function handler()
931
- {
932
  $instance = self::get_instance();
933
 
934
  $type = Router::verify_type();
7
  namespace LiteSpeed;
8
  defined( 'WPINC' ) || exit;
9
 
10
+ class Crawler extends Base {
 
11
  const TYPE_REFRESH_MAP = 'refresh_map';
12
  const TYPE_EMPTY = 'empty';
13
  const TYPE_BLACKLIST_EMPTY = 'blacklist_empty';
52
  * @since 1.1.0
53
  * @access protected
54
  */
55
+ protected function __construct() {
 
56
  if ( is_multisite() ) {
57
  $this->_sitemeta = 'meta' . get_current_blog_id() . '.data';
58
  }
74
  * @since 3.0
75
  * @access public
76
  */
77
+ public static function get_summary( $field = false ) {
 
78
  $_default = array(
79
  'list_size' => 0,
80
  'last_update_time' => 0,
116
  * @since 3.0
117
  * @access public
118
  */
119
+ public static function save_summary( $data = null ) {
 
120
  $instance = self::get_instance();
121
  $instance->_summary[ 'meta_save_time' ] = time();
122
 
135
  * @since 1.1.0
136
  * @access public
137
  */
138
+ public static function start( $force = false ) {
 
139
  if ( ! Router::can_crawl() ) {
140
  Debug2::debug( '🐞 ......crawler is NOT allowed by the server admin......' );
141
  return false;
154
  * @since 1.1.0
155
  * @access private
156
  */
157
+ private function _crawl_data( $force ) {
 
158
  Debug2::debug( '🐞 ......crawler started......' );
159
  // for the first time running
160
  if ( ! $this->_summary || ! Data::get_instance()->tb_exist( 'crawler' ) || ! Data::get_instance()->tb_exist( 'crawler_blacklist' ) ) {
193
  * @since 3.0
194
  * @access private
195
  */
196
+ private function load_conf() {
197
+ $this->_crawler_conf[ 'base' ] = home_url();
198
+
199
  $current_crawler = $this->_crawlers[ $this->_summary[ 'curr_crawler' ] ];
200
 
201
  /**
239
  $this->_crawler_conf[ 'ua' ] = 'Mobile';
240
  }
241
 
 
 
242
  /**
243
  * Limit delay to use server setting
244
  * @since 1.8.3
266
  * @since 1.1.0
267
  * @access private
268
  */
269
+ private function _engine_start() {
 
270
  // check if is running
271
  if ( $this->_summary['is_running'] && time() - $this->_summary['is_running'] < $this->_crawler_conf[ 'run_duration' ] ) {
272
  $this->_end_reason = 'stopped';
315
  * @since 1.1.0
316
  * @access private
317
  */
318
+ private function _adjust_current_threads() {
 
319
  /**
320
  * If server is windows, exit
321
  * @see https://wordpress.org/support/topic/crawler-keeps-causing-crashes/
378
  * @since 1.1.0
379
  * @access private
380
  */
381
+ private function _prepare_running() {
 
382
  $this->_summary[ 'is_running' ] = time();
383
  $this->_summary[ 'done' ] = 0;// reset done status
384
  $this->_summary[ 'last_status' ] = 'prepare running';
389
  $this->_summary[ 'curr_crawler_beginning_time' ] = time();
390
  }
391
 
392
+ if ( $this->_summary[ 'curr_crawler' ] == 0 && $this->_summary[ 'last_pos' ] == 0 ) {
393
+ $this->_summary[ 'this_full_beginning_time' ] = time();
394
+ $this->_summary[ 'list_size' ] = $this->__map->count_map();
395
+ }
396
+
397
+ if ( $this->_summary[ 'end_reason' ] == 'end' && $this->_summary[ 'last_pos' ] == 0 ) {
398
+ $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array();
399
  }
400
+
401
  self::save_summary();
402
  }
403
 
407
  * @since 1.1.0
408
  * @access private
409
  */
410
+ private function _do_running() {
411
+ $options = $this->_get_curl_options( true );
 
412
 
413
  while ( $urlChunks = $this->__map->list_map( self::CHUNKS, $this->_summary['last_pos'] ) ) {
414
  // start crawling
415
  $urlChunks = array_chunk( $urlChunks, $this->_cur_threads );
416
  foreach ( $urlChunks as $rows ) {
417
  // multi curl
418
+ $rets = $this->_multi_request( $rows, $options );
419
 
420
  // check result headers
421
  foreach ( $rows as $row ) {
511
  * @since 1.1.0
512
  * @access private
513
  */
514
+ private function _multi_request( $rows, $options ) {
 
515
  $mh = curl_multi_init();
516
  $curls = array();
517
  foreach ( $rows as $row ) {
583
  * @since 2.0
584
  * @access private
585
  */
586
+ private function _status_parse( $header, $code ) {
 
587
  if ( $code == 201 ) {
588
  return 'H';
589
  }
616
  * @since 1.1.0
617
  * @access private
618
  */
619
+ private function _get_curl_options( $crawler_only = false ) {
 
620
  $options = array(
621
  CURLOPT_RETURNTRANSFER => true,
622
  CURLOPT_HEADER => true,
641
  $options[ CURLOPT_HTTP_VERSION ] = CURL_HTTP_VERSION_1_1;
642
  // $options[ CURL_HTTP_VERSION_2 ] = 1;
643
 
644
+ // IP resolve
645
+ if ( $this->_options[ Base::O_SERVER_IP ] ) {
 
 
 
 
646
  Utility::compatibility();
647
+ if ( ( $this->_options[ Base::O_CRAWLER_DROP_DOMAIN ] || ! $crawler_only ) && $this->_crawler_conf[ 'base' ] ) {
648
  // Resolve URL to IP
649
  $parsed_url = parse_url( $this->_crawler_conf[ 'base' ] );
650
 
651
  if ( ! empty( $parsed_url[ 'host' ] ) ) {
652
  $dom = $parsed_url[ 'host' ];
653
  $port = $parsed_url[ 'scheme' ] == 'https' ? '443' : '80';
654
+ $url = $dom . ':' . $port . ':' . $this->_options[ Base::O_SERVER_IP ];
655
 
656
  $options[ CURLOPT_RESOLVE ] = array( $url );
657
  $options[ CURLOPT_DNS_USE_GLOBAL_CACHE ] = false;
662
  // if is walker
663
  // $options[ CURLOPT_FRESH_CONNECT ] = true;
664
 
665
+ // Referer
666
  if ( isset( $_SERVER[ 'HTTP_HOST' ] ) && isset( $_SERVER[ 'REQUEST_URI' ] ) ) {
667
  $options[ CURLOPT_REFERER ] = 'http://' . $_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ];
668
  }
669
 
670
+ // User Agent
671
+ if ( $crawler_only ) {
672
+ if ( strpos( $this->_crawler_conf[ 'ua' ], Crawler::FAST_USER_AGENT ) !== 0 ) {
673
+ $this->_crawler_conf[ 'ua' ] = Crawler::FAST_USER_AGENT . ' ' . $this->_crawler_conf[ 'ua' ];
674
+ }
675
+ }
676
+ $options[ CURLOPT_USERAGENT ] = $this->_crawler_conf[ 'ua' ];
677
+
678
  /**
679
  * Append hash to cookie for validation
680
  * @since 1.9.1
681
  */
682
+ if ( $crawler_only ) {
683
+ $this->_crawler_conf[ 'cookies' ][ 'litespeed_hash' ] = Router::get_hash();
684
+ }
685
 
686
+ // Cookies
687
  $cookies = array();
688
  foreach ( $this->_crawler_conf[ 'cookies' ] as $k => $v ) {
689
  if ( ! $v ) {
698
  return $options;
699
  }
700
 
701
+ /**
702
+ * Self curl to get HTML content
703
+ *
704
+ * @since 3.3
705
+ */
706
+ public function self_curl( $url, $ua ) {
707
+ $this->_crawler_conf[ 'base' ] = home_url();
708
+ $this->_crawler_conf[ 'ua' ] = $ua;
709
+
710
+ $options = $this->_get_curl_options();
711
+ $options[ CURLOPT_HEADER ] = false;
712
+ $options[ CURLOPT_FOLLOWLOCATION ] = true;
713
+
714
+ $ch = curl_init();
715
+ curl_setopt_array( $ch, $options );
716
+ curl_setopt( $ch, CURLOPT_URL, $url );
717
+ $result = curl_exec( $ch );
718
+ curl_close( $ch );
719
+
720
+ return $result;
721
+ }
722
+
723
  /**
724
  * Terminate crawling
725
  *
726
  * @since 1.1.0
727
  * @access private
728
  */
729
+ private function _terminate_running() {
 
730
  $this->_map_status_list = $this->__map->save_map_status( $this->_map_status_list, $this->_summary[ 'curr_crawler' ] );
731
 
732
  if ( $this->_end_reason == 'end' ) { // Current crawler is fully done
733
  // $end_reason = sprintf( __( 'Crawler %s reached end of sitemap file.', 'litespeed-cache' ), '#' . ( $this->_summary['curr_crawler'] + 1 ) );
734
  $this->_summary[ 'curr_crawler' ]++; // Jump to next cralwer
735
+ // $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array(); // reset this at next crawl time
736
  $this->_summary[ 'last_pos' ] = 0;// reset last position
737
  $this->_summary[ 'last_crawler_total_cost' ] = time() - $this->_summary[ 'curr_crawler_beginning_time' ];
738
  $count_crawlers = count( $this->list_crawlers() );
739
  if ( $this->_summary[ 'curr_crawler' ] >= $count_crawlers ) {
740
  Debug2::debug( '🐞 _terminate_running Touched end, whole crawled. Reload crawler!' );
741
  $this->_summary[ 'curr_crawler' ] = 0;
742
+ // $this->_summary[ 'crawler_stats' ][ $this->_summary[ 'curr_crawler' ] ] = array();
743
  $this->_summary[ 'done' ] = 'touchedEnd';// log done status
744
  $this->_summary[ 'last_full_time_cost' ] = time() - $this->_summary[ 'this_full_beginning_time' ];
745
  }
756
  * @since 1.9.1
757
  * @access public
758
  */
759
+ public function list_crawlers() {
 
760
  if ( $this->_crawlers ) {
761
  return $this->_crawlers;
762
  }
819
  * @since 2.8
820
  * @access private
821
  */
822
+ private function _recursive_build_crawler( $crawler_factors, $group = array(), $i = 0 ) {
 
823
  $current_factor = array_keys( $crawler_factors );
824
  $current_factor = $current_factor[ $i ];
825
 
859
  * @since 1.1.0
860
  * @access public
861
  */
862
+ public function json_path() {
 
863
  if ( ! file_exists( LITESPEED_STATIC_DIR . '/crawler/' . $this->_sitemeta ) ) {
864
  return false;
865
  }
874
  * @since 1.1.0
875
  * @access public
876
  */
877
+ public function reset_pos() {
 
878
  File::save( $this->_resetfile, time() , true );
879
  }
880
 
884
  * @since 3.0
885
  * @access public
886
  */
887
+ public function display_status( $status_row, $reason_set ) {
 
888
  if ( ! $status_row ) {
889
  return '';
890
  }
924
  * @access protected
925
  * @param string $error Error info
926
  */
927
+ protected function output($msg) {
 
928
  if ( defined('DOING_CRON') ) {
929
  echo $msg;
930
  // exit();
941
  * @since 3.0
942
  * @access public
943
  */
944
+ public static function handler() {
 
945
  $instance = self::get_instance();
946
 
947
  $type = Router::verify_type();
src/css.cls.php CHANGED
@@ -20,8 +20,7 @@ class CSS extends Base {
20
  * @since 3.0
21
  * @access protected
22
  */
23
- protected function __construct()
24
- {
25
  $this->_summary = self::get_summary();
26
  }
27
 
@@ -32,8 +31,7 @@ class CSS extends Base {
32
  * @since 2.3 Migrated from optimize.cls
33
  * @access public
34
  */
35
- public static function prepend_ccss( $html_head )
36
- {
37
  // Get critical css for current page
38
  // Note: need to consider mobile
39
  $rules = self::get_instance()->_ccss();
@@ -43,18 +41,7 @@ class CSS extends Base {
43
 
44
  $html_head = '<style id="litespeed-optm-css-rules">' . $rules . '</style>' . $html_head;
45
 
46
- return $html_head ;
47
- }
48
-
49
- /**
50
- * Check if there is a ccss cache folder
51
- *
52
- * @since 2.3
53
- * @access public
54
- */
55
- public static function has_ccss_cache()
56
- {
57
- return is_dir( LITESPEED_STATIC_DIR . '/ccss' ) ;
58
  }
59
 
60
  /**
@@ -63,9 +50,8 @@ class CSS extends Base {
63
  * @since 2.3
64
  * @access private
65
  */
66
- private function _ccss_realpath( $ccss_type )
67
- {
68
- return LITESPEED_STATIC_DIR . "/ccss/$ccss_type.css" ;
69
  }
70
 
71
  /**
@@ -74,18 +60,17 @@ class CSS extends Base {
74
  * @since 2.3
75
  * @access public
76
  */
77
- public function rm_cache_folder()
78
- {
79
  if ( file_exists( LITESPEED_STATIC_DIR . '/ccss' ) ) {
80
- File::rrmdir( LITESPEED_STATIC_DIR . '/ccss' ) ;
81
  }
82
 
83
  // Clear CCSS in queue too
84
- $this->_summary[ 'queue' ] = array() ;
85
- $this->_summary[ 'curr_request' ] = 0 ;
86
  self::save_summary();
87
 
88
- Debug2::debug2( '[CSS] Cleared ccss queue' ) ;
89
  }
90
 
91
 
@@ -100,50 +85,49 @@ class CSS extends Base {
100
  * @since 2.3
101
  * @access private
102
  */
103
- private function _ccss()
104
- {
105
  // If don't need to generate CCSS, bypass
106
  if ( ! Conf::val( Base::O_OPTM_CCSS_GEN ) ) {
107
- Debug2::debug( '[CSS] bypassed ccss due to setting' ) ;
108
- return '' ;
109
  }
110
 
111
- $ccss_type = $this->_which_css() ;
112
- $ccss_file = $this->_ccss_realpath( $ccss_type ) ;
113
 
114
  if ( file_exists( $ccss_file ) ) {
115
- Debug2::debug2( '[CSS] existing ccss ' . $ccss_file ) ;
116
- return File::read( $ccss_file ) ;
117
  }
118
 
119
  // Check if is already in a request, bypass current one
120
- if ( ! empty( $this->_summary[ 'curr_request' ] ) && time() - $this->_summary[ 'curr_request' ] < 300 ) {
121
  Debug2::debug( '[CCSS] Last request not done' );
122
- return '' ;
123
  }
124
 
125
- global $wp ;
126
- $request_url = home_url( $wp->request ) ;
127
 
128
  // If generate in backend, log it and bypass
129
  if ( Conf::val( Base::O_OPTM_CCSS_ASYNC ) ) {
130
  // Store it to prepare for cron
131
  if ( empty( $this->_summary[ 'queue' ] ) ) {
132
- $this->_summary[ 'queue' ] = array() ;
133
  }
134
  $this->_summary[ 'queue' ][ $ccss_type ] = array(
135
  'url' => $request_url,
136
  'user_agent' => $_SERVER[ 'HTTP_USER_AGENT' ],
137
  'is_mobile' => $this->_separate_mobile_ccss(),
138
- ) ;// Current UA will be used to request
139
- Debug2::debug( '[CSS] Added queue [type] ' . $ccss_type . ' [url] ' . $request_url . ' [UA] ' . $_SERVER[ 'HTTP_USER_AGENT' ] ) ;
140
 
141
  self::save_summary();
142
- return '' ;
143
  }
144
 
145
  // generate on the fly
146
- return $this->_generate_ccss( $request_url, $ccss_type, $_SERVER[ 'HTTP_USER_AGENT' ], $this->_separate_mobile_ccss() ) ;
147
  }
148
 
149
  /**
@@ -154,7 +138,7 @@ class CSS extends Base {
154
  */
155
  private function _separate_mobile_ccss()
156
  {
157
- return ( wp_is_mobile() || apply_filters( 'litespeed_is_mobile', false ) ) && Conf::val( Base::O_CACHE_MOBILE ) ;
158
  }
159
 
160
  /**
@@ -167,25 +151,25 @@ class CSS extends Base {
167
  {
168
  $_instance = self::get_instance();
169
  if ( empty( $_instance->_summary[ 'queue' ] ) ) {
170
- return ;
171
  }
172
 
173
  // For cron, need to check request interval too
174
  if ( ! $continue ) {
175
  if ( ! empty( $_instance->_summary[ 'curr_request' ] ) && time() - $_instance->_summary[ 'curr_request' ] < 300 ) {
176
  Debug2::debug( '[CCSS] Last request not done' );
177
- return ;
178
  }
179
  }
180
 
181
  foreach ( $_instance->_summary[ 'queue' ] as $k => $v ) {
182
- Debug2::debug( '[CSS] cron job [type] ' . $k . ' [url] ' . $v[ 'url' ] . ( $v[ 'is_mobile' ] ? ' 📱 ' : '' ) . ' [UA] ' . $v[ 'user_agent' ] ) ;
183
 
184
- $_instance->_generate_ccss( $v[ 'url' ], $k, $v[ 'user_agent' ], $v[ 'is_mobile' ] ) ;
185
 
186
  // only request first one
187
  if ( ! $continue ) {
188
- return ;
189
  }
190
  }
191
  }
@@ -196,8 +180,7 @@ class CSS extends Base {
196
  * @since 2.3
197
  * @access private
198
  */
199
- private function _generate_ccss( $request_url, $ccss_type, $user_agent, $is_mobile )
200
- {
201
  // Check if has credit to push
202
  $allowance = Cloud::get_instance()->allowance( Cloud::SVC_CCSS );
203
  if ( ! $allowance ) {
@@ -206,50 +189,129 @@ class CSS extends Base {
206
  return;
207
  }
208
 
209
- $ccss_file = $this->_ccss_realpath( $ccss_type ) ;
210
 
211
  // Update css request status
212
- $this->_summary[ 'curr_request' ] = time() ;
213
  self::save_summary();
214
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  // Generate critical css
216
  $data = array(
217
  'url' => $request_url,
218
  'ccss_type' => $ccss_type,
219
  'user_agent' => $user_agent,
220
  'is_mobile' => $is_mobile ? 1 : 0,
221
- ) ;
 
 
 
222
 
223
- Debug2::debug( '[CSS] Generating: ', $data ) ;
224
 
225
- $json = Cloud::post( Cloud::SVC_CCSS, $data, 180 ) ;
226
  if ( ! is_array( $json ) ) {
227
  return false;
228
  }
229
 
230
  if ( empty( $json[ 'ccss' ] ) ) {
231
- Debug2::debug( '[CSS] ❌ empty ccss' ) ;
232
  $this->_popup_and_save( $ccss_type, $request_url );
233
- return false ;
234
  }
235
 
236
  // Add filters
237
- $ccss = apply_filters( 'litespeed_ccss', $json[ 'ccss' ], $ccss_type ) ;
238
 
239
  // Write to file
240
- File::save( $ccss_file, $ccss, true ) ;
241
 
242
  // Save summary data
243
- $this->_summary[ 'last_spent' ] = time() - $this->_summary[ 'curr_request' ] ;
244
- $this->_summary[ 'last_request' ] = $this->_summary[ 'curr_request' ] ;
245
- $this->_summary[ 'curr_request' ] = 0 ;
246
  $this->_popup_and_save( $ccss_type, $request_url );
247
 
248
- Debug2::debug( '[CSS] saved ccss ' . $ccss_file ) ;
249
 
250
- Debug2::debug2( '[CSS] ccss con: ' . $ccss ) ;
251
 
252
- return $ccss ;
253
  }
254
 
255
  /**
@@ -273,7 +335,7 @@ class CSS extends Base {
273
 
274
  // Generate UCSS
275
  $data = array(
276
- 'type' => 'ucss',
277
  'url' => $request_url,
278
  'whitelist' => $this->_filter_whitelist(),
279
  'user_agent' => $user_agent,
@@ -294,7 +356,7 @@ class CSS extends Base {
294
 
295
  Debug2::debug( '[UCSS] Generating UCSS: ', $data );
296
 
297
- $json = Cloud::post( Cloud::SVC_CCSS, $data, 180 ) ;
298
  if ( ! is_array( $json ) ) {
299
  return false;
300
  }
@@ -359,10 +421,10 @@ class CSS extends Base {
359
  private function _popup_and_save( $ccss_type, $request_url )
360
  {
361
  if ( empty( $this->_summary[ 'ccss_type_history' ] ) ) {
362
- $this->_summary[ 'ccss_type_history' ] = array() ;
363
  }
364
- $this->_summary[ 'ccss_type_history' ][ $ccss_type ] = $request_url ;
365
- unset( $this->_summary[ 'queue' ][ $ccss_type ] ) ;
366
 
367
  self::save_summary();
368
  }
@@ -375,35 +437,35 @@ class CSS extends Base {
375
  */
376
  private function _which_css()
377
  {
378
- $css = Utility::page_type() ;
379
 
380
- $unique = false ;
381
 
382
  // Check if in separate css type option
383
- $separate_posttypes = Conf::val( Base::O_OPTM_CCSS_SEP_POSTTYPE ) ;
384
  if ( ! empty( $separate_posttypes ) && in_array( $css, $separate_posttypes ) ) {
385
- Debug2::debug( '[CSS] Hit separate posttype setting [type] ' . $css ) ;
386
- $unique = true ;
387
  }
388
 
389
- $separate_uri = Conf::val( Base::O_OPTM_CCSS_SEP_URI ) ;
390
  if ( ! empty( $separate_uri ) ) {
391
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $separate_uri ) ;
392
  if ( $result ) {
393
- Debug2::debug( '[CSS] Hit separate URI setting: ' . $result ) ;
394
- $unique = true ;
395
  }
396
  }
397
 
398
  if ( $unique ) {
399
- $css .= '-' . md5( $_SERVER[ 'REQUEST_URI' ] ) ;
400
  }
401
 
402
  if ( $this->_separate_mobile_ccss() ) {
403
- $css .= '.mobile' ;
404
  }
405
 
406
- return $css ;
407
  }
408
 
409
  /**
@@ -414,20 +476,20 @@ class CSS extends Base {
414
  */
415
  public static function handler()
416
  {
417
- $instance = self::get_instance() ;
418
 
419
- $type = Router::verify_type() ;
420
 
421
  switch ( $type ) {
422
  case self::TYPE_GENERATE_CRITICAL :
423
- self::cron_ccss( true ) ;
424
- break ;
425
 
426
  default:
427
- break ;
428
  }
429
 
430
- Admin::redirect() ;
431
  }
432
 
433
  }
20
  * @since 3.0
21
  * @access protected
22
  */
23
+ protected function __construct() {
 
24
  $this->_summary = self::get_summary();
25
  }
26
 
31
  * @since 2.3 Migrated from optimize.cls
32
  * @access public
33
  */
34
+ public static function prepend_ccss( $html_head ) {
 
35
  // Get critical css for current page
36
  // Note: need to consider mobile
37
  $rules = self::get_instance()->_ccss();
41
 
42
  $html_head = '<style id="litespeed-optm-css-rules">' . $rules . '</style>' . $html_head;
43
 
44
+ return $html_head;
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
 
47
  /**
50
  * @since 2.3
51
  * @access private
52
  */
53
+ private function _ccss_realpath( $ccss_type ) {
54
+ return LITESPEED_STATIC_DIR . "/ccss/$ccss_type.css";
 
55
  }
56
 
57
  /**
60
  * @since 2.3
61
  * @access public
62
  */
63
+ public function rm_cache_folder() {
 
64
  if ( file_exists( LITESPEED_STATIC_DIR . '/ccss' ) ) {
65
+ File::rrmdir( LITESPEED_STATIC_DIR . '/ccss' );
66
  }
67
 
68
  // Clear CCSS in queue too
69
+ $this->_summary[ 'queue' ] = array();
70
+ $this->_summary[ 'curr_request' ] = 0;
71
  self::save_summary();
72
 
73
+ Debug2::debug2( '[CSS] Cleared ccss queue' );
74
  }
75
 
76
 
85
  * @since 2.3
86
  * @access private
87
  */
88
+ private function _ccss() {
 
89
  // If don't need to generate CCSS, bypass
90
  if ( ! Conf::val( Base::O_OPTM_CCSS_GEN ) ) {
91
+ Debug2::debug( '[CSS] bypassed ccss due to setting' );
92
+ return '';
93
  }
94
 
95
+ $ccss_type = $this->_which_css();
96
+ $ccss_file = $this->_ccss_realpath( $ccss_type );
97
 
98
  if ( file_exists( $ccss_file ) ) {
99
+ Debug2::debug2( '[CSS] existing ccss ' . $ccss_file );
100
+ return File::read( $ccss_file );
101
  }
102
 
103
  // Check if is already in a request, bypass current one
104
+ if ( ! empty( $this->_summary[ 'curr_request' ] ) && time() - $this->_summary[ 'curr_request' ] < 300 && ! Conf::val( Base::O_DEBUG ) ) {
105
  Debug2::debug( '[CCSS] Last request not done' );
106
+ return '';
107
  }
108
 
109
+ global $wp;
110
+ $request_url = home_url( $wp->request );
111
 
112
  // If generate in backend, log it and bypass
113
  if ( Conf::val( Base::O_OPTM_CCSS_ASYNC ) ) {
114
  // Store it to prepare for cron
115
  if ( empty( $this->_summary[ 'queue' ] ) ) {
116
+ $this->_summary[ 'queue' ] = array();
117
  }
118
  $this->_summary[ 'queue' ][ $ccss_type ] = array(
119
  'url' => $request_url,
120
  'user_agent' => $_SERVER[ 'HTTP_USER_AGENT' ],
121
  'is_mobile' => $this->_separate_mobile_ccss(),
122
+ );// Current UA will be used to request
123
+ Debug2::debug( '[CSS] Added queue [type] ' . $ccss_type . ' [url] ' . $request_url . ' [UA] ' . $_SERVER[ 'HTTP_USER_AGENT' ] );
124
 
125
  self::save_summary();
126
+ return '';
127
  }
128
 
129
  // generate on the fly
130
+ return $this->_generate_ccss( $request_url, $ccss_type, $_SERVER[ 'HTTP_USER_AGENT' ], $this->_separate_mobile_ccss() );
131
  }
132
 
133
  /**
138
  */
139
  private function _separate_mobile_ccss()
140
  {
141
+ return ( wp_is_mobile() || apply_filters( 'litespeed_is_mobile', false ) ) && Conf::val( Base::O_CACHE_MOBILE );
142
  }
143
 
144
  /**
151
  {
152
  $_instance = self::get_instance();
153
  if ( empty( $_instance->_summary[ 'queue' ] ) ) {
154
+ return;
155
  }
156
 
157
  // For cron, need to check request interval too
158
  if ( ! $continue ) {
159
  if ( ! empty( $_instance->_summary[ 'curr_request' ] ) && time() - $_instance->_summary[ 'curr_request' ] < 300 ) {
160
  Debug2::debug( '[CCSS] Last request not done' );
161
+ return;
162
  }
163
  }
164
 
165
  foreach ( $_instance->_summary[ 'queue' ] as $k => $v ) {
166
+ Debug2::debug( '[CSS] cron job [type] ' . $k . ' [url] ' . $v[ 'url' ] . ( $v[ 'is_mobile' ] ? ' 📱 ' : '' ) . ' [UA] ' . $v[ 'user_agent' ] );
167
 
168
+ $_instance->_generate_ccss( $v[ 'url' ], $k, $v[ 'user_agent' ], $v[ 'is_mobile' ] );
169
 
170
  // only request first one
171
  if ( ! $continue ) {
172
+ return;
173
  }
174
  }
175
  }
180
  * @since 2.3
181
  * @access private
182
  */
183
+ private function _generate_ccss( $request_url, $ccss_type, $user_agent, $is_mobile ) {
 
184
  // Check if has credit to push
185
  $allowance = Cloud::get_instance()->allowance( Cloud::SVC_CCSS );
186
  if ( ! $allowance ) {
189
  return;
190
  }
191
 
192
+ $ccss_file = $this->_ccss_realpath( $ccss_type );
193
 
194
  // Update css request status
195
+ $this->_summary[ 'curr_request' ] = time();
196
  self::save_summary();
197
 
198
+ // Gather guest HTML to send
199
+ $html = Crawler::get_instance()->self_curl( add_query_arg( 'LSCWP_CTRL', 'before_optm', $request_url ), $user_agent );
200
+ Debug2::debug2( '[CSS] self_curl result....', $html );
201
+
202
+
203
+ $html = Optimizer::get_instance()->html_min( $html, true );
204
+ // Drop <noscript>xxx</noscript>
205
+ $html = preg_replace( '#<noscript>.*</noscript>#isU', '', $html );
206
+
207
+ if ( ! $html ) {
208
+ return false;
209
+ }
210
+
211
+ // Parse HTML to gather all CSS content before requesting
212
+ $css = '';
213
+ preg_match_all( '#<link ([^>]+)/?>|<style[^>]*>([^<]+)</style>#isU', $html, $matches, PREG_SET_ORDER );
214
+ foreach ( $matches as $match ) {
215
+ $attrs = false;
216
+ if ( strpos( $match[ 0 ], '<link' ) === 0 ) {
217
+ $attrs = Utility::parse_attr( $match[ 1 ] );
218
+
219
+ if ( ! empty( $attrs[ 'rel' ] ) ) {
220
+ if ( $attrs[ 'rel' ] !== 'stylesheet' && $attrs[ 'rel' ] !== 'preload' ) {
221
+ continue;
222
+ }
223
+ }
224
+
225
+ if ( ! empty( $attrs[ 'media' ] ) && strpos( $attrs[ 'media' ], 'print' ) !== false ) {
226
+ continue;
227
+ }
228
+ if ( empty( $attrs[ 'href' ] ) ) {
229
+ continue;
230
+ }
231
+
232
+ // Check Google fonts hit
233
+ if ( strpos( $attrs[ 'href' ], 'fonts.googleapis.com' ) !== false ) {
234
+ $html = str_replace( $match[ 0 ], '', $html );
235
+ continue;
236
+ }
237
+
238
+ // Load CSS content
239
+ $real_file = Utility::is_internal_file( $attrs[ 'href' ] );
240
+ if ( ! $real_file ) {
241
+ Debug2::debug2( '[CCSS] Load Remote CSS ' . $attrs[ 'href' ] );
242
+ $con = wp_remote_retrieve_body( wp_remote_get( $attrs[ 'href' ] ) );
243
+ if ( ! $con ) {
244
+ continue;
245
+ }
246
+ }
247
+ else {
248
+ Debug2::debug2( '[CCSS] Load local CSS ' . $real_file[ 0 ] );
249
+ $con = File::read( $real_file[ 0 ] );
250
+ $con = Lib\CSS_MIN\UriRewriter::rewrite( $con, dirname( $real_file[ 0 ] ) );
251
+ }
252
+ }
253
+ else { // Inline style
254
+ Debug2::debug2( '[CCSS] Load inline CSS ' . substr( $match[ 2 ], 0, 100 ) . '...' );
255
+ $con = $match[ 2 ];
256
+ }
257
+
258
+ $con = Optimizer::minify_css( $con );
259
+
260
+ if ( ! empty( $attrs[ 'media' ] ) && $attrs[ 'media' ] !== 'all' ) {
261
+ $css .= '@media ' . $attrs[ 'media' ] . '{' . $con . "\n}";
262
+ }
263
+ else {
264
+ $css .= $con . "\n";
265
+ }
266
+
267
+ $html = str_replace( $match[ 0 ], '', $html );
268
+ }
269
+
270
+ if ( ! $css ) {
271
+ return false;
272
+ }
273
+
274
  // Generate critical css
275
  $data = array(
276
  'url' => $request_url,
277
  'ccss_type' => $ccss_type,
278
  'user_agent' => $user_agent,
279
  'is_mobile' => $is_mobile ? 1 : 0,
280
+ 'html' => $html,
281
+ 'css' => $css,
282
+ 'type' => 'CCSS',
283
+ );
284
 
285
+ Debug2::debug( '[CSS] Generating: ', $data );
286
 
287
+ $json = Cloud::post( Cloud::SVC_CCSS, $data, 180 );
288
  if ( ! is_array( $json ) ) {
289
  return false;
290
  }
291
 
292
  if ( empty( $json[ 'ccss' ] ) ) {
293
+ Debug2::debug( '[CSS] ❌ empty ccss' );
294
  $this->_popup_and_save( $ccss_type, $request_url );
295
+ return false;
296
  }
297
 
298
  // Add filters
299
+ $ccss = apply_filters( 'litespeed_ccss', $json[ 'ccss' ], $ccss_type );
300
 
301
  // Write to file
302
+ File::save( $ccss_file, $ccss, true );
303
 
304
  // Save summary data
305
+ $this->_summary[ 'last_spent' ] = time() - $this->_summary[ 'curr_request' ];
306
+ $this->_summary[ 'last_request' ] = $this->_summary[ 'curr_request' ];
307
+ $this->_summary[ 'curr_request' ] = 0;
308
  $this->_popup_and_save( $ccss_type, $request_url );
309
 
310
+ Debug2::debug( '[CSS] saved ccss ' . $ccss_file );
311
 
312
+ Debug2::debug2( '[CSS] ccss con: ' . $ccss );
313
 
314
+ return $ccss;
315
  }
316
 
317
  /**
335
 
336
  // Generate UCSS
337
  $data = array(
338
+ 'type' => 'UCSS',
339
  'url' => $request_url,
340
  'whitelist' => $this->_filter_whitelist(),
341
  'user_agent' => $user_agent,
356
 
357
  Debug2::debug( '[UCSS] Generating UCSS: ', $data );
358
 
359
+ $json = Cloud::post( Cloud::SVC_CCSS, $data, 180 );
360
  if ( ! is_array( $json ) ) {
361
  return false;
362
  }
421
  private function _popup_and_save( $ccss_type, $request_url )
422
  {
423
  if ( empty( $this->_summary[ 'ccss_type_history' ] ) ) {
424
+ $this->_summary[ 'ccss_type_history' ] = array();
425
  }
426
+ $this->_summary[ 'ccss_type_history' ][ $ccss_type ] = $request_url;
427
+ unset( $this->_summary[ 'queue' ][ $ccss_type ] );
428
 
429
  self::save_summary();
430
  }
437
  */
438
  private function _which_css()
439
  {
440
+ $css = Utility::page_type();
441
 
442
+ $unique = false;
443
 
444
  // Check if in separate css type option
445
+ $separate_posttypes = Conf::val( Base::O_OPTM_CCSS_SEP_POSTTYPE );
446
  if ( ! empty( $separate_posttypes ) && in_array( $css, $separate_posttypes ) ) {
447
+ Debug2::debug( '[CSS] Hit separate posttype setting [type] ' . $css );
448
+ $unique = true;
449
  }
450
 
451
+ $separate_uri = Conf::val( Base::O_OPTM_CCSS_SEP_URI );
452
  if ( ! empty( $separate_uri ) ) {
453
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $separate_uri );
454
  if ( $result ) {
455
+ Debug2::debug( '[CSS] Hit separate URI setting: ' . $result );
456
+ $unique = true;
457
  }
458
  }
459
 
460
  if ( $unique ) {
461
+ $css .= '-' . md5( $_SERVER[ 'REQUEST_URI' ] );
462
  }
463
 
464
  if ( $this->_separate_mobile_ccss() ) {
465
+ $css .= '.mobile';
466
  }
467
 
468
+ return $css;
469
  }
470
 
471
  /**
476
  */
477
  public static function handler()
478
  {
479
+ $instance = self::get_instance();
480
 
481
+ $type = Router::verify_type();
482
 
483
  switch ( $type ) {
484
  case self::TYPE_GENERATE_CRITICAL :
485
+ self::cron_ccss( true );
486
+ break;
487
 
488
  default:
489
+ break;
490
  }
491
 
492
+ Admin::redirect();
493
  }
494
 
495
  }
src/data.cls.php CHANGED
@@ -416,7 +416,7 @@ class Data extends Instance
416
  * @since 1.3.1
417
  * @access public
418
  */
419
- public function optm_save_src( $filename, $src ) {
420
  global $wpdb;
421
 
422
  $src = json_encode( $src );
@@ -424,7 +424,7 @@ class Data extends Instance
424
  'hash_name' => $filename,
425
  'src' => $src,
426
  'dateline' => time(),
427
- 'refer' => ! empty( $_SERVER[ 'SCRIPT_URI' ] ) ? $_SERVER[ 'SCRIPT_URI' ] : '',
428
  );
429
 
430
  $res = $wpdb->replace( $this->tb( 'cssjs' ), $f );
416
  * @since 1.3.1
417
  * @access public
418
  */
419
+ public function optm_save_src( $filename, $src, $request_url ) {
420
  global $wpdb;
421
 
422
  $src = json_encode( $src );
424
  'hash_name' => $filename,
425
  'src' => $src,
426
  'dateline' => time(),
427
+ 'refer' => $request_url,
428
  );
429
 
430
  $res = $wpdb->replace( $this->tb( 'cssjs' ), $f );
src/db-optm.cls.php CHANGED
@@ -12,8 +12,7 @@ namespace LiteSpeed;
12
 
13
  defined( 'WPINC' ) || exit;
14
 
15
- class DB_Optm extends Instance
16
- {
17
  private static $_hide_more = false;
18
 
19
  private static $TYPES = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients', 'optimize_tables', 'all_cssjs' );
@@ -26,8 +25,7 @@ class DB_Optm extends Instance
26
  *
27
  * @since 3.0
28
  */
29
- public static function hide_more()
30
- {
31
  return self::$_hide_more;
32
  }
33
 
@@ -40,8 +38,7 @@ class DB_Optm extends Instance
40
  * @param bool $ignore_multisite If ignore multisite check
41
  * @return int The rows that will be affected
42
  */
43
- public static function db_count( $type, $ignore_multisite = false )
44
- {
45
  if ( $type === 'all' ) {
46
  $num = 0;
47
  foreach ( self::$TYPES as $v ) {
@@ -127,8 +124,7 @@ class DB_Optm extends Instance
127
  * @since 3.0 changed to private
128
  * @access private
129
  */
130
- private function _db_clean( $type )
131
- {
132
  if ( $type === 'all' ) {
133
  foreach ( self::$TYPES as $v ) {
134
  $this->_db_clean( $v );
@@ -217,8 +213,7 @@ class DB_Optm extends Instance
217
  * @since 3.0
218
  * @access public
219
  */
220
- public function list_myisam()
221
- {
222
  global $wpdb;
223
  $q = "SELECT * FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE = 'myisam' AND TABLE_NAME LIKE '{$wpdb->prefix}%'";
224
  return $wpdb->get_results( $q );
@@ -230,8 +225,7 @@ class DB_Optm extends Instance
230
  * @since 3.0
231
  * @access private
232
  */
233
- private function _conv_innodb()
234
- {
235
  global $wpdb;
236
 
237
  if ( empty( $_GET[ 'tb' ] ) ) {
@@ -270,8 +264,7 @@ class DB_Optm extends Instance
270
  * @since 3.0
271
  * @access public
272
  */
273
- public function autoload_summary()
274
- {
275
  global $wpdb;
276
 
277
  $summary = $wpdb->get_row( "SELECT SUM(LENGTH(option_value)) AS autoload_size,COUNT(*) AS autload_entries FROM `$wpdb->options` WHERE autoload='yes'" );
@@ -287,8 +280,7 @@ class DB_Optm extends Instance
287
  * @since 3.0
288
  * @access public
289
  */
290
- public static function handler()
291
- {
292
  $instance = self::get_instance();
293
 
294
  $type = Router::verify_type();
12
 
13
  defined( 'WPINC' ) || exit;
14
 
15
+ class DB_Optm extends Instance {
 
16
  private static $_hide_more = false;
17
 
18
  private static $TYPES = array( 'revision', 'auto_draft', 'trash_post', 'spam_comment', 'trash_comment', 'trackback-pingback', 'expired_transient', 'all_transients', 'optimize_tables', 'all_cssjs' );
25
  *
26
  * @since 3.0
27
  */
28
+ public static function hide_more() {
 
29
  return self::$_hide_more;
30
  }
31
 
38
  * @param bool $ignore_multisite If ignore multisite check
39
  * @return int The rows that will be affected
40
  */
41
+ public static function db_count( $type, $ignore_multisite = false ) {
 
42
  if ( $type === 'all' ) {
43
  $num = 0;
44
  foreach ( self::$TYPES as $v ) {
124
  * @since 3.0 changed to private
125
  * @access private
126
  */
127
+ private function _db_clean( $type ) {
 
128
  if ( $type === 'all' ) {
129
  foreach ( self::$TYPES as $v ) {
130
  $this->_db_clean( $v );
213
  * @since 3.0
214
  * @access public
215
  */
216
+ public function list_myisam() {
 
217
  global $wpdb;
218
  $q = "SELECT * FROM information_schema.tables WHERE TABLE_SCHEMA = '" . DB_NAME . "' and ENGINE = 'myisam' AND TABLE_NAME LIKE '{$wpdb->prefix}%'";
219
  return $wpdb->get_results( $q );
225
  * @since 3.0
226
  * @access private
227
  */
228
+ private function _conv_innodb() {
 
229
  global $wpdb;
230
 
231
  if ( empty( $_GET[ 'tb' ] ) ) {
264
  * @since 3.0
265
  * @access public
266
  */
267
+ public function autoload_summary() {
 
268
  global $wpdb;
269
 
270
  $summary = $wpdb->get_row( "SELECT SUM(LENGTH(option_value)) AS autoload_size,COUNT(*) AS autload_entries FROM `$wpdb->options` WHERE autoload='yes'" );
280
  * @since 3.0
281
  * @access public
282
  */
283
+ public static function handler() {
 
284
  $instance = self::get_instance();
285
 
286
  $type = Router::verify_type();
src/debug2.cls.php CHANGED
@@ -10,20 +10,19 @@
10
  * @subpackage LiteSpeed/inc
11
  * @author LiteSpeed Technologies <info@litespeedtech.com>
12
  */
13
- namespace LiteSpeed ;
14
 
15
- defined( 'WPINC' ) || exit ;
16
 
17
- class Debug2 extends Instance
18
- {
19
- protected static $_instance ;
20
- private static $log_path ;
21
- private static $_prefix ;
22
 
23
- const TYPE_CLEAR_LOG = 'clear_log' ;
24
- const TYPE_BETA_TEST = 'beta_test' ;
25
 
26
- const BETA_TEST_URL = 'beta_test_url' ;
27
 
28
  const BETA_TEST_URL_GITHUB = 'https://github.com/litespeedtech/lscache_wp/archive/master.zip';
29
  const BETA_TEST_URL_WP = 'https://downloads.wordpress.org/plugin/litespeed-cache.zip';
@@ -36,17 +35,16 @@ class Debug2 extends Instance
36
  * @since 1.1.2
37
  * @access public
38
  */
39
- protected function __construct()
40
- {
41
- self::$log_path = LSCWP_CONTENT_DIR . '/debug.log' ;
42
  if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Crawler::FAST_USER_AGENT ) === 0 ) {
43
- self::$log_path = LSCWP_CONTENT_DIR . '/crawler.log' ;
44
  }
45
 
46
- ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', get_current_blog_id() ) ;
47
 
48
  if ( Conf::val( Base::O_DEBUG_LEVEL ) ) {
49
- ! defined( 'LSCWP_LOG_MORE' ) && define( 'LSCWP_LOG_MORE', true ) ;
50
  }
51
 
52
  }
@@ -57,11 +55,10 @@ class Debug2 extends Instance
57
  * @since 2.9.5
58
  * @access public
59
  */
60
- public function beta_test( $zip = false )
61
- {
62
  if ( ! $zip ) {
63
  if ( empty( $_REQUEST[ self::BETA_TEST_URL ] ) ) {
64
- return ;
65
  }
66
 
67
  $zip = $_REQUEST[ self::BETA_TEST_URL ];
@@ -84,30 +81,30 @@ class Debug2 extends Instance
84
  }
85
 
86
  if ( ! $zip ) {
87
- Debug2::debug( '[Debug2] ❌ No ZIP file' ) ;
88
- return ;
89
  }
90
 
91
- Debug2::debug( '[Debug2] ZIP file ' . $zip ) ;
92
 
93
- $update_plugins = get_site_transient( 'update_plugins' ) ;
94
  if ( ! is_object( $update_plugins ) ) {
95
- $update_plugins = new \stdClass() ;
96
  }
97
 
98
- $plugin_info = new \stdClass() ;
99
  $plugin_info->new_version = Core::VER;
100
  $plugin_info->slug = Core::PLUGIN_NAME;
101
  $plugin_info->plugin = Core::PLUGIN_FILE;
102
- $plugin_info->package = $zip ;
103
- $plugin_info->url = 'https://wordpress.org/plugins/litespeed-cache/' ;
104
 
105
- $update_plugins->response[ Core::PLUGIN_FILE ] = $plugin_info ;
106
 
107
- set_site_transient( 'update_plugins', $update_plugins ) ;
108
 
109
  // Run upgrade
110
- Activation::get_instance()->upgrade() ;
111
  }
112
 
113
  /**
@@ -116,18 +113,17 @@ class Debug2 extends Instance
116
  * @since 2.9.5
117
  * @access private
118
  */
119
- private function _package_zip( $commit )
120
- {
121
  $data = array(
122
  'commit' => $commit,
123
  );
124
  $res = Cloud::get( Cloud::API_BETA_TEST, $data );
125
 
126
  if ( empty( $res[ 'zip' ] ) ) {
127
- return false ;
128
  }
129
 
130
- return $res[ 'zip' ] ;
131
  }
132
 
133
  /**
@@ -136,20 +132,19 @@ class Debug2 extends Instance
136
  * @since 2.7
137
  * @access public
138
  */
139
- public static function log_purge( $purge_header )
140
- {
141
  // Check if debug is ON
142
  if ( ! defined( 'LSCWP_LOG' ) && ! defined( 'LSCWP_LOG_BYPASS_NOTADMIN' ) ) {
143
- return ;
144
  }
145
 
146
- $purge_file = LSCWP_CONTENT_DIR . '/debug.purge.log' ;
147
 
148
- self::get_instance()->_init_request( $purge_file ) ;
149
 
150
- $msg = $purge_header . self::_backtrace_info( 6 ) ;
151
 
152
- File::append( $purge_file, self::format_message( $msg ) ) ;
153
 
154
  }
155
 
@@ -159,13 +154,12 @@ class Debug2 extends Instance
159
  * @since 1.1.0
160
  * @access public
161
  */
162
- public static function init()
163
- {
164
- $debug = Conf::val( Base::O_DEBUG ) ;
165
  if ( $debug == Base::VAL_ON2 ) {
166
  if ( ! Router::is_admin_ip() ) {
167
- define( 'LSCWP_LOG_BYPASS_NOTADMIN', true ) ;
168
- return ;
169
  }
170
  }
171
 
@@ -174,25 +168,25 @@ class Debug2 extends Instance
174
  * This is after LSCWP_LOG_BYPASS_NOTADMIN to make `log_purge()` still work
175
  * @since 3.0
176
  */
177
- $list = Conf::val( Base::O_DEBUG_INC ) ;
178
  if ( $list ) {
179
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $list ) ;
180
  if ( ! $result ) {
181
- return ;
182
  }
183
  }
184
 
185
- $list = Conf::val( Base::O_DEBUG_EXC ) ;
186
  if ( $list ) {
187
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $list ) ;
188
  if ( $result ) {
189
- return ;
190
  }
191
  }
192
 
193
  if ( ! defined( 'LSCWP_LOG' ) ) {// If not initialized, do it now
194
- self::get_instance()->_init_request() ;
195
- define( 'LSCWP_LOG', true ) ;
196
 
197
  }
198
  }
@@ -203,25 +197,24 @@ class Debug2 extends Instance
203
  * @since 1.0.12
204
  * @access private
205
  */
206
- private function _init_request( $log_file = null )
207
- {
208
  if ( ! $log_file ) {
209
- $log_file = self::$log_path ;
210
  }
211
 
212
  // Check log file size
213
- $log_file_size = Conf::val( Base::O_DEBUG_FILESIZE ) ;
214
  if ( file_exists( $log_file ) && filesize( $log_file ) > $log_file_size * 1000000 ) {
215
- File::save( $log_file, '' ) ;
216
  }
217
 
218
  // For more than 2s's requests, add more break
219
  if ( file_exists( $log_file ) && time() - filemtime( $log_file ) > 2 ) {
220
- File::append( $log_file, "\n\n\n\n" ) ;
221
  }
222
 
223
  if ( PHP_SAPI == 'cli' ) {
224
- return ;
225
  }
226
 
227
  $servervars = array(
@@ -234,62 +227,62 @@ class Debug2 extends Instance
234
  'LSCACHE_VARY_COOKIE' => '',
235
  'LSCACHE_VARY_VALUE' => '',
236
  'ESI_CONTENT_TYPE' => '',
237
- ) ;
238
- $server = array_merge( $servervars, $_SERVER ) ;
239
- $params = array() ;
240
 
241
  if ( isset( $_SERVER[ 'HTTPS' ] ) && $_SERVER[ 'HTTPS' ] == 'on' ) {
242
- $server['SERVER_PROTOCOL'] .= ' (HTTPS) ' ;
243
  }
244
 
245
- $param = sprintf( '💓 ------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) ) ;
246
 
247
- $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '' ;
248
  if ( Conf::val( Base::O_DEBUG_COLLAPS_QS ) ) {
249
  if ( strlen( $qs ) > 53 ) {
250
- $qs = substr( $qs, 0, 53 ) . '...' ;
251
  }
252
  if ( $qs ) {
253
- $param .= ' ? ' . $qs ;
254
  }
255
- $params[] = $param ;
256
  }
257
  else {
258
- $params[] = $param ;
259
- $params[] = 'Query String: ' . $qs ;
260
  }
261
 
262
  if ( ! empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
263
- $params[] = 'HTTP_REFERER: ' . $server[ 'HTTP_REFERER' ] ;
264
  }
265
 
266
  if ( defined( 'LSCWP_LOG_MORE' ) ) {
267
- $params[] = 'User Agent: ' . $server[ 'HTTP_USER_AGENT' ] ;
268
- $params[] = 'Accept: ' . $server['HTTP_ACCEPT'] ;
269
- $params[] = 'Accept Encoding: ' . $server['HTTP_ACCEPT_ENCODING'] ;
270
  }
271
  if ( Conf::val( Base::O_DEBUG_COOKIE ) ) {
272
- $params[] = 'Cookie: ' . $server['HTTP_COOKIE'] ;
273
  }
274
  if ( isset( $_COOKIE[ '_lscache_vary' ] ) ) {
275
- $params[] = 'Cookie _lscache_vary: ' . $_COOKIE[ '_lscache_vary' ] ;
276
  }
277
  if ( defined( 'LSCWP_LOG_MORE' ) ) {
278
- $params[] = 'X-LSCACHE: ' . ( ! empty( $server[ 'X-LSCACHE' ] ) ? 'true' : 'false' ) ;
279
  }
280
  if( $server['LSCACHE_VARY_COOKIE'] ) {
281
- $params[] = 'LSCACHE_VARY_COOKIE: ' . $server['LSCACHE_VARY_COOKIE'] ;
282
  }
283
  if( $server['LSCACHE_VARY_VALUE'] ) {
284
- $params[] = 'LSCACHE_VARY_VALUE: ' . $server['LSCACHE_VARY_VALUE'] ;
285
  }
286
  if( $server['ESI_CONTENT_TYPE'] ) {
287
- $params[] = 'ESI_CONTENT_TYPE: ' . $server['ESI_CONTENT_TYPE'] ;
288
  }
289
 
290
- $request = array_map( __CLASS__ . '::format_message', $params ) ;
291
 
292
- File::append( $log_file, $request ) ;
293
  }
294
 
295
  /**
@@ -300,62 +293,72 @@ class Debug2 extends Instance
300
  * @param string $msg The log message to write.
301
  * @return string The formatted log message.
302
  */
303
- private static function format_message( $msg )
304
- {
305
  // If call here without calling get_enabled() first, improve compatibility
306
  if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
307
- return $msg . "\n" ;
308
  }
309
 
310
  if ( ! isset( self::$_prefix ) ) {
311
  // address
312
  if ( PHP_SAPI == 'cli' ) {
313
- $addr = '=CLI=' ;
314
  if ( isset( $_SERVER[ 'USER' ] ) ) {
315
- $addr .= $_SERVER[ 'USER' ] ;
316
  }
317
  elseif ( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) {
318
- $addr .= $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ;
319
  }
320
  }
321
  else {
322
- $addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ] ;
323
  }
324
 
325
  // Generate a unique string per request
326
- self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, Str::rrand( 3 ) ) ;
327
  }
328
- list( $usec, $sec ) = explode(' ', microtime() ) ;
329
- return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n" ;
330
  }
331
 
332
  /**
333
  * Direct call to log a debug message.
334
  *
335
  * @since 1.1.3
336
- * @since 1.6 Added array dump as 2nd param
337
  * @access public
338
- * @param string $msg The debug message.
339
- * @param int|array $backtrace_limit Backtrace depth, Or the array to dump
340
  */
341
- public static function debug( $msg, $backtrace_limit = false )
342
- {
343
  if ( ! defined( 'LSCWP_LOG' ) ) {
344
- return ;
345
  }
346
 
347
  if ( $backtrace_limit !== false ) {
348
  if ( ! is_numeric( $backtrace_limit ) ) {
349
- $msg .= ' --- ' . var_export( $backtrace_limit, true ) ;
350
- self::push( $msg ) ;
351
- return ;
 
352
  }
353
 
354
- self::push( $msg, $backtrace_limit + 1 ) ;
355
- return ;
356
  }
357
 
358
- self::push( $msg ) ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
359
  }
360
 
361
  /**
@@ -363,15 +366,12 @@ class Debug2 extends Instance
363
  *
364
  * @since 1.2.0
365
  * @access public
366
- * @param string $msg The debug message.
367
- * @param int $backtrace_limit Backtrace depth.
368
  */
369
- public static function debug2( $msg, $backtrace_limit = false )
370
- {
371
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
372
- return ;
373
  }
374
- self::debug( $msg, $backtrace_limit ) ;
375
  }
376
 
377
  /**
@@ -382,14 +382,13 @@ class Debug2 extends Instance
382
  * @param string $msg The debug message.
383
  * @param int $backtrace_limit Backtrace depth.
384
  */
385
- private static function push( $msg, $backtrace_limit = false )
386
- {
387
  // backtrace handler
388
  if ( defined( 'LSCWP_LOG_MORE' ) && $backtrace_limit !== false ) {
389
- $msg .= self::_backtrace_info( $backtrace_limit ) ;
390
  }
391
 
392
- File::append( self::$log_path, self::format_message( $msg ) ) ;
393
  }
394
 
395
  /**
@@ -397,21 +396,20 @@ class Debug2 extends Instance
397
  *
398
  * @since 2.7
399
  */
400
- private static function _backtrace_info( $backtrace_limit )
401
- {
402
- $msg = '' ;
403
 
404
  $trace = version_compare( PHP_VERSION, '5.4.0', '<' ) ? debug_backtrace() : debug_backtrace( false, $backtrace_limit + 3 );
405
- for ( $i=2 ; $i <= $backtrace_limit + 2 ; $i++ ) {// 0st => _backtrace_info(), 1st => push()
406
  if ( empty( $trace[ $i ][ 'class' ] ) ) {
407
  if ( empty( $trace[ $i ][ 'file' ] ) ) {
408
- break ;
409
  }
410
- $log = "\n" . $trace[ $i ][ 'file' ] ;
411
  }
412
  else {
413
  if ( $trace[$i]['class'] == __CLASS__ ) {
414
- continue ;
415
  }
416
 
417
  $args = '';
@@ -431,12 +429,12 @@ class Debug2 extends Instance
431
  $log = str_replace('Core', 'LSC', $trace[$i]['class']) . $trace[$i]['type'] . $trace[$i]['function'] . '(' . $args . ')';
432
  }
433
  if ( ! empty( $trace[$i-1]['line'] ) ) {
434
- $log .= '@' . $trace[$i-1]['line'] ;
435
  }
436
- $msg .= " => $log" ;
437
  }
438
 
439
- return $msg ;
440
  }
441
 
442
  /**
@@ -445,10 +443,9 @@ class Debug2 extends Instance
445
  * @since 1.6.6
446
  * @access private
447
  */
448
- private function _clear_log()
449
- {
450
- File::save( self::$log_path, '' ) ;
451
- File::save( LSCWP_CONTENT_DIR . '/debug.purge.log', '' ) ;
452
  }
453
 
454
  /**
@@ -457,25 +454,24 @@ class Debug2 extends Instance
457
  * @since 1.6.6
458
  * @access public
459
  */
460
- public static function handler()
461
- {
462
- $instance = self::get_instance() ;
463
 
464
- $type = Router::verify_type() ;
465
 
466
  switch ( $type ) {
467
  case self::TYPE_CLEAR_LOG :
468
- $instance->_clear_log() ;
469
- break ;
470
 
471
  case self::TYPE_BETA_TEST :
472
- $instance->beta_test() ;
473
- break ;
474
 
475
  default:
476
- break ;
477
  }
478
 
479
- Admin::redirect() ;
480
  }
481
  }
10
  * @subpackage LiteSpeed/inc
11
  * @author LiteSpeed Technologies <info@litespeedtech.com>
12
  */
13
+ namespace LiteSpeed;
14
 
15
+ defined( 'WPINC' ) || exit;
16
 
17
+ class Debug2 extends Instance {
18
+ protected static $_instance;
19
+ private static $log_path;
20
+ private static $_prefix;
 
21
 
22
+ const TYPE_CLEAR_LOG = 'clear_log';
23
+ const TYPE_BETA_TEST = 'beta_test';
24
 
25
+ const BETA_TEST_URL = 'beta_test_url';
26
 
27
  const BETA_TEST_URL_GITHUB = 'https://github.com/litespeedtech/lscache_wp/archive/master.zip';
28
  const BETA_TEST_URL_WP = 'https://downloads.wordpress.org/plugin/litespeed-cache.zip';
35
  * @since 1.1.2
36
  * @access public
37
  */
38
+ protected function __construct() {
39
+ self::$log_path = LSCWP_CONTENT_DIR . '/debug.log';
 
40
  if ( ! empty( $_SERVER[ 'HTTP_USER_AGENT' ] ) && strpos( $_SERVER[ 'HTTP_USER_AGENT' ], Crawler::FAST_USER_AGENT ) === 0 ) {
41
+ self::$log_path = LSCWP_CONTENT_DIR . '/crawler.log';
42
  }
43
 
44
+ ! defined( 'LSCWP_LOG_TAG' ) && define( 'LSCWP_LOG_TAG', get_current_blog_id() );
45
 
46
  if ( Conf::val( Base::O_DEBUG_LEVEL ) ) {
47
+ ! defined( 'LSCWP_LOG_MORE' ) && define( 'LSCWP_LOG_MORE', true );
48
  }
49
 
50
  }
55
  * @since 2.9.5
56
  * @access public
57
  */
58
+ public function beta_test( $zip = false ) {
 
59
  if ( ! $zip ) {
60
  if ( empty( $_REQUEST[ self::BETA_TEST_URL ] ) ) {
61
+ return;
62
  }
63
 
64
  $zip = $_REQUEST[ self::BETA_TEST_URL ];
81
  }
82
 
83
  if ( ! $zip ) {
84
+ Debug2::debug( '[Debug2] ❌ No ZIP file' );
85
+ return;
86
  }
87
 
88
+ Debug2::debug( '[Debug2] ZIP file ' . $zip );
89
 
90
+ $update_plugins = get_site_transient( 'update_plugins' );
91
  if ( ! is_object( $update_plugins ) ) {
92
+ $update_plugins = new \stdClass();
93
  }
94
 
95
+ $plugin_info = new \stdClass();
96
  $plugin_info->new_version = Core::VER;
97
  $plugin_info->slug = Core::PLUGIN_NAME;
98
  $plugin_info->plugin = Core::PLUGIN_FILE;
99
+ $plugin_info->package = $zip;
100
+ $plugin_info->url = 'https://wordpress.org/plugins/litespeed-cache/';
101
 
102
+ $update_plugins->response[ Core::PLUGIN_FILE ] = $plugin_info;
103
 
104
+ set_site_transient( 'update_plugins', $update_plugins );
105
 
106
  // Run upgrade
107
+ Activation::get_instance()->upgrade();
108
  }
109
 
110
  /**
113
  * @since 2.9.5
114
  * @access private
115
  */
116
+ private function _package_zip( $commit ) {
 
117
  $data = array(
118
  'commit' => $commit,
119
  );
120
  $res = Cloud::get( Cloud::API_BETA_TEST, $data );
121
 
122
  if ( empty( $res[ 'zip' ] ) ) {
123
+ return false;
124
  }
125
 
126
+ return $res[ 'zip' ];
127
  }
128
 
129
  /**
132
  * @since 2.7
133
  * @access public
134
  */
135
+ public static function log_purge( $purge_header ) {
 
136
  // Check if debug is ON
137
  if ( ! defined( 'LSCWP_LOG' ) && ! defined( 'LSCWP_LOG_BYPASS_NOTADMIN' ) ) {
138
+ return;
139
  }
140
 
141
+ $purge_file = LSCWP_CONTENT_DIR . '/debug.purge.log';
142
 
143
+ self::get_instance()->_init_request( $purge_file );
144
 
145
+ $msg = $purge_header . self::_backtrace_info( 6 );
146
 
147
+ File::append( $purge_file, self::format_message( $msg ) );
148
 
149
  }
150
 
154
  * @since 1.1.0
155
  * @access public
156
  */
157
+ public static function init() {
158
+ $debug = Conf::val( Base::O_DEBUG );
 
159
  if ( $debug == Base::VAL_ON2 ) {
160
  if ( ! Router::is_admin_ip() ) {
161
+ define( 'LSCWP_LOG_BYPASS_NOTADMIN', true );
162
+ return;
163
  }
164
  }
165
 
168
  * This is after LSCWP_LOG_BYPASS_NOTADMIN to make `log_purge()` still work
169
  * @since 3.0
170
  */
171
+ $list = Conf::val( Base::O_DEBUG_INC );
172
  if ( $list ) {
173
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $list );
174
  if ( ! $result ) {
175
+ return;
176
  }
177
  }
178
 
179
+ $list = Conf::val( Base::O_DEBUG_EXC );
180
  if ( $list ) {
181
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $list );
182
  if ( $result ) {
183
+ return;
184
  }
185
  }
186
 
187
  if ( ! defined( 'LSCWP_LOG' ) ) {// If not initialized, do it now
188
+ self::get_instance()->_init_request();
189
+ define( 'LSCWP_LOG', true );
190
 
191
  }
192
  }
197
  * @since 1.0.12
198
  * @access private
199
  */
200
+ private function _init_request( $log_file = null ) {
 
201
  if ( ! $log_file ) {
202
+ $log_file = self::$log_path;
203
  }
204
 
205
  // Check log file size
206
+ $log_file_size = Conf::val( Base::O_DEBUG_FILESIZE );
207
  if ( file_exists( $log_file ) && filesize( $log_file ) > $log_file_size * 1000000 ) {
208
+ File::save( $log_file, '' );
209
  }
210
 
211
  // For more than 2s's requests, add more break
212
  if ( file_exists( $log_file ) && time() - filemtime( $log_file ) > 2 ) {
213
+ File::append( $log_file, "\n\n\n\n" );
214
  }
215
 
216
  if ( PHP_SAPI == 'cli' ) {
217
+ return;
218
  }
219
 
220
  $servervars = array(
227
  'LSCACHE_VARY_COOKIE' => '',
228
  'LSCACHE_VARY_VALUE' => '',
229
  'ESI_CONTENT_TYPE' => '',
230
+ );
231
+ $server = array_merge( $servervars, $_SERVER );
232
+ $params = array();
233
 
234
  if ( isset( $_SERVER[ 'HTTPS' ] ) && $_SERVER[ 'HTTPS' ] == 'on' ) {
235
+ $server['SERVER_PROTOCOL'] .= ' (HTTPS) ';
236
  }
237
 
238
+ $param = sprintf( '💓 ------%s %s %s', $server['REQUEST_METHOD'], $server['SERVER_PROTOCOL'], strtok( $server['REQUEST_URI'], '?' ) );
239
 
240
+ $qs = ! empty( $server['QUERY_STRING'] ) ? $server['QUERY_STRING'] : '';
241
  if ( Conf::val( Base::O_DEBUG_COLLAPS_QS ) ) {
242
  if ( strlen( $qs ) > 53 ) {
243
+ $qs = substr( $qs, 0, 53 ) . '...';
244
  }
245
  if ( $qs ) {
246
+ $param .= ' ? ' . $qs;
247
  }
248
+ $params[] = $param;
249
  }
250
  else {
251
+ $params[] = $param;
252
+ $params[] = 'Query String: ' . $qs;
253
  }
254
 
255
  if ( ! empty( $_SERVER[ 'HTTP_REFERER' ] ) ) {
256
+ $params[] = 'HTTP_REFERER: ' . $server[ 'HTTP_REFERER' ];
257
  }
258
 
259
  if ( defined( 'LSCWP_LOG_MORE' ) ) {
260
+ $params[] = 'User Agent: ' . $server[ 'HTTP_USER_AGENT' ];
261
+ $params[] = 'Accept: ' . $server['HTTP_ACCEPT'];
262
+ $params[] = 'Accept Encoding: ' . $server['HTTP_ACCEPT_ENCODING'];
263
  }
264
  if ( Conf::val( Base::O_DEBUG_COOKIE ) ) {
265
+ $params[] = 'Cookie: ' . $server['HTTP_COOKIE'];
266
  }
267
  if ( isset( $_COOKIE[ '_lscache_vary' ] ) ) {
268
+ $params[] = 'Cookie _lscache_vary: ' . $_COOKIE[ '_lscache_vary' ];
269
  }
270
  if ( defined( 'LSCWP_LOG_MORE' ) ) {
271
+ $params[] = 'X-LSCACHE: ' . ( ! empty( $server[ 'X-LSCACHE' ] ) ? 'true' : 'false' );
272
  }
273
  if( $server['LSCACHE_VARY_COOKIE'] ) {
274
+ $params[] = 'LSCACHE_VARY_COOKIE: ' . $server['LSCACHE_VARY_COOKIE'];
275
  }
276
  if( $server['LSCACHE_VARY_VALUE'] ) {
277
+ $params[] = 'LSCACHE_VARY_VALUE: ' . $server['LSCACHE_VARY_VALUE'];
278
  }
279
  if( $server['ESI_CONTENT_TYPE'] ) {
280
+ $params[] = 'ESI_CONTENT_TYPE: ' . $server['ESI_CONTENT_TYPE'];
281
  }
282
 
283
+ $request = array_map( __CLASS__ . '::format_message', $params );
284
 
285
+ File::append( $log_file, $request );
286
  }
287
 
288
  /**
293
  * @param string $msg The log message to write.
294
  * @return string The formatted log message.
295
  */
296
+ private static function format_message( $msg ) {
 
297
  // If call here without calling get_enabled() first, improve compatibility
298
  if ( ! defined( 'LSCWP_LOG_TAG' ) ) {
299
+ return $msg . "\n";
300
  }
301
 
302
  if ( ! isset( self::$_prefix ) ) {
303
  // address
304
  if ( PHP_SAPI == 'cli' ) {
305
+ $addr = '=CLI=';
306
  if ( isset( $_SERVER[ 'USER' ] ) ) {
307
+ $addr .= $_SERVER[ 'USER' ];
308
  }
309
  elseif ( $_SERVER[ 'HTTP_X_FORWARDED_FOR' ] ) {
310
+ $addr .= $_SERVER[ 'HTTP_X_FORWARDED_FOR' ];
311
  }
312
  }
313
  else {
314
+ $addr = $_SERVER[ 'REMOTE_ADDR' ] . ':' . $_SERVER[ 'REMOTE_PORT' ];
315
  }
316
 
317
  // Generate a unique string per request
318
+ self::$_prefix = sprintf( " [%s %s %s] ", $addr, LSCWP_LOG_TAG, Str::rrand( 3 ) );
319
  }
320
+ list( $usec, $sec ) = explode(' ', microtime() );
321
+ return date( 'm/d/y H:i:s', $sec + LITESPEED_TIME_OFFSET ) . substr( $usec, 1, 4 ) . self::$_prefix . $msg . "\n";
322
  }
323
 
324
  /**
325
  * Direct call to log a debug message.
326
  *
327
  * @since 1.1.3
 
328
  * @access public
 
 
329
  */
330
+ public static function debug( $msg, $backtrace_limit = false ) {
 
331
  if ( ! defined( 'LSCWP_LOG' ) ) {
332
+ return;
333
  }
334
 
335
  if ( $backtrace_limit !== false ) {
336
  if ( ! is_numeric( $backtrace_limit ) ) {
337
+ $backtrace_limit = self::trim_longtext( $backtrace_limit );
338
+ $msg .= ' --- ' . var_export( $backtrace_limit, true );
339
+ self::push( $msg );
340
+ return;
341
  }
342
 
343
+ self::push( $msg, $backtrace_limit + 1 );
344
+ return;
345
  }
346
 
347
+ self::push( $msg );
348
+ }
349
+
350
+ /**
351
+ * Trim long string before array dump
352
+ * @since 3.3
353
+ */
354
+ public static function trim_longtext( $backtrace_limit ) {
355
+ if ( is_array( $backtrace_limit ) ) {
356
+ $backtrace_limit = array_map( __CLASS__ . '::trim_longtext', $backtrace_limit );
357
+ }
358
+ if ( is_string( $backtrace_limit ) && strlen( $backtrace_limit ) > 500 ) {
359
+ $backtrace_limit = substr( $backtrace_limit, 0, 1000 ) . '...';
360
+ }
361
+ return $backtrace_limit;
362
  }
363
 
364
  /**
366
  *
367
  * @since 1.2.0
368
  * @access public
 
 
369
  */
370
+ public static function debug2( $msg, $backtrace_limit = false ) {
 
371
  if ( ! defined( 'LSCWP_LOG_MORE' ) ) {
372
+ return;
373
  }
374
+ self::debug( $msg, $backtrace_limit );
375
  }
376
 
377
  /**
382
  * @param string $msg The debug message.
383
  * @param int $backtrace_limit Backtrace depth.
384
  */
385
+ private static function push( $msg, $backtrace_limit = false ) {
 
386
  // backtrace handler
387
  if ( defined( 'LSCWP_LOG_MORE' ) && $backtrace_limit !== false ) {
388
+ $msg .= self::_backtrace_info( $backtrace_limit );
389
  }
390
 
391
+ File::append( self::$log_path, self::format_message( $msg ) );
392
  }
393
 
394
  /**
396
  *
397
  * @since 2.7
398
  */
399
+ private static function _backtrace_info( $backtrace_limit ) {
400
+ $msg = '';
 
401
 
402
  $trace = version_compare( PHP_VERSION, '5.4.0', '<' ) ? debug_backtrace() : debug_backtrace( false, $backtrace_limit + 3 );
403
+ for ( $i=2; $i <= $backtrace_limit + 2; $i++ ) {// 0st => _backtrace_info(), 1st => push()
404
  if ( empty( $trace[ $i ][ 'class' ] ) ) {
405
  if ( empty( $trace[ $i ][ 'file' ] ) ) {
406
+ break;
407
  }
408
+ $log = "\n" . $trace[ $i ][ 'file' ];
409
  }
410
  else {
411
  if ( $trace[$i]['class'] == __CLASS__ ) {
412
+ continue;
413
  }
414
 
415
  $args = '';
429
  $log = str_replace('Core', 'LSC', $trace[$i]['class']) . $trace[$i]['type'] . $trace[$i]['function'] . '(' . $args . ')';
430
  }
431
  if ( ! empty( $trace[$i-1]['line'] ) ) {
432
+ $log .= '@' . $trace[$i-1]['line'];
433
  }
434
+ $msg .= " => $log";
435
  }
436
 
437
+ return $msg;
438
  }
439
 
440
  /**
443
  * @since 1.6.6
444
  * @access private
445
  */
446
+ private function _clear_log() {
447
+ File::save( self::$log_path, '' );
448
+ File::save( LSCWP_CONTENT_DIR . '/debug.purge.log', '' );
 
449
  }
450
 
451
  /**
454
  * @since 1.6.6
455
  * @access public
456
  */
457
+ public static function handler() {
458
+ $instance = self::get_instance();
 
459
 
460
+ $type = Router::verify_type();
461
 
462
  switch ( $type ) {
463
  case self::TYPE_CLEAR_LOG :
464
+ $instance->_clear_log();
465
+ break;
466
 
467
  case self::TYPE_BETA_TEST :
468
+ $instance->beta_test();
469
+ break;
470
 
471
  default:
472
+ break;
473
  }
474
 
475
+ Admin::redirect();
476
  }
477
  }
src/doc.cls.php CHANGED
@@ -7,13 +7,12 @@
7
  * @subpackage LiteSpeed/src
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
- namespace LiteSpeed ;
11
 
12
- defined( 'WPINC' ) || exit ;
13
 
14
- class Doc
15
- {
16
- // protected static $_instance ;
17
 
18
  /**
19
  * Privacy policy
@@ -21,9 +20,8 @@ class Doc
21
  * @since 2.2.7
22
  * @access public
23
  */
24
- public static function privacy_policy()
25
- {
26
- return __( 'This site utilizes caching in order to facilitate a faster response time and better user experience. Caching potentially stores a duplicate copy of every web page that is on display on this site. All cache files are temporary, and are never accessed by any third party, except as necessary to obtain technical support from the cache plugin vendor. Cache files expire on a schedule set by the site administrator, but may easily be purged by the admin before their natural expiration, if necessary.', 'litespeed-cache' ) ;
27
  }
28
 
29
 
@@ -33,9 +31,24 @@ class Doc
33
  * @since 2.4.2
34
  * @access public
35
  */
36
- public static function learn_more( $url )
37
- {
38
- return ' <a href="' . $url . '" target="_blank" class="litespeed-learn-more">' . __( 'Learn More', 'litespeed-cache' ) . '</a>' ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  /**
@@ -44,9 +57,8 @@ class Doc
44
  * @since 3.0
45
  * @access public
46
  */
47
- public static function one_per_line()
48
- {
49
- echo __( 'One per line.', 'litespeed-cache' ) ;
50
  }
51
 
52
  /**
@@ -55,12 +67,11 @@ class Doc
55
  * @since 3.0
56
  * @access public
57
  */
58
- public static function notice_htaccess()
59
- {
60
- echo '<font class="litespeed-warning">' ;
61
- echo '⚠️ ' . __( 'This setting will edit the .htaccess file.', 'litespeed-cache' ) ;
62
- echo ' <a href="https://docs.litespeedtech.com/lscache/lscwp/toolbox/#edit-htaccess-tab" target="_blank" class="litespeed-learn-more">' . __( 'Learn More', 'litespeed-cache' ) . '</a>' ;
63
- echo '</font>' ;
64
  }
65
 
66
  /**
@@ -69,8 +80,7 @@ class Doc
69
  * @since 3.0
70
  * @access public
71
  */
72
- public static function notice_ips()
73
- {
74
  echo '<div class="litespeed-warning">';
75
  echo '⚠️ ' . __( 'For online services to work correctly, you must whitelist all online server IPs.', 'litespeed-cache' ) . '<br/>';
76
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . __( 'Before generating key, please verify all IPs on this list are whitelisted', 'litespeed-cache' ) . ': ';
7
  * @subpackage LiteSpeed/src
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
+ namespace LiteSpeed;
11
 
12
+ defined( 'WPINC' ) || exit;
13
 
14
+ class Doc {
15
+ // protected static $_instance;
 
16
 
17
  /**
18
  * Privacy policy
20
  * @since 2.2.7
21
  * @access public
22
  */
23
+ public static function privacy_policy() {
24
+ return __( 'This site utilizes caching in order to facilitate a faster response time and better user experience. Caching potentially stores a duplicate copy of every web page that is on display on this site. All cache files are temporary, and are never accessed by any third party, except as necessary to obtain technical support from the cache plugin vendor. Cache files expire on a schedule set by the site administrator, but may easily be purged by the admin before their natural expiration, if necessary.', 'litespeed-cache' );
 
25
  }
26
 
27
 
31
  * @since 2.4.2
32
  * @access public
33
  */
34
+ public static function learn_more( $url, $title = false, $self = false, $class = false, $return = false ) {
35
+ if ( ! $class ) {
36
+ $class = 'litespeed-learn-more';
37
+ }
38
+
39
+ if ( ! $title ) {
40
+ $title = __( 'Learn More', 'litespeed-cache' );
41
+ }
42
+
43
+ $self = $self ? '' : "target='_blank'";
44
+
45
+ $txt = " <a href='$url' $self class='$class'>$title</a>";
46
+
47
+ if ( $return ) {
48
+ return $txt;
49
+ }
50
+
51
+ echo $txt;
52
  }
53
 
54
  /**
57
  * @since 3.0
58
  * @access public
59
  */
60
+ public static function one_per_line() {
61
+ echo __( 'One per line.', 'litespeed-cache' );
 
62
  }
63
 
64
  /**
67
  * @since 3.0
68
  * @access public
69
  */
70
+ public static function notice_htaccess() {
71
+ echo '<font class="litespeed-warning">';
72
+ echo '⚠️ ' . __( 'This setting will edit the .htaccess file.', 'litespeed-cache' );
73
+ echo ' <a href="https://docs.litespeedtech.com/lscache/lscwp/toolbox/#edit-htaccess-tab" target="_blank" class="litespeed-learn-more">' . __( 'Learn More', 'litespeed-cache' ) . '</a>';
74
+ echo '</font>';
 
75
  }
76
 
77
  /**
80
  * @since 3.0
81
  * @access public
82
  */
83
+ public static function notice_ips() {
 
84
  echo '<div class="litespeed-warning">';
85
  echo '⚠️ ' . __( 'For online services to work correctly, you must whitelist all online server IPs.', 'litespeed-cache' ) . '<br/>';
86
  echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . __( 'Before generating key, please verify all IPs on this list are whitelisted', 'litespeed-cache' ) . ': ';
src/error.cls.php CHANGED
@@ -11,8 +11,7 @@ namespace LiteSpeed;
11
 
12
  defined( 'WPINC' ) || exit;
13
 
14
- class Error
15
- {
16
  private static $CODE_SET = array(
17
  'HTA_LOGIN_COOKIE_INVALID' => 4300, // .htaccess did not find.
18
  'HTA_DNF' => 4500, // .htaccess did not find.
@@ -27,8 +26,7 @@ class Error
27
  *
28
  * @since 3.0
29
  */
30
- public static function t( $code, $args = null )
31
- {
32
  throw new \Exception( self::msg( $code, $args ) );
33
  }
34
 
@@ -37,18 +35,17 @@ class Error
37
  *
38
  * @since 3.0
39
  */
40
- public static function msg( $code, $args = null )
41
- {
42
  switch ( $code ) {
43
 
44
  case 'disabled_all':
45
  $msg = sprintf( __( 'The setting %s is currently enabled.', 'litespeed-cache' ), '<strong>' . Lang::title( Base::O_DEBUG_DISABLE_ALL ) . '</strong>' ) .
46
- ' ' . sprintf( __( '<a %s>Click here to change</a>.', 'litespeed-cache' ), ' href="' . admin_url('admin.php?page=litespeed-toolbox') . '" ' );
47
  break;
48
 
49
  case 'lack_of_api_key':
50
  $msg = sprintf( __( 'You will need to set %s to use the online services.', 'litespeed-cache' ), '<strong>' . Lang::title( Base::O_API_KEY ) . '</strong>' ) .
51
- ' ' . sprintf( __( '<a %s>Click here to set</a>.', 'litespeed-cache' ), ' href="' . admin_url('admin.php?page=litespeed-general') . '" ' );
52
  break;
53
 
54
  case 'lack_of_quota':
@@ -67,11 +64,11 @@ class Error
67
  $msg = __( 'The image list is empty.', 'litespeed-cache' );
68
  break;
69
 
70
- case 'lack_of_param' :
71
  $msg = __( 'Not enough parameters. Please check if the domain key is set correctly', 'litespeed-cache' );
72
  break;
73
 
74
- case 'unfinished_queue' :
75
  $msg = __( 'There is proceeding queue not pulled yet.', 'litespeed-cache' );
76
  break;
77
 
@@ -79,19 +76,23 @@ class Error
79
  $msg = sprintf( __( 'There is proceeding queue not pulled yet. Queue info: %s.', 'litespeed-cache' ), '<code>' . substr( $code, strlen( 'unfinished_queue ' ) ) . '</code>' );
80
  break;
81
 
82
- case 'err_key' :
 
 
 
 
83
  $msg = __( 'The domain key is not correct. Please try to sync your domain key again.', 'litespeed-cache' );
84
  break;
85
 
86
- case 'err_overdraw' :
87
  $msg = __( 'Credits are not enough to proceed the current request.', 'litespeed-cache' );
88
  break;
89
 
90
- case 'W' :
91
  $msg = __( '%s file not writable.', 'litespeed-cache' );
92
  break;
93
 
94
- case 'HTA_DNF' :
95
  if ( ! is_array( $args ) ) {
96
  $args = array( '<code>' . $args . '</code>' );
97
  }
@@ -99,31 +100,31 @@ class Error
99
  $msg = __( 'Could not find %1$s in %2$s.', 'litespeed-cache' );
100
  break;
101
 
102
- case 'HTA_LOGIN_COOKIE_INVALID' :
103
  $msg = sprintf( __( 'Invalid login cookie. Please check the %s file.', 'litespeed-cache' ), '.htaccess' );
104
  break;
105
 
106
- case 'HTA_BK' :
107
  $msg = sprintf( __( 'Failed to back up %s file, aborted changes.', 'litespeed-cache' ), '.htaccess' );
108
  break;
109
 
110
- case 'HTA_R' :
111
  $msg = sprintf( __( '%s file not readable.', 'litespeed-cache' ), '.htaccess' );
112
  break;
113
 
114
- case 'HTA_W' :
115
  $msg = sprintf( __( '%s file not writable.', 'litespeed-cache' ), '.htaccess' );
116
  break;
117
 
118
- case 'HTA_GET' :
119
  $msg = sprintf( __( 'Failed to get %s file contents.', 'litespeed-cache' ), '.htaccess' );
120
  break;
121
 
122
- case 'failed_tb_creation' :
123
  $msg = __( 'Failed to create table %s! SQL: %s.', 'litespeed-cache' );
124
  break;
125
 
126
- case 'crawler_disabled' :
127
  $msg = __( 'Crawler disabled by the server admin.', 'litespeed-cache' );
128
  break;
129
 
11
 
12
  defined( 'WPINC' ) || exit;
13
 
14
+ class Error {
 
15
  private static $CODE_SET = array(
16
  'HTA_LOGIN_COOKIE_INVALID' => 4300, // .htaccess did not find.
17
  'HTA_DNF' => 4500, // .htaccess did not find.
26
  *
27
  * @since 3.0
28
  */
29
+ public static function t( $code, $args = null ) {
 
30
  throw new \Exception( self::msg( $code, $args ) );
31
  }
32
 
35
  *
36
  * @since 3.0
37
  */
38
+ public static function msg( $code, $args = null ) {
 
39
  switch ( $code ) {
40
 
41
  case 'disabled_all':
42
  $msg = sprintf( __( 'The setting %s is currently enabled.', 'litespeed-cache' ), '<strong>' . Lang::title( Base::O_DEBUG_DISABLE_ALL ) . '</strong>' ) .
43
+ Doc::learn_more( admin_url( 'admin.php?page=litespeed-toolbox' ), __( 'Click here to change.', 'litespeed-cache' ), true, false, true );
44
  break;
45
 
46
  case 'lack_of_api_key':
47
  $msg = sprintf( __( 'You will need to set %s to use the online services.', 'litespeed-cache' ), '<strong>' . Lang::title( Base::O_API_KEY ) . '</strong>' ) .
48
+ Doc::learn_more( admin_url( 'admin.php?page=litespeed-general' ), __( 'Click here to set.', 'litespeed-cache' ), true, false, true );
49
  break;
50
 
51
  case 'lack_of_quota':
64
  $msg = __( 'The image list is empty.', 'litespeed-cache' );
65
  break;
66
 
67
+ case 'lack_of_param':
68
  $msg = __( 'Not enough parameters. Please check if the domain key is set correctly', 'litespeed-cache' );
69
  break;
70
 
71
+ case 'unfinished_queue':
72
  $msg = __( 'There is proceeding queue not pulled yet.', 'litespeed-cache' );
73
  break;
74
 
76
  $msg = sprintf( __( 'There is proceeding queue not pulled yet. Queue info: %s.', 'litespeed-cache' ), '<code>' . substr( $code, strlen( 'unfinished_queue ' ) ) . '</code>' );
77
  break;
78
 
79
+ case 'site_not_registered':
80
+ $msg = __( 'The site is not registered on QUIC.cloud.', 'litespeed-cache' );
81
+ break;
82
+
83
+ case 'err_key':
84
  $msg = __( 'The domain key is not correct. Please try to sync your domain key again.', 'litespeed-cache' );
85
  break;
86
 
87
+ case 'err_overdraw':
88
  $msg = __( 'Credits are not enough to proceed the current request.', 'litespeed-cache' );
89
  break;
90
 
91
+ case 'W':
92
  $msg = __( '%s file not writable.', 'litespeed-cache' );
93
  break;
94
 
95
+ case 'HTA_DNF':
96
  if ( ! is_array( $args ) ) {
97
  $args = array( '<code>' . $args . '</code>' );
98
  }
100
  $msg = __( 'Could not find %1$s in %2$s.', 'litespeed-cache' );
101
  break;
102
 
103
+ case 'HTA_LOGIN_COOKIE_INVALID':
104
  $msg = sprintf( __( 'Invalid login cookie. Please check the %s file.', 'litespeed-cache' ), '.htaccess' );
105
  break;
106
 
107
+ case 'HTA_BK':
108
  $msg = sprintf( __( 'Failed to back up %s file, aborted changes.', 'litespeed-cache' ), '.htaccess' );
109
  break;
110
 
111
+ case 'HTA_R':
112
  $msg = sprintf( __( '%s file not readable.', 'litespeed-cache' ), '.htaccess' );
113
  break;
114
 
115
+ case 'HTA_W':
116
  $msg = sprintf( __( '%s file not writable.', 'litespeed-cache' ), '.htaccess' );
117
  break;
118
 
119
+ case 'HTA_GET':
120
  $msg = sprintf( __( 'Failed to get %s file contents.', 'litespeed-cache' ), '.htaccess' );
121
  break;
122
 
123
+ case 'failed_tb_creation':
124
  $msg = __( 'Failed to create table %s! SQL: %s.', 'litespeed-cache' );
125
  break;
126
 
127
+ case 'crawler_disabled':
128
  $msg = __( 'Crawler disabled by the server admin.', 'litespeed-cache' );
129
  break;
130
 
src/file.cls.php CHANGED
@@ -5,19 +5,32 @@
5
  *
6
  * @since 1.1.0
7
  */
8
- namespace LiteSpeed ;
9
 
10
- defined( 'WPINC' ) || exit ;
11
 
12
- class File
13
- {
14
- const MARKER = 'LiteSpeed Operator' ;
15
 
16
- function __construct()
17
- {
18
  // nothing to do here
19
  }
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * Delete folder
23
  *
@@ -25,24 +38,23 @@ class File
25
  */
26
  public static function rrmdir( $dir ) {
27
 
28
- $files = array_diff( scandir( $dir ), array( '.', '..' ) ) ;
29
 
30
  foreach ( $files as $file ) {
31
- is_dir( "$dir/$file" ) ? self::rrmdir( "$dir/$file" ) : unlink( "$dir/$file" ) ;
32
  }
33
 
34
- return rmdir( $dir ) ;
35
  }
36
 
37
- public static function count_lines($filename)
38
- {
39
  if ( ! file_exists($filename) ) {
40
- return 0 ;
41
  }
42
 
43
- $file = new \SplFileObject($filename) ;
44
- $file->seek(PHP_INT_MAX) ;
45
- return $file->key() + 1 ;
46
  }
47
 
48
  /**
@@ -53,46 +65,45 @@ class File
53
  * @param int $start_line
54
  * @param int $lines
55
  */
56
- public static function read($filename, $start_line = null, $lines = null)
57
- {
58
  if ( ! file_exists($filename) ) {
59
- return '' ;
60
  }
61
 
62
  if ( ! is_readable($filename) ) {
63
- return false ;
64
  }
65
 
66
  if ( $start_line !== null ) {
67
- $res = array() ;
68
- $file = new \SplFileObject($filename) ;
69
- $file->seek($start_line) ;
70
 
71
  if ( $lines === null) {
72
  while ( ! $file->eof() ) {
73
- $res[] = rtrim($file->current(), "\n") ;
74
- $file->next() ;
75
  }
76
  }
77
  else{
78
- for ( $i=0 ; $i < $lines ; $i++ ) {
79
  if ( $file->eof() ) {
80
- break ;
81
  }
82
- $res[] = rtrim($file->current(), "\n") ;
83
- $file->next() ;
84
  }
85
  }
86
 
87
- unset($file) ;
88
- return $res ;
89
  }
90
 
91
- $content = file_get_contents( $filename ) ;
92
 
93
- $content = self::remove_zero_space( $content ) ;
94
 
95
- return $content ;
96
  }
97
 
98
  /**
@@ -105,9 +116,8 @@ class File
105
  * @param boolean $mkdir
106
  * @param boolean $silence Used to avoid WP's functions are used
107
  */
108
- public static function append( $filename, $data, $mkdir = false, $silence = true )
109
- {
110
- return self::save( $filename, $data, $mkdir, true, $silence ) ;
111
  }
112
 
113
  /**
@@ -120,54 +130,53 @@ class File
120
  * @param boolean $append If the content needs to be appended
121
  * @param boolean $silence Used to avoid WP's functions are used
122
  */
123
- public static function save( $filename, $data, $mkdir = false, $append = false, $silence = true )
124
- {
125
- $error = false ;
126
- $folder = dirname( $filename ) ;
127
 
128
  // mkdir if folder does not exist
129
  if ( ! file_exists( $folder ) ) {
130
  if ( ! $mkdir ) {
131
- return $silence ? false : sprintf( __( 'Folder does not exist: %s', 'litespeed-cache' ), $folder ) ;
132
  }
133
 
134
- set_error_handler( 'litespeed_exception_handler' ) ;
135
 
136
  try {
137
- mkdir( $folder, 0755, true ) ;
138
  }
139
  catch ( \ErrorException $ex ) {
140
- return $silence ? false : sprintf( __( 'Can not create folder: %1$s. Error: %2$s', 'litespeed-cache' ), $folder, $ex->getMessage() ) ;
141
  }
142
 
143
- restore_error_handler() ;
144
  }
145
 
146
  if ( ! file_exists( $filename ) ) {
147
  if ( ! is_writable( $folder ) ) {
148
- return $silence ? false : sprintf( __( 'Folder is not writable: %s.', 'litespeed-cache' ), $folder ) ;
149
  }
150
- set_error_handler( 'litespeed_exception_handler' ) ;
151
  try {
152
- touch( $filename ) ;
153
  }
154
  catch ( \ErrorException $ex ){
155
- return $silence ? false : sprintf( __( 'File %s is not writable.', 'litespeed-cache' ), $filename ) ;
156
  }
157
- restore_error_handler() ;
158
  }
159
  elseif ( ! is_writeable( $filename ) ) {
160
- return $silence ? false : sprintf( __( 'File %s is not writable.', 'litespeed-cache' ), $filename ) ;
161
  }
162
 
163
- $data = self::remove_zero_space( $data ) ;
164
 
165
- $ret = file_put_contents( $filename, $data, $append ? FILE_APPEND : LOCK_EX ) ;
166
  if ( $ret === false ) {
167
- return $silence ? false : sprintf( __( 'Failed to write to %s.', 'litespeed-cache' ), $filename ) ;
168
  }
169
 
170
- return true ;
171
  }
172
 
173
  /**
@@ -176,23 +185,22 @@ class File
176
  * @since 2.1.2
177
  * @since 2.9 changed to public
178
  */
179
- public static function remove_zero_space( $content )
180
- {
181
  if ( is_array( $content ) ) {
182
- $content = array_map( __CLASS__ . '::remove_zero_space', $content ) ;
183
- return $content ;
184
  }
185
 
186
  // Remove UTF-8 BOM if present
187
  if ( substr( $content, 0, 3 ) === "\xEF\xBB\xBF" ) {
188
- $content = substr( $content, 3 ) ;
189
  }
190
 
191
- $content = str_replace( "\xe2\x80\x8b", '', $content ) ;
192
- $content = str_replace( "\xe2\x80\x8c", '', $content ) ;
193
- $content = str_replace( "\xe2\x80\x8d", '', $content ) ;
194
 
195
- return $content ;
196
  }
197
 
198
  /**
@@ -208,17 +216,16 @@ class File
208
  * @param bool $prepend Prepend insertion if not exist.
209
  * @return bool True on write success, false on failure.
210
  */
211
- public static function insert_with_markers($filename, $insertion = false, $marker = false, $prepend = false)
212
- {
213
  if ( !$marker ) {
214
- $marker = self::MARKER ;
215
  }
216
 
217
  if ( !$insertion ) {
218
- $insertion = array() ;
219
  }
220
 
221
- return self::_insert_with_markers($filename, $marker, $insertion, $prepend) ;//todo: capture exceptions
222
  }
223
 
224
  /**
@@ -228,20 +235,19 @@ class File
228
  * @param string $marker
229
  * @return string The block data
230
  */
231
- public static function wrap_marker_data($insertion, $marker = false)
232
- {
233
  if ( ! $marker ) {
234
- $marker = self::MARKER ;
235
  }
236
- $start_marker = "# BEGIN {$marker}" ;
237
- $end_marker = "# END {$marker}" ;
238
 
239
  $new_data = implode( "\n", array_merge(
240
  array( $start_marker ),
241
  $insertion,
242
  array( $end_marker )
243
- ) ) ;
244
- return $new_data ;
245
  }
246
 
247
  /**
@@ -251,26 +257,25 @@ class File
251
  * @param string $marker
252
  * @return string The current block data
253
  */
254
- public static function touch_marker_data($filename, $marker = false)
255
- {
256
  if( ! $marker ) {
257
- $marker = self::MARKER ;
258
  }
259
 
260
- $result = self::_extract_from_markers($filename, $marker) ;
261
 
262
  if( ! $result ) {
263
- return false ;
264
  }
265
 
266
- $start_marker = "# BEGIN {$marker}" ;
267
- $end_marker = "# END {$marker}" ;
268
  $new_data = implode( "\n", array_merge(
269
  array( $start_marker ),
270
  $result,
271
  array( $end_marker )
272
- ) ) ;
273
- return $new_data ;
274
  }
275
 
276
  /**
@@ -280,12 +285,11 @@ class File
280
  * @param string $marker
281
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
282
  */
283
- public static function extract_from_markers($filename, $marker = false)
284
- {
285
  if( ! $marker ) {
286
- $marker = self::MARKER ;
287
  }
288
- return self::_extract_from_markers($filename, $marker) ;
289
  }
290
 
291
  /**
@@ -295,30 +299,29 @@ class File
295
  * @param string $marker
296
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
297
  */
298
- private static function _extract_from_markers( $filename, $marker )
299
- {
300
- $result = array() ;
301
 
302
  if (!file_exists($filename) ) {
303
- return $result ;
304
  }
305
 
306
  if ( $markerdata = explode( "\n", implode( '', file($filename) ) ) ) {
307
- $state = false ;
308
  foreach ( $markerdata as $markerline ) {
309
  if ( strpos($markerline, '# END ' . $marker) !== false ) {
310
- $state = false ;
311
  }
312
  if ( $state ) {
313
- $result[] = $markerline ;
314
  }
315
  if (strpos($markerline, '# BEGIN ' . $marker) !== false) {
316
- $state = true ;
317
  }
318
  }
319
  }
320
 
321
- return array_map('trim', $result) ;
322
  }
323
 
324
  /**
@@ -332,75 +335,74 @@ class File
332
  * @since 3.0 Throw errors if failed
333
  * @access private
334
  */
335
- private static function _insert_with_markers( $filename, $marker, $insertion, $prepend = false)
336
- {
337
  if ( ! file_exists( $filename ) ) {
338
  if ( ! is_writable( dirname( $filename ) ) ) {
339
- Error::t( 'W', dirname( $filename ) ) ;
340
  }
341
 
342
- set_error_handler("litespeed_exception_handler") ;
343
  try {
344
- touch( $filename ) ;
345
  } catch ( \ErrorException $ex ) {
346
- Error::t( 'W', $filename ) ;
347
  }
348
- restore_error_handler() ;
349
  }
350
  elseif ( ! is_writeable( $filename ) ) {
351
- Error::t( 'W', $filename ) ;
352
  }
353
 
354
  if ( ! is_array( $insertion ) ) {
355
- $insertion = explode( "\n", $insertion ) ;
356
  }
357
 
358
- $start_marker = "# BEGIN {$marker}" ;
359
- $end_marker = "# END {$marker}" ;
360
 
361
- $fp = fopen( $filename, 'r+' ) ;
362
  if ( ! $fp ) {
363
- Error::t( 'W', $filename ) ;
364
  }
365
 
366
  // Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
367
- flock( $fp, LOCK_EX ) ;
368
 
369
- $lines = array() ;
370
  while ( ! feof($fp) ) {
371
- $lines[] = rtrim(fgets($fp), "\r\n" ) ;
372
  }
373
 
374
  // Split out the existing file into the preceding lines, and those that appear after the marker
375
- $pre_lines = $post_lines = $existing_lines = array() ;
376
- $found_marker = $found_end_marker = false ;
377
  foreach ( $lines as $line ) {
378
  if ( ! $found_marker && false !== strpos($line, $start_marker) ) {
379
- $found_marker = true ;
380
- continue ;
381
  }
382
  elseif ( ! $found_end_marker && false !== strpos($line, $end_marker) ) {
383
- $found_end_marker = true ;
384
- continue ;
385
  }
386
 
387
  if ( ! $found_marker ) {
388
- $pre_lines[] = $line ;
389
  }
390
  elseif ( $found_marker && $found_end_marker ) {
391
- $post_lines[] = $line ;
392
  }
393
  else {
394
- $existing_lines[] = $line ;
395
  }
396
  }
397
 
398
  // Check to see if there was a change
399
  if ( $existing_lines === $insertion ) {
400
- flock($fp, LOCK_UN) ;
401
- fclose($fp) ;
402
 
403
- return true ;
404
  }
405
 
406
  // Check if need to prepend data if not exist
@@ -411,7 +413,7 @@ class File
411
  $insertion,
412
  array( $end_marker ),
413
  $pre_lines
414
- ) ) ;
415
 
416
  }
417
  else {
@@ -422,21 +424,21 @@ class File
422
  $insertion,
423
  array( $end_marker ),
424
  $post_lines
425
- ) ) ;
426
  }
427
 
428
 
429
  // Write to the start of the file, and truncate it to that length
430
- fseek($fp, 0) ;
431
- $bytes = fwrite($fp, $new_file_data) ;
432
  if ( $bytes ) {
433
- ftruncate($fp, ftell($fp)) ;
434
  }
435
- fflush($fp) ;
436
- flock($fp, LOCK_UN) ;
437
- fclose($fp) ;
438
 
439
- return (bool) $bytes ;
440
  }
441
  }
442
 
5
  *
6
  * @since 1.1.0
7
  */
8
+ namespace LiteSpeed;
9
 
10
+ defined( 'WPINC' ) || exit;
11
 
12
+ class File {
13
+ const MARKER = 'LiteSpeed Operator';
 
14
 
15
+ function __construct() {
 
16
  // nothing to do here
17
  }
18
 
19
+ /**
20
+ * Detect if an URL is 404
21
+ *
22
+ * @since 3.3
23
+ */
24
+ public static function is_404( $url ) {
25
+ $response = wp_remote_get( $url );
26
+ $code = wp_remote_retrieve_response_code( $response );
27
+ if ( $code == 404 ) {
28
+ return false;
29
+ }
30
+
31
+ return true;
32
+ }
33
+
34
  /**
35
  * Delete folder
36
  *
38
  */
39
  public static function rrmdir( $dir ) {
40
 
41
+ $files = array_diff( scandir( $dir ), array( '.', '..' ) );
42
 
43
  foreach ( $files as $file ) {
44
+ is_dir( "$dir/$file" ) ? self::rrmdir( "$dir/$file" ) : unlink( "$dir/$file" );
45
  }
46
 
47
+ return rmdir( $dir );
48
  }
49
 
50
+ public static function count_lines($filename) {
 
51
  if ( ! file_exists($filename) ) {
52
+ return 0;
53
  }
54
 
55
+ $file = new \SplFileObject($filename);
56
+ $file->seek(PHP_INT_MAX);
57
+ return $file->key() + 1;
58
  }
59
 
60
  /**
65
  * @param int $start_line
66
  * @param int $lines
67
  */
68
+ public static function read($filename, $start_line = null, $lines = null) {
 
69
  if ( ! file_exists($filename) ) {
70
+ return '';
71
  }
72
 
73
  if ( ! is_readable($filename) ) {
74
+ return false;
75
  }
76
 
77
  if ( $start_line !== null ) {
78
+ $res = array();
79
+ $file = new \SplFileObject($filename);
80
+ $file->seek($start_line);
81
 
82
  if ( $lines === null) {
83
  while ( ! $file->eof() ) {
84
+ $res[] = rtrim($file->current(), "\n");
85
+ $file->next();
86
  }
87
  }
88
  else{
89
+ for ( $i=0; $i < $lines; $i++ ) {
90
  if ( $file->eof() ) {
91
+ break;
92
  }
93
+ $res[] = rtrim($file->current(), "\n");
94
+ $file->next();
95
  }
96
  }
97
 
98
+ unset($file);
99
+ return $res;
100
  }
101
 
102
+ $content = file_get_contents( $filename );
103
 
104
+ $content = self::remove_zero_space( $content );
105
 
106
+ return $content;
107
  }
108
 
109
  /**
116
  * @param boolean $mkdir
117
  * @param boolean $silence Used to avoid WP's functions are used
118
  */
119
+ public static function append( $filename, $data, $mkdir = false, $silence = true ) {
120
+ return self::save( $filename, $data, $mkdir, true, $silence );
 
121
  }
122
 
123
  /**
130
  * @param boolean $append If the content needs to be appended
131
  * @param boolean $silence Used to avoid WP's functions are used
132
  */
133
+ public static function save( $filename, $data, $mkdir = false, $append = false, $silence = true ) {
134
+ $error = false;
135
+ $folder = dirname( $filename );
 
136
 
137
  // mkdir if folder does not exist
138
  if ( ! file_exists( $folder ) ) {
139
  if ( ! $mkdir ) {
140
+ return $silence ? false : sprintf( __( 'Folder does not exist: %s', 'litespeed-cache' ), $folder );
141
  }
142
 
143
+ set_error_handler( 'litespeed_exception_handler' );
144
 
145
  try {
146
+ mkdir( $folder, 0755, true );
147
  }
148
  catch ( \ErrorException $ex ) {
149
+ return $silence ? false : sprintf( __( 'Can not create folder: %1$s. Error: %2$s', 'litespeed-cache' ), $folder, $ex->getMessage() );
150
  }
151
 
152
+ restore_error_handler();
153
  }
154
 
155
  if ( ! file_exists( $filename ) ) {
156
  if ( ! is_writable( $folder ) ) {
157
+ return $silence ? false : sprintf( __( 'Folder is not writable: %s.', 'litespeed-cache' ), $folder );
158
  }
159
+ set_error_handler( 'litespeed_exception_handler' );
160
  try {
161
+ touch( $filename );
162
  }
163
  catch ( \ErrorException $ex ){
164
+ return $silence ? false : sprintf( __( 'File %s is not writable.', 'litespeed-cache' ), $filename );
165
  }
166
+ restore_error_handler();
167
  }
168
  elseif ( ! is_writeable( $filename ) ) {
169
+ return $silence ? false : sprintf( __( 'File %s is not writable.', 'litespeed-cache' ), $filename );
170
  }
171
 
172
+ $data = self::remove_zero_space( $data );
173
 
174
+ $ret = file_put_contents( $filename, $data, $append ? FILE_APPEND : LOCK_EX );
175
  if ( $ret === false ) {
176
+ return $silence ? false : sprintf( __( 'Failed to write to %s.', 'litespeed-cache' ), $filename );
177
  }
178
 
179
+ return true;
180
  }
181
 
182
  /**
185
  * @since 2.1.2
186
  * @since 2.9 changed to public
187
  */
188
+ public static function remove_zero_space( $content ) {
 
189
  if ( is_array( $content ) ) {
190
+ $content = array_map( __CLASS__ . '::remove_zero_space', $content );
191
+ return $content;
192
  }
193
 
194
  // Remove UTF-8 BOM if present
195
  if ( substr( $content, 0, 3 ) === "\xEF\xBB\xBF" ) {
196
+ $content = substr( $content, 3 );
197
  }
198
 
199
+ $content = str_replace( "\xe2\x80\x8b", '', $content );
200
+ $content = str_replace( "\xe2\x80\x8c", '', $content );
201
+ $content = str_replace( "\xe2\x80\x8d", '', $content );
202
 
203
+ return $content;
204
  }
205
 
206
  /**
216
  * @param bool $prepend Prepend insertion if not exist.
217
  * @return bool True on write success, false on failure.
218
  */
219
+ public static function insert_with_markers($filename, $insertion = false, $marker = false, $prepend = false) {
 
220
  if ( !$marker ) {
221
+ $marker = self::MARKER;
222
  }
223
 
224
  if ( !$insertion ) {
225
+ $insertion = array();
226
  }
227
 
228
+ return self::_insert_with_markers($filename, $marker, $insertion, $prepend);//todo: capture exceptions
229
  }
230
 
231
  /**
235
  * @param string $marker
236
  * @return string The block data
237
  */
238
+ public static function wrap_marker_data($insertion, $marker = false) {
 
239
  if ( ! $marker ) {
240
+ $marker = self::MARKER;
241
  }
242
+ $start_marker = "# BEGIN {$marker}";
243
+ $end_marker = "# END {$marker}";
244
 
245
  $new_data = implode( "\n", array_merge(
246
  array( $start_marker ),
247
  $insertion,
248
  array( $end_marker )
249
+ ) );
250
+ return $new_data;
251
  }
252
 
253
  /**
257
  * @param string $marker
258
  * @return string The current block data
259
  */
260
+ public static function touch_marker_data($filename, $marker = false) {
 
261
  if( ! $marker ) {
262
+ $marker = self::MARKER;
263
  }
264
 
265
+ $result = self::_extract_from_markers($filename, $marker);
266
 
267
  if( ! $result ) {
268
+ return false;
269
  }
270
 
271
+ $start_marker = "# BEGIN {$marker}";
272
+ $end_marker = "# END {$marker}";
273
  $new_data = implode( "\n", array_merge(
274
  array( $start_marker ),
275
  $result,
276
  array( $end_marker )
277
+ ) );
278
+ return $new_data;
279
  }
280
 
281
  /**
285
  * @param string $marker
286
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
287
  */
288
+ public static function extract_from_markers($filename, $marker = false) {
 
289
  if( ! $marker ) {
290
+ $marker = self::MARKER;
291
  }
292
+ return self::_extract_from_markers($filename, $marker);
293
  }
294
 
295
  /**
299
  * @param string $marker
300
  * @return array An array of strings from a file (.htaccess ) from between BEGIN and END markers.
301
  */
302
+ private static function _extract_from_markers( $filename, $marker ) {
303
+ $result = array();
 
304
 
305
  if (!file_exists($filename) ) {
306
+ return $result;
307
  }
308
 
309
  if ( $markerdata = explode( "\n", implode( '', file($filename) ) ) ) {
310
+ $state = false;
311
  foreach ( $markerdata as $markerline ) {
312
  if ( strpos($markerline, '# END ' . $marker) !== false ) {
313
+ $state = false;
314
  }
315
  if ( $state ) {
316
+ $result[] = $markerline;
317
  }
318
  if (strpos($markerline, '# BEGIN ' . $marker) !== false) {
319
+ $state = true;
320
  }
321
  }
322
  }
323
 
324
+ return array_map('trim', $result);
325
  }
326
 
327
  /**
335
  * @since 3.0 Throw errors if failed
336
  * @access private
337
  */
338
+ private static function _insert_with_markers( $filename, $marker, $insertion, $prepend = false) {
 
339
  if ( ! file_exists( $filename ) ) {
340
  if ( ! is_writable( dirname( $filename ) ) ) {
341
+ Error::t( 'W', dirname( $filename ) );
342
  }
343
 
344
+ set_error_handler("litespeed_exception_handler");
345
  try {
346
+ touch( $filename );
347
  } catch ( \ErrorException $ex ) {
348
+ Error::t( 'W', $filename );
349
  }
350
+ restore_error_handler();
351
  }
352
  elseif ( ! is_writeable( $filename ) ) {
353
+ Error::t( 'W', $filename );
354
  }
355
 
356
  if ( ! is_array( $insertion ) ) {
357
+ $insertion = explode( "\n", $insertion );
358
  }
359
 
360
+ $start_marker = "# BEGIN {$marker}";
361
+ $end_marker = "# END {$marker}";
362
 
363
+ $fp = fopen( $filename, 'r+' );
364
  if ( ! $fp ) {
365
+ Error::t( 'W', $filename );
366
  }
367
 
368
  // Attempt to get a lock. If the filesystem supports locking, this will block until the lock is acquired.
369
+ flock( $fp, LOCK_EX );
370
 
371
+ $lines = array();
372
  while ( ! feof($fp) ) {
373
+ $lines[] = rtrim(fgets($fp), "\r\n" );
374
  }
375
 
376
  // Split out the existing file into the preceding lines, and those that appear after the marker
377
+ $pre_lines = $post_lines = $existing_lines = array();
378
+ $found_marker = $found_end_marker = false;
379
  foreach ( $lines as $line ) {
380
  if ( ! $found_marker && false !== strpos($line, $start_marker) ) {
381
+ $found_marker = true;
382
+ continue;
383
  }
384
  elseif ( ! $found_end_marker && false !== strpos($line, $end_marker) ) {
385
+ $found_end_marker = true;
386
+ continue;
387
  }
388
 
389
  if ( ! $found_marker ) {
390
+ $pre_lines[] = $line;
391
  }
392
  elseif ( $found_marker && $found_end_marker ) {
393
+ $post_lines[] = $line;
394
  }
395
  else {
396
+ $existing_lines[] = $line;
397
  }
398
  }
399
 
400
  // Check to see if there was a change
401
  if ( $existing_lines === $insertion ) {
402
+ flock($fp, LOCK_UN);
403
+ fclose($fp);
404
 
405
+ return true;
406
  }
407
 
408
  // Check if need to prepend data if not exist
413
  $insertion,
414
  array( $end_marker ),
415
  $pre_lines
416
+ ) );
417
 
418
  }
419
  else {
424
  $insertion,
425
  array( $end_marker ),
426
  $post_lines
427
+ ) );
428
  }
429
 
430
 
431
  // Write to the start of the file, and truncate it to that length
432
+ fseek($fp, 0);
433
+ $bytes = fwrite($fp, $new_file_data);
434
  if ( $bytes ) {
435
+ ftruncate($fp, ftell($fp));
436
  }
437
+ fflush($fp);
438
+ flock($fp, LOCK_UN);
439
+ fclose($fp);
440
 
441
+ return (bool) $bytes;
442
  }
443
  }
444
 
src/gui.cls.php CHANGED
@@ -388,8 +388,7 @@ class GUI extends Base
388
  * @since 1.3
389
  * @access public
390
  */
391
- public function frontend_shortcut()
392
- {
393
  global $wp_admin_bar ;
394
 
395
  $wp_admin_bar->add_menu( array(
@@ -511,7 +510,7 @@ class GUI extends Base
511
  ) );
512
  }
513
 
514
- if ( CSS::has_ccss_cache() ) {
515
  $wp_admin_bar->add_menu( array(
516
  'parent' => 'litespeed-menu',
517
  'id' => 'litespeed-purge-ccss',
@@ -521,6 +520,16 @@ class GUI extends Base
521
  ) );
522
  }
523
 
 
 
 
 
 
 
 
 
 
 
524
  if ( Placeholder::has_lqip_cache() ) {
525
  $wp_admin_bar->add_menu( array(
526
  'parent' => 'litespeed-menu',
@@ -553,8 +562,7 @@ class GUI extends Base
553
  * @global WP_Admin_Bar $wp_admin_bar
554
  * @since 1.7.2 Moved from admin_display.cls to gui.cls; Renamed from `add_quick_purge` to `backend_shortcut`
555
  */
556
- public function backend_shortcut()
557
- {
558
  global $wp_admin_bar ;
559
 
560
  // if ( defined( 'LITESPEED_ON' ) ) {
@@ -653,7 +661,7 @@ class GUI extends Base
653
  ) );
654
  }
655
 
656
- if ( CSS::has_ccss_cache() ) {
657
  $wp_admin_bar->add_menu( array(
658
  'parent' => 'litespeed-menu',
659
  'id' => 'litespeed-purge-ccss',
@@ -663,6 +671,16 @@ class GUI extends Base
663
  ) );
664
  }
665
 
 
 
 
 
 
 
 
 
 
 
666
  if ( Placeholder::has_lqip_cache() ) {
667
  $wp_admin_bar->add_menu( array(
668
  'parent' => 'litespeed-menu',
388
  * @since 1.3
389
  * @access public
390
  */
391
+ public function frontend_shortcut() {
 
392
  global $wp_admin_bar ;
393
 
394
  $wp_admin_bar->add_menu( array(
510
  ) );
511
  }
512
 
513
+ if ( Conf::val( Base::O_OPTM_CCSS_GEN ) ) {
514
  $wp_admin_bar->add_menu( array(
515
  'parent' => 'litespeed-menu',
516
  'id' => 'litespeed-purge-ccss',
520
  ) );
521
  }
522
 
523
+ if ( Conf::val( Base::O_OPTM_LOCALIZE ) ) {
524
+ $wp_admin_bar->add_menu( array(
525
+ 'parent' => 'litespeed-menu',
526
+ 'id' => 'litespeed-purge-localres',
527
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Localized Resources', 'litespeed-cache' ),
528
+ 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES, false, '_ori' ),
529
+ 'meta' => array( 'tabindex' => '0' ),
530
+ ) );
531
+ }
532
+
533
  if ( Placeholder::has_lqip_cache() ) {
534
  $wp_admin_bar->add_menu( array(
535
  'parent' => 'litespeed-menu',
562
  * @global WP_Admin_Bar $wp_admin_bar
563
  * @since 1.7.2 Moved from admin_display.cls to gui.cls; Renamed from `add_quick_purge` to `backend_shortcut`
564
  */
565
+ public function backend_shortcut() {
 
566
  global $wp_admin_bar ;
567
 
568
  // if ( defined( 'LITESPEED_ON' ) ) {
661
  ) );
662
  }
663
 
664
+ if ( Conf::val( Base::O_OPTM_CCSS_GEN ) ) {
665
  $wp_admin_bar->add_menu( array(
666
  'parent' => 'litespeed-menu',
667
  'id' => 'litespeed-purge-ccss',
671
  ) );
672
  }
673
 
674
+ if ( Conf::val( Base::O_OPTM_LOCALIZE ) ) {
675
+ $wp_admin_bar->add_menu( array(
676
+ 'parent' => 'litespeed-menu',
677
+ 'id' => 'litespeed-purge-localres',
678
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Localized Resources', 'litespeed-cache' ),
679
+ 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES ),
680
+ 'meta' => array( 'tabindex' => '0' ),
681
+ ) );
682
+ }
683
+
684
  if ( Placeholder::has_lqip_cache() ) {
685
  $wp_admin_bar->add_menu( array(
686
  'parent' => 'litespeed-menu',
src/lang.cls.php CHANGED
@@ -124,6 +124,8 @@ class Lang extends Base
124
  self::O_OPTM_CSS_FONT_DISPLAY => __( 'Font Display Optimization', 'litespeed-cache' ),
125
  self::O_OPTM_JS_DEFER => __( 'Load JS Deferred', 'litespeed-cache' ),
126
  self::O_OPTM_JS_INLINE_DEFER => __( 'Load Inline JS', 'litespeed-cache' ),
 
 
127
  self::O_OPTM_EXC_JQ => __( 'Exclude JQuery', 'litespeed-cache' ),
128
  self::O_OPTM_DNS_PREFETCH => __( 'DNS Prefetch', 'litespeed-cache' ),
129
  self::O_OPTM_DNS_PREFETCH_CTRL => __( 'DNS Prefetch Control', 'litespeed-cache' ),
@@ -138,6 +140,7 @@ class Lang extends Base
138
  self::O_OPTM_GGFONTS_RM => __( 'Remove Google Fonts', 'litespeed-cache' ),
139
  self::O_OPTM_CCSS_CON => __( 'Critical CSS Rules', 'litespeed-cache' ),
140
  self::O_OPTM_JS_DEFER_EXC => __( 'JS Deferred Excludes', 'litespeed-cache' ),
 
141
  self::O_OPTM_EMOJI_RM => __( 'Remove WordPress Emoji', 'litespeed-cache' ),
142
  self::O_OPTM_EXC => __( 'URI Excludes', 'litespeed-cache' ),
143
  self::O_OPTM_EXC_ROLES => __( 'Role Excludes', 'litespeed-cache' ),
124
  self::O_OPTM_CSS_FONT_DISPLAY => __( 'Font Display Optimization', 'litespeed-cache' ),
125
  self::O_OPTM_JS_DEFER => __( 'Load JS Deferred', 'litespeed-cache' ),
126
  self::O_OPTM_JS_INLINE_DEFER => __( 'Load Inline JS', 'litespeed-cache' ),
127
+ self::O_OPTM_LOCALIZE => __( 'Localize Resources', 'litespeed-cache' ),
128
+ self::O_OPTM_LOCALIZE_DOMAINS => __( 'Localization Domains', 'litespeed-cache' ),
129
  self::O_OPTM_EXC_JQ => __( 'Exclude JQuery', 'litespeed-cache' ),
130
  self::O_OPTM_DNS_PREFETCH => __( 'DNS Prefetch', 'litespeed-cache' ),
131
  self::O_OPTM_DNS_PREFETCH_CTRL => __( 'DNS Prefetch Control', 'litespeed-cache' ),
140
  self::O_OPTM_GGFONTS_RM => __( 'Remove Google Fonts', 'litespeed-cache' ),
141
  self::O_OPTM_CCSS_CON => __( 'Critical CSS Rules', 'litespeed-cache' ),
142
  self::O_OPTM_JS_DEFER_EXC => __( 'JS Deferred Excludes', 'litespeed-cache' ),
143
+ self::O_OPTM_JS_INLINE_DEFER_EXC => __( 'Inline JS Deferred Excludes', 'litespeed-cache' ),
144
  self::O_OPTM_EMOJI_RM => __( 'Remove WordPress Emoji', 'litespeed-cache' ),
145
  self::O_OPTM_EXC => __( 'URI Excludes', 'litespeed-cache' ),
146
  self::O_OPTM_EXC_ROLES => __( 'Role Excludes', 'litespeed-cache' ),
src/localization.cls.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The localization class.
4
+ *
5
+ * @since 3.3
6
+ */
7
+ namespace LiteSpeed;
8
+
9
+ defined( 'WPINC' ) || exit;
10
+
11
+ class Localization extends Base {
12
+ protected static $_instance;
13
+
14
+
15
+ /**
16
+ * Localize Resources
17
+ *
18
+ * @since 3.3
19
+ */
20
+ public function serve_static( $uri ) {
21
+ $url = 'https://' . $uri;
22
+
23
+ Control::set_no_vary();
24
+ Control::set_public_forced( 'Localized Resources' );
25
+ Tag::add( Tag::TYPE_LOCALRES );
26
+
27
+ header( 'Content-Type: application/javascript' );
28
+
29
+ $res = wp_remote_get( $url );
30
+ $content = wp_remote_retrieve_body( $res );
31
+
32
+ if ( ! $content ) {
33
+ $content = '/* Failed to load ' . $url . ' */';
34
+ }
35
+
36
+ echo $content;
37
+
38
+ exit;
39
+ }
40
+
41
+
42
+
43
+ /**
44
+ * Localize JS/Fonts
45
+ *
46
+ * @since 3.3
47
+ * @access public
48
+ */
49
+ public function finalize( $content ) {
50
+ if ( ! Conf::val( Base::O_OPTM_LOCALIZE ) ) {
51
+ return $content;
52
+ }
53
+
54
+ $domains = Conf::val( Base::O_OPTM_LOCALIZE_DOMAINS );
55
+ if ( ! $domains ) {
56
+ return $content;
57
+ }
58
+
59
+ foreach ( $domains as $v ) {
60
+ if ( ! $v || strpos( $v, '#' ) === 0 ) {
61
+ continue;
62
+ }
63
+
64
+ $type = 'js';
65
+ $domain = $v;
66
+ // Try to parse space splitted value
67
+ if ( strpos( $v, ' ' ) ) {
68
+ $v = explode( ' ', $v );
69
+ if ( ! empty( $v[ 1 ] ) ) {
70
+ $type = strtolower( $v[ 0 ] );
71
+ $domain = $v[ 1 ];
72
+ }
73
+ }
74
+
75
+ if ( strpos( $domain, 'https://' ) !== 0 ) {
76
+ continue;
77
+ }
78
+
79
+ if ( $type != 'js' ) {
80
+ continue;
81
+ }
82
+
83
+ $content = str_replace( $domain, LITESPEED_STATIC_URL . '/localres/' . substr( $domain, 8 ), $content );
84
+ }
85
+
86
+ return $content;
87
+ }
88
+
89
+ }
src/optimize.cls.php CHANGED
@@ -8,44 +8,43 @@
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
- namespace LiteSpeed ;
12
 
13
- defined( 'WPINC' ) || exit ;
14
 
15
- class Optimize extends Base
16
- {
17
- protected static $_instance ;
18
 
19
- const LIB_FILE_CSS_ASYNC = 'assets/js/css_async.min.js' ;
20
- const LIB_FILE_WEBFONTLOADER = 'assets/js/webfontloader.min.js' ;
21
 
22
- const ITEM_TIMESTAMP_PURGE_CSS = 'timestamp_purge_css' ;
23
 
24
- private $content ;
25
- private $http2_headers = array() ;
 
26
 
27
- private $cfg_http2_css ;
28
- private $cfg_http2_js ;
29
- private $cfg_css_min ;
30
- private $cfg_css_comb ;
31
- private $cfg_js_min ;
32
- private $cfg_js_comb ;
33
- private $cfg_css_async ;
34
- private $cfg_js_defer ;
35
- private $cfg_js_defer_exc = false ;
36
- private $cfg_qs_rm ;
37
- private $cfg_exc_jquery ;
38
- private $cfg_ggfonts_async ;
39
- private $_conf_css_font_display ;
40
- private $cfg_optm_max_size ;
41
- private $cfg_ttl ;
42
- private $cfg_ggfonts_rm ;
43
 
44
- private $dns_prefetch ;
45
- private $_ggfonts_urls = array() ;
46
 
47
- private $html_foot = '' ; // The html info append to <body>
48
- private $html_head = '' ; // The html info prepend to <body>
49
 
50
  private static $_var_i = 0;
51
 
@@ -54,8 +53,7 @@ class Optimize extends Base
54
  * @since 1.2.2
55
  * @access protected
56
  */
57
- protected function __construct()
58
- {
59
  }
60
 
61
  /**
@@ -64,15 +62,13 @@ class Optimize extends Base
64
  * @since 3.0
65
  * @access protected
66
  */
67
- public function init()
68
- {
69
  $this->cfg_css_async = Conf::val( Base::O_OPTM_CSS_ASYNC );
70
  if ( $this->cfg_css_async && ! Conf::val( Base::O_API_KEY ) ) {
71
  Debug2::debug( '[Optm] ❌ CCSS set to OFF due to lack of domain key' );
72
  $this->cfg_css_async = false;
73
  }
74
- $this->cfg_js_defer = Conf::val( Base::O_OPTM_JS_DEFER ) ;
75
- $this->cfg_qs_rm = Conf::val( Base::O_OPTM_QS_RM ) ;
76
 
77
  if ( ! Router::can_optm() ) {
78
  return;
@@ -80,17 +76,12 @@ class Optimize extends Base
80
 
81
  // To remove emoji from WP
82
  if ( Conf::val( Base::O_OPTM_EMOJI_RM ) ) {
83
- $this->_emoji_rm() ;
84
  }
85
 
86
- if ( $this->cfg_qs_rm ) {
87
- add_filter( 'style_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
88
- add_filter( 'script_loader_src', array( $this, 'remove_query_strings' ), 999 ) ;
89
- }
90
-
91
- // Check if there is any critical css rules setting
92
- if ( $this->cfg_css_async ) {
93
- add_filter( 'litespeed_optm_html_head', __NAMESPACE__ . '\CSS::prepend_ccss', 1 ) ;
94
  }
95
 
96
  /**
@@ -98,7 +89,7 @@ class Optimize extends Base
98
  * @since 1.5
99
  */
100
  if ( $this->cfg_js_defer ) {
101
- $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', Conf::val( Base::O_OPTM_JS_DEFER_EXC ) ) ;
102
  }
103
 
104
  /**
@@ -120,8 +111,7 @@ class Optimize extends Base
120
  * @since 1.6
121
  * @access public
122
  */
123
- public function vary_add_role_exclude( $vary )
124
- {
125
  if ( Conf::get_instance()->in_optm_exc_roles() ) {
126
  $vary[ 'role_exclude_optm' ] = 1;
127
  }
@@ -136,19 +126,18 @@ class Optimize extends Base
136
  * @since 2.9.8 Changed to private
137
  * @access private
138
  */
139
- private function _emoji_rm()
140
- {
141
- remove_action( 'wp_head' , 'print_emoji_detection_script', 7 ) ;
142
- remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' ) ;
143
- remove_filter( 'the_content_feed' , 'wp_staticize_emoji' ) ;
144
- remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' ) ;
145
  /**
146
  * Added for better result
147
  * @since 1.6.2.1
148
  */
149
- remove_action( 'wp_print_styles', 'print_emoji_styles' ) ;
150
- remove_action( 'admin_print_styles', 'print_emoji_styles' ) ;
151
- remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ) ;
152
  }
153
 
154
  /**
@@ -158,60 +147,59 @@ class Optimize extends Base
158
  * @since 3.0 Renamed func. Changed access to public
159
  * @access public
160
  */
161
- public function serve_satic( $uri )
162
- {
163
- $this->cfg_css_min = Conf::val( Base::O_OPTM_CSS_MIN ) ;
164
- $this->cfg_css_comb = Conf::val( Base::O_OPTM_CSS_COMB ) ;
165
- $this->cfg_js_min = Conf::val( Base::O_OPTM_JS_MIN ) ;
166
- $this->cfg_js_comb = Conf::val( Base::O_OPTM_JS_COMB ) ;
167
- $this->cfg_ttl = Conf::val( Base::O_OPTM_TTL ) ;
168
 
169
  // If not turn on min files
170
  if ( ! $this->cfg_css_min && ! $this->cfg_css_comb && ! $this->cfg_js_min && ! $this->cfg_js_comb ) {
171
- return ;
172
  }
173
 
174
  // try to match `xx.css`
175
  if ( ! preg_match( '#^(\w+)\.(css|js)#U', $uri, $match ) ) {
176
- return ;
177
  }
178
 
179
- Debug2::debug( '[Optm] start minifying file' ) ;
180
 
181
  // Proceed css/js file generation
182
- define( 'LITESPEED_MIN_FILE', true ) ;
183
 
184
- $file_type = $match[ 2 ] ;
185
 
186
- $static_file = LITESPEED_STATIC_DIR . '/cssjs/' . $match[ 0 ] ;
187
 
188
  // Even if hit PHP, still check if the file is valid to bypass minify process
189
  if ( ! file_exists( $static_file ) || time() - filemtime( $static_file ) > $this->cfg_ttl ) {
190
- $concat_only = ! ( $file_type === 'css' ? $this->cfg_css_min : $this->cfg_js_min ) ;
191
 
192
- $content = Optimizer::get_instance()->serve( $match[ 0 ], $concat_only ) ;
193
 
194
  if ( ! $content ) {
195
- Debug2::debug( '[Optm] Static file generation bypassed due to empty' ) ;
196
- return ;
197
  }
198
 
199
  // Generate static file
200
- File::save( $static_file, $content, true ) ;
201
- Debug2::debug2( '[Optm] Saved cache to file [path] ' . $static_file ) ;
202
 
203
  }
204
  else {
205
  // Load file from file based cache if not expired
206
- Debug2::debug2( '[Optm] Static file available' ) ;
207
  }
208
 
209
- $url = LITESPEED_STATIC_URL . '/cssjs/' . $match[ 0 ] ;
210
 
211
- Debug2::debug( '[Optm] Redirect to ' . $url ) ;
212
 
213
- wp_redirect( $url ) ;
214
- exit ;
215
  }
216
 
217
  /**
@@ -220,10 +208,9 @@ class Optimize extends Base
220
  * @since 2.1
221
  * @access public
222
  */
223
- public function rm_cache_folder()
224
- {
225
  if ( file_exists( LITESPEED_STATIC_DIR . '/cssjs' ) ) {
226
- File::rrmdir( LITESPEED_STATIC_DIR . '/cssjs' ) ;
227
  }
228
  }
229
 
@@ -233,17 +220,16 @@ class Optimize extends Base
233
  * @since 1.3
234
  * @access public
235
  */
236
- public function remove_query_strings( $src )
237
- {
238
  if ( strpos( $src, '_litespeed_rm_qs=0' ) || strpos( $src, '/recaptcha' ) ) {
239
- return $src ;
240
  }
241
 
242
  if ( strpos( $src, '.js?' ) !== false || strpos( $src, '.css?' ) !== false ) {
243
- $src = preg_replace( '/\?.*/', '', $src ) ;
244
  }
245
 
246
- return $src ;
247
  }
248
 
249
  /**
@@ -252,25 +238,24 @@ class Optimize extends Base
252
  * @since 3.0
253
  * @access public
254
  */
255
- public static function need_db()
256
- {
257
  if ( Conf::val( Base::O_OPTM_CSS_MIN ) ) {
258
- return true ;
259
  }
260
 
261
  if ( Conf::val( Base::O_OPTM_CSS_COMB ) ) {
262
- return true ;
263
  }
264
 
265
  if ( Conf::val( Base::O_OPTM_JS_MIN ) ) {
266
- return true ;
267
  }
268
 
269
  if ( Conf::val( Base::O_OPTM_JS_COMB ) ) {
270
- return true ;
271
  }
272
 
273
- return false ;
274
  }
275
 
276
  /**
@@ -281,41 +266,40 @@ class Optimize extends Base
281
  * @access public
282
  * @return string The content that is after optimization
283
  */
284
- public static function finalize( $content )
285
- {
286
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
287
- return $content ;
288
  }
289
 
290
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
291
- Debug2::debug( '[Optm] bypass: Not frontend HTML type' ) ;
292
- return $content ;
293
  }
294
 
295
  // Check if hit URI excludes
296
- $excludes = Conf::val( Base::O_OPTM_EXC ) ;
297
  if ( ! empty( $excludes ) ) {
298
- $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes ) ;
299
  if ( $result ) {
300
- Debug2::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result ) ;
301
- return $content ;
302
  }
303
  }
304
 
305
  // Check if is exclude optm roles ( Need to set Vary too )
306
  if ( $result = Conf::get_instance()->in_optm_exc_roles() ) {
307
- Debug2::debug( '[Optm] bypass: hit Role Excludes setting: ' . $result ) ;
308
- return $content ;
309
  }
310
 
311
 
312
- Debug2::debug( '[Optm] start' ) ;
313
 
314
- $instance = self::get_instance() ;
315
- $instance->content = $content ;
316
 
317
- $instance->_optimize() ;
318
- return $instance->content ;
319
  }
320
 
321
  /**
@@ -324,35 +308,34 @@ class Optimize extends Base
324
  * @since 1.2.2
325
  * @access private
326
  */
327
- private function _optimize()
328
- {
329
- $this->cfg_http2_css = Conf::val( Base::O_OPTM_CSS_HTTP2 ) ;
330
- $this->cfg_http2_js = Conf::val( Base::O_OPTM_JS_HTTP2 ) ;
331
- $this->cfg_css_min = Conf::val( Base::O_OPTM_CSS_MIN ) ;
332
- $this->cfg_css_comb = Conf::val( Base::O_OPTM_CSS_COMB ) ;
333
- $this->cfg_js_min = Conf::val( Base::O_OPTM_JS_MIN ) ;
334
- $this->cfg_js_comb = Conf::val( Base::O_OPTM_JS_COMB ) ;
335
- $this->cfg_exc_jquery = Conf::val( Base::O_OPTM_EXC_JQ ) ;
336
- $this->cfg_ggfonts_async = Conf::val( Base::O_OPTM_GGFONTS_ASYNC ) ;
337
- $this->_conf_css_font_display = Conf::val( Base::O_OPTM_CSS_FONT_DISPLAY ) ;
338
  if ( ! empty( Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ) ) {
339
- $this->_conf_css_font_display = Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ;
340
  }
341
 
342
- $this->cfg_ttl = Conf::val( Base::O_OPTM_TTL ) ;
343
- $this->cfg_optm_max_size = Conf::val( Base::O_OPTM_MAX_SIZE ) * 1000000 ;
344
- $this->cfg_ggfonts_rm = Conf::val( Base::O_OPTM_GGFONTS_RM ) ;
345
 
346
  if ( ! Router::can_optm() ) {
347
- Debug2::debug( '[Optm] bypass: admin/feed/preview' ) ;
348
- return ;
349
  }
350
 
351
- do_action( 'litespeed_optm' ) ;
352
 
353
  // Parse css from content
354
  if ( $this->cfg_css_min || $this->cfg_css_comb || $this->cfg_http2_css || $this->cfg_ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async || $this->_conf_css_font_display ) {
355
- list( $src_list, $html_list ) = $this->_handle_css() ;
356
  }
357
 
358
  // css optimizer
@@ -360,66 +343,69 @@ class Optimize extends Base
360
 
361
  if ( $src_list ) {
362
  // Analyze local file
363
- list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list ) ;
364
 
365
  // IF combine
366
  if ( $this->cfg_css_comb ) {
367
- $enqueue_first = Conf::val( Base::O_OPTM_CSS_COMB_PRIO ) ;
368
 
369
- $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list ) ;
370
 
371
- $snippet = '' ;
372
  foreach ( $urls as $url ) {
373
- $snippet .= '<link data-optimized="2" rel="stylesheet" href="' . $url . '" />' ;// use 2 as combined
374
  }
375
 
376
  // Handle css async load
377
  if ( $this->cfg_css_async ) {
378
  // Only ignored html snippet needs async
379
- $ignored_html_async = $this->_async_css_list( $ignored_html ) ;
380
 
381
- $snippet = '' ;
382
  foreach ( $urls as $url ) {
383
  $snippet .= '<link rel="preload" data-asynced="1" data-optimized="2" as="style" onload="this.onload=null;this.rel=\'stylesheet\'" href="' . $url . '" />'; // todo: How to use " in attr wrapper "
384
  }
385
 
386
  // enqueue combined file first
387
  if ( $enqueue_first ) {
388
- $this->html_head .= $snippet . implode( '', $ignored_html_async ) ;
389
  }
390
  else {
391
- $this->html_head .= implode( '', $ignored_html_async ) . $snippet ;
392
  }
393
 
394
  }
395
  else {
396
  // enqueue combined file first
397
  if ( $enqueue_first ) {
398
- $this->html_head .= $snippet . implode( '', $ignored_html ) ;
399
  }
400
  else {
401
- $this->html_head .= implode( '', $ignored_html ) . $snippet ;
402
  }
403
  }
404
 
405
  // Move all css to top
406
- $this->content = str_replace( $html_list, '', $this->content ) ;// todo: need to keep position for certain files
407
 
408
  // Add to HTTP2
409
  foreach ( $urls as $url ) {
410
- $this->append_http2( $url ) ;
411
  }
412
 
413
  }
414
  // Only minify
415
  elseif ( $this->cfg_css_min ) {
416
  // will handle async css load inside
417
- $this->_src_queue_handler( $src_queue_list, $html_list ) ;
418
  }
419
  // Only HTTP2 push
420
  else {
421
- foreach ( $src_queue_list as $val ) {
422
- $this->append_http2( $val ) ;
 
 
 
423
  }
424
  }
425
  }
@@ -428,62 +414,62 @@ class Optimize extends Base
428
  // Handle css lazy load if not handled async loaded yet
429
  if ( $this->cfg_css_async && ! $this->cfg_css_min && ! $this->cfg_css_comb ) {
430
  // async html
431
- $html_list_async = $this->_async_css_list( $html_list ) ;
432
 
433
  // Replace async css
434
- $this->content = str_replace( $html_list, $html_list_async, $this->content ) ;
435
 
436
  }
437
 
438
  // Parse js from buffer as needed
439
  if ( $this->cfg_js_min || $this->cfg_js_comb || $this->cfg_http2_js || $this->cfg_js_defer ) {
440
- list( $src_list, $html_list, $head_src_list ) = $this->_parse_js() ;
441
  }
442
 
443
  // js optimizer
444
  if ( $this->cfg_js_min || $this->cfg_js_comb || $this->cfg_http2_js ) {
445
 
446
  if ( $src_list ) {
447
- list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list, 'js' ) ;
448
 
449
  // IF combine
450
  if ( $this->cfg_js_comb ) {
451
- $enqueue_first = Conf::val( Base::O_OPTM_JS_COMB_PRIO ) ;
452
 
453
  // separate head/foot js/raw html
454
- $head_js = array() ;
455
- $head_ignored_html = array() ;
456
- $foot_js = array() ;
457
- $foot_ignored_html = array() ;
458
  foreach ( $src_queue_list as $k => $src ) {
459
  if ( in_array( $src, $head_src_list ) ) {
460
- $head_js[ $k ] = $src ;
461
  }
462
  else {
463
- $foot_js[ $k ] = $src ;
464
  }
465
  }
466
  foreach ( $ignored_html as $src => $html ) {
467
  if ( in_array( $src, $head_src_list ) ) {
468
- $head_ignored_html[ $src ] = $html ;
469
  }
470
  else {
471
- $foot_ignored_html[] = $html ;
472
  }
473
  }
474
 
475
- $snippet = '' ;
476
  if ( $head_js ) {
477
- $urls = $this->_limit_size_build_hash_url( $head_js, $file_size_list, 'js' ) ;
478
  foreach ( $urls as $url ) {
479
- $snippet .= '<script data-optimized="1" src="' . $url . '" ' . ( $this->cfg_js_defer ? 'defer' : '' ) . '></script>' ;
480
 
481
  // Add to HTTP2
482
- $this->append_http2( $url, 'js' ) ;
483
  }
484
  }
485
  if ( $this->cfg_js_defer ) {
486
- $head_ignored_html = $this->_js_defer( $head_ignored_html ) ;
487
  }
488
 
489
  /**
@@ -496,52 +482,52 @@ class Optimize extends Base
496
  foreach ( $head_ignored_html as $src => $html ) {
497
  if ( $this->_is_jquery( $src ) ) {
498
  // jQuery should be always the first one
499
- $this->html_head .= $html ;
500
- unset( $head_ignored_html[ $src ] ) ;
501
- break ;
502
  }
503
  }
504
- $this->html_head .= $snippet . implode( '', $head_ignored_html ) ;
505
  }
506
  else {
507
- $this->html_head .= implode( '', $head_ignored_html ) . $snippet ;
508
  }
509
 
510
- $snippet = '' ;
511
  if ( $foot_js ) {
512
- $urls = $this->_limit_size_build_hash_url( $foot_js, $file_size_list, 'js' ) ;
513
  foreach ( $urls as $url ) {
514
- $snippet .= '<script data-optimized="1" src="' . $url . '" ' . ( $this->cfg_js_defer ? 'defer' : '' ) . '></script>' ;
515
 
516
  // Add to HTTP2
517
- $this->append_http2( $url, 'js' ) ;
518
  }
519
  }
520
  if ( $this->cfg_js_defer ) {
521
- $foot_ignored_html = $this->_js_defer( $foot_ignored_html ) ;
522
  }
523
 
524
  // enqueue combined file first
525
  if ( $enqueue_first ) {
526
- $this->html_foot .= $snippet . implode( '', $foot_ignored_html ) ;
527
  }
528
  else {
529
- $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet ;
530
  }
531
 
532
  // Will move all js to top/bottom
533
- $this->content = str_replace( $html_list, '', $this->content ) ;
534
 
535
  }
536
  // Only minify
537
  elseif ( $this->cfg_js_min ) {
538
  // Will handle js defer inside
539
- $this->_src_queue_handler( $src_queue_list, $html_list, 'js' ) ;
540
  }
541
  // Only HTTP2 push
542
  else {
543
  foreach ( $src_queue_list as $val ) {
544
- $this->append_http2( $val, 'js' ) ;
545
  }
546
  }
547
  }
@@ -550,10 +536,10 @@ class Optimize extends Base
550
  // Handle js defer if not handled defer yet
551
  if ( $this->cfg_js_defer && ! $this->cfg_js_min && ! $this->cfg_js_comb ) {
552
  // defer html
553
- $html_list2 = $this->_js_defer( $html_list ) ;
554
 
555
  // Replace async js
556
- $this->content = str_replace( $html_list, $html_list2, $this->content ) ;
557
  }
558
 
559
 
@@ -574,21 +560,31 @@ class Optimize extends Base
574
  * Handle google fonts async
575
  * This will result in a JS snippet in head, so need to put it in the end to avoid being replaced by JS parser
576
  */
577
- $this->_async_ggfonts() ;
578
 
579
  /**
580
  * Font display optm
581
  * @since 3.0
582
  */
583
- $this->_font_optm() ;
 
 
 
 
 
 
584
 
585
  /**
586
  * Inline script manipulated until document is ready
587
- *
588
  * @since 3.0
589
  */
590
  $this->_js_inline_defer();
591
 
 
 
 
 
 
592
  // Replace html head part
593
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head );
594
  if ( $this->html_head ) {
@@ -630,6 +626,8 @@ class Optimize extends Base
630
  return;
631
  }
632
 
 
 
633
  Debug2::debug( '[Optm] Inline JS defer ' . $optm_js_inline );
634
 
635
  preg_match_all( '#<script([^>]*)>(.*)</script>#isU', $this->content, $matches, PREG_SET_ORDER );
@@ -656,7 +654,20 @@ class Optimize extends Base
656
  }
657
  }
658
 
659
- $con = trim( $match[ 2 ] );
 
 
 
 
 
 
 
 
 
 
 
 
 
660
  if ( ! $con ) {
661
  continue;
662
  }
@@ -709,15 +720,14 @@ class Optimize extends Base
709
  * @since 2.7.3
710
  * @access private
711
  */
712
- private function _async_ggfonts()
713
- {
714
  if ( ! $this->cfg_ggfonts_async || ! $this->_ggfonts_urls ) {
715
- return ;
716
  }
717
 
718
- Debug2::debug2( '[Optm] google fonts async found: ', $this->_ggfonts_urls ) ;
719
 
720
- $html = '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />' ;
721
 
722
  /**
723
  * Append fonts
@@ -729,24 +739,24 @@ class Optimize extends Base
729
  * -> family: PT Sans:400,700|PT Sans Narrow:400|Montserrat:600
730
  * <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' />
731
  */
732
- $html .='<script>WebFontConfig={google:{families:[' ;
733
 
734
- $families = array() ;
735
  foreach ( $this->_ggfonts_urls as $v ) {
736
- $qs = wp_specialchars_decode( $v ) ;
737
- $qs = urldecode( $qs ) ;
738
- $qs = parse_url( $qs, PHP_URL_QUERY ) ;
739
- parse_str( $qs, $qs ) ;
740
 
741
  if ( empty( $qs[ 'family' ] ) ) {
742
- Debug2::debug( '[Optm] ERR ggfonts failed to find family: ' . $v ) ;
743
- continue ;
744
  }
745
 
746
- $subset = empty( $qs[ 'subset' ] ) ? '' : ':' . $qs[ 'subset' ] ;
747
 
748
  foreach ( array_filter( explode( '|', $qs[ 'family' ] ) ) as $v2 ) {
749
- $families[] = $v2 . $subset ;
750
  }
751
 
752
  }
@@ -758,18 +768,18 @@ class Optimize extends Base
758
  // if webfontloader lib was loaded before WebFontConfig variable, call WebFont.load
759
  $html .= 'if ( typeof WebFont === "object" && typeof WebFont.load === "function" ) { WebFont.load( WebFontConfig ); }';
760
 
761
- $html .= '</script>' ;
762
 
763
  // https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js
764
- $webfont_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_WEBFONTLOADER ;
765
 
766
  // default async, if js defer set use defer
767
  // TODO: make defer optional
768
- $html .= '<script id="litespeed-webfont-lib" src="' . $webfont_lib_url . '" ' . ( $this->cfg_js_defer ? 'defer' : 'async' ) . '></script>' ;
769
- $this->append_http2( $webfont_lib_url, 'js' ) ; // async lib will be http/2 pushed always
770
 
771
  // Put this in the very beginning for preconnect
772
- $this->html_head = $html . $this->html_head ;
773
  }
774
 
775
  /**
@@ -778,21 +788,20 @@ class Optimize extends Base
778
  * @since 3.0
779
  * @access private
780
  */
781
- private function _font_optm()
782
- {
783
  if ( ! $this->_conf_css_font_display || ! $this->_ggfonts_urls ) {
784
- return ;
785
  }
786
 
787
- Debug2::debug2( '[Optm] google fonts optm ', $this->_ggfonts_urls ) ;
788
 
789
  foreach ( $this->_ggfonts_urls as $v ) {
790
  if ( strpos( $v, 'display=' ) ) {
791
- continue ;
792
  }
793
- $this->html_head = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->html_head ) ;
794
- $this->html_foot = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->html_foot ) ;
795
- $this->content = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->content ) ;
796
  }
797
  }
798
 
@@ -802,23 +811,22 @@ class Optimize extends Base
802
  * @since 1.7.1
803
  * @access private
804
  */
805
- private function _dns_prefetch_init()
806
- {
807
  // Widely enable link DNS prefetch
808
  if ( Conf::val( Base::O_OPTM_DNS_PREFETCH_CTRL ) ) {
809
  add_filter( 'litespeed_optm_html_head', array( $this, 'dns_prefetch_xmeta' ), 999 );
810
  }
811
 
812
- $this->dns_prefetch = Conf::val( Base::O_OPTM_DNS_PREFETCH ) ;
813
  if ( ! $this->dns_prefetch ) {
814
- return ;
815
  }
816
 
817
  if ( function_exists( 'wp_resource_hints' ) ) {
818
- add_filter( 'wp_resource_hints', array( $this, 'dns_prefetch_filter' ), 10, 2 ) ;
819
  }
820
  else {
821
- add_action( 'litespeed_optm', array( $this, 'dns_prefetch_output' ) ) ;
822
  }
823
  }
824
 
@@ -828,8 +836,7 @@ class Optimize extends Base
828
  * @since 3.0
829
  * @access public
830
  */
831
- public function dns_prefetch_xmeta( $content )
832
- {
833
  $content .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
834
  return $content;
835
  }
@@ -840,19 +847,18 @@ class Optimize extends Base
840
  * @since 1.7.1
841
  * @access public
842
  */
843
- public function dns_prefetch_filter( $urls, $relation_type )
844
- {
845
  if ( $relation_type !== 'dns-prefetch' ) {
846
- return $urls ;
847
  }
848
 
849
  foreach ( $this->dns_prefetch as $v ) {
850
  if ( $v ) {
851
- $urls[] = $v ;
852
  }
853
  }
854
 
855
- return $urls ;
856
  }
857
 
858
  /**
@@ -861,8 +867,7 @@ class Optimize extends Base
861
  * @since 1.7.1
862
  * @access public
863
  */
864
- public function dns_prefetch_output()
865
- {
866
  foreach ( $this->dns_prefetch as $v ) {
867
  if ( $v ) {
868
  $this->html_head .= '<link rel="dns-prefetch" href="' . $v . '" />';
@@ -881,11 +886,10 @@ class Optimize extends Base
881
  $i = 0;
882
  $src_arr = array();
883
  $url_sensitive = Conf::val( Base::O_OPTM_CSS_UNIQUE ) && $file_type == 'css'; // If need to keep unique CSS per URI
884
- foreach ( $src_queue_list as $k => $v ) {
885
-
886
  empty( $src_arr[ $i ] ) && $src_arr[ $i ] = array();
887
 
888
- $src_arr[ $i ][] = $v;
889
 
890
  $total += $file_size_list[ $k ];
891
 
@@ -900,8 +904,8 @@ class Optimize extends Base
900
 
901
  // group build
902
  $hashed_arr = array();
903
- foreach ( $src_arr as $v ) {
904
- $hashed_arr[] = $this->_build_hash_url( $v, $file_type, $url_sensitive );
905
  }
906
 
907
  return $hashed_arr;
@@ -913,33 +917,35 @@ class Optimize extends Base
913
  * @since 1.2.2
914
  * @access private
915
  */
916
- private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' )
917
- {
918
- $html_list_ori = $html_list ;
919
 
920
- $tag = $file_type === 'css' ? 'link' : 'script' ;
921
  foreach ( $src_queue_list as $key => $src ) {
922
- $url = $this->_build_hash_url( $src, $file_type ) ;
923
- $snippet = str_replace( $src, $url, $html_list[ $key ] ) ;
924
- $snippet = str_replace( "<$tag ", '<' . $tag . ' data-optimized="1" ', $snippet ) ;
 
 
 
925
 
926
- $html_list[ $key ] = $snippet ;
927
 
928
  // Add to HTTP2
929
- $this->append_http2( $url, $file_type ) ;
930
  }
931
 
932
  // Handle css async load
933
  if ( $file_type === 'css' && $this->cfg_css_async ) {
934
- $html_list = $this->_async_css_list( $html_list ) ;
935
  }
936
 
937
  // Handle js defer
938
  if ( $file_type === 'js' && $this->cfg_js_defer ) {
939
- $html_list = $this->_js_defer( $html_list ) ;
940
  }
941
 
942
- $this->content = str_replace( $html_list_ori, $html_list, $this->content ) ;
943
  }
944
 
945
  /**
@@ -949,49 +955,56 @@ class Optimize extends Base
949
  * @access private
950
  * @return array Array(Ignored raw html, src needed to be handled list, filesize for param 2nd )
951
  */
952
- private function _analyse_links( $src_list, $html_list, $file_type = 'css' )
953
- {
954
  // if ( $file_type == 'css' ) {
955
- // $excludes = apply_filters( 'litespeed_optimize_css_excludes', Conf::val( Base::O_OPTM_CSS_EXC ) ) ;
956
  // }
957
  // else {
958
- // $excludes = apply_filters( 'litespeed_optimize_js_excludes', Conf::val( Base::O_OPTM_JS_EXC ) ) ;
959
  // }
960
  // if ( $excludes ) {
961
- // $excludes = explode( "\n", $excludes ) ;
962
  // }
963
 
964
- $ignored_html = array() ;
965
- $src_queue_list = array() ;
966
- $file_size_list = array() ;
967
 
968
  // Analyse links
969
- foreach ( $src_list as $key => $src ) {
970
- Debug2::debug2( '[Optm] ' . $src ) ;
 
 
 
 
 
 
 
 
971
 
972
  /**
973
  * Excluded links won't be done any optm
974
  * @since 1.7
975
  */
976
  // if ( $excludes && $exclude = Utility::str_hit_array( $src, $excludes ) ) {
977
- // $ignored_html[] = $html_list[ $key ] ;
978
- // Debug2::debug2( '[Optm]: Abort excludes: ' . $exclude ) ;
979
- // continue ;
980
  // }
981
 
982
  // Check if has no-optimize attr
983
  if ( strpos( $html_list[ $key ], 'data-ignore-optimize' ) !== false ) {
984
- $ignored_html[] = $html_list[ $key ] ;
985
- Debug2::debug2( '[Optm] Abort excludes: attr data-ignore-optimize' ) ;
986
- continue ;
987
  }
988
 
989
  // Check if is external URL
990
- $url_parsed = parse_url( $src ) ;
991
  if ( ! $file_info = Utility::is_internal_file( $src ) ) {
992
- $ignored_html[ $src ] = $html_list[ $key ] ;
993
- Debug2::debug2( '[Optm] Abort external/non-exist' ) ;
994
- continue ;
995
  }
996
 
997
  /**
@@ -1000,20 +1013,22 @@ class Optimize extends Base
1000
  * @since 1.5
1001
  */
1002
  if ( $this->cfg_exc_jquery && $this->_is_jquery( $src ) ) {
1003
- $ignored_html[ $src ] = $html_list[ $key ] ;
1004
- Debug2::debug2( '[Optm] Abort jQuery by setting' ) ;
1005
 
1006
  // Add to HTTP2 as its ignored but still internal src
1007
- $this->append_http2( $src, 'js' ) ;
1008
 
1009
- continue ;
1010
  }
1011
 
1012
- $src_queue_list[ $key ] = $src ;
1013
- $file_size_list[ $key ] = $file_info[ 1 ] ;
 
 
1014
  }
1015
 
1016
- return array( $ignored_html, $src_queue_list, $file_size_list ) ;
1017
  }
1018
 
1019
  /**
@@ -1035,18 +1050,22 @@ class Optimize extends Base
1035
  $src = array( $src );
1036
  }
1037
 
1038
- $src = array_values( $src );
 
1039
 
1040
  // Drop query strings
1041
- $src = array_map( array( $this, 'remove_query_strings' ), $src );
1042
-
1043
- $purge_timestamp = self::get_option( self::ITEM_TIMESTAMP_PURGE_CSS );
1044
-
1045
- $hash = md5( json_encode( $src ) . $purge_timestamp );
1046
-
1047
- $short = substr( $hash, -5 );
 
1048
 
1049
- $filename = $short . '.' . $file_type;
 
 
1050
 
1051
  // Need to check conflicts
1052
  // If short hash exists
@@ -1063,7 +1082,7 @@ class Optimize extends Base
1063
 
1064
  // Need to insert the record
1065
  if ( ! $existed ) {
1066
- Data::get_instance()->optm_save_src( $filename, $src );
1067
  }
1068
 
1069
  // Generate static files
@@ -1081,7 +1100,7 @@ class Optimize extends Base
1081
 
1082
  }
1083
 
1084
- return LITESPEED_STATIC_URL . '/cssjs/' . $filename;
1085
  }
1086
 
1087
  /**
@@ -1091,59 +1110,62 @@ class Optimize extends Base
1091
  * @access private
1092
  * @return array All the src & related raw html list
1093
  */
1094
- private function _parse_js()
1095
- {
1096
- $excludes = apply_filters( 'litespeed_optimize_js_excludes', Conf::val( Base::O_OPTM_JS_EXC ) ) ;
1097
 
1098
- $src_list = array() ;
1099
- $html_list = array() ;
1100
- $head_src_list = array() ;
1101
 
1102
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
1103
- preg_match_all( '#<script \s*([^>]+)>\s*</script>|</head>#isU', $content, $matches, PREG_SET_ORDER ) ;
1104
- $is_head = true ;
1105
  foreach ( $matches as $match ) {
1106
  if ( $match[ 0 ] === '</head>' ) {
1107
- $is_head = false ;
1108
- continue ;
1109
  }
1110
- $attrs = Utility::parse_attr( $match[ 1 ] ) ;
1111
 
1112
  if ( isset( $attrs[ 'data-optimized' ] ) ) {
1113
- continue ;
1114
  }
1115
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
1116
- continue ;
1117
  }
1118
  if ( empty( $attrs[ 'src' ] ) ) {
1119
- continue ;
1120
  }
1121
 
1122
- $url_parsed = parse_url( $attrs[ 'src' ], PHP_URL_PATH ) ;
 
 
 
 
1123
  if ( substr( $url_parsed, -3 ) !== '.js' ) {
1124
- Debug2::debug2( '[Optm] _parse_js bypassed due to not js file ' . $url_parsed ) ;
1125
- continue ;
1126
  }
1127
 
1128
  // to avoid multiple replacement
1129
  if ( in_array( $match[ 0 ], $html_list ) ) {
1130
- continue ;
1131
  }
1132
  // todo @v2.0: allow defer even exclude from optm
1133
  if ( $excludes && $exclude = Utility::str_hit_array( $attrs[ 'src' ], $excludes ) ) {
1134
- Debug2::debug2( '[Optm] _parse_js bypassed exclude ' . $exclude ) ;
1135
- continue ;
1136
  }
1137
 
1138
- $src_list[] = $attrs[ 'src' ] ;
1139
- $html_list[] = $match[ 0 ] ;
1140
 
1141
  if ( $is_head ) {
1142
- $head_src_list[] = $attrs[ 'src' ] ;
1143
  }
1144
  }
1145
 
1146
- return array( $src_list, $html_list, $head_src_list ) ;
1147
  }
1148
 
1149
  /**
@@ -1153,52 +1175,51 @@ class Optimize extends Base
1153
  * @access private
1154
  * @return array All the src & related raw html list
1155
  */
1156
- private function _handle_css()
1157
- {
1158
- $excludes = apply_filters( 'litespeed_optimize_css_excludes', Conf::val( Base::O_OPTM_CSS_EXC ) ) ;
1159
 
1160
- $css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', array() ) ;
1161
 
1162
- $src_list = array() ;
1163
- $html_list = array() ;
1164
 
1165
- // $dom = new \PHPHtmlParser\Dom ;
1166
- // $dom->load( $content ) ;return $val;
1167
- // $items = $dom->find( 'link' ) ;
1168
 
1169
- $content = preg_replace( '#<!--.*-->#sU', '', $this->content ) ;
1170
- preg_match_all( '#<link \s*([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER ) ;
1171
  foreach ( $matches as $match ) {
1172
- $attrs = Utility::parse_attr( $match[ 1 ] ) ;
1173
 
1174
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
1175
- continue ;
1176
  }
1177
  if ( isset( $attrs[ 'data-optimized' ] ) ) {
1178
- continue ;
1179
  }
1180
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
1181
- continue ;
1182
  }
1183
  if ( ! empty( $attrs[ 'media' ] ) && strpos( $attrs[ 'media' ], 'print' ) !== false ) {
1184
- continue ;
1185
  }
1186
  if ( empty( $attrs[ 'href' ] ) ) {
1187
- continue ;
1188
  }
1189
 
1190
  if ( $excludes && $exclude = Utility::str_hit_array( $attrs[ 'href' ], $excludes ) ) {
1191
- Debug2::debug2( '[Optm] _handle_css bypassed exclude ' . $exclude ) ;
1192
- continue ;
1193
  }
1194
 
1195
  // Check if need to remove this css
1196
  if ( $css_to_be_removed && Utility::str_hit_array( $attrs[ 'href' ], $css_to_be_removed ) ) {
1197
- Debug2::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] ) ;
1198
  // Delete this css snippet from orig html
1199
- $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1200
 
1201
- continue ;
1202
  }
1203
 
1204
  // Check Google fonts hit
@@ -1209,27 +1230,36 @@ class Optimize extends Base
1209
  * @since 3.0 For fotn display optm, need to parse google fonts URL too
1210
  */
1211
  if ( ! in_array( $attrs[ 'href' ], $this->_ggfonts_urls ) ) {
1212
- $this->_ggfonts_urls[] = $attrs[ 'href' ] ;
1213
  }
1214
 
1215
  if ( $this->cfg_ggfonts_rm || $this->cfg_ggfonts_async ) {
1216
- Debug2::debug2( '[Optm] rm css snippet [Google fonts] ' . $attrs[ 'href' ] ) ;
1217
- $this->content = str_replace( $match[ 0 ], '', $this->content ) ;
1218
 
1219
- continue ;
1220
  }
1221
  }
1222
 
1223
  // to avoid multiple replacement
1224
  if ( in_array( $match[ 0 ], $html_list ) ) {
1225
- continue ;
 
 
 
 
 
 
 
 
 
 
1226
  }
1227
 
1228
- $src_list[] = $attrs[ 'href' ] ;
1229
- $html_list[] = $match[ 0 ] ;
1230
  }
1231
 
1232
- return array( $src_list, $html_list ) ;
1233
  }
1234
 
1235
  /**
@@ -1240,27 +1270,26 @@ class Optimize extends Base
1240
  * @param array $html_list Orignal css array
1241
  * @return array (array)css_async_list
1242
  */
1243
- private function _async_css_list( $html_list )
1244
- {
1245
  foreach ( $html_list as $k => $ori ) {
1246
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
1247
- Debug2::debug2( '[Optm] bypass: attr data-asynced exist' ) ;
1248
- continue ;
1249
  }
1250
 
1251
  if ( strpos( $ori, 'data-no-async' ) !== false ) {
1252
- Debug2::debug2( '[Optm] bypass: attr api data-no-async' ) ;
1253
- continue ;
1254
  }
1255
 
1256
  // async replacement
1257
- $v = str_replace( 'stylesheet', 'preload', $ori ) ;
1258
  $v = str_replace( '<link', '<link data-asynced="1" as="style" onload="this.onload=null;this.rel=\'stylesheet\'" ', $v );
1259
  // Append to noscript content
1260
- $v .= '<noscript>' . $ori . '</noscript>' ;
1261
- $html_list[ $k ] = $v ;
1262
  }
1263
- return $html_list ;
1264
  }
1265
 
1266
  /**
@@ -1269,22 +1298,21 @@ class Optimize extends Base
1269
  * @since 1.3
1270
  * @access private
1271
  */
1272
- private function _js_defer( $html_list )
1273
- {
1274
  foreach ( $html_list as $k => $v ) {
1275
  if ( strpos( $v, 'async' ) !== false ) {
1276
- continue ;
1277
  }
1278
  if ( strpos( $v, 'defer' ) !== false ) {
1279
- continue ;
1280
  }
1281
  if ( strpos( $v, 'data-deferred' ) !== false ) {
1282
- Debug2::debug2( '[Optm] bypass: attr data-deferred exist' ) ;
1283
- continue ;
1284
  }
1285
  if ( strpos( $v, 'data-no-defer' ) !== false ) {
1286
- Debug2::debug2( '[Optm] bypass: attr api data-no-defer' ) ;
1287
- continue ;
1288
  }
1289
 
1290
  /**
@@ -1293,20 +1321,20 @@ class Optimize extends Base
1293
  */
1294
  if ( $this->cfg_js_defer_exc || $this->cfg_exc_jquery ) {
1295
  // parse js src
1296
- preg_match( '#<script \s*([^>]+)>#isU', $v, $matches ) ;
1297
  if ( empty( $matches[ 1 ] ) ) {
1298
- Debug2::debug( '[Optm] js defer parse html failed: ' . $v ) ;
1299
- continue ;
1300
  }
1301
 
1302
- $attrs = Utility::parse_attr( $matches[ 1 ] ) ;
1303
 
1304
  if ( empty( $attrs[ 'src' ] ) ) {
1305
- Debug2::debug( '[Optm] js defer parse src failed: ' . $matches[ 1 ] ) ;
1306
- continue ;
1307
  }
1308
 
1309
- $src = $attrs[ 'src' ] ;
1310
  }
1311
 
1312
  /**
@@ -1314,8 +1342,8 @@ class Optimize extends Base
1314
  * @since 1.5
1315
  */
1316
  if ( $this->cfg_js_defer_exc && Utility::str_hit_array( $src, $this->cfg_js_defer_exc ) ) {
1317
- Debug2::debug( '[Optm] js defer exclude ' . $src ) ;
1318
- continue ;
1319
  }
1320
 
1321
  /**
@@ -1323,14 +1351,14 @@ class Optimize extends Base
1323
  * @since 1.5
1324
  */
1325
  if ( $this->cfg_exc_jquery && $this->_is_jquery( $src ) ) {
1326
- Debug2::debug2( '[Optm] js defer Abort jQuery by setting' ) ;
1327
- continue ;
1328
  }
1329
 
1330
- $html_list[ $k ] = str_replace( '></script>', ' defer data-deferred="1"></script>', $v ) ;
1331
  }
1332
 
1333
- return $html_list ;
1334
  }
1335
 
1336
  /**
@@ -1339,9 +1367,8 @@ class Optimize extends Base
1339
  * @since 1.5
1340
  * @access private
1341
  */
1342
- private function _is_jquery( $src )
1343
- {
1344
- return stripos( $src, 'jquery.js' ) !== false || stripos( $src, 'jquery.min.js' ) !== false ;
1345
  }
1346
 
1347
  /**
@@ -1350,10 +1377,9 @@ class Optimize extends Base
1350
  * @since 1.2.2
1351
  * @access private
1352
  */
1353
- private function append_http2( $url, $file_type = 'css' )
1354
- {
1355
  if ( ! ( $file_type === 'css' ? $this->cfg_http2_css : $this->cfg_http2_js ) ) {
1356
- return ;
1357
  }
1358
 
1359
  /**
@@ -1361,20 +1387,20 @@ class Optimize extends Base
1361
  * @since 1.6.2.1
1362
  */
1363
  if ( CDN::inc_type( $file_type ) ) {
1364
- return ;
1365
  }
1366
 
1367
  /**
1368
  * Keep QS for constance by set 2nd param to true
1369
  * @since 1.6.2.1
1370
  */
1371
- $uri = Utility::url2uri( $url, true ) ;
1372
 
1373
  if ( ! $uri ) {
1374
- return ;
1375
  }
1376
 
1377
- $this->http2_headers[] = '<' . $uri . '>; rel=preload; as=' . ( $file_type === 'css' ? 'style' : 'script' ) ;
1378
  }
1379
 
1380
  }
8
  * @subpackage LiteSpeed/inc
9
  * @author LiteSpeed Technologies <info@litespeedtech.com>
10
  */
11
+ namespace LiteSpeed;
12
 
13
+ defined( 'WPINC' ) || exit;
14
 
15
+ class Optimize extends Base {
16
+ protected static $_instance;
 
17
 
18
+ const LIB_FILE_CSS_ASYNC = 'assets/js/css_async.min.js';
19
+ const LIB_FILE_WEBFONTLOADER = 'assets/js/webfontloader.min.js';
20
 
21
+ const ITEM_TIMESTAMP_PURGE_CSS = 'timestamp_purge_css';
22
 
23
+ private $content;
24
+ private $content_ori;
25
+ private $http2_headers = array();
26
 
27
+ private $cfg_http2_css;
28
+ private $cfg_http2_js;
29
+ private $cfg_css_min;
30
+ private $cfg_css_comb;
31
+ private $cfg_js_min;
32
+ private $cfg_js_comb;
33
+ private $cfg_css_async;
34
+ private $cfg_js_defer;
35
+ private $cfg_js_defer_exc = false;
36
+ private $cfg_exc_jquery;
37
+ private $cfg_ggfonts_async;
38
+ private $_conf_css_font_display;
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 static $_var_i = 0;
50
 
53
  * @since 1.2.2
54
  * @access protected
55
  */
56
+ protected function __construct() {
 
57
  }
58
 
59
  /**
62
  * @since 3.0
63
  * @access protected
64
  */
65
+ public function init() {
 
66
  $this->cfg_css_async = Conf::val( Base::O_OPTM_CSS_ASYNC );
67
  if ( $this->cfg_css_async && ! Conf::val( Base::O_API_KEY ) ) {
68
  Debug2::debug( '[Optm] ❌ CCSS set to OFF due to lack of domain key' );
69
  $this->cfg_css_async = false;
70
  }
71
+ $this->cfg_js_defer = Conf::val( Base::O_OPTM_JS_DEFER );
 
72
 
73
  if ( ! Router::can_optm() ) {
74
  return;
76
 
77
  // To remove emoji from WP
78
  if ( Conf::val( Base::O_OPTM_EMOJI_RM ) ) {
79
+ $this->_emoji_rm();
80
  }
81
 
82
+ if ( Conf::val( Base::O_OPTM_QS_RM ) ) {
83
+ add_filter( 'style_loader_src', array( $this, 'remove_query_strings' ), 999 );
84
+ add_filter( 'script_loader_src', array( $this, 'remove_query_strings' ), 999 );
 
 
 
 
 
85
  }
86
 
87
  /**
89
  * @since 1.5
90
  */
91
  if ( $this->cfg_js_defer ) {
92
+ $this->cfg_js_defer_exc = apply_filters( 'litespeed_optm_js_defer_exc', Conf::val( Base::O_OPTM_JS_DEFER_EXC ) );
93
  }
94
 
95
  /**
111
  * @since 1.6
112
  * @access public
113
  */
114
+ public function vary_add_role_exclude( $vary ) {
 
115
  if ( Conf::get_instance()->in_optm_exc_roles() ) {
116
  $vary[ 'role_exclude_optm' ] = 1;
117
  }
126
  * @since 2.9.8 Changed to private
127
  * @access private
128
  */
129
+ private function _emoji_rm() {
130
+ remove_action( 'wp_head' , 'print_emoji_detection_script', 7 );
131
+ remove_action( 'admin_print_scripts' , 'print_emoji_detection_script' );
132
+ remove_filter( 'the_content_feed' , 'wp_staticize_emoji' );
133
+ remove_filter( 'comment_text_rss' , 'wp_staticize_emoji' );
 
134
  /**
135
  * Added for better result
136
  * @since 1.6.2.1
137
  */
138
+ remove_action( 'wp_print_styles', 'print_emoji_styles' );
139
+ remove_action( 'admin_print_styles', 'print_emoji_styles' );
140
+ remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
141
  }
142
 
143
  /**
147
  * @since 3.0 Renamed func. Changed access to public
148
  * @access public
149
  */
150
+ public function serve_satic( $uri ) {
151
+ $this->cfg_css_min = Conf::val( Base::O_OPTM_CSS_MIN );
152
+ $this->cfg_css_comb = Conf::val( Base::O_OPTM_CSS_COMB );
153
+ $this->cfg_js_min = Conf::val( Base::O_OPTM_JS_MIN );
154
+ $this->cfg_js_comb = Conf::val( Base::O_OPTM_JS_COMB );
155
+ $this->cfg_ttl = Conf::val( Base::O_OPTM_TTL );
 
156
 
157
  // If not turn on min files
158
  if ( ! $this->cfg_css_min && ! $this->cfg_css_comb && ! $this->cfg_js_min && ! $this->cfg_js_comb ) {
159
+ return;
160
  }
161
 
162
  // try to match `xx.css`
163
  if ( ! preg_match( '#^(\w+)\.(css|js)#U', $uri, $match ) ) {
164
+ return;
165
  }
166
 
167
+ Debug2::debug( '[Optm] start minifying file' );
168
 
169
  // Proceed css/js file generation
170
+ define( 'LITESPEED_MIN_FILE', true );
171
 
172
+ $file_type = $match[ 2 ];
173
 
174
+ $static_file = LITESPEED_STATIC_DIR . '/cssjs/' . $match[ 0 ];
175
 
176
  // Even if hit PHP, still check if the file is valid to bypass minify process
177
  if ( ! file_exists( $static_file ) || time() - filemtime( $static_file ) > $this->cfg_ttl ) {
178
+ $concat_only = ! ( $file_type === 'css' ? $this->cfg_css_min : $this->cfg_js_min );
179
 
180
+ $content = Optimizer::get_instance()->serve( $match[ 0 ], $concat_only );
181
 
182
  if ( ! $content ) {
183
+ Debug2::debug( '[Optm] Static file generation bypassed due to empty' );
184
+ return;
185
  }
186
 
187
  // Generate static file
188
+ File::save( $static_file, $content, true );
189
+ Debug2::debug2( '[Optm] Saved cache to file [path] ' . $static_file );
190
 
191
  }
192
  else {
193
  // Load file from file based cache if not expired
194
+ Debug2::debug2( '[Optm] Static file available' );
195
  }
196
 
197
+ $url = LITESPEED_STATIC_URL . '/cssjs/' . $match[ 0 ];
198
 
199
+ Debug2::debug( '[Optm] Redirect to ' . $url );
200
 
201
+ wp_redirect( $url );
202
+ exit;
203
  }
204
 
205
  /**
208
  * @since 2.1
209
  * @access public
210
  */
211
+ public function rm_cache_folder() {
 
212
  if ( file_exists( LITESPEED_STATIC_DIR . '/cssjs' ) ) {
213
+ File::rrmdir( LITESPEED_STATIC_DIR . '/cssjs' );
214
  }
215
  }
216
 
220
  * @since 1.3
221
  * @access public
222
  */
223
+ public function remove_query_strings( $src ) {
 
224
  if ( strpos( $src, '_litespeed_rm_qs=0' ) || strpos( $src, '/recaptcha' ) ) {
225
+ return $src;
226
  }
227
 
228
  if ( strpos( $src, '.js?' ) !== false || strpos( $src, '.css?' ) !== false ) {
229
+ $src = preg_replace( '/\?.*/', '', $src );
230
  }
231
 
232
+ return $src;
233
  }
234
 
235
  /**
238
  * @since 3.0
239
  * @access public
240
  */
241
+ public static function need_db() {
 
242
  if ( Conf::val( Base::O_OPTM_CSS_MIN ) ) {
243
+ return true;
244
  }
245
 
246
  if ( Conf::val( Base::O_OPTM_CSS_COMB ) ) {
247
+ return true;
248
  }
249
 
250
  if ( Conf::val( Base::O_OPTM_JS_MIN ) ) {
251
+ return true;
252
  }
253
 
254
  if ( Conf::val( Base::O_OPTM_JS_COMB ) ) {
255
+ return true;
256
  }
257
 
258
+ return false;
259
  }
260
 
261
  /**
266
  * @access public
267
  * @return string The content that is after optimization
268
  */
269
+ public static function finalize( $content ) {
 
270
  if ( defined( 'LITESPEED_MIN_FILE' ) ) {// Must have this to avoid css/js from optimization again ( But can be removed as mini file doesn't have LITESPEED_IS_HTML, keep for efficiency)
271
+ return $content;
272
  }
273
 
274
  if ( ! defined( 'LITESPEED_IS_HTML' ) ) {
275
+ Debug2::debug( '[Optm] bypass: Not frontend HTML type' );
276
+ return $content;
277
  }
278
 
279
  // Check if hit URI excludes
280
+ $excludes = Conf::val( Base::O_OPTM_EXC );
281
  if ( ! empty( $excludes ) ) {
282
+ $result = Utility::str_hit_array( $_SERVER[ 'REQUEST_URI' ], $excludes );
283
  if ( $result ) {
284
+ Debug2::debug( '[Optm] bypass: hit URI Excludes setting: ' . $result );
285
+ return $content;
286
  }
287
  }
288
 
289
  // Check if is exclude optm roles ( Need to set Vary too )
290
  if ( $result = Conf::get_instance()->in_optm_exc_roles() ) {
291
+ Debug2::debug( '[Optm] bypass: hit Role Excludes setting: ' . $result );
292
+ return $content;
293
  }
294
 
295
 
296
+ Debug2::debug( '[Optm] start' );
297
 
298
+ $instance = self::get_instance();
299
+ $instance->content_ori = $instance->content = $content;
300
 
301
+ $instance->_optimize();
302
+ return $instance->content;
303
  }
304
 
305
  /**
308
  * @since 1.2.2
309
  * @access private
310
  */
311
+ private function _optimize() {
312
+ $this->cfg_http2_css = Conf::val( Base::O_OPTM_CSS_HTTP2 );
313
+ $this->cfg_http2_js = Conf::val( Base::O_OPTM_JS_HTTP2 );
314
+ $this->cfg_css_min = Conf::val( Base::O_OPTM_CSS_MIN );
315
+ $this->cfg_css_comb = Conf::val( Base::O_OPTM_CSS_COMB );
316
+ $this->cfg_js_min = Conf::val( Base::O_OPTM_JS_MIN );
317
+ $this->cfg_js_comb = Conf::val( Base::O_OPTM_JS_COMB );
318
+ $this->cfg_exc_jquery = Conf::val( Base::O_OPTM_EXC_JQ );
319
+ $this->cfg_ggfonts_async = Conf::val( Base::O_OPTM_GGFONTS_ASYNC );
320
+ $this->_conf_css_font_display = Conf::val( Base::O_OPTM_CSS_FONT_DISPLAY );
 
321
  if ( ! empty( Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ) ) {
322
+ $this->_conf_css_font_display = Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ];
323
  }
324
 
325
+ $this->cfg_ttl = Conf::val( Base::O_OPTM_TTL );
326
+ $this->cfg_optm_max_size = Conf::val( Base::O_OPTM_MAX_SIZE ) * 1000000;
327
+ $this->cfg_ggfonts_rm = Conf::val( Base::O_OPTM_GGFONTS_RM );
328
 
329
  if ( ! Router::can_optm() ) {
330
+ Debug2::debug( '[Optm] bypass: admin/feed/preview' );
331
+ return;
332
  }
333
 
334
+ do_action( 'litespeed_optm' );
335
 
336
  // Parse css from content
337
  if ( $this->cfg_css_min || $this->cfg_css_comb || $this->cfg_http2_css || $this->cfg_ggfonts_rm || $this->cfg_css_async || $this->cfg_ggfonts_async || $this->_conf_css_font_display ) {
338
+ list( $src_list, $html_list ) = $this->_handle_css();
339
  }
340
 
341
  // css optimizer
343
 
344
  if ( $src_list ) {
345
  // Analyze local file
346
+ list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list );
347
 
348
  // IF combine
349
  if ( $this->cfg_css_comb ) {
350
+ $enqueue_first = Conf::val( Base::O_OPTM_CSS_COMB_PRIO );
351
 
352
+ $urls = $this->_limit_size_build_hash_url( $src_queue_list, $file_size_list );
353
 
354
+ $snippet = '';
355
  foreach ( $urls as $url ) {
356
+ $snippet .= '<link data-optimized="2" rel="stylesheet" href="' . $url . '" />';// use 2 as combined
357
  }
358
 
359
  // Handle css async load
360
  if ( $this->cfg_css_async ) {
361
  // Only ignored html snippet needs async
362
+ $ignored_html_async = $this->_async_css_list( $ignored_html );
363
 
364
+ $snippet = '';
365
  foreach ( $urls as $url ) {
366
  $snippet .= '<link rel="preload" data-asynced="1" data-optimized="2" as="style" onload="this.onload=null;this.rel=\'stylesheet\'" href="' . $url . '" />'; // todo: How to use " in attr wrapper "
367
  }
368
 
369
  // enqueue combined file first
370
  if ( $enqueue_first ) {
371
+ $this->html_head .= $snippet . implode( '', $ignored_html_async );
372
  }
373
  else {
374
+ $this->html_head .= implode( '', $ignored_html_async ) . $snippet;
375
  }
376
 
377
  }
378
  else {
379
  // enqueue combined file first
380
  if ( $enqueue_first ) {
381
+ $this->html_head .= $snippet . implode( '', $ignored_html );
382
  }
383
  else {
384
+ $this->html_head .= implode( '', $ignored_html ) . $snippet;
385
  }
386
  }
387
 
388
  // Move all css to top
389
+ $this->content = str_replace( $html_list, '', $this->content );// todo: need to keep position for certain files
390
 
391
  // Add to HTTP2
392
  foreach ( $urls as $url ) {
393
+ $this->append_http2( $url );
394
  }
395
 
396
  }
397
  // Only minify
398
  elseif ( $this->cfg_css_min ) {
399
  // will handle async css load inside
400
+ $this->_src_queue_handler( $src_queue_list, $html_list );
401
  }
402
  // Only HTTP2 push
403
  else {
404
+ foreach ( $src_queue_list as $src ) {
405
+ if ( ! empty( $src[ 'src' ] ) ) {
406
+ $src = $src[ 'src' ];
407
+ }
408
+ $this->append_http2( $src );
409
  }
410
  }
411
  }
414
  // Handle css lazy load if not handled async loaded yet
415
  if ( $this->cfg_css_async && ! $this->cfg_css_min && ! $this->cfg_css_comb ) {
416
  // async html
417
+ $html_list_async = $this->_async_css_list( $html_list );
418
 
419
  // Replace async css
420
+ $this->content = str_replace( $html_list, $html_list_async, $this->content );
421
 
422
  }
423
 
424
  // Parse js from buffer as needed
425
  if ( $this->cfg_js_min || $this->cfg_js_comb || $this->cfg_http2_js || $this->cfg_js_defer ) {
426
+ list( $src_list, $html_list, $head_src_list ) = $this->_parse_js();
427
  }
428
 
429
  // js optimizer
430
  if ( $this->cfg_js_min || $this->cfg_js_comb || $this->cfg_http2_js ) {
431
 
432
  if ( $src_list ) {
433
+ list( $ignored_html, $src_queue_list, $file_size_list ) = $this->_analyse_links( $src_list, $html_list, 'js' );
434
 
435
  // IF combine
436
  if ( $this->cfg_js_comb ) {
437
+ $enqueue_first = Conf::val( Base::O_OPTM_JS_COMB_PRIO );
438
 
439
  // separate head/foot js/raw html
440
+ $head_js = array();
441
+ $head_ignored_html = array();
442
+ $foot_js = array();
443
+ $foot_ignored_html = array();
444
  foreach ( $src_queue_list as $k => $src ) {
445
  if ( in_array( $src, $head_src_list ) ) {
446
+ $head_js[ $k ] = $src;
447
  }
448
  else {
449
+ $foot_js[ $k ] = $src;
450
  }
451
  }
452
  foreach ( $ignored_html as $src => $html ) {
453
  if ( in_array( $src, $head_src_list ) ) {
454
+ $head_ignored_html[ $src ] = $html;
455
  }
456
  else {
457
+ $foot_ignored_html[] = $html;
458
  }
459
  }
460
 
461
+ $snippet = '';
462
  if ( $head_js ) {
463
+ $urls = $this->_limit_size_build_hash_url( $head_js, $file_size_list, 'js' );
464
  foreach ( $urls as $url ) {
465
+ $snippet .= '<script data-optimized="1" src="' . $url . '" ' . ( $this->cfg_js_defer ? 'defer' : '' ) . '></script>';
466
 
467
  // Add to HTTP2
468
+ $this->append_http2( $url, 'js' );
469
  }
470
  }
471
  if ( $this->cfg_js_defer ) {
472
+ $head_ignored_html = $this->_js_defer( $head_ignored_html );
473
  }
474
 
475
  /**
482
  foreach ( $head_ignored_html as $src => $html ) {
483
  if ( $this->_is_jquery( $src ) ) {
484
  // jQuery should be always the first one
485
+ $this->html_head .= $html;
486
+ unset( $head_ignored_html[ $src ] );
487
+ break;
488
  }
489
  }
490
+ $this->html_head .= $snippet . implode( '', $head_ignored_html );
491
  }
492
  else {
493
+ $this->html_head .= implode( '', $head_ignored_html ) . $snippet;
494
  }
495
 
496
+ $snippet = '';
497
  if ( $foot_js ) {
498
+ $urls = $this->_limit_size_build_hash_url( $foot_js, $file_size_list, 'js' );
499
  foreach ( $urls as $url ) {
500
+ $snippet .= '<script data-optimized="1" src="' . $url . '" ' . ( $this->cfg_js_defer ? 'defer' : '' ) . '></script>';
501
 
502
  // Add to HTTP2
503
+ $this->append_http2( $url, 'js' );
504
  }
505
  }
506
  if ( $this->cfg_js_defer ) {
507
+ $foot_ignored_html = $this->_js_defer( $foot_ignored_html );
508
  }
509
 
510
  // enqueue combined file first
511
  if ( $enqueue_first ) {
512
+ $this->html_foot .= $snippet . implode( '', $foot_ignored_html );
513
  }
514
  else {
515
+ $this->html_foot .= implode( '', $foot_ignored_html ) . $snippet;
516
  }
517
 
518
  // Will move all js to top/bottom
519
+ $this->content = str_replace( $html_list, '', $this->content );
520
 
521
  }
522
  // Only minify
523
  elseif ( $this->cfg_js_min ) {
524
  // Will handle js defer inside
525
+ $this->_src_queue_handler( $src_queue_list, $html_list, 'js' );
526
  }
527
  // Only HTTP2 push
528
  else {
529
  foreach ( $src_queue_list as $val ) {
530
+ $this->append_http2( $val, 'js' );
531
  }
532
  }
533
  }
536
  // Handle js defer if not handled defer yet
537
  if ( $this->cfg_js_defer && ! $this->cfg_js_min && ! $this->cfg_js_comb ) {
538
  // defer html
539
+ $html_list2 = $this->_js_defer( $html_list );
540
 
541
  // Replace async js
542
+ $this->content = str_replace( $html_list, $html_list2, $this->content );
543
  }
544
 
545
 
560
  * Handle google fonts async
561
  * This will result in a JS snippet in head, so need to put it in the end to avoid being replaced by JS parser
562
  */
563
+ $this->_async_ggfonts();
564
 
565
  /**
566
  * Font display optm
567
  * @since 3.0
568
  */
569
+ $this->_font_optm();
570
+
571
+ /**
572
+ * Localize GG/FB JS/Fonts
573
+ * @since 3.3
574
+ */
575
+ $this->content = Localization::get_instance()->finalize( $this->content );
576
 
577
  /**
578
  * Inline script manipulated until document is ready
 
579
  * @since 3.0
580
  */
581
  $this->_js_inline_defer();
582
 
583
+ // Check if there is any critical css rules setting
584
+ if ( $this->cfg_css_async ) {
585
+ $this->html_head = CSS::prepend_ccss( $this->html_head );
586
+ }
587
+
588
  // Replace html head part
589
  $this->html_head = apply_filters( 'litespeed_optm_html_head', $this->html_head );
590
  if ( $this->html_head ) {
626
  return;
627
  }
628
 
629
+ $optm_js_inline_exc = Conf::val( Base::O_OPTM_JS_INLINE_DEFER_EXC );
630
+
631
  Debug2::debug( '[Optm] Inline JS defer ' . $optm_js_inline );
632
 
633
  preg_match_all( '#<script([^>]*)>(.*)</script>#isU', $this->content, $matches, PREG_SET_ORDER );
654
  }
655
  }
656
 
657
+ $con = $match[ 2 ];
658
+
659
+ if ( $optm_js_inline_exc ) {
660
+ $hit = Utility::str_hit_array( $con, $optm_js_inline_exc );
661
+ if ( $hit ) {
662
+ Debug2::debug2( '[Optm] inline js defer excluded [setting] ' . $hit );
663
+ continue;
664
+ }
665
+ }
666
+
667
+ $con = trim( $con );
668
+ // Minify JS first
669
+ $con = Optimizer::minify_js( $con );
670
+
671
  if ( ! $con ) {
672
  continue;
673
  }
720
  * @since 2.7.3
721
  * @access private
722
  */
723
+ private function _async_ggfonts() {
 
724
  if ( ! $this->cfg_ggfonts_async || ! $this->_ggfonts_urls ) {
725
+ return;
726
  }
727
 
728
+ Debug2::debug2( '[Optm] google fonts async found: ', $this->_ggfonts_urls );
729
 
730
+ $html = '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />';
731
 
732
  /**
733
  * Append fonts
739
  * -> family: PT Sans:400,700|PT Sans Narrow:400|Montserrat:600
740
  * <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' />
741
  */
742
+ $html .='<script>WebFontConfig={google:{families:[';
743
 
744
+ $families = array();
745
  foreach ( $this->_ggfonts_urls as $v ) {
746
+ $qs = wp_specialchars_decode( $v );
747
+ $qs = urldecode( $qs );
748
+ $qs = parse_url( $qs, PHP_URL_QUERY );
749
+ parse_str( $qs, $qs );
750
 
751
  if ( empty( $qs[ 'family' ] ) ) {
752
+ Debug2::debug( '[Optm] ERR ggfonts failed to find family: ' . $v );
753
+ continue;
754
  }
755
 
756
+ $subset = empty( $qs[ 'subset' ] ) ? '' : ':' . $qs[ 'subset' ];
757
 
758
  foreach ( array_filter( explode( '|', $qs[ 'family' ] ) ) as $v2 ) {
759
+ $families[] = $v2 . $subset;
760
  }
761
 
762
  }
768
  // if webfontloader lib was loaded before WebFontConfig variable, call WebFont.load
769
  $html .= 'if ( typeof WebFont === "object" && typeof WebFont.load === "function" ) { WebFont.load( WebFontConfig ); }';
770
 
771
+ $html .= '</script>';
772
 
773
  // https://cdnjs.cloudflare.com/ajax/libs/webfont/1.6.28/webfontloader.js
774
+ $webfont_lib_url = LSWCP_PLUGIN_URL . self::LIB_FILE_WEBFONTLOADER;
775
 
776
  // default async, if js defer set use defer
777
  // TODO: make defer optional
778
+ $html .= '<script id="litespeed-webfont-lib" src="' . $webfont_lib_url . '" ' . ( $this->cfg_js_defer ? 'defer' : 'async' ) . '></script>';
779
+ $this->append_http2( $webfont_lib_url, 'js' ); // async lib will be http/2 pushed always
780
 
781
  // Put this in the very beginning for preconnect
782
+ $this->html_head = $html . $this->html_head;
783
  }
784
 
785
  /**
788
  * @since 3.0
789
  * @access private
790
  */
791
+ private function _font_optm() {
 
792
  if ( ! $this->_conf_css_font_display || ! $this->_ggfonts_urls ) {
793
+ return;
794
  }
795
 
796
+ Debug2::debug2( '[Optm] google fonts optm ', $this->_ggfonts_urls );
797
 
798
  foreach ( $this->_ggfonts_urls as $v ) {
799
  if ( strpos( $v, 'display=' ) ) {
800
+ continue;
801
  }
802
+ $this->html_head = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->html_head );
803
+ $this->html_foot = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->html_foot );
804
+ $this->content = str_replace( $v, $v . '&#038;display=' . $this->_conf_css_font_display, $this->content );
805
  }
806
  }
807
 
811
  * @since 1.7.1
812
  * @access private
813
  */
814
+ private function _dns_prefetch_init() {
 
815
  // Widely enable link DNS prefetch
816
  if ( Conf::val( Base::O_OPTM_DNS_PREFETCH_CTRL ) ) {
817
  add_filter( 'litespeed_optm_html_head', array( $this, 'dns_prefetch_xmeta' ), 999 );
818
  }
819
 
820
+ $this->dns_prefetch = Conf::val( Base::O_OPTM_DNS_PREFETCH );
821
  if ( ! $this->dns_prefetch ) {
822
+ return;
823
  }
824
 
825
  if ( function_exists( 'wp_resource_hints' ) ) {
826
+ add_filter( 'wp_resource_hints', array( $this, 'dns_prefetch_filter' ), 10, 2 );
827
  }
828
  else {
829
+ add_action( 'litespeed_optm', array( $this, 'dns_prefetch_output' ) );
830
  }
831
  }
832
 
836
  * @since 3.0
837
  * @access public
838
  */
839
+ public function dns_prefetch_xmeta( $content ) {
 
840
  $content .= '<meta http-equiv="x-dns-prefetch-control" content="on">';
841
  return $content;
842
  }
847
  * @since 1.7.1
848
  * @access public
849
  */
850
+ public function dns_prefetch_filter( $urls, $relation_type ) {
 
851
  if ( $relation_type !== 'dns-prefetch' ) {
852
+ return $urls;
853
  }
854
 
855
  foreach ( $this->dns_prefetch as $v ) {
856
  if ( $v ) {
857
+ $urls[] = $v;
858
  }
859
  }
860
 
861
+ return $urls;
862
  }
863
 
864
  /**
867
  * @since 1.7.1
868
  * @access public
869
  */
870
+ public function dns_prefetch_output() {
 
871
  foreach ( $this->dns_prefetch as $v ) {
872
  if ( $v ) {
873
  $this->html_head .= '<link rel="dns-prefetch" href="' . $v . '" />';
886
  $i = 0;
887
  $src_arr = array();
888
  $url_sensitive = Conf::val( Base::O_OPTM_CSS_UNIQUE ) && $file_type == 'css'; // If need to keep unique CSS per URI
889
+ foreach ( $src_queue_list as $k => $src ) {
 
890
  empty( $src_arr[ $i ] ) && $src_arr[ $i ] = array();
891
 
892
+ $src_arr[ $i ][] = $src;
893
 
894
  $total += $file_size_list[ $k ];
895
 
904
 
905
  // group build
906
  $hashed_arr = array();
907
+ foreach ( $src_arr as $src_list ) {
908
+ $hashed_arr[] = $this->_build_hash_url( $src_list, $file_type, $url_sensitive );
909
  }
910
 
911
  return $hashed_arr;
917
  * @since 1.2.2
918
  * @access private
919
  */
920
+ private function _src_queue_handler( $src_queue_list, $html_list, $file_type = 'css' ) {
921
+ $html_list_ori = $html_list;
 
922
 
923
+ $tag = $file_type === 'css' ? 'link' : 'script';
924
  foreach ( $src_queue_list as $key => $src ) {
925
+ if ( ! empty( $src[ 'src' ] ) ) {
926
+ $src = $src[ 'src' ];
927
+ }
928
+ $url = $this->_build_hash_url( $src, $file_type );
929
+ $snippet = str_replace( $src, $url, $html_list[ $key ] );
930
+ $snippet = str_replace( "<$tag ", '<' . $tag . ' data-optimized="1" ', $snippet );
931
 
932
+ $html_list[ $key ] = $snippet;
933
 
934
  // Add to HTTP2
935
+ $this->append_http2( $url, $file_type );
936
  }
937
 
938
  // Handle css async load
939
  if ( $file_type === 'css' && $this->cfg_css_async ) {
940
+ $html_list = $this->_async_css_list( $html_list );
941
  }
942
 
943
  // Handle js defer
944
  if ( $file_type === 'js' && $this->cfg_js_defer ) {
945
+ $html_list = $this->_js_defer( $html_list );
946
  }
947
 
948
+ $this->content = str_replace( $html_list_ori, $html_list, $this->content );
949
  }
950
 
951
  /**
955
  * @access private
956
  * @return array Array(Ignored raw html, src needed to be handled list, filesize for param 2nd )
957
  */
958
+ private function _analyse_links( $src_list, $html_list, $file_type = 'css' ) {
 
959
  // if ( $file_type == 'css' ) {
960
+ // $excludes = apply_filters( 'litespeed_optimize_css_excludes', Conf::val( Base::O_OPTM_CSS_EXC ) );
961
  // }
962
  // else {
963
+ // $excludes = apply_filters( 'litespeed_optimize_js_excludes', Conf::val( Base::O_OPTM_JS_EXC ) );
964
  // }
965
  // if ( $excludes ) {
966
+ // $excludes = explode( "\n", $excludes );
967
  // }
968
 
969
+ $ignored_html = array();
970
+ $src_queue_list = array();
971
+ $file_size_list = array();
972
 
973
  // Analyse links
974
+ foreach ( $src_list as $key => $src_info ) {
975
+ // CSS has different format when having media='' conditional attribute
976
+ if ( ! empty( $src_info[ 'src' ] ) ) {
977
+ $src = $src_info[ 'src' ];
978
+ }
979
+ else {
980
+ $src = $src_info;
981
+ }
982
+
983
+ Debug2::debug2( '[Optm] ' . $src );
984
 
985
  /**
986
  * Excluded links won't be done any optm
987
  * @since 1.7
988
  */
989
  // if ( $excludes && $exclude = Utility::str_hit_array( $src, $excludes ) ) {
990
+ // $ignored_html[] = $html_list[ $key ];
991
+ // Debug2::debug2( '[Optm]: Abort excludes: ' . $exclude );
992
+ // continue;
993
  // }
994
 
995
  // Check if has no-optimize attr
996
  if ( strpos( $html_list[ $key ], 'data-ignore-optimize' ) !== false ) {
997
+ $ignored_html[] = $html_list[ $key ];
998
+ Debug2::debug2( '[Optm] Abort excludes: attr data-ignore-optimize' );
999
+ continue;
1000
  }
1001
 
1002
  // Check if is external URL
1003
+ $url_parsed = parse_url( $src );
1004
  if ( ! $file_info = Utility::is_internal_file( $src ) ) {
1005
+ $ignored_html[ $src ] = $html_list[ $key ];
1006
+ Debug2::debug2( '[Optm] Abort external/non-exist' );
1007
+ continue;
1008
  }
1009
 
1010
  /**
1013
  * @since 1.5
1014
  */
1015
  if ( $this->cfg_exc_jquery && $this->_is_jquery( $src ) ) {
1016
+ $ignored_html[ $src ] = $html_list[ $key ];
1017
+ Debug2::debug2( '[Optm] Abort jQuery by setting' );
1018
 
1019
  // Add to HTTP2 as its ignored but still internal src
1020
+ $this->append_http2( $src, 'js' );
1021
 
1022
+ continue;
1023
  }
1024
 
1025
+ // Note: some CSS may have different format
1026
+ $src_queue_list[ $key ] = $src_info;
1027
+
1028
+ $file_size_list[ $key ] = $file_info[ 1 ];
1029
  }
1030
 
1031
+ return array( $ignored_html, $src_queue_list, $file_size_list );
1032
  }
1033
 
1034
  /**
1050
  $src = array( $src );
1051
  }
1052
 
1053
+ // Query string hash
1054
+ $qs_hash = substr( md5( json_encode( $src ) . self::get_option( self::ITEM_TIMESTAMP_PURGE_CSS ) ), -5 );
1055
 
1056
  // Drop query strings
1057
+ foreach ( $src as $k => $v ) {
1058
+ if ( ! empty( $v[ 'src' ] ) ) {
1059
+ $src[ $k ][ 'src' ] = $this->remove_query_strings( $v[ 'src' ] ); // CSS w/ cond `media=`
1060
+ }
1061
+ else {
1062
+ $src[ $k ] = $this->remove_query_strings( $v );
1063
+ }
1064
+ }
1065
 
1066
+ // $src = array_values( $src );
1067
+ $hash = md5( json_encode( $src ) );
1068
+ $filename = substr( $hash, -5 ) . '.' . $file_type;
1069
 
1070
  // Need to check conflicts
1071
  // If short hash exists
1082
 
1083
  // Need to insert the record
1084
  if ( ! $existed ) {
1085
+ Data::get_instance()->optm_save_src( $filename, $src, $request_url );
1086
  }
1087
 
1088
  // Generate static files
1100
 
1101
  }
1102
 
1103
+ return LITESPEED_STATIC_URL . '/cssjs/' . $filename . '?' . $qs_hash;
1104
  }
1105
 
1106
  /**
1110
  * @access private
1111
  * @return array All the src & related raw html list
1112
  */
1113
+ private function _parse_js() {
1114
+ $excludes = apply_filters( 'litespeed_optimize_js_excludes', Conf::val( Base::O_OPTM_JS_EXC ) );
 
1115
 
1116
+ $src_list = array();
1117
+ $html_list = array();
1118
+ $head_src_list = array();
1119
 
1120
+ $content = preg_replace( '#<!--.*-->#sU', '', $this->content );
1121
+ preg_match_all( '#<script ([^>]+)>\s*</script>|</head>#isU', $content, $matches, PREG_SET_ORDER ); // v3.3 Changed `<script \s*(` to `<script (`
1122
+ $is_head = true;
1123
  foreach ( $matches as $match ) {
1124
  if ( $match[ 0 ] === '</head>' ) {
1125
+ $is_head = false;
1126
+ continue;
1127
  }
1128
+ $attrs = Utility::parse_attr( $match[ 1 ] );
1129
 
1130
  if ( isset( $attrs[ 'data-optimized' ] ) ) {
1131
+ continue;
1132
  }
1133
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
1134
+ continue;
1135
  }
1136
  if ( empty( $attrs[ 'src' ] ) ) {
1137
+ continue;
1138
  }
1139
 
1140
+ if ( strpos( $attrs[ 'src' ], '/localres/' ) !== false ) {
1141
+ continue;
1142
+ }
1143
+
1144
+ $url_parsed = parse_url( $attrs[ 'src' ], PHP_URL_PATH );
1145
  if ( substr( $url_parsed, -3 ) !== '.js' ) {
1146
+ Debug2::debug2( '[Optm] _parse_js bypassed due to not js file ' . $url_parsed );
1147
+ continue;
1148
  }
1149
 
1150
  // to avoid multiple replacement
1151
  if ( in_array( $match[ 0 ], $html_list ) ) {
1152
+ continue;
1153
  }
1154
  // todo @v2.0: allow defer even exclude from optm
1155
  if ( $excludes && $exclude = Utility::str_hit_array( $attrs[ 'src' ], $excludes ) ) {
1156
+ Debug2::debug2( '[Optm] _parse_js bypassed exclude ' . $exclude );
1157
+ continue;
1158
  }
1159
 
1160
+ $src_list[] = $attrs[ 'src' ];
1161
+ $html_list[] = $match[ 0 ];
1162
 
1163
  if ( $is_head ) {
1164
+ $head_src_list[] = $attrs[ 'src' ];
1165
  }
1166
  }
1167
 
1168
+ return array( $src_list, $html_list, $head_src_list );
1169
  }
1170
 
1171
  /**
1175
  * @access private
1176
  * @return array All the src & related raw html list
1177
  */
1178
+ private function _handle_css() {
1179
+ $excludes = apply_filters( 'litespeed_optimize_css_excludes', Conf::val( Base::O_OPTM_CSS_EXC ) );
 
1180
 
1181
+ $css_to_be_removed = apply_filters( 'litespeed_optm_css_to_be_removed', array() );
1182
 
1183
+ $src_list = array();
1184
+ $html_list = array();
1185
 
1186
+ // $dom = new \PHPHtmlParser\Dom;
1187
+ // $dom->load( $content );return $val;
1188
+ // $items = $dom->find( 'link' );
1189
 
1190
+ $content = preg_replace( '#<!--.*-->#sU', '', $this->content );
1191
+ preg_match_all( '#<link ([^>]+)/?>#isU', $content, $matches, PREG_SET_ORDER ); // Changed in v3.3 `<link \s*` to `<link ` and see if css can parse w/o issue
1192
  foreach ( $matches as $match ) {
1193
+ $attrs = Utility::parse_attr( $match[ 1 ] );
1194
 
1195
  if ( empty( $attrs[ 'rel' ] ) || $attrs[ 'rel' ] !== 'stylesheet' ) {
1196
+ continue;
1197
  }
1198
  if ( isset( $attrs[ 'data-optimized' ] ) ) {
1199
+ continue;
1200
  }
1201
  if ( ! empty( $attrs[ 'data-no-optimize' ] ) ) {
1202
+ continue;
1203
  }
1204
  if ( ! empty( $attrs[ 'media' ] ) && strpos( $attrs[ 'media' ], 'print' ) !== false ) {
1205
+ // continue;
1206
  }
1207
  if ( empty( $attrs[ 'href' ] ) ) {
1208
+ continue;
1209
  }
1210
 
1211
  if ( $excludes && $exclude = Utility::str_hit_array( $attrs[ 'href' ], $excludes ) ) {
1212
+ Debug2::debug2( '[Optm] _handle_css bypassed exclude ' . $exclude );
1213
+ continue;
1214
  }
1215
 
1216
  // Check if need to remove this css
1217
  if ( $css_to_be_removed && Utility::str_hit_array( $attrs[ 'href' ], $css_to_be_removed ) ) {
1218
+ Debug2::debug( '[Optm] rm css snippet ' . $attrs[ 'href' ] );
1219
  // Delete this css snippet from orig html
1220
+ $this->content = str_replace( $match[ 0 ], '', $this->content );
1221
 
1222
+ continue;
1223
  }
1224
 
1225
  // Check Google fonts hit
1230
  * @since 3.0 For fotn display optm, need to parse google fonts URL too
1231
  */
1232
  if ( ! in_array( $attrs[ 'href' ], $this->_ggfonts_urls ) ) {
1233
+ $this->_ggfonts_urls[] = $attrs[ 'href' ];
1234
  }
1235
 
1236
  if ( $this->cfg_ggfonts_rm || $this->cfg_ggfonts_async ) {
1237
+ Debug2::debug2( '[Optm] rm css snippet [Google fonts] ' . $attrs[ 'href' ] );
1238
+ $this->content = str_replace( $match[ 0 ], '', $this->content );
1239
 
1240
+ continue;
1241
  }
1242
  }
1243
 
1244
  // to avoid multiple replacement
1245
  if ( in_array( $match[ 0 ], $html_list ) ) {
1246
+ continue;
1247
+ }
1248
+
1249
+ if ( ! empty( $attrs[ 'media' ] ) && $attrs[ 'media' ] !== 'all' ) {
1250
+ $src_list[] = array(
1251
+ 'src' => $attrs[ 'href' ],
1252
+ 'media' => $attrs[ 'media' ],
1253
+ );
1254
+ }
1255
+ else {
1256
+ $src_list[] = $attrs[ 'href' ];
1257
  }
1258
 
1259
+ $html_list[] = $match[ 0 ];
 
1260
  }
1261
 
1262
+ return array( $src_list, $html_list );
1263
  }
1264
 
1265
  /**
1270
  * @param array $html_list Orignal css array
1271
  * @return array (array)css_async_list
1272
  */
1273
+ private function _async_css_list( $html_list ) {
 
1274
  foreach ( $html_list as $k => $ori ) {
1275
  if ( strpos( $ori, 'data-asynced' ) !== false ) {
1276
+ Debug2::debug2( '[Optm] bypass: attr data-asynced exist' );
1277
+ continue;
1278
  }
1279
 
1280
  if ( strpos( $ori, 'data-no-async' ) !== false ) {
1281
+ Debug2::debug2( '[Optm] bypass: attr api data-no-async' );
1282
+ continue;
1283
  }
1284
 
1285
  // async replacement
1286
+ $v = str_replace( 'stylesheet', 'preload', $ori );
1287
  $v = str_replace( '<link', '<link data-asynced="1" as="style" onload="this.onload=null;this.rel=\'stylesheet\'" ', $v );
1288
  // Append to noscript content
1289
+ $v .= '<noscript>' . $ori . '</noscript>';
1290
+ $html_list[ $k ] = $v;
1291
  }
1292
+ return $html_list;
1293
  }
1294
 
1295
  /**
1298
  * @since 1.3
1299
  * @access private
1300
  */
1301
+ private function _js_defer( $html_list ) {
 
1302
  foreach ( $html_list as $k => $v ) {
1303
  if ( strpos( $v, 'async' ) !== false ) {
1304
+ continue;
1305
  }
1306
  if ( strpos( $v, 'defer' ) !== false ) {
1307
+ continue;
1308
  }
1309
  if ( strpos( $v, 'data-deferred' ) !== false ) {
1310
+ Debug2::debug2( '[Optm] bypass: attr data-deferred exist' );
1311
+ continue;
1312
  }
1313
  if ( strpos( $v, 'data-no-defer' ) !== false ) {
1314
+ Debug2::debug2( '[Optm] bypass: attr api data-no-defer' );
1315
+ continue;
1316
  }
1317
 
1318
  /**
1321
  */
1322
  if ( $this->cfg_js_defer_exc || $this->cfg_exc_jquery ) {
1323
  // parse js src
1324
+ preg_match( '#<script \s*([^>]+)>#isU', $v, $matches );
1325
  if ( empty( $matches[ 1 ] ) ) {
1326
+ Debug2::debug( '[Optm] js defer parse html failed: ' . $v );
1327
+ continue;
1328
  }
1329
 
1330
+ $attrs = Utility::parse_attr( $matches[ 1 ] );
1331
 
1332
  if ( empty( $attrs[ 'src' ] ) ) {
1333
+ Debug2::debug( '[Optm] js defer parse src failed: ' . $matches[ 1 ] );
1334
+ continue;
1335
  }
1336
 
1337
+ $src = $attrs[ 'src' ];
1338
  }
1339
 
1340
  /**
1342
  * @since 1.5
1343
  */
1344
  if ( $this->cfg_js_defer_exc && Utility::str_hit_array( $src, $this->cfg_js_defer_exc ) ) {
1345
+ Debug2::debug( '[Optm] js defer exclude ' . $src );
1346
+ continue;
1347
  }
1348
 
1349
  /**
1351
  * @since 1.5
1352
  */
1353
  if ( $this->cfg_exc_jquery && $this->_is_jquery( $src ) ) {
1354
+ Debug2::debug2( '[Optm] js defer Abort jQuery by setting' );
1355
+ continue;
1356
  }
1357
 
1358
+ $html_list[ $k ] = str_replace( '></script>', ' defer data-deferred="1"></script>', $v );
1359
  }
1360
 
1361
+ return $html_list;
1362
  }
1363
 
1364
  /**
1367
  * @since 1.5
1368
  * @access private
1369
  */
1370
+ private function _is_jquery( $src ) {
1371
+ return stripos( $src, 'jquery.js' ) !== false || stripos( $src, 'jquery.min.js' ) !== false;
 
1372
  }
1373
 
1374
  /**
1377
  * @since 1.2.2
1378
  * @access private
1379
  */
1380
+ private function append_http2( $url, $file_type = 'css' ) {
 
1381
  if ( ! ( $file_type === 'css' ? $this->cfg_http2_css : $this->cfg_http2_js ) ) {
1382
+ return;
1383
  }
1384
 
1385
  /**
1387
  * @since 1.6.2.1
1388
  */
1389
  if ( CDN::inc_type( $file_type ) ) {
1390
+ return;
1391
  }
1392
 
1393
  /**
1394
  * Keep QS for constance by set 2nd param to true
1395
  * @since 1.6.2.1
1396
  */
1397
+ $uri = Utility::url2uri( $url, true );
1398
 
1399
  if ( ! $uri ) {
1400
+ return;
1401
  }
1402
 
1403
+ $this->http2_headers[] = '<' . $uri . '>; rel=preload; as=' . ( $file_type === 'css' ? 'style' : 'script' );
1404
  }
1405
 
1406
  }
src/optimizer.cls.php CHANGED
@@ -7,15 +7,14 @@
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
- namespace LiteSpeed ;
11
 
12
- defined( 'WPINC' ) || exit ;
13
 
14
- class Optimizer extends Instance
15
- {
16
- protected static $_instance ;
17
 
18
- private $_conf_css_font_display ;
19
 
20
  /**
21
  * Init optimizer
@@ -23,11 +22,10 @@ class Optimizer extends Instance
23
  * @since 1.9
24
  * @access protected
25
  */
26
- protected function __construct()
27
- {
28
- $this->_conf_css_font_display = Conf::val( Base::O_OPTM_CSS_FONT_DISPLAY ) ;
29
  if ( ! empty( Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ) ) {
30
- $this->_conf_css_font_display = Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ;
31
  }
32
  }
33
 
@@ -37,15 +35,14 @@ class Optimizer extends Instance
37
  * @since 1.9
38
  * @access public
39
  */
40
- public function html_min( $content )
41
- {
42
- $options = array() ;
43
- if ( Conf::val( Base::O_OPTM_CSS_INLINE_MIN ) ) {
44
- $options[ 'cssMinifier' ] = __CLASS__ . '::minify_css' ;
45
  }
46
 
47
- if ( Conf::val( Base::O_OPTM_JS_INLINE_MIN ) ) {
48
- $options[ 'jsMinifier' ] = __CLASS__ . '::minify_js' ;
49
  }
50
 
51
  /**
@@ -53,17 +50,17 @@ class Optimizer extends Instance
53
  * @since 2.2.3
54
  */
55
  try {
56
- $obj = new Lib\HTML_MIN( $content, $options ) ;
57
- $content_final = $obj->process() ;
58
  if ( ! defined( 'LSCACHE_ESI_SILENCE' ) ) {
59
- $content_final .= "\n" . '<!-- Page optimized by LiteSpeed Cache @' . date('Y-m-d H:i:s') . ' -->' ;
60
  }
61
- return $content_final ;
62
 
63
  } catch ( \Exception $e ) {
64
- Debug2::debug( '******[Optmer] html_min failed: ' . $e->getMessage() ) ;
65
- error_log( '****** LiteSpeed Optimizer html_min failed: ' . $e->getMessage() ) ;
66
- return $content ;
67
  }
68
  }
69
 
@@ -104,57 +101,67 @@ class Optimizer extends Instance
104
  }
105
 
106
  // Parse real file path
107
- $real_files = array() ;
108
- foreach ( $src_list as $url ) {
109
- $real_file = Utility::is_internal_file( $url ) ;
 
110
  if ( ! $real_file ) {
111
- continue ;
 
 
 
 
 
 
 
 
 
 
112
  }
113
- $real_files[] = $real_file[ 0 ] ;
114
  }
115
 
116
  if ( ! $real_files ) {
117
  return false;
118
  }
119
 
120
- Debug2::debug2( '[Optmer] src_list : ', $src_list ) ;
121
 
122
- // set_error_handler( 'litespeed_exception_handler' ) ;
123
 
124
- $content = '' ;
125
  // try {
126
  // Handle CSS
127
  if ( $file_type === 'css' ) {
128
- $content = $this->_serve_css( $real_files, $concat_only ) ;
129
  }
130
  // Handle JS
131
  else {
132
- $content = $this->_serve_js( $real_files, $concat_only ) ;
133
  }
134
 
135
  // } catch ( \Exception $e ) {
136
- // $tmp = '[url] ' . implode( ', ', $src_list ) . ' [err] ' . $e->getMessage() ;
137
 
138
- // Debug2::debug( '******[Optmer] serve err ' . $tmp ) ;
139
- // error_log( '****** LiteSpeed Optimizer serve err ' . $tmp ) ;
140
- // return false ;//todo: return ori data
141
  // }
142
- // restore_error_handler() ;
143
 
144
  /**
145
  * Clean comment when minify
146
  * @since 1.7.1
147
  */
148
  if ( Conf::val( Base::O_OPTM_RM_COMMENT ) ) {
149
- $content = $this->_remove_comment( $content, $file_type ) ;
150
  }
151
 
152
- Debug2::debug2( '[Optmer] Generated content ' . $file_type ) ;
153
 
154
  // Add filter
155
- $content = apply_filters( 'litespeed_optm_cssjs', $content, $file_type, $src_list ) ;
156
 
157
- return $content ;
158
  }
159
 
160
  /**
@@ -163,30 +170,41 @@ class Optimizer extends Instance
163
  * @since 1.9
164
  * @access private
165
  */
166
- private function _serve_css( $files, $concat_only = false )
167
- {
168
- $con = array() ;
169
- foreach ( $files as $real_path ) {
170
- Debug2::debug2( '[Optmer] [real_path] ' . $real_path ) ;
171
- $data = File::read( $real_path ) ;
 
 
 
 
 
 
 
172
 
173
  // Font optimize
174
  if ( $this->_conf_css_font_display ) {
175
- $data = preg_replace( '#(@font\-face\s*\{)#isU', '${1}font-display:' . $this->_conf_css_font_display . ';', $data ) ;
176
  }
177
 
178
- $data = preg_replace( '/@charset[^;]+;\\s*/', '', $data ) ;
179
 
180
  if ( ! $concat_only && ! $this->_is_min( $real_path ) ) {
181
- $data = self::minify_css( $data ) ;
182
  }
183
 
184
- $data = Lib\CSS_MIN\UriRewriter::rewrite( $data, dirname( $real_path ) ) ;
 
 
 
 
185
 
186
- $con[] = $data ;
187
  }
188
 
189
- return implode( '', $con ) ;
190
  }
191
 
192
  /**
@@ -195,23 +213,22 @@ class Optimizer extends Instance
195
  * @since 1.9
196
  * @access private
197
  */
198
- private function _serve_js( $files, $concat_only )
199
- {
200
- $con = array() ;
201
  foreach ( $files as $real_path ) {
202
- $data = File::read( $real_path ) ;
203
 
204
  if ( ! $concat_only && ! $this->_is_min( $real_path ) ) {
205
- $data = self::minify_js( $data ) ;
206
  }
207
  else {
208
- $data = $this->_null_minifier( $data ) ;
209
  }
210
 
211
- $con[] = $data ;
212
  }
213
 
214
- return implode( "\n;", $con ) ;
215
  }
216
 
217
  /**
@@ -220,16 +237,15 @@ class Optimizer extends Instance
220
  * @since 2.2.3
221
  * @access private
222
  */
223
- public static function minify_css( $data )
224
- {
225
  try {
226
- $obj = new Lib\CSS_MIN\Minifier() ;
227
- return $obj->run( $data ) ;
228
 
229
  } catch ( \Exception $e ) {
230
- Debug2::debug( '******[Optmer] minify_css failed: ' . $e->getMessage() ) ;
231
- error_log( '****** LiteSpeed Optimizer minify_css failed: ' . $e->getMessage() ) ;
232
- return $data ;
233
  }
234
  }
235
 
@@ -241,24 +257,23 @@ class Optimizer extends Instance
241
  * @since 2.2.3
242
  * @access private
243
  */
244
- public static function minify_js( $data, $js_type = '' )
245
- {
246
  // For inline JS optimize, need to check if it's js type
247
  if ( $js_type ) {
248
- preg_match( '#type=([\'"])(.+)\g{1}#isU', $js_type, $matches ) ;
249
  if ( $matches && $matches[ 2 ] != 'text/javascript' ) {
250
- Debug2::debug( '******[Optmer] minify_js bypass due to type: ' . $matches[ 2 ] ) ;
251
- return $data ;
252
  }
253
  }
254
 
255
  try {
256
- $data = Lib\JSMin::minify( $data ) ;
257
- return $data ;
258
  } catch ( \Exception $e ) {
259
- Debug2::debug( '******[Optmer] minify_js failed: ' . $e->getMessage() ) ;
260
- // error_log( '****** LiteSpeed Optimizer minify_js failed: ' . $e->getMessage() ) ;
261
- return $data ;
262
  }
263
  }
264
 
@@ -267,11 +282,10 @@ class Optimizer extends Instance
267
  *
268
  * @access private
269
  */
270
- private function _null_minifier( $content )
271
- {
272
- $content = str_replace( "\r\n", "\n", $content ) ;
273
 
274
- return trim( $content ) ;
275
  }
276
 
277
  /**
@@ -280,14 +294,13 @@ class Optimizer extends Instance
280
  * @since 1.9
281
  * @access private
282
  */
283
- private function _is_min( $filename )
284
- {
285
- $basename = basename( $filename ) ;
286
  if ( preg_match( '|[-\.]min\.(?:[a-zA-Z]+)$|i', $basename ) ) {
287
- return true ;
288
  }
289
 
290
- return false ;
291
  }
292
 
293
  /**
@@ -297,8 +310,7 @@ class Optimizer extends Instance
297
  * @since 1.9 Moved here from optiize.cls
298
  * @access private
299
  */
300
- private function _remove_comment( $content, $type )
301
- {
302
  $_from = array(
303
  '|\/\*.*\*\/|U',
304
  '|\/\*.*\*\/|sU',
@@ -306,7 +318,7 @@ class Optimizer extends Instance
306
  // "|;+\n*;+|",
307
  // "|\n+;|",
308
  // "|;\n+|"
309
- ) ;
310
 
311
  $_to = array(
312
  '',
@@ -315,15 +327,15 @@ class Optimizer extends Instance
315
  // ';',
316
  // ';',
317
  // ';',
318
- ) ;
319
 
320
- $content = preg_replace( $_from, $_to, $content ) ;
321
  if ( $type == 'css' ) {
322
- $content = preg_replace( "|: *|", ':', $content ) ;
323
- $content = preg_replace( "| */ *|", '/', $content ) ;
324
  }
325
- $content = trim( $content ) ;
326
- return $content ;
327
  }
328
  }
329
 
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
+ namespace LiteSpeed;
11
 
12
+ defined( 'WPINC' ) || exit;
13
 
14
+ class Optimizer extends Instance {
15
+ protected static $_instance;
 
16
 
17
+ private $_conf_css_font_display;
18
 
19
  /**
20
  * Init optimizer
22
  * @since 1.9
23
  * @access protected
24
  */
25
+ protected function __construct() {
26
+ $this->_conf_css_font_display = Conf::val( Base::O_OPTM_CSS_FONT_DISPLAY );
 
27
  if ( ! empty( Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ] ) ) {
28
+ $this->_conf_css_font_display = Base::$CSS_FONT_DISPLAY_SET[ $this->_conf_css_font_display ];
29
  }
30
  }
31
 
35
  * @since 1.9
36
  * @access public
37
  */
38
+ public function html_min( $content, $force_inline_minify = false ) {
39
+ $options = array();
40
+ if ( Conf::val( Base::O_OPTM_CSS_INLINE_MIN ) || $force_inline_minify ) {
41
+ $options[ 'cssMinifier' ] = __CLASS__ . '::minify_css';
 
42
  }
43
 
44
+ if ( Conf::val( Base::O_OPTM_JS_INLINE_MIN ) || $force_inline_minify ) {
45
+ $options[ 'jsMinifier' ] = __CLASS__ . '::minify_js';
46
  }
47
 
48
  /**
50
  * @since 2.2.3
51
  */
52
  try {
53
+ $obj = new Lib\HTML_MIN( $content, $options );
54
+ $content_final = $obj->process();
55
  if ( ! defined( 'LSCACHE_ESI_SILENCE' ) ) {
56
+ $content_final .= "\n" . '<!-- Page optimized by LiteSpeed Cache @' . date('Y-m-d H:i:s') . ' -->';
57
  }
58
+ return $content_final;
59
 
60
  } catch ( \Exception $e ) {
61
+ Debug2::debug( '******[Optmer] html_min failed: ' . $e->getMessage() );
62
+ error_log( '****** LiteSpeed Optimizer html_min failed: ' . $e->getMessage() );
63
+ return $content;
64
  }
65
  }
66
 
101
  }
102
 
103
  // Parse real file path
104
+ $real_files = array();
105
+ foreach ( $src_list as $src_info ) {
106
+ $real_file = Utility::is_internal_file( ! empty( $src_info[ 'src' ] ) ? $src_info[ 'src' ] : $src_info );
107
+
108
  if ( ! $real_file ) {
109
+ continue;
110
+ }
111
+
112
+ if ( ! empty( $src_info[ 'media' ] ) ) {
113
+ $real_files[] = array(
114
+ 'src' => $real_file[ 0 ],
115
+ 'media' => $src_info[ 'media' ],
116
+ );
117
+ }
118
+ else {
119
+ $real_files[] = $real_file[ 0 ];
120
  }
 
121
  }
122
 
123
  if ( ! $real_files ) {
124
  return false;
125
  }
126
 
127
+ Debug2::debug2( '[Optmer] src_list : ', $src_list );
128
 
129
+ // set_error_handler( 'litespeed_exception_handler' );
130
 
131
+ $content = '';
132
  // try {
133
  // Handle CSS
134
  if ( $file_type === 'css' ) {
135
+ $content = $this->_serve_css( $real_files, $concat_only );
136
  }
137
  // Handle JS
138
  else {
139
+ $content = $this->_serve_js( $real_files, $concat_only );
140
  }
141
 
142
  // } catch ( \Exception $e ) {
143
+ // $tmp = '[url] ' . implode( ', ', $src_list ) . ' [err] ' . $e->getMessage();
144
 
145
+ // Debug2::debug( '******[Optmer] serve err ' . $tmp );
146
+ // error_log( '****** LiteSpeed Optimizer serve err ' . $tmp );
147
+ // return false;//todo: return ori data
148
  // }
149
+ // restore_error_handler();
150
 
151
  /**
152
  * Clean comment when minify
153
  * @since 1.7.1
154
  */
155
  if ( Conf::val( Base::O_OPTM_RM_COMMENT ) ) {
156
+ $content = $this->_remove_comment( $content, $file_type );
157
  }
158
 
159
+ Debug2::debug2( '[Optmer] Generated content ' . $file_type );
160
 
161
  // Add filter
162
+ $content = apply_filters( 'litespeed_optm_cssjs', $content, $file_type, $src_list );
163
 
164
+ return $content;
165
  }
166
 
167
  /**
170
  * @since 1.9
171
  * @access private
172
  */
173
+ private function _serve_css( $files, $concat_only = false ) {
174
+ $con = array();
175
+ foreach ( $files as $path_info ) {
176
+ $media = false;
177
+ if ( ! empty( $path_info[ 'src' ] ) ) {
178
+ $real_path = $path_info[ 'src' ];
179
+ $media = $path_info[ 'media' ];
180
+ }
181
+ else {
182
+ $real_path = $path_info;
183
+ }
184
+ Debug2::debug2( '[Optmer] [real_path] ' . $real_path );
185
+ $data = File::read( $real_path );
186
 
187
  // Font optimize
188
  if ( $this->_conf_css_font_display ) {
189
+ $data = preg_replace( '#(@font\-face\s*\{)#isU', '${1}font-display:' . $this->_conf_css_font_display . ';', $data );
190
  }
191
 
192
+ $data = preg_replace( '/@charset[^;]+;\\s*/', '', $data );
193
 
194
  if ( ! $concat_only && ! $this->_is_min( $real_path ) ) {
195
+ $data = self::minify_css( $data );
196
  }
197
 
198
+ $data = Lib\CSS_MIN\UriRewriter::rewrite( $data, dirname( $real_path ) );
199
+
200
+ if ( $media ) {
201
+ $data = '@media ' . $media . '{' . $data . "\n}";
202
+ }
203
 
204
+ $con[] = $data;
205
  }
206
 
207
+ return implode( '', $con );
208
  }
209
 
210
  /**
213
  * @since 1.9
214
  * @access private
215
  */
216
+ private function _serve_js( $files, $concat_only ) {
217
+ $con = array();
 
218
  foreach ( $files as $real_path ) {
219
+ $data = File::read( $real_path );
220
 
221
  if ( ! $concat_only && ! $this->_is_min( $real_path ) ) {
222
+ $data = self::minify_js( $data );
223
  }
224
  else {
225
+ $data = $this->_null_minifier( $data );
226
  }
227
 
228
+ $con[] = $data;
229
  }
230
 
231
+ return implode( "\n;", $con );
232
  }
233
 
234
  /**
237
  * @since 2.2.3
238
  * @access private
239
  */
240
+ public static function minify_css( $data ) {
 
241
  try {
242
+ $obj = new Lib\CSS_MIN\Minifier();
243
+ return $obj->run( $data );
244
 
245
  } catch ( \Exception $e ) {
246
+ Debug2::debug( '******[Optmer] minify_css failed: ' . $e->getMessage() );
247
+ error_log( '****** LiteSpeed Optimizer minify_css failed: ' . $e->getMessage() );
248
+ return $data;
249
  }
250
  }
251
 
257
  * @since 2.2.3
258
  * @access private
259
  */
260
+ public static function minify_js( $data, $js_type = '' ) {
 
261
  // For inline JS optimize, need to check if it's js type
262
  if ( $js_type ) {
263
+ preg_match( '#type=([\'"])(.+)\g{1}#isU', $js_type, $matches );
264
  if ( $matches && $matches[ 2 ] != 'text/javascript' ) {
265
+ Debug2::debug( '******[Optmer] minify_js bypass due to type: ' . $matches[ 2 ] );
266
+ return $data;
267
  }
268
  }
269
 
270
  try {
271
+ $data = Lib\JSMin::minify( $data );
272
+ return $data;
273
  } catch ( \Exception $e ) {
274
+ Debug2::debug( '******[Optmer] minify_js failed: ' . $e->getMessage() );
275
+ // error_log( '****** LiteSpeed Optimizer minify_js failed: ' . $e->getMessage() );
276
+ return $data;
277
  }
278
  }
279
 
282
  *
283
  * @access private
284
  */
285
+ private function _null_minifier( $content ) {
286
+ $content = str_replace( "\r\n", "\n", $content );
 
287
 
288
+ return trim( $content );
289
  }
290
 
291
  /**
294
  * @since 1.9
295
  * @access private
296
  */
297
+ private function _is_min( $filename ) {
298
+ $basename = basename( $filename );
 
299
  if ( preg_match( '|[-\.]min\.(?:[a-zA-Z]+)$|i', $basename ) ) {
300
+ return true;
301
  }
302
 
303
+ return false;
304
  }
305
 
306
  /**
310
  * @since 1.9 Moved here from optiize.cls
311
  * @access private
312
  */
313
+ private function _remove_comment( $content, $type ) {
 
314
  $_from = array(
315
  '|\/\*.*\*\/|U',
316
  '|\/\*.*\*\/|sU',
318
  // "|;+\n*;+|",
319
  // "|\n+;|",
320
  // "|;\n+|"
321
+ );
322
 
323
  $_to = array(
324
  '',
327
  // ';',
328
  // ';',
329
  // ';',
330
+ );
331
 
332
+ $content = preg_replace( $_from, $_to, $content );
333
  if ( $type == 'css' ) {
334
+ $content = preg_replace( "|: *|", ':', $content );
335
+ $content = preg_replace( "| */ *|", '/', $content );
336
  }
337
+ $content = trim( $content );
338
+ return $content;
339
  }
340
  }
341
 
src/placeholder.cls.php CHANGED
@@ -7,26 +7,25 @@
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
- namespace LiteSpeed ;
11
 
12
- defined( 'WPINC' ) || exit ;
13
 
14
- class Placeholder extends Base
15
- {
16
- protected static $_instance ;
17
 
18
- const TYPE_GENERATE = 'generate' ;
19
 
20
- private $_conf_placeholder_resp ;
21
- private $_conf_placeholder_resp_svg ;
22
  private $_conf_lqip;
23
  private $_conf_lqip_qual;
24
  private $_conf_lqip_min_w;
25
  private $_conf_lqip_min_h;
26
- private $_conf_placeholder_resp_color ;
27
- private $_conf_placeholder_resp_async ;
28
- private $_placeholder_resp_dict = array() ;
29
- private $_ph_queue = array() ;
30
 
31
  protected $_summary;
32
 
@@ -36,17 +35,16 @@ class Placeholder extends Base
36
  * @since 3.0
37
  * @access protected
38
  */
39
- protected function __construct()
40
- {
41
- $this->_conf_placeholder_resp = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP ) ;
42
- $this->_conf_placeholder_resp_svg = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_SVG ) ;
43
  $this->_conf_lqip = Conf::val( Base::O_MEDIA_LQIP );
44
  $this->_conf_lqip_qual = Conf::val( Base::O_MEDIA_LQIP_QUAL );
45
  $this->_conf_lqip_min_w = Conf::val( Base::O_MEDIA_LQIP_MIN_W );
46
  $this->_conf_lqip_min_h = Conf::val( Base::O_MEDIA_LQIP_MIN_H );
47
- $this->_conf_placeholder_resp_async = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_ASYNC ) ;
48
- $this->_conf_placeholder_resp_color = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_COLOR ) ;
49
- $this->_conf_ph_default = Conf::val( Base::O_MEDIA_LAZY_PLACEHOLDER ) ?: LITESPEED_PLACEHOLDER ;
50
 
51
  $this->_summary = self::get_summary();
52
  }
@@ -54,11 +52,10 @@ class Placeholder extends Base
54
  /**
55
  * Init Placeholder
56
  */
57
- public function init()
58
- {
59
- Debug2::debug2( '[Placeholder] init' ) ;
60
 
61
- add_action( 'litspeed_after_admin_init', array( $this, 'after_admin_init' ) ) ;
62
  }
63
 
64
  /**
@@ -67,8 +64,7 @@ class Placeholder extends Base
67
  * @since 3.0
68
  * @access public
69
  */
70
- public function after_admin_init()
71
- {
72
  if ( $this->_conf_lqip ) {
73
  add_filter( 'manage_media_columns', array( $this, 'media_row_title' ) );
74
  add_filter( 'manage_media_custom_column', array( $this, 'media_row_actions' ), 10, 2 );
@@ -82,8 +78,7 @@ class Placeholder extends Base
82
  * @since 3.0
83
  * @access public
84
  */
85
- public function media_row_title( $posts_columns )
86
- {
87
  $posts_columns[ 'lqip' ] = __( 'LQIP', 'litespeed-cache' );
88
 
89
  return $posts_columns;
@@ -95,8 +90,7 @@ class Placeholder extends Base
95
  * @since 3.0
96
  * @access public
97
  */
98
- public function media_row_actions( $column_name, $post_id )
99
- {
100
  if ( $column_name !== 'lqip' ) {
101
  return;
102
  }
@@ -112,9 +106,8 @@ class Placeholder extends Base
112
  * @since 3.0
113
  * @access public
114
  */
115
- public function media_row_con( $post_id )
116
- {
117
- $meta_value = wp_get_attachment_metadata( $post_id ) ;
118
 
119
  if ( empty( $meta_value[ 'file' ] ) ) {
120
  return;
@@ -123,31 +116,31 @@ class Placeholder extends Base
123
  $total_files = 0;
124
 
125
  // List all sizes
126
- $all_sizes = array( $meta_value[ 'file' ] ) ;
127
- $size_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/' ;
128
  foreach ( $meta_value[ 'sizes' ] as $v ) {
129
- $all_sizes[] = $size_path . $v[ 'file' ] ;
130
  }
131
 
132
  foreach ( $all_sizes as $short_path ) {
133
- $lqip_folder = LITESPEED_STATIC_DIR . '/lqip/' . $short_path ;
134
 
135
  if ( is_dir( $lqip_folder ) ) {
136
- Debug2::debug( '[LQIP] Found folder: ' . $short_path ) ;
137
 
138
 
139
 
140
  // List all files
141
  foreach ( scandir( $lqip_folder ) as $v ) {
142
  if ( $v == '.' || $v == '..' ) {
143
- continue ;
144
  }
145
 
146
  if ( $total_files == 0 ) {
147
  echo '<div class="litespeed-media-lqip"><img src="' . File::read( $lqip_folder . '/' . $v ) . '" alt="' . sprintf( __( 'LQIP image preview for size %s', 'litespeed-cache' ), $v ) .'"></div>';
148
  }
149
 
150
- echo '<div class="litespeed-media-size"><a href="' . File::read( $lqip_folder . '/' . $v ) . '" target="_blank">' . $v . '</a></div>' ;
151
 
152
  $total_files++;
153
  }
@@ -167,23 +160,22 @@ class Placeholder extends Base
167
  * @since 3.0
168
  * @access public
169
  */
170
- public function replace( $html, $src, $size )
171
- {
172
  // Check if need to enable responsive placeholder or not
173
- $this_placeholder = $this->_placeholder( $src, $size ) ?: $this->_conf_ph_default ;
174
 
175
- $additional_attr = '' ;
176
  if ( $this->_conf_lqip && $this_placeholder != $this->_conf_ph_default ) {
177
- Debug2::debug2( '[Placeholder] Use resp LQIP [size] ' . $size ) ;
178
- $additional_attr = ' data-placeholder-resp="' . $size . '"' ;
179
  }
180
 
181
- $snippet = '<noscript>' . $html . '</noscript>' ;
182
- $html = str_replace( array( ' src=', ' srcset=', ' sizes=' ), array( ' data-src=', ' data-srcset=', ' data-sizes=' ), $html ) ;
183
- $html = str_replace( '<img ', '<img data-lazyloaded="1"' . $additional_attr . ' src="' . $this_placeholder . '" ', $html ) ;
184
- $snippet = $html . $snippet ;
185
 
186
- return $snippet ;
187
  }
188
 
189
  /**
@@ -192,91 +184,90 @@ class Placeholder extends Base
192
  * @since 2.5.1
193
  * @access private
194
  */
195
- private function _placeholder( $src, $size )
196
- {
197
  // Low Quality Image Placeholders
198
  if ( ! $size ) {
199
- Debug2::debug2( '[Placeholder] no size ' . $src ) ;
200
- return false ;
201
  }
202
 
203
  if ( ! $this->_conf_placeholder_resp ) {
204
- return false ;
205
  }
206
 
207
  // If use local generator
208
  if ( ! $this->_conf_lqip || ! $this->_lqip_size_check( $size ) ) {
209
- return $this->_generate_placeholder_locally( $size ) ;
210
  }
211
 
212
- Debug2::debug2( '[Placeholder] Resp LQIP process [src] ' . $src . ' [size] ' . $size ) ;
213
 
214
  $arr_key = $size . ' ' . $src;
215
 
216
  // Check if its already in dict or not
217
  if ( ! empty( $this->_placeholder_resp_dict[ $arr_key ] ) ) {
218
- Debug2::debug2( '[Placeholder] already in dict' ) ;
219
 
220
- return $this->_placeholder_resp_dict[ $arr_key ] ;
221
  }
222
 
223
  // Need to generate the responsive placeholder
224
- $placeholder_realpath = $this->_placeholder_realpath( $src, $size ) ; // todo: give offload API
225
  if ( file_exists( $placeholder_realpath ) ) {
226
- Debug2::debug2( '[Placeholder] file exists' ) ;
227
- $this->_placeholder_resp_dict[ $arr_key ] = File::read( $placeholder_realpath ) ;
228
 
229
- return $this->_placeholder_resp_dict[ $arr_key ] ;
230
  }
231
 
232
  // Add to cron queue
233
 
234
  // Prevent repeated requests
235
  if ( in_array( $arr_key, $this->_ph_queue ) ) {
236
- Debug2::debug2( '[Placeholder] file bypass generating due to in queue' ) ;
237
- return $this->_generate_placeholder_locally( $size ) ;
238
  }
239
 
240
- $this->_ph_queue[] = $arr_key ;
241
 
242
  // Send request to generate placeholder
243
  if ( ! $this->_conf_placeholder_resp_async ) {
244
  // If requested recently, bypass
245
  if ( $this->_summary && ! empty( $this->_summary[ 'curr_request' ] ) && time() - $this->_summary[ 'curr_request' ] < 300 ) {
246
- Debug2::debug2( '[Placeholder] file bypass generating due to interval limit' ) ;
247
- return false ;
248
  }
249
  // Generate immediately
250
- $this->_placeholder_resp_dict[ $arr_key ] = $this->_generate_placeholder( $arr_key ) ;
251
 
252
- return $this->_placeholder_resp_dict[ $arr_key ] ;
253
  }
254
 
255
  // Prepare default svg placeholder as tmp placeholder
256
- $tmp_placeholder = $this->_generate_placeholder_locally( $size ) ;
257
 
258
  // Store it to prepare for cron
259
  if ( empty( $this->_summary[ 'queue' ] ) ) {
260
- $this->_summary[ 'queue' ] = array() ;
261
  }
262
  if ( in_array( $arr_key, $this->_summary[ 'queue' ] ) ) {
263
- Debug2::debug2( '[Placeholder] already in queue' ) ;
264
 
265
- return $tmp_placeholder ;
266
  }
267
 
268
  if ( count( $this->_summary[ 'queue' ] ) > 100 ) {
269
- Debug2::debug2( '[Placeholder] queue is full' ) ;
270
 
271
- return $tmp_placeholder ;
272
  }
273
 
274
- $this->_summary[ 'queue' ][] = $arr_key ;
275
 
276
- Debug2::debug( '[Placeholder] Added placeholder queue' ) ;
277
 
278
  self::save_summary();
279
- return $tmp_placeholder ;
280
 
281
  }
282
 
@@ -286,9 +277,8 @@ class Placeholder extends Base
286
  * @since 3.0
287
  * @access public
288
  */
289
- public static function has_lqip_cache()
290
- {
291
- return is_dir( LITESPEED_STATIC_DIR . '/lqip' ) ;
292
  }
293
 
294
  /**
@@ -297,27 +287,26 @@ class Placeholder extends Base
297
  * @since 2.5.1
298
  * @access private
299
  */
300
- private function _placeholder_realpath( $src, $size )
301
- {
302
  // Use LQIP Cloud generator, each image placeholder will be separately stored
303
 
304
  // Compatibility with WebP
305
  if ( substr( $src, -5 ) === '.webp' ) {
306
- $src = substr( $src, 0, -5 ) ;
307
  }
308
 
309
  // External images will use cache folder directly
310
- $domain = parse_url( $src, PHP_URL_HOST ) ;
311
  if ( $domain && ! Utility::internal( $domain ) ) { // todo: need to improve `util:internal()` to include `CDN::internal()`
312
- $md5 = md5( $src ) ;
313
 
314
- return LITESPEED_STATIC_DIR . '/lqip/remote/' . substr( $md5, 0, 1 ) . '/' . substr( $md5, 1, 1 ) . '/' . $md5 . '.' . $size ;
315
  }
316
 
317
  // Drop domain
318
- $short_path = Utility::att_short_path( $src ) ;
319
 
320
- return LITESPEED_STATIC_DIR . '/lqip/' . $short_path . '/' . $size ;
321
 
322
  }
323
 
@@ -327,16 +316,15 @@ class Placeholder extends Base
327
  * @since 3.0
328
  * @access public
329
  */
330
- public function rm_lqip_cache_folder()
331
- {
332
  if ( self::has_lqip_cache() ) {
333
- File::rrmdir( LITESPEED_STATIC_DIR . '/lqip' ) ;
334
  }
335
 
336
  // Clear LQIP in queue too
337
- self::save_summary( array() ) ;
338
 
339
- Debug2::debug( '[Placeholder] Cleared LQIP queue' ) ;
340
  }
341
 
342
  /**
@@ -345,29 +333,28 @@ class Placeholder extends Base
345
  * @since 2.5.1
346
  * @access public
347
  */
348
- public static function cron( $continue = false )
349
- {
350
  $_instance = self::get_instance();
351
  if ( empty( $_instance->_summary[ 'queue' ] ) ) {
352
- return ;
353
  }
354
 
355
  // For cron, need to check request interval too
356
  if ( ! $continue ) {
357
  if ( ! empty( $_instance->_summary[ 'curr_request' ] ) && time() - $_instance->_summary[ 'curr_request' ] < 300 ) {
358
  Debug2::debug( '[Placeholder] Last request not done' );
359
- return ;
360
  }
361
  }
362
 
363
  foreach ( $_instance->_summary[ 'queue' ] as $v ) {
364
- Debug2::debug( '[Placeholder] cron job [size] ' . $v ) ;
365
 
366
- $_instance->_generate_placeholder( $v ) ;
367
 
368
  // only request first one
369
  if ( ! $continue ) {
370
- return ;
371
  }
372
  }
373
  }
@@ -378,15 +365,14 @@ class Placeholder extends Base
378
  * @since 3.0
379
  * @access private
380
  */
381
- private function _generate_placeholder_locally( $size )
382
- {
383
- Debug2::debug2( '[Placeholder] _generate_placeholder local [size] ' . $size ) ;
384
 
385
- $size = explode( 'x', $size ) ;
386
 
387
- $svg = str_replace( array( '{width}', '{height}', '{color}' ), array( $size[ 0 ], $size[ 1 ], $this->_conf_placeholder_resp_color ), $this->_conf_placeholder_resp_svg ) ;
388
 
389
- return 'data:image/svg+xml;base64,' . base64_encode( $svg ) ;
390
  }
391
 
392
  /**
@@ -395,36 +381,43 @@ class Placeholder extends Base
395
  * @since 2.5.1
396
  * @access private
397
  */
398
- private function _generate_placeholder( $raw_size_and_src )
399
- {
400
  // Parse containing size and src info
401
- $size_and_src = explode( ' ', $raw_size_and_src, 2 ) ;
402
- $size = $size_and_src[ 0 ] ;
403
- $src = false ;
404
  if ( ! empty( $size_and_src[ 1 ] ) ) {
405
- $src = $size_and_src[ 1 ] ;
406
  }
407
 
408
- $file = $this->_placeholder_realpath( $src, $size ) ;
409
 
410
  // Local generate SVG to serve ( Repeatly doing this here to remove stored cron queue in case the setting _conf_lqip is changed )
411
  if ( ! $this->_conf_lqip || ! $this->_lqip_size_check( $size ) ) {
412
- $data = $this->_generate_placeholder_locally( $size ) ;
413
  }
414
  else {
415
  // Update request status
416
- $this->_summary[ 'curr_request' ] = time() ;
417
  self::save_summary();
418
 
419
  // Generate LQIP
420
- list( $width, $height ) = explode( 'x', $size ) ;
421
  $req_data = array(
422
  'width' => $width,
423
  'height' => $height,
424
  'url' => substr( $src, -5 ) === '.webp' ? substr( $src, 0, -5 ) : $src,
425
  'quality' => $this->_conf_lqip_qual,
426
- ) ;
427
- $json = Cloud::post( Cloud::SVC_LQIP, $req_data, 30 ) ;
 
 
 
 
 
 
 
 
428
  if ( ! is_array( $json ) ) {
429
  return $this->_generate_placeholder_locally( $size );
430
  }
@@ -432,28 +425,28 @@ class Placeholder extends Base
432
  if ( empty( $json[ 'lqip' ] ) || strpos( $json[ 'lqip' ], 'data:image/svg+xml' ) !== 0 ) {
433
  // image error, pop up the current queue
434
  $this->_popup_and_save( $raw_size_and_src );
435
- Debug2::debug( '[Placeholder] wrong response format', $json ) ;
436
 
437
  return $this->_generate_placeholder_locally( $size );
438
  }
439
 
440
- $data = $json[ 'lqip' ] ;
441
 
442
- Debug2::debug( '[Placeholder] _generate_placeholder LQIP' ) ;
443
  }
444
 
445
  // Write to file
446
- File::save( $file, $data, true ) ;
447
 
448
  // Save summary data
449
- $this->_summary[ 'last_spent' ] = time() - $this->_summary[ 'curr_request' ] ;
450
- $this->_summary[ 'last_request' ] = $this->_summary[ 'curr_request' ] ;
451
- $this->_summary[ 'curr_request' ] = 0 ;
452
  $this->_popup_and_save( $raw_size_and_src );
453
 
454
- Debug2::debug( '[Placeholder] saved LQIP ' . $file ) ;
455
 
456
- return $data ;
457
  }
458
 
459
  /**
@@ -461,8 +454,7 @@ class Placeholder extends Base
461
  *
462
  * @since 3.0
463
  */
464
- private function _lqip_size_check( $size )
465
- {
466
  $size = explode( 'x', $size );
467
  if ( $size[ 0 ] >= $this->_conf_lqip_min_w || $size[ 1 ] >= $this->_conf_lqip_min_h ) {
468
  return true;
@@ -476,10 +468,9 @@ class Placeholder extends Base
476
  *
477
  * @since 3.0
478
  */
479
- private function _popup_and_save( $raw_size_and_src )
480
- {
481
  if ( ! empty( $this->_summary[ 'queue' ] ) && in_array( $raw_size_and_src, $this->_summary[ 'queue' ] ) ) {
482
- unset( $this->_summary[ 'queue' ][ array_search( $raw_size_and_src, $this->_summary[ 'queue' ] ) ] ) ;
483
  }
484
 
485
  self::save_summary();
@@ -491,22 +482,21 @@ class Placeholder extends Base
491
  * @since 2.5.1
492
  * @access public
493
  */
494
- public static function handler()
495
- {
496
- $instance = self::get_instance() ;
497
 
498
- $type = Router::verify_type() ;
499
 
500
  switch ( $type ) {
501
  case self::TYPE_GENERATE :
502
- self::cron( true ) ;
503
- break ;
504
 
505
  default:
506
- break ;
507
  }
508
 
509
- Admin::redirect() ;
510
  }
511
 
512
  }
7
  * @subpackage LiteSpeed/inc
8
  * @author LiteSpeed Technologies <info@litespeedtech.com>
9
  */
10
+ namespace LiteSpeed;
11
 
12
+ defined( 'WPINC' ) || exit;
13
 
14
+ class Placeholder extends Base {
15
+ protected static $_instance;
 
16
 
17
+ const TYPE_GENERATE = 'generate';
18
 
19
+ private $_conf_placeholder_resp;
20
+ private $_conf_placeholder_resp_svg;
21
  private $_conf_lqip;
22
  private $_conf_lqip_qual;
23
  private $_conf_lqip_min_w;
24
  private $_conf_lqip_min_h;
25
+ private $_conf_placeholder_resp_color;
26
+ private $_conf_placeholder_resp_async;
27
+ private $_placeholder_resp_dict = array();
28
+ private $_ph_queue = array();
29
 
30
  protected $_summary;
31
 
35
  * @since 3.0
36
  * @access protected
37
  */
38
+ protected function __construct() {
39
+ $this->_conf_placeholder_resp = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP );
40
+ $this->_conf_placeholder_resp_svg = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_SVG );
 
41
  $this->_conf_lqip = Conf::val( Base::O_MEDIA_LQIP );
42
  $this->_conf_lqip_qual = Conf::val( Base::O_MEDIA_LQIP_QUAL );
43
  $this->_conf_lqip_min_w = Conf::val( Base::O_MEDIA_LQIP_MIN_W );
44
  $this->_conf_lqip_min_h = Conf::val( Base::O_MEDIA_LQIP_MIN_H );
45
+ $this->_conf_placeholder_resp_async = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_ASYNC );
46
+ $this->_conf_placeholder_resp_color = Conf::val( Base::O_MEDIA_PLACEHOLDER_RESP_COLOR );
47
+ $this->_conf_ph_default = Conf::val( Base::O_MEDIA_LAZY_PLACEHOLDER ) ?: LITESPEED_PLACEHOLDER;
48
 
49
  $this->_summary = self::get_summary();
50
  }
52
  /**
53
  * Init Placeholder
54
  */
55
+ public function init() {
56
+ Debug2::debug2( '[Placeholder] init' );
 
57
 
58
+ add_action( 'litspeed_after_admin_init', array( $this, 'after_admin_init' ) );
59
  }
60
 
61
  /**
64
  * @since 3.0
65
  * @access public
66
  */
67
+ public function after_admin_init() {
 
68
  if ( $this->_conf_lqip ) {
69
  add_filter( 'manage_media_columns', array( $this, 'media_row_title' ) );
70
  add_filter( 'manage_media_custom_column', array( $this, 'media_row_actions' ), 10, 2 );
78
  * @since 3.0
79
  * @access public
80
  */
81
+ public function media_row_title( $posts_columns ) {
 
82
  $posts_columns[ 'lqip' ] = __( 'LQIP', 'litespeed-cache' );
83
 
84
  return $posts_columns;
90
  * @since 3.0
91
  * @access public
92
  */
93
+ public function media_row_actions( $column_name, $post_id ) {
 
94
  if ( $column_name !== 'lqip' ) {
95
  return;
96
  }
106
  * @since 3.0
107
  * @access public
108
  */
109
+ public function media_row_con( $post_id ) {
110
+ $meta_value = wp_get_attachment_metadata( $post_id );
 
111
 
112
  if ( empty( $meta_value[ 'file' ] ) ) {
113
  return;
116
  $total_files = 0;
117
 
118
  // List all sizes
119
+ $all_sizes = array( $meta_value[ 'file' ] );
120
+ $size_path = pathinfo( $meta_value[ 'file' ], PATHINFO_DIRNAME ) . '/';
121
  foreach ( $meta_value[ 'sizes' ] as $v ) {
122
+ $all_sizes[] = $size_path . $v[ 'file' ];
123
  }
124
 
125
  foreach ( $all_sizes as $short_path ) {
126
+ $lqip_folder = LITESPEED_STATIC_DIR . '/lqip/' . $short_path;
127
 
128
  if ( is_dir( $lqip_folder ) ) {
129
+ Debug2::debug( '[LQIP] Found folder: ' . $short_path );
130
 
131
 
132
 
133
  // List all files
134
  foreach ( scandir( $lqip_folder ) as $v ) {
135
  if ( $v == '.' || $v == '..' ) {
136
+ continue;
137
  }
138
 
139
  if ( $total_files == 0 ) {
140
  echo '<div class="litespeed-media-lqip"><img src="' . File::read( $lqip_folder . '/' . $v ) . '" alt="' . sprintf( __( 'LQIP image preview for size %s', 'litespeed-cache' ), $v ) .'"></div>';
141
  }
142
 
143
+ echo '<div class="litespeed-media-size"><a href="' . File::read( $lqip_folder . '/' . $v ) . '" target="_blank">' . $v . '</a></div>';
144
 
145
  $total_files++;
146
  }
160
  * @since 3.0
161
  * @access public
162
  */
163
+ public function replace( $html, $src, $size ) {
 
164
  // Check if need to enable responsive placeholder or not
165
+ $this_placeholder = $this->_placeholder( $src, $size ) ?: $this->_conf_ph_default;
166
 
167
+ $additional_attr = '';
168
  if ( $this->_conf_lqip && $this_placeholder != $this->_conf_ph_default ) {
169
+ Debug2::debug2( '[Placeholder] Use resp LQIP [size] ' . $size );
170
+ $additional_attr = ' data-placeholder-resp="' . $size . '"';
171
  }
172
 
173
+ $snippet = '<noscript>' . $html . '</noscript>';
174
+ $html = str_replace( array( ' src=', ' srcset=', ' sizes=' ), array( ' data-src=', ' data-srcset=', ' data-sizes=' ), $html );
175
+ $html = str_replace( '<img ', '<img data-lazyloaded="1"' . $additional_attr . ' src="' . $this_placeholder . '" ', $html );
176
+ $snippet = $html . $snippet;
177
 
178
+ return $snippet;
179
  }
180
 
181
  /**
184
  * @since 2.5.1
185
  * @access private
186
  */
187
+ private function _placeholder( $src, $size ) {
 
188
  // Low Quality Image Placeholders
189
  if ( ! $size ) {
190
+ Debug2::debug2( '[Placeholder] no size ' . $src );
191
+ return false;
192
  }
193
 
194
  if ( ! $this->_conf_placeholder_resp ) {
195
+ return false;
196
  }
197
 
198
  // If use local generator
199
  if ( ! $this->_conf_lqip || ! $this->_lqip_size_check( $size ) ) {
200
+ return $this->_generate_placeholder_locally( $size );
201
  }
202
 
203
+ Debug2::debug2( '[Placeholder] Resp LQIP process [src] ' . $src . ' [size] ' . $size );
204
 
205
  $arr_key = $size . ' ' . $src;
206
 
207
  // Check if its already in dict or not
208
  if ( ! empty( $this->_placeholder_resp_dict[ $arr_key ] ) ) {
209
+ Debug2::debug2( '[Placeholder] already in dict' );
210
 
211
+ return $this->_placeholder_resp_dict[ $arr_key ];
212
  }
213
 
214
  // Need to generate the responsive placeholder
215
+ $placeholder_realpath = $this->_placeholder_realpath( $src, $size ); // todo: give offload API
216
  if ( file_exists( $placeholder_realpath ) ) {
217
+ Debug2::debug2( '[Placeholder] file exists' );
218
+ $this->_placeholder_resp_dict[ $arr_key ] = File::read( $placeholder_realpath );
219
 
220
+ return $this->_placeholder_resp_dict[ $arr_key ];
221
  }
222
 
223
  // Add to cron queue
224
 
225
  // Prevent repeated requests
226
  if ( in_array( $arr_key, $this->_ph_queue ) ) {
227
+ Debug2::debug2( '[Placeholder] file bypass generating due to in queue' );
228
+ return $this->_generate_placeholder_locally( $size );
229
  }
230
 
231
+ $this->_ph_queue[] = $arr_key;
232
 
233
  // Send request to generate placeholder
234
  if ( ! $this->_conf_placeholder_resp_async ) {
235
  // If requested recently, bypass
236
  if ( $this->_summary && ! empty( $this->_summary[ 'curr_request' ] ) && time() - $this->_summary[ 'curr_request' ] < 300 ) {
237
+ Debug2::debug2( '[Placeholder] file bypass generating due to interval limit' );
238
+ return false;
239
  }
240
  // Generate immediately
241
+ $this->_placeholder_resp_dict[ $arr_key ] = $this->_generate_placeholder( $arr_key );
242
 
243
+ return $this->_placeholder_resp_dict[ $arr_key ];
244
  }
245
 
246
  // Prepare default svg placeholder as tmp placeholder
247
+ $tmp_placeholder = $this->_generate_placeholder_locally( $size );
248
 
249
  // Store it to prepare for cron
250
  if ( empty( $this->_summary[ 'queue' ] ) ) {
251
+ $this->_summary[ 'queue' ] = array();
252
  }
253
  if ( in_array( $arr_key, $this->_summary[ 'queue' ] ) ) {
254
+ Debug2::debug2( '[Placeholder] already in queue' );
255
 
256
+ return $tmp_placeholder;
257
  }
258
 
259
  if ( count( $this->_summary[ 'queue' ] ) > 100 ) {
260
+ Debug2::debug2( '[Placeholder] queue is full' );
261
 
262
+ return $tmp_placeholder;
263
  }
264
 
265
+ $this->_summary[ 'queue' ][] = $arr_key;
266
 
267
+ Debug2::debug( '[Placeholder] Added placeholder queue' );
268
 
269
  self::save_summary();
270
+ return $tmp_placeholder;
271
 
272
  }
273
 
277
  * @since 3.0
278
  * @access public
279
  */
280
+ public static function has_lqip_cache() {
281
+ return is_dir( LITESPEED_STATIC_DIR . '/lqip' );
 
282
  }
283
 
284
  /**
287
  * @since 2.5.1
288
  * @access private
289
  */
290
+ private function _placeholder_realpath( $src, $size ) {
 
291
  // Use LQIP Cloud generator, each image placeholder will be separately stored
292
 
293
  // Compatibility with WebP
294
  if ( substr( $src, -5 ) === '.webp' ) {
295
+ $src = substr( $src, 0, -5 );
296
  }
297
 
298
  // External images will use cache folder directly
299
+ $domain = parse_url( $src, PHP_URL_HOST );
300
  if ( $domain && ! Utility::internal( $domain ) ) { // todo: need to improve `util:internal()` to include `CDN::internal()`
301
+ $md5 = md5( $src );
302
 
303
+ return LITESPEED_STATIC_DIR . '/lqip/remote/' . substr( $md5, 0, 1 ) . '/' . substr( $md5, 1, 1 ) . '/' . $md5 . '.' . $size;
304
  }
305
 
306
  // Drop domain
307
+ $short_path = Utility::att_short_path( $src );
308
 
309
+ return LITESPEED_STATIC_DIR . '/lqip/' . $short_path . '/' . $size;
310
 
311
  }
312
 
316
  * @since 3.0
317
  * @access public
318
  */
319
+ public function rm_lqip_cache_folder() {
 
320
  if ( self::has_lqip_cache() ) {
321
+ File::rrmdir( LITESPEED_STATIC_DIR . '/lqip' );
322
  }
323
 
324
  // Clear LQIP in queue too
325
+ self::save_summary( array() );
326
 
327
+ Debug2::debug( '[Placeholder] Cleared LQIP queue' );
328
  }
329
 
330
  /**
333
  * @since 2.5.1
334
  * @access public
335
  */
336
+ public static function cron( $continue = false ) {
 
337
  $_instance = self::get_instance();
338
  if ( empty( $_instance->_summary[ 'queue' ] ) ) {
339
+ return;
340
  }
341
 
342
  // For cron, need to check request interval too
343
  if ( ! $continue ) {
344
  if ( ! empty( $_instance->_summary[ 'curr_request' ] ) && time() - $_instance->_summary[ 'curr_request' ] < 300 ) {
345
  Debug2::debug( '[Placeholder] Last request not done' );
346
+ return;
347
  }
348
  }
349
 
350
  foreach ( $_instance->_summary[ 'queue' ] as $v ) {
351
+ Debug2::debug( '[Placeholder] cron job [size] ' . $v );
352
 
353
+ $_instance->_generate_placeholder( $v );
354
 
355
  // only request first one
356
  if ( ! $continue ) {
357
+ return;
358
  }
359
  }
360
  }
365
  * @since 3.0
366
  * @access private
367
  */
368
+ private function _generate_placeholder_locally( $size ) {
369
+ Debug2::debug2( '[Placeholder] _generate_placeholder local [size] ' . $size );
 
370
 
371
+ $size = explode( 'x', $size );
372
 
373
+ $svg = str_replace( array( '{width}', '{height}', '{color}' ), array( $size[ 0 ], $size[ 1 ], $this->_conf_placeholder_resp_color ), $this->_conf_placeholder_resp_svg );
374
 
375
+ return 'data:image/svg+xml;base64,' . base64_encode( $svg );
376
  }
377
 
378
  /**
381
  * @since 2.5.1
382
  * @access private
383
  */
384
+ private function _generate_placeholder( $raw_size_and_src ) {
 
385
  // Parse containing size and src info
386
+ $size_and_src = explode( ' ', $raw_size_and_src, 2 );
387
+ $size = $size_and_src[ 0 ];
388
+ $src = false;
389
  if ( ! empty( $size_and_src[ 1 ] ) ) {
390
+ $src = $size_and_src[ 1 ];
391
  }
392
 
393
+ $file = $this->_placeholder_realpath( $src, $size );
394
 
395
  // Local generate SVG to serve ( Repeatly doing this here to remove stored cron queue in case the setting _conf_lqip is changed )
396
  if ( ! $this->_conf_lqip || ! $this->_lqip_size_check( $size ) ) {
397
+ $data = $this->_generate_placeholder_locally( $size );
398
  }
399
  else {
400
  // Update request status
401
+ $this->_summary[ 'curr_request' ] = time();
402
  self::save_summary();
403
 
404
  // Generate LQIP
405
+ list( $width, $height ) = explode( 'x', $size );
406
  $req_data = array(
407
  'width' => $width,
408
  'height' => $height,
409
  'url' => substr( $src, -5 ) === '.webp' ? substr( $src, 0, -5 ) : $src,
410
  'quality' => $this->_conf_lqip_qual,
411
+ );
412
+
413
+ // CHeck if the image is 404 first
414
+ if ( File::is_404( $req_data[ 'url' ] ) ) {
415
+ $this->_popup_and_save( $raw_size_and_src );
416
+ Debug2::debug( '[Placeholder] 404 before request [src] ' . $req_data[ 'url' ] );
417
+ return $this->_generate_placeholder_locally( $size );
418
+ }
419
+
420
+ $json = Cloud::post( Cloud::SVC_LQIP, $req_data, 30 );
421
  if ( ! is_array( $json ) ) {
422
  return $this->_generate_placeholder_locally( $size );
423
  }
425
  if ( empty( $json[ 'lqip' ] ) || strpos( $json[ 'lqip' ], 'data:image/svg+xml' ) !== 0 ) {
426
  // image error, pop up the current queue
427
  $this->_popup_and_save( $raw_size_and_src );
428
+ Debug2::debug( '[Placeholder] wrong response format', $json );
429
 
430
  return $this->_generate_placeholder_locally( $size );
431
  }
432
 
433
+ $data = $json[ 'lqip' ];
434
 
435
+ Debug2::debug( '[Placeholder] _generate_placeholder LQIP' );
436
  }
437
 
438
  // Write to file
439
+ File::save( $file, $data, true );
440
 
441
  // Save summary data
442
+ $this->_summary[ 'last_spent' ] = time() - $this->_summary[ 'curr_request' ];
443
+ $this->_summary[ 'last_request' ] = $this->_summary[ 'curr_request' ];
444
+ $this->_summary[ 'curr_request' ] = 0;
445
  $this->_popup_and_save( $raw_size_and_src );
446
 
447
+ Debug2::debug( '[Placeholder] saved LQIP ' . $file );
448
 
449
+ return $data;
450
  }
451
 
452
  /**
454
  *
455
  * @since 3.0
456
  */
457
+ private function _lqip_size_check( $size ) {
 
458
  $size = explode( 'x', $size );
459
  if ( $size[ 0 ] >= $this->_conf_lqip_min_w || $size[ 1 ] >= $this->_conf_lqip_min_h ) {
460
  return true;
468
  *
469
  * @since 3.0
470
  */
471
+ private function _popup_and_save( $raw_size_and_src ) {
 
472
  if ( ! empty( $this->_summary[ 'queue' ] ) && in_array( $raw_size_and_src, $this->_summary[ 'queue' ] ) ) {
473
+ unset( $this->_summary[ 'queue' ][ array_search( $raw_size_and_src, $this->_summary[ 'queue' ] ) ] );
474
  }
475
 
476
  self::save_summary();
482
  * @since 2.5.1
483
  * @access public
484
  */
485
+ public static function handler() {
486
+ $instance = self::get_instance();
 
487
 
488
+ $type = Router::verify_type();
489
 
490
  switch ( $type ) {
491
  case self::TYPE_GENERATE :
492
+ self::cron( true );
493
+ break;
494
 
495
  default:
496
+ break;
497
  }
498
 
499
+ Admin::redirect();
500
  }
501
 
502
  }
src/purge.cls.php CHANGED
@@ -3,46 +3,44 @@
3
  * The plugin purge class for X-LiteSpeed-Purge
4
  *
5
  * @since 1.1.3
6
- * @since 1.5 Moved into /inc
7
  * @since 2.2 Refactored. Changed access from public to private for most func and class variables.
8
  */
9
- namespace LiteSpeed ;
10
 
11
- defined( 'WPINC' ) || exit ;
12
 
13
- class Purge extends Base
14
- {
15
- protected static $_instance ;
16
 
17
- protected $_pub_purge = array() ;
18
- protected $_priv_purge = array() ;
19
- protected $_purge_related = false ;
20
- protected $_purge_single = false ;
21
 
22
- const X_HEADER = 'X-LiteSpeed-Purge' ;
23
- const DB_QUEUE = 'queue' ;
24
 
25
- const TYPE_PURGE_ALL = 'purge_all' ;
26
- const TYPE_PURGE_ALL_LSCACHE = 'purge_all_lscache' ;
27
- const TYPE_PURGE_ALL_CSSJS = 'purge_all_cssjs' ;
28
- const TYPE_PURGE_ALL_CCSS = 'purge_all_ccss' ;
29
- const TYPE_PURGE_ALL_LQIP = 'purge_all_lqip' ;
30
- const TYPE_PURGE_ALL_AVATAR = 'purge_all_avatar' ;
31
- const TYPE_PURGE_ALL_OBJECT = 'purge_all_object' ;
32
- const TYPE_PURGE_ALL_OPCACHE = 'purge_all_opcache' ;
 
33
 
34
- const TYPE_PURGE_FRONT = 'purge_front' ;
35
- const TYPE_PURGE_FRONTPAGE = 'purge_frontpage' ;
36
- const TYPE_PURGE_PAGES = 'purge_pages' ;
37
- const TYPE_PURGE_ERROR = 'purge_error' ;
38
 
39
  /**
40
  * Initialize
41
  *
42
  * @since 2.2.3
43
  */
44
- protected function __construct()
45
- {
46
  }
47
 
48
  /**
@@ -50,8 +48,7 @@ class Purge extends Base
50
  *
51
  * @since 3.0
52
  */
53
- public function init()
54
- {
55
  //register purge actions
56
  $purge_post_events = array(
57
  // 'edit_post',
@@ -79,8 +76,7 @@ class Purge extends Base
79
  * @since 3.0
80
  * @access public
81
  */
82
- public static function purge_publish( $new_status, $old_status, $post )
83
- {
84
  if ( $new_status != 'publish' && $old_status != 'publish' ) {
85
  return;
86
  }
@@ -94,66 +90,69 @@ class Purge extends Base
94
  * @since 1.8
95
  * @access public
96
  */
97
- public static function handler()
98
- {
99
- $instance = self::get_instance() ;
100
 
101
- $type = Router::verify_type() ;
102
 
103
  switch ( $type ) {
104
- case self::TYPE_PURGE_ALL :
105
- $instance->_purge_all() ;
106
- break ;
107
 
108
- case self::TYPE_PURGE_ALL_LSCACHE :
109
- $instance->_purge_all_lscache() ;
110
- break ;
111
 
112
- case self::TYPE_PURGE_ALL_CSSJS :
113
- $instance->_purge_all_cssjs() ;
114
- break ;
115
 
116
- case self::TYPE_PURGE_ALL_CCSS :
117
- $instance->_purge_all_ccss() ;
118
- break ;
119
 
120
- case self::TYPE_PURGE_ALL_LQIP :
121
- $instance->_purge_all_lqip() ;
122
- break ;
123
 
124
- case self::TYPE_PURGE_ALL_AVATAR :
125
- $instance->_purge_all_avatar() ;
126
- break ;
127
 
128
- case self::TYPE_PURGE_ALL_OBJECT :
129
- $instance->_purge_all_object() ;
130
- break ;
131
 
132
- case self::TYPE_PURGE_ALL_OPCACHE :
133
- $instance->purge_all_opcache() ;
134
- break ;
135
 
136
- case self::TYPE_PURGE_FRONT :
137
- $instance->_purge_front() ;
138
- break ;
139
 
140
- case self::TYPE_PURGE_FRONTPAGE :
141
- $instance->_purge_frontpage() ;
142
- break ;
143
 
144
- case self::TYPE_PURGE_PAGES :
145
- $instance->_purge_pages() ;
146
- break ;
147
 
148
- case strpos( $type, self::TYPE_PURGE_ERROR ) === 0 :
149
- $instance->_purge_error( substr( $type, strlen( self::TYPE_PURGE_ERROR ) ) ) ;
150
- break ;
 
 
 
 
151
 
152
  default:
153
- break ;
154
  }
155
 
156
- Admin::redirect() ;
157
  }
158
 
159
  /**
@@ -162,9 +161,8 @@ class Purge extends Base
162
  * @since 1.0.0
163
  * @access public
164
  */
165
- public static function purge_all( $reason = false )
166
- {
167
- self::get_instance()->_purge_all( $reason ) ;
168
  }
169
 
170
  /**
@@ -173,27 +171,27 @@ class Purge extends Base
173
  * @since 2.2
174
  * @access private
175
  */
176
- private function _purge_all( $reason = false )
177
- {
178
- $this->_purge_all_lscache( true ) ;
179
- $this->_purge_all_cssjs( true ) ;
180
- // $this->_purge_all_ccss( true ) ;
181
- // $this->_purge_all_lqip( true ) ;
182
- $this->_purge_all_object( true ) ;
183
- $this->purge_all_opcache( true ) ;
184
 
185
  if ( ! is_string( $reason ) ) {
186
- $reason = false ;
187
  }
188
 
189
  if ( $reason ) {
190
- $reason = "( $reason )" ;
191
  }
192
 
193
- Debug2::debug( '[Purge] Purge all ' . $reason, 3 ) ;
194
 
195
- $msg = __( 'Purged all caches successfully.', 'litespeed-cache' ) ;
196
- ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg ) ;
197
 
198
  do_action( 'litespeed_purged_all' );
199
  }
@@ -209,7 +207,7 @@ class Purge extends Base
209
  */
210
  private function _purge_all_lscache( $silence = false )
211
  {
212
- $this->_add( '*' ) ;
213
 
214
  if ( ! $silence ) {
215
  $msg = __( 'Notified LiteSpeed Web Server to purge all LSCache entries.', 'litespeed-cache' ) ;
@@ -255,8 +253,7 @@ class Purge extends Base
255
  * @since 3.0
256
  * @access private
257
  */
258
- private function _purge_all_avatar( $silence = false )
259
- {
260
  Avatar::get_instance()->rm_cache_folder() ;
261
 
262
  if ( ! $silence ) {
@@ -265,24 +262,38 @@ class Purge extends Base
265
  }
266
  }
267
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  /**
269
  * Alerts LiteSpeed Web Server to purge pages.
270
  *
271
  * @since 1.2.2
272
  * @access private
273
  */
274
- private function _purge_all_cssjs( $silence = false )
275
- {
276
- Optimize::update_option( Optimize::ITEM_TIMESTAMP_PURGE_CSS, time() ) ;
277
 
278
- $this->_add( Tag::TYPE_MIN ) ;
279
 
280
  // For non-ls users
281
- Optimize::get_instance()->rm_cache_folder() ;
282
 
283
  if ( ! $silence ) {
284
- $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' ) ;
285
- ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg ) ;
286
  }
287
  }
288
 
@@ -292,29 +303,28 @@ class Purge extends Base
292
  * @since 1.8.2
293
  * @access public
294
  */
295
- public function purge_all_opcache( $silence = false )
296
- {
297
  if ( ! Router::opcache_enabled() ) {
298
- Debug2::debug( '[Purge] Failed to reset opcode cache due to opcache not enabled' ) ;
299
 
300
  if ( ! $silence ) {
301
- $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' ) ;
302
- Admin_Display::error( $msg ) ;
303
  }
304
 
305
- return false ;
306
  }
307
 
308
  // Purge opcode cache
309
- opcache_reset() ;
310
- Debug2::debug( '[Purge] Reset opcode cache' ) ;
311
 
312
  if ( ! $silence ) {
313
- $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' ) ;
314
- ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg ) ;
315
  }
316
 
317
- return true ;
318
  }
319
 
320
  /**
3
  * The plugin purge class for X-LiteSpeed-Purge
4
  *
5
  * @since 1.1.3
 
6
  * @since 2.2 Refactored. Changed access from public to private for most func and class variables.
7
  */
8
+ namespace LiteSpeed;
9
 
10
+ defined( 'WPINC' ) || exit;
11
 
12
+ class Purge extends Base {
13
+ protected static $_instance;
 
14
 
15
+ protected $_pub_purge = array();
16
+ protected $_priv_purge = array();
17
+ protected $_purge_related = false;
18
+ protected $_purge_single = false;
19
 
20
+ const X_HEADER = 'X-LiteSpeed-Purge';
21
+ const DB_QUEUE = 'queue';
22
 
23
+ const TYPE_PURGE_ALL = 'purge_all';
24
+ const TYPE_PURGE_ALL_LSCACHE = 'purge_all_lscache';
25
+ const TYPE_PURGE_ALL_CSSJS = 'purge_all_cssjs';
26
+ const TYPE_PURGE_ALL_LOCALRES = 'purge_all_localres';
27
+ const TYPE_PURGE_ALL_CCSS = 'purge_all_ccss';
28
+ const TYPE_PURGE_ALL_LQIP = 'purge_all_lqip';
29
+ const TYPE_PURGE_ALL_AVATAR = 'purge_all_avatar';
30
+ const TYPE_PURGE_ALL_OBJECT = 'purge_all_object';
31
+ const TYPE_PURGE_ALL_OPCACHE = 'purge_all_opcache';
32
 
33
+ const TYPE_PURGE_FRONT = 'purge_front';
34
+ const TYPE_PURGE_FRONTPAGE = 'purge_frontpage';
35
+ const TYPE_PURGE_PAGES = 'purge_pages';
36
+ const TYPE_PURGE_ERROR = 'purge_error';
37
 
38
  /**
39
  * Initialize
40
  *
41
  * @since 2.2.3
42
  */
43
+ protected function __construct() {
 
44
  }
45
 
46
  /**
48
  *
49
  * @since 3.0
50
  */
51
+ public function init() {
 
52
  //register purge actions
53
  $purge_post_events = array(
54
  // 'edit_post',
76
  * @since 3.0
77
  * @access public
78
  */
79
+ public static function purge_publish( $new_status, $old_status, $post ) {
 
80
  if ( $new_status != 'publish' && $old_status != 'publish' ) {
81
  return;
82
  }
90
  * @since 1.8
91
  * @access public
92
  */
93
+ public static function handler() {
94
+ $instance = self::get_instance();
 
95
 
96
+ $type = Router::verify_type();
97
 
98
  switch ( $type ) {
99
+ case self::TYPE_PURGE_ALL:
100
+ $instance->_purge_all();
101
+ break;
102
 
103
+ case self::TYPE_PURGE_ALL_LSCACHE:
104
+ $instance->_purge_all_lscache();
105
+ break;
106
 
107
+ case self::TYPE_PURGE_ALL_CSSJS:
108
+ $instance->_purge_all_cssjs();
109
+ break;
110
 
111
+ case self::TYPE_PURGE_ALL_LOCALRES:
112
+ $instance->_purge_all_localres();
113
+ break;
114
 
115
+ case self::TYPE_PURGE_ALL_CCSS:
116
+ $instance->_purge_all_ccss();
117
+ break;
118
 
119
+ case self::TYPE_PURGE_ALL_LQIP:
120
+ $instance->_purge_all_lqip();
121
+ break;
122
 
123
+ case self::TYPE_PURGE_ALL_AVATAR:
124
+ $instance->_purge_all_avatar();
125
+ break;
126
 
127
+ case self::TYPE_PURGE_ALL_OBJECT:
128
+ $instance->_purge_all_object();
129
+ break;
130
 
131
+ case self::TYPE_PURGE_ALL_OPCACHE:
132
+ $instance->purge_all_opcache();
133
+ break;
134
 
135
+ case self::TYPE_PURGE_FRONT:
136
+ $instance->_purge_front();
137
+ break;
138
 
139
+ case self::TYPE_PURGE_FRONTPAGE:
140
+ $instance->_purge_frontpage();
141
+ break;
142
 
143
+ case self::TYPE_PURGE_PAGES:
144
+ $instance->_purge_pages();
145
+ break;
146
+
147
+ case strpos( $type, self::TYPE_PURGE_ERROR ) === 0:
148
+ $instance->_purge_error( substr( $type, strlen( self::TYPE_PURGE_ERROR ) ) );
149
+ break;
150
 
151
  default:
152
+ break;
153
  }
154
 
155
+ Admin::redirect();
156
  }
157
 
158
  /**
161
  * @since 1.0.0
162
  * @access public
163
  */
164
+ public static function purge_all( $reason = false ) {
165
+ self::get_instance()->_purge_all( $reason );
 
166
  }
167
 
168
  /**
171
  * @since 2.2
172
  * @access private
173
  */
174
+ private function _purge_all( $reason = false ) {
175
+ $this->_purge_all_lscache( true );
176
+ $this->_purge_all_cssjs( true );
177
+ $this->_purge_all_localres( true );
178
+ // $this->_purge_all_ccss( true );
179
+ // $this->_purge_all_lqip( true );
180
+ $this->_purge_all_object( true );
181
+ $this->purge_all_opcache( true );
182
 
183
  if ( ! is_string( $reason ) ) {
184
+ $reason = false;
185
  }
186
 
187
  if ( $reason ) {
188
+ $reason = "( $reason )";
189
  }
190
 
191
+ Debug2::debug( '[Purge] Purge all ' . $reason, 3 );
192
 
193
+ $msg = __( 'Purged all caches successfully.', 'litespeed-cache' );
194
+ ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg );
195
 
196
  do_action( 'litespeed_purged_all' );
197
  }
207
  */
208
  private function _purge_all_lscache( $silence = false )
209
  {
210
+ $this->_add( '*' );
211
 
212
  if ( ! $silence ) {
213
  $msg = __( 'Notified LiteSpeed Web Server to purge all LSCache entries.', 'litespeed-cache' ) ;
253
  * @since 3.0
254
  * @access private
255
  */
256
+ private function _purge_all_avatar( $silence = false ) {
 
257
  Avatar::get_instance()->rm_cache_folder() ;
258
 
259
  if ( ! $silence ) {
262
  }
263
  }
264
 
265
+ /**
266
+ * Delete all localized JS
267
+ *
268
+ * @since 3.3
269
+ * @access private
270
+ */
271
+ private function _purge_all_localres( $silence = false ) {
272
+ $this->_add( Tag::TYPE_LOCALRES );
273
+
274
+ if ( ! $silence ) {
275
+ $msg = __( 'Notified LiteSpeed Web Server to purge localized resource entries.', 'litespeed-cache' );
276
+ ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg );
277
+ }
278
+ }
279
+
280
  /**
281
  * Alerts LiteSpeed Web Server to purge pages.
282
  *
283
  * @since 1.2.2
284
  * @access private
285
  */
286
+ private function _purge_all_cssjs( $silence = false ) {
287
+ Optimize::update_option( Optimize::ITEM_TIMESTAMP_PURGE_CSS, time() );
 
288
 
289
+ $this->_add( Tag::TYPE_MIN );
290
 
291
  // For non-ls users
292
+ Optimize::get_instance()->rm_cache_folder();
293
 
294
  if ( ! $silence ) {
295
+ $msg = __( 'Notified LiteSpeed Web Server to purge CSS/JS entries.', 'litespeed-cache' );
296
+ ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg );
297
  }
298
  }
299
 
303
  * @since 1.8.2
304
  * @access public
305
  */
306
+ public function purge_all_opcache( $silence = false ) {
 
307
  if ( ! Router::opcache_enabled() ) {
308
+ Debug2::debug( '[Purge] Failed to reset opcode cache due to opcache not enabled' );
309
 
310
  if ( ! $silence ) {
311
+ $msg = __( 'Opcode cache is not enabled.', 'litespeed-cache' );
312
+ Admin_Display::error( $msg );
313
  }
314
 
315
+ return false;
316
  }
317
 
318
  // Purge opcode cache
319
+ opcache_reset();
320
+ Debug2::debug( '[Purge] Reset opcode cache' );
321
 
322
  if ( ! $silence ) {
323
+ $msg = __( 'Reset the entire opcode cache successfully.', 'litespeed-cache' );
324
+ ! defined( 'LITESPEED_PURGE_SILENT' ) && Admin_Display::succeed( $msg );
325
  }
326
 
327
+ return true;
328
  }
329
 
330
  /**
src/report.cls.php CHANGED
@@ -87,8 +87,7 @@ class Report extends Base
87
  * @since 1.0.12
88
  * @access public
89
  */
90
- public function generate_environment_report($options = null)
91
- {
92
  global $wp_version, $_SERVER ;
93
  $frontend_htaccess = Htaccess::get_frontend_htaccess() ;
94
  $backend_htaccess = Htaccess::get_backend_htaccess() ;
@@ -129,6 +128,15 @@ class Report extends Base
129
 
130
  if ( is_null($options) ) {
131
  $options = Conf::get_instance()->get_options( true );
 
 
 
 
 
 
 
 
 
132
  }
133
 
134
  if ( ! is_null($options) && is_multisite() ) {
87
  * @since 1.0.12
88
  * @access public
89
  */
90
+ public function generate_environment_report( $options = null ) {
 
91
  global $wp_version, $_SERVER ;
92
  $frontend_htaccess = Htaccess::get_frontend_htaccess() ;
93
  $backend_htaccess = Htaccess::get_backend_htaccess() ;
128
 
129
  if ( is_null($options) ) {
130
  $options = Conf::get_instance()->get_options( true );
131
+
132
+ if ( is_multisite() ) {
133
+ $options2 = Conf::get_instance()->get_options();
134
+ foreach ( $options2 as $k => $v ) {
135
+ if ( $options[ $k ] !== $v ) {
136
+ $options[ '[Overwritten] ' . $k ] = $v;
137
+ }
138
+ }
139
+ }
140
  }
141
 
142
  if ( ! is_null($options) && is_multisite() ) {
src/rest.cls.php CHANGED
@@ -56,26 +56,31 @@ class REST extends Instance {
56
  register_rest_route( 'litespeed/v1', '/ip_validate', array(
57
  'methods' => 'POST',
58
  'callback' => array( $this, 'ip_validate' ),
 
59
  ) );
60
 
61
  // Token callback validate
62
  register_rest_route( 'litespeed/v1', '/token', array(
63
  'methods' => 'POST',
64
  'callback' => array( $this, 'token' ),
 
65
  ) );
66
  register_rest_route( 'litespeed/v1', '/token', array(
67
  'methods' => 'GET',
68
  'callback' => array( $this, 'token_get' ),
 
69
  ) );
70
  register_rest_route( 'litespeed/v1', '/ping', array(
71
  'methods' => 'GET',
72
  'callback' => array( $this, 'ping' ),
 
73
  ) );
74
 
75
  // API key callback notification
76
  register_rest_route( 'litespeed/v1', '/apikey', array(
77
  'methods' => 'POST',
78
  'callback' => array( $this, 'apikey' ),
 
79
  ) );
80
 
81
  // Image optm notify_img
@@ -83,6 +88,7 @@ class REST extends Instance {
83
  register_rest_route( 'litespeed/v1', '/notify_img', array(
84
  'methods' => 'POST',
85
  'callback' => array( $this, 'notify_img' ),
 
86
  ) );
87
 
88
  // Image optm check_img
@@ -90,6 +96,7 @@ class REST extends Instance {
90
  register_rest_route( 'litespeed/v1', '/check_img', array(
91
  'methods' => 'POST',
92
  'callback' => array( $this, 'check_img' ),
 
93
  ) );
94
 
95
  }
56
  register_rest_route( 'litespeed/v1', '/ip_validate', array(
57
  'methods' => 'POST',
58
  'callback' => array( $this, 'ip_validate' ),
59
+ 'permission_callback' => '__return_true',
60
  ) );
61
 
62
  // Token callback validate
63
  register_rest_route( 'litespeed/v1', '/token', array(
64
  'methods' => 'POST',
65
  'callback' => array( $this, 'token' ),
66
+ 'permission_callback' => '__return_true',
67
  ) );
68
  register_rest_route( 'litespeed/v1', '/token', array(
69
  'methods' => 'GET',
70
  'callback' => array( $this, 'token_get' ),
71
+ 'permission_callback' => '__return_true',
72
  ) );
73
  register_rest_route( 'litespeed/v1', '/ping', array(
74
  'methods' => 'GET',
75
  'callback' => array( $this, 'ping' ),
76
+ 'permission_callback' => '__return_true',
77
  ) );
78
 
79
  // API key callback notification
80
  register_rest_route( 'litespeed/v1', '/apikey', array(
81
  'methods' => 'POST',
82
  'callback' => array( $this, 'apikey' ),
83
+ 'permission_callback' => '__return_true',
84
  ) );
85
 
86
  // Image optm notify_img
88
  register_rest_route( 'litespeed/v1', '/notify_img', array(
89
  'methods' => 'POST',
90
  'callback' => array( $this, 'notify_img' ),
91
+ 'permission_callback' => '__return_true',
92
  ) );
93
 
94
  // Image optm check_img
96
  register_rest_route( 'litespeed/v1', '/check_img', array(
97
  'methods' => 'POST',
98
  'callback' => array( $this, 'check_img' ),
99
+ 'permission_callback' => '__return_true',
100
  ) );
101
 
102
  }
src/router.cls.php CHANGED
@@ -672,14 +672,18 @@ class Router extends Base
672
  }
673
 
674
  switch ( $path[ 0 ] ) {
675
- case 'avatar' :
676
  Avatar::get_instance()->serve_satic( $path[ 1 ] );
677
  break;
678
 
679
- case 'cssjs' :
680
  Optimize::get_instance()->serve_satic( $path[ 1 ] );
681
  break;
682
 
 
 
 
 
683
  default :
684
  break;
685
  }
672
  }
673
 
674
  switch ( $path[ 0 ] ) {
675
+ case 'avatar':
676
  Avatar::get_instance()->serve_satic( $path[ 1 ] );
677
  break;
678
 
679
+ case 'cssjs':
680
  Optimize::get_instance()->serve_satic( $path[ 1 ] );
681
  break;
682
 
683
+ case 'localres':
684
+ Localization::get_instance()->serve_static( $path[ 1 ] );
685
+ break;
686
+
687
  default :
688
  break;
689
  }
src/str.cls.php CHANGED
@@ -4,12 +4,11 @@
4
  *
5
  * @since 1.3
6
  */
7
- namespace LiteSpeed ;
8
 
9
- defined( 'WPINC' ) || exit ;
10
 
11
- class Str
12
- {
13
 
14
  /**
15
  * Generate random string
@@ -20,53 +19,52 @@ class Str
20
  * @param int $type 1-Number 2-LowerChar 4-UpperChar
21
  * @return string
22
  */
23
- public static function rrand( $len, $type = 7 )
24
- {
25
- mt_srand( ( double ) microtime() * 1000000 ) ;
26
 
27
  switch( $type ) {
28
  case 0 :
29
- $charlist = '012' ;
30
- break ;
31
 
32
  case 1 :
33
- $charlist = '0123456789' ;
34
- break ;
35
 
36
  case 2 :
37
- $charlist = 'abcdefghijklmnopqrstuvwxyz' ;
38
- break ;
39
 
40
  case 3 :
41
- $charlist = '0123456789abcdefghijklmnopqrstuvwxyz' ;
42
- break ;
43
 
44
  case 4 :
45
- $charlist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
46
- break ;
47
 
48
  case 5 :
49
- $charlist = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
50
- break ;
51
 
52
  case 6 :
53
- $charlist = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
54
- break ;
55
 
56
  case 7 :
57
- $charlist = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ;
58
- break ;
59
 
60
  }
61
 
62
- $str = '' ;
63
 
64
- $max = strlen( $charlist ) - 1 ;
65
- for( $i = 0 ; $i < $len ; $i++ ) {
66
- $str .= $charlist[ mt_rand( 0, $max ) ] ;
67
  }
68
 
69
- return $str ;
70
  }
71
 
72
 
4
  *
5
  * @since 1.3
6
  */
7
+ namespace LiteSpeed;
8
 
9
+ defined( 'WPINC' ) || exit;
10
 
11
+ class Str {
 
12
 
13
  /**
14
  * Generate random string
19
  * @param int $type 1-Number 2-LowerChar 4-UpperChar
20
  * @return string
21
  */
22
+ public static function rrand( $len, $type = 7 ) {
23
+ mt_srand( ( double ) microtime() * 1000000 );
 
24
 
25
  switch( $type ) {
26
  case 0 :
27
+ $charlist = '012';
28
+ break;
29
 
30
  case 1 :
31
+ $charlist = '0123456789';
32
+ break;
33
 
34
  case 2 :
35
+ $charlist = 'abcdefghijklmnopqrstuvwxyz';
36
+ break;
37
 
38
  case 3 :
39
+ $charlist = '0123456789abcdefghijklmnopqrstuvwxyz';
40
+ break;
41
 
42
  case 4 :
43
+ $charlist = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
44
+ break;
45
 
46
  case 5 :
47
+ $charlist = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
48
+ break;
49
 
50
  case 6 :
51
+ $charlist = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
52
+ break;
53
 
54
  case 7 :
55
+ $charlist = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
56
+ break;
57
 
58
  }
59
 
60
+ $str = '';
61
 
62
+ $max = strlen( $charlist ) - 1;
63
+ for( $i = 0; $i < $len; $i++ ) {
64
+ $str .= $charlist[ mt_rand( 0, $max ) ];
65
  }
66
 
67
+ return $str;
68
  }
69
 
70
 
src/tag.cls.php CHANGED
@@ -5,38 +5,38 @@
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
7
  */
8
- namespace LiteSpeed ;
9
-
10
- defined( 'WPINC' ) || exit ;
11
-
12
- class Tag extends Instance
13
- {
14
- protected static $_instance ;
15
-
16
- const TYPE_FEED = 'FD' ;
17
- const TYPE_FRONTPAGE = 'F' ;
18
- const TYPE_HOME = 'H' ;
19
- const TYPE_PAGES = 'PGS' ;
20
- const TYPE_PAGES_WITH_RECENT_POSTS = 'PGSRP' ;
21
- const TYPE_HTTP = 'HTTP.' ;
22
- const TYPE_POST = 'Po.' ; // Post. Cannot use P, reserved for litemage.
23
- const TYPE_ARCHIVE_POSTTYPE = 'PT.' ;
24
- const TYPE_ARCHIVE_TERM = 'T.' ; //for is_category|is_tag|is_tax
25
- const TYPE_AUTHOR = 'A.' ;
26
- const TYPE_ARCHIVE_DATE = 'D.' ;
27
- const TYPE_BLOG = 'B.' ;
28
- const TYPE_LOGIN = 'L' ;
29
- const TYPE_URL = 'URL.' ;
30
- const TYPE_WIDGET = 'W.' ;
31
- const TYPE_ESI = 'ESI.' ;
32
- const TYPE_REST = 'REST' ;
33
- const TYPE_LIST = 'LIST' ;
34
- const TYPE_MIN = 'MIN' ;
35
-
36
- const X_HEADER = 'X-LiteSpeed-Tag' ;
37
-
38
- private static $_tags = array() ;
39
- private static $_tags_priv = array( 'tag_priv' ) ;
40
 
41
  /**
42
  * Initialize
5
  * @since 1.1.3
6
  * @since 1.5 Moved into /inc
7
  */
8
+ namespace LiteSpeed;
9
+
10
+ defined( 'WPINC' ) || exit;
11
+
12
+ class Tag extends Instance {
13
+ protected static $_instance;
14
+
15
+ const TYPE_FEED = 'FD';
16
+ const TYPE_FRONTPAGE = 'F';
17
+ const TYPE_HOME = 'H';
18
+ const TYPE_PAGES = 'PGS';
19
+ const TYPE_PAGES_WITH_RECENT_POSTS = 'PGSRP';
20
+ const TYPE_HTTP = 'HTTP.';
21
+ const TYPE_POST = 'Po.'; // Post. Cannot use P, reserved for litemage.
22
+ const TYPE_ARCHIVE_POSTTYPE = 'PT.';
23
+ const TYPE_ARCHIVE_TERM = 'T.'; //for is_category|is_tag|is_tax
24
+ const TYPE_AUTHOR = 'A.';
25
+ const TYPE_ARCHIVE_DATE = 'D.';
26
+ const TYPE_BLOG = 'B.';
27
+ const TYPE_LOGIN = 'L';
28
+ const TYPE_URL = 'URL.';
29
+ const TYPE_WIDGET = 'W.';
30
+ const TYPE_ESI = 'ESI.';
31
+ const TYPE_REST = 'REST';
32
+ const TYPE_LIST = 'LIST';
33
+ const TYPE_MIN = 'MIN';
34
+ const TYPE_LOCALRES = 'LOCALRES';
35
+
36
+ const X_HEADER = 'X-LiteSpeed-Tag';
37
+
38
+ private static $_tags = array();
39
+ private static $_tags_priv = array( 'tag_priv' );
40
 
41
  /**
42
  * Initialize
src/task.cls.php CHANGED
@@ -9,8 +9,7 @@ namespace LiteSpeed;
9
 
10
  defined( 'WPINC' ) || exit;
11
 
12
- class Task extends Instance
13
- {
14
  protected static $_instance;
15
 
16
  private static $_triggers = array(
@@ -31,8 +30,7 @@ class Task extends Instance
31
  * @since 1.6
32
  * @access protected
33
  */
34
- protected function __construct()
35
- {
36
  }
37
 
38
  /**
@@ -41,8 +39,7 @@ class Task extends Instance
41
  * @since 3.0
42
  * @access public
43
  */
44
- public function init()
45
- {
46
  Debug2::debug2( '⏰ Task init' );
47
 
48
  add_filter( 'cron_schedules', array( $this, 'lscache_cron_filter' ) );
@@ -76,8 +73,7 @@ class Task extends Instance
76
  * @since 3.0
77
  * @access public
78
  */
79
- public static function destroy()
80
- {
81
  Utility::compatibility();
82
  array_map( 'wp_clear_scheduled_hook', array_column( self::$_triggers, 'name' ) );
83
  }
@@ -88,8 +84,7 @@ class Task extends Instance
88
  * @since 3.0
89
  * @access public
90
  */
91
- public static function try_clean( $id )
92
- {
93
  // Clean v2's leftover cron ( will remove in v3.1 )
94
  // foreach ( wp_get_ready_cron_jobs() as $hooks ) {
95
  // foreach ( $hooks as $hook => $v ) {
@@ -117,8 +112,7 @@ class Task extends Instance
117
  * @since 1.6.1
118
  * @access public
119
  */
120
- public function lscache_cron_filter( $schedules )
121
- {
122
  if ( ! array_key_exists( self::FITLER, $schedules ) ) {
123
  $schedules[ self::FITLER ] = array(
124
  'interval' => 60,
@@ -134,8 +128,7 @@ class Task extends Instance
134
  * @since 1.1.0
135
  * @access public
136
  */
137
- public function lscache_cron_filter_crawler( $schedules )
138
- {
139
  $interval = Conf::val( Base::O_CRAWLER_RUN_INTERVAL );
140
  // $wp_schedules = wp_get_schedules();
141
  if ( ! array_key_exists( self::FITLER_CRAWLER, $schedules ) ) {
9
 
10
  defined( 'WPINC' ) || exit;
11
 
12
+ class Task extends Instance {
 
13
  protected static $_instance;
14
 
15
  private static $_triggers = array(
30
  * @since 1.6
31
  * @access protected
32
  */
33
+ protected function __construct() {
 
34
  }
35
 
36
  /**
39
  * @since 3.0
40
  * @access public
41
  */
42
+ public function init() {
 
43
  Debug2::debug2( '⏰ Task init' );
44
 
45
  add_filter( 'cron_schedules', array( $this, 'lscache_cron_filter' ) );
73
  * @since 3.0
74
  * @access public
75
  */
76
+ public static function destroy() {
 
77
  Utility::compatibility();
78
  array_map( 'wp_clear_scheduled_hook', array_column( self::$_triggers, 'name' ) );
79
  }
84
  * @since 3.0
85
  * @access public
86
  */
87
+ public static function try_clean( $id ) {
 
88
  // Clean v2's leftover cron ( will remove in v3.1 )
89
  // foreach ( wp_get_ready_cron_jobs() as $hooks ) {
90
  // foreach ( $hooks as $hook => $v ) {
112
  * @since 1.6.1
113
  * @access public
114
  */
115
+ public function lscache_cron_filter( $schedules ) {
 
116
  if ( ! array_key_exists( self::FITLER, $schedules ) ) {
117
  $schedules[ self::FITLER ] = array(
118
  'interval' => 60,
128
  * @since 1.1.0
129
  * @access public
130
  */
131
+ public function lscache_cron_filter_crawler( $schedules ) {
 
132
  $interval = Conf::val( Base::O_CRAWLER_RUN_INTERVAL );
133
  // $wp_schedules = wp_get_schedules();
134
  if ( ! array_key_exists( self::FITLER_CRAWLER, $schedules ) ) {
src/utility.cls.php CHANGED
@@ -505,6 +505,20 @@ class Utility extends Instance {
505
  return '//' . $url[ 'host' ] ;
506
  }
507
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
508
  /**
509
  * Generate domain const
510
  *
@@ -536,8 +550,7 @@ class Utility extends Instance {
536
  * @param bool $type String handler type
537
  * @return string
538
  */
539
- public static function sanitize_lines( $arr, $type = null )
540
- {
541
  if ( ! $arr ) {
542
  if ( $type === 'string' ) {
543
  return '' ;
@@ -564,6 +577,11 @@ class Utility extends Instance {
564
  $changed = true ;
565
  }
566
 
 
 
 
 
 
567
  if ( $changed ) {
568
  $arr = array_map( 'trim', $arr ) ;
569
  }
505
  return '//' . $url[ 'host' ] ;
506
  }
507
 
508
+ /**
509
+ * Drop protocol `https:` from https://example.com
510
+ *
511
+ * @since 3.3
512
+ */
513
+ public static function noprotocol( $url ) {
514
+ $tmp = parse_url( trim( $url ) );
515
+ if ( ! empty( $tmp[ 'scheme' ] ) ) {
516
+ $url = str_replace( $tmp[ 'scheme' ] . ':', '', $url );
517
+ }
518
+
519
+ return $url;
520
+ }
521
+
522
  /**
523
  * Generate domain const
524
  *
550
  * @param bool $type String handler type
551
  * @return string
552
  */
553
+ public static function sanitize_lines( $arr, $type = null ) {
 
554
  if ( ! $arr ) {
555
  if ( $type === 'string' ) {
556
  return '' ;
577
  $changed = true ;
578
  }
579
 
580
+ if ( $type === 'noprotocol' ) {
581
+ $arr = array_map( __CLASS__ . '::noprotocol', $arr ); // Drop protocol, `https://example.com` -> `//example.com`
582
+ $changed = true;
583
+ }
584
+
585
  if ( $changed ) {
586
  $arr = array_map( 'trim', $arr ) ;
587
  }
thirdparty/woocommerce.content.tpl.php CHANGED
@@ -1,30 +1,31 @@
1
  <?php
2
- namespace LiteSpeed\Thirdparty ;
3
 
4
- defined( 'WPINC' ) || exit ;
5
 
6
- use \LiteSpeed\API ;
7
- use \LiteSpeed\Admin_Display ;
 
8
  ?>
9
 
10
  <div data-litespeed-layout='woocommerce'>
11
 
12
  <h3 class="litespeed-title-short">
13
- <?php echo __( 'WooCommerce Settings', 'litespeed-cache' ) ; ?>
14
- <?php Admin_Display::get_instance()->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#woocommerce-tab', false, 'litespeed-learn-more' ) ; ?>
15
  </h3>
16
 
17
  <div class="litespeed-callout notice notice-warning inline">
18
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
19
- <p><?php echo __( 'After verifying that the cache works in general, please test the cart.', 'litespeed-cache' ) ; ?></p>
20
- <p><?php echo sprintf( __( 'To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache' ), 'href="https://docs.litespeedtech.com/lscache/lscwp/installation/#testing" target="_blank"' ) ; ?></p>
21
  </div>
22
 
23
  <table class="wp-list-table striped litespeed-table"><tbody>
24
  <tr>
25
  <th>
26
- <?php $id = self::O_UPDATE_INTERVAL ; ?>
27
- <?php echo __( 'Product Update Interval', 'litespeed-cache' ) ; ?>
28
  </th>
29
  <td>
30
  <?php
@@ -33,46 +34,46 @@ use \LiteSpeed\Admin_Display ;
33
  self::O_PS_CS => __( 'Purge product and categories only when the stock status changes.', 'litespeed-cache' ),
34
  self::O_PS_CN => __( 'Purge product only when the stock status changes.', 'litespeed-cache' ) . ' ' . __( 'Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache' ),
35
  self::O_PQS_CQS => __( 'Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache' ),
36
- ) ;
37
  $conf = (int) apply_filters( 'litespeed_conf', $id );
38
  foreach ( $options as $k => $v ) :
39
- $checked = (int) $k === $conf ? ' checked ' : '' ;
40
  ?>
41
  <?php do_action( 'litespeed_setting_enroll', $id ); ?>
42
  <div class='litespeed-radio-row'>
43
- <input type='radio' autocomplete='off' name='<?php echo $id ; ?>' id='conf_<?php echo $id ; ?>_<?php echo $k ; ?>' value='<?php echo $k ; ?>' <?php echo $checked ; ?> />
44
- <label for='conf_<?php echo $id ; ?>_<?php echo $k ; ?>'><?php echo $v ; ?></label>
45
  </div>
46
- <?php endforeach ; ?>
47
  <div class="litespeed-desc">
48
- <?php echo __( 'Determines how changes in product quantity and product stock status affect product pages and their associated category pages.', 'litespeed-cache' ) ; ?>
49
  </div>
50
  </td>
51
  </tr>
52
 
53
  <tr>
54
  <th>
55
- <?php $id = self::O_SHOP_FRONT_TTL ; ?>
56
- <?php echo __( 'Use Front Page TTL for the Shop Page', 'litespeed-cache' ) ; ?>
57
  </th>
58
  <td>
59
  <?php do_action( 'litespeed_build_switch', $id ); ?>
60
  <div class="litespeed-desc">
61
- <?php echo __( 'Checking this option will force the shop page to use the front page TTL setting.', 'litespeed-cache' ) ; ?>
62
- <?php echo sprintf( __( 'For example, if the homepage for the site is located at %1$s, the shop page may be located at %2$s.', 'litespeed-cache' ), 'https://www.EXAMPLE.com', 'https://www.EXAMPLE.com/shop' ) ; ?>
63
  </div>
64
  </td>
65
  </tr>
66
 
67
  <tr>
68
  <th>
69
- <?php $id = self::O_WOO_CACHE_CART ; ?>
70
- <?php echo __( 'Privately Cache Cart', 'litespeed-cache' ) ; ?>
71
  </th>
72
  <td>
73
  <?php do_action( 'litespeed_build_switch', $id ); ?>
74
  <div class="litespeed-desc">
75
- <?php echo __( 'Privately cache cart when not empty.', 'litespeed-cache' ) ; ?>
76
  </div>
77
  </td>
78
  </tr>
1
  <?php
2
+ namespace LiteSpeed\Thirdparty;
3
 
4
+ defined( 'WPINC' ) || exit;
5
 
6
+ use \LiteSpeed\API;
7
+ use \LiteSpeed\Doc;
8
+ use \LiteSpeed\Admin_Display;
9
  ?>
10
 
11
  <div data-litespeed-layout='woocommerce'>
12
 
13
  <h3 class="litespeed-title-short">
14
+ <?php echo __( 'WooCommerce Settings', 'litespeed-cache' ); ?>
15
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#woocommerce-tab' ); ?>
16
  </h3>
17
 
18
  <div class="litespeed-callout notice notice-warning inline">
19
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
20
+ <p><?php echo __( 'After verifying that the cache works in general, please test the cart.', 'litespeed-cache' ); ?></p>
21
+ <p><?php echo sprintf( __( 'To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache' ), 'href="https://docs.litespeedtech.com/lscache/lscwp/installation/#testing" target="_blank"' ); ?></p>
22
  </div>
23
 
24
  <table class="wp-list-table striped litespeed-table"><tbody>
25
  <tr>
26
  <th>
27
+ <?php $id = self::O_UPDATE_INTERVAL; ?>
28
+ <?php echo __( 'Product Update Interval', 'litespeed-cache' ); ?>
29
  </th>
30
  <td>
31
  <?php
34
  self::O_PS_CS => __( 'Purge product and categories only when the stock status changes.', 'litespeed-cache' ),
35
  self::O_PS_CN => __( 'Purge product only when the stock status changes.', 'litespeed-cache' ) . ' ' . __( 'Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache' ),
36
  self::O_PQS_CQS => __( 'Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache' ),
37
+ );
38
  $conf = (int) apply_filters( 'litespeed_conf', $id );
39
  foreach ( $options as $k => $v ) :
40
+ $checked = (int) $k === $conf ? ' checked ' : '';
41
  ?>
42
  <?php do_action( 'litespeed_setting_enroll', $id ); ?>
43
  <div class='litespeed-radio-row'>
44
+ <input type='radio' autocomplete='off' name='<?php echo $id; ?>' id='conf_<?php echo $id; ?>_<?php echo $k; ?>' value='<?php echo $k; ?>' <?php echo $checked; ?> />
45
+ <label for='conf_<?php echo $id; ?>_<?php echo $k; ?>'><?php echo $v; ?></label>
46
  </div>
47
+ <?php endforeach; ?>
48
  <div class="litespeed-desc">
49
+ <?php echo __( 'Determines how changes in product quantity and product stock status affect product pages and their associated category pages.', 'litespeed-cache' ); ?>
50
  </div>
51
  </td>
52
  </tr>
53
 
54
  <tr>
55
  <th>
56
+ <?php $id = self::O_SHOP_FRONT_TTL; ?>
57
+ <?php echo __( 'Use Front Page TTL for the Shop Page', 'litespeed-cache' ); ?>
58
  </th>
59
  <td>
60
  <?php do_action( 'litespeed_build_switch', $id ); ?>
61
  <div class="litespeed-desc">
62
+ <?php echo __( 'Checking this option will force the shop page to use the front page TTL setting.', 'litespeed-cache' ); ?>
63
+ <?php echo sprintf( __( 'For example, if the homepage for the site is located at %1$s, the shop page may be located at %2$s.', 'litespeed-cache' ), 'https://www.EXAMPLE.com', 'https://www.EXAMPLE.com/shop' ); ?>
64
  </div>
65
  </td>
66
  </tr>
67
 
68
  <tr>
69
  <th>
70
+ <?php $id = self::O_WOO_CACHE_CART; ?>
71
+ <?php echo __( 'Privately Cache Cart', 'litespeed-cache' ); ?>
72
  </th>
73
  <td>
74
  <?php do_action( 'litespeed_build_switch', $id ); ?>
75
  <div class="litespeed-desc">
76
+ <?php echo __( 'Privately cache cart when not empty.', 'litespeed-cache' ); ?>
77
  </div>
78
  </td>
79
  </tr>
tpl/cache/network_settings-advanced.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Advanced Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#advanced-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Advanced Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#advanced-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/network_settings-cache.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Cache Control Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Cache Control Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/network_settings-excludes.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Exclude Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#excludes-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Exclude Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#excludes-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/network_settings-purge.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Purge Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Purge Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/settings-advanced.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Advanced Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#advanced-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <div class="litespeed-callout notice notice-warning inline">
@@ -30,7 +30,7 @@ defined( 'WPINC' ) || exit;
30
  <?php $this->build_switch( $id ); ?>
31
  <div class="litespeed-desc">
32
  <?php echo __( 'Enable this option if you are using both HTTP and HTTPS in the same domain and are noticing cache irregularities.', 'litespeed-cache' ); ?>
33
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#improve-httphttps-compatibility' ); ?>
34
  </div>
35
  </td>
36
  </tr>
@@ -44,7 +44,7 @@ defined( 'WPINC' ) || exit;
44
  <?php $this->build_switch( $id ); ?>
45
  <div class="litespeed-desc">
46
  <?php echo __( 'When a vistor hovers over a page link, preload that page. This will speed up the visit to that link.', 'litespeed-cache' ); ?>
47
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#instant-click' ); ?>
48
  <br /><font class="litespeed-danger">
49
  ⚠️
50
  <?php echo __( 'This will generate extra requests to the server, which will increase server load.', 'litespeed-cache' ); ?>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Advanced Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#advanced-tab' ); ?>
9
  </h3>
10
 
11
  <div class="litespeed-callout notice notice-warning inline">
30
  <?php $this->build_switch( $id ); ?>
31
  <div class="litespeed-desc">
32
  <?php echo __( 'Enable this option if you are using both HTTP and HTTPS in the same domain and are noticing cache irregularities.', 'litespeed-cache' ); ?>
33
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#improve-httphttps-compatibility' ); ?>
34
  </div>
35
  </td>
36
  </tr>
44
  <?php $this->build_switch( $id ); ?>
45
  <div class="litespeed-desc">
46
  <?php echo __( 'When a vistor hovers over a page link, preload that page. This will speed up the visit to that link.', 'litespeed-cache' ); ?>
47
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#instant-click' ); ?>
48
  <br /><font class="litespeed-danger">
49
  ⚠️
50
  <?php echo __( 'This will generate extra requests to the server, which will increase server load.', 'litespeed-cache' ); ?>
tpl/cache/settings-cache.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Cache Control Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Cache Control Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/settings-esi.tpl.php CHANGED
@@ -5,13 +5,13 @@ defined( 'WPINC' ) || exit ;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'ESI Settings', 'litespeed-cache' ) ; ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#esi-tab', false, 'litespeed-learn-more' ) ; ?>
9
  </h3>
10
 
11
  <div class="litespeed-description">
12
  <p><?php echo __( 'With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache' ) ; ?></p>
13
  <p><?php echo __( 'ESI allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. In other words, ESI lets you “punch holes” in a page, and then fill those holes with content that may be cached privately, cached publicly with its own TTL, or not cached at all.', 'litespeed-cache' ) ; ?>
14
- <?php $this->learn_more( 'https://blog.litespeedtech.com/2017/08/30/wpw-private-cache-vs-public-cache/', __( 'WpW: Private Cache vs. Public Cache', 'litespeed-cache' ) ) ; ?>
15
  </p>
16
  <p>
17
  💡:
@@ -21,10 +21,10 @@ defined( 'WPINC' ) || exit ;
21
  '<code>[shortcodeA att1="val1" att2="val2"]</code>',
22
  '<code>[esi shortcodeA att1="val1" att2="val2"]</code>'
23
  ) ; ?>
24
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#turning-wordpress-shortcodes-into-esi-blocks' ) ; ?>
25
  </p>
26
  <p>
27
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url', __( 'ESI sample for developers', 'litespeed-cache' ) ) ; ?>
28
  </p>
29
  </div>
30
 
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'ESI Settings', 'litespeed-cache' ) ; ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#esi-tab' ); ?>
9
  </h3>
10
 
11
  <div class="litespeed-description">
12
  <p><?php echo __( 'With ESI (Edge Side Includes), pages may be served from cache for logged-in users.', 'litespeed-cache' ) ; ?></p>
13
  <p><?php echo __( 'ESI allows you to designate parts of your dynamic page as separate fragments that are then assembled together to make the whole page. In other words, ESI lets you “punch holes” in a page, and then fill those holes with content that may be cached privately, cached publicly with its own TTL, or not cached at all.', 'litespeed-cache' ) ; ?>
14
+ <?php Doc::learn_more( 'https://blog.litespeedtech.com/2017/08/30/wpw-private-cache-vs-public-cache/', __( 'WpW: Private Cache vs. Public Cache', 'litespeed-cache' ) ); ?>
15
  </p>
16
  <p>
17
  💡:
21
  '<code>[shortcodeA att1="val1" att2="val2"]</code>',
22
  '<code>[esi shortcodeA att1="val1" att2="val2"]</code>'
23
  ) ; ?>
24
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#turning-wordpress-shortcodes-into-esi-blocks' ); ?>
25
  </p>
26
  <p>
27
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/api/#generate-esi-block-url', __( 'ESI sample for developers', 'litespeed-cache' ) ); ?>
28
  </p>
29
  </div>
30
 
tpl/cache/settings-excludes.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Exclude Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#excludes-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Exclude Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#excludes-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/cache/settings-purge.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Purge Settings', 'litespeed-cache' ); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-tab', false, 'litespeed-learn-more' ); ?>
9
  </h3>
10
 
11
  <?php
@@ -83,7 +83,7 @@ $break_arr = array(
83
  <?php $this->build_switch( $id ); ?>
84
  <div class="litespeed-desc">
85
  <?php echo __( 'If ON, stale copy of cached page will be shown to visitor until a new cache copy is available. Reduces the server load for following visits. If OFF, page will be dynamically generated while visitor waits.', 'litespeed-cache' ); ?>
86
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#serve-stale' ); ?>
87
  </div>
88
  <div class="litespeed-callout notice notice-warning inline">
89
  <h4><?php echo __( 'Note', 'litespeed-cache' ); ?></h4>
@@ -107,13 +107,13 @@ $break_arr = array(
107
  <?php Doc::one_per_line(); ?>
108
  </div>
109
  <div class="litespeed-desc">
110
- <?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>/path/u-1.html</code>', '<code>/path/u-2.html</code>', '<code>/path/u-*.html</code>' ) ; ?>
111
  </div>
112
  <div class="litespeed-callout notice notice-warning inline">
113
  <h4><?php echo __( 'Note', 'litespeed-cache' ); ?></h4>
114
  <p>
115
  <?php echo __( 'For URLs with wildcards, there may be a delay in initiating scheduled purge.', 'litespeed-cache' ); ?><br />
116
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#scheduled-purge-urls' ); ?>
117
  </p>
118
  </div>
119
  </td>
@@ -142,16 +142,16 @@ $break_arr = array(
142
 
143
  <div class="litespeed-textarea-recommended">
144
  <div>
145
- <?php $this->build_textarea( $id, 50 ) ; ?>
146
  </div>
147
  <div>
148
- <?php $this->recommended( $id, true ) ; ?>
149
  </div>
150
  </div>
151
 
152
  <div class="litespeed-desc">
153
  <?php echo __( 'A Purge All will be executed when WordPress runs these hooks.', 'litespeed-cache' ); ?>
154
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-all-hooks' ); ?>
155
  </div>
156
  </td>
157
  </tr>
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'Purge Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-tab' ); ?>
9
  </h3>
10
 
11
  <?php
83
  <?php $this->build_switch( $id ); ?>
84
  <div class="litespeed-desc">
85
  <?php echo __( 'If ON, stale copy of cached page will be shown to visitor until a new cache copy is available. Reduces the server load for following visits. If OFF, page will be dynamically generated while visitor waits.', 'litespeed-cache' ); ?>
86
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#serve-stale' ); ?>
87
  </div>
88
  <div class="litespeed-callout notice notice-warning inline">
89
  <h4><?php echo __( 'Note', 'litespeed-cache' ); ?></h4>
107
  <?php Doc::one_per_line(); ?>
108
  </div>
109
  <div class="litespeed-desc">
110
+ <?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>/path/u-1.html</code>', '<code>/path/u-2.html</code>', '<code>/path/u-*.html</code>' ); ?>
111
  </div>
112
  <div class="litespeed-callout notice notice-warning inline">
113
  <h4><?php echo __( 'Note', 'litespeed-cache' ); ?></h4>
114
  <p>
115
  <?php echo __( 'For URLs with wildcards, there may be a delay in initiating scheduled purge.', 'litespeed-cache' ); ?><br />
116
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#scheduled-purge-urls' ); ?>
117
  </p>
118
  </div>
119
  </td>
142
 
143
  <div class="litespeed-textarea-recommended">
144
  <div>
145
+ <?php $this->build_textarea( $id, 50 ); ?>
146
  </div>
147
  <div>
148
+ <?php $this->recommended( $id ); ?>
149
  </div>
150
  </div>
151
 
152
  <div class="litespeed-desc">
153
  <?php echo __( 'A Purge All will be executed when WordPress runs these hooks.', 'litespeed-cache' ); ?>
154
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#purge-all-hooks' ); ?>
155
  </div>
156
  </td>
157
  </tr>
tpl/cache/settings-ttl.tpl.php CHANGED
@@ -5,7 +5,7 @@ defined( 'WPINC' ) || exit ;
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'TTL', 'litespeed-cache' ) ; ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#ttl-tab', false, 'litespeed-learn-more' ) ; ?>
9
  </h3>
10
 
11
 
5
 
6
  <h3 class="litespeed-title-short">
7
  <?php echo __( 'TTL', 'litespeed-cache' ) ; ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#ttl-tab' ); ?>
9
  </h3>
10
 
11
 
tpl/cache/settings_inc.browser.tpl.php CHANGED
@@ -4,14 +4,14 @@ defined( 'WPINC' ) || exit;
4
  ?>
5
  <h3 class="litespeed-title-short">
6
  <?php echo __( 'Browser Cache Settings', 'litespeed-cache' ); ?>
7
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#browser-tab', false, 'litespeed-learn-more' ); ?>
8
  </h3>
9
 
10
  <?php if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) : ?>
11
  <div class="litespeed-callout notice notice-warning inline">
12
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
13
  <p><?php echo __( 'OpenLiteSpeed users please check this', 'litespeed-cache' ); ?>:
14
- <?php $this->learn_more( 'https://openlitespeed.org/kb/how-to-set-up-custom-headers/', 'Setting Up Custom Headers' ); ?></p>
15
  </div>
16
  <?php endif; ?>
17
 
4
  ?>
5
  <h3 class="litespeed-title-short">
6
  <?php echo __( 'Browser Cache Settings', 'litespeed-cache' ); ?>
7
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#browser-tab' ); ?>
8
  </h3>
9
 
10
  <?php if ( LITESPEED_SERVER_TYPE === 'LITESPEED_SERVER_OLS' ) : ?>
11
  <div class="litespeed-callout notice notice-warning inline">
12
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
13
  <p><?php echo __( 'OpenLiteSpeed users please check this', 'litespeed-cache' ); ?>:
14
+ <?php Doc::learn_more( 'https://openlitespeed.org/kb/how-to-set-up-custom-headers/', __( 'Setting Up Custom Headers', 'litespeed-cache' ) ); ?></p>
15
  </div>
16
  <?php endif; ?>
17
 
tpl/cache/settings_inc.cache_dropquery.tpl.php CHANGED
@@ -13,7 +13,7 @@ defined( 'WPINC' ) || exit ;
13
  <div class="litespeed-desc">
14
  <?php echo sprintf( __( 'Ignore certain query strings when caching. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.3+' ); ?>
15
  <?php echo sprintf( __( 'For example, to drop parameters beginning with %s, %s can be used here.', 'litespeed-cache' ), '<code>utm</code>', '<code>utm*</code>' ); ?>
16
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#drop-query-string' ); ?>
17
 
18
  <br />
19
  <?php Doc::one_per_line(); ?>
13
  <div class="litespeed-desc">
14
  <?php echo sprintf( __( 'Ignore certain query strings when caching. (LSWS %s required)', 'litespeed-cache' ), 'v5.2.3+' ); ?>
15
  <?php echo sprintf( __( 'For example, to drop parameters beginning with %s, %s can be used here.', 'litespeed-cache' ), '<code>utm</code>', '<code>utm*</code>' ); ?>
16
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#drop-query-string' ); ?>
17
 
18
  <br />
19
  <?php Doc::one_per_line(); ?>
tpl/cache/settings_inc.cache_mobile.tpl.php CHANGED
@@ -1,31 +1,31 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
  ?>
6
 
7
  <!-- build_setting_mobile_view start -->
8
  <tr>
9
  <th>
10
- <?php $id = Base::O_CACHE_MOBILE ; ?>
11
- <?php $this->title( $id ) ; ?>
12
  </th>
13
  <td>
14
  <?php
15
- $this->build_switch( $id ) ;
16
  ?>
17
  <div class="litespeed-desc">
18
- <?php echo __( 'Cache mobile views separately.', 'litespeed-cache' ) ; ?>
19
- <?php echo __( 'Only enable for AMP or mobile-specific design/content, not for responsive sites.', 'litespeed-cache' ) ; ?>
20
- <br /><?php Doc::notice_htaccess() ; ?>
21
  </div>
22
  </td>
23
  </tr>
24
 
25
  <tr>
26
  <th class="litespeed-padding-left">
27
- <?php $id = Base::O_CACHE_MOBILE_RULES ; ?>
28
- <?php $this->title( $id ) ; ?>
29
  </th>
30
  <td>
31
  <?php
@@ -36,15 +36,15 @@ defined( 'WPINC' ) || exit ;
36
  if ( defined( 'LITESPEED_ON' ) ) {
37
 
38
  try {
39
- $mobile_agents = Htaccess::get_instance()->current_mobile_agents() ;
40
  if ( $mobile_agents !== Utility::arr2regex( Conf::val( $id ), true ) ) {
41
  echo '<div class="litespeed-callout notice notice-error inline"><p>'
42
  . __( 'Htaccess did not match configuration option.', 'litespeed-cache' )
43
  . ' ' . sprintf( __( 'Htaccess rule is: %s', 'litespeed-cache' ), '<code>' . $mobile_agents . '</code>' )
44
- . '</p></div>' ;
45
  }
46
  } catch( \Exception $e ) {
47
- echo '<div class="litespeed-callout notice notice-error inline"><p>' . $e->getMessage() . '</p></div>' ;
48
  }
49
 
50
  }
@@ -52,24 +52,24 @@ defined( 'WPINC' ) || exit ;
52
 
53
  <div class="litespeed-textarea-recommended">
54
  <div>
55
- <?php $this->build_textarea( $id, 40 ) ; ?>
56
  </div>
57
  <div>
58
- <?php $this->recommended( $id, true ) ; ?>
59
  </div>
60
  </div>
61
 
62
  <div class="litespeed-desc">
63
- <?php Doc::one_per_line() ; ?>
64
 
65
- <?php $this->_validate_syntax( $id ) ; ?>
66
 
67
  <?php if ( Conf::val( Base::O_CACHE_MOBILE ) && ! Conf::val( $id ) ) : ?>
68
  <font class="litespeed-warning">
69
 
70
- <?php echo sprintf( __( 'If %1$s is %2$s, then %3$s must be populated!', 'litespeed-cache' ), '<code>' . __('Cache Mobile', 'litespeed-cache') . '</code>', '<code>' . __('ON', 'litespeed-cache') . '</code>', '<code>' . __('List of Mobile User Agents', 'litespeed-cache') . '</code>' ) ; ?>
71
  </font>
72
- <?php endif ; ?>
73
  </div>
74
  </td>
75
  </tr>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
  ?>
6
 
7
  <!-- build_setting_mobile_view start -->
8
  <tr>
9
  <th>
10
+ <?php $id = Base::O_CACHE_MOBILE; ?>
11
+ <?php $this->title( $id ); ?>
12
  </th>
13
  <td>
14
  <?php
15
+ $this->build_switch( $id );
16
  ?>
17
  <div class="litespeed-desc">
18
+ <?php echo __( 'Cache mobile views separately.', 'litespeed-cache' ); ?>
19
+ <?php echo __( 'Only enable for AMP or mobile-specific design/content, not for responsive sites.', 'litespeed-cache' ); ?>
20
+ <br /><?php Doc::notice_htaccess(); ?>
21
  </div>
22
  </td>
23
  </tr>
24
 
25
  <tr>
26
  <th class="litespeed-padding-left">
27
+ <?php $id = Base::O_CACHE_MOBILE_RULES; ?>
28
+ <?php $this->title( $id ); ?>
29
  </th>
30
  <td>
31
  <?php
36
  if ( defined( 'LITESPEED_ON' ) ) {
37
 
38
  try {
39
+ $mobile_agents = Htaccess::get_instance()->current_mobile_agents();
40
  if ( $mobile_agents !== Utility::arr2regex( Conf::val( $id ), true ) ) {
41
  echo '<div class="litespeed-callout notice notice-error inline"><p>'
42
  . __( 'Htaccess did not match configuration option.', 'litespeed-cache' )
43
  . ' ' . sprintf( __( 'Htaccess rule is: %s', 'litespeed-cache' ), '<code>' . $mobile_agents . '</code>' )
44
+ . '</p></div>';
45
  }
46
  } catch( \Exception $e ) {
47
+ echo '<div class="litespeed-callout notice notice-error inline"><p>' . $e->getMessage() . '</p></div>';
48
  }
49
 
50
  }
52
 
53
  <div class="litespeed-textarea-recommended">
54
  <div>
55
+ <?php $this->build_textarea( $id, 40 ); ?>
56
  </div>
57
  <div>
58
+ <?php $this->recommended( $id ); ?>
59
  </div>
60
  </div>
61
 
62
  <div class="litespeed-desc">
63
+ <?php Doc::one_per_line(); ?>
64
 
65
+ <?php $this->_validate_syntax( $id ); ?>
66
 
67
  <?php if ( Conf::val( Base::O_CACHE_MOBILE ) && ! Conf::val( $id ) ) : ?>
68
  <font class="litespeed-warning">
69
 
70
+ <?php echo sprintf( __( 'If %1$s is %2$s, then %3$s must be populated!', 'litespeed-cache' ), '<code>' . __('Cache Mobile', 'litespeed-cache') . '</code>', '<code>' . __('ON', 'litespeed-cache') . '</code>', '<code>' . __('List of Mobile User Agents', 'litespeed-cache') . '</code>' ); ?>
71
  </font>
72
+ <?php endif; ?>
73
  </div>
74
  </td>
75
  </tr>
tpl/cache/settings_inc.object.tpl.php CHANGED
@@ -25,7 +25,7 @@ else {
25
 
26
  <h3 class="litespeed-title-short">
27
  <?php echo __( 'Object Cache Settings', 'litespeed-cache' ) ; ?>
28
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#object-tab', false, 'litespeed-learn-more' ) ; ?>
29
  </h3>
30
 
31
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -39,7 +39,7 @@ else {
39
  <?php $this->build_switch( $id ) ; ?>
40
  <div class="litespeed-desc">
41
  <?php echo __( 'Use object cache functionality.', 'litespeed-cache' ) ; ?>
42
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#memcached-lsmcd-and-redis-object-cache-support-in-lscwp' ) ; ?>
43
  </div>
44
  <div class="litespeed-block">
45
 
@@ -50,7 +50,7 @@ else {
50
  <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Memcached' ) ; ?>: <?php echo $mem_enabled ; ?><br />
51
  <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Redis' ) ; ?>: <?php echo $redis_enabled ; ?><br />
52
  <?php echo __( 'Connection Test', 'litespeed-cache' ) ; ?>: <?php echo $mem_conn_desc ; ?>
53
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#how-to-debug' ) ; ?>
54
  </div>
55
 
56
  </div>
@@ -209,7 +209,7 @@ else {
209
  <div class="litespeed-desc">
210
  <?php echo sprintf( __( 'Save transients in database when %1$s is %2$s.', 'litespeed-cache' ), '<code>' . Lang::title( Base::O_OBJECT_ADMIN ) . '</code>', '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?>
211
  <br />
212
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#store-transients' ) ; ?>
213
  </div>
214
  </td>
215
  </tr>
25
 
26
  <h3 class="litespeed-title-short">
27
  <?php echo __( 'Object Cache Settings', 'litespeed-cache' ) ; ?>
28
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#object-tab' ); ?>
29
  </h3>
30
 
31
  <table class="wp-list-table striped litespeed-table"><tbody>
39
  <?php $this->build_switch( $id ) ; ?>
40
  <div class="litespeed-desc">
41
  <?php echo __( 'Use object cache functionality.', 'litespeed-cache' ) ; ?>
42
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#memcached-lsmcd-and-redis-object-cache-support-in-lscwp' ); ?>
43
  </div>
44
  <div class="litespeed-block">
45
 
50
  <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Memcached' ) ; ?>: <?php echo $mem_enabled ; ?><br />
51
  <?php echo sprintf( __( '%s Extension', 'litespeed-cache' ), 'Redis' ) ; ?>: <?php echo $redis_enabled ; ?><br />
52
  <?php echo __( 'Connection Test', 'litespeed-cache' ) ; ?>: <?php echo $mem_conn_desc ; ?>
53
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/admin/#how-to-debug' ); ?>
54
  </div>
55
 
56
  </div>
209
  <div class="litespeed-desc">
210
  <?php echo sprintf( __( 'Save transients in database when %1$s is %2$s.', 'litespeed-cache' ), '<code>' . Lang::title( Base::O_OBJECT_ADMIN ) . '</code>', '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>' ) ; ?>
211
  <br />
212
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#store-transients' ); ?>
213
  </div>
214
  </td>
215
  </tr>
tpl/cdn/settings.tpl.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
- $home_url = home_url( '/' ) ;
6
- $parsed = parse_url( $home_url ) ;
7
- $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url ) ;
8
- $cdn_url = 'https://cdn.' . substr( $home_url, 2 ) ;
9
 
10
  $cdn_mapping = Conf::val( Base::O_CDN_MAPPING );
11
  // Special handler: Append one row if somehow the DB default preset value got deleted
@@ -14,39 +14,39 @@ if ( ! $cdn_mapping ) {
14
  $cdn_mapping = self::$_default_options[ Base::O_CDN_MAPPING ];
15
  }
16
 
17
- $this->form_action() ;
18
  ?>
19
 
20
  <h3 class="litespeed-title-short">
21
- <?php echo __( 'CDN Settings', 'litespeed-cache' ) ; ?>
22
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/', false, 'litespeed-learn-more' ) ; ?>
23
  </h3>
24
 
25
  <table class="wp-list-table striped litespeed-table"><tbody>
26
 
27
  <tr>
28
  <th>
29
- <?php $id = Base::O_CDN_QUIC ; ?>
30
- <?php $this->title( $id ) ; ?>
31
  </th>
32
  <td>
33
- <?php $this->build_switch( $id ) ; ?>
34
  <div class="litespeed-desc">
35
- <?php echo sprintf( __( 'Enable %s CDN API functionality.', 'litespeed-cache' ), 'QUIC.cloud' ) ; ?>
36
  </div>
37
  </td>
38
  </tr>
39
 
40
  <tr>
41
  <th>
42
- <?php $id = Base::O_CDN ; ?>
43
- <?php $this->title( $id ) ; ?>
44
  </th>
45
  <td>
46
- <?php $this->build_switch( $id ) ; ?>
47
  <div class="litespeed-desc">
48
- <?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ) ; ?>
49
- <?php echo sprintf( __( 'Leave this setting %1$s if you have QUIC.cloud CDN or Cloudflare API turned %2$s.', 'litespeed-cache' ), '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>', '<code>' . __( 'ON', 'litespeed-cache' ) . '</code>' ) ; ?>
50
  </div>
51
  </td>
52
  </tr>
@@ -59,62 +59,62 @@ $this->form_action() ;
59
  <div class="litespeed-block" data-litespeed-cdn-mapping="1">
60
  <div class='litespeed-cdn-mapping-col1'>
61
  <label class="litespeed-form-label">
62
- <?php $id = Base::CDN_MAPPING_URL ; ?>
63
- <?php $this->title( $id ) ; ?>
64
  <button type="button" class="button button-link litespeed-collection-button litespeed-danger" data-litespeed-cdn-mapping-del="1" data-action="remove">
65
  <span class="dashicons dashicons-dismiss"></span>
66
- <span class="screen-reader-text"><?php echo __( 'Remove CDN URL', 'litespeed-cache' ) ; ?></span>
67
  </button>
68
  </label>
69
 
70
  <?php
71
- $this->build_input( Base::O_CDN_MAPPING . "[$id][]", 'litespeed-input-long', $v[ $id ] ) ;
72
  ?>
73
  <div class="litespeed-desc">
74
- <?php echo sprintf( __( 'CDN URL to be used. For example, %s', 'litespeed-cache' ), '<code>' . $cdn_url . '</code>' ) ; ?>
75
  </div>
76
  </div>
77
 
78
  <div class="litespeed-col-auto litespeed-cdn-mapping-col2">
79
  <div class="litespeed-row litespeed-toggle-wrapper">
80
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
81
- <?php $id = Base::CDN_MAPPING_INC_IMG ; ?>
82
- <?php $this->title( $id ) ; ?>
83
  </div>
84
  <?php
85
- $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
86
  ?>
87
  </div>
88
  <div class="litespeed-row litespeed-toggle-wrapper">
89
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
90
- <?php $id = Base::CDN_MAPPING_INC_CSS ; ?>
91
- <?php $this->title( $id ) ; ?>
92
  </div>
93
  <?php
94
- $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
95
  ?>
96
  </div>
97
  <div class="litespeed-row litespeed-toggle-wrapper">
98
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
99
- <?php $id = Base::CDN_MAPPING_INC_JS ; ?>
100
- <?php $this->title( $id ) ; ?>
101
  </div>
102
  <?php
103
- $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false ) ;
104
  ?>
105
  </div>
106
  </div>
107
 
108
  <div class="litespeed-col-auto">
109
  <label class="litespeed-form-label">
110
- <?php $id = Base::CDN_MAPPING_FILETYPE ; ?>
111
- <?php $this->title( $id ) ; ?>
112
  </label>
113
- <?php $this->build_textarea( Base::O_CDN_MAPPING . "[$id][]", 18, is_array( $v[ $id ] ) ? implode( "\n", $v[ $id ] ) : $v[ $id ] ) ; ?>
114
  </div>
115
  </div>
116
 
117
- <?php endforeach ; ?>
118
 
119
  <p><button type="button" class="button button-link litespeed-form-action litespeed-link-with-icon" id="litespeed-cdn-mapping-add" data-action="add">
120
  <span class="dashicons dashicons-plus-alt"></span><?php echo __( 'Add new CDN URL', 'litespeed-cache' );?>
@@ -122,31 +122,31 @@ $this->form_action() ;
122
 
123
  <div class="litespeed-warning">
124
  <?php echo __('NOTE', 'litespeed-cache'); ?>:
125
- <?php echo __( 'To randomize CDN hostname, define multiple hostnames for the same resources.', 'litespeed-cache' ) ; ?>
126
  </div>
127
 
128
  <div class="litespeed-desc">
129
- <b><?php $this->title( Base::CDN_MAPPING_INC_IMG ) ; ?></b>:
130
- <?php echo sprintf( __( 'Serve all image files through the CDN. This will affect all attachments, HTML %s tags, and CSS %s attributes.', 'litespeed-cache' ), '<code>&lt;img</code>', '<code>url()</code>' ) ; ?>
131
 
132
  <br />
133
- <b><?php $this->title( Base::CDN_MAPPING_INC_CSS ) ; ?></b>:
134
- <?php echo __( 'Serve all CSS files through the CDN. This will affect all enqueued WP CSS files.', 'litespeed-cache' ) ; ?>
135
 
136
  <br />
137
- <b><?php $this->title( Base::CDN_MAPPING_INC_JS ) ; ?></b>:
138
- <?php echo __( 'Serve all JavaScript files through the CDN. This will affect all enqueued WP JavaScript files.', 'litespeed-cache' ) ; ?>
139
 
140
  <br />
141
- <b><?php $this->title( Base::CDN_MAPPING_FILETYPE ) ; ?></b>:
142
- <?php echo __( 'Static file type links to be replaced by CDN links.', 'litespeed-cache' ) ; ?>
143
- <?php Doc::one_per_line() ; ?>
144
- <?php echo sprintf( __( 'This will affect all tags containing attributes: %s %s %s.', 'litespeed-cache' ), '<code>src=""</code>', '<code>data-src=""</code>', '<code>href=""</code>' ) ; ?>
145
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/#include-file-types', __( 'Default value', 'litespeed-cache' ) ) ; ?>
146
 
147
  <br />
148
- <?php echo sprintf( __( 'If you turn any of the above settings OFF, please remove the related file types from the %s box.' ), '<b>' . __( 'Include File Types', 'litespeed-cache' ) . '</b>' ) ; ?>
149
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/#include-file-types' ) ; ?>
150
  </div>
151
 
152
  </td>
@@ -164,7 +164,7 @@ $this->form_action() ;
164
  <?php $this->build_textarea( $id, 40 ); ?>
165
  </div>
166
  <div>
167
- <?php $this->recommended( $id, true ); ?>
168
  </div>
169
  </div>
170
 
@@ -179,110 +179,110 @@ $this->form_action() ;
179
 
180
  <tr>
181
  <th class="litespeed-padding-left">
182
- <?php $id = Base::O_CDN_ORI ; ?>
183
- <?php $this->title( $id ) ; ?>
184
  </th>
185
  <td>
186
- <?php $this->build_textarea( $id ) ; ?>
187
  <div class="litespeed-desc">
188
- <?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s.', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ) ; ?>
189
- <br /><?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>//www.aa.com</code>', '<code>//aa.com</code>', '<code>//*aa.com</code>' ) ; ?>
190
- <?php Doc::one_per_line() ; ?>
191
  </div>
192
  </td>
193
  </tr>
194
 
195
  <tr>
196
  <th class="litespeed-padding-left">
197
- <?php $id = Base::O_CDN_ORI_DIR ; ?>
198
- <?php $this->title( $id ) ; ?>
199
  </th>
200
  <td>
201
  <div class="litespeed-textarea-recommended">
202
  <div>
203
- <?php $this->build_textarea( $id, 40 ) ; ?>
204
  </div>
205
  <div>
206
- <?php $this->recommended( $id, true ) ; ?>
207
  </div>
208
  </div>
209
 
210
  <div class="litespeed-desc">
211
- <?php echo __( 'Only files within these directories will be pointed to the CDN.', 'litespeed-cache' ) ; ?>
212
- <?php Doc::one_per_line() ; ?>
213
  </div>
214
  </td>
215
  </tr>
216
 
217
  <tr>
218
  <th class="litespeed-padding-left">
219
- <?php $id = Base::O_CDN_EXC ; ?>
220
- <?php $this->title( $id ) ; ?>
221
  </th>
222
  <td>
223
- <?php $this->build_textarea( $id ) ; ?>
224
  <div class="litespeed-desc">
225
- <?php echo __( 'Paths containing these strings will not be served from the CDN.', 'litespeed-cache' ) ; ?>
226
- <?php Doc::one_per_line() ; ?>
227
  </div>
228
  </td>
229
  </tr>
230
 
231
  <tr>
232
  <th>
233
- <?php $id = Base::O_CDN_REMOTE_JQ ; ?>
234
- <?php $this->title( $id ) ; ?>
235
  </th>
236
  <td>
237
  <?php $this->build_switch( $id, array( __( 'OFF', 'litespeed-cache' ), 'Google', 'CDNJS' ) ); ?>
238
  <div class="litespeed-desc">
239
- <?php echo __( 'Improve page load time by loading jQuery from a remote CDN service instead of locally.', 'litespeed-cache' ) ; ?>
240
  </div>
241
  </td>
242
  </tr>
243
 
244
  <tr>
245
  <th>
246
- <?php $id = Base::O_CDN_CLOUDFLARE ; ?>
247
- <?php $this->title( $id ) ; ?>
248
  </th>
249
  <td>
250
- <?php $this->build_switch( $id ) ; ?>
251
  <div class="litespeed-desc">
252
- <?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
253
- <?php echo sprintf( __( 'This can be managed from <a %2$s>%1$s</a>.', 'litespeed-cache' ), '<b>' . __( 'CDN', 'litespeed-cache' ) . '</b> -&gt; <b>' . __( 'Manage', 'litespeed-cache' ) . '</b>', 'href="admin.php?page=litespeed-cdn#manage"' ) ; ?>
254
  </div>
255
  <div class="litespeed-block">
256
  <div class='litespeed-col'>
257
- <label class="litespeed-form-label"><?php echo __( 'Email Address', 'litespeed-cache' ) ; ?></label>
258
 
259
- <?php $this->build_input( Base::O_CDN_CLOUDFLARE_EMAIL ) ; ?>
260
  <div class="litespeed-desc">
261
- <?php echo sprintf( __( 'Your Email address on %s.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
262
  </div>
263
  </div>
264
 
265
  <div class='litespeed-col'>
266
- <label class="litespeed-form-label"><?php echo __( 'Global API Key', 'litespeed-cache' ) ; ?></label>
267
 
268
- <?php $this->build_input( Base::O_CDN_CLOUDFLARE_KEY ) ; ?>
269
  <div class="litespeed-desc">
270
- <?php echo sprintf( __( 'Your API key is used to access %s APIs.', 'litespeed-cache' ), 'Cloudflare' ) ; ?>
271
- <?php echo sprintf( __( 'Get it from <a %1$s>%2$s</a>.', 'litespeed-cache' ), 'href="https://dash.cloudflare.com/profile/api-tokens" target="_blank"', 'Cloudflare' ) ; ?>
272
  </div>
273
  </div>
274
 
275
  <div class='litespeed-col'>
276
- <label class="litespeed-form-label"><?php echo __( 'Domain', 'litespeed-cache' ) ; ?></label>
277
 
278
  <?php
279
- $cf_zone = Conf::val( Base::O_CDN_CLOUDFLARE_ZONE ) ;
280
- $cls = $cf_zone ? ' litespeed-input-success' : ' litespeed-input-warning' ;
281
- $this->build_input( Base::O_CDN_CLOUDFLARE_NAME, $cls ) ;
282
  ?>
283
  <div class="litespeed-desc">
284
- <?php echo __( 'You can just type part of the domain.', 'litespeed-cache' ) ; ?>
285
- <?php echo __( 'Once saved, it will be matched with the current list and completed automatically.', 'litespeed-cache' ) ; ?>
286
  </div>
287
  </div>
288
  </div>
@@ -292,5 +292,5 @@ $this->form_action() ;
292
  </tbody></table>
293
 
294
  <?php
295
- $this->form_end() ;
296
 
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
+ $home_url = home_url( '/' );
6
+ $parsed = parse_url( $home_url );
7
+ $home_url = str_replace( $parsed[ 'scheme' ] . ':', '', $home_url );
8
+ $cdn_url = 'https://cdn.' . substr( $home_url, 2 );
9
 
10
  $cdn_mapping = Conf::val( Base::O_CDN_MAPPING );
11
  // Special handler: Append one row if somehow the DB default preset value got deleted
14
  $cdn_mapping = self::$_default_options[ Base::O_CDN_MAPPING ];
15
  }
16
 
17
+ $this->form_action();
18
  ?>
19
 
20
  <h3 class="litespeed-title-short">
21
+ <?php echo __( 'CDN Settings', 'litespeed-cache' ); ?>
22
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/' ); ?>
23
  </h3>
24
 
25
  <table class="wp-list-table striped litespeed-table"><tbody>
26
 
27
  <tr>
28
  <th>
29
+ <?php $id = Base::O_CDN_QUIC; ?>
30
+ <?php $this->title( $id ); ?>
31
  </th>
32
  <td>
33
+ <?php $this->build_switch( $id ); ?>
34
  <div class="litespeed-desc">
35
+ <?php echo sprintf( __( 'Enable %s CDN API functionality.', 'litespeed-cache' ), 'QUIC.cloud' ); ?>
36
  </div>
37
  </td>
38
  </tr>
39
 
40
  <tr>
41
  <th>
42
+ <?php $id = Base::O_CDN; ?>
43
+ <?php $this->title( $id ); ?>
44
  </th>
45
  <td>
46
+ <?php $this->build_switch( $id ); ?>
47
  <div class="litespeed-desc">
48
+ <?php echo __( 'Enable Content Delivery Network use.', 'litespeed-cache' ); ?>
49
+ <?php echo sprintf( __( 'Leave this setting %1$s if you have QUIC.cloud CDN or Cloudflare API turned %2$s.', 'litespeed-cache' ), '<code>' . __( 'OFF', 'litespeed-cache' ) . '</code>', '<code>' . __( 'ON', 'litespeed-cache' ) . '</code>' ); ?>
50
  </div>
51
  </td>
52
  </tr>
59
  <div class="litespeed-block" data-litespeed-cdn-mapping="1">
60
  <div class='litespeed-cdn-mapping-col1'>
61
  <label class="litespeed-form-label">
62
+ <?php $id = Base::CDN_MAPPING_URL; ?>
63
+ <?php $this->title( $id ); ?>
64
  <button type="button" class="button button-link litespeed-collection-button litespeed-danger" data-litespeed-cdn-mapping-del="1" data-action="remove">
65
  <span class="dashicons dashicons-dismiss"></span>
66
+ <span class="screen-reader-text"><?php echo __( 'Remove CDN URL', 'litespeed-cache' ); ?></span>
67
  </button>
68
  </label>
69
 
70
  <?php
71
+ $this->build_input( Base::O_CDN_MAPPING . "[$id][]", 'litespeed-input-long', $v[ $id ] );
72
  ?>
73
  <div class="litespeed-desc">
74
+ <?php echo sprintf( __( 'CDN URL to be used. For example, %s', 'litespeed-cache' ), '<code>' . $cdn_url . '</code>' ); ?>
75
  </div>
76
  </div>
77
 
78
  <div class="litespeed-col-auto litespeed-cdn-mapping-col2">
79
  <div class="litespeed-row litespeed-toggle-wrapper">
80
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
81
+ <?php $id = Base::CDN_MAPPING_INC_IMG; ?>
82
+ <?php $this->title( $id ); ?>
83
  </div>
84
  <?php
85
+ $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false );
86
  ?>
87
  </div>
88
  <div class="litespeed-row litespeed-toggle-wrapper">
89
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
90
+ <?php $id = Base::CDN_MAPPING_INC_CSS; ?>
91
+ <?php $this->title( $id ); ?>
92
  </div>
93
  <?php
94
+ $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false );
95
  ?>
96
  </div>
97
  <div class="litespeed-row litespeed-toggle-wrapper">
98
  <div class="litespeed-cdn-mapping-inc litespeed-form-label litespeed-form-label--toggle">
99
+ <?php $id = Base::CDN_MAPPING_INC_JS; ?>
100
+ <?php $this->title( $id ); ?>
101
  </div>
102
  <?php
103
+ $this->build_toggle( Base::O_CDN_MAPPING . "[$id][]", ! empty( $v[ $id ] ) ? true : false );
104
  ?>
105
  </div>
106
  </div>
107
 
108
  <div class="litespeed-col-auto">
109
  <label class="litespeed-form-label">
110
+ <?php $id = Base::CDN_MAPPING_FILETYPE; ?>
111
+ <?php $this->title( $id ); ?>
112
  </label>
113
+ <?php $this->build_textarea( Base::O_CDN_MAPPING . "[$id][]", 18, is_array( $v[ $id ] ) ? implode( "\n", $v[ $id ] ) : $v[ $id ] ); ?>
114
  </div>
115
  </div>
116
 
117
+ <?php endforeach; ?>
118
 
119
  <p><button type="button" class="button button-link litespeed-form-action litespeed-link-with-icon" id="litespeed-cdn-mapping-add" data-action="add">
120
  <span class="dashicons dashicons-plus-alt"></span><?php echo __( 'Add new CDN URL', 'litespeed-cache' );?>
122
 
123
  <div class="litespeed-warning">
124
  <?php echo __('NOTE', 'litespeed-cache'); ?>:
125
+ <?php echo __( 'To randomize CDN hostname, define multiple hostnames for the same resources.', 'litespeed-cache' ); ?>
126
  </div>
127
 
128
  <div class="litespeed-desc">
129
+ <b><?php $this->title( Base::CDN_MAPPING_INC_IMG ); ?></b>:
130
+ <?php echo sprintf( __( 'Serve all image files through the CDN. This will affect all attachments, HTML %s tags, and CSS %s attributes.', 'litespeed-cache' ), '<code>&lt;img</code>', '<code>url()</code>' ); ?>
131
 
132
  <br />
133
+ <b><?php $this->title( Base::CDN_MAPPING_INC_CSS ); ?></b>:
134
+ <?php echo __( 'Serve all CSS files through the CDN. This will affect all enqueued WP CSS files.', 'litespeed-cache' ); ?>
135
 
136
  <br />
137
+ <b><?php $this->title( Base::CDN_MAPPING_INC_JS ); ?></b>:
138
+ <?php echo __( 'Serve all JavaScript files through the CDN. This will affect all enqueued WP JavaScript files.', 'litespeed-cache' ); ?>
139
 
140
  <br />
141
+ <b><?php $this->title( Base::CDN_MAPPING_FILETYPE ); ?></b>:
142
+ <?php echo __( 'Static file type links to be replaced by CDN links.', 'litespeed-cache' ); ?>
143
+ <?php Doc::one_per_line(); ?>
144
+ <?php echo sprintf( __( 'This will affect all tags containing attributes: %s %s %s.', 'litespeed-cache' ), '<code>src=""</code>', '<code>data-src=""</code>', '<code>href=""</code>' ); ?>
145
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/#include-file-types', __( 'Default value', 'litespeed-cache' ) ); ?>
146
 
147
  <br />
148
+ <?php echo sprintf( __( 'If you turn any of the above settings OFF, please remove the related file types from the %s box.' ), '<b>' . __( 'Include File Types', 'litespeed-cache' ) . '</b>' ); ?>
149
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cdn/#include-file-types' ); ?>
150
  </div>
151
 
152
  </td>
164
  <?php $this->build_textarea( $id, 40 ); ?>
165
  </div>
166
  <div>
167
+ <?php $this->recommended( $id ); ?>
168
  </div>
169
  </div>
170
 
179
 
180
  <tr>
181
  <th class="litespeed-padding-left">
182
+ <?php $id = Base::O_CDN_ORI; ?>
183
+ <?php $this->title( $id ); ?>
184
  </th>
185
  <td>
186
+ <?php $this->build_textarea( $id ); ?>
187
  <div class="litespeed-desc">
188
+ <?php echo sprintf( __( 'Site URL to be served through the CDN. Beginning with %1$s. For example, %2$s.', 'litespeed-cache' ), '<code>//</code>', '<code>' . $home_url . '</code>' ); ?>
189
+ <br /><?php echo sprintf( __( 'Wildcard %1$s supported (match zero or more characters). For example, to match %2$s and %3$s, use %4$s.', 'litespeed-cache' ), '<code>*</code>', '<code>//www.aa.com</code>', '<code>//aa.com</code>', '<code>//*aa.com</code>' ); ?>
190
+ <?php Doc::one_per_line(); ?>
191
  </div>
192
  </td>
193
  </tr>
194
 
195
  <tr>
196
  <th class="litespeed-padding-left">
197
+ <?php $id = Base::O_CDN_ORI_DIR; ?>
198
+ <?php $this->title( $id ); ?>
199
  </th>
200
  <td>
201
  <div class="litespeed-textarea-recommended">
202
  <div>
203
+ <?php $this->build_textarea( $id, 40 ); ?>
204
  </div>
205
  <div>
206
+ <?php $this->recommended( $id ); ?>
207
  </div>
208
  </div>
209
 
210
  <div class="litespeed-desc">
211
+ <?php echo __( 'Only files within these directories will be pointed to the CDN.', 'litespeed-cache' ); ?>
212
+ <?php Doc::one_per_line(); ?>
213
  </div>
214
  </td>
215
  </tr>
216
 
217
  <tr>
218
  <th class="litespeed-padding-left">
219
+ <?php $id = Base::O_CDN_EXC; ?>
220
+ <?php $this->title( $id ); ?>
221
  </th>
222
  <td>
223
+ <?php $this->build_textarea( $id ); ?>
224
  <div class="litespeed-desc">
225
+ <?php echo __( 'Paths containing these strings will not be served from the CDN.', 'litespeed-cache' ); ?>
226
+ <?php Doc::one_per_line(); ?>
227
  </div>
228
  </td>
229
  </tr>
230
 
231
  <tr>
232
  <th>
233
+ <?php $id = Base::O_CDN_REMOTE_JQ; ?>
234
+ <?php $this->title( $id ); ?>
235
  </th>
236
  <td>
237
  <?php $this->build_switch( $id, array( __( 'OFF', 'litespeed-cache' ), 'Google', 'CDNJS' ) ); ?>
238
  <div class="litespeed-desc">
239
+ <?php echo __( 'Improve page load time by loading jQuery from a remote CDN service instead of locally.', 'litespeed-cache' ); ?>
240
  </div>
241
  </td>
242
  </tr>
243
 
244
  <tr>
245
  <th>
246
+ <?php $id = Base::O_CDN_CLOUDFLARE; ?>
247
+ <?php $this->title( $id ); ?>
248
  </th>
249
  <td>
250
+ <?php $this->build_switch( $id ); ?>
251
  <div class="litespeed-desc">
252
+ <?php echo sprintf( __( 'Use %s API functionality.', 'litespeed-cache' ), 'Cloudflare' ); ?>
253
+ <?php echo sprintf( __( 'This can be managed from <a %2$s>%1$s</a>.', 'litespeed-cache' ), '<b>' . __( 'CDN', 'litespeed-cache' ) . '</b> -&gt; <b>' . __( 'Manage', 'litespeed-cache' ) . '</b>', 'href="admin.php?page=litespeed-cdn#manage"' ); ?>
254
  </div>
255
  <div class="litespeed-block">
256
  <div class='litespeed-col'>
257
+ <label class="litespeed-form-label"><?php echo __( 'Email Address', 'litespeed-cache' ); ?></label>
258
 
259
+ <?php $this->build_input( Base::O_CDN_CLOUDFLARE_EMAIL ); ?>
260
  <div class="litespeed-desc">
261
+ <?php echo sprintf( __( 'Your Email address on %s.', 'litespeed-cache' ), 'Cloudflare' ); ?>
262
  </div>
263
  </div>
264
 
265
  <div class='litespeed-col'>
266
+ <label class="litespeed-form-label"><?php echo __( 'Global API Key', 'litespeed-cache' ); ?></label>
267
 
268
+ <?php $this->build_input( Base::O_CDN_CLOUDFLARE_KEY ); ?>
269
  <div class="litespeed-desc">
270
+ <?php echo sprintf( __( 'Your API key is used to access %s APIs.', 'litespeed-cache' ), 'Cloudflare' ); ?>
271
+ <?php echo sprintf( __( 'Get it from <a %1$s>%2$s</a>.', 'litespeed-cache' ), 'href="https://dash.cloudflare.com/profile/api-tokens" target="_blank"', 'Cloudflare' ); ?>
272
  </div>
273
  </div>
274
 
275
  <div class='litespeed-col'>
276
+ <label class="litespeed-form-label"><?php echo __( 'Domain', 'litespeed-cache' ); ?></label>
277
 
278
  <?php
279
+ $cf_zone = Conf::val( Base::O_CDN_CLOUDFLARE_ZONE );
280
+ $cls = $cf_zone ? ' litespeed-input-success' : ' litespeed-input-warning';
281
+ $this->build_input( Base::O_CDN_CLOUDFLARE_NAME, $cls );
282
  ?>
283
  <div class="litespeed-desc">
284
+ <?php echo __( 'You can just type part of the domain.', 'litespeed-cache' ); ?>
285
+ <?php echo __( 'Once saved, it will be matched with the current list and completed automatically.', 'litespeed-cache' ); ?>
286
  </div>
287
  </div>
288
  </div>
292
  </tbody></table>
293
 
294
  <?php
295
+ $this->form_end();
296
 
tpl/crawler/blacklist.tpl.php CHANGED
@@ -19,7 +19,7 @@ $pagination = Utility::pagination( $count, 30 );
19
 
20
  <h3 class="litespeed-title">
21
  <?php echo __( 'Blacklist', 'litespeed-cache' ); ?>
22
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#blacklist-tab', false, 'litespeed-learn-more' ); ?>
23
  </h3>
24
 
25
  <?php echo __( 'Total', 'litespeed-cache' ) . ': ' . $count; ?>
19
 
20
  <h3 class="litespeed-title">
21
  <?php echo __( 'Blacklist', 'litespeed-cache' ); ?>
22
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#blacklist-tab' ); ?>
23
  </h3>
24
 
25
  <?php echo __( 'Total', 'litespeed-cache' ) . ': ' . $count; ?>
tpl/crawler/map.tpl.php CHANGED
@@ -31,7 +31,7 @@ $pagination = Utility::pagination( $count, 30 );
31
 
32
  <h3 class="litespeed-title">
33
  <?php echo __( 'Sitemap List', 'litespeed-cache' ); ?>
34
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#map-tab', false, 'litespeed-learn-more' ); ?>
35
  </h3>
36
 
37
  <?php echo __( 'Sitemap Total', 'litespeed-cache' ) . ': ' . $count; ?>
31
 
32
  <h3 class="litespeed-title">
33
  <?php echo __( 'Sitemap List', 'litespeed-cache' ); ?>
34
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#map-tab' ); ?>
35
  </h3>
36
 
37
  <?php echo __( 'Sitemap Total', 'litespeed-cache' ) . ': ' . $count; ?>
tpl/crawler/settings-general.tpl.php CHANGED
@@ -7,7 +7,7 @@ $this->form_action();
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler General Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#general-settings-tab', false, 'litespeed-learn-more' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -124,25 +124,6 @@ $this->form_action();
124
  </td>
125
  </tr>
126
 
127
- <tr>
128
- <th>
129
- <?php $id = Base::O_SERVER_IP; ?>
130
- <?php $this->title( $id ); ?>
131
- </th>
132
- <td>
133
- <?php $this->build_input($id); ?>
134
- <div class="litespeed-desc">
135
- <?php echo __( 'Enter this site\'s IP address to allow cloud services directly call IP instead of domain name. This eliminates the overhead of DNS and CDN lookups.', 'litespeed-cache' ); ?>
136
- <br /><?php echo __('Your server IP is', 'litespeed-cache'); ?>: <code id='litespeed_server_ip'>-</code> <a href="javascript:;" class="button button-link" id="litespeed_get_ip"><?php echo __('Check my public IP from', 'litespeed-cache'); ?> DoAPI.us</a>
137
- <font class="litespeed-warning litespeed-left10">
138
- ⚠️ <?php echo __( 'Notice', 'litespeed-cache' ); ?>: <?php echo __( 'the auto-detected IP may not be accurate if you have an additional outgoing IP set, or you have multiple IPs configured on your server. Please make sure this IP is the correct one for visiting your site.', 'litespeed-cache' ); ?>
139
- </font>
140
-
141
- <?php $this->_validate_ip( $id ); ?>
142
- </div>
143
- </td>
144
- </tr>
145
-
146
  <tr>
147
  <th>
148
  <?php $id = Base::O_CRAWLER_LOAD_LIMIT; ?>
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler General Settings', 'litespeed-cache'); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#general-settings-tab' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
124
  </td>
125
  </tr>
126
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  <tr>
128
  <th>
129
  <?php $id = Base::O_CRAWLER_LOAD_LIMIT; ?>
tpl/crawler/settings-simulation.tpl.php CHANGED
@@ -7,7 +7,7 @@ $this->form_action();
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler Simulation Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#simulation-settings-tab', false, 'litespeed-learn-more' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -102,7 +102,7 @@ $this->form_action();
102
 
103
  <div class="litespeed-desc">
104
  <?php echo __('To crawl for a particular cookie, enter the cookie name, and the values you wish to crawl for. Values should be one per line, and can include a blank line. There will be one crawler created per cookie value, per simulated role.', 'litespeed-cache'); ?>
105
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#cookie-simulation' ); ?>
106
  <p><?php echo sprintf( __( 'Use %1$s in %2$s to indicate this cookie has not been set.', 'litespeed-cache' ), '<code>_null</code>', __( 'Cookie Values', 'litespeed-cache' ) ); ?></p>
107
  </div>
108
 
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler Simulation Settings', 'litespeed-cache'); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#simulation-settings-tab' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
102
 
103
  <div class="litespeed-desc">
104
  <?php echo __('To crawl for a particular cookie, enter the cookie name, and the values you wish to crawl for. Values should be one per line, and can include a blank line. There will be one crawler created per cookie value, per simulated role.', 'litespeed-cache'); ?>
105
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#cookie-simulation' ); ?>
106
  <p><?php echo sprintf( __( 'Use %1$s in %2$s to indicate this cookie has not been set.', 'litespeed-cache' ), '<code>_null</code>', __( 'Cookie Values', 'litespeed-cache' ) ); ?></p>
107
  </div>
108
 
tpl/crawler/settings-sitemap.tpl.php CHANGED
@@ -7,7 +7,7 @@ $this->form_action();
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler Sitemap Settings', 'litespeed-cache'); ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#sitemap-settings-tab', false, 'litespeed-learn-more' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
7
 
8
  <h3 class="litespeed-title-short">
9
  <?php echo __('Crawler Sitemap Settings', 'litespeed-cache'); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/#sitemap-settings-tab' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/crawler/summary.tpl.php CHANGED
@@ -40,7 +40,7 @@ if($seconds > 0):
40
 
41
  <h3 class="litespeed-title litespeed-relative">
42
  <?php echo __('Crawler Cron', 'litespeed-cache'); ?>
43
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/', false, 'litespeed-learn-more' ); ?>
44
  </h3>
45
 
46
  <?php if ( ! Router::can_crawl() ): ?>
40
 
41
  <h3 class="litespeed-title litespeed-relative">
42
  <?php echo __('Crawler Cron', 'litespeed-cache'); ?>
43
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/crawler/' ); ?>
44
  </h3>
45
 
46
  <?php if ( ! Router::can_crawl() ): ?>
tpl/db_optm/manage.tpl.php CHANGED
@@ -76,7 +76,7 @@ $autoload_summary = DB_Optm::get_instance()->autoload_summary();
76
 
77
  <h3 class="litespeed-title">
78
  <?php echo __('Database Optimizer', 'litespeed-cache'); ?>
79
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/database/', false, 'litespeed-learn-more' ); ?>
80
  </h3>
81
 
82
  <div class="litespeed-panel-wrapper litespeed-cards-wrapper">
76
 
77
  <h3 class="litespeed-title">
78
  <?php echo __('Database Optimizer', 'litespeed-cache'); ?>
79
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/database/' ); ?>
80
  </h3>
81
 
82
  <div class="litespeed-panel-wrapper litespeed-cards-wrapper">
tpl/db_optm/settings.tpl.php CHANGED
@@ -8,7 +8,7 @@ $this->form_action();
8
 
9
  <h3 class="litespeed-title-short">
10
  <?php echo __( 'DB Optimization Settings', 'litespeed-cache' ); ?>
11
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/database/#db-optimization-settings-tab', false, 'litespeed-learn-more' ); ?>
12
  </h3>
13
 
14
  <table class="wp-list-table striped litespeed-table"><tbody>
8
 
9
  <h3 class="litespeed-title-short">
10
  <?php echo __( 'DB Optimization Settings', 'litespeed-cache' ); ?>
11
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/database/#db-optimization-settings-tab' ); ?>
12
  </h3>
13
 
14
  <table class="wp-list-table striped litespeed-table"><tbody>
tpl/general/network_settings.tpl.php CHANGED
@@ -6,7 +6,7 @@ defined( 'WPINC' ) || exit;
6
 
7
  <h3 class="litespeed-title-short">
8
  <?php echo __( 'General Settings', 'litespeed-cache' ); ?>
9
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/general/', false, 'litespeed-learn-more' ); ?>
10
  </h3>
11
 
12
  <?php
6
 
7
  <h3 class="litespeed-title-short">
8
  <?php echo __( 'General Settings', 'litespeed-cache' ); ?>
9
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/general/' ); ?>
10
  </h3>
11
 
12
  <?php
tpl/general/settings.tpl.php CHANGED
@@ -43,7 +43,7 @@ $this->form_action();
43
 
44
  <h3 class="litespeed-title-short">
45
  <?php echo __( 'General Settings', 'litespeed-cache' ); ?>
46
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/general/', false, 'litespeed-learn-more' ); ?>
47
  </h3>
48
 
49
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -64,20 +64,20 @@ $this->form_action();
64
  <?php endif; ?>
65
 
66
  <?php if ( $permalink_structure && $can_token ) : ?>
67
- <?php $this->learn_more( Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_GEN_KEY ), $apply_btn_txt, 'button litespeed-btn-success', true ); ?>
68
  <?php else: ?>
69
- <?php $this->learn_more( 'javascript:;', $apply_btn_txt, 'button disabled', true ); ?>
70
  <?php endif; ?>
71
  <?php if ( $apply_ts_txt ) : ?>
72
  <span class="litespeed-desc"><?php echo $apply_ts_txt; ?></span>
73
  <?php endif; ?>
74
 
75
  <?php if ( ! empty( $cloud_summary[ 'is_linked' ] ) ) : ?>
76
- <?php $this->learn_more( Cloud::CLOUD_SERVER_DASH, __( 'Visit My Dashboard on QUIC.cloud', 'litespeed-cache' ), 'button litespeed-btn-success litespeed-right', false ); ?>
77
  <?php elseif ( $__cloud->can_link_qc() ) : ?>
78
- <?php $this->learn_more( Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_LINK ), __( 'Link to QUIC.cloud', 'litespeed-cache' ), 'button litespeed-btn-warning litespeed-right', true ); ?>
79
  <?php else: ?>
80
- <?php $this->learn_more( 'javascript:;', __( 'Link to QUIC.cloud', 'litespeed-cache' ), 'button disabled litespeed-btn-warning litespeed-right', true ); ?>
81
  <?php endif; ?>
82
 
83
  <?php if ( $is_requesting && $can_token ) : ?>
@@ -116,7 +116,7 @@ $this->form_action();
116
  <div class="litespeed-callout notice notice-warning inline">
117
  <h4><?php echo __( 'Notice', 'litespeed-cache' ); ?>:</h4>
118
  <p><?php echo sprintf( __( 'You must click the %s button if you wish to associate this site with a QUIC.cloud account.', 'litespeed-cache' ), '<code>' . __( 'Link to QUIC.cloud', 'litespeed-cache' ) . '</code>' ); ?></p>
119
- <p><?php $this->learn_more( 'https://www.quic.cloud/faq/#do-i-need-to-register-on-quic-cloud-to-use-the-online-services', __( 'Benefits of linking to a QUIC.cloud account', 'litespeed-cache' ) ); ?></p>
120
  </div>
121
  <?php endif; ?>
122
 
@@ -125,7 +125,7 @@ $this->form_action();
125
  <br /><?php Doc::notice_ips(); ?>
126
  <div class="litespeed-callout notice notice-success inline">
127
  <h4><?php echo __( 'Current Cloud Nodes in Service','litespeed-cache' ); ?>
128
- <a class="litespeed-right" href="<?php echo Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_CLEAR_CLOUD ); ?>" data-balloon-pos="up" data-balloon-break aria-label='<?php echo __( 'Click to clear all nodes for further redetection.', 'litespeed-cache' ); ?>' data-litespeed-cfm="<?php echo __( 'Are you sure to clear all cloud nodes?', 'litespeed-cache' ) ; ?>"><i class='litespeed-quic-icon'></i></a>
129
  </h4>
130
  <p>
131
  <?php
@@ -147,6 +147,25 @@ $this->form_action();
147
  </td>
148
  </tr>
149
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
150
  <tr>
151
  <th>
152
  <?php $id = Base::O_NEWS; ?>
43
 
44
  <h3 class="litespeed-title-short">
45
  <?php echo __( 'General Settings', 'litespeed-cache' ); ?>
46
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/general/' ); ?>
47
  </h3>
48
 
49
  <table class="wp-list-table striped litespeed-table"><tbody>
64
  <?php endif; ?>
65
 
66
  <?php if ( $permalink_structure && $can_token ) : ?>
67
+ <?php Doc::learn_more( Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_GEN_KEY ), $apply_btn_txt, true, 'button litespeed-btn-success' ); ?>
68
  <?php else: ?>
69
+ <?php Doc::learn_more( 'javascript:;', $apply_btn_txt, true, 'button disabled' ); ?>
70
  <?php endif; ?>
71
  <?php if ( $apply_ts_txt ) : ?>
72
  <span class="litespeed-desc"><?php echo $apply_ts_txt; ?></span>
73
  <?php endif; ?>
74
 
75
  <?php if ( ! empty( $cloud_summary[ 'is_linked' ] ) ) : ?>
76
+ <?php Doc::learn_more( Cloud::CLOUD_SERVER_DASH, __( 'Visit My Dashboard on QUIC.cloud', 'litespeed-cache' ), false, 'button litespeed-btn-success litespeed-right' ); ?>
77
  <?php elseif ( $__cloud->can_link_qc() ) : ?>
78
+ <?php Doc::learn_more( Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_LINK ), __( 'Link to QUIC.cloud', 'litespeed-cache' ), true, 'button litespeed-btn-warning litespeed-right' ); ?>
79
  <?php else: ?>
80
+ <?php Doc::learn_more( 'javascript:;', __( 'Link to QUIC.cloud', 'litespeed-cache' ), true, 'button disabled litespeed-btn-warning litespeed-right' ); ?>
81
  <?php endif; ?>
82
 
83
  <?php if ( $is_requesting && $can_token ) : ?>
116
  <div class="litespeed-callout notice notice-warning inline">
117
  <h4><?php echo __( 'Notice', 'litespeed-cache' ); ?>:</h4>
118
  <p><?php echo sprintf( __( 'You must click the %s button if you wish to associate this site with a QUIC.cloud account.', 'litespeed-cache' ), '<code>' . __( 'Link to QUIC.cloud', 'litespeed-cache' ) . '</code>' ); ?></p>
119
+ <p><?php Doc::learn_more( 'https://www.quic.cloud/faq/#do-i-need-to-register-on-quic-cloud-to-use-the-online-services', __( 'Benefits of linking to a QUIC.cloud account', 'litespeed-cache' ) ); ?></p>
120
  </div>
121
  <?php endif; ?>
122
 
125
  <br /><?php Doc::notice_ips(); ?>
126
  <div class="litespeed-callout notice notice-success inline">
127
  <h4><?php echo __( 'Current Cloud Nodes in Service','litespeed-cache' ); ?>
128
+ <a class="litespeed-right" href="<?php echo Utility::build_url( Router::ACTION_CLOUD, Cloud::TYPE_CLEAR_CLOUD ); ?>" data-balloon-pos="up" data-balloon-break aria-label='<?php echo __( 'Click to clear all nodes for further redetection.', 'litespeed-cache' ); ?>' data-litespeed-cfm="<?php echo __( 'Are you sure to clear all cloud nodes?', 'litespeed-cache' ); ?>"><i class='litespeed-quic-icon'></i></a>
129
  </h4>
130
  <p>
131
  <?php
147
  </td>
148
  </tr>
149
 
150
+ <tr>
151
+ <th>
152
+ <?php $id = Base::O_SERVER_IP; ?>
153
+ <?php $this->title( $id ); ?>
154
+ </th>
155
+ <td>
156
+ <?php $this->build_input($id); ?>
157
+ <div class="litespeed-desc">
158
+ <?php echo __( 'Enter this site\'s IP address to allow cloud services directly call IP instead of domain name. This eliminates the overhead of DNS and CDN lookups.', 'litespeed-cache' ); ?>
159
+ <br /><?php echo __('Your server IP is', 'litespeed-cache'); ?>: <code id='litespeed_server_ip'>-</code> <a href="javascript:;" class="button button-link" id="litespeed_get_ip"><?php echo __('Check my public IP from', 'litespeed-cache'); ?> DoAPI.us</a>
160
+ <font class="litespeed-warning litespeed-left10">
161
+ ⚠️ <?php echo __( 'Notice', 'litespeed-cache' ); ?>: <?php echo __( 'the auto-detected IP may not be accurate if you have an additional outgoing IP set, or you have multiple IPs configured on your server. Please make sure this IP is the correct one for visiting your site.', 'litespeed-cache' ); ?>
162
+ </font>
163
+
164
+ <?php $this->_validate_ip( $id ); ?>
165
+ </div>
166
+ </td>
167
+ </tr>
168
+
169
  <tr>
170
  <th>
171
  <?php $id = Base::O_NEWS; ?>
tpl/img_optm/network_settings.tpl.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
- $this->form_action( Router::ACTION_SAVE_SETTINGS_NETWORK ) ;
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
- <?php echo __( 'Image Optimization Settings', 'litespeed-cache' ) ; ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#image-optimization-settings-tab', false, 'litespeed-learn-more' ) ; ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -16,5 +16,5 @@ $this->form_action( Router::ACTION_SAVE_SETTINGS_NETWORK ) ;
16
  </tbody></table>
17
 
18
  <?php
19
- $this->form_end( true ) ;
20
 
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
+ $this->form_action( Router::ACTION_SAVE_SETTINGS_NETWORK );
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
+ <?php echo __( 'Image Optimization Settings', 'litespeed-cache' ); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#image-optimization-settings-tab' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
16
  </tbody></table>
17
 
18
  <?php
19
+ $this->form_end( true );
20
 
tpl/img_optm/settings.tpl.php CHANGED
@@ -1,70 +1,70 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
- $this->form_action() ;
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
- <?php echo __( 'Image Optimization Settings', 'litespeed-cache' ) ; ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#image-optimization-settings-tab', false, 'litespeed-learn-more' ) ; ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
14
 
15
  <tr>
16
  <th>
17
- <?php $id = Base::O_IMG_OPTM_AUTO ; ?>
18
- <?php $this->title( $id ) ; ?>
19
  </th>
20
  <td>
21
- <?php $this->build_switch( $id ) ; ?>
22
  <div class="litespeed-desc">
23
- <?php echo __( 'Automatically request optimization via cron job.', 'litespeed-cache' ) ; ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
- <?php $id = Base::O_IMG_OPTM_CRON ; ?>
31
- <?php $this->title( $id ) ; ?>
32
  </th>
33
  <td>
34
- <?php $this->build_switch( $id ) ; ?>
35
  <div class="litespeed-desc">
36
- <?php echo __( 'Disabling this will stop the cron job responsible for pulling optimized images back from QUIC.cloud Image Server.', 'litespeed-cache' ) ; ?>
37
  </div>
38
  </td>
39
  </tr>
40
 
41
  <tr>
42
  <th>
43
- <?php $id = Base::O_IMG_OPTM_ORI ; ?>
44
- <?php $this->title( $id ) ; ?>
45
  </th>
46
  <td>
47
- <?php $this->build_switch( $id ) ; ?>
48
  <div class="litespeed-desc">
49
- <?php echo __( 'Optimize images and save backups of the originals in the same folder.', 'litespeed-cache' ) ; ?>
50
  </div>
51
  </td>
52
  </tr>
53
 
54
  <tr>
55
  <th>
56
- <?php $id = Base::O_IMG_OPTM_RM_BKUP ; ?>
57
- <?php $this->title( $id ) ; ?>
58
  </th>
59
  <td>
60
- <?php $this->build_switch( $id ) ; ?>
61
  <div class="litespeed-desc">
62
- <?php echo __( 'Automatically remove the original image backups after fetching optimized images.', 'litespeed-cache' ) ; ?>
63
 
64
  <br /><font class="litespeed-danger">
65
  🚨
66
- <?php echo __( 'This is irreversible.', 'litespeed-cache' ) ; ?>
67
- <?php echo __( 'You will be unable to Revert Optimization once the backups are deleted!', 'litespeed-cache' ) ; ?>
68
  </font>
69
  </div>
70
  </td>
@@ -72,41 +72,41 @@ $this->form_action() ;
72
 
73
  <tr>
74
  <th>
75
- <?php $id = Base::O_IMG_OPTM_LOSSLESS ; ?>
76
- <?php $this->title( $id ) ; ?>
77
  </th>
78
  <td>
79
- <?php $this->build_switch( $id ) ; ?>
80
  <div class="litespeed-desc">
81
- <?php echo __( 'Optimize images using lossless compression.', 'litespeed-cache' ) ; ?>
82
- <?php echo __( 'This can improve quality but may result in larger images than lossy compression will.', 'litespeed-cache' ) ; ?>
83
  </div>
84
  </td>
85
  </tr>
86
 
87
  <tr>
88
  <th>
89
- <?php $id = Base::O_IMG_OPTM_EXIF ; ?>
90
- <?php $this->title( $id ) ; ?>
91
  </th>
92
  <td>
93
- <?php $this->build_switch( $id ) ; ?>
94
  <div class="litespeed-desc">
95
- <?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ) ; ?>
96
- <?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ) ; ?>
97
  </div>
98
  </td>
99
  </tr>
100
 
101
  <tr>
102
  <th>
103
- <?php $id = Base::O_IMG_OPTM_WEBP ; ?>
104
- <?php $this->title( $id ) ; ?>
105
  </th>
106
  <td>
107
- <?php $this->build_switch( $id ) ; ?>
108
  <div class="litespeed-desc">
109
- <?php echo __( 'Request WebP versions of original images when doing optimization.', 'litespeed-cache' ) ; ?>
110
  </div>
111
  </td>
112
  </tr>
@@ -114,61 +114,61 @@ $this->form_action() ;
114
  <?php
115
  if ( ! is_multisite() ) :
116
  // webp
117
- require LSCWP_DIR . 'tpl/img_optm/settings.media_webp.tpl.php' ;
118
 
119
- endif ;
120
  ?>
121
 
122
  <tr>
123
  <th>
124
- <?php $id = Base::O_IMG_OPTM_WEBP_ATTR ; ?>
125
- <?php $this->title( $id ) ; ?>
126
  </th>
127
  <td>
128
 
129
  <div class="litespeed-textarea-recommended">
130
  <div>
131
- <?php $this->build_textarea( $id, 40 ) ; ?>
132
  </div>
133
  <div>
134
- <?php $this->recommended( $id, true ) ; ?>
135
  </div>
136
  </div>
137
 
138
  <div class="litespeed-desc">
139
- <?php echo __( 'Specify which element attributes will be replaced with WebP.', 'litespeed-cache' ) ; ?>
140
- <?php echo __( 'Only attributes listed here will be replaced.', 'litespeed-cache' ) ; ?>
141
- <br /><?php echo sprintf( __( 'Use the format %1$s or %2$s (element is optional).', 'litespeed-cache' ), '<code>element.attribute</code>', '<code>.attribute</code>' ) ; ?>
142
- <?php Doc::one_per_line() ; ?>
143
  </div>
144
  </td>
145
  </tr>
146
 
147
  <tr>
148
  <th>
149
- <?php $id = Base::O_IMG_OPTM_WEBP_REPLACE_SRCSET ; ?>
150
- <?php $this->title( $id ) ; ?>
151
  </th>
152
  <td>
153
- <?php $this->build_switch( $id ) ; ?>
154
  <div class="litespeed-desc">
155
- <?php echo sprintf( __( 'Enable replacement of WebP in %s elements that were generated outside of WordPress logic.', 'litespeed-cache' ), '<code>srcset</code>' ) ; ?>
156
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#webp-for-extra-srcset' ) ; ?>
157
  </div>
158
  </td>
159
  </tr>
160
 
161
  <tr>
162
  <th>
163
- <?php $id = Base::O_IMG_OPTM_JPG_QUALITY ; ?>
164
- <?php $this->title( $id ) ; ?>
165
  </th>
166
  <td>
167
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?>
168
  <div class="litespeed-desc">
169
  <?php echo __('The image compression quality setting of WordPress out of 100.', 'litespeed-cache'); ?>
170
- <?php $this->recommended( $id ) ; ?>
171
- <?php $this->_validate_ttl( $id, 0, 100 ) ; ?>
172
  </div>
173
  </td>
174
  </tr>
@@ -176,7 +176,7 @@ $this->form_action() ;
176
 
177
  <?php
178
 
179
- $this->form_end() ;
180
 
181
 
182
 
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
+ $this->form_action();
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
+ <?php echo __( 'Image Optimization Settings', 'litespeed-cache' ); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#image-optimization-settings-tab' ); ?>
11
  </h3>
12
 
13
  <table class="wp-list-table striped litespeed-table"><tbody>
14
 
15
  <tr>
16
  <th>
17
+ <?php $id = Base::O_IMG_OPTM_AUTO; ?>
18
+ <?php $this->title( $id ); ?>
19
  </th>
20
  <td>
21
+ <?php $this->build_switch( $id ); ?>
22
  <div class="litespeed-desc">
23
+ <?php echo __( 'Automatically request optimization via cron job.', 'litespeed-cache' ); ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
+ <?php $id = Base::O_IMG_OPTM_CRON; ?>
31
+ <?php $this->title( $id ); ?>
32
  </th>
33
  <td>
34
+ <?php $this->build_switch( $id ); ?>
35
  <div class="litespeed-desc">
36
+ <?php echo __( 'Disabling this will stop the cron job responsible for pulling optimized images back from QUIC.cloud Image Server.', 'litespeed-cache' ); ?>
37
  </div>
38
  </td>
39
  </tr>
40
 
41
  <tr>
42
  <th>
43
+ <?php $id = Base::O_IMG_OPTM_ORI; ?>
44
+ <?php $this->title( $id ); ?>
45
  </th>
46
  <td>
47
+ <?php $this->build_switch( $id ); ?>
48
  <div class="litespeed-desc">
49
+ <?php echo __( 'Optimize images and save backups of the originals in the same folder.', 'litespeed-cache' ); ?>
50
  </div>
51
  </td>
52
  </tr>
53
 
54
  <tr>
55
  <th>
56
+ <?php $id = Base::O_IMG_OPTM_RM_BKUP; ?>
57
+ <?php $this->title( $id ); ?>
58
  </th>
59
  <td>
60
+ <?php $this->build_switch( $id ); ?>
61
  <div class="litespeed-desc">
62
+ <?php echo __( 'Automatically remove the original image backups after fetching optimized images.', 'litespeed-cache' ); ?>
63
 
64
  <br /><font class="litespeed-danger">
65
  🚨
66
+ <?php echo __( 'This is irreversible.', 'litespeed-cache' ); ?>
67
+ <?php echo __( 'You will be unable to Revert Optimization once the backups are deleted!', 'litespeed-cache' ); ?>
68
  </font>
69
  </div>
70
  </td>
72
 
73
  <tr>
74
  <th>
75
+ <?php $id = Base::O_IMG_OPTM_LOSSLESS; ?>
76
+ <?php $this->title( $id ); ?>
77
  </th>
78
  <td>
79
+ <?php $this->build_switch( $id ); ?>
80
  <div class="litespeed-desc">
81
+ <?php echo __( 'Optimize images using lossless compression.', 'litespeed-cache' ); ?>
82
+ <?php echo __( 'This can improve quality but may result in larger images than lossy compression will.', 'litespeed-cache' ); ?>
83
  </div>
84
  </td>
85
  </tr>
86
 
87
  <tr>
88
  <th>
89
+ <?php $id = Base::O_IMG_OPTM_EXIF; ?>
90
+ <?php $this->title( $id ); ?>
91
  </th>
92
  <td>
93
+ <?php $this->build_switch( $id ); ?>
94
  <div class="litespeed-desc">
95
+ <?php echo __( 'Preserve EXIF data (copyright, GPS, comments, keywords, etc) when optimizing.', 'litespeed-cache' ); ?>
96
+ <?php echo __( 'This will increase the size of optimized files.', 'litespeed-cache' ); ?>
97
  </div>
98
  </td>
99
  </tr>
100
 
101
  <tr>
102
  <th>
103
+ <?php $id = Base::O_IMG_OPTM_WEBP; ?>
104
+ <?php $this->title( $id ); ?>
105
  </th>
106
  <td>
107
+ <?php $this->build_switch( $id ); ?>
108
  <div class="litespeed-desc">
109
+ <?php echo __( 'Request WebP versions of original images when doing optimization.', 'litespeed-cache' ); ?>
110
  </div>
111
  </td>
112
  </tr>
114
  <?php
115
  if ( ! is_multisite() ) :
116
  // webp
117
+ require LSCWP_DIR . 'tpl/img_optm/settings.media_webp.tpl.php';
118
 
119
+ endif;
120
  ?>
121
 
122
  <tr>
123
  <th>
124
+ <?php $id = Base::O_IMG_OPTM_WEBP_ATTR; ?>
125
+ <?php $this->title( $id ); ?>
126
  </th>
127
  <td>
128
 
129
  <div class="litespeed-textarea-recommended">
130
  <div>
131
+ <?php $this->build_textarea( $id, 40 ); ?>
132
  </div>
133
  <div>
134
+ <?php $this->recommended( $id ); ?>
135
  </div>
136
  </div>
137
 
138
  <div class="litespeed-desc">
139
+ <?php echo __( 'Specify which element attributes will be replaced with WebP.', 'litespeed-cache' ); ?>
140
+ <?php echo __( 'Only attributes listed here will be replaced.', 'litespeed-cache' ); ?>
141
+ <br /><?php echo sprintf( __( 'Use the format %1$s or %2$s (element is optional).', 'litespeed-cache' ), '<code>element.attribute</code>', '<code>.attribute</code>' ); ?>
142
+ <?php Doc::one_per_line(); ?>
143
  </div>
144
  </td>
145
  </tr>
146
 
147
  <tr>
148
  <th>
149
+ <?php $id = Base::O_IMG_OPTM_WEBP_REPLACE_SRCSET; ?>
150
+ <?php $this->title( $id ); ?>
151
  </th>
152
  <td>
153
+ <?php $this->build_switch( $id ); ?>
154
  <div class="litespeed-desc">
155
+ <?php echo sprintf( __( 'Enable replacement of WebP in %s elements that were generated outside of WordPress logic.', 'litespeed-cache' ), '<code>srcset</code>' ); ?>
156
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/imageopt/#webp-for-extra-srcset' ); ?>
157
  </div>
158
  </td>
159
  </tr>
160
 
161
  <tr>
162
  <th>
163
+ <?php $id = Base::O_IMG_OPTM_JPG_QUALITY; ?>
164
+ <?php $this->title( $id ); ?>
165
  </th>
166
  <td>
167
+ <?php $this->build_input( $id, 'litespeed-input-short' ); ?>
168
  <div class="litespeed-desc">
169
  <?php echo __('The image compression quality setting of WordPress out of 100.', 'litespeed-cache'); ?>
170
+ <?php $this->recommended( $id ); ?>
171
+ <?php $this->_validate_ttl( $id, 0, 100 ); ?>
172
  </div>
173
  </td>
174
  </tr>
176
 
177
  <?php
178
 
179
+ $this->form_end();
180
 
181
 
182
 
tpl/page_optm/entry.tpl.php CHANGED
@@ -8,7 +8,7 @@ $menu_list = array(
8
  'settings_html' => __( 'Optimization Settings', 'litespeed-cache' ),
9
  'settings_media' => __( 'Media Settings', 'litespeed-cache' ),
10
  'settings_media_exc' => __( 'Media Excludes', 'litespeed-cache' ),
11
- 'settings_discussion' => __( 'Discussion Settings', 'litespeed-cache' ),
12
  'settings_tuning' => __( 'Tuning Settings', 'litespeed-cache' ),
13
  ) ;
14
 
8
  'settings_html' => __( 'Optimization Settings', 'litespeed-cache' ),
9
  'settings_media' => __( 'Media Settings', 'litespeed-cache' ),
10
  'settings_media_exc' => __( 'Media Excludes', 'litespeed-cache' ),
11
+ 'settings_localization' => __( 'Localization Settings', 'litespeed-cache' ),
12
  'settings_tuning' => __( 'Tuning Settings', 'litespeed-cache' ),
13
  ) ;
14
 
tpl/page_optm/settings_css.tpl.php CHANGED
@@ -9,7 +9,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_CCSS );
9
 
10
  <h3 class="litespeed-title-short">
11
  <?php echo __( 'CSS Settings', 'litespeed-cache' ); ?>
12
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/', false, 'litespeed-learn-more' ); ?>
13
  </h3>
14
 
15
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -181,7 +181,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_CCSS );
181
  <div class="litespeed-desc">
182
  <?php echo __( 'Automatically generate critical CSS in the background via a cron-based queue.', 'litespeed-cache' ); ?>
183
  <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ); ?>
184
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#generate-critical-css-in-the-background' ); ?>
185
  </div>
186
 
187
  <?php if ( $css_summary ) : ?>
@@ -230,7 +230,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_CCSS );
230
  <div class="litespeed-desc">
231
  <?php echo __('List post types where each item of that type should have its own CCSS generated.', 'litespeed-cache'); ?>
232
  <?php echo sprintf( __( 'For example, if every Page on the site has different formatting, enter %s in the box. Separate critical CSS files will be stored for every Page on the site.', 'litespeed-cache' ), '<code>page</code>' ); ?>
233
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#separate-ccss-cache-post-types' ); ?>
234
  </div>
235
  </td>
236
  </tr>
9
 
10
  <h3 class="litespeed-title-short">
11
  <?php echo __( 'CSS Settings', 'litespeed-cache' ); ?>
12
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/' ); ?>
13
  </h3>
14
 
15
  <table class="wp-list-table striped litespeed-table"><tbody>
181
  <div class="litespeed-desc">
182
  <?php echo __( 'Automatically generate critical CSS in the background via a cron-based queue.', 'litespeed-cache' ); ?>
183
  <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ); ?>
184
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#generate-critical-css-in-the-background' ); ?>
185
  </div>
186
 
187
  <?php if ( $css_summary ) : ?>
230
  <div class="litespeed-desc">
231
  <?php echo __('List post types where each item of that type should have its own CCSS generated.', 'litespeed-cache'); ?>
232
  <?php echo sprintf( __( 'For example, if every Page on the site has different formatting, enter %s in the box. Separate critical CSS files will be stored for every Page on the site.', 'litespeed-cache' ), '<code>page</code>' ); ?>
233
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#separate-ccss-cache-post-types' ); ?>
234
  </div>
235
  </td>
236
  </tr>
tpl/page_optm/settings_discussion.tpl.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
-
5
- $last_generated = Avatar::get_summary() ;
6
- $avatar_queue = Avatar::get_instance()->queue_count();
7
- ?>
8
-
9
- <?php if ( Avatar::need_db() && ! Data::get_instance()->tb_exist( 'avatar' ) ) : ?>
10
- <div class="litespeed-callout notice notice-error inline">
11
- <h4><?php echo __( 'WARNING', 'litespeed-cache' ) ; ?></h4>
12
- <p><?php echo sprintf( __( 'Failed to create Avatar table. Please follow <a %s>Table Creation guidance from LiteSpeed Wiki</a> to finish setup.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation" target="_blank"' ) ; ?></p>
13
- </div>
14
- <?php endif; ?>
15
-
16
- <h3 class="litespeed-title-short">
17
- <?php echo __( 'Discussion Settings', 'litespeed-cache' ) ; ?>
18
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#discussion-settings-tab', false, 'litespeed-learn-more' ) ; ?>
19
- </h3>
20
-
21
- <table class="wp-list-table striped litespeed-table"><tbody>
22
- <tr>
23
- <th>
24
- <?php $id = Base::O_DISCUSS_AVATAR_CACHE ; ?>
25
- <?php $this->title( $id ) ; ?>
26
- </th>
27
- <td>
28
- <?php $this->build_switch( $id ) ; ?>
29
- <div class="litespeed-desc">
30
- <?php echo __( 'Store Gravatar locally.', 'litespeed-cache' ) ; ?>
31
- <?php echo __( 'Accelerates the speed by caching Gravatar (Globally Recognized Avatars).', 'litespeed-cache' ) ; ?>
32
- </div>
33
- </td>
34
- </tr>
35
-
36
- <tr>
37
- <th>
38
- <?php $id = Base::O_DISCUSS_AVATAR_CRON ; ?>
39
- <?php $this->title( $id ) ; ?>
40
- </th>
41
- <td>
42
- <?php $this->build_switch( $id ) ; ?>
43
- <div class="litespeed-desc">
44
- <?php echo __( 'Refresh Gravatar cache by cron.', 'litespeed-cache' ) ; ?>
45
- </div>
46
-
47
- <?php if ( $last_generated ) : ?>
48
- <div class="litespeed-desc">
49
- <?php if ( ! empty( $last_generated[ 'last_request' ] ) ) : ?>
50
- <p>
51
- <?php echo __( 'Last ran', 'litespeed-cache' ) . ': <code>' . Utility::readable_time( $last_generated[ 'last_request' ] ) . '</code>' ; ?>
52
- </p>
53
- <?php endif ; ?>
54
- <?php if ( $avatar_queue ) : ?>
55
- <div class="litespeed-callout notice notice-warning inline">
56
- <h4>
57
- <?php echo __( 'Avatar list in queue waiting for update','litespeed-cache' ) ; ?>:
58
- <?php echo $avatar_queue ; ?>
59
- </h4>
60
- </div>
61
- <a href="<?php echo Utility::build_url( Router::ACTION_AVATAR, Avatar::TYPE_GENERATE ) ; ?>" class="button litespeed-btn-success">
62
- <?php echo __( 'Run Queue Manually', 'litespeed-cache' ) ; ?>
63
- </a>
64
- <?php endif ; ?>
65
- </div>
66
- <?php endif ; ?>
67
-
68
- </td>
69
- </tr>
70
-
71
- <tr>
72
- <th>
73
- <?php $id = Base::O_DISCUSS_AVATAR_CACHE_TTL ; ?>
74
- <?php $this->title( $id ) ; ?>
75
- </th>
76
- <td>
77
- <?php $this->build_input( $id ) ; ?> <?php $this->readable_seconds() ; ?>
78
- <div class="litespeed-desc">
79
- <?php echo __( 'Specify how long, in seconds, Gravatar files are cached.', 'litespeed-cache' ) ; ?>
80
- <?php $this->recommended( $id ) ; ?>
81
- <?php $this->_validate_ttl( $id, 3600 ) ; ?>
82
- </div>
83
- </td>
84
- </tr>
85
-
86
- </tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tpl/page_optm/settings_html.tpl.php CHANGED
@@ -1,131 +1,130 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
- <?php echo __( 'Optimization Settings', 'litespeed-cache' ) ; ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#optimization-settings-tab', false, 'litespeed-learn-more' ) ; ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
- <?php $id = Base::O_OPTM_TTL ; ?>
16
- <?php $this->title( $id ) ; ?>
17
  </th>
18
  <td>
19
- <?php $this->build_input( $id ) ; ?> <?php $this->readable_seconds() ; ?>
20
  <div class="litespeed-desc">
21
- <?php echo __( 'Specify how long, in seconds, CSS/JS files are cached.', 'litespeed-cache' ) ; ?>
22
- <?php $this->recommended( $id ) ; ?>
23
- <?php $this->_validate_ttl( $id, 3600 ) ; ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
- <?php $id = Base::O_OPTM_HTML_MIN ; ?>
31
- <?php $this->title( $id ) ; ?>
32
  </th>
33
  <td>
34
- <?php $this->build_switch( $id ) ; ?>
35
  <div class="litespeed-desc">
36
- <?php echo __( 'Minify HTML content.', 'litespeed-cache' ) ; ?>
37
  </div>
38
  </td>
39
  </tr>
40
 
41
  <tr>
42
  <th class="litespeed-padding-left">
43
- <?php $id = Base::O_OPTM_CSS_INLINE_MIN ; ?>
44
- <?php $this->title( $id ) ; ?>
45
  </th>
46
  <td>
47
- <?php $this->build_switch( $id ) ; ?>
48
  <div class="litespeed-desc">
49
- <?php echo __( 'Minify inline CSS code.', 'litespeed-cache' ) ; ?>
50
  </div>
51
  </td>
52
  </tr>
53
 
54
  <tr>
55
  <th class="litespeed-padding-left">
56
- <?php $id = Base::O_OPTM_JS_INLINE_MIN ; ?>
57
- <?php $this->title( $id ) ; ?>
58
  </th>
59
  <td>
60
- <?php $this->build_switch( $id ) ; ?>
61
  <div class="litespeed-desc">
62
- <?php echo __( 'Minify inline JS code.', 'litespeed-cache' ) ; ?>
63
  </div>
64
  </td>
65
  </tr>
66
 
67
  <tr>
68
  <th>
69
- <?php $id = Base::O_OPTM_DNS_PREFETCH ; ?>
70
- <?php $this->title( $id ) ; ?>
71
  </th>
72
  <td>
73
- <?php $this->build_textarea( $id ) ; ?>
74
  <div class="litespeed-desc">
75
- <?php echo __( 'Prefetching DNS can reduce latency for visitors.', 'litespeed-cache' ) ; ?>
76
- <?php echo __( 'For example', 'litespeed-cache' ) ; ?>: <code>//www.example.com</code>
77
- <?php Doc::one_per_line() ; ?>
78
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#dns-prefetch' ) ; ?>
79
  </div>
80
  </td>
81
  </tr>
82
 
83
  <tr>
84
  <th>
85
- <?php $id = Base::O_OPTM_DNS_PREFETCH_CTRL ; ?>
86
- <?php $this->title( $id ) ; ?>
87
  </th>
88
  <td>
89
- <?php $this->build_switch( $id ) ; ?>
90
  <div class="litespeed-desc">
91
- <?php echo __( 'Widely enable DNS prefetch for URLs in the document, including images, CSS, JavaScript, and so forth.', 'litespeed-cache' ) ; ?>
92
- <?php echo __( 'This can improve the page loading speed.', 'litespeed-cache' ) ; ?>
93
- <?php $this->learn_more( 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control' ) ; ?>
94
  </div>
95
  </td>
96
  </tr>
97
 
98
  <tr>
99
  <th>
100
- <?php $id = Base::O_OPTM_RM_COMMENT ; ?>
101
- <?php $this->title( $id ) ; ?>
102
  </th>
103
  <td>
104
- <?php $this->build_switch( $id ) ; ?>
105
  <div class="litespeed-desc">
106
- <?php echo __( 'Remove the comments inside of JS/CSS files when minifying.', 'litespeed-cache' ) ; ?>
107
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
108
  </div>
109
  </td>
110
  </tr>
111
 
112
  <tr>
113
  <th>
114
- <?php $id = Base::O_OPTM_QS_RM ; ?>
115
- <?php $this->title( $id ) ; ?>
116
  </th>
117
  <td>
118
- <?php $this->build_switch( $id ) ; ?>
119
  <div class="litespeed-desc">
120
- <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ) ; ?>
121
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
122
  <br /><font class="litespeed-warning">
123
  ⚠️
124
- <?php echo __( 'Google reCAPTCHA will be bypassed automatically.', 'litespeed-cache' ) ; ?>
125
  </font>
126
  <br /><font class="litespeed-success">
127
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
128
- <?php echo sprintf( __( 'Append query string %s to the resources to bypass this action.', 'litespeed-cache' ), '<code>&_litespeed_rm_qs=0</code>' ) ; ?>
129
  </font>
130
  </div>
131
  </td>
@@ -133,42 +132,42 @@ defined( 'WPINC' ) || exit ;
133
 
134
  <tr>
135
  <th>
136
- <?php $id = Base::O_OPTM_GGFONTS_ASYNC ; ?>
137
- <?php $this->title( $id ) ; ?>
138
  </th>
139
  <td>
140
- <?php $this->build_switch( $id ) ; ?>
141
  <div class="litespeed-desc">
142
- <?php echo __( 'Use Web Font Loader library to load Google Fonts asynchronously while leaving other CSS intact.', 'litespeed-cache' ) ; ?>
143
- <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ) ; ?>
144
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#load-google-fonts-asynchronously' ) ; ?>
145
  </div>
146
  </td>
147
  </tr>
148
 
149
  <tr>
150
  <th>
151
- <?php $id = Base::O_OPTM_GGFONTS_RM ; ?>
152
- <?php $this->title( $id ) ; ?>
153
  </th>
154
  <td>
155
- <?php $this->build_switch( $id ) ; ?>
156
  <div class="litespeed-desc">
157
- <?php echo __( 'Prevent Google Fonts from loading on all pages.', 'litespeed-cache' ) ; ?>
158
  </div>
159
  </td>
160
  </tr>
161
 
162
  <tr>
163
  <th>
164
- <?php $id = Base::O_OPTM_EMOJI_RM ; ?>
165
- <?php $this->title( $id ) ; ?>
166
  </th>
167
  <td>
168
- <?php $this->build_switch( $id ) ; ?>
169
  <div class="litespeed-desc">
170
- <?php echo __( 'Stop loading WordPress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ) ; ?>
171
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
172
  </div>
173
  </td>
174
  </tr>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
+ <?php echo __( 'Optimization Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#optimization-settings-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
+ <?php $id = Base::O_OPTM_TTL; ?>
16
+ <?php $this->title( $id ); ?>
17
  </th>
18
  <td>
19
+ <?php $this->build_input( $id ); ?> <?php $this->readable_seconds(); ?>
20
  <div class="litespeed-desc">
21
+ <?php echo __( 'Specify how long, in seconds, CSS/JS files are cached.', 'litespeed-cache' ); ?>
22
+ <?php $this->recommended( $id ); ?>
23
+ <?php $this->_validate_ttl( $id, 3600 ); ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
+ <?php $id = Base::O_OPTM_HTML_MIN; ?>
31
+ <?php $this->title( $id ); ?>
32
  </th>
33
  <td>
34
+ <?php $this->build_switch( $id ); ?>
35
  <div class="litespeed-desc">
36
+ <?php echo __( 'Minify HTML content.', 'litespeed-cache' ); ?>
37
  </div>
38
  </td>
39
  </tr>
40
 
41
  <tr>
42
  <th class="litespeed-padding-left">
43
+ <?php $id = Base::O_OPTM_CSS_INLINE_MIN; ?>
44
+ <?php $this->title( $id ); ?>
45
  </th>
46
  <td>
47
+ <?php $this->build_switch( $id ); ?>
48
  <div class="litespeed-desc">
49
+ <?php echo __( 'Minify inline CSS code.', 'litespeed-cache' ); ?>
50
  </div>
51
  </td>
52
  </tr>
53
 
54
  <tr>
55
  <th class="litespeed-padding-left">
56
+ <?php $id = Base::O_OPTM_JS_INLINE_MIN; ?>
57
+ <?php $this->title( $id ); ?>
58
  </th>
59
  <td>
60
+ <?php $this->build_switch( $id ); ?>
61
  <div class="litespeed-desc">
62
+ <?php echo __( 'Minify inline JS code.', 'litespeed-cache' ); ?>
63
  </div>
64
  </td>
65
  </tr>
66
 
67
  <tr>
68
  <th>
69
+ <?php $id = Base::O_OPTM_DNS_PREFETCH; ?>
70
+ <?php $this->title( $id ); ?>
71
  </th>
72
  <td>
73
+ <?php $this->build_textarea( $id ); ?>
74
  <div class="litespeed-desc">
75
+ <?php echo __( 'Prefetching DNS can reduce latency for visitors.', 'litespeed-cache' ); ?>
76
+ <?php echo __( 'For example', 'litespeed-cache' ); ?>: <code>//www.example.com</code>
77
+ <?php Doc::one_per_line(); ?>
78
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#dns-prefetch' ); ?>
79
  </div>
80
  </td>
81
  </tr>
82
 
83
  <tr>
84
  <th>
85
+ <?php $id = Base::O_OPTM_DNS_PREFETCH_CTRL; ?>
86
+ <?php $this->title( $id ); ?>
87
  </th>
88
  <td>
89
+ <?php $this->build_switch( $id ); ?>
90
  <div class="litespeed-desc">
91
+ <?php echo __( 'Widely enable DNS prefetch for URLs in the document, including images, CSS, JavaScript, and so forth.', 'litespeed-cache' ); ?>
92
+ <?php echo __( 'This can improve the page loading speed.', 'litespeed-cache' ); ?>
93
+ <?php Doc::learn_more( 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-DNS-Prefetch-Control' ); ?>
94
  </div>
95
  </td>
96
  </tr>
97
 
98
  <tr>
99
  <th>
100
+ <?php $id = Base::O_OPTM_RM_COMMENT; ?>
101
+ <?php $this->title( $id ); ?>
102
  </th>
103
  <td>
104
+ <?php $this->build_switch( $id ); ?>
105
  <div class="litespeed-desc">
106
+ <?php echo __( 'Remove the comments inside of JS/CSS files when minifying.', 'litespeed-cache' ); ?>
107
+ <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
108
  </div>
109
  </td>
110
  </tr>
111
 
112
  <tr>
113
  <th>
114
+ <?php $id = Base::O_OPTM_QS_RM; ?>
115
+ <?php $this->title( $id ); ?>
116
  </th>
117
  <td>
118
+ <?php $this->build_switch( $id ); ?>
119
  <div class="litespeed-desc">
120
+ <?php echo __( 'Remove query strings from static resources.', 'litespeed-cache' ); ?>
 
121
  <br /><font class="litespeed-warning">
122
  ⚠️
123
+ <?php echo __( 'Google reCAPTCHA will be bypassed automatically.', 'litespeed-cache' ); ?>
124
  </font>
125
  <br /><font class="litespeed-success">
126
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
127
+ <?php echo sprintf( __( 'Append query string %s to the resources to bypass this action.', 'litespeed-cache' ), '<code>&_litespeed_rm_qs=0</code>' ); ?>
128
  </font>
129
  </div>
130
  </td>
132
 
133
  <tr>
134
  <th>
135
+ <?php $id = Base::O_OPTM_GGFONTS_ASYNC; ?>
136
+ <?php $this->title( $id ); ?>
137
  </th>
138
  <td>
139
+ <?php $this->build_switch( $id ); ?>
140
  <div class="litespeed-desc">
141
+ <?php echo __( 'Use Web Font Loader library to load Google Fonts asynchronously while leaving other CSS intact.', 'litespeed-cache' ); ?>
142
+ <?php echo __( 'This will also add a preconnect to Google for faster Google Fonts downloading.', 'litespeed-cache' ); ?>
143
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#load-google-fonts-asynchronously' ); ?>
144
  </div>
145
  </td>
146
  </tr>
147
 
148
  <tr>
149
  <th>
150
+ <?php $id = Base::O_OPTM_GGFONTS_RM; ?>
151
+ <?php $this->title( $id ); ?>
152
  </th>
153
  <td>
154
+ <?php $this->build_switch( $id ); ?>
155
  <div class="litespeed-desc">
156
+ <?php echo __( 'Prevent Google Fonts from loading on all pages.', 'litespeed-cache' ); ?>
157
  </div>
158
  </td>
159
  </tr>
160
 
161
  <tr>
162
  <th>
163
+ <?php $id = Base::O_OPTM_EMOJI_RM; ?>
164
+ <?php $this->title( $id ); ?>
165
  </th>
166
  <td>
167
+ <?php $this->build_switch( $id ); ?>
168
  <div class="litespeed-desc">
169
+ <?php echo __( 'Stop loading WordPress.org emoji. Browser default emoji will be displayed instead.', 'litespeed-cache' ); ?>
170
+ <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
171
  </div>
172
  </td>
173
  </tr>
tpl/page_optm/settings_js.tpl.php CHANGED
@@ -1,78 +1,78 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
- <?php echo __( 'JS Settings', 'litespeed-cache' ) ; ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-settings-tab', false, 'litespeed-learn-more' ) ; ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
- <?php $id = Base::O_OPTM_JS_MIN ; ?>
16
- <?php $this->title( $id ) ; ?>
17
  </th>
18
  <td>
19
- <?php $this->build_switch( $id ) ; ?>
20
  <div class="litespeed-desc">
21
- <?php echo __( 'Minify JS files.', 'litespeed-cache' ) ; ?>
22
  </div>
23
  </td>
24
  </tr>
25
 
26
  <tr>
27
  <th>
28
- <?php $id = Base::O_OPTM_JS_COMB ; ?>
29
- <?php $this->title( $id ) ; ?>
30
  </th>
31
  <td>
32
- <?php $this->build_switch( $id ) ; ?>
33
  <div class="litespeed-desc">
34
- <?php echo __( 'Combine JS files.', 'litespeed-cache' ) ; ?>
35
- <a href="https://docs.litespeedtech.com/lscache/lscwp/ts-optimize/" target="_blank"><?php echo __( 'How to Fix Problems Caused by CSS/JS Optimization.', 'litespeed-cache' ) ; ?></a>
36
  </div>
37
  </td>
38
  </tr>
39
 
40
  <tr>
41
  <th>
42
- <?php $id = Base::O_OPTM_JS_HTTP2 ; ?>
43
- <?php $this->title( $id ) ; ?>
44
  </th>
45
  <td>
46
- <?php $this->build_switch( $id ) ; ?>
47
  <div class="litespeed-desc">
48
- <?php echo __( 'Pre-send internal JS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ) ; ?>
49
  </div>
50
  </td>
51
  </tr>
52
 
53
  <tr>
54
  <th>
55
- <?php $id = Base::O_OPTM_JS_DEFER ; ?>
56
- <?php $this->title( $id ) ; ?>
57
  </th>
58
  <td>
59
- <?php $this->build_switch( $id ) ; ?>
60
  <div class="litespeed-desc">
61
- <?php echo __( 'Doing so can help reduce resource contention and improve performance.', 'litespeed-cache' ) ; ?>
62
- <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ) ; ?>
63
  </div>
64
  </td>
65
  </tr>
66
 
67
  <tr>
68
  <th>
69
- <?php $id = Base::O_OPTM_JS_INLINE_DEFER ; ?>
70
- <?php $this->title( $id ) ; ?>
71
  </th>
72
  <td>
73
  <?php $this->build_switch( $id, array( __( 'Default', 'litespeed-cache' ), __( 'After DOM Ready', 'litespeed-cache' ), __( 'Deferred', 'litespeed-cache' ) ) ); ?>
74
  <div class="litespeed-desc">
75
- <?php echo __( 'Loading inline JS after DOM is fully loaded can increase JS compatibility and reduce JS error when other JS optimization features are enabled.', 'litespeed-cache' ) ; ?>
76
  <br /><?php echo sprintf( __( '%s is recommended although would cause the most issues for scripts that are placed inline to avoid being deferred.', 'litespeed-cache' ), '<code>' . __( 'Deferred', 'litespeed-cache' ) . '</code>' ); ?>
77
  </div>
78
  </td>
@@ -80,16 +80,16 @@ defined( 'WPINC' ) || exit ;
80
 
81
  <tr>
82
  <th>
83
- <?php $id = Base::O_OPTM_EXC_JQ ; ?>
84
- <?php $this->title( $id ) ; ?>
85
  </th>
86
  <td>
87
- <?php $this->build_switch( $id ) ; ?>
88
  <div class="litespeed-desc">
89
- <?php echo sprintf( __( 'Improve compatibility with inline JS by preventing jQuery optimization. (Recommended Setting: %s)', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ) ) ; ?>
90
  <br /><font class="litespeed-warning">
91
  ⚠️
92
- <?php echo sprintf( __( 'If there is any JS error related to %1$s when enabled %2$s, please turn on this option.', 'litespeed-cache' ), 'jQuery', __( 'JS Combine', 'litespeed-cache' ) ) ; ?>
93
  </font>
94
  </div>
95
  </td>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
+ <?php echo __( 'JS Settings', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#js-settings-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
+ <?php $id = Base::O_OPTM_JS_MIN; ?>
16
+ <?php $this->title( $id ); ?>
17
  </th>
18
  <td>
19
+ <?php $this->build_switch( $id ); ?>
20
  <div class="litespeed-desc">
21
+ <?php echo __( 'Minify JS files.', 'litespeed-cache' ); ?>
22
  </div>
23
  </td>
24
  </tr>
25
 
26
  <tr>
27
  <th>
28
+ <?php $id = Base::O_OPTM_JS_COMB; ?>
29
+ <?php $this->title( $id ); ?>
30
  </th>
31
  <td>
32
+ <?php $this->build_switch( $id ); ?>
33
  <div class="litespeed-desc">
34
+ <?php echo __( 'Combine JS files.', 'litespeed-cache' ); ?>
35
+ <a href="https://docs.litespeedtech.com/lscache/lscwp/ts-optimize/" target="_blank"><?php echo __( 'How to Fix Problems Caused by CSS/JS Optimization.', 'litespeed-cache' ); ?></a>
36
  </div>
37
  </td>
38
  </tr>
39
 
40
  <tr>
41
  <th>
42
+ <?php $id = Base::O_OPTM_JS_HTTP2; ?>
43
+ <?php $this->title( $id ); ?>
44
  </th>
45
  <td>
46
+ <?php $this->build_switch( $id ); ?>
47
  <div class="litespeed-desc">
48
+ <?php echo __( 'Pre-send internal JS files to the browser before they are requested. (Requires the HTTP/2 protocol)', 'litespeed-cache' ); ?>
49
  </div>
50
  </td>
51
  </tr>
52
 
53
  <tr>
54
  <th>
55
+ <?php $id = Base::O_OPTM_JS_DEFER; ?>
56
+ <?php $this->title( $id ); ?>
57
  </th>
58
  <td>
59
+ <?php $this->build_switch( $id ); ?>
60
  <div class="litespeed-desc">
61
+ <?php echo __( 'Doing so can help reduce resource contention and improve performance.', 'litespeed-cache' ); ?>
62
+ <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
63
  </div>
64
  </td>
65
  </tr>
66
 
67
  <tr>
68
  <th>
69
+ <?php $id = Base::O_OPTM_JS_INLINE_DEFER; ?>
70
+ <?php $this->title( $id ); ?>
71
  </th>
72
  <td>
73
  <?php $this->build_switch( $id, array( __( 'Default', 'litespeed-cache' ), __( 'After DOM Ready', 'litespeed-cache' ), __( 'Deferred', 'litespeed-cache' ) ) ); ?>
74
  <div class="litespeed-desc">
75
+ <?php echo __( 'Loading inline JS after DOM is fully loaded can increase JS compatibility and reduce JS error when other JS optimization features are enabled.', 'litespeed-cache' ); ?>
76
  <br /><?php echo sprintf( __( '%s is recommended although would cause the most issues for scripts that are placed inline to avoid being deferred.', 'litespeed-cache' ), '<code>' . __( 'Deferred', 'litespeed-cache' ) . '</code>' ); ?>
77
  </div>
78
  </td>
80
 
81
  <tr>
82
  <th>
83
+ <?php $id = Base::O_OPTM_EXC_JQ; ?>
84
+ <?php $this->title( $id ); ?>
85
  </th>
86
  <td>
87
+ <?php $this->build_switch( $id ); ?>
88
  <div class="litespeed-desc">
89
+ <?php echo sprintf( __( 'Improve compatibility with inline JS by preventing jQuery optimization. (Recommended Setting: %s)', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ) ); ?>
90
  <br /><font class="litespeed-warning">
91
  ⚠️
92
+ <?php echo sprintf( __( 'If there is any JS error related to %1$s when enabled %2$s, please turn on this option.', 'litespeed-cache' ), 'jQuery', __( 'JS Combine', 'litespeed-cache' ) ); ?>
93
  </font>
94
  </div>
95
  </td>
tpl/page_optm/settings_localization.tpl.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
+
5
+ $last_generated = Avatar::get_summary();
6
+ $avatar_queue = Avatar::get_instance()->queue_count();
7
+ ?>
8
+
9
+ <?php if ( Avatar::need_db() && ! Data::get_instance()->tb_exist( 'avatar' ) ) : ?>
10
+ <div class="litespeed-callout notice notice-error inline">
11
+ <h4><?php echo __( 'WARNING', 'litespeed-cache' ); ?></h4>
12
+ <p><?php echo sprintf( __( 'Failed to create Avatar table. Please follow <a %s>Table Creation guidance from LiteSpeed Wiki</a> to finish setup.', 'litespeed-cache' ), 'href="https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation" target="_blank"' ); ?></p>
13
+ </div>
14
+ <?php endif; ?>
15
+
16
+ <h3 class="litespeed-title-short">
17
+ <?php echo __( 'Localization Settings', 'litespeed-cache' ); ?>
18
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#localization-settings-tab' ); ?>
19
+ </h3>
20
+
21
+ <table class="wp-list-table striped litespeed-table"><tbody>
22
+ <tr>
23
+ <th>
24
+ <?php $id = Base::O_DISCUSS_AVATAR_CACHE; ?>
25
+ <?php $this->title( $id ); ?>
26
+ </th>
27
+ <td>
28
+ <?php $this->build_switch( $id ); ?>
29
+ <div class="litespeed-desc">
30
+ <?php echo __( 'Store Gravatar locally.', 'litespeed-cache' ); ?>
31
+ <?php echo __( 'Accelerates the speed by caching Gravatar (Globally Recognized Avatars).', 'litespeed-cache' ); ?>
32
+ </div>
33
+ </td>
34
+ </tr>
35
+
36
+ <tr>
37
+ <th class="litespeed-padding-left">
38
+ <?php $id = Base::O_DISCUSS_AVATAR_CRON; ?>
39
+ <?php $this->title( $id ); ?>
40
+ </th>
41
+ <td>
42
+ <?php $this->build_switch( $id ); ?>
43
+ <div class="litespeed-desc">
44
+ <?php echo __( 'Refresh Gravatar cache by cron.', 'litespeed-cache' ); ?>
45
+ </div>
46
+
47
+ <?php if ( $last_generated ) : ?>
48
+ <div class="litespeed-desc">
49
+ <?php if ( ! empty( $last_generated[ 'last_request' ] ) ) : ?>
50
+ <p>
51
+ <?php echo __( 'Last ran', 'litespeed-cache' ) . ': <code>' . Utility::readable_time( $last_generated[ 'last_request' ] ) . '</code>'; ?>
52
+ </p>
53
+ <?php endif; ?>
54
+ <?php if ( $avatar_queue ) : ?>
55
+ <div class="litespeed-callout notice notice-warning inline">
56
+ <h4>
57
+ <?php echo __( 'Avatar list in queue waiting for update','litespeed-cache' ); ?>:
58
+ <?php echo $avatar_queue; ?>
59
+ </h4>
60
+ </div>
61
+ <a href="<?php echo Utility::build_url( Router::ACTION_AVATAR, Avatar::TYPE_GENERATE ); ?>" class="button litespeed-btn-success">
62
+ <?php echo __( 'Run Queue Manually', 'litespeed-cache' ); ?>
63
+ </a>
64
+ <?php endif; ?>
65
+ </div>
66
+ <?php endif; ?>
67
+
68
+ </td>
69
+ </tr>
70
+
71
+ <tr>
72
+ <th class="litespeed-padding-left">
73
+ <?php $id = Base::O_DISCUSS_AVATAR_CACHE_TTL; ?>
74
+ <?php $this->title( $id ); ?>
75
+ </th>
76
+ <td>
77
+ <?php $this->build_input( $id ); ?> <?php $this->readable_seconds(); ?>
78
+ <div class="litespeed-desc">
79
+ <?php echo __( 'Specify how long, in seconds, Gravatar files are cached.', 'litespeed-cache' ); ?>
80
+ <?php $this->recommended( $id ); ?>
81
+ <?php $this->_validate_ttl( $id, 3600 ); ?>
82
+ </div>
83
+ </td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <th>
88
+ <?php $id = Base::O_OPTM_LOCALIZE; ?>
89
+ <?php $this->title( $id ); ?>
90
+ </th>
91
+ <td>
92
+ <?php $this->build_switch( $id ); ?>
93
+ <div class="litespeed-desc">
94
+ <?php echo __( 'Localize external resources.', 'litespeed-cache' ); ?>
95
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#localize' ); ?>
96
+ </div>
97
+ </td>
98
+ </tr>
99
+
100
+ <tr>
101
+ <th class="litespeed-padding-left">
102
+ <?php $id = Base::O_OPTM_LOCALIZE_DOMAINS; ?>
103
+ <?php $this->title( $id ); ?>
104
+ </th>
105
+ <td>
106
+ <div class="litespeed-textarea-recommended">
107
+ <div>
108
+ <?php $this->build_textarea( $id ); ?>
109
+ </div>
110
+ <div>
111
+ <?php $this->recommended( $id, true ); ?>
112
+ </div>
113
+ </div>
114
+
115
+ <div class="litespeed-desc">
116
+ <?php echo __( 'Resources from the domains listed here will be copied and replaced with local URLs.', 'litespeed-cache' ); ?>
117
+ <?php echo __( 'HTTPS sources only.', 'litespeed-cache' ); ?>
118
+
119
+ <br /><?php echo __( 'List as file format (optional) + URL, separated by a space.', 'litespeed-cache' ); ?>
120
+ <?php Doc::one_per_line(); ?>
121
+
122
+ <br /><?php echo sprintf( __( 'Comments are supported. Start a line with a %s to turn it into a comment line.', 'litespeed-cache' ), '<code>#</code>' ); ?>
123
+
124
+ <br />
125
+ <?php echo sprintf( __( 'If format is not specified, %s is assumed.', 'litespeed-cache' ), '<code>JS</code>' ); ?>
126
+ <?php echo __( 'Currently format supports', 'litespeed-cache' ) . ':<code>JS</code>'; ?>.
127
+
128
+ <br /><?php echo sprintf( __( '%s format will be added in a future version.', 'litespeed-cache' ), '<code>FONT</code>' ); ?>.
129
+ <?php echo __( 'The format will affect the response content type header.', 'litespeed-cache' ); ?>
130
+
131
+ <br /><?php echo __( 'For example', 'litespeed-cache' ); ?>: <code>https://www.example.com</code> <?php echo __( 'or', 'litespeed-cache' ); ?> <code>JS https://cdnjs.com</code>
132
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#localization-domains' ); ?>
133
+
134
+ <!--<br /><?php echo __( 'Example 2', 'litespeed-cache' ); ?>: <code>FONT https://fonts.googleapis.com</code>-->
135
+
136
+ </div>
137
+ </td>
138
+ </tr>
139
+
140
+ </tbody></table>
tpl/page_optm/settings_media.tpl.php CHANGED
@@ -10,7 +10,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_LQIP );
10
 
11
  <h3 class="litespeed-title-short">
12
  <?php echo __( 'Media Settings', 'litespeed-cache' ); ?>
13
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#media-settings-tab', false, 'litespeed-learn-more' ); ?>
14
  </h3>
15
 
16
  <table class="wp-list-table striped litespeed-table"><tbody>
@@ -103,7 +103,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_LQIP );
103
  <div class="litespeed-desc">
104
  <?php echo __( 'Use QUIC.cloud LQIP (Low Quality Image Placeholder) generator service for responsive image previews while loading.', 'litespeed-cache' ); ?>
105
  <br /><?php echo __( 'Keep this off to use plain color placeholders.', 'litespeed-cache' ); ?>
106
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#lqip-cloud-generator' ); ?>
107
  </div>
108
  </td>
109
  </tr>
@@ -157,7 +157,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_LQIP );
157
  '<code>' . Lang::title( Base::O_MEDIA_PLACEHOLDER_RESP_SVG ) . '</code>'
158
  ); ?>
159
  <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ); ?>
160
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#generate-lqip-in-background' ); ?>
161
  </div>
162
 
163
  <?php if ( $placeholder_summary ) : ?>
@@ -212,7 +212,7 @@ $closest_server = Cloud::get_summary( 'server.' . Cloud::SVC_LQIP );
212
  <div class="litespeed-desc">
213
  <?php echo __( 'Include the lazy load image JavaScript library inline.', 'litespeed-cache' ); ?>
214
  <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
215
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#inline-lazy-load-images-library' ); ?>
216
  </div>
217
  </td>
218
  </tr>
10
 
11
  <h3 class="litespeed-title-short">
12
  <?php echo __( 'Media Settings', 'litespeed-cache' ); ?>
13
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#media-settings-tab' ); ?>
14
  </h3>
15
 
16
  <table class="wp-list-table striped litespeed-table"><tbody>
103
  <div class="litespeed-desc">
104
  <?php echo __( 'Use QUIC.cloud LQIP (Low Quality Image Placeholder) generator service for responsive image previews while loading.', 'litespeed-cache' ); ?>
105
  <br /><?php echo __( 'Keep this off to use plain color placeholders.', 'litespeed-cache' ); ?>
106
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#lqip-cloud-generator' ); ?>
107
  </div>
108
  </td>
109
  </tr>
157
  '<code>' . Lang::title( Base::O_MEDIA_PLACEHOLDER_RESP_SVG ) . '</code>'
158
  ); ?>
159
  <?php echo sprintf( __( 'If set to %s this is done in the foreground, which may slow down page load.', 'litespeed-cache' ), '<code>' . __('OFF', 'litespeed-cache') . '</code>' ); ?>
160
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#generate-lqip-in-background' ); ?>
161
  </div>
162
 
163
  <?php if ( $placeholder_summary ) : ?>
212
  <div class="litespeed-desc">
213
  <?php echo __( 'Include the lazy load image JavaScript library inline.', 'litespeed-cache' ); ?>
214
  <?php echo __( 'This can improve your speed score in services like Pingdom, GTmetrix and PageSpeed.', 'litespeed-cache' ); ?>
215
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#inline-lazy-load-images-library' ); ?>
216
  </div>
217
  </td>
218
  </tr>
tpl/page_optm/settings_media_exc.tpl.php CHANGED
@@ -1,30 +1,30 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
- <?php echo __( 'Media Excludes', 'litespeed-cache' ) ; ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#media-excludes-tab', false, 'litespeed-learn-more' ) ; ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
- <?php $id = Base::O_MEDIA_LAZY_EXC ; ?>
16
- <?php $this->title( $id ) ; ?>
17
  </th>
18
  <td>
19
- <?php $this->build_textarea( $id ) ; ?>
20
  <div class="litespeed-desc">
21
- <?php echo __( 'Listed images will not be lazy loaded.', 'litespeed-cache' ) ; ?>
22
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
23
- <?php Doc::one_per_line() ; ?>
24
  <br /><font class="litespeed-success">
25
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
26
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_media_lazy_img_excludes</code>' ) ; ?>
27
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-lazy="1"</code>' ) ; ?>
28
  </font>
29
  </div>
30
  </td>
@@ -32,80 +32,80 @@ defined( 'WPINC' ) || exit ;
32
 
33
  <tr>
34
  <th>
35
- <?php $id = Base::O_MEDIA_LAZY_CLS_EXC ; ?>
36
- <?php $this->title( $id ) ; ?>
37
  </th>
38
  <td>
39
  <div class="litespeed-textarea-recommended">
40
  <div>
41
- <?php $this->build_textarea( $id ) ; ?>
42
  </div>
43
  <div>
44
- <?php $this->recommended( $id, true ); ?>
45
  </div>
46
  </div>
47
 
48
  <div class="litespeed-desc">
49
- <?php echo __( 'Images containing these class names will not be lazy loaded.', 'litespeed-cache' ) ; ?>
50
- <?php echo __( 'Both full and partial strings can be used.', 'litespeed-cache' ) ; ?>
51
- <?php Doc::one_per_line() ; ?>
52
  </div>
53
  </td>
54
  </tr>
55
 
56
  <tr>
57
  <th>
58
- <?php $id = Base::O_MEDIA_LAZY_PARENT_CLS_EXC ; ?>
59
- <?php $this->title( $id ) ; ?>
60
  </th>
61
  <td>
62
- <?php $this->build_textarea( $id ) ; ?>
63
  <div class="litespeed-desc">
64
- <?php echo __( 'Images having these parent class names will not be lazy loaded.', 'litespeed-cache' ) ; ?>
65
- <?php Doc::one_per_line() ; ?>
66
  </div>
67
  </td>
68
  </tr>
69
 
70
  <tr>
71
  <th>
72
- <?php $id = Base::O_MEDIA_IFRAME_LAZY_CLS_EXC ; ?>
73
- <?php $this->title( $id ) ; ?>
74
  </th>
75
  <td>
76
- <?php $this->build_textarea( $id ) ; ?>
77
  <div class="litespeed-desc">
78
- <?php echo __( 'Iframes containing these class names will not be lazy loaded.', 'litespeed-cache' ) ; ?>
79
- <?php echo __( 'Both full and partial strings can be used.', 'litespeed-cache' ) ; ?>
80
- <?php Doc::one_per_line() ; ?>
81
  </div>
82
  </td>
83
  </tr>
84
 
85
  <tr>
86
  <th>
87
- <?php $id = Base::O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC ; ?>
88
- <?php $this->title( $id ) ; ?>
89
  </th>
90
  <td>
91
- <?php $this->build_textarea( $id ) ; ?>
92
  <div class="litespeed-desc">
93
- <?php echo __( 'Iframes having these parent class names will not be lazy loaded.', 'litespeed-cache' ) ; ?>
94
- <?php Doc::one_per_line() ; ?>
95
  </div>
96
  </td>
97
  </tr>
98
 
99
  <tr>
100
  <th>
101
- <?php $id = Base::O_MEDIA_LAZY_URI_EXC ; ?>
102
- <?php $this->title( $id ) ; ?>
103
  </th>
104
  <td>
105
- <?php $this->build_textarea( $id ) ; ?>
106
  <div class="litespeed-desc">
107
- <?php echo __( 'Prevent any lazy load of listed pages.', 'litespeed-cache' ) ; ?>
108
- <?php $this->_uri_usage_example() ; ?>
109
  </div>
110
  </td>
111
  </tr>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
  ?>
5
 
6
  <h3 class="litespeed-title-short">
7
+ <?php echo __( 'Media Excludes', 'litespeed-cache' ); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#media-excludes-tab' ); ?>
9
  </h3>
10
 
11
  <table class="wp-list-table striped litespeed-table"><tbody>
12
 
13
  <tr>
14
  <th>
15
+ <?php $id = Base::O_MEDIA_LAZY_EXC; ?>
16
+ <?php $this->title( $id ); ?>
17
  </th>
18
  <td>
19
+ <?php $this->build_textarea( $id ); ?>
20
  <div class="litespeed-desc">
21
+ <?php echo __( 'Listed images will not be lazy loaded.', 'litespeed-cache' ); ?>
22
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ); ?>
23
+ <?php Doc::one_per_line(); ?>
24
  <br /><font class="litespeed-success">
25
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
26
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_media_lazy_img_excludes</code>' ); ?>
27
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-lazy="1"</code>' ); ?>
28
  </font>
29
  </div>
30
  </td>
32
 
33
  <tr>
34
  <th>
35
+ <?php $id = Base::O_MEDIA_LAZY_CLS_EXC; ?>
36
+ <?php $this->title( $id ); ?>
37
  </th>
38
  <td>
39
  <div class="litespeed-textarea-recommended">
40
  <div>
41
+ <?php $this->build_textarea( $id ); ?>
42
  </div>
43
  <div>
44
+ <?php $this->recommended( $id ); ?>
45
  </div>
46
  </div>
47
 
48
  <div class="litespeed-desc">
49
+ <?php echo __( 'Images containing these class names will not be lazy loaded.', 'litespeed-cache' ); ?>
50
+ <?php echo __( 'Both full and partial strings can be used.', 'litespeed-cache' ); ?>
51
+ <?php Doc::one_per_line(); ?>
52
  </div>
53
  </td>
54
  </tr>
55
 
56
  <tr>
57
  <th>
58
+ <?php $id = Base::O_MEDIA_LAZY_PARENT_CLS_EXC; ?>
59
+ <?php $this->title( $id ); ?>
60
  </th>
61
  <td>
62
+ <?php $this->build_textarea( $id ); ?>
63
  <div class="litespeed-desc">
64
+ <?php echo __( 'Images having these parent class names will not be lazy loaded.', 'litespeed-cache' ); ?>
65
+ <?php Doc::one_per_line(); ?>
66
  </div>
67
  </td>
68
  </tr>
69
 
70
  <tr>
71
  <th>
72
+ <?php $id = Base::O_MEDIA_IFRAME_LAZY_CLS_EXC; ?>
73
+ <?php $this->title( $id ); ?>
74
  </th>
75
  <td>
76
+ <?php $this->build_textarea( $id ); ?>
77
  <div class="litespeed-desc">
78
+ <?php echo __( 'Iframes containing these class names will not be lazy loaded.', 'litespeed-cache' ); ?>
79
+ <?php echo __( 'Both full and partial strings can be used.', 'litespeed-cache' ); ?>
80
+ <?php Doc::one_per_line(); ?>
81
  </div>
82
  </td>
83
  </tr>
84
 
85
  <tr>
86
  <th>
87
+ <?php $id = Base::O_MEDIA_IFRAME_LAZY_PARENT_CLS_EXC; ?>
88
+ <?php $this->title( $id ); ?>
89
  </th>
90
  <td>
91
+ <?php $this->build_textarea( $id ); ?>
92
  <div class="litespeed-desc">
93
+ <?php echo __( 'Iframes having these parent class names will not be lazy loaded.', 'litespeed-cache' ); ?>
94
+ <?php Doc::one_per_line(); ?>
95
  </div>
96
  </td>
97
  </tr>
98
 
99
  <tr>
100
  <th>
101
+ <?php $id = Base::O_MEDIA_LAZY_URI_EXC; ?>
102
+ <?php $this->title( $id ); ?>
103
  </th>
104
  <td>
105
+ <?php $this->build_textarea( $id ); ?>
106
  <div class="litespeed-desc">
107
+ <?php echo __( 'Prevent any lazy load of listed pages.', 'litespeed-cache' ); ?>
108
+ <?php $this->_uri_usage_example(); ?>
109
  </div>
110
  </td>
111
  </tr>
tpl/page_optm/settings_tuning.tpl.php CHANGED
@@ -1,43 +1,43 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
- global $wp_roles ;
6
  if ( !isset( $wp_roles ) ) {
7
- $wp_roles = new \WP_Roles() ;
8
  }
9
 
10
- $roles = array() ;
11
  foreach ( $wp_roles->roles as $k => $v ) {
12
- $roles[ $k ] = $v[ 'name' ] ;
13
  }
14
- ksort( $roles ) ;
15
 
16
  ?>
17
  <h3 class="litespeed-title-short">
18
- <?php echo __( 'Tuning Settings', 'litespeed-cache' ) ; ?>
19
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#tuning-settings-tab', false, 'litespeed-learn-more' ) ; ?>
20
  </h3>
21
 
22
  <table class="wp-list-table striped litespeed-table"><tbody>
23
 
24
  <tr>
25
  <th>
26
- <?php $id = Base::O_OPTM_CSS_COMB_PRIO ; ?>
27
- <?php $this->title( $id ) ; ?>
28
  </th>
29
  <td>
30
- <?php $this->build_switch( $id ) ; ?>
31
  <div class="litespeed-desc">
32
- <?php echo __( 'Load combined CSS files before other CSS files.', 'litespeed-cache' ) ; ?>
33
- <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
34
  <br /><font class="litespeed-warning">
35
  ⚠️
36
- <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined CSS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
37
  </font>
38
  <br /><font class="litespeed-success">
39
  <?php echo __('API', 'litespeed-cache'); ?>:
40
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ) ; ?>
41
  </font>
42
  </div>
43
  </td>
@@ -45,19 +45,19 @@ ksort( $roles ) ;
45
 
46
  <tr>
47
  <th>
48
- <?php $id = Base::O_OPTM_CSS_EXC ; ?>
49
- <?php $this->title( $id ) ; ?>
50
  </th>
51
  <td>
52
- <?php $this->build_textarea( $id ) ; ?>
53
  <div class="litespeed-desc">
54
- <?php echo __( 'Listed CSS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
55
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
56
- <?php Doc::one_per_line() ; ?>
57
  <br /><font class="litespeed-success">
58
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
59
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optimize_css_excludes</code>' ) ; ?>
60
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
61
  </font>
62
  </div>
63
  </td>
@@ -65,21 +65,21 @@ ksort( $roles ) ;
65
 
66
  <tr>
67
  <th>
68
- <?php $id = Base::O_OPTM_JS_COMB_PRIO ; ?>
69
- <?php $this->title( $id ) ; ?>
70
  </th>
71
  <td>
72
- <?php $this->build_switch( $id ) ; ?>
73
  <div class="litespeed-desc">
74
- <?php echo __( 'Load combined JS files before other JS files.', 'litespeed-cache' ) ; ?>
75
- <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ) ; ?>
76
  <br /><font class="litespeed-warning">
77
  ⚠️
78
- <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined JS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ) ; ?>
79
  </font>
80
  <br /><font class="litespeed-success">
81
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
82
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top/bottom.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ) ; ?>
83
  </font>
84
  </div>
85
  </td>
@@ -87,19 +87,19 @@ ksort( $roles ) ;
87
 
88
  <tr>
89
  <th>
90
- <?php $id = Base::O_OPTM_JS_EXC ; ?>
91
- <?php $this->title( $id ) ; ?>
92
  </th>
93
  <td>
94
- <?php $this->build_textarea( $id ) ; ?>
95
  <div class="litespeed-desc">
96
- <?php echo __( 'Listed JS files will not be minified/combined.', 'litespeed-cache' ) ; ?>
97
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
98
- <?php Doc::one_per_line() ; ?>
99
  <br /><font class="litespeed-success">
100
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
101
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optimize_js_excludes</code>' ) ; ?>
102
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ) ; ?>
103
  </font>
104
  </div>
105
  </td>
@@ -107,47 +107,47 @@ ksort( $roles ) ;
107
 
108
  <tr>
109
  <th>
110
- <?php $id = Base::O_OPTM_MAX_SIZE ; ?>
111
- <?php $this->title( $id ) ; ?>
112
  </th>
113
  <td>
114
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?> <?php echo __( 'MB', 'litespeed-cache' ) ; ?>
115
  <div class="litespeed-desc">
116
- <?php echo __( 'Specify the maximum size in megabytes for combined files.', 'litespeed-cache' ) ; ?>
117
- <?php echo __( 'Larger numbers will generate fewer files, which is better for achieving higher page scores, but can cause heavy memory usage.', 'litespeed-cache' ) ; ?>
118
- <?php $this->recommended( $id ) ; ?>
119
  </div>
120
  </td>
121
  </tr>
122
 
123
  <tr>
124
  <th>
125
- <?php $id = Base::O_OPTM_CCSS_CON ; ?>
126
- <?php $this->title( $id ) ; ?>
127
  </th>
128
  <td>
129
- <?php $this->build_textarea( $id ) ; ?>
130
  <div class="litespeed-desc">
131
- <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ) ; ?>
132
  </div>
133
  </td>
134
  </tr>
135
 
136
  <tr>
137
  <th>
138
- <?php $id = Base::O_OPTM_JS_DEFER_EXC ; ?>
139
- <?php $this->title( $id ) ; ?>
140
  </th>
141
  <td>
142
- <?php $this->build_textarea( $id ) ; ?>
143
  <div class="litespeed-desc">
144
- <?php echo __( 'Listed JS files will not be deferred.', 'litespeed-cache' ) ; ?>
145
- <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ) ; ?>
146
- <?php Doc::one_per_line() ; ?>
147
  <br /><span class="litespeed-success">
148
- <?php echo __( 'API', 'litespeed-cache' ) ; ?>:
149
- <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optm_js_defer_exc</code>' ) ; ?>
150
- <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-defer="1"</code>' ) ; ?>
151
  </span>
152
  </div>
153
  </td>
@@ -155,33 +155,47 @@ ksort( $roles ) ;
155
 
156
  <tr>
157
  <th>
158
- <?php $id = Base::O_OPTM_EXC ; ?>
159
- <?php $this->title( $id ) ; ?>
160
  </th>
161
  <td>
162
- <?php $this->build_textarea( $id ) ; ?>
163
  <div class="litespeed-desc">
164
- <?php echo __( 'Prevent any optimization of listed pages.', 'litespeed-cache' ) ; ?>
165
- <?php $this->_uri_usage_example() ; ?>
166
  </div>
167
  </td>
168
  </tr>
169
 
170
  <tr>
171
  <th>
172
- <?php $id = Base::O_OPTM_EXC_ROLES ; ?>
173
- <?php $this->title( $id ) ; ?>
174
  </th>
175
  <td>
 
176
  <div class="litespeed-desc">
177
- <?php echo __( 'Selected roles will be excluded from all optimizations.', 'litespeed-cache' ) ; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  </div>
179
  <div class="litespeed-tick-list">
180
  <?php foreach ( $roles as $role => $title ): ?>
181
- <?php $this->build_checkbox( $id . '[]', $title, $this->__cfg->in_optm_exc_roles( $role ), $role ) ; ?>
182
  <?php endforeach; ?>
183
  </div>
184
-
185
  </td>
186
  </tr>
187
 
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
+ global $wp_roles;
6
  if ( !isset( $wp_roles ) ) {
7
+ $wp_roles = new \WP_Roles();
8
  }
9
 
10
+ $roles = array();
11
  foreach ( $wp_roles->roles as $k => $v ) {
12
+ $roles[ $k ] = $v[ 'name' ];
13
  }
14
+ ksort( $roles );
15
 
16
  ?>
17
  <h3 class="litespeed-title-short">
18
+ <?php echo __( 'Tuning Settings', 'litespeed-cache' ); ?>
19
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/pageopt/#tuning-settings-tab' ); ?>
20
  </h3>
21
 
22
  <table class="wp-list-table striped litespeed-table"><tbody>
23
 
24
  <tr>
25
  <th>
26
+ <?php $id = Base::O_OPTM_CSS_COMB_PRIO; ?>
27
+ <?php $this->title( $id ); ?>
28
  </th>
29
  <td>
30
+ <?php $this->build_switch( $id ); ?>
31
  <div class="litespeed-desc">
32
+ <?php echo __( 'Load combined CSS files before other CSS files.', 'litespeed-cache' ); ?>
33
+ <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ); ?>
34
  <br /><font class="litespeed-warning">
35
  ⚠️
36
+ <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined CSS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ); ?>
37
  </font>
38
  <br /><font class="litespeed-success">
39
  <?php echo __('API', 'litespeed-cache'); ?>:
40
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ); ?>
41
  </font>
42
  </div>
43
  </td>
45
 
46
  <tr>
47
  <th>
48
+ <?php $id = Base::O_OPTM_CSS_EXC; ?>
49
+ <?php $this->title( $id ); ?>
50
  </th>
51
  <td>
52
+ <?php $this->build_textarea( $id ); ?>
53
  <div class="litespeed-desc">
54
+ <?php echo __( 'Listed CSS files will not be minified/combined.', 'litespeed-cache' ); ?>
55
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ); ?>
56
+ <?php Doc::one_per_line(); ?>
57
  <br /><font class="litespeed-success">
58
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
59
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optimize_css_excludes</code>' ); ?>
60
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ); ?>
61
  </font>
62
  </div>
63
  </td>
65
 
66
  <tr>
67
  <th>
68
+ <?php $id = Base::O_OPTM_JS_COMB_PRIO; ?>
69
+ <?php $this->title( $id ); ?>
70
  </th>
71
  <td>
72
+ <?php $this->build_switch( $id ); ?>
73
  <div class="litespeed-desc">
74
+ <?php echo __( 'Load combined JS files before other JS files.', 'litespeed-cache' ); ?>
75
+ <?php echo sprintf( __( 'Set to %s by default.', 'litespeed-cache' ), __( 'OFF', 'litespeed-cache' ) ); ?>
76
  <br /><font class="litespeed-warning">
77
  ⚠️
78
+ <?php echo sprintf( __( 'Only set to %s when changing the order of combined and uncombined JS is needed.', 'litespeed-cache'), __( 'ON', 'litespeed-cache' ) ); ?>
79
  </font>
80
  <br /><font class="litespeed-success">
81
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
82
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded from moving to top/bottom.', 'litespeed-cache' ), '<code>data-optimized="0"</code>' ); ?>
83
  </font>
84
  </div>
85
  </td>
87
 
88
  <tr>
89
  <th>
90
+ <?php $id = Base::O_OPTM_JS_EXC; ?>
91
+ <?php $this->title( $id ); ?>
92
  </th>
93
  <td>
94
+ <?php $this->build_textarea( $id ); ?>
95
  <div class="litespeed-desc">
96
+ <?php echo __( 'Listed JS files will not be minified/combined.', 'litespeed-cache' ); ?>
97
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ); ?>
98
+ <?php Doc::one_per_line(); ?>
99
  <br /><font class="litespeed-success">
100
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
101
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optimize_js_excludes</code>' ); ?>
102
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-optimize="1"</code>' ); ?>
103
  </font>
104
  </div>
105
  </td>
107
 
108
  <tr>
109
  <th>
110
+ <?php $id = Base::O_OPTM_MAX_SIZE; ?>
111
+ <?php $this->title( $id ); ?>
112
  </th>
113
  <td>
114
+ <?php $this->build_input( $id, 'litespeed-input-short' ); ?> <?php echo __( 'MB', 'litespeed-cache' ); ?>
115
  <div class="litespeed-desc">
116
+ <?php echo __( 'Specify the maximum size in megabytes for combined files.', 'litespeed-cache' ); ?>
117
+ <?php echo __( 'Larger numbers will generate fewer files, which is better for achieving higher page scores, but can cause heavy memory usage.', 'litespeed-cache' ); ?>
118
+ <?php $this->recommended( $id ); ?>
119
  </div>
120
  </td>
121
  </tr>
122
 
123
  <tr>
124
  <th>
125
+ <?php $id = Base::O_OPTM_CCSS_CON; ?>
126
+ <?php $this->title( $id ); ?>
127
  </th>
128
  <td>
129
+ <?php $this->build_textarea( $id ); ?>
130
  <div class="litespeed-desc">
131
+ <?php echo sprintf( __( 'Specify critical CSS rules for above-the-fold content when enabling %s.', 'litespeed-cache' ), __( 'Load CSS Asynchronously', 'litespeed-cache' ) ); ?>
132
  </div>
133
  </td>
134
  </tr>
135
 
136
  <tr>
137
  <th>
138
+ <?php $id = Base::O_OPTM_JS_DEFER_EXC; ?>
139
+ <?php $this->title( $id ); ?>
140
  </th>
141
  <td>
142
+ <?php $this->build_textarea( $id ); ?>
143
  <div class="litespeed-desc">
144
+ <?php echo __( 'Listed JS files will not be deferred.', 'litespeed-cache' ); ?>
145
+ <?php echo __( 'Both full URLs and partial strings can be used.', 'litespeed-cache' ); ?>
146
+ <?php Doc::one_per_line(); ?>
147
  <br /><span class="litespeed-success">
148
+ <?php echo __( 'API', 'litespeed-cache' ); ?>:
149
+ <?php echo sprintf( __( 'Filter %s is supported.', 'litespeed-cache' ), '<code>litespeed_optm_js_defer_exc</code>' ); ?>
150
+ <?php echo sprintf( __( 'Elements with attribute %s in html code will be excluded.', 'litespeed-cache' ), '<code>data-no-defer="1"</code>' ); ?>
151
  </span>
152
  </div>
153
  </td>
155
 
156
  <tr>
157
  <th>
158
+ <?php $id = Base::O_OPTM_JS_INLINE_DEFER_EXC; ?>
159
+ <?php $this->title( $id ); ?>
160
  </th>
161
  <td>
162
+ <?php $this->build_textarea( $id ); ?>
163
  <div class="litespeed-desc">
164
+ <?php echo __( 'Inline JS codes including the above fragments will not be deferred.', 'litespeed-cache' ); ?>
165
+ <?php Doc::one_per_line(); ?>
166
  </div>
167
  </td>
168
  </tr>
169
 
170
  <tr>
171
  <th>
172
+ <?php $id = Base::O_OPTM_EXC; ?>
173
+ <?php $this->title( $id ); ?>
174
  </th>
175
  <td>
176
+ <?php $this->build_textarea( $id ); ?>
177
  <div class="litespeed-desc">
178
+ <?php echo __( 'Prevent any optimization of listed pages.', 'litespeed-cache' ); ?>
179
+ <?php $this->_uri_usage_example(); ?>
180
+ </div>
181
+ </td>
182
+ </tr>
183
+
184
+ <tr>
185
+ <th>
186
+ <?php $id = Base::O_OPTM_EXC_ROLES; ?>
187
+ <?php $this->title( $id ); ?>
188
+ </th>
189
+ <td>
190
+ <div class="litespeed-desc">
191
+ <?php echo __( 'Selected roles will be excluded from all optimizations.', 'litespeed-cache' ); ?>
192
  </div>
193
  <div class="litespeed-tick-list">
194
  <?php foreach ( $roles as $role => $title ): ?>
195
+ <?php $this->build_checkbox( $id . '[]', $title, $this->__cfg->in_optm_exc_roles( $role ), $role ); ?>
196
  <?php endforeach; ?>
197
  </div>
198
+
199
  </td>
200
  </tr>
201
 
tpl/toolbox/beta_test.tpl.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
  ?>
5
 
6
- <?php $this->form_action( Router::ACTION_DEBUG2, Debug2::TYPE_BETA_TEST ) ; ?>
7
 
8
  <h3 class="litespeed-title">
9
  <?php echo __( 'Try GitHub Version', 'litespeed-cache' ); ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#beta-test-tab', false, 'litespeed-learn-more' ); ?>
11
  </h3>
12
 
13
  <div class="litespeed-desc"><?php echo __( 'Use this section to switch plugin versions. To beta test a GitHub commit, enter the commit URL in the field below.', 'litespeed-cache' ); ?></div>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
  ?>
5
 
6
+ <?php $this->form_action( Router::ACTION_DEBUG2, Debug2::TYPE_BETA_TEST ); ?>
7
 
8
  <h3 class="litespeed-title">
9
  <?php echo __( 'Try GitHub Version', 'litespeed-cache' ); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#beta-test-tab' ); ?>
11
  </h3>
12
 
13
  <div class="litespeed-desc"><?php echo __( 'Use this section to switch plugin versions. To beta test a GitHub commit, enter the commit URL in the field below.', 'litespeed-cache' ); ?></div>
tpl/toolbox/edit_htaccess.tpl.php CHANGED
@@ -37,7 +37,7 @@ if ( defined( 'LITESPEED_ON' ) ) {
37
 
38
  <h3 class="litespeed-title">
39
  <?php echo __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache'); ?>
40
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#edit-htaccess-tab', false, 'litespeed-learn-more' ); ?>
41
  </h3>
42
 
43
  <div class="litespeed-callout notice notice-error inline">
37
 
38
  <h3 class="litespeed-title">
39
  <?php echo __('LiteSpeed Cache Edit .htaccess', 'litespeed-cache'); ?>
40
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#edit-htaccess-tab' ); ?>
41
  </h3>
42
 
43
  <div class="litespeed-callout notice notice-error inline">
tpl/toolbox/heartbeat.tpl.php CHANGED
@@ -1,21 +1,21 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
- $this->form_action() ;
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
- <?php echo __( 'Heartbeat Control', 'litespeed-cache' ) ; ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#heartbeat-tab', false, 'litespeed-learn-more' ) ; ?>
11
  </h3>
12
 
13
  <div class="litespeed-callout notice notice-warning inline">
14
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
15
- <p><?php echo __( 'Disable WordPress interval heartbeat to reduce server load.', 'litespeed-cache' ) ; ?>
16
  <span class="litespeed-warning">
17
  🚨
18
- <?php echo __( 'Disabling this may cause WordPress tasks triggered by AJAX to stop working.', 'litespeed-cache' ) ; ?>
19
  </span></p>
20
  </div>
21
 
@@ -24,95 +24,95 @@ $this->form_action() ;
24
 
25
  <tr>
26
  <th>
27
- <?php $id = Base::O_MISC_HEARTBEAT_FRONT ; ?>
28
- <?php $this->title( $id ) ; ?>
29
  </th>
30
  <td>
31
- <?php $this->build_switch( $id ) ; ?>
32
  <div class="litespeed-desc">
33
 
34
- <?php echo __( 'Turn ON to control heartbeat on frontend.', 'litespeed-cache' ) ; ?>
35
  </div>
36
  </td>
37
  </tr>
38
 
39
  <tr>
40
  <th>
41
- <?php $id = Base::O_MISC_HEARTBEAT_FRONT_TTL ; ?>
42
- <?php $this->title( $id ) ; ?>
43
  </th>
44
  <td>
45
- <?php $this->build_input( $id, 'litespeed-input-short') ; ?> <?php $this->readable_seconds() ; ?>
46
  <div class="litespeed-desc">
47
- <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'frontend' ) ; ?>
48
- <?php echo sprintf( __( 'WordPress valid interval is %s seconds.', 'litespeed-cache' ), '<code>15</code> - <code>120</code>' ) ; ?><br />
49
- <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ) ; ?><br />
50
- <?php $this->recommended( $id ) ; ?>
51
- <?php $this->_validate_ttl( $id, 15, 120, true ) ; ?>
52
  </div>
53
  </td>
54
  </tr>
55
 
56
  <tr>
57
  <th>
58
- <?php $id = Base::O_MISC_HEARTBEAT_BACK ; ?>
59
- <?php $this->title( $id ) ; ?>
60
  </th>
61
  <td>
62
- <?php $this->build_switch( $id ) ; ?>
63
  <div class="litespeed-desc">
64
- <?php echo __( 'Turn ON to control heartbeat on backend.', 'litespeed-cache' ) ; ?>
65
  </div>
66
  </td>
67
  </tr>
68
 
69
  <tr>
70
  <th>
71
- <?php $id = Base::O_MISC_HEARTBEAT_BACK_TTL ; ?>
72
- <?php $this->title( $id ) ; ?>
73
  </th>
74
  <td>
75
- <?php $this->build_input( $id, 'litespeed-input-short') ; ?> <?php $this->readable_seconds() ; ?>
76
  <div class="litespeed-desc">
77
- <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'backend' ) ; ?>
78
- <?php echo sprintf( __( 'WordPress valid interval is %s seconds', 'litespeed-cache' ), '<code>15</code> ~ <code>120</code>' ) ; ?><br />
79
- <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ) ; ?><br />
80
- <?php $this->recommended( $id ) ; ?>
81
- <?php $this->_validate_ttl( $id, 15, 120, true ) ; ?>
82
  </div>
83
  </td>
84
  </tr>
85
 
86
  <tr>
87
  <th>
88
- <?php $id = Base::O_MISC_HEARTBEAT_EDITOR ; ?>
89
- <?php $this->title( $id ) ; ?>
90
  </th>
91
  <td>
92
- <?php $this->build_switch( $id ) ; ?>
93
  <div class="litespeed-desc">
94
- <?php echo __( 'Turn ON to control heartbeat in backend editor.', 'litespeed-cache' ) ; ?>
95
  </div>
96
  </td>
97
  </tr>
98
 
99
  <tr>
100
  <th>
101
- <?php $id = Base::O_MISC_HEARTBEAT_EDITOR_TTL ; ?>
102
- <?php $this->title( $id ) ; ?>
103
  </th>
104
  <td>
105
- <?php $this->build_input( $id, 'litespeed-input-short') ; ?> <?php $this->readable_seconds() ; ?>
106
  <div class="litespeed-desc">
107
- <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'backend editor' ) ; ?>
108
- <?php echo sprintf( __( 'WordPress valid interval is %s seconds', 'litespeed-cache' ), '<code>15</code> ~ <code>120</code>' ) ; ?><br />
109
- <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ) ; ?><br />
110
- <?php $this->recommended( $id ) ; ?>
111
- <?php $this->_validate_ttl( $id, 15, 120, true ) ; ?>
112
  </div>
113
  </td>
114
  </tr>
115
 
116
  </tbody></table>
117
 
118
- <?php $this->form_end() ; ?>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
+ $this->form_action();
6
  ?>
7
 
8
  <h3 class="litespeed-title-short">
9
+ <?php echo __( 'Heartbeat Control', 'litespeed-cache' ); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#heartbeat-tab' ); ?>
11
  </h3>
12
 
13
  <div class="litespeed-callout notice notice-warning inline">
14
  <h4><?php echo __( 'NOTICE:', 'litespeed-cache' ); ?></h4>
15
+ <p><?php echo __( 'Disable WordPress interval heartbeat to reduce server load.', 'litespeed-cache' ); ?>
16
  <span class="litespeed-warning">
17
  🚨
18
+ <?php echo __( 'Disabling this may cause WordPress tasks triggered by AJAX to stop working.', 'litespeed-cache' ); ?>
19
  </span></p>
20
  </div>
21
 
24
 
25
  <tr>
26
  <th>
27
+ <?php $id = Base::O_MISC_HEARTBEAT_FRONT; ?>
28
+ <?php $this->title( $id ); ?>
29
  </th>
30
  <td>
31
+ <?php $this->build_switch( $id ); ?>
32
  <div class="litespeed-desc">
33
 
34
+ <?php echo __( 'Turn ON to control heartbeat on frontend.', 'litespeed-cache' ); ?>
35
  </div>
36
  </td>
37
  </tr>
38
 
39
  <tr>
40
  <th>
41
+ <?php $id = Base::O_MISC_HEARTBEAT_FRONT_TTL; ?>
42
+ <?php $this->title( $id ); ?>
43
  </th>
44
  <td>
45
+ <?php $this->build_input( $id, 'litespeed-input-short'); ?> <?php $this->readable_seconds(); ?>
46
  <div class="litespeed-desc">
47
+ <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'frontend' ); ?>
48
+ <?php echo sprintf( __( 'WordPress valid interval is %s seconds.', 'litespeed-cache' ), '<code>15</code> - <code>120</code>' ); ?><br />
49
+ <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ); ?><br />
50
+ <?php $this->recommended( $id ); ?>
51
+ <?php $this->_validate_ttl( $id, 15, 120, true ); ?>
52
  </div>
53
  </td>
54
  </tr>
55
 
56
  <tr>
57
  <th>
58
+ <?php $id = Base::O_MISC_HEARTBEAT_BACK; ?>
59
+ <?php $this->title( $id ); ?>
60
  </th>
61
  <td>
62
+ <?php $this->build_switch( $id ); ?>
63
  <div class="litespeed-desc">
64
+ <?php echo __( 'Turn ON to control heartbeat on backend.', 'litespeed-cache' ); ?>
65
  </div>
66
  </td>
67
  </tr>
68
 
69
  <tr>
70
  <th>
71
+ <?php $id = Base::O_MISC_HEARTBEAT_BACK_TTL; ?>
72
+ <?php $this->title( $id ); ?>
73
  </th>
74
  <td>
75
+ <?php $this->build_input( $id, 'litespeed-input-short'); ?> <?php $this->readable_seconds(); ?>
76
  <div class="litespeed-desc">
77
+ <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'backend' ); ?>
78
+ <?php echo sprintf( __( 'WordPress valid interval is %s seconds', 'litespeed-cache' ), '<code>15</code> ~ <code>120</code>' ); ?><br />
79
+ <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ); ?><br />
80
+ <?php $this->recommended( $id ); ?>
81
+ <?php $this->_validate_ttl( $id, 15, 120, true ); ?>
82
  </div>
83
  </td>
84
  </tr>
85
 
86
  <tr>
87
  <th>
88
+ <?php $id = Base::O_MISC_HEARTBEAT_EDITOR; ?>
89
+ <?php $this->title( $id ); ?>
90
  </th>
91
  <td>
92
+ <?php $this->build_switch( $id ); ?>
93
  <div class="litespeed-desc">
94
+ <?php echo __( 'Turn ON to control heartbeat in backend editor.', 'litespeed-cache' ); ?>
95
  </div>
96
  </td>
97
  </tr>
98
 
99
  <tr>
100
  <th>
101
+ <?php $id = Base::O_MISC_HEARTBEAT_EDITOR_TTL; ?>
102
+ <?php $this->title( $id ); ?>
103
  </th>
104
  <td>
105
+ <?php $this->build_input( $id, 'litespeed-input-short'); ?> <?php $this->readable_seconds(); ?>
106
  <div class="litespeed-desc">
107
+ <?php echo sprintf( __( 'Specify the %s heartbeat interval in seconds.', 'litespeed-cache' ), 'backend editor' ); ?>
108
+ <?php echo sprintf( __( 'WordPress valid interval is %s seconds', 'litespeed-cache' ), '<code>15</code> ~ <code>120</code>' ); ?><br />
109
+ <?php echo sprintf( __( 'Set to %1$s to forbid heartbeat on %2$s.', 'litespeed-cache' ), '<code>0</code>', 'frontend' ); ?><br />
110
+ <?php $this->recommended( $id ); ?>
111
+ <?php $this->_validate_ttl( $id, 15, 120, true ); ?>
112
  </div>
113
  </td>
114
  </tr>
115
 
116
  </tbody></table>
117
 
118
+ <?php $this->form_end(); ?>
tpl/toolbox/import_export.tpl.php CHANGED
@@ -6,51 +6,51 @@ $summary = Import::get_summary();
6
  ?>
7
 
8
  <h3 class="litespeed-title">
9
- <?php echo __('Export Settings', 'litespeed-cache') ; ?>
10
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#importexport-tab', false, 'litespeed-learn-more' ); ?>
11
  </h3>
12
 
13
- <div><a href="<?php echo Utility::build_url( Router::ACTION_IMPORT, Import::TYPE_EXPORT ) ; ?>" class="button button-primary">
14
- <?php echo __( 'Export', 'litespeed-cache' ) ; ?>
15
  </a></div>
16
 
17
  <?php if ( ! empty( $summary[ 'export_file' ] ) ) : ?>
18
  <div class="litespeed-desc">
19
- <?php echo __( 'Last exported', 'litespeed-cache' ) ; ?>: <code><?php echo $summary[ 'export_file' ] ; ?></code> <?php echo Utility::readable_time( $summary[ 'export_time' ]) ; ?>
20
  </div>
21
- <?php endif ; ?>
22
 
23
  <div class="litespeed-desc">
24
- <?php echo __( 'This will export all current LiteSpeed Cache settings and save as a file.', 'litespeed-cache' ) ; ?>
25
  </div>
26
 
27
- <h3 class="litespeed-title"><?php echo __('Import Settings', 'litespeed-cache') ; ?></h3>
28
 
29
- <?php $this->form_action( Router::ACTION_IMPORT, Import::TYPE_IMPORT, true ) ; ?>
30
 
31
  <div class="litespeed-div">
32
  <input type="file" name="ls_file" class="litespeed-input" />
33
  </div>
34
  <div class="litespeed-div">
35
- <?php submit_button(__('Import', 'litespeed-cache'), 'button button-primary', 'litespeed-submit') ; ?>
36
  </div>
37
  </form>
38
 
39
  <?php if ( ! empty( $summary[ 'import_file' ] ) ) : ?>
40
  <div class="litespeed-desc">
41
- <?php echo __( 'Last imported', 'litespeed-cache' ) ; ?>: <code><?php echo $summary[ 'import_file' ] ; ?></code> <?php echo Utility::readable_time( $summary[ 'import_time' ]) ; ?>
42
  </div>
43
- <?php endif ; ?>
44
 
45
  <div class="litespeed-desc">
46
- <?php echo __( 'This will import settings from a file and override all current LiteSpeed Cache settings.', 'litespeed-cache' ) ; ?>
47
  </div>
48
 
49
- <h3 class="litespeed-title"><?php echo __('Reset All Settings', 'litespeed-cache') ; ?></h3>
50
- <div><p>🚨 <?php echo __( 'This will reset all settings to default settings.', 'litespeed-cache' ) ; ?></p>
51
  </div>
52
- <div><a href="<?php echo Utility::build_url( Router::ACTION_IMPORT, Import::TYPE_RESET ) ; ?>" data-litespeed-cfm="<?php echo __( 'Are you sure to reset all settings to default settings?', 'litespeed-cache' ) ; ?>" class="button litespeed-btn-danger-bg">
53
- <?php echo __( 'Reset Settings', 'litespeed-cache' ) ; ?>
54
  </a></div>
55
 
56
 
6
  ?>
7
 
8
  <h3 class="litespeed-title">
9
+ <?php echo __('Export Settings', 'litespeed-cache'); ?>
10
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#importexport-tab' ); ?>
11
  </h3>
12
 
13
+ <div><a href="<?php echo Utility::build_url( Router::ACTION_IMPORT, Import::TYPE_EXPORT ); ?>" class="button button-primary">
14
+ <?php echo __( 'Export', 'litespeed-cache' ); ?>
15
  </a></div>
16
 
17
  <?php if ( ! empty( $summary[ 'export_file' ] ) ) : ?>
18
  <div class="litespeed-desc">
19
+ <?php echo __( 'Last exported', 'litespeed-cache' ); ?>: <code><?php echo $summary[ 'export_file' ]; ?></code> <?php echo Utility::readable_time( $summary[ 'export_time' ]); ?>
20
  </div>
21
+ <?php endif; ?>
22
 
23
  <div class="litespeed-desc">
24
+ <?php echo __( 'This will export all current LiteSpeed Cache settings and save as a file.', 'litespeed-cache' ); ?>
25
  </div>
26
 
27
+ <h3 class="litespeed-title"><?php echo __('Import Settings', 'litespeed-cache'); ?></h3>
28
 
29
+ <?php $this->form_action( Router::ACTION_IMPORT, Import::TYPE_IMPORT, true ); ?>
30
 
31
  <div class="litespeed-div">
32
  <input type="file" name="ls_file" class="litespeed-input" />
33
  </div>
34
  <div class="litespeed-div">
35
+ <?php submit_button(__('Import', 'litespeed-cache'), 'button button-primary', 'litespeed-submit'); ?>
36
  </div>
37
  </form>
38
 
39
  <?php if ( ! empty( $summary[ 'import_file' ] ) ) : ?>
40
  <div class="litespeed-desc">
41
+ <?php echo __( 'Last imported', 'litespeed-cache' ); ?>: <code><?php echo $summary[ 'import_file' ]; ?></code> <?php echo Utility::readable_time( $summary[ 'import_time' ]); ?>
42
  </div>
43
+ <?php endif; ?>
44
 
45
  <div class="litespeed-desc">
46
+ <?php echo __( 'This will import settings from a file and override all current LiteSpeed Cache settings.', 'litespeed-cache' ); ?>
47
  </div>
48
 
49
+ <h3 class="litespeed-title"><?php echo __('Reset All Settings', 'litespeed-cache'); ?></h3>
50
+ <div><p>🚨 <?php echo __( 'This will reset all settings to default settings.', 'litespeed-cache' ); ?></p>
51
  </div>
52
+ <div><a href="<?php echo Utility::build_url( Router::ACTION_IMPORT, Import::TYPE_RESET ); ?>" data-litespeed-cfm="<?php echo __( 'Are you sure to reset all settings to default settings?', 'litespeed-cache' ); ?>" class="button litespeed-btn-danger-bg">
53
+ <?php echo __( 'Reset Settings', 'litespeed-cache' ); ?>
54
  </a></div>
55
 
56
 
tpl/toolbox/log_viewer.tpl.php CHANGED
@@ -1,29 +1,29 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
  ?>
5
 
6
  <h3 class="litespeed-title">
7
  <?php echo __('Debug Log', 'litespeed-cache'); ?>
8
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#log-view-tab', false, 'litespeed-learn-more' ); ?>
9
 
10
- <a href="<?php echo Utility::build_url( Router::ACTION_DEBUG2, Debug2::TYPE_CLEAR_LOG ) ; ?>" class="button button-primary" litespeed-accesskey='D'>
11
- <?php echo __( 'Clear Log', 'litespeed-cache' ) ; ?>
12
  </a>
13
  </h3>
14
 
15
 
16
  <?php
17
- $file = LSCWP_CONTENT_DIR . '/debug.log' ;
18
- $lines = File::count_lines( $file ) ;
19
- $start = $lines > 1000 ? $lines - 1000 : 0 ;
20
- $logs = File::read( $file, $start ) ;
21
  $logs = $logs ? implode( "\n", $logs ) : '';
22
 
23
- echo nl2br( htmlspecialchars( $logs ) ) ;
24
  ?>
25
 
26
 
27
- <a href="<?php echo Utility::build_url( Router::ACTION_DEBUG2, Debug2::TYPE_CLEAR_LOG ) ; ?>" class="button button-primary">
28
- <?php echo __( 'Clear Log', 'litespeed-cache' ) ; ?>
29
  </a>
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
  ?>
5
 
6
  <h3 class="litespeed-title">
7
  <?php echo __('Debug Log', 'litespeed-cache'); ?>
8
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#log-view-tab' ); ?>
9
 
10
+ <a href="<?php echo Utility::build_url( Router::ACTION_DEBUG2, Debug2::TYPE_CLEAR_LOG ); ?>" class="button button-primary" litespeed-accesskey='D'>
11
+ <?php echo __( 'Clear Log', 'litespeed-cache' ); ?>
12
  </a>
13
  </h3>
14
 
15
 
16
  <?php
17
+ $file = LSCWP_CONTENT_DIR . '/debug.log';
18
+ $lines = File::count_lines( $file );
19
+ $start = $lines > 1000 ? $lines - 1000 : 0;
20
+ $logs = File::read( $file, $start );
21
  $logs = $logs ? implode( "\n", $logs ) : '';
22
 
23
+ echo nl2br( htmlspecialchars( $logs ) );
24
  ?>
25
 
26
 
27
+ <a href="<?php echo Utility::build_url( Router::ACTION_DEBUG2, Debug2::TYPE_CLEAR_LOG ); ?>" class="button button-primary">
28
+ <?php echo __( 'Clear Log', 'litespeed-cache' ); ?>
29
  </a>
tpl/toolbox/purge.tpl.php CHANGED
@@ -67,7 +67,7 @@ if ( Router::opcache_enabled() ) {
67
  ) ;
68
  }
69
 
70
- if ( CSS::has_ccss_cache() ) {
71
  $_panels[] = array(
72
  'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Critical CSS', 'litespeed-cache' ),
73
  'desc' => __( 'This will delete all generated critical CSS files', 'litespeed-cache' ),
@@ -76,6 +76,15 @@ if ( CSS::has_ccss_cache() ) {
76
  ) ;
77
  }
78
 
 
 
 
 
 
 
 
 
 
79
  if ( Placeholder::has_lqip_cache() ) {
80
  $_panels[] = array(
81
  'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'LQIP Cache', 'litespeed-cache' ),
@@ -124,7 +133,7 @@ if ( ! is_multisite() || is_network_admin() ) {
124
 
125
  <h3 class="litespeed-title">
126
  <?php echo __('Purge', 'litespeed-cache'); ?>
127
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#purge-tab', false, 'litespeed-learn-more' ); ?>
128
  </h3>
129
 
130
  <div class="litespeed-panel-wrapper litespeed-cards-wrapper">
67
  ) ;
68
  }
69
 
70
+ if ( Conf::val( Base::O_OPTM_CCSS_GEN ) ) {
71
  $_panels[] = array(
72
  'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Critical CSS', 'litespeed-cache' ),
73
  'desc' => __( 'This will delete all generated critical CSS files', 'litespeed-cache' ),
76
  ) ;
77
  }
78
 
79
+ if ( Conf::val( Base::O_OPTM_LOCALIZE ) ) {
80
+ $_panels[] = array(
81
+ 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'Localized Resources', 'litespeed-cache' ),
82
+ 'desc' => __( 'This will delete all localized resources', 'litespeed-cache' ),
83
+ 'icon' => 'purge-cssjs',
84
+ 'append_url' => Purge::TYPE_PURGE_ALL_LOCALRES,
85
+ );
86
+ }
87
+
88
  if ( Placeholder::has_lqip_cache() ) {
89
  $_panels[] = array(
90
  'title' => __( 'Purge All', 'litespeed-cache' ) . ' - ' . __( 'LQIP Cache', 'litespeed-cache' ),
133
 
134
  <h3 class="litespeed-title">
135
  <?php echo __('Purge', 'litespeed-cache'); ?>
136
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#purge-tab' ); ?>
137
  </h3>
138
 
139
  <div class="litespeed-panel-wrapper litespeed-cards-wrapper">
tpl/toolbox/report.tpl.php CHANGED
@@ -39,7 +39,7 @@ $install_link = Utility::build_url( Router::ACTION_ACTIVATION, Activation::TYPE_
39
 
40
  <h3 class="litespeed-title">
41
  <?php echo __('LiteSpeed Report', 'litespeed-cache') ; ?>
42
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#report-tab', false, 'litespeed-learn-more' ); ?>
43
  </h3>
44
 
45
  <p><?php echo __('Report number', 'litespeed-cache') ; ?>: <b><?php echo ! empty( $env_ref[ 'num' ] ) ? $env_ref[ 'num' ] : '-' ; ?></b></p>
39
 
40
  <h3 class="litespeed-title">
41
  <?php echo __('LiteSpeed Report', 'litespeed-cache') ; ?>
42
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#report-tab' ); ?>
43
  </h3>
44
 
45
  <p><?php echo __('Report number', 'litespeed-cache') ; ?>: <b><?php echo ! empty( $env_ref[ 'num' ] ) ? $env_ref[ 'num' ] : '-' ; ?></b></p>
tpl/toolbox/settings-debug.tpl.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
- namespace LiteSpeed ;
3
- defined( 'WPINC' ) || exit ;
4
 
5
  $this->form_action( $this->_is_network_admin ? Router::ACTION_SAVE_SETTINGS_NETWORK : false );
6
  ?>
@@ -8,137 +8,137 @@ $this->form_action( $this->_is_network_admin ? Router::ACTION_SAVE_SETTINGS_NETW
8
 
9
  <h3 class="litespeed-title-short">
10
  <?php echo __('Debug Settings', 'litespeed-cache'); ?>
11
- <?php $this->learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#debug-settings-tab', false, 'litespeed-learn-more' ) ; ?>
12
  </h3>
13
 
14
  <table class="wp-list-table striped litespeed-table"><tbody>
15
  <tr>
16
  <th>
17
- <?php $id = Base::O_DEBUG_DISABLE_ALL ; ?>
18
- <?php $this->title( $id ) ; ?>
19
  </th>
20
  <td>
21
- <?php $this->build_switch( $id ) ; ?>
22
  <div class="litespeed-desc">
23
- <?php echo __( 'This will disable LSCache and all optimization features for debug purpose.', 'litespeed-cache' ) ; ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
- <?php $id = Base::O_DEBUG ; ?>
31
- <?php $this->title( $id ) ; ?>
32
  </th>
33
  <td>
34
  <?php $this->build_switch( $id, array( __( 'OFF', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ), __( 'Admin IP Only', 'litespeed-cache' ) ) ); ?>
35
  <div class="litespeed-desc">
36
- <?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ) ; ?>
37
- <?php echo __( 'To prevent filling up the disk, this setting should be OFF when everything is working.', 'litespeed-cache' ) ; ?>
38
- <?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ) ; ?>
39
- <?php echo sprintf( __( 'The logs will be output to %s.', 'litespeed-cache' ), '<code>wp-content/debug.log</code>' ) ; ?>
40
  </div>
41
  </td>
42
  </tr>
43
 
44
  <tr>
45
  <th>
46
- <?php $id = Base::O_DEBUG_IPS ; ?>
47
- <?php $this->title( $id ) ; ?>
48
  </th>
49
  <td>
50
- <?php $this->build_textarea( $id, 30 ) ; ?>
51
  <div class="litespeed-desc">
52
- <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ) ; ?>
53
- <?php echo __( 'Your IP', 'litespeed-cache' ) ; ?>: <code><?php echo Router::get_ip() ; ?></code>
54
- <?php $this->_validate_ip( $id ) ; ?>
55
  <br />
56
- <?php $this->learn_more(
57
  'https://docs.litespeedtech.com/lscache/lscwp/admin/#admin-ip-commands',
58
  __( 'More information about the available commands can be found here.', 'litespeed-cache' )
59
- ) ; ?>
60
  </div>
61
  </td>
62
  </tr>
63
 
64
  <tr>
65
  <th>
66
- <?php $id = Base::O_DEBUG_LEVEL ; ?>
67
- <?php $this->title( $id ) ; ?>
68
  </th>
69
  <td>
70
  <?php $this->build_switch( $id, array( __( 'Basic', 'litespeed-cache' ), __( 'Advanced', 'litespeed-cache' ) ) ); ?>
71
  <div class="litespeed-desc">
72
- <?php echo __( 'Advanced level will log more details.', 'litespeed-cache' ) ; ?>
73
  </div>
74
  </td>
75
  </tr>
76
 
77
  <tr>
78
  <th>
79
- <?php $id = Base::O_DEBUG_FILESIZE ; ?>
80
- <?php $this->title( $id ) ; ?>
81
  </th>
82
  <td>
83
- <?php $this->build_input( $id, 'litespeed-input-short' ) ; ?> <?php echo __( 'MB', 'litespeed-cache' ) ; ?>
84
  <div class="litespeed-desc">
85
- <?php echo __( 'Specify the maximum size of the log file.', 'litespeed-cache' ) ; ?>
86
- <?php $this->recommended( $id ) ; ?>
87
- <?php $this->_validate_ttl( $id, 3, 3000 ) ; ?>
88
  </div>
89
  </td>
90
  </tr>
91
 
92
  <tr>
93
  <th>
94
- <?php $id = Base::O_DEBUG_COOKIE ; ?>
95
- <?php $this->title( $id ) ; ?>
96
  </th>
97
  <td>
98
- <?php $this->build_switch( $id ) ; ?>
99
  <div class="litespeed-desc">
100
- <?php echo __( 'Log requested cookie values.', 'litespeed-cache' ) ; ?>
101
  </div>
102
  </td>
103
  </tr>
104
 
105
  <tr>
106
  <th>
107
- <?php $id = Base::O_DEBUG_COLLAPS_QS ; ?>
108
- <?php $this->title( $id ) ; ?>
109
  </th>
110
  <td>
111
- <?php $this->build_switch( $id ) ; ?>
112
  <div class="litespeed-desc">
113
- <?php echo __( 'Shorten query strings in the debug log to improve readability.', 'litespeed-cache' ) ; ?>
114
  </div>
115
  </td>
116
  </tr>
117
 
118
  <tr>
119
  <th>
120
- <?php $id = Base::O_DEBUG_INC ; ?>
121
- <?php $this->title( $id ) ; ?>
122
  </th>
123
  <td>
124
- <?php $this->build_textarea( $id ) ; ?>
125
  <div class="litespeed-desc">
126
- <?php echo __( 'Only log listed pages.', 'litespeed-cache' ) ; ?>
127
- <?php $this->_uri_usage_example() ; ?>
128
  </div>
129
  </td>
130
  </tr>
131
 
132
  <tr>
133
  <th>
134
- <?php $id = Base::O_DEBUG_EXC ; ?>
135
- <?php $this->title( $id ) ; ?>
136
  </th>
137
  <td>
138
- <?php $this->build_textarea( $id ) ; ?>
139
  <div class="litespeed-desc">
140
- <?php echo __( 'Prevent any debug log of listed pages.', 'litespeed-cache' ) ; ?>
141
- <?php $this->_uri_usage_example() ; ?>
142
  </div>
143
  </td>
144
  </tr>
@@ -147,5 +147,5 @@ $this->form_action( $this->_is_network_admin ? Router::ACTION_SAVE_SETTINGS_NETW
147
 
148
  <?php
149
 
150
- $this->form_end() ;
151
 
1
  <?php
2
+ namespace LiteSpeed;
3
+ defined( 'WPINC' ) || exit;
4
 
5
  $this->form_action( $this->_is_network_admin ? Router::ACTION_SAVE_SETTINGS_NETWORK : false );
6
  ?>
8
 
9
  <h3 class="litespeed-title-short">
10
  <?php echo __('Debug Settings', 'litespeed-cache'); ?>
11
+ <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/toolbox/#debug-settings-tab' ); ?>
12
  </h3>
13
 
14
  <table class="wp-list-table striped litespeed-table"><tbody>
15
  <tr>
16
  <th>
17
+ <?php $id = Base::O_DEBUG_DISABLE_ALL; ?>
18
+ <?php $this->title( $id ); ?>
19
  </th>
20
  <td>
21
+ <?php $this->build_switch( $id ); ?>
22
  <div class="litespeed-desc">
23
+ <?php echo __( 'This will disable LSCache and all optimization features for debug purpose.', 'litespeed-cache' ); ?>
24
  </div>
25
  </td>
26
  </tr>
27
 
28
  <tr>
29
  <th>
30
+ <?php $id = Base::O_DEBUG; ?>
31
+ <?php $this->title( $id ); ?>
32
  </th>
33
  <td>
34
  <?php $this->build_switch( $id, array( __( 'OFF', 'litespeed-cache' ), __( 'ON', 'litespeed-cache' ), __( 'Admin IP Only', 'litespeed-cache' ) ) ); ?>
35
  <div class="litespeed-desc">
36
+ <?php echo __( 'Outputs to WordPress debug log.', 'litespeed-cache' ); ?>
37
+ <?php echo __( 'To prevent filling up the disk, this setting should be OFF when everything is working.', 'litespeed-cache' ); ?>
38
+ <?php echo __( 'The Admin IP option will only output log messages on requests from admin IPs.', 'litespeed-cache' ); ?>
39
+ <?php echo sprintf( __( 'The logs will be output to %s.', 'litespeed-cache' ), '<code>wp-content/debug.log</code>' ); ?>
40
  </div>
41
  </td>
42
  </tr>
43
 
44
  <tr>
45
  <th>
46
+ <?php $id = Base::O_DEBUG_IPS; ?>
47
+ <?php $this->title( $id ); ?>
48
  </th>
49
  <td>
50
+ <?php $this->build_textarea( $id, 30 ); ?>
51
  <div class="litespeed-desc">
52
+ <?php echo __( 'Allows listed IPs (one per line) to perform certain actions from their browsers.', 'litespeed-cache' ); ?>
53
+ <?php echo __( 'Your IP', 'litespeed-cache' ); ?>: <code><?php echo Router::get_ip(); ?></code>
54
+ <?php $this->_validate_ip( $id ); ?>
55
  <br />
56
+ <?php Doc::learn_more(
57
  'https://docs.litespeedtech.com/lscache/lscwp/admin/#admin-ip-commands',
58
  __( 'More information about the available commands can be found here.', 'litespeed-cache' )
59
+ ); ?>
60
  </div>
61
  </td>
62
  </tr>
63
 
64
  <tr>
65
  <th>
66
+ <?php $id = Base::O_DEBUG_LEVEL; ?>
67
+ <?php $this->title( $id ); ?>
68
  </th>
69
  <td>
70
  <?php $this->build_switch( $id, array( __( 'Basic', 'litespeed-cache' ), __( 'Advanced', 'litespeed-cache' ) ) ); ?>
71
  <div class="litespeed-desc">
72
+ <?php echo __( 'Advanced level will log more details.', 'litespeed-cache' ); ?>
73
  </div>
74
  </td>
75
  </tr>
76
 
77
  <tr>
78
  <th>
79
+ <?php $id = Base::O_DEBUG_FILESIZE; ?>
80
+ <?php $this->title( $id ); ?>
81
  </th>
82
  <td>
83
+ <?php $this->build_input( $id, 'litespeed-input-short' ); ?> <?php echo __( 'MB', 'litespeed-cache' ); ?>
84
  <div class="litespeed-desc">
85
+ <?php echo __( 'Specify the maximum size of the log file.', 'litespeed-cache' ); ?>
86
+ <?php $this->recommended( $id ); ?>
87
+ <?php $this->_validate_ttl( $id, 3, 3000 ); ?>
88
  </div>
89
  </td>
90
  </tr>
91
 
92
  <tr>
93
  <th>
94
+ <?php $id = Base::O_DEBUG_COOKIE; ?>
95
+ <?php $this->title( $id ); ?>
96
  </th>
97
  <td>
98
+ <?php $this->build_switch( $id ); ?>
99
  <div class="litespeed-desc">
100
+ <?php echo __( 'Log requested cookie values.', 'litespeed-cache' ); ?>
101
  </div>
102
  </td>
103
  </tr>
104
 
105
  <tr>
106
  <th>
107
+ <?php $id = Base::O_DEBUG_COLLAPS_QS; ?>
108
+ <?php $this->title( $id ); ?>
109
  </th>
110
  <td>
111
+ <?php $this->build_switch( $id ); ?>
112
  <div class="litespeed-desc">
113
+ <?php echo __( 'Shorten query strings in the debug log to improve readability.', 'litespeed-cache' ); ?>
114
  </div>
115
  </td>
116
  </tr>
117
 
118
  <tr>
119
  <th>
120
+ <?php $id = Base::O_DEBUG_INC; ?>
121
+ <?php $this->title( $id ); ?>
122
  </th>
123
  <td>
124
+ <?php $this->build_textarea( $id ); ?>
125
  <div class="litespeed-desc">
126
+ <?php echo __( 'Only log listed pages.', 'litespeed-cache' ); ?>
127
+ <?php $this->_uri_usage_example(); ?>
128
  </div>
129
  </td>
130
  </tr>
131
 
132
  <tr>
133
  <th>
134
+ <?php $id = Base::O_DEBUG_EXC; ?>
135
+ <?php $this->title( $id ); ?>
136
  </th>
137
  <td>
138
+ <?php $this->build_textarea( $id ); ?>
139
  <div class="litespeed-desc">
140
+ <?php echo __( 'Prevent any debug log of listed pages.', 'litespeed-cache' ); ?>
141
+ <?php $this->_uri_usage_example(); ?>
142
  </div>
143
  </td>
144
  </tr>
147
 
148
  <?php
149
 
150
+ $this->form_end();
151