Файловый менеджер - Редактировать - /home/tuudkjt/globeasy/wp-includes/ID3/thirdparty.tar
Назад
wc-pdf-product-vouchers.cls.php 0000777 00000001740 15252323732 0012544 0 ustar 00 <?php /** * The Third Party integration with WooCommerce PDF Product Vouchers. * * @since 5.1.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility for WooCommerce PDF Product Vouchers. */ class WC_PDF_Product_Vouchers { /** * Disable caching for generated vouchers. * * @since 5.1.0 * @access public * @return void */ public static function detect() { if (!class_exists('\WC_PDF_Product_Vouchers_Loader')) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended $is_voucher = !empty($_GET['post_type']) && 'wc_voucher' === sanitize_text_field(wp_unslash($_GET['post_type'])); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $has_key = !empty($_GET['voucher_key']) || !empty($_GET['key']); if ($is_voucher && $has_key) { do_action('litespeed_control_set_nocache', '3rd WC PDF Product Voucher'); } } } yith-wishlist.cls.php 0000777 00000012356 15252323732 0010700 0 ustar 00 <?php /** * The Third Party integration with the YITH WooCommerce Wishlist plugin. * * Hooks YITH Wishlist UI into LiteSpeed ESI and purges appropriately. * * @since 1.1.0 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); use LiteSpeed\Tag; use LiteSpeed\Conf; use LiteSpeed\Base; /** * YITH WooCommerce Wishlist integration for LiteSpeed Cache. */ class Yith_Wishlist { const ESI_PARAM_POSTID = 'yith_pid'; /** * Current product ID captured for ESI rendering. * * @var int */ private static $_post_id; /** * Detects if YITH WooCommerce Wishlist and WooCommerce are installed. * * @since 1.1.0 * @return void */ public static function detect() { if ( ! defined( 'WOOCOMMERCE_VERSION' ) || ! defined( 'YITH_WCWL' ) ) { return; } if ( apply_filters( 'litespeed_esi_status', false ) ) { add_action( 'litespeed_tpl_normal', __CLASS__ . '::is_not_esi' ); add_action( 'litespeed_esi_load-yith_wcwl_add', __CLASS__ . '::load_add_to_wishlist' ); add_filter( 'litespeed_esi_inline-yith_wcwl_add', __CLASS__ . '::inline_add_to_wishlist', 20, 2 ); // Hook to add/delete wishlist. add_action( 'yith_wcwl_added_to_wishlist', __CLASS__ . '::purge' ); add_action( 'yith_wcwl_removed_from_wishlist', __CLASS__ . '::purge' ); } } /** * Purge ESI YITH cache when add/remove items. * * @since 1.2.0 * @return void */ public static function purge() { do_action( 'litespeed_purge_esi', 'yith_wcwl_add' ); } /** * Hooked to the litespeed_is_not_esi_template action. * * If the request is not an ESI request, hook to the add to wishlist button * filter to replace it as an ESI block. * * @since 1.1.0 * @return void */ public static function is_not_esi() { add_filter( 'yith_wcwl_add_to_wishlist_params', __CLASS__ . '::add_to_wishlist_params', 999, 2 ); add_filter( 'yith_wcwl_add_to_wishlisth_button_html', __CLASS__ . '::sub_add_to_wishlist', 999 ); } /** * Store the post id for later shortcode usage. * * @since 3.4.1 * * @param array $defaults Default parameters provided by YITH. * @param array $atts Shortcode attributes for add-to-wishlist. * @return array Unmodified defaults. */ public static function add_to_wishlist_params( $defaults, $atts ) { self::$_post_id = ! empty( $atts['product_id'] ) ? (int) $atts['product_id'] : (int) $defaults['product_id']; return $defaults; } /** * Replace the native button HTML with an ESI block. * * The add to wishlist button displays a different output when the item is already * in the wishlist/cart. For this reason, the button must be an ESI block. * * @since 1.1.0 * * @param string $template Original button HTML. * @return string ESI URL placeholder for rendering. */ public static function sub_add_to_wishlist( $template ) { $params = [ self::ESI_PARAM_POSTID => self::$_post_id, ]; $inline_tags = [ '', rtrim( Tag::TYPE_ESI, '.' ), Tag::TYPE_ESI . 'yith_wcwl_add' ]; $inline_tags = implode( ',', array_map( function ( $val ) { return 'public:' . LSWCP_TAG_PREFIX . '_' . $val; }, $inline_tags ) ); $inline_tags .= ',' . LSWCP_TAG_PREFIX . '_tag_priv'; do_action( 'litespeed_esi_combine', 'yith_wcwl_add' ); $inline_params = [ 'val' => $template, 'tag' => $inline_tags, 'control' => 'private,no-vary,max-age=' . Conf::cls()->conf( Base::O_CACHE_TTL_PRIV ), ]; return apply_filters( 'litespeed_esi_url', 'yith_wcwl_add', 'YITH ADD TO WISHLIST', $params, 'private,no-vary', false, false, false, $inline_params ); } /** * Load the add to wishlist button HTML for ESI output. * * @since 1.1.0 * * @param array $params ESI parameters, expects product id under ESI_PARAM_POSTID. * @return void */ public static function load_add_to_wishlist( $params ) { $pid = isset( $params[ self::ESI_PARAM_POSTID ] ) ? (int) $params[ self::ESI_PARAM_POSTID ] : 0; // Output the rendered shortcode safely. // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_kses_post handles allowed HTML. echo wp_kses_post( \YITH_WCWL_Shortcode::add_to_wishlist( [ 'product_id' => $pid ] ) ); do_action( 'litespeed_control_set_private', 'yith wishlist' ); do_action( 'litespeed_vary_no' ); } /** * Generate ESI inline value. * * @since 3.4.2 * * @param mixed $res Current response (array or anything); will be normalized to array. * @param array $params ESI parameters that include product id. * @return array Inline ESI payload with value, control and tags. */ public static function inline_add_to_wishlist( $res, $params ) { if ( ! is_array( $res ) ) { $res = []; } $pid = isset( $params[ self::ESI_PARAM_POSTID ] ) ? (int) $params[ self::ESI_PARAM_POSTID ] : 0; $res['val'] = \YITH_WCWL_Shortcode::add_to_wishlist( [ 'product_id' => $pid ] ); $res['control'] = 'private,no-vary,max-age=' . Conf::cls()->conf( Base::O_CACHE_TTL_PRIV ); $inline_tags = [ '', rtrim( Tag::TYPE_ESI, '.' ), Tag::TYPE_ESI . 'yith_wcwl_add' ]; $inline_tags = implode( ',', array_map( function ( $val ) { return 'public:' . LSWCP_TAG_PREFIX . '_' . $val; }, $inline_tags ) ); $inline_tags .= ',' . LSWCP_TAG_PREFIX . '_tag_priv'; $res['tag'] = $inline_tags; return $res; } } caldera-forms.cls.php 0000777 00000001446 15252323732 0010574 0 ustar 00 <?php /** * The Third Party integration with Caldera Forms. * * @since 3.2.2 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Integration with Caldera Forms to ensure proper nonce handling for cached pages. */ class Caldera_Forms { /** * Detects if Caldera Forms is active and registers nonces accordingly. * * Hooks the plugin's frontend nonce pattern into LiteSpeed so cached pages * still validate form submissions. * * @since 3.2.2 * @return void */ public static function detect() { if (!defined('CFCORE_VER')) { return; } // plugins/caldera-forms/classes/render/nonce.php -> class Caldera_Forms_Render_Nonce do_action('litespeed_nonce', 'caldera_forms_front_*'); } } theme-my-login.cls.php 0000777 00000002012 15252323732 0010676 0 ustar 00 <?php /** * The Third Party integration with the Theme My Login plugin. * * @since 1.0.15 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility for the Theme My Login plugin. */ class Theme_My_Login { /** * Detects if Better Theme My Login is active. * * @since 1.0.15 * @access public * @return void */ public static function detect() { if (defined('THEME_MY_LOGIN_PATH')) { add_action('litespeed_control_finalize', __CLASS__ . '::set_control'); } } /** * This filter is used to let the cache know if a page is cacheable. * * @since 1.0.15 * @access public * @return void */ public static function set_control() { if (!apply_filters('litespeed_control_cacheable', false)) { return; } // Check if this page is TML page or not. if (class_exists('Theme_My_Login') && \Theme_My_Login::is_tml_page()) { do_action('litespeed_control_set_nocache', 'Theme My Login'); } } } perfmatters.cls.php 0000777 00000001744 15252323732 0010412 0 ustar 00 <?php /** * The Third Party integration with the Perfmatters plugin. * * @since 4.4.5 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility for the Perfmatters plugin. */ class Perfmatters { /** * Preload Perfmatters integration. * * @since 4.4.5 * @return void */ public static function preload() { if (!defined('PERFMATTERS_VERSION')) { return; } if (is_admin()) { return; } if (has_action('shutdown', 'perfmatters_script_manager') !== false) { add_action('init', __CLASS__ . '::disable_litespeed_esi', 4); } } /** * Disable LiteSpeed ESI when Perfmatters Script Manager is active. * * @since 4.4.5 * @return void */ public static function disable_litespeed_esi() { if (!defined('LITESPEED_ESI_OFF')) { define('LITESPEED_ESI_OFF', true); } do_action('litespeed_debug', 'Disable ESI due to Perfmatters script manager'); } } woocommerce.content.tpl.php 0000777 00000007637 15252323732 0012073 0 ustar 00 <?php /** * LiteSpeed Cache – WooCommerce settings template. * * Renders the WooCommerce integration settings within the LiteSpeed Cache admin. * * @package LiteSpeed\Thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; use LiteSpeed\Doc; ?> <div data-litespeed-layout="woocommerce"> <h3 class="litespeed-title-short"> <?php esc_html_e( 'WooCommerce Settings', 'litespeed-cache' ); ?> <?php Doc::learn_more( 'https://docs.litespeedtech.com/lscache/lscwp/cache/#woocommerce-tab' ); ?> </h3> <div class="litespeed-callout notice notice-warning inline"> <h4><?php esc_html_e( 'NOTICE:', 'litespeed-cache' ); ?></h4> <p><?php esc_html_e( 'After verifying that the cache works in general, please test the cart.', 'litespeed-cache' ); ?></p> <p> <?php printf( /* translators: %s: link attributes */ esc_html__( 'To test the cart, visit the %sFAQ%s.', 'litespeed-cache' ), '<a href="https://docs.litespeedtech.com/lscache/lscwp/installation/#non-cacheable-pages" target="_blank">', '</a>' ); ?> </p> <p><?php esc_html_e( 'By default, the My Account, Checkout, and Cart pages are automatically excluded from caching. Misconfiguration of page associations in WooCommerce settings may cause some pages to be erroneously excluded.', 'litespeed-cache' ); ?></p> </div> <table class="wp-list-table striped litespeed-table"> <tbody> <tr> <th> <?php $setting_id = self::O_UPDATE_INTERVAL; ?> <?php esc_html_e( 'Product Update Interval', 'litespeed-cache' ); ?> </th> <td> <?php $options = [ self::O_PQS_CS => esc_html__( 'Purge product on changes to the quantity or stock status.', 'litespeed-cache' ) . ' ' . esc_html__( 'Purge categories only when stock status changes.', 'litespeed-cache' ), self::O_PS_CS => esc_html__( 'Purge product and categories only when the stock status changes.', 'litespeed-cache' ), self::O_PS_CN => esc_html__( 'Purge product only when the stock status changes.', 'litespeed-cache' ) . ' ' . esc_html__( 'Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache' ), self::O_PQS_CQS => esc_html__( 'Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache' ), ]; $conf = (int) apply_filters( 'litespeed_conf', $setting_id ); do_action( 'litespeed_setting_enroll', $setting_id ); foreach ( $options as $k => $v ) : $input_id = 'conf_' . $setting_id . '_' . $k; ?> <div class="litespeed-radio-row"> <input type="radio" autocomplete="off" name="<?php echo esc_attr( (string) $setting_id ); ?>" id="<?php echo esc_attr( $input_id ); ?>" value="<?php echo esc_attr( (string) $k ); ?>" <?php echo checked( $conf, (int) $k, false ); ?> /> <label for="<?php echo esc_attr( $input_id ); ?>"><?php echo esc_html( $v ); ?></label> </div> <?php endforeach; ?> <div class="litespeed-desc"> <?php esc_html_e( 'Determines how changes in product quantity and product stock status affect product pages and their associated category pages.', 'litespeed-cache' ); ?> </div> </td> </tr> <tr> <th> <?php $setting_id = self::O_CART_VARY; ?> <?php esc_html_e( 'Vary for Mini Cart', 'litespeed-cache' ); ?> </th> <td> <?php $conf = (int) apply_filters( 'litespeed_conf', $setting_id ); $this->cls( 'Admin_Display' )->build_switch( $setting_id ); ?> <div class="litespeed-desc"> <?php esc_html_e( 'Generate a separate vary cache copy for the mini cart when the cart is not empty.', 'litespeed-cache' ); ?> <?php esc_html_e( 'If your theme does not use JS to update the mini cart, you must enable this option to display the correct cart contents.', 'litespeed-cache' ); ?> <br /><?php Doc::notice_htaccess(); ?> </div> </td> </tr> </tbody> </table> </div> amp.cls.php 0000777 00000004704 15252323732 0006632 0 ustar 00 <?php /** * The Third Party integration with AMP plugin. * * @since 2.9.8.6 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; /** * Integration helpers for AMP-compatible behaviour. * * Disables optimization features on AMP endpoints provided by popular AMP * plugins to ensure valid AMP output (no injected JS/lazy/CSS async, etc). */ class AMP { /** * Maybe mark current request as AMP and disable conflicting optimizations. * * @since 4.2 * * @param string $amp_function Callback/function name that returns whether current request is AMP. * @return void */ private static function _maybe_amp( $amp_function ) { if ( is_admin() ) { return; } // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( ! isset( $_GET['amp'] ) && ( ! function_exists( $amp_function ) || ! $amp_function() ) ) { return; } do_action( 'litespeed_debug', '[3rd] ❌ AMP disabled page optm/lazy' ); defined( 'LITESPEED_NO_PAGEOPTM' ) || define( 'LITESPEED_NO_PAGEOPTM', true ); defined( 'LITESPEED_NO_LAZY' ) || define( 'LITESPEED_NO_LAZY', true ); defined( 'LITESPEED_NO_OPTM' ) || define( 'LITESPEED_NO_OPTM', true ); // defined( 'LITESPEED_GUEST' ) || define( 'LITESPEED_GUEST', false ); } /** * Ampforwp_is_amp_endpoint() from Accelerated Mobile Pages. * * @since 4.2 * @return void */ public static function maybe_acc_mob_pages() { self::_maybe_amp( 'ampforwp_is_amp_endpoint' ); } /** * Google AMP fix. * * @since 4.2.0.1 * @return void */ public static function maybe_google_amp() { self::_maybe_amp( 'amp_is_request' ); } /** * Preload hooks to detect AMP requests and turn off conflicting features. * * CSS async will affect AMP result and Lazyload injects JS libraries which * AMP does not allow. Ensure those are disabled early on AMP endpoints. * * @since 2.9.8.6 * @access public * @return void */ public static function preload() { add_action( 'wp', __CLASS__ . '::maybe_acc_mob_pages' ); add_action( 'wp', __CLASS__ . '::maybe_google_amp' ); // amp_is_request() from AMP. // self::maybe_amp( 'amp_is_request' ); // add_filter( 'litespeed_can_optm', '__return_false' ); // do_action( 'litespeed_conf_force', API::O_OPTM_CSS_ASYNC, false ); // do_action( 'litespeed_conf_force', API::O_MEDIA_LAZY, false ); // do_action( 'litespeed_conf_force', API::O_MEDIA_IFRAME_LAZY, false ); } } wpml.cls.php 0000777 00000002025 15252323732 0007026 0 ustar 00 <?php /** * The Third Party integration with WPML. * * Adds WPML language domains to LiteSpeed's list of internal domains. * * @since 2.9.4 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); /** * WPML integration for LiteSpeed Cache. */ class WPML { /** * Registers filters when WPML is active. * * @since 2.9.4 * @return void */ public static function detect() { if ( ! defined( 'WPML_PLUGIN_BASENAME' ) ) { return; } add_filter( 'litespeed_internal_domains', __CLASS__ . '::append_domains' ); } /** * Take language domains as internal domains. * * @since 2.9.4 * * @param array $domains Existing internal domains. * @return array Modified list of internal domains including WPML language domains. */ public static function append_domains( $domains ) { $wpml_domains = apply_filters( 'wpml_setting', false, 'language_domains' ); if ( $wpml_domains ) { $domains = array_merge( $domains, array_values( $wpml_domains ) ); } return $domains; } } facetwp.cls.php 0000777 00000002707 15252323732 0007507 0 ustar 00 <?php /** * The Third Party integration with FacetWP. * * @since 2.9.9 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * FacetWP compatibility hooks for LiteSpeed Cache. */ class Facetwp { /** * Detect FacetWP context and adjust ESI params when FacetWP returns buffered HTML via the "wp" template. * * Note: We only *read* POST data here to detect an AJAX context; no privileged action is performed. * Data is unslashed and sanitized before comparison. * * @since 2.9.9 * @return void */ public static function detect() { if ( ! defined( 'FACETWP_VERSION' ) ) { return; } /** * For Facetwp, if the template is "wp", return the buffered HTML * So marked as rest call to put is_json to ESI */ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Reading POST to detect FacetWP AJAX; no state change or sensitive action performed. if ( ! empty( $_POST['action'] ) && ! empty( $_POST['data'] ) && ! empty( $_POST['data']['template'] ) && 'wp' === $_POST['data']['template'] ) { add_filter( 'litespeed_esi_params', __CLASS__ . '::set_is_json' ); } } /** * Mark ESI response as JSON for FacetWP's "wp" template refreshes. * * @since 2.9.9 * @param array $params Existing ESI params. * @return array Modified ESI params. */ public static function set_is_json( $params ) { $params['is_json'] = 1; return $params; } } wpdiscuz.cls.php 0000777 00000002272 15252323732 0007723 0 ustar 00 <?php /** * The Third Party integration with Wpdiscuz. * * @since 2.9.5 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); use LiteSpeed\API; /** * Wpdiscuz integration for LiteSpeed Cache. * * Appends commenter vary and disables pending-check when a commenter is detected. */ class Wpdiscuz { /** * Registers hooks when Wpdiscuz is active. * * @since 2.9.5 * @return void */ public static function detect() { if ( ! defined( 'WPDISCUZ_DS' ) ) { return; } self::check_commenter(); add_action( 'wpdiscuz_add_comment', __CLASS__ . '::add_comment' ); } /** * Appends the commenter vary on new Wpdiscuz comments. * * @since 2.9.5 * @return void */ public static function add_comment() { API::vary_append_commenter(); } /** * Checks current commenter and disables pending vary check if a name exists. * * @since 2.9.5 * @return void */ public static function check_commenter() { $commentor = wp_get_current_commenter(); if (strlen($commentor['comment_author']) > 0) { add_filter( 'litespeed_vary_check_commenter_pending', '__return_false' ); } } } woocommerce.cls.php 0000777 00000067632 15252323732 0010405 0 ustar 00 <?php /** * The Third Party integration with the WooCommerce plugin. * * @since 1.0.5 * @since 1.6.6 Added function_exists check for compatibility * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); use LiteSpeed\API; use LiteSpeed\Base; use LiteSpeed\ESI; /** * WooCommerce third-party integration for LiteSpeed Cache. * * Handles ESI blocks, cache tags, purging behaviors, and settings integration * specific to WooCommerce. */ class WooCommerce extends Base { const O_CACHE_TTL_FRONTPAGE = Base::O_CACHE_TTL_FRONTPAGE; const CACHETAG_SHOP = 'WC_S'; const CACHETAG_TERM = 'WC_T.'; const O_UPDATE_INTERVAL = 'wc_update_interval'; const O_CART_VARY = 'wc_cart_vary'; const O_PQS_CS = 0; // flush product on quantity + stock change, categories on stock change const O_PS_CS = 1; // flush product and categories on stock change const O_PS_CN = 2; // flush product on stock change, categories no flush const O_PQS_CQS = 3; // flush product and categories on quantity + stock change const ESI_PARAM_ARGS = 'wc_args'; const ESI_PARAM_POSTID = 'wc_post_id'; const ESI_PARAM_NAME = 'wc_name'; const ESI_PARAM_PATH = 'wc_path'; const ESI_PARAM_LOCATED = 'wc_located'; /** * Whether ESI is enabled via litespeed_esi_status filter. * * @var bool */ private $esi_enabled; /** * Detects if WooCommerce is installed. * * @since 1.0.5 * @access public * @return void */ public static function detect() { if ( ! defined('WOOCOMMERCE_VERSION') ) { return; } self::cls()->add_hooks(); } /** * Add hooks to woo actions. * * @since 1.6.3 * @access public * @return void */ public function add_hooks() { $this->_option_append(); $this->esi_enabled = (bool) apply_filters('litespeed_esi_status', false); add_action('litespeed_control_finalize', [ $this, 'set_control' ]); add_action('litespeed_tag_finalize', [ $this, 'set_tag' ]); // Purging a product on stock change should only occur during product purchase. This function will add the purging callback when an order is complete. add_action('woocommerce_product_set_stock', [ $this, 'purge_product' ]); add_action('woocommerce_variation_set_stock', [ $this, 'purge_product' ]); // #984479 Update variations stock add_action('comment_post', [ $this, 'add_review' ], 10, 3); if ( $this->esi_enabled ) { if ( function_exists('is_shop') && ! is_shop() ) { add_action('litespeed_tpl_normal', [ $this, 'set_block_template' ]); // No need for add-to-cart button // add_action( 'litespeed_esi_load-wc-add-to-cart-form', [ $this, 'load_add_to_cart_form_block' ] ) ; add_action('litespeed_esi_load-storefront-cart-header', [ $this, 'load_cart_header' ]); add_action('litespeed_esi_load-widget', [ $this, 'register_post_view' ]); } if ( function_exists('is_product') && is_product() ) { add_filter('litespeed_esi_params', [ $this, 'add_post_id' ], 10, 2); } // #612331 - remove WooCommerce geolocation redirect on ESI page (PR#708) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- ESI parameter detection, not processing user input. if (!empty($_GET[ESI::QS_ACTION]) && !empty($_GET[ESI::QS_PARAMS])) { remove_action( 'template_redirect', [ 'WC_Cache_Helper', 'geolocation_ajax_redirect' ], 10 ); } } if ( is_admin() ) { add_action('litespeed_api_purge_post', [ $this, 'backend_purge' ]); // todo add_action('delete_term_relationships', [ $this, 'delete_rel' ], 10, 2); add_action('litespeed_settings_tab', [ $this, 'settings_add_tab' ]); add_action('litespeed_settings_content', [ $this, 'settings_add_content' ]); add_filter('litespeed_widget_default_options', [ $this, 'wc_widget_default' ], 10, 2); } if ( apply_filters('litespeed_conf', self::O_CART_VARY) ) { add_filter( 'litespeed_vary_cookies', /** * Modify list of vary cookies. * * @param string[] $cookie_list List of vary cookies. * @return string[] */ function ( $cookie_list ) { $cookie_list[] = 'woocommerce_cart_hash'; return array_unique( $cookie_list ); } ); } } /** * Purge esi private tag. * * @since 1.6.3 * @access public * @return void */ public function purge_esi() { do_action('litespeed_debug', '3rd woo purge ESI in action: ' . current_filter()); do_action('litespeed_purge_private_esi', 'storefront-cart-header'); } /** * Purge private all. * * @since 3.0 * @access public * @return void */ public function purge_private_all() { do_action('litespeed_purge_private_all'); } /** * Check if need to give an ESI block for cart. * * @since 1.7.2 * @access public * * @param string $template Template path. * @return string Template path. */ public function check_if_need_esi( $template ) { if ( $this->vary_needed() ) { do_action('litespeed_debug', 'API: 3rd woo added ESI'); add_action('litespeed_tpl_normal', [ $this, 'set_swap_header_cart' ]); } return $template; } /** * Keep vary on if cart is not empty. * * @since 1.7.2 * @access public * * @param array $vary Vary array. * @return array */ public function vary_maintain( $vary ) { if ( $this->vary_needed() ) { do_action('litespeed_debug', 'API: 3rd woo added vary due to cart not empty'); $vary['woo_cart'] = 1; } return $vary; } /** * Check if vary need to be on based on cart. * * @since 1.7.2 * @access private * @return bool True when cart has items. */ private function vary_needed() { if ( ! function_exists('WC') ) { return false; } $woocom = WC(); if ( ! $woocom ) { return false; } if ( is_null( $woocom->cart ) ) { return false; } return $woocom->cart->get_cart_contents_count() > 0; } /** * Hooked to the litespeed_is_not_esi_template action. * If the request is not an esi request, set a hook in woocommerce_before_template_part to see if it's something we can ESI. * * @since 1.1.0 * @access public * @return void */ public function set_block_template() { add_action('woocommerce_before_template_part', [ $this, 'block_template' ], 999, 4); } /** * Hooked to the litespeed_is_not_esi_template action. * If the request is not an esi request, set a hook in storefront_header to see if it's something we can ESI. * * Will remove storefront_header_cart in storefront_header. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * @return void */ public function set_swap_header_cart() { $priority = has_action('storefront_header', 'storefront_header_cart'); if ( false !== $priority ) { remove_action('storefront_header', 'storefront_header_cart', $priority); add_action('storefront_header', [ $this, 'esi_cart_header' ], $priority); } } /** * Hooked to the woocommerce_before_template_part action. * Checks if the template contains 'add-to-cart'. If so, and if we want to ESI the request, block it and build the ESI code block. * * The function parameters will be passed to the ESI request. * * @since 1.1.0 * @access public * * @param string $template_name Template name. * @param string $template_path Template path. * @param string $located Located template path. * @param array $args Template args. * @return void */ public function block_template( $template_name, $template_path, $located, $args ) { if ( false === strpos( $template_name, 'add-to-cart' ) ) { if ( false !== strpos( $template_name, 'related.php' ) ) { remove_action('woocommerce_before_template_part', [ $this, 'block_template' ], 999); add_filter('woocommerce_related_products_args', [ $this, 'add_related_tags' ]); add_action('woocommerce_after_template_part', [ $this, 'end_template' ], 999); } return; } // Build ESI block for add-to-cart. // $post_obj = get_post( get_the_ID() ); // if ( ! $post_obj ) { // return; // } // $params = [ // self::ESI_PARAM_ARGS => $args, // self::ESI_PARAM_NAME => $template_name, // self::ESI_PARAM_POSTID => $post_obj->ID, // self::ESI_PARAM_PATH => $template_path, // self::ESI_PARAM_LOCATED => $located, // ]; // add_action('woocommerce_after_add_to_cart_form', [ $this, 'end_form' ]); // add_action('woocommerce_after_template_part', [ $this, 'end_form' ], 999); // // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Filter returns a URL; escaped below. // echo esc_url( apply_filters( 'litespeed_esi_url', 'wc-add-to-cart-form', 'WC_CART_FORM', $params ) ); // // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Allow basic wrapper markup. // echo wp_kses_post( apply_filters( 'litespeed_clean_wrapper_begin', '' ) ); } /** * Hooked to the woocommerce_after_add_to_cart_form action. * If this is hit first, clean the buffer and remove this function and end_template. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param string $template_name Template name. * @return void */ public function end_form( $template_name = '' ) { if ( ! empty( $template_name ) && false === strpos( $template_name, 'add-to-cart' ) ) { return; } // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Allow basic wrapper markup. echo wp_kses_post( apply_filters( 'litespeed_clean_wrapper_end', '' ) ); remove_action('woocommerce_after_add_to_cart_form', [ $this, 'end_form' ]); remove_action('woocommerce_after_template_part', [ $this, 'end_form' ], 999); } /** * If related products are loaded, need to add the extra product ids. * * The page will be purged if any of the products are changed. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param array $args The arguments used to build the related products section. * @return array The unchanged arguments. */ public function add_related_tags( $args ) { if ( empty( $args ) || ! isset( $args['post__in'] ) ) { return $args; } $related_posts = $args['post__in']; foreach ( $related_posts as $related ) { do_action('litespeed_tag_add_post', $related); } return $args; } /** * Hooked to the woocommerce_after_template_part action. * If the template contains 'related.php', restore block hook. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param string $template_name Template name. * @return void */ public function end_template( $template_name ) { if ( false !== strpos( $template_name, 'related.php' ) ) { remove_action('woocommerce_after_template_part', [ $this, 'end_template' ], 999); $this->set_block_template(); } } /** * Hooked to the storefront_header header. * If we want to ESI the request, block it and build the ESI code block. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * @return void */ public function esi_cart_header() { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Filter returns URL. echo apply_filters( 'litespeed_esi_url', 'storefront-cart-header', 'STOREFRONT_CART_HEADER' ); } /** * Hooked to the litespeed_esi_load-storefront-cart-header action. * Generates the cart header for ESI display. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * @return void */ public function load_cart_header() { storefront_header_cart(); } /** * Hooked to the litespeed_esi_load-wc-add-to-cart-form action. * Parses the ESI input parameters and generates the add to cart form for ESI display. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param array $params ESI parameters. * @return void */ public function load_add_to_cart_form_block( $params ) { global $post, $wp_query; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Intentional for WooCommerce template setup. $post = get_post($params[self::ESI_PARAM_POSTID]); $wp_query->setup_postdata($post); function_exists('wc_get_template') && wc_get_template($params[self::ESI_PARAM_NAME], $params[self::ESI_PARAM_ARGS], $params[self::ESI_PARAM_PATH]); } /** * Update WooCommerce when someone visits a product and has the recently viewed products widget. * * Currently, this widget should not be cached. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param array $params Widget parameter array. * @return void */ public function register_post_view( $params ) { if ( 'WC_Widget_Recently_Viewed' !== $params[ API::PARAM_NAME ] ) { return; } if ( ! isset( $params[ self::ESI_PARAM_POSTID ] ) ) { return; } $id = (int) $params[ self::ESI_PARAM_POSTID ]; $esi_post = get_post( $id ); $product = function_exists('wc_get_product') ? wc_get_product( $esi_post ) : false; if ( empty( $product ) ) { return; } // Setup post data for tracking view without directly overriding $post. if ( $esi_post ) { setup_postdata( $esi_post ); } if ( function_exists('wc_track_product_view') ) { wc_track_product_view(); } } /** * Adds the post id to the widget ESI parameters for the Recently Viewed widget. * * This is needed in the ESI request to update the cookie properly. * * @since 1.1.0 * @access public * * @param array $params Existing ESI params. * @param string $block_id Block identifier. * @return array */ public function add_post_id( $params, $block_id ) { if ( 'widget' === $block_id ) { if ( 'WC_Widget_Recently_Viewed' === $params[ API::PARAM_NAME ] ) { $params[ self::ESI_PARAM_POSTID ] = get_the_ID(); } } return $params; } /** * Hooked to the litespeed_widget_default_options filter. * * The recently viewed widget must be ESI to function properly. * This function will set it to enable and no cache by default. * * @since 1.1.0 * @access public * * @param array $options Widget options. * @param mixed $widget Widget instance. * @return array */ public function wc_widget_default( $options, $widget ) { if ( ! is_array( $options ) ) { return $options; } $widget_name = get_class( $widget ); if ( 'WC_Widget_Recently_Viewed' === $widget_name ) { $options[ API::WIDGET_O_ESIENABLE ] = API::VAL_ON2; $options[ API::WIDGET_O_TTL ] = 0; } elseif ( 'WC_Widget_Recent_Reviews' === $widget_name ) { $options[ API::WIDGET_O_ESIENABLE ] = API::VAL_ON; $options[ API::WIDGET_O_TTL ] = 86400; } return $options; } /** * Set WooCommerce cache tags based on page type. * * @since 1.0.9 * @since 1.6.3 Removed static * @access public * @return void */ public function set_tag() { $id = get_the_ID(); if ( false === $id ) { return; } // Check if product has a cache ttl limit or not. $sale_from = (int) get_post_meta( $id, '_sale_price_dates_from', true ); $sale_to = (int) get_post_meta( $id, '_sale_price_dates_to', true ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested -- Need local timestamp for WooCommerce sale dates. $now = current_time('timestamp'); $ttl = false; if ( $sale_from && $now < $sale_from ) { $ttl = $sale_from - $now; } elseif ( $sale_to && $now < $sale_to ) { $ttl = $sale_to - $now; } if ( $ttl && $ttl < apply_filters( 'litespeed_control_ttl', 0 ) ) { do_action( 'litespeed_control_set_ttl', $ttl, "WooCommerce set scheduled TTL to $ttl" ); } if ( function_exists('is_shop') && is_shop() ) { do_action('litespeed_tag_add', self::CACHETAG_SHOP); } if ( function_exists('is_product_taxonomy') && ! is_product_taxonomy() ) { return; } if ( isset( $GLOBALS['product_cat'] ) && is_string( $GLOBALS['product_cat'] ) ) { // todo: need to check previous woo version to find if its from old woo versions or not! $term = get_term_by( 'slug', $GLOBALS['product_cat'], 'product_cat' ); } elseif ( isset( $GLOBALS['product_tag'] ) && is_string( $GLOBALS['product_tag'] ) ) { $term = get_term_by( 'slug', $GLOBALS['product_tag'], 'product_tag' ); } else { $term = false; } if ( false === $term ) { return; } while ( isset( $term ) ) { do_action( 'litespeed_tag_add', self::CACHETAG_TERM . $term->term_id ); if ( 0 === (int) $term->parent ) { break; } $term = get_term( $term->parent ); } } /** * Check if the page is cacheable according to WooCommerce. * * @since 1.0.5 * @since 1.6.3 Removed static * @access public * * @param string $esi_id The ESI block id if a request is an ESI request. * @return void */ public function set_control( $esi_id ) { if ( ! apply_filters( 'litespeed_control_cacheable', false ) ) { return; } /** * Avoid possible 500 issue. * * @since 1.6.2.1 */ if ( ! function_exists( 'WC' ) ) { return; } $woocom = WC(); if ( ! $woocom || empty( $woocom->session ) ) { return; } // For later versions, DONOTCACHEPAGE should be set. // No need to check uri/qs. if ( version_compare( $woocom->version, '1.4.2', '>=' ) ) { if ( version_compare( $woocom->version, '3.2.0', '<' ) && defined('DONOTCACHEPAGE') && DONOTCACHEPAGE ) { do_action( 'litespeed_control_set_nocache', '3rd party woocommerce not cache by constant' ); return; } elseif ( version_compare( $woocom->version, '2.1.0', '>=' ) ) { $err = false; if ( ! function_exists( 'wc_get_page_id' ) ) { return; } /** * From woo/inc/class-wc-cache-helper.php:prevent_caching() * * @since 1.4 */ $page_ids = array_filter( [ wc_get_page_id( 'cart' ), wc_get_page_id( 'checkout' ), wc_get_page_id( 'myaccount' ) ] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['download_file'] ) || isset( $_GET['add-to-cart'] ) || is_page( $page_ids ) ) { $err = 'woo non cacheable pages'; } elseif ( function_exists( 'wc_notice_count' ) && wc_notice_count() > 0 ) { $err = 'has wc notice'; } if ( $err ) { do_action( 'litespeed_control_set_nocache', '3rd party woocommerce not cache due to ' . $err ); return; } } return; } if ( ! isset( $_SERVER['REQUEST_URI'] ) ) { return; } $uri = esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ); $uri_len = strlen( $uri ); if ( $uri_len < 5 ) { return; } if ( in_array( $uri, [ 'cart/', 'checkout/', 'my-account/', 'addons/', 'logout/', 'lost-password/', 'product/' ], true ) ) { // why contains `product`? do_action( 'litespeed_control_set_nocache', 'uri in cart/account/user pages' ); return; } if ( ! isset( $_SERVER['QUERY_STRING'] ) ) { return; } $qs = sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ); $qs_len = strlen( $qs ); if ( ! empty( $qs ) && $qs_len >= 12 && 0 === strpos( $qs, 'add-to-cart=' ) ) { do_action( 'litespeed_control_set_nocache', 'qs contains add-to-cart' ); } } /** * Purge a product page and related pages (based on settings) on checkout. * * @since 1.0.9 * @since 1.6.3 Removed static * @access public * * @param \WC_Product $product Product object. * @return void */ public function purge_product( $product ) { do_action( 'litespeed_debug', '[3rd] Woo Purge [pid] ' . $product->get_id() ); $do_purge = function ( $action, $debug = '' ) use ( $product ) { $config = apply_filters( 'litespeed_conf', self::O_UPDATE_INTERVAL ); if ( is_null( $config ) ) { $config = self::O_PQS_CS; } if ( self::O_PQS_CQS === $config ) { $action(); if ( $debug ) { do_action( 'litespeed_debug', $debug ); } } elseif ( self::O_PQS_CS !== $config && $product->is_in_stock() ) { do_action( 'litespeed_debug', '[3rd] Woo No purge needed [option] ' . $config ); return false; } elseif ( self::O_PS_CN !== $config && ! $product->is_in_stock() ) { $action(); if ( $debug ) { do_action( 'litespeed_debug', $debug ); } } return true; }; if ( ! $do_purge( function () use ( $product ) { $this->backend_purge( $product->get_id() ); } ) ) { return; } do_action( 'litespeed_purge_post', $product->get_id() ); // Check if is variation, purge stock too #984479. if ( $product->is_type( 'variation' ) ) { do_action( 'litespeed_purge_post', $product->get_parent_id() ); } // Check if WPML is enabled ##972971. if ( defined( 'WPML_PLUGIN_BASENAME' ) ) { // Check if it is a variable product and get post/parent ID. $wpml_purge_id = $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id(); $type = apply_filters( 'wpml_element_type', get_post_type( $wpml_purge_id ) ); $trid = apply_filters( 'wpml_element_trid', false, $wpml_purge_id, $type ); $translations = apply_filters( 'wpml_get_element_translations', [], $trid, $type ); foreach ( $translations as $lang => $translation ) { do_action( 'litespeed_debug', '[3rd] Woo WPML purge language: ' . $translation->language_code . ' , post ID: ' . $translation->element_id ); do_action( 'litespeed_purge_post', $translation->element_id ); // use the $translation->element_id as it is post ID of other languages. } // Check other languages category and purge if configured. // wp_get_post_terms() only returns default language category ID. $default_cats = wp_get_post_terms( $wpml_purge_id, 'product_cat' ); $languages = apply_filters( 'wpml_active_languages', null ); foreach ( $default_cats as $default_cat ) { foreach ( $languages as $language ) { $tr_cat_id = icl_object_id( $default_cat->term_id, 'product_cat', false, $language['code'] ); $do_purge( function () use ( $tr_cat_id ) { do_action( 'litespeed_purge', self::CACHETAG_TERM . $tr_cat_id ); }, '[3rd] Woo Purge WPML category [language] ' . $language['code'] . ' [cat] ' . $tr_cat_id ); } } } } /** * Delete object-term relationship. If the post is a product and the term ids array is not empty, * will add purge tags to the deleted terms. * * @since 1.0.9 * @since 1.6.3 Removed static * @access public * * @param int $post_id Object ID. * @param array $term_ids An array of term taxonomy IDs. * @return void */ public function delete_rel( $post_id, $term_ids ) { if ( ! function_exists( 'wc_get_product' ) ) { return; } if ( empty( $term_ids ) || false === wc_get_product( $post_id ) ) { return; } foreach ( $term_ids as $term_id ) { do_action( 'litespeed_purge', self::CACHETAG_TERM . $term_id ); } } /** * Purge a product's categories and tags pages in case they are affected. * * @since 1.0.9 * @since 1.6.3 Removed static * @access public * * @param int $post_id Post id that is about to be purged. * @return void */ public function backend_purge( $post_id ) { if ( ! function_exists( 'wc_get_product' ) ) { return; } if ( ! isset( $post_id ) || false === wc_get_product( $post_id ) ) { return; } $cats = $this->get_cats( $post_id ); if ( ! empty( $cats ) ) { foreach ( $cats as $cat ) { do_action( 'litespeed_purge', self::CACHETAG_TERM . $cat ); } } if ( ! function_exists( 'wc_get_product_terms' ) ) { return; } $tags = wc_get_product_terms( $post_id, 'product_tag', [ 'fields' => 'ids' ] ); if ( ! empty( $tags ) ) { foreach ( $tags as $tag ) { do_action( 'litespeed_purge', self::CACHETAG_TERM . $tag ); } } } /** * When a product has a new review added, purge the recent reviews widget. * * @since 1.1.0 * @since 1.6.3 Removed static * @access public * * @param mixed $unused Unused. * @param integer $comment_approved Whether the comment is approved or not. * @param array $commentdata Information about the comment. * @return void */ public function add_review( $unused, $comment_approved, $commentdata ) { if ( ! function_exists( 'wc_get_product' ) ) { return; } $post_id = $commentdata['comment_post_ID']; if ( 1 !== (int) $comment_approved || ! isset( $post_id ) || false === wc_get_product( $post_id ) ) { return; } global $wp_widget_factory; if ( ! isset( $wp_widget_factory->widgets['WC_Widget_Recent_Reviews'] ) ) { return; } $recent_reviews = $wp_widget_factory->widgets['WC_Widget_Recent_Reviews']; if ( ! is_null( $recent_reviews ) ) { do_action( 'litespeed_tag_add_widget', $recent_reviews->id ); } } /** * Append new options. * * @since 1.6.3 Removed static * @since 3.0 new API * @return void */ private function _option_append() { // Append option save value filter. do_action( 'litespeed_conf_multi_switch', self::O_UPDATE_INTERVAL, 3 ); // This need to be before conf_append. do_action( 'litespeed_conf_append', self::O_UPDATE_INTERVAL, false ); do_action( 'litespeed_conf_append', self::O_CART_VARY, false ); } /** * Hooked to `litespeed_settings_tab` action. * Adds the integration configuration options (currently, to determine purge rules). * * @since 1.6.3 Removed static * * @param string $setting_page Setting page slug. * @return void */ public function settings_add_tab( $setting_page ) { if ( 'cache' !== $setting_page ) { return; } require 'woocommerce.tab.tpl.php'; } /** * Hook to show config content. * * @since 3.0 * * @param string $setting_page Setting page slug. * @return void */ public function settings_add_content( $setting_page ) { if ( 'cache' !== $setting_page ) { return; } require 'woocommerce.content.tpl.php'; } /** * Helper function to select the function(s) to use to get the product category ids. * * @since 1.0.10 * @since 1.6.3 Removed static * @access private * * @param int $product_id The product id. * @return array An array of category ids. */ private function get_cats( $product_id ) { if ( ! function_exists( 'WC' ) ) { return []; } $woocom = WC(); if ( isset( $woocom ) && version_compare( $woocom->version, '2.5.0', '>=' ) && function_exists( 'wc_get_product_cat_ids' ) ) { return wc_get_product_cat_ids( $product_id ); } $product_cats = wp_get_post_terms( $product_id, 'product_cat', [ 'fields' => 'ids' ] ); foreach ( $product_cats as $product_cat ) { $product_cats = array_merge( $product_cats, get_ancestors( $product_cat, 'product_cat' ) ); } return $product_cats; } /** * 3rd party preload. * * @since 2.9.8.4 * @return void */ public static function preload() { /** * Auto purge for WooCommerce Advanced Bulk Edit plugin, * Bulk edit hook needs to be added to preload as it will die before detect. */ add_action( 'wp_ajax_wpmelon_adv_bulk_edit', __CLASS__ . '::bulk_edit_purge', 1 ); } /** * Auto purge for WooCommerce Advanced Bulk Edit plugin. * * @since 2.9.8.4 * @return void */ public static function bulk_edit_purge() { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Third-party plugin action; cannot enforce here. if ( empty( $_POST['type'] ) || 'saveproducts' !== $_POST['type'] || empty( $_POST['data'] ) ) { return; } /* * admin-ajax form-data structure * array( * "type" => "saveproducts", * "data" => array( * "column1" => "464$###0$###2#^#463$###0$###4#^#462$###0$###6#^#", * "column2" => "464$###0$###2#^#463$###0$###4#^#462$###0$###6#^#" * ) * ) */ $stock_string_arr = []; // Ensure data is unslashed before processing. // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Third-party plugin may not send nonce. Data format defined by third-party plugin. $data = isset( $_POST['data'] ) ? wp_unslash( $_POST['data'] ) : []; foreach ( (array) $data as $stock_value ) { $stock_string_arr = array_merge( $stock_string_arr, explode( '#^#', (string) $stock_value ) ); } $lscwp_3rd_woocommerce = new self(); if ( count( $stock_string_arr ) < 1 ) { return; } foreach ( $stock_string_arr as $edited_stock ) { $product_id = (int) strtok( (string) $edited_stock, '$' ); $product = wc_get_product( $product_id ); if ( empty( $product ) ) { do_action( 'litespeed_debug', '3rd woo purge: ' . $product_id . ' not found.' ); continue; } $lscwp_3rd_woocommerce->purge_product( $product ); } } } wp-polls.cls.php 0000777 00000001447 15252323732 0007633 0 ustar 00 <?php /** * The Third Party integration with the WP-Polls plugin. * * Ensures WP-Polls pages are marked as non-cacheable in LiteSpeed Cache. * * @since 1.0.7 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; /** * WP-Polls integration. */ class Wp_Polls { /** * Register WP-Polls display filters to mark output as non-cacheable. * * @since 1.0.7 * @return void */ public static function detect() { add_filter( 'wp_polls_display_pollvote', __CLASS__ . '::set_control' ); add_filter( 'wp_polls_display_pollresult', __CLASS__ . '::set_control' ); } /** * Mark WP-Polls output as non-cacheable. * * @since 1.0.7 * @return void */ public static function set_control() { do_action( 'litespeed_control_set_nocache', 'wp polls' ); } } beaver-builder.cls.php 0000777 00000002167 15252323732 0010746 0 ustar 00 <?php /** * The Third Party integration with the Beaver Builder plugin. * * @since 3.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; /** * Integration for Beaver Builder cache handling and purging. */ class Beaver_Builder { /** * Detects if Beaver_Builder is active. * * @since 3.0 * @access public * @return void */ public static function detect() { if ( ! defined( 'FL_BUILDER_VERSION' ) ) { return; } /** * Purge All hooks. * * @see beaver-builder/extensions/fi-builder-cache-helper/classes/class-fi-builder-cache-helper.php */ $actions = array( 'fl_builder_cache_cleared', 'fl_builder_after_save_layout', 'fl_builder_after_save_user_template', 'upgrader_process_complete', ); foreach ( $actions as $val ) { add_action( $val, __CLASS__ . '::purge' ); } } /** * Purges the cache when Beaver_Builder's cache is purged. * * @since 3.0 * @access public * @return void */ public static function purge() { do_action( 'litespeed_purge_all', '3rd Beaver_Builder' ); } } entry.inc.php 0000777 00000003012 15252323732 0007175 0 ustar 00 <?php /** * The registry for Third Party Plugins Integration files. * * This file is only used to include the integration files/classes. * This works as an entry point for the initial add_action for the * detect function. * * It is not required to add all integration files here, this just provides * a common place for plugin authors to append their file to. * * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ defined('WPINC') || exit(); $third_cls = array( 'Aelia_CurrencySwitcher', 'Autoptimize', 'Avada', 'BBPress', 'Beaver_Builder', 'Caldera_Forms', 'Divi_Theme_Builder', 'Facetwp', 'LiteSpeed_Check', 'Theme_My_Login', 'User_Switching', 'WCML', 'WooCommerce', 'WC_PDF_Product_Vouchers', 'Woo_Paypal', 'Wp_Polls', 'WP_PostRatings', 'Wpdiscuz', 'WPLister', 'WPML', 'WpTouch', 'Yith_Wishlist', ); foreach ($third_cls as $cls) { add_action('litespeed_load_thirdparty', 'LiteSpeed\Thirdparty\\' . $cls . '::detect'); } // Preload needed for certain thirdparty add_action('litespeed_init', 'LiteSpeed\Thirdparty\Divi_Theme_Builder::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\WooCommerce::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\NextGenGallery::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\AMP::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\Elementor::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\Gravity_Forms::preload'); add_action('litespeed_init', 'LiteSpeed\Thirdparty\Perfmatters::preload'); elementor.cls.php 0000777 00000006404 15252323732 0010046 0 ustar 00 <?php /** * The Third Party integration with the Elementor plugin. * * Detects Elementor editor/preview actions and safely disables LiteSpeed Cache features * that could interfere with live editing. Also hooks cache purge when Elementor regenerates * its CSS & data. * * @since 2.9.8.8 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Handles Elementor compatibility. */ class Elementor { /** * Preload hooks and disable caching features during Elementor edit/preview flows. * * This method only inspects query/server values to detect editor context. * No privileged actions are performed here, so nonce verification is not required. * * @since 2.9.8.8 * @return void */ public static function preload() { if ( ! defined( 'ELEMENTOR_VERSION' ) ) { return; } // If user explicitly opened the Elementor editor, disable all LSCWP features. $action = isset( $_GET['action'] ) ? sanitize_text_field( wp_unslash( $_GET['action'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( 'elementor' === $action ) { do_action( 'litespeed_disable_all', 'elementor edit mode' ); } // If the referrer indicates an Elementor editor context, inspect possible save actions. $http_referer = isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( '' !== $http_referer && false !== strpos( $http_referer, 'action=elementor' ) ) { // Elementor posts JSON in the 'actions' request field when saving from editor. // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $actions_raw = isset( $_REQUEST['actions'] ) ? wp_unslash( $_REQUEST['actions'] ) : ''; if ( '' !== $actions_raw ) { // Use a forgiving sanitizer for JSON strings, then decode. $json = json_decode( sanitize_textarea_field( $actions_raw ), true ); // Debug2::debug( '3rd Elementor', $json ); if ( ! empty( $json['save_builder']['action'] ) && 'save_builder' === $json['save_builder']['action'] && ! empty( $json['save_builder']['data']['status'] ) && 'publish' === $json['save_builder']['data']['status'] ) { // Publishing from editor — allow normal flow so crawler/purge can run. return; } } // In all other editor-referrer cases, disable LSCWP features during edit. do_action( 'litespeed_disable_all', 'elementor edit mode in HTTP_REFERER' ); } // Clear LSC cache when Elementor regenerates CSS & Data. add_action( 'elementor/core/files/clear_cache', __CLASS__ . '::regenerate_litespeed_cache' ); } /** * Disable LiteSpeed ESI explicitly (kept for backward compatibility if re-enabled). * * @since 2.9.8.8 * @return void */ public static function disable_litespeed_esi() { if ( ! defined( 'LITESPEED_ESI_OFF' ) ) { define( 'LITESPEED_ESI_OFF', true ); } } /** * Purge LiteSpeed Cache when Elementor regenerates its CSS & Data. * * @since 2.9.8.8 * @return void */ public static function regenerate_litespeed_cache() { do_action( 'litespeed_purge_all', 'Elementor - Regenerate CSS & Data' ); } } avada.cls.php 0000777 00000001455 15252323732 0007131 0 ustar 00 <?php /** * The Third Party integration with the Avada plugin. * * @since 1.1.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; /** * Integration for Avada cache flushing. */ class Avada { /** * Detects if Avada is installed. * * @since 1.1.0 * @access public * @return void */ public static function detect() { if ( ! defined( 'AVADA_VERSION' ) ) { return; } add_action( 'update_option_avada_dynamic_css_posts', __CLASS__ . '::flush' ); add_action( 'update_option_fusion_options', __CLASS__ . '::flush' ); } /** * Purges the cache. * * @since 1.1.0 * @access public * @return void */ public static function flush() { do_action( 'litespeed_purge_all', '3rd avada' ); } } nextgengallery.cls.php 0000777 00000015015 15252323732 0011102 0 ustar 00 <?php /** * The Third Party integration with the NextGen Gallery plugin. * * @since 1.0.5 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides LiteSpeed Cache compatibility for NextGen Gallery. */ class NextGenGallery { const CACHETAG_ALBUMS = 'NGG_A.'; const CACHETAG_GALLERIES = 'NGG_G.'; const CACHETAG_TAGS = 'NGG_T.'; /** * Hook NextGen Gallery events for purging cache. * * @since 1.0.5 * @return void */ public static function preload() { add_action('ngg_added_new_image', __CLASS__ . '::add_image'); add_action('ngg_ajax_image_save', __CLASS__ . '::update_image'); add_action('ngg_delete_picture', __CLASS__ . '::delete_image'); add_action('ngg_moved_images', __CLASS__ . '::move_image', 10, 3); add_action('ngg_copied_images', __CLASS__ . '::copy_image', 10, 3); add_action('ngg_generated_image', __CLASS__ . '::gen_image'); add_action('ngg_recovered_image', __CLASS__ . '::gen_image'); add_action('ngg_gallery_sort', __CLASS__ . '::update_gallery'); add_action('ngg_delete_gallery', __CLASS__ . '::update_gallery'); add_action('ngg_update_album', __CLASS__ . '::update_album'); add_action('ngg_delete_album', __CLASS__ . '::update_album'); add_filter('ngg_displayed_gallery_cache_params', __CLASS__ . '::add_container'); } /** * Purge cache when an image is added. * * @since 1.0.5 * @param object $image The image object added. * @return void */ public static function add_image( $image ) { if (!$image || !method_exists($image, 'get_gallery')) { return; } $gallery = $image->get_gallery(); if ($gallery && $gallery->pageid) { do_action('litespeed_purge', self::CACHETAG_GALLERIES . $gallery->pageid); } } /** * Purge cache when an image is updated. * * @since 1.0.5 * @return void */ public static function update_image() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_REQUEST['gallery_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended do_action( 'litespeed_purge', self::CACHETAG_GALLERIES . sanitize_key( wp_unslash( $_REQUEST['gallery_id'] ) ) ); return; } // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( isset( $_POST['task_list'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing $task_list = str_replace( '\\', '', wp_unslash( $_POST['task_list'] ) ); $task_list = json_decode( $task_list, true ); if ( ! empty( $task_list[0]['query']['id'] ) ) { do_action( 'litespeed_purge', self::CACHETAG_GALLERIES . sanitize_key( $task_list[0]['query']['id'] ) ); return; } } // phpcs:ignore WordPress.Security.NonceVerification.Missing if ( isset( $_POST['id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $id = (int) $_POST['id']; // phpcs:ignore WordPress.Security.NonceVerification.Missing } elseif ( isset( $_POST['image'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $id = (int) $_POST['image']; // phpcs:ignore WordPress.Security.NonceVerification.Recommended } elseif ( isset( $_GET['pid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $id = (int) $_GET['pid']; } else { error_log( 'LiteSpeed_Cache hit ngg_ajax_image_save with no post image id.' ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log return; } $image = \C_Image_Mapper::get_instance()->find($id); if ($image) { do_action('litespeed_purge', self::CACHETAG_GALLERIES . $image->galleryid); } } /** * Purge cache when an image is deleted. * * @since 1.0.5 * @return void */ public static function delete_image() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['gid'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended do_action( 'litespeed_purge', self::CACHETAG_GALLERIES . sanitize_key( wp_unslash( $_GET['gid'] ) ) ); } } /** * Purge cache when an image is moved. * * @since 1.0.8 * @param array $images Unused. * @param array $old_gallery_ids Source gallery IDs. * @param int $new_gallery_id Destination gallery ID. * @return void */ public static function move_image( $images, $old_gallery_ids, $new_gallery_id ) { foreach ($old_gallery_ids as $gid) { do_action('litespeed_purge', self::CACHETAG_GALLERIES . $gid); } do_action('litespeed_purge', self::CACHETAG_GALLERIES . $new_gallery_id); } /** * Purge cache when an image is copied. * * @since 1.0.8 * @param array $image_pid_map Unused. * @param array $old_gallery_ids Unused. * @param int $new_gallery_id Destination gallery ID. * @return void */ public static function copy_image( $image_pid_map, $old_gallery_ids, $new_gallery_id ) { do_action('litespeed_purge', self::CACHETAG_GALLERIES . $new_gallery_id); } /** * Purge cache when an image is regenerated or recovered. * * @since 1.0.8 * @param object $image The regenerated image object. * @return void */ public static function gen_image( $image ) { do_action('litespeed_purge', self::CACHETAG_GALLERIES . $image->galleryid); } /** * Purge cache when a gallery is updated. * * @since 1.0.5 * @param int|object $gid Gallery ID or object with gid. * @return void */ public static function update_gallery( $gid ) { if (is_object($gid) && !empty($gid->gid)) { $gid = $gid->gid; } do_action('litespeed_purge', self::CACHETAG_GALLERIES . $gid); } /** * Purge cache when an album is updated. * * @since 1.0.5 * @param int $aid Album ID. * @return void */ public static function update_album( $aid ) { do_action('litespeed_purge', self::CACHETAG_ALBUMS . $aid); } /** * Tag gallery/album/tag content during rendering. * * @since 1.0.5 * @param object $render_parms Render parameters. * @return mixed Null if $render_parms is null, otherwise same input. */ public static function add_container( $render_parms ) { if (is_null($render_parms)) { return null; } $src = $render_parms[0]->source; $container_ids = $render_parms[0]->container_ids; switch ($src) { case 'albums': $tag = self::CACHETAG_ALBUMS; break; case 'galleries': $tag = self::CACHETAG_GALLERIES; break; case 'tags': $tag = self::CACHETAG_TAGS; break; default: return $render_parms; } foreach ($container_ids as $id) { do_action('litespeed_tag_add', $tag . $id); } return $render_parms; } } wptouch.cls.php 0000777 00000001557 15252323732 0007551 0 ustar 00 <?php /** * The Third Party integration with the WPTouch Mobile plugin. * * Marks requests from mobile devices via WPTouch as mobile in LiteSpeed Cache. * * @since 1.0.7 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); /** * WPTouch integration for LiteSpeed Cache. */ class WpTouch { /** * Detects if WPTouch is installed. * * @since 1.0.7 * @return void */ public static function detect() { global $wptouch_pro; if ( isset( $wptouch_pro ) ) { add_action( 'litespeed_control_finalize', __CLASS__ . '::set_control' ); } } /** * Check if the device is mobile. If so, set mobile. * * @since 1.0.7 * @return void */ public static function set_control() { global $wptouch_pro; if ( ! empty( $wptouch_pro->is_mobile_device ) ) { add_filter( 'litespeed_is_mobile', '__return_true' ); } } } wplister.cls.php 0000777 00000001546 15252323732 0007727 0 ustar 00 <?php /** * The Third Party integration with the WPLister plugin. * * Hooks WPLister inventory status updates to LiteSpeed WooCommerce backend purging. * * @since 1.1.0 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); /** * WPLister integration for LiteSpeed Cache. */ class WPLister { /** * Detects if WooCommerce and WPLister are installed and registers hooks. * * @since 1.1.0 * @return void */ public static function detect() { if ( defined( 'WOOCOMMERCE_VERSION' ) && defined( 'WPLISTER_VERSION' ) ) { // User reported this will sync correctly. add_action( 'wplister_revise_inventory_status', [ WooCommerce::cls(), 'backend_purge' ] ); // Added as a safety measure for WPLister Pro only. add_action( 'wplister_inventory_status_changed', [ WooCommerce::cls(), 'backend_purge' ] ); } } } wcml.cls.php 0000777 00000003367 15252323732 0007023 0 ustar 00 <?php /** * The Third Party integration with WCML. * * @since 3.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility with WCML for currency handling. */ class WCML { /** * Holds the current WCML currency. * * @var string */ private static $_currency = ''; /** * Detect if WCML is active and register hooks. * * @since 3.0 * @access public * @return void */ public static function detect() { if (!defined('WCML_VERSION')) { return; } add_filter('wcml_client_currency', __CLASS__ . '::apply_client_currency'); add_action('wcml_set_client_currency', __CLASS__ . '::set_client_currency'); } /** * Sets the client currency and triggers vary updates. * * @since 3.0 * @access public * @param string $currency The currency code to set. * @return void */ public static function set_client_currency( $currency ) { self::apply_client_currency($currency); do_action('litespeed_vary_ajax_force'); } /** * Applies the client currency and adjusts vary accordingly. * * @since 3.0 * @access public * @param string $currency The currency code to apply. * @return string The applied currency. */ public static function apply_client_currency( $currency ) { self::$_currency = $currency; add_filter('litespeed_vary', __CLASS__ . '::apply_vary'); return $currency; } /** * Appends WCML currency to vary list. * * @since 3.0 * @access public * @param array $vary_list The existing vary list. * @return array The updated vary list including WCML currency. */ public static function apply_vary( $vary_list ) { $vary_list['wcml_currency'] = self::$_currency; return $vary_list; } } autoptimize.cls.php 0000777 00000001616 15252323732 0010426 0 ustar 00 <?php /** * The Third Party integration with the Autoptimize plugin. * * @since 1.0.12 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; /** * Integration for Autoptimize cache events. */ class Autoptimize { /** * Detects if Autoptimize is active. * * @since 1.0.12 * @access public * @return void */ public static function detect() { if ( defined( 'AUTOPTIMIZE_PLUGIN_DIR' ) ) { add_action( 'litespeed_purge_finalize', __CLASS__ . '::purge' ); } } /** * Purges LiteSpeed cache when Autoptimize's cache is purged. * * @since 1.0.12 * @access public * @return void */ public static function purge() { if ( defined( 'AUTOPTIMIZE_PURGE' ) || has_action( 'shutdown', 'autoptimize_do_cachepurged_action', 11 ) ) { do_action( 'litespeed_purge_all', '3rd Autoptimize' ); } } } divi-theme-builder.cls.php 0000777 00000007105 15252323732 0011532 0 ustar 00 <?php /** * The Third Party integration with DIVI Theme. * * Ensures Divi Builder edit/preview modes don't conflict with LiteSpeed Cache features, * and registers required nonces for Divi modules. * * @since 2.9.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Handles Divi Theme Builder compatibility. */ class Divi_Theme_Builder { // private static $js_comment_box = false; /** * If Divi front-end edit/preview mode is active, disable LSCWP features to avoid conflicts. * * Note: This reads query vars only to detect Divi edit states. Nonce verification * is not applicable here because no privileged action is performed. * * @since 2.9.7.2 #435538 #581740 #977284 * @since 2.9.9.1 Added 'et_pb_preview' for loading image from library in Divi page edit * @return void */ public static function preload() { if (!function_exists('et_setup_theme')) { return; } // Sanitize incoming query params before use. $et_fb = isset($_GET['et_fb']) ? sanitize_text_field(wp_unslash($_GET['et_fb'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $et_pb_preview = isset($_GET['et_pb_preview']) ? sanitize_text_field(wp_unslash($_GET['et_pb_preview'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $p = isset($_GET['p']) ? absint(wp_unslash($_GET['p'])) : 0; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $preview = isset($_GET['preview']) ? sanitize_text_field(wp_unslash($_GET['preview'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( '' !== $et_fb || '' !== $et_pb_preview || ( $p && 'true' === $preview ) ) { do_action( 'litespeed_disable_all', 'divi edit mode' ); } } /** * Detect Divi and register required integrations. * * - Allows the crawler to ignore Divi's first-visit "no-cache" for CCSS generation. * - Adds nonces used by Divi modules so cached pages still validate requests. * * @since 2.9.0 * @return void */ public static function detect() { if (!defined('ET_CORE')) { return; } // As DIVI may set first visit to non-cacheable to generate CCSS, // instruct the crawler to ignore that flag. if (!defined('LITESPEED_CRAWLER_IGNORE_NONCACHEABLE')) { define('LITESPEED_CRAWLER_IGNORE_NONCACHEABLE', true); } /** * Add contact form to nonce. * * @since 2.9.7.1 #475461 */ do_action('litespeed_nonce', 'et-pb-contact-form-submit'); /** * Subscribe module and A/B logging. * * @since 3.0 */ do_action('litespeed_nonce', 'et_frontend_nonce'); do_action('litespeed_nonce', 'et_ab_log_nonce'); /* // the comment box fix is for user using theme builder, ESI will load the wrong json string // As we disabled all for edit mode, this is no more needed add_action( 'et_fb_before_comments_template', 'Divi_Theme_Builder::js_comment_box_on' ); add_action( 'et_fb_after_comments_template', 'Divi_Theme_Builder::js_comment_box_off' ); add_filter( 'litespeed_esi_params-comment-form', 'Divi_Theme_Builder::esi_comment_add_slash' );// Note: this is changed in v2.9.8.1 */ } /* * Enable comment box JS mode (legacy code - currently disabled). * public static function js_comment_box_on() { self::$js_comment_box = true; } public static function js_comment_box_off() { self::$js_comment_box = false; } public static function esi_comment_add_slash( $params ) { if ( self::$js_comment_box ) { $params['is_json'] = 1; $params['_ls_silence'] = 1; } return $params; } */ } woocommerce.tab.tpl.php 0000777 00000000346 15252323732 0011155 0 ustar 00 <?php /** * WooCommerce tab template for LiteSpeed Cache plugin. * * @package LiteSpeed */ defined( 'WPINC' ) || exit; ?> <a class='litespeed-tab nav-tab' href='#woocommerce' data-litespeed-tab='woocommerce'>WooCommerce</a> gravity-forms.cls.php 0000777 00000002223 15252323732 0010660 0 ustar 00 <?php /** * The Third Party integration with Gravity Forms. * * @since 4.1.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Gravity Forms compatibility hooks for LiteSpeed Cache. */ class Gravity_Forms { /** * Check if GF is enabled and disable LSCWP on gf-download and gf-signature URI. * * Note: Query params are only read to detect special Gravity Forms endpoints. * Nonce verification is not applicable here as no privileged action is performed. * * @since 4.1.0 #900899 #827184 * @return void */ public static function preload() { if (class_exists('GFCommon')) { $gf_download = isset($_GET['gf-download']) ? sanitize_text_field(wp_unslash($_GET['gf-download'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $gf_signature = isset($_GET['gf-signature']) ? sanitize_text_field(wp_unslash($_GET['gf-signature'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ('' !== $gf_download || '' !== $gf_signature) { do_action('litespeed_disable_all', 'Stopped for Gravity Form'); } } } } bbpress.cls.php 0000777 00000005115 15252323732 0007512 0 ustar 00 <?php /** * The Third Party integration with the bbPress plugin. * * @since 1.0.5 * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit; use LiteSpeed\Router; /** * Integration for bbPress cache handling and purging. */ class BBPress { /** * Detect if bbPress is installed and if the page is a bbPress page. * * @since 1.0.5 * @access public * @return void */ public static function detect() { if ( function_exists( 'is_bbpress' ) ) { add_action( 'litespeed_api_purge_post', __CLASS__ . '::on_purge' ); // todo if ( apply_filters( 'litespeed_esi_status', false ) ) { // Don't consider private cache yet (will do if any feedback) add_action( 'litespeed_control_finalize', __CLASS__ . '::set_control' ); } } } /** * This filter is used to let the cache know if a page is cacheable. * * @since 1.2.0 * @access public * @return void */ public static function set_control() { if ( ! apply_filters( 'litespeed_control_cacheable', false ) ) { return; } // Set non ESI public if ( is_bbpress() && Router::is_logged_in() ) { do_action( 'litespeed_control_set_nocache', 'bbpress nocache due to loggedin' ); } } /** * When a bbPress page is purged, need to purge the forums list and * any/all ancestor pages. * * @since 1.0.5 * @access public * @param int $post_id The post id of the page being purged. * @return void */ public static function on_purge( $post_id ) { if ( ! is_bbpress() ) { if ( ! function_exists( 'bbp_is_forum' ) || ! function_exists( 'bbp_is_topic' ) || ! function_exists( 'bbp_is_reply' ) ) { return; } if ( ! bbp_is_forum( $post_id ) && ! bbp_is_topic( $post_id ) && ! bbp_is_reply( $post_id ) ) { return; } } // Need to purge base forums page, bbPress page was updated. do_action( 'litespeed_purge_posttype', bbp_get_forum_post_type() ); $ancestors = get_post_ancestors( $post_id ); // If there are ancestors, need to purge them as well. if ( ! empty( $ancestors ) ) { foreach ( $ancestors as $ancestor ) { do_action( 'litespeed_purge_post', $ancestor ); } } global $wp_widget_factory; $replies_widget = $wp_widget_factory->get_widget_object( 'BBP_Replies_Widget' ); if ( bbp_is_reply( $post_id ) && $replies_widget ) { do_action( 'litespeed_purge_widget', $replies_widget->id ); } $topic_widget = $wp_widget_factory->get_widget_object( 'BBP_Topics_Widget' ); if ( bbp_is_topic( $post_id ) && $topic_widget ) { do_action( 'litespeed_purge_widget', $topic_widget->id ); } } } user-switching.cls.php 0000777 00000001431 15252323732 0011022 0 ustar 00 <?php /** * The Third Party integration with User Switching. * * @since 3.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility for the User Switching plugin. */ class User_Switching { /** * Detects if User Switching is active and registers required nonces. * * @since 3.0 * @access public * @return void */ public static function detect() { if (!class_exists('user_switching')) { return; } /** * Register switch back URL nonce. * * @since 3.0 */ if (function_exists('current_user_switched')) { $old_user = current_user_switched(); if ($old_user) { do_action('litespeed_nonce', 'switch_to_olduser_' . $old_user->ID); } } } } litespeed-check.cls.php 0000777 00000012645 15252323732 0011111 0 ustar 00 <?php /** * Check if any plugins that could conflict with LiteSpeed Cache are active. * * @since 4.7 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Detects incompatible plugins and displays admin notices if needed. */ class LiteSpeed_Check { /** * Incompatible plugins list. * * @var array */ public static $_incompatible_plugins = array( // 'autoptimize/autoptimize.php', 'breeze/breeze.php', 'cache-enabler/cache-enabler.php', 'cachify/cachify.php', 'cloudflare/cloudflare.php', 'comet-cache/comet-cache.php', 'docket-cache/docket-cache.php', 'fast-velocity-minify/fvm.php', 'hummingbird-performance/wp-hummingbird.php', 'nginx-cache/nginx-cache.php', 'nitropack/main.php', 'pantheon-advanced-page-cache/pantheon-advanced-page-cache.php', 'powered-cache/powered-cache.php', 'psn-pagespeed-ninja/pagespeedninja.php', 'sg-cachepress/sg-cachepress.php', 'simple-cache/simple-cache.php', // 'redis-cache/redis-cache.php', 'w3-total-cache/w3-total-cache.php', 'wp-cloudflare-page-cache/wp-cloudflare-page-cache.php', 'wp-fastest-cache/wpFastestCache.php', 'wp-meteor/wp-meteor.php', 'wp-optimize/wp-optimize.php', 'wp-performance-score-booster/wp-performance-score-booster.php', 'wp-rocket/wp-rocket.php', 'wp-super-cache/wp-cache.php', ); /** * Option key for storing notice state. * * @var string */ private static $_option = 'thirdparty_litespeed_check'; /** * Admin notice HTML ID. * * @var string */ private static $_msg_id = 'id="lscwp-incompatible-plugin-notice"'; /** * Detect incompatible plugins and hook into plugin lifecycle. * * @since 4.7 * @return void */ public static function detect() { if (!is_admin()) { return; } /** * Check for incompatible plugins when `litespeed-cache` is first activated. */ $plugin = basename(LSCWP_DIR) . '/litespeed-cache.php'; register_deactivation_hook($plugin, function ( $network_wide ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found \LiteSpeed\Admin_Display::delete_option(self::$_option); }); if (!\LiteSpeed\Admin_Display::get_option(self::$_option)) { self::activated_plugin($plugin, null); \LiteSpeed\Admin_Display::add_option(self::$_option, true); } /** * Check for incompatible plugins when any plugin is (de)activated. */ add_action('activated_plugin', __CLASS__ . '::activated_plugin', 10, 2); add_action('deactivated_plugin', __CLASS__ . '::deactivated_plugin', 10, 2); if (class_exists('PagespeedNinja')) { \LiteSpeed\Admin_Display::error( '<div ' . self::$_msg_id . '>' . __('Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:', 'litespeed-cache') . '<p style="color: red; font-weight: 700;">' . 'PageSpeed Ninja' . '</p>' . '</div>' ); } } /** * Handle plugin activation. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $network_wide Whether activated network-wide. * @return void */ public static function activated_plugin( $plugin, $network_wide ) { self::incompatible_plugin_notice($plugin, $network_wide, 'activated'); } /** * Handle plugin deactivation. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $network_wide Whether deactivated network-wide. * @return void */ public static function deactivated_plugin( $plugin, $network_wide ) { self::incompatible_plugin_notice($plugin, $network_wide, 'deactivated'); } /** * Detect any incompatible plugins that are currently `active` and `valid`. * Show a notification if there are any. * * @since 4.7 * @param string $plugin Plugin path. * @param bool $_network_wide Whether action is network-wide. * @param string $action Action type (activated|deactivated). * @return void */ public static function incompatible_plugin_notice( $plugin, $_network_wide, $action ) { self::update_messages(); $deactivated = 'deactivated' === $action ? array( $plugin ) : array(); $incompatible_plugins = array_map(function ( $plugin ) { return WP_PLUGIN_DIR . '/' . $plugin; }, array_diff(self::$_incompatible_plugins, $deactivated)); $active_incompatible_plugins = array_map(function ( $plugin ) { $plugin = get_plugin_data($plugin, false, true); return $plugin['Name']; }, array_intersect($incompatible_plugins, wp_get_active_and_valid_plugins())); if (empty($active_incompatible_plugins)) { return; } \LiteSpeed\Admin_Display::error( '<div ' . self::$_msg_id . '>' . __('Please consider disabling the following detected plugins, as they may conflict with LiteSpeed Cache:', 'litespeed-cache') . '<p style="color: red; font-weight: 700;">' . implode(', ', $active_incompatible_plugins) . '</p>' . '</div>', false, true ); } /** * Prevent multiple incompatible plugin notices. * * @since 4.7 * @return void */ private static function update_messages() { $messages = \LiteSpeed\Admin_Display::get_option(\LiteSpeed\Admin_Display::DB_MSG_PIN, array()); if (is_array($messages)) { foreach ($messages as $index => $message) { if (strpos($message, self::$_msg_id) !== false) { unset($messages[$index]); if (!$messages) { $messages = -1; } \LiteSpeed\Admin_Display::update_option(\LiteSpeed\Admin_Display::DB_MSG_PIN, $messages); break; } } } } } aelia-currencyswitcher.cls.php 0000777 00000005255 15252323732 0012533 0 ustar 00 <?php /** * The Third Party integration with the Aelia CurrencySwitcher plugin. * * @since 1.0.13 * @since 2.6 Removed hook_vary as OLS supports vary header already * @package LiteSpeed * @subpackage LiteSpeed_Cache/thirdparty */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); /** * Integration layer for Aelia Currency Switcher. * * Registers the plugin cookies as Vary drivers so cached pages can differ by * selected currency / location. Hooks both the runtime vary list (headers) * and the rewrite-rules vary list (always needed). */ class Aelia_CurrencySwitcher { /** * Cookie names used by Aelia Currency Switcher to determine currency & geo. * * @var string[] */ private static $_cookies = array( 'aelia_cs_selected_currency', 'aelia_customer_country', 'aelia_customer_state', 'aelia_tax_exempt' ); /** * Detects if WooCommerce + Aelia Currency Switcher are present and registers hooks. * * @since 1.0.13 * @access public * @return void */ public static function detect() { if ( defined( 'WOOCOMMERCE_VERSION' ) && isset( $GLOBALS['woocommerce-aelia-currencyswitcher'] ) && is_object( $GLOBALS['woocommerce-aelia-currencyswitcher'] ) ) { // Not all pages need to add vary, so allow sites to restrict via filter. self::$_cookies = apply_filters( 'litespeed_3rd_aelia_cookies', self::$_cookies ); // Add cookies to the active vary header list (conditionally used at runtime). add_filter( 'litespeed_vary_curr_cookies', __CLASS__ . '::check_cookies' ); // Ensure rewrite rules are aware of these cookies (always include). add_filter( 'litespeed_vary_cookies', __CLASS__ . '::register_cookies' ); } } /** * Ensure Aelia cookies are part of the global vary cookie registry. * * @since 1.0.13 * * @param string[] $cookies Current list of vary cookies. * @return string[] Updated list including Aelia cookies. */ public static function register_cookies( $cookies ) { return array_merge( $cookies, self::$_cookies ); } /** * Conditionally append Aelia cookies to the vary header set for WooCommerce pages. * * If the page is not a WooCommerce page, leave the list unchanged. * Otherwise, append Aelia's cookies so responses vary correctly. * * @since 1.0.13 * @access public * * @param string[] $cookies Current list of vary cookies for the response. * @return string[] Potentially augmented list of vary cookies. */ public static function check_cookies( $cookies ) { // NOTE: is_cart and is_checkout are handled by WooCommerce itself. if ( ! function_exists( 'is_woocommerce' ) || ! is_woocommerce() ) { return $cookies; } return array_merge( $cookies, self::$_cookies ); } } wp-postratings.cls.php 0000777 00000001604 15252323732 0011052 0 ustar 00 <?php /** * The Third Party integration with the WP-PostRatings plugin. * * Hooks into rating events to purge related caches. * * @since 1.1.1 * @package LiteSpeed */ namespace LiteSpeed\Thirdparty; defined( 'WPINC' ) || exit(); /** * WP-PostRatings integration for LiteSpeed Cache. */ class WP_PostRatings { /** * Detects if the WP-PostRatings plugin is active and registers hooks. * * @since 1.1.1 * @return void */ public static function detect() { if ( defined( 'WP_POSTRATINGS_VERSION' ) ) { add_action( 'rate_post', __CLASS__ . '::flush', 10, 3 ); } } /** * Purge the cache for a rated post. * * @since 1.1.1 * * @param int $uid User ID who rated. * @param int $post_id The rated post ID. * @return void */ public static function flush( $uid, $post_id ) { do_action( 'litespeed_purge_post', (int) $post_id ); } } woo-paypal.cls.php 0000777 00000001545 15252323732 0010145 0 ustar 00 <?php /** * The Third Party integration with WooCommerce PayPal Checkout Gateway. * * @ref https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/ * * @since 3.0 * @package LiteSpeed * @subpackage LiteSpeed_Cache\Thirdparty */ namespace LiteSpeed\Thirdparty; defined('WPINC') || exit(); /** * Provides compatibility with WooCommerce PayPal Checkout. */ class Woo_Paypal { /** * Detect if WooCommerce PayPal Checkout is active and register nonces. * * @since 3.0 * @access public * @return void */ public static function detect() { if (!defined('WC_GATEWAY_PPEC_VERSION')) { return; } do_action('litespeed_nonce', '_wc_ppec_update_shipping_costs_nonce private'); do_action('litespeed_nonce', '_wc_ppec_start_checkout_nonce private'); do_action('litespeed_nonce', '_wc_ppec_generate_cart_nonce private'); } }
| ver. 1.6 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка