PluginProbe ʕ •ᴥ•ʔ
LiteSpeed Cache / 7.6.1
LiteSpeed Cache v7.6.1
trunk 1.0.15 1.9.1.1 2.9.9.2 3.6.4 4.6 5.7.0.1 6.5.4 7.0.0.1 7.0.1 7.1 7.2 7.3 7.3.0.1 7.4 7.5 7.5.0.1 7.6 7.6.1 7.6.2 7.7 7.8 7.8.0.1 7.8.1
litespeed-cache / src / gui.cls.php
litespeed-cache / src Last commit date
cdn 7 months ago data_structure 7 months ago activation.cls.php 7 months ago admin-display.cls.php 7 months ago admin-settings.cls.php 7 months ago admin.cls.php 7 months ago api.cls.php 7 months ago avatar.cls.php 7 months ago base.cls.php 7 months ago cdn.cls.php 7 months ago cloud.cls.php 7 months ago conf.cls.php 7 months ago control.cls.php 7 months ago core.cls.php 7 months ago crawler-map.cls.php 7 months ago crawler.cls.php 7 months ago css.cls.php 7 months ago data.cls.php 7 months ago data.upgrade.func.php 7 months ago db-optm.cls.php 7 months ago debug2.cls.php 7 months ago doc.cls.php 7 months ago error.cls.php 7 months ago esi.cls.php 7 months ago file.cls.php 7 months ago gui.cls.php 7 months ago health.cls.php 7 months ago htaccess.cls.php 7 months ago img-optm.cls.php 7 months ago import.cls.php 7 months ago import.preset.cls.php 7 months ago lang.cls.php 7 months ago localization.cls.php 7 months ago media.cls.php 7 months ago metabox.cls.php 7 months ago object-cache-wp.cls.php 7 months ago object-cache.cls.php 7 months ago object.lib.php 7 months ago optimize.cls.php 7 months ago optimizer.cls.php 7 months ago placeholder.cls.php 7 months ago purge.cls.php 7 months ago report.cls.php 7 months ago rest.cls.php 7 months ago root.cls.php 7 months ago router.cls.php 7 months ago str.cls.php 7 months ago tag.cls.php 7 months ago task.cls.php 7 months ago tool.cls.php 7 months ago ucss.cls.php 7 months ago utility.cls.php 7 months ago vary.cls.php 7 months ago vpi.cls.php 7 months ago
gui.cls.php
1258 lines
1 <?php
2 /**
3 * The frontend GUI class.
4 *
5 * Provides front-end and admin-bar UI helpers for LiteSpeed Cache.
6 *
7 * @package LiteSpeed
8 * @since 1.3
9 */
10
11 namespace LiteSpeed;
12
13 defined( 'WPINC' ) || exit();
14
15 /**
16 * GUI helpers for LiteSpeed Cache.
17 */
18 class GUI extends Base {
19 const LOG_TAG = '[GUI]';
20
21 /**
22 * Counter for temporary HTML wrappers.
23 *
24 * @var int Counter for temporary HTML wrappers to remove from the buffer.
25 */
26 private static $_clean_counter = 0;
27
28 /**
29 * Promo display flag.
30 *
31 * @var bool Internal flag used by promo templates to decide whether to display.
32 */
33 private $_promo_true = false;
34
35 /**
36 * Promo list configuration.
37 *
38 * Format: [ file_tag => [ days, litespeed_only ], ... ]
39 *
40 * @var array<string, array{0:int,1:bool}>
41 */
42 private $_promo_list = [
43 'new_version' => [ 7, false ],
44 'score' => [ 14, false ],
45 // 'slack' => [ 3, false ],
46 ];
47
48 /** Path to guest JavaScript file. */
49 const LIB_GUEST_JS = 'assets/js/guest.min.js';
50
51 /** Path to guest document.referrer JavaScript file. */
52 const LIB_GUEST_DOCREF_JS = 'assets/js/guest.docref.min.js';
53
54 /** Path to guest vary endpoint. */
55 const PHP_GUEST = 'guest.vary.php';
56
57 /** Dismiss type: WHM. */
58 const TYPE_DISMISS_WHM = 'whm';
59
60 /** Dismiss type: ExpiresDefault. */
61 const TYPE_DISMISS_EXPIRESDEFAULT = 'ExpiresDefault';
62
63 /** Dismiss type: Promo. */
64 const TYPE_DISMISS_PROMO = 'promo';
65
66 /** Dismiss type: PIN. */
67 const TYPE_DISMISS_PIN = 'pin';
68
69 /** WHM message option name. */
70 const WHM_MSG = 'lscwp_whm_install';
71
72 /** WHM message option value. */
73 const WHM_MSG_VAL = 'whm_install';
74
75 /**
76 * Summary options cache.
77 *
78 * @var array<string,mixed> Summary/options cache.
79 */
80 protected $_summary;
81
82 /**
83 * Instance.
84 *
85 * @since 1.3
86 */
87 public function __construct() {
88 $this->_summary = self::get_summary();
89 }
90
91 /**
92 * Frontend init.
93 *
94 * @since 3.0
95 */
96 public function init() {
97 self::debug2( 'init' );
98
99 if ( is_admin_bar_showing() && current_user_can( 'manage_options' ) ) {
100 add_action( 'wp_enqueue_scripts', [ $this, 'frontend_enqueue_style' ] );
101 add_action( 'admin_bar_menu', [ $this, 'frontend_shortcut' ], 95 );
102 }
103
104 /**
105 * Turn on instant click.
106 *
107 * @since 1.8.2
108 */
109 if ( $this->conf( self::O_UTIL_INSTANT_CLICK ) ) {
110 add_action( 'wp_enqueue_scripts', [ $this, 'frontend_enqueue_style_public' ] );
111 }
112
113 // NOTE: this needs to be before optimizer to avoid wrapper being removed.
114 add_filter( 'litespeed_buffer_finalize', [ $this, 'finalize' ], 8 );
115 }
116
117 /**
118 * Print a loading message when redirecting CCSS/UCSS page to avoid blank page confusion.
119 *
120 * @param int $counter Files left in queue.
121 * @param string $type Queue type label.
122 * @return void
123 */
124 public static function print_loading( $counter, $type ) {
125 echo '<div style="font-size:25px;text-align:center;padding-top:150px;width:100%;position:absolute;">';
126 echo "<img width='35' src='" . esc_url( LSWCP_PLUGIN_URL . 'assets/img/Litespeed.icon.svg' ) . "' alt='' /> ";
127 printf(
128 /* translators: 1: number, 2: text */
129 esc_html__( '%1$s %2$s files left in queue', 'litespeed-cache' ),
130 esc_html( number_format_i18n( $counter ) ),
131 esc_html( $type )
132 );
133 echo '<p><a href="' . esc_url( admin_url( 'admin.php?page=litespeed-page_optm' ) ) . '">' . esc_html__( 'Cancel', 'litespeed-cache' ) . '</a></p>';
134 echo '</div>';
135 }
136
137 /**
138 * Display the tab list.
139 *
140 * @since 7.3
141 *
142 * @param array<string,string> $tabs Key => Label pairs.
143 * @return void
144 */
145 public static function display_tab_list( $tabs ) {
146 $i = 1;
147 foreach ( $tabs as $k => $val ) {
148 $accesskey = $i <= 9 ? $i : '';
149 printf(
150 '<a class="litespeed-tab nav-tab" href="#%1$s" data-litespeed-tab="%1$s" litespeed-accesskey="%2$s">%3$s</a>',
151 esc_attr( $k ),
152 esc_attr( $accesskey ),
153 esc_html( $val )
154 );
155 ++$i;
156 }
157 }
158
159 /**
160 * Render a pie chart SVG string.
161 *
162 * @since 1.6.6
163 *
164 * @param int $percent Percentage 0-100.
165 * @param int $width Width/height in pixels.
166 * @param bool $finished_tick Show a tick when 100%.
167 * @param bool $without_percentage Hide the % label.
168 * @param string|bool $append_cls Extra CSS class.
169 * @return string SVG markup.
170 */
171 public static function pie( $percent, $width = 50, $finished_tick = false, $without_percentage = false, $append_cls = false ) {
172 $label = $without_percentage ? $percent : ( $percent . '%' );
173 $percentage = '<text x="50%" y="50%">' . esc_html( $label ) . '</text>';
174
175 if ( 100 === $percent && $finished_tick ) {
176 $percentage = '<text x="50%" y="50%" class="litespeed-pie-done">✓</text>';
177 }
178
179 $svg = sprintf(
180 "<svg class='litespeed-pie %1\$s' viewbox='0 0 33.83098862 33.83098862' width='%2\$d' height='%2\$d' xmlns='http://www.w3.org/2000/svg'>
181 <circle class='litespeed-pie_bg' cx='16.91549431' cy='16.91549431' r='15.91549431' />
182 <circle class='litespeed-pie_circle' cx='16.91549431' cy='16.91549431' r='15.91549431' stroke-dasharray='%3\$d,100' />
183 <g class='litespeed-pie_info'>%4\$s</g>
184 </svg>",
185 esc_attr( $append_cls ),
186 $width,
187 $percent,
188 $percentage
189 );
190
191 return $svg;
192 }
193
194 /**
195 * Allowed SVG tags/attributes for kses.
196 *
197 * @since 7.3
198 *
199 * @return array<string,array<string,bool>> Allowed tags/attributes.
200 */
201 public static function allowed_svg_tags() {
202 return [
203 'svg' => [
204 'width' => true,
205 'height' => true,
206 'viewbox' => true, // Note: SVG standard uses 'viewBox', but wp_kses normalizes to lowercase.
207 'xmlns' => true,
208 'class' => true,
209 'id' => true,
210 ],
211 'circle' => [
212 'cx' => true,
213 'cy' => true,
214 'r' => true,
215 'fill' => true,
216 'stroke' => true,
217 'class' => true,
218 'stroke-width' => true,
219 'stroke-dasharray' => true,
220 ],
221 'path' => [
222 'd' => true,
223 'fill' => true,
224 'stroke' => true,
225 ],
226 'text' => [
227 'x' => true,
228 'y' => true,
229 'dx' => true,
230 'dy' => true,
231 'font-size' => true,
232 'font-family' => true,
233 'font-weight' => true,
234 'fill' => true,
235 'stroke' => true,
236 'stroke-width' => true,
237 'text-anchor' => true,
238 'class' => true,
239 'id' => true,
240 ],
241 'g' => [
242 'transform' => true,
243 'fill' => true,
244 'stroke' => true,
245 'stroke-width' => true,
246 'class' => true,
247 'id' => true,
248 ],
249 'button' => [
250 'type' => true,
251 'data-balloon-break' => true,
252 'data-balloon-pos' => true,
253 'aria-label' => true,
254 'class' => true,
255 ],
256 ];
257 }
258
259 /**
260 * Display a tiny pie with a tooltip.
261 *
262 * @since 3.0
263 *
264 * @param int $percent Percentage 0-100.
265 * @param int $width Width/height in pixels.
266 * @param string $tooltip Tooltip text.
267 * @param string $tooltip_pos Tooltip position (e.g., 'up').
268 * @param string|bool $append_cls Extra CSS class.
269 * @return string HTML/SVG.
270 */
271 public static function pie_tiny( $percent, $width = 50, $tooltip = '', $tooltip_pos = 'up', $append_cls = false ) {
272 // formula C = 2πR.
273 $dasharray = 2 * 3.1416 * 9 * ( $percent / 100 );
274
275 return sprintf(
276 "
277 <button type='button' data-balloon-break data-balloon-pos='%1\$s' aria-label='%2\$s' class='litespeed-btn-pie'>
278 <svg class='litespeed-pie litespeed-pie-tiny %3\$s' viewbox='0 0 30 30' width='%4\$d' height='%4\$d' xmlns='http://www.w3.org/2000/svg'>
279 <circle class='litespeed-pie_bg' cx='15' cy='15' r='9' />
280 <circle class='litespeed-pie_circle' cx='15' cy='15' r='9' stroke-dasharray='%5\$s,100' />
281 <g class='litespeed-pie_info'><text x='50%%' y='50%%'>i</text></g>
282 </svg>
283 </button>
284 ",
285 esc_attr( $tooltip_pos ),
286 esc_attr( $tooltip ),
287 esc_attr( $append_cls ),
288 $width,
289 esc_attr( $dasharray )
290 );
291 }
292
293 /**
294 * Get CSS class name for PageSpeed score.
295 *
296 * Scale:
297 * 90-100 (fast)
298 * 50-89 (average)
299 * 0-49 (slow)
300 *
301 * @since 2.9
302 * @access public
303 *
304 * @param int $score Score 0-100.
305 * @return string Class name: success|warning|danger.
306 */
307 public function get_cls_of_pagescore( $score ) {
308 if ( $score >= 90 ) {
309 return 'success';
310 }
311
312 if ( $score >= 50 ) {
313 return 'warning';
314 }
315
316 return 'danger';
317 }
318
319 /**
320 * Handle dismiss actions for banners and notices.
321 *
322 * @since 1.0
323 * @access public
324 * @return void
325 */
326 public static function dismiss() {
327 $_instance = self::cls();
328
329 switch ( Router::verify_type() ) {
330 case self::TYPE_DISMISS_WHM:
331 self::dismiss_whm();
332 break;
333
334 case self::TYPE_DISMISS_EXPIRESDEFAULT:
335 self::update_option( Admin_Display::DB_DISMISS_MSG, Admin_Display::RULECONFLICT_DISMISSED );
336 break;
337
338 case self::TYPE_DISMISS_PIN:
339 Admin_Display::dismiss_pin();
340 break;
341
342 case self::TYPE_DISMISS_PROMO:
343 if ( empty( $_GET['promo_tag'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
344 break;
345 }
346
347 $promo_tag = sanitize_key( wp_unslash( $_GET['promo_tag'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
348 if ( empty( $_instance->_promo_list[ $promo_tag ] ) ) {
349 break;
350 }
351
352 defined( 'LSCWP_LOG' ) && self::debug( 'Dismiss promo ' . $promo_tag );
353
354 // Forever dismiss.
355 if ( ! empty( $_GET['done'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
356 $_instance->_summary[ $promo_tag ] = 'done';
357 } elseif ( ! empty( $_GET['later'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
358 // Delay the banner to half year later.
359 $_instance->_summary[ $promo_tag ] = time() + ( 86400 * 180 );
360 } else {
361 // Update welcome banner to 30 days after.
362 $_instance->_summary[ $promo_tag ] = time() + ( 86400 * 30 );
363 }
364
365 self::save_summary();
366
367 break;
368
369 default:
370 break;
371 }
372
373 if ( Router::is_ajax() ) {
374 // All dismiss actions are considered as ajax call, so just exit.
375 exit( wp_json_encode( [ 'success' => 1 ] ) );
376 }
377
378 // Plain click link, redirect to referral url.
379 Admin::redirect();
380 }
381
382 /**
383 * Check if has rule conflict notice.
384 *
385 * @since 1.1.5
386 * @access public
387 *
388 * @return bool True if message should be shown.
389 */
390 public static function has_msg_ruleconflict() {
391 $db_dismiss_msg = self::get_option( Admin_Display::DB_DISMISS_MSG );
392 if ( ! $db_dismiss_msg ) {
393 self::update_option( Admin_Display::DB_DISMISS_MSG, -1 );
394 }
395 return Admin_Display::RULECONFLICT_ON === $db_dismiss_msg;
396 }
397
398 /**
399 * Check if has WHM notice.
400 *
401 * @since 1.1.1
402 * @access public
403 *
404 * @return bool True if message should be shown.
405 */
406 public static function has_whm_msg() {
407 $val = self::get_option( self::WHM_MSG );
408 if ( ! $val ) {
409 self::dismiss_whm();
410 return false;
411 }
412 return self::WHM_MSG_VAL === $val;
413 }
414
415 /**
416 * Delete WHM message tag.
417 *
418 * @since 1.1.1
419 * @access public
420 * @return void
421 */
422 public static function dismiss_whm() {
423 self::update_option( self::WHM_MSG, -1 );
424 }
425
426 /**
427 * Whether current request is a LiteSpeed admin page.
428 *
429 * @since 2.9
430 *
431 * @return bool True if LiteSpeed page.
432 */
433 private function _is_litespeed_page() {
434 if (
435 ! empty( $_GET['page'] ) && // phpcs:ignore WordPress.Security.NonceVerification.Recommended
436 in_array(
437 (string) $_GET['page'], // phpcs:ignore WordPress.Security.NonceVerification.Recommended
438 [
439 'litespeed-settings',
440 'litespeed-dash',
441 Admin::PAGE_EDIT_HTACCESS,
442 'litespeed-optimization',
443 'litespeed-crawler',
444 'litespeed-import',
445 'litespeed-report',
446 ],
447 true
448 )
449 ) {
450 return true;
451 }
452
453 return false;
454 }
455
456 /**
457 * Display promo banner (or check-only mode to know which promo would display).
458 *
459 * @since 2.1
460 * @access public
461 *
462 * @param bool $check_only If true, only return the promo tag that would be shown.
463 * @return false|string False if none, or the promo tag string.
464 */
465 public function show_promo( $check_only = false ) {
466 $is_litespeed_page = $this->_is_litespeed_page();
467
468 // Bypass showing info banner if disabled all in debug.
469 if ( defined( 'LITESPEED_DISABLE_ALL' ) && LITESPEED_DISABLE_ALL ) {
470 return false;
471 }
472
473 if ( file_exists( ABSPATH . '.litespeed_no_banner' ) ) {
474 defined( 'LSCWP_LOG' ) && self::debug( 'Bypass banners due to silence file' );
475 return false;
476 }
477
478 foreach ( $this->_promo_list as $promo_tag => $v ) {
479 list( $delay_days, $litespeed_page_only ) = $v;
480
481 if ( $litespeed_page_only && ! $is_litespeed_page ) {
482 continue;
483 }
484
485 // First time check.
486 if ( empty( $this->_summary[ $promo_tag ] ) ) {
487 $this->_summary[ $promo_tag ] = time() + 86400 * $delay_days;
488 self::save_summary();
489 continue;
490 }
491
492 $promo_timestamp = $this->_summary[ $promo_tag ];
493
494 // Was ticked as done.
495 if ( 'done' === $promo_timestamp ) {
496 continue;
497 }
498
499 // Not reach the dateline yet.
500 if ( time() < $promo_timestamp ) {
501 continue;
502 }
503
504 // Try to load, if can pass, will set $this->_promo_true = true.
505 $this->_promo_true = false;
506 include LSCWP_DIR . "tpl/banner/$promo_tag.php";
507
508 // If not defined, means it didn't pass the display workflow in tpl.
509 if ( ! $this->_promo_true ) {
510 continue;
511 }
512
513 if ( $check_only ) {
514 return $promo_tag;
515 }
516
517 defined( 'LSCWP_LOG' ) && self::debug( 'Show promo ' . $promo_tag );
518
519 // Only contain one.
520 break;
521 }
522
523 return false;
524 }
525
526 /**
527 * Load frontend public script.
528 *
529 * @since 1.8.2
530 * @access public
531 * @return void
532 */
533 public function frontend_enqueue_style_public() {
534 wp_enqueue_script( Core::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'assets/js/instant_click.min.js', [], Core::VER, true );
535 }
536
537 /**
538 * Load frontend stylesheet.
539 *
540 * @since 1.3
541 * @access public
542 * @return void
543 */
544 public function frontend_enqueue_style() {
545 wp_enqueue_style( Core::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'assets/css/litespeed.css', [], Core::VER, 'all' );
546 }
547
548 /**
549 * Load frontend menu shortcut items in the admin bar.
550 *
551 * @since 1.3
552 * @since 7.6 Add VPI clear.
553 * @access public
554 * @return void
555 */
556 public function frontend_shortcut() {
557 global $wp_admin_bar;
558
559 $wp_admin_bar->add_menu(
560 [
561 'id' => 'litespeed-menu',
562 'title' => '<span class="ab-icon"></span>',
563 'href' => get_admin_url( null, 'admin.php?page=litespeed' ),
564 'meta' => [
565 'tabindex' => 0,
566 'class' => 'litespeed-top-toolbar',
567 ],
568 ]
569 );
570
571 $wp_admin_bar->add_menu(
572 [
573 'parent' => 'litespeed-menu',
574 'id' => 'litespeed-purge-single',
575 'title' => esc_html__( 'Purge this page', 'litespeed-cache' ) . ' - LSCache',
576 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_FRONT, false, true ),
577 'meta' => [ 'tabindex' => '0' ],
578 ]
579 );
580
581 if ( $this->has_cache_folder( 'ucss' ) ) {
582 $possible_url_tag = UCSS::get_url_tag();
583 $append_arr = [];
584 if ( $possible_url_tag ) {
585 $append_arr['url_tag'] = $possible_url_tag;
586 }
587
588 $wp_admin_bar->add_menu(
589 [
590 'parent' => 'litespeed-menu',
591 'id' => 'litespeed-purge-single-ucss',
592 'title' => esc_html__( 'Purge this page', 'litespeed-cache' ) . ' - UCSS',
593 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_UCSS, false, true, $append_arr ),
594 'meta' => [ 'tabindex' => '0' ],
595 ]
596 );
597 }
598
599 $wp_admin_bar->add_menu(
600 [
601 'parent' => 'litespeed-menu',
602 'id' => 'litespeed-single-action',
603 'title' => esc_html__( 'Mark this page as ', 'litespeed-cache' ),
604 'meta' => [ 'tabindex' => '0' ],
605 ]
606 );
607
608 $current_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
609
610 if ( $current_uri ) {
611 $append_arr = [
612 Conf::TYPE_SET . '[' . self::O_CACHE_FORCE_URI . '][]' => $current_uri . '$',
613 'redirect' => $current_uri,
614 ];
615 $wp_admin_bar->add_menu(
616 [
617 'parent' => 'litespeed-single-action',
618 'id' => 'litespeed-single-forced_cache',
619 'title' => esc_html__( 'Forced cacheable', 'litespeed-cache' ),
620 'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
621 ]
622 );
623
624 $append_arr = [
625 Conf::TYPE_SET . '[' . self::O_CACHE_EXC . '][]' => $current_uri . '$',
626 'redirect' => $current_uri,
627 ];
628 $wp_admin_bar->add_menu(
629 [
630 'parent' => 'litespeed-single-action',
631 'id' => 'litespeed-single-noncache',
632 'title' => esc_html__( 'Non cacheable', 'litespeed-cache' ),
633 'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
634 ]
635 );
636
637 $append_arr = [
638 Conf::TYPE_SET . '[' . self::O_CACHE_PRIV_URI . '][]' => $current_uri . '$',
639 'redirect' => $current_uri,
640 ];
641 $wp_admin_bar->add_menu(
642 [
643 'parent' => 'litespeed-single-action',
644 'id' => 'litespeed-single-private',
645 'title' => esc_html__( 'Private cache', 'litespeed-cache' ),
646 'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
647 ]
648 );
649
650 $append_arr = [
651 Conf::TYPE_SET . '[' . self::O_OPTM_EXC . '][]' => $current_uri . '$',
652 'redirect' => $current_uri,
653 ];
654 $wp_admin_bar->add_menu(
655 [
656 'parent' => 'litespeed-single-action',
657 'id' => 'litespeed-single-nonoptimize',
658 'title' => esc_html__( 'No optimization', 'litespeed-cache' ),
659 'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
660 ]
661 );
662 }
663
664 $wp_admin_bar->add_menu(
665 [
666 'parent' => 'litespeed-single-action',
667 'id' => 'litespeed-single-more',
668 'title' => esc_html__( 'More settings', 'litespeed-cache' ),
669 'href' => get_admin_url( null, 'admin.php?page=litespeed-cache' ),
670 ]
671 );
672
673 $wp_admin_bar->add_menu(
674 [
675 'parent' => 'litespeed-menu',
676 'id' => 'litespeed-purge-all',
677 'title' => esc_html__( 'Purge All', 'litespeed-cache' ),
678 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL, false, '_ori' ),
679 'meta' => [ 'tabindex' => '0' ],
680 ]
681 );
682
683 $wp_admin_bar->add_menu(
684 [
685 'parent' => 'litespeed-menu',
686 'id' => 'litespeed-purge-all-lscache',
687 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LSCache', 'litespeed-cache' ),
688 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE, false, '_ori' ),
689 'meta' => [ 'tabindex' => '0' ],
690 ]
691 );
692
693 $wp_admin_bar->add_menu(
694 [
695 'parent' => 'litespeed-menu',
696 'id' => 'litespeed-purge-cssjs',
697 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'CSS/JS Cache', 'litespeed-cache' ),
698 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CSSJS, false, '_ori' ),
699 'meta' => [ 'tabindex' => '0' ],
700 ]
701 );
702
703 if ( $this->conf( self::O_CDN_CLOUDFLARE ) ) {
704 $wp_admin_bar->add_menu(
705 [
706 'parent' => 'litespeed-menu',
707 'id' => 'litespeed-purge-cloudflare',
708 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Cloudflare', 'litespeed-cache' ),
709 'href' => Utility::build_url( Router::ACTION_CDN_CLOUDFLARE, CDN\Cloudflare::TYPE_PURGE_ALL ),
710 'meta' => [ 'tabindex' => '0' ],
711 ]
712 );
713 }
714
715 if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
716 $wp_admin_bar->add_menu(
717 [
718 'parent' => 'litespeed-menu',
719 'id' => 'litespeed-purge-object',
720 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Object Cache', 'litespeed-cache' ),
721 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OBJECT, false, '_ori' ),
722 'meta' => [ 'tabindex' => '0' ],
723 ]
724 );
725 }
726
727 if ( Router::opcache_enabled() ) {
728 $wp_admin_bar->add_menu(
729 [
730 'parent' => 'litespeed-menu',
731 'id' => 'litespeed-purge-opcache',
732 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Opcode Cache', 'litespeed-cache' ),
733 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OPCACHE, false, '_ori' ),
734 'meta' => [ 'tabindex' => '0' ],
735 ]
736 );
737 }
738
739 if ( $this->has_cache_folder( 'ccss' ) ) {
740 $wp_admin_bar->add_menu(
741 [
742 'parent' => 'litespeed-menu',
743 'id' => 'litespeed-purge-ccss',
744 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - CCSS',
745 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CCSS, false, '_ori' ),
746 'meta' => [ 'tabindex' => '0' ],
747 ]
748 );
749 }
750
751 if ( $this->has_cache_folder( 'ucss' ) ) {
752 $wp_admin_bar->add_menu(
753 [
754 'parent' => 'litespeed-menu',
755 'id' => 'litespeed-purge-ucss',
756 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - UCSS',
757 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_UCSS, false, '_ori' ),
758 ]
759 );
760 }
761
762 if ( $this->has_cache_folder( 'localres' ) ) {
763 $wp_admin_bar->add_menu(
764 [
765 'parent' => 'litespeed-menu',
766 'id' => 'litespeed-purge-localres',
767 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Localized Resources', 'litespeed-cache' ),
768 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES, false, '_ori' ),
769 'meta' => [ 'tabindex' => '0' ],
770 ]
771 );
772 }
773
774 if ( $this->has_cache_folder( 'lqip' ) ) {
775 $wp_admin_bar->add_menu(
776 [
777 'parent' => 'litespeed-menu',
778 'id' => 'litespeed-purge-placeholder',
779 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LQIP Cache', 'litespeed-cache' ),
780 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LQIP, false, '_ori' ),
781 'meta' => [ 'tabindex' => '0' ],
782 ]
783 );
784 }
785
786 if ( $this->has_cache_folder( 'vpi' ) ) {
787 $wp_admin_bar->add_menu(
788 [
789 'parent' => 'litespeed-menu',
790 'id' => 'litespeed-purge-vpi',
791 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - VPI',
792 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_VPI, false, '_ori' ),
793 'meta' => [ 'tabindex' => '0' ],
794 ]
795 );
796 }
797
798 if ( $this->has_cache_folder( 'avatar' ) ) {
799 $wp_admin_bar->add_menu(
800 [
801 'parent' => 'litespeed-menu',
802 'id' => 'litespeed-purge-avatar',
803 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Gravatar Cache', 'litespeed-cache' ),
804 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_AVATAR, false, '_ori' ),
805 'meta' => [ 'tabindex' => '0' ],
806 ]
807 );
808 }
809
810 do_action( 'litespeed_frontend_shortcut' );
811 }
812
813 /**
814 * Hooked to wp_before_admin_bar_render.
815 * Adds links to the admin bar so users can quickly manage/purge.
816 *
817 * @since 1.7.2 Moved from admin_display.cls to gui.cls; Renamed from `add_quick_purge` to `backend_shortcut`.
818 * @access public
819 * @global \WP_Admin_Bar $wp_admin_bar
820 * @return void
821 */
822 public function backend_shortcut() {
823 global $wp_admin_bar;
824
825 if ( defined( 'LITESPEED_DISABLE_ALL' ) && LITESPEED_DISABLE_ALL ) {
826 $wp_admin_bar->add_menu(
827 [
828 'id' => 'litespeed-menu',
829 'title' => '<span class="ab-icon icon_disabled" title="LiteSpeed Cache"></span>',
830 'href' => 'admin.php?page=litespeed-toolbox#settings-debug',
831 'meta' => [
832 'tabindex' => 0,
833 'class' => 'litespeed-top-toolbar',
834 ],
835 ]
836 );
837 $wp_admin_bar->add_menu(
838 [
839 'parent' => 'litespeed-menu',
840 'id' => 'litespeed-enable_all',
841 'title' => esc_html__( 'Enable All Features', 'litespeed-cache' ),
842 'href' => 'admin.php?page=litespeed-toolbox#settings-debug',
843 'meta' => [ 'tabindex' => '0' ],
844 ]
845 );
846 return;
847 }
848
849 $wp_admin_bar->add_menu(
850 [
851 'id' => 'litespeed-menu',
852 'title' => '<span class="ab-icon" title="' . esc_attr__( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . ' - ' . esc_attr__( 'LSCache', 'litespeed-cache' ) . '"></span>',
853 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE ),
854 'meta' => [
855 'tabindex' => 0,
856 'class' => 'litespeed-top-toolbar',
857 ],
858 ]
859 );
860
861 $wp_admin_bar->add_menu(
862 [
863 'parent' => 'litespeed-menu',
864 'id' => 'litespeed-bar-manage',
865 'title' => esc_html__( 'Manage', 'litespeed-cache' ),
866 'href' => 'admin.php?page=litespeed',
867 'meta' => [ 'tabindex' => '0' ],
868 ]
869 );
870
871 $wp_admin_bar->add_menu(
872 [
873 'parent' => 'litespeed-menu',
874 'id' => 'litespeed-bar-setting',
875 'title' => esc_html__( 'Settings', 'litespeed-cache' ),
876 'href' => 'admin.php?page=litespeed-cache',
877 'meta' => [ 'tabindex' => '0' ],
878 ]
879 );
880
881 if ( ! is_network_admin() ) {
882 $wp_admin_bar->add_menu(
883 [
884 'parent' => 'litespeed-menu',
885 'id' => 'litespeed-bar-imgoptm',
886 'title' => esc_html__( 'Image Optimization', 'litespeed-cache' ),
887 'href' => 'admin.php?page=litespeed-img_optm',
888 'meta' => [ 'tabindex' => '0' ],
889 ]
890 );
891 }
892
893 $wp_admin_bar->add_menu(
894 [
895 'parent' => 'litespeed-menu',
896 'id' => 'litespeed-purge-all',
897 'title' => esc_html__( 'Purge All', 'litespeed-cache' ),
898 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL ),
899 'meta' => [ 'tabindex' => '0' ],
900 ]
901 );
902
903 $wp_admin_bar->add_menu(
904 [
905 'parent' => 'litespeed-menu',
906 'id' => 'litespeed-purge-all-lscache',
907 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LSCache', 'litespeed-cache' ),
908 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE ),
909 'meta' => [ 'tabindex' => '0' ],
910 ]
911 );
912
913 $wp_admin_bar->add_menu(
914 [
915 'parent' => 'litespeed-menu',
916 'id' => 'litespeed-purge-cssjs',
917 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'CSS/JS Cache', 'litespeed-cache' ),
918 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CSSJS ),
919 'meta' => [ 'tabindex' => '0' ],
920 ]
921 );
922
923 if ( $this->conf( self::O_CDN_CLOUDFLARE ) ) {
924 $wp_admin_bar->add_menu(
925 [
926 'parent' => 'litespeed-menu',
927 'id' => 'litespeed-purge-cloudflare',
928 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Cloudflare', 'litespeed-cache' ),
929 'href' => Utility::build_url( Router::ACTION_CDN_CLOUDFLARE, CDN\Cloudflare::TYPE_PURGE_ALL ),
930 'meta' => [ 'tabindex' => '0' ],
931 ]
932 );
933 }
934
935 if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
936 $wp_admin_bar->add_menu(
937 [
938 'parent' => 'litespeed-menu',
939 'id' => 'litespeed-purge-object',
940 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Object Cache', 'litespeed-cache' ),
941 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OBJECT ),
942 'meta' => [ 'tabindex' => '0' ],
943 ]
944 );
945 }
946
947 if ( Router::opcache_enabled() ) {
948 $wp_admin_bar->add_menu(
949 [
950 'parent' => 'litespeed-menu',
951 'id' => 'litespeed-purge-opcache',
952 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Opcode Cache', 'litespeed-cache' ),
953 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OPCACHE ),
954 'meta' => [ 'tabindex' => '0' ],
955 ]
956 );
957 }
958
959 if ( $this->has_cache_folder( 'ccss' ) ) {
960 $wp_admin_bar->add_menu(
961 [
962 'parent' => 'litespeed-menu',
963 'id' => 'litespeed-purge-ccss',
964 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - CCSS',
965 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CCSS ),
966 'meta' => [ 'tabindex' => '0' ],
967 ]
968 );
969 }
970
971 if ( $this->has_cache_folder( 'ucss' ) ) {
972 $wp_admin_bar->add_menu(
973 [
974 'parent' => 'litespeed-menu',
975 'id' => 'litespeed-purge-ucss',
976 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - UCSS',
977 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_UCSS ),
978 ]
979 );
980 }
981
982 if ( $this->has_cache_folder( 'localres' ) ) {
983 $wp_admin_bar->add_menu(
984 [
985 'parent' => 'litespeed-menu',
986 'id' => 'litespeed-purge-localres',
987 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Localized Resources', 'litespeed-cache' ),
988 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES ),
989 'meta' => [ 'tabindex' => '0' ],
990 ]
991 );
992 }
993
994 if ( $this->has_cache_folder( 'lqip' ) ) {
995 $wp_admin_bar->add_menu(
996 [
997 'parent' => 'litespeed-menu',
998 'id' => 'litespeed-purge-placeholder',
999 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LQIP Cache', 'litespeed-cache' ),
1000 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LQIP ),
1001 'meta' => [ 'tabindex' => '0' ],
1002 ]
1003 );
1004 }
1005
1006 if ( $this->has_cache_folder( 'vpi' ) ) {
1007 $wp_admin_bar->add_menu(
1008 [
1009 'parent' => 'litespeed-menu',
1010 'id' => 'litespeed-purge-vpi',
1011 'title' => __( 'Purge All', 'litespeed-cache' ) . ' - VPI',
1012 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_VPI ),
1013 'meta' => [ 'tabindex' => '0' ],
1014 ]
1015 );
1016 }
1017
1018 if ( $this->has_cache_folder( 'avatar' ) ) {
1019 $wp_admin_bar->add_menu(
1020 [
1021 'parent' => 'litespeed-menu',
1022 'id' => 'litespeed-purge-avatar',
1023 'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Gravatar Cache', 'litespeed-cache' ),
1024 'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_AVATAR ),
1025 'meta' => [ 'tabindex' => '0' ],
1026 ]
1027 );
1028 }
1029
1030 do_action( 'litespeed_backend_shortcut' );
1031 }
1032
1033 /**
1034 * Clear unfinished data link/button.
1035 *
1036 * @since 2.4.2
1037 * @access public
1038 *
1039 * @param int $unfinished_num Number of unfinished images.
1040 * @return string HTML for action button.
1041 */
1042 public static function img_optm_clean_up( $unfinished_num ) {
1043 return sprintf(
1044 '<a href="%1$s" class="button litespeed-btn-warning" data-balloon-pos="up" aria-label="%2$s"><span class="dashicons dashicons-editor-removeformatting"></span>&nbsp;%3$s</a>',
1045 esc_url( Utility::build_url( Router::ACTION_IMG_OPTM, Img_Optm::TYPE_CLEAN ) ),
1046 esc_attr__( 'Remove all previous unfinished image optimization requests.', 'litespeed-cache' ),
1047 esc_html__( 'Clean Up Unfinished Data', 'litespeed-cache' ) . ( $unfinished_num ? ': ' . Admin_Display::print_plural( $unfinished_num, 'image' ) : '' )
1048 );
1049 }
1050
1051 /**
1052 * Generate install link.
1053 *
1054 * @since 2.4.2
1055 * @access public
1056 *
1057 * @param string $title Plugin title.
1058 * @param string $name Slug.
1059 * @param string $v Version (unused, kept for BC).
1060 * @return string HTML link.
1061 */
1062 public static function plugin_install_link( $title, $name, $v ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
1063 $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $name ), 'install-plugin_' . $name );
1064
1065 $action = sprintf(
1066 '<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%3$s" aria-label="%4$s">%5$s</a>',
1067 esc_url( $url ),
1068 esc_attr( $name ),
1069 esc_attr( $title ),
1070 esc_attr( sprintf( __( 'Install %s', 'litespeed-cache' ), $title ) ),
1071 esc_html__( 'Install Now', 'litespeed-cache' )
1072 );
1073
1074 return $action;
1075 }
1076
1077 /**
1078 * Generate upgrade link.
1079 *
1080 * @since 2.4.2
1081 * @access public
1082 *
1083 * @param string $title Plugin title.
1084 * @param string $name Slug.
1085 * @param string $v Version string.
1086 * @return string HTML message with links.
1087 */
1088 public static function plugin_upgrade_link( $title, $name, $v ) {
1089 $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $name . '&section=changelog&TB_iframe=true&width=600&height=800' );
1090 $file = $name . '/' . $name . '.php';
1091
1092 $msg = sprintf(
1093 /* translators: 1: details URL, 2: class/aria, 3: version, 4: update URL, 5: class/aria */
1094 __('<a href="%1$s" %2$s>View version %3$s details</a> or <a href="%4$s" %5$s target="_blank">update now</a>.', 'litespeed-cache'),
1095 esc_url( $details_url ),
1096 sprintf(
1097 'class="thickbox open-plugin-details-modal" aria-label="%s"',
1098 esc_attr(
1099 sprintf(
1100 /* translators: 1: plugin title, 2: version */
1101 __( 'View %1$s version %2$s details', 'litespeed-cache' ),
1102 $title,
1103 $v
1104 )
1105 )
1106 ),
1107 esc_html( $v ),
1108 esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ) ),
1109 sprintf(
1110 'class="update-link" aria-label="%s"',
1111 esc_attr(
1112 sprintf(
1113 /* translators: %s: plugin title */
1114 __( 'Update %s now', 'litespeed-cache' ),
1115 $title
1116 )
1117 )
1118 )
1119 );
1120
1121 return $msg;
1122 }
1123
1124 /**
1125 * Finalize buffer by GUI class.
1126 *
1127 * @since 1.6
1128 * @access public
1129 *
1130 * @param string $buffer HTML buffer.
1131 * @return string Filtered buffer.
1132 */
1133 public function finalize( $buffer ) {
1134 $buffer = $this->_clean_wrapper( $buffer );
1135
1136 // Maybe restore doc.ref.
1137 if ( $this->conf( Base::O_GUEST ) && false !== strpos( $buffer, '<head>' ) && defined( 'LITESPEED_IS_HTML' ) ) {
1138 $buffer = $this->_enqueue_guest_docref_js( $buffer );
1139 }
1140
1141 if ( defined( 'LITESPEED_GUEST' ) && LITESPEED_GUEST && false !== strpos( $buffer, '</body>' ) && defined( 'LITESPEED_IS_HTML' ) ) {
1142 $buffer = $this->_enqueue_guest_js( $buffer );
1143 }
1144
1145 return $buffer;
1146 }
1147
1148 /**
1149 * Append guest restore doc.ref JS for organic traffic count.
1150 *
1151 * @since 4.4.6
1152 *
1153 * @param string $buffer HTML buffer.
1154 * @return string Buffer with inline script injected.
1155 */
1156 private function _enqueue_guest_docref_js( $buffer ) {
1157 $js_con = File::read( LSCWP_DIR . self::LIB_GUEST_DOCREF_JS );
1158 $buffer = preg_replace( '/<head>/', '<head><script data-no-optimize="1">' . $js_con . '</script>', $buffer, 1 );
1159 return $buffer;
1160 }
1161
1162 /**
1163 * Append guest JS to update vary.
1164 *
1165 * @since 4.0
1166 *
1167 * @param string $buffer HTML buffer.
1168 * @return string Buffer with inline script injected.
1169 */
1170 private function _enqueue_guest_js( $buffer ) {
1171 $js_con = File::read( LSCWP_DIR . self::LIB_GUEST_JS );
1172 // Build path for guest endpoint using wp_parse_url for compatibility.
1173 $guest_update_path = wp_parse_url( LSWCP_PLUGIN_URL . self::PHP_GUEST, PHP_URL_PATH );
1174 $js_con = str_replace( 'litespeed_url', esc_url( $guest_update_path ), $js_con );
1175 $buffer = preg_replace( '/<\/body>/', '<script data-no-optimize="1">' . $js_con . '</script></body>', $buffer, 1 );
1176 return $buffer;
1177 }
1178
1179 /**
1180 * Clean wrapper from buffer.
1181 *
1182 * @since 1.4
1183 * @since 1.6 Converted to private with adding prefix _.
1184 * @access private
1185 *
1186 * @param string $buffer HTML buffer.
1187 * @return string Cleaned buffer.
1188 */
1189 private function _clean_wrapper( $buffer ) {
1190 if ( self::$_clean_counter < 1 ) {
1191 self::debug2( 'bypassed by no counter' );
1192 return $buffer;
1193 }
1194
1195 self::debug2( 'start cleaning counter ' . self::$_clean_counter );
1196
1197 for ( $i = 1; $i <= self::$_clean_counter; $i++ ) {
1198 // If miss beginning.
1199 $start = strpos( $buffer, self::clean_wrapper_begin( $i ) );
1200 if ( false === $start ) {
1201 $buffer = str_replace( self::clean_wrapper_end( $i ), '', $buffer );
1202 self::debug2( "lost beginning wrapper $i" );
1203 continue;
1204 }
1205
1206 // If miss end.
1207 $end_wrapper = self::clean_wrapper_end( $i );
1208 $end = strpos( $buffer, $end_wrapper );
1209 if ( false === $end ) {
1210 $buffer = str_replace( self::clean_wrapper_begin( $i ), '', $buffer );
1211 self::debug2( "lost ending wrapper $i" );
1212 continue;
1213 }
1214
1215 // Now replace wrapped content.
1216 $buffer = substr_replace( $buffer, '', $start, $end - $start + strlen( $end_wrapper ) );
1217 self::debug2( "cleaned wrapper $i" );
1218 }
1219
1220 return $buffer;
1221 }
1222
1223 /**
1224 * Display a to-be-removed HTML wrapper (begin tag).
1225 *
1226 * @since 1.4
1227 * @access public
1228 *
1229 * @param int|false $counter Optional explicit wrapper id; auto-increment if false.
1230 * @return string Wrapper begin HTML comment.
1231 */
1232 public static function clean_wrapper_begin( $counter = false ) {
1233 if ( false === $counter ) {
1234 ++self::$_clean_counter;
1235 $counter = self::$_clean_counter;
1236 self::debug( 'clean wrapper ' . $counter . ' begin' );
1237 }
1238 return '<!-- LiteSpeed To Be Removed begin ' . $counter . ' -->';
1239 }
1240
1241 /**
1242 * Display a to-be-removed HTML wrapper (end tag).
1243 *
1244 * @since 1.4
1245 * @access public
1246 *
1247 * @param int|false $counter Optional explicit wrapper id; use latest if false.
1248 * @return string Wrapper end HTML comment.
1249 */
1250 public static function clean_wrapper_end( $counter = false ) {
1251 if ( false === $counter ) {
1252 $counter = self::$_clean_counter;
1253 self::debug( 'clean wrapper ' . $counter . ' end' );
1254 }
1255 return '<!-- LiteSpeed To Be Removed end ' . $counter . ' -->';
1256 }
1257 }
1258