// Try to load, if can pass, will set $this->_promo_true = true.
$this->_promo_true = false;
include LSCWP_DIR . "tpl/banner/$promo_tag.php";
// If not defined, means it didn't pass the display workflow in tpl.
if ( ! $this->_promo_true ) {
defined( 'LSCWP_LOG' ) && self::debug( 'Show promo ' . $promo_tag );
* Load frontend public script.
public function frontend_enqueue_style_public() {
LSWCP_PLUGIN_URL . 'assets/js/instant_click.min.js',
* Load frontend stylesheet.
public function frontend_enqueue_style() {
wp_enqueue_style( Core::PLUGIN_NAME, LSWCP_PLUGIN_URL . 'assets/css/litespeed.css', [], Core::VER, 'all' );
* Load frontend menu shortcut items in the admin bar.
* @since 7.6 Add VPI clear.
public function frontend_shortcut() {
'id' => 'litespeed-menu',
'title' => '<span class="ab-icon"></span>',
'href' => get_admin_url( null, 'admin.php?page=litespeed' ),
'class' => 'litespeed-top-toolbar',
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-single',
'title' => esc_html__( 'Purge this page', 'litespeed-cache' ) . ' - LSCache',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_FRONT, false, true ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'ucss' ) ) {
$possible_url_tag = UCSS::get_url_tag();
if ( $possible_url_tag ) {
$append_arr['url_tag'] = $possible_url_tag;
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-single-ucss',
'title' => esc_html__( 'Purge this page', 'litespeed-cache' ) . ' - UCSS',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_UCSS, false, true, $append_arr ),
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-single-action',
'title' => esc_html__( 'Mark this page as ', 'litespeed-cache' ),
'meta' => [ 'tabindex' => '0' ],
$current_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
Conf::TYPE_SET . '[' . self::O_CACHE_FORCE_URI . '][]' => $current_uri . '$',
'redirect' => $current_uri,
'parent' => 'litespeed-single-action',
'id' => 'litespeed-single-forced_cache',
'title' => esc_html__( 'Forced cacheable', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
Conf::TYPE_SET . '[' . self::O_CACHE_EXC . '][]' => $current_uri . '$',
'redirect' => $current_uri,
'parent' => 'litespeed-single-action',
'id' => 'litespeed-single-noncache',
'title' => esc_html__( 'Non cacheable', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
Conf::TYPE_SET . '[' . self::O_CACHE_PRIV_URI . '][]' => $current_uri . '$',
'redirect' => $current_uri,
'parent' => 'litespeed-single-action',
'id' => 'litespeed-single-private',
'title' => esc_html__( 'Private cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
Conf::TYPE_SET . '[' . self::O_OPTM_EXC . '][]' => $current_uri . '$',
'redirect' => $current_uri,
'parent' => 'litespeed-single-action',
'id' => 'litespeed-single-nonoptimize',
'title' => esc_html__( 'No optimization', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, true, $append_arr ),
'parent' => 'litespeed-single-action',
'id' => 'litespeed-single-more',
'title' => esc_html__( 'More settings', 'litespeed-cache' ),
'href' => get_admin_url( null, 'admin.php?page=litespeed-cache' ),
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-all',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-all-lscache',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LSCache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-cssjs',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'CSS/JS Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CSSJS, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->conf( self::O_CDN_CLOUDFLARE ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-cloudflare',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Cloudflare', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CDN_CLOUDFLARE, CDN\Cloudflare::TYPE_PURGE_ALL ),
'meta' => [ 'tabindex' => '0' ],
if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-object',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Object Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OBJECT, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( Router::opcache_enabled() ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-opcache',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Opcode Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OPCACHE, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'ccss' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-ccss',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - CCSS',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CCSS, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'ucss' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-ucss',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - UCSS',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_UCSS, false, '_ori' ),
if ( $this->has_cache_folder( 'localres' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-localres',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Localized Resources', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'lqip' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-placeholder',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LQIP Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LQIP, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'vpi' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-vpi',
'title' => __( 'Purge All', 'litespeed-cache' ) . ' - VPI',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_VPI, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'avatar' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-avatar',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Gravatar Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_AVATAR, false, '_ori' ),
'meta' => [ 'tabindex' => '0' ],
do_action( 'litespeed_frontend_shortcut' );
* Hooked to wp_before_admin_bar_render.
* Adds links to the admin bar so users can quickly manage/purge.
* @since 1.7.2 Moved from admin_display.cls to gui.cls; Renamed from `add_quick_purge` to `backend_shortcut`.
* @global \WP_Admin_Bar $wp_admin_bar
public function backend_shortcut() {
if ( defined( 'LITESPEED_DISABLE_ALL' ) && LITESPEED_DISABLE_ALL ) {
'id' => 'litespeed-menu',
'title' => '<span class="ab-icon icon_disabled" title="LiteSpeed Cache"></span>',
'href' => 'admin.php?page=litespeed-toolbox#settings-debug',
'class' => 'litespeed-top-toolbar',
'parent' => 'litespeed-menu',
'id' => 'litespeed-enable_all',
'title' => esc_html__( 'Enable All Features', 'litespeed-cache' ),
'href' => 'admin.php?page=litespeed-toolbox#settings-debug',
'meta' => [ 'tabindex' => '0' ],
'id' => 'litespeed-menu',
'title' => '<span class="ab-icon" title="' . esc_attr__( 'LiteSpeed Cache Purge All', 'litespeed-cache' ) . ' - ' . esc_attr__( 'LSCache', 'litespeed-cache' ) . '"></span>',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE ),
'class' => 'litespeed-top-toolbar',
'parent' => 'litespeed-menu',
'id' => 'litespeed-bar-manage',
'title' => esc_html__( 'Manage', 'litespeed-cache' ),
'href' => 'admin.php?page=litespeed',
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-bar-setting',
'title' => esc_html__( 'Settings', 'litespeed-cache' ),
'href' => 'admin.php?page=litespeed-cache',
'meta' => [ 'tabindex' => '0' ],
if ( ! is_network_admin() ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-bar-imgoptm',
'title' => esc_html__( 'Image Optimization', 'litespeed-cache' ),
'href' => 'admin.php?page=litespeed-img_optm',
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-all',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL ),
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-all-lscache',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'LSCache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LSCACHE ),
'meta' => [ 'tabindex' => '0' ],
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-cssjs',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'CSS/JS Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CSSJS ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->conf( self::O_CDN_CLOUDFLARE ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-cloudflare',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Cloudflare', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_CDN_CLOUDFLARE, CDN\Cloudflare::TYPE_PURGE_ALL ),
'meta' => [ 'tabindex' => '0' ],
if ( defined( 'LSCWP_OBJECT_CACHE' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-object',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Object Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OBJECT ),
'meta' => [ 'tabindex' => '0' ],
if ( Router::opcache_enabled() ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-opcache',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Opcode Cache', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_OPCACHE ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'ccss' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-ccss',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - CCSS',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_CCSS ),
'meta' => [ 'tabindex' => '0' ],
if ( $this->has_cache_folder( 'ucss' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-ucss',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - UCSS',
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_UCSS ),
if ( $this->has_cache_folder( 'localres' ) ) {
'parent' => 'litespeed-menu',
'id' => 'litespeed-purge-localres',
'title' => esc_html__( 'Purge All', 'litespeed-cache' ) . ' - ' . esc_html__( 'Localized Resources', 'litespeed-cache' ),
'href' => Utility::build_url( Router::ACTION_PURGE, Purge::TYPE_PURGE_ALL_LOCALRES ),
'meta' => [ 'tabindex' => '0' ],