HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/thirdparty.tar
aelia-currencyswitcher.cls.php000064400000003444151540133450012517 0ustar00<?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_Cache
 * @subpackage	LiteSpeed_Cache/thirdparty
 * @author		LiteSpeed Technologies <info@litespeedtech.com>
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\API;

class Aelia_CurrencySwitcher
{
	private static $_cookies = array('aelia_cs_selected_currency', 'aelia_customer_country', 'aelia_customer_state', 'aelia_tax_exempt');

	/**
	 * Detects if WooCommerce is installed.
	 *
	 * @since 1.0.13
	 * @access public
	 */
	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 need to use this API to set conditions
			self::$_cookies = apply_filters('litespeed_3rd_aelia_cookies', self::$_cookies);
			add_filter('litespeed_vary_curr_cookies', __CLASS__ . '::check_cookies'); // this is for vary response headers, only add when needed
			add_filter('litespeed_vary_cookies', __CLASS__ . '::register_cookies'); // this is for rewrite rules, so always add
		}
	}

	public static function register_cookies($list)
	{
		return array_merge($list, self::$_cookies);
	}

	/**
	 * If the page is not a woocommerce page, ignore the logic.
	 * Else check cookies. If cookies are set, set the vary headers, else do not cache the page.
	 *
	 * @since 1.0.13
	 * @access public
	 */
	public static function check_cookies($list)
	{
		// NOTE: is_cart and is_checkout should also be checked, but will be checked by woocommerce anyway.
		if (!is_woocommerce()) {
			return $list;
		}

		return array_merge($list, self::$_cookies);
	}
}
amp.cls.php000064400000003600151540133450006612 0ustar00<?php
/**
 * The Third Party integration with AMP plugin.
 *
 * @since		2.9.8.6
 * @package		LiteSpeed_Cache
 * @subpackage	LiteSpeed_Cache/thirdparty
 * @author		LiteSpeed Technologies <info@litespeedtech.com>
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\API;

class AMP
{
	/**
	 * @since 4.2
	 */
	private static function _maybe_amp($amp_function)
	{
		if (is_admin()) {
			return;
		}
		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
	 */
	public static function maybe_acc_mob_pages()
	{
		self::_maybe_amp('ampforwp_is_amp_endpoint');
	}

	/**
	 * Google AMP fix
	 *
	 * @since 4.2.0.1
	 */
	public static function maybe_google_amp()
	{
		self::_maybe_amp('amp_is_request');
	}

	/**
	 * CSS async will affect AMP result and
	 * Lazyload will inject JS library which AMP not allowed
	 * need to force set false before load
	 *
	 * @since 2.9.8.6
	 * @access public
	 */
	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 );
	}
}
autoptimize.cls.php000064400000001332151540133450010407 0ustar00<?php
/**
 * The Third Party integration with the Autoptimize plugin.
 *
 * @since		1.0.12
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Autoptimize
{
	/**
	 * Detects if Autoptimize is active.
	 *
	 *@since 1.0.12
	 *@access public
	 */
	public static function detect()
	{
		if (defined('AUTOPTIMIZE_PLUGIN_DIR')) {
			add_action('litespeed_purge_finalize', __CLASS__ . '::purge');
		}
	}

	/**
	 * Purges the cache when Autoptimize's cache is purged.
	 *
	 * @since 1.0.12
	 * @access public
	 */
	public static function purge()
	{
		if (defined('AUTOPTIMIZE_PURGE') || has_action('shutdown', 'autoptimize_do_cachepurged_action', 11)) {
			do_action('litespeed_purge_all', '3rd Autoptimize');
		}
	}
}
avada.cls.php000064400000001207151540133450007112 0ustar00<?php
/**
 * The Third Party integration with the Avada plugin.
 *
 * @since		1.1.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Avada
{
	/**
	 * Detects if Avada is installed.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	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
	 */
	public static function flush()
	{
		do_action('litespeed_purge_all', '3rd avada');
	}
}
bbpress.cls.php000064400000004513151540133450007501 0ustar00<?php
/**
 * The Third Party integration with the bbPress plugin.
 *
 * @since		1.0.5
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\Router;

class BBPress
{
	/**
	 * Detect if bbPress is installed and if the page is a bbPress page.
	 *
	 * @since 1.0.5
	 * @access public
	 */
	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.
	 *
	 * @access public
	 * @since 1.2.0
	 */
	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 integer $post_id The post id of the page being purged.
	 */
	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);
		}
	}
}
beaver-builder.cls.php000064400000001645151540133450010734 0ustar00<?php
/**
 * The Third Party integration with the Beaver Builder plugin.
 *
 * @since		3.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Beaver_Builder
{
	/**
	 * Detects if Beaver_Builder is active.
	 *
	 *@since 3.0
	 *@access public
	 */
	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
	 */
	public static function purge()
	{
		do_action('litespeed_purge_all', '3rd Beaver_Builder');
	}
}
caldera-forms.cls.php000064400000000623151540133450010556 0ustar00<?php
/**
 * The Third Party integration with Caldera Forms.
 *
 * @since		3.2.2
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Caldera_Forms
{
	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_*');
	}
}
divi-theme-builder.cls.php000064400000004315151540133450011520 0ustar00<?php
/**
 * The Third Party integration with DIVI Theme.
 *
 * @since		2.9.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Divi_Theme_Builder
{
	// private static $js_comment_box = false;

	/**
	 * Check if is Edit mode in frontend, disable all LSCWP features to avoid breaking page builder
	 *
	 * @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
	 */
	public static function preload()
	{
		if (!function_exists('et_setup_theme')) {
			return;
		}
		if (!empty($_GET['et_fb']) || !empty($_GET['et_pb_preview']) || (!empty($_GET['p']) && !empty($_GET['preview']) && $_GET['preview'] === 'true')) {
			do_action('litespeed_disable_all', 'divi edit mode');
		}
	}

	public static function detect()
	{
		if (!defined('ET_CORE')) {
			return;
		}

		// As DIVI will set page to non-cacheable for the 1st visit to generate CCSS, will need to ignore that no-cache for crawler
		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 @Robert Staddon
		 */
		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
		*/
	}

	/*
	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;
	}
	*/
}
elementor.cls.php000064400000002530151540133450010030 0ustar00<?php
/**
 * The Third Party integration with the bbPress plugin.
 *
 * @since		2.9.8.8
 */
namespace LiteSpeed\Thirdparty;
defined('WPINC') || exit();

use LiteSpeed\Debug2;

class Elementor
{
	public static function preload()
	{
		if (!defined('ELEMENTOR_VERSION')) {
			return;
		}

		if (!is_admin()) {
			//		    add_action( 'init', __CLASS__ . '::disable_litespeed_esi', 4 );	// temporarily comment out this line for backward compatibility
		}

		if (isset($_GET['action']) && $_GET['action'] === 'elementor') {
			do_action('litespeed_disable_all', 'elementor edit mode');
		}

		if (!empty($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'action=elementor')) {
			if (!empty($_REQUEST['actions'])) {
				$json = json_decode(stripslashes($_REQUEST['actions']), true);
				// Debug2::debug( '3rd Elementor', $json );
				if (
					!empty($json['save_builder']['action']) &&
					$json['save_builder']['action'] == 'save_builder' &&
					!empty($json['save_builder']['data']['status']) &&
					$json['save_builder']['data']['status'] == 'publish'
				) {
					return; // Save post, don't disable all in case we will allow fire crawler right away after purged
				}
			}
			do_action('litespeed_disable_all', 'elementor edit mode in HTTP_REFERER');
		}
	}

	public static function disable_litespeed_esi()
	{
		define('LITESPEED_ESI_OFF', true);
	}
}
entry.inc.php000064400000002732151540133450007173 0ustar00<?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.
 *
 */
defined('WPINC') || exit();

use LiteSpeed\API;

$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');
facetwp.cls.php000064400000001255151540133450007472 0ustar00<?php
/**
 * The Third Party integration with FacetWP.
 *
 * @since		2.9.9
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Facetwp
{
	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
		 */
		if (!empty($_POST['action']) && !empty($_POST['data']) && !empty($_POST['data']['template']) && $_POST['data']['template'] === 'wp') {
			add_filter('litespeed_esi_params', __CLASS__ . '::set_is_json');
		}
	}

	public static function set_is_json($params)
	{
		$params['is_json'] = 1;
		return $params;
	}
}
gravity-forms.cls.php000064400000001015151540133450010644 0ustar00<?php
/**
 * The Third Party integration with Gravity Forms.
 *
 * @since       4.1.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Gravity_Forms
{
	/**
	 * Check if GF is enabled and disable LSCWP on gf-download and gf-signature URI
	 *
	 * @since 4.1.0 #900899 #827184
	 */
	public static function preload()
	{
		if (class_exists('GFCommon')) {
			if (isset($_GET['gf-download']) || isset($_GET['gf-signature'])) {
				do_action('litespeed_disable_all', 'Stopped for Gravity Form');
			}
		}
	}
}
litespeed-check.cls.php000064400000011156151540133450011073 0ustar00<?php

/**
 * Check if any plugins that could conflict with LiteSpeed Cache are active.
 * @since		4.7
 */

namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class LiteSpeed_Check
{
	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',
	);

	private static $_option = 'thirdparty_litespeed_check';
	private static $_msg_id = 'id="lscwp-incompatible-plugin-notice"';

	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) {
			\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>'
			);
		}
	}

	public static function activated_plugin($plugin, $network_wide)
	{
		self::incompatible_plugin_notice($plugin, $network_wide, 'activated');
	}

	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.
	 */
	public static function incompatible_plugin_notice($plugin, $_network_wide, $action)
	{
		self::update_messages();

		/**
		 * The 'deactivated_plugin' action fires before
		 * `wp_get_active_and_valid_plugins` can see the change, so we'll need to
		 * remove `$plugin` from the list.
		 */
		$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, in case an admin (de)activates
	 * a number of incompatible plugins in succession without dismissing the
	 * notice(s).
	 */
	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;
				}
			}
		}
	}
}
nextgengallery.cls.php000064400000014233151540133450011071 0ustar00<?php
/**
 * The Third Party integration with the NextGen Gallery plugin.
 *
 * @since		1.0.5
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

// Try preload instead
// todo: need test
// add_action('load_nextgen_gallery_modules', 'NextGenGallery::detect') ;

class NextGenGallery
{
	const CACHETAG_ALBUMS = 'NGG_A.';
	const CACHETAG_GALLERIES = 'NGG_G.';
	const CACHETAG_TAGS = 'NGG_T.';

	/**
	 * Detect is triggered at the load_nextgen_gallery_modules action.
	 *
	 * If this action is triggered, assume NextGen Gallery is used.
	 *
	 * @since	1.0.5
	 * @access	public
	 */
	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');
	}

	/**
	 * When an image is added, need to purge all pages that displays its gallery.
	 *
	 * @since	1.0.5
	 * @access	public
	 * @param	string	$image	The image object added.
	 */
	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);
		}
	}

	/**
	 * When an image is updated, need to purge all pages that displays its gallery.
	 *
	 * @since 1.0.5
	 * @access	public
	 */
	public static function update_image()
	{
		if (isset($_REQUEST['gallery_id'])) {
			do_action('litespeed_purge', self::CACHETAG_GALLERIES . sanitize_key($_REQUEST['gallery_id']));
			return;
		}

		if (isset($_POST['task_list'])) {
			$task_list = str_replace('\\', '', $_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;
			}
		}

		if (isset($_POST['id'])) {
			$id = (int) $_POST['id'];
		} elseif (isset($_POST['image'])) {
			$id = (int) $_POST['image'];
		} elseif (isset($_GET['pid'])) {
			$id = (int) $_GET['pid'];
		} else {
			error_log('LiteSpeed_Cache hit ngg_ajax_image_save with no post image id.');
			return;
		}
		$image = \C_Image_Mapper::get_instance()->find($id);
		if ($image) {
			do_action('litespeed_purge', self::CACHETAG_GALLERIES . $image->galleryid);
		}
	}

	/**
	 * When an image is deleted, need to purge all pages that displays its gallery.
	 *
	 * @since 1.0.5
	 * @access	public
	 */
	public static function delete_image()
	{
		if (isset($_GET['gid'])) {
			do_action('litespeed_purge', self::CACHETAG_GALLERIES . sanitize_key($_GET['gid']));
		}
	}

	/**
	 * When an image is moved, need to purge all old galleries and the new gallery.
	 *
	 * @since 1.0.8
	 * @access	public
	 * @param array $images unused
	 * @param array $old_gallery_ids Source gallery ids for the images.
	 * @param integer $new_gallery_id Destination gallery id.
	 */
	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);
	}

	/**
	 * When an image is copied, need to purge the destination gallery.
	 *
	 * @param array $image_pid_map unused
	 * @param array $old_gallery_ids unused
	 * @param integer $new_gallery_id Destination gallery id.
	 */
	public static function copy_image($image_pid_map, $old_gallery_ids, $new_gallery_id)
	{
		do_action('litespeed_purge', self::CACHETAG_GALLERIES . $new_gallery_id);
	}

	/**
	 * When an image is re-generated, need to purge the gallery it belongs to.
	 * Also applies to recovered images.
	 *
	 * @param Image $image The re-generated image.
	 */
	public static function gen_image($image)
	{
		do_action('litespeed_purge', self::CACHETAG_GALLERIES . $image->galleryid);
	}

	/**
	 * When a gallery is updated, need to purge all pages that display the gallery.
	 *
	 * @since 1.0.5
	 * @access  public
	 * @param	integer		$gid	The gallery id of the gallery updated.
	 */
	public static function update_gallery($gid)
	{
		// New version input will be an object with gid value
		if (is_object($gid) && !empty($gid->gid)) {
			$gid = $gid->gid;
		}

		do_action('litespeed_purge', self::CACHETAG_GALLERIES . $gid);
	}

	/**
	 * When an album is updated, need to purge all pages that display the album.
	 *
	 * @since 1.0.5
	 * @access public
	 * @param	integer		$aid	The album id of the album updated.
	 */
	public static function update_album($aid)
	{
		do_action('litespeed_purge', self::CACHETAG_ALBUMS . $aid);
	}

	/**
	 * When rendering a page, if the page has a gallery, album or tag cloud,
	 * it needs to be tagged appropriately.
	 *
	 * @since 1.0.5
	 * @access public
	 * @param object $render_parms Parameters used to render the associated part of the page.
	 * @return mixed Null if passed in null, $render_parms otherwise.
	 */
	public static function add_container($render_parms)
	{
		// Check if null. If it is null, can't continue.
		if (is_null($render_parms)) {
			return null;
		}
		$src = $render_parms[0]->source;
		$container_ids = $render_parms[0]->container_ids;
		// Can switch on first char if we end up with more sources.
		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;
	}
}
perfmatters.cls.php000064400000001223151540133450010370 0ustar00<?php

/**
 * The Third Party integration with the Perfmatters plugin.
 *
 * @since		4.4.5
 */

namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Perfmatters
{
	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);
		}
	}

	public static function disable_litespeed_esi()
	{
		defined('LITESPEED_ESI_OFF') || define('LITESPEED_ESI_OFF', true);
		do_action('litespeed_debug', 'Disable ESI due to Perfmatters script manager');
	}
}
theme-my-login.cls.php000064400000001553151540133450010675 0ustar00<?php
/**
 * The Third Party integration with the Theme My Login plugin.
 *
 * @since		1.0.15
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class Theme_My_Login
{
	/**
	 * Detects if Better Theme My Login is active.
	 *
	 * @since 1.0.15
	 * @access public
	 *
	 */
	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.
	 *
	 * @access public
	 * @since 1.0.15
	 */
	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');
		}
	}
}
user-switching.cls.php000064400000001002151540133450011002 0ustar00<?php
/**
 * The Third Party integration with User Switching.
 *
 * @since		3.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class User_Switching
{
	public static function detect()
	{
		if (!class_exists('user_switching')) {
			return;
		}

		/**
		 * Register switch back URL nonce
		 * @since  3.0 @Robert Staddon
		 */
		if (function_exists('current_user_switched') && ($old_user = current_user_switched())) {
			do_action('litespeed_nonce', 'switch_to_olduser_' . $old_user->ID);
		}
	}
}
wc-pdf-product-vouchers.cls.php000064400000001205151540133450012526 0ustar00<?php
/**
 * The Third Party integration with WooCommerce PDF Product Vouchers.
 *
 * @since		5.1.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WC_PDF_Product_Vouchers
{
	/**
	 * Do not cache generated vouchers
	 *
	 * @since 5.1.0
	 */
	public static function detect()
	{
		if (!class_exists('\WC_PDF_Product_Vouchers_Loader')) {
			return;
		}

		$is_voucher = !empty($_GET['post_type']) && 'wc_voucher' === $_GET['post_type'];
		$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');
		}
	}
}
wcml.cls.php000064400000001644151540133450007005 0ustar00<?php
/**
 * The Third Party integration with WCML.
 *
 * @since		3.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WCML
{
	private static $_currency = '';

	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');
	}

	public static function set_client_currency($currency)
	{
		self::apply_client_currency($currency);

		do_action('litespeed_vary_ajax_force');
	}

	public static function apply_client_currency($currency)
	{
		if ($currency !== wcml_get_woocommerce_currency_option()) {
			self::$_currency = $currency;
			add_filter('litespeed_vary', __CLASS__ . '::apply_vary');
		}

		return $currency;
	}

	public static function apply_vary($list)
	{
		$list['wcml_currency'] = self::$_currency;
		return $list;
	}
}
woo-paypal.cls.php000064400000001122151540133450010122 0ustar00<?php
/**
 * The Third Party integration with WooCommerce PayPal Checkout Gateway
 * @ref https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/
 *
 * @since		3.0
 */
namespace LiteSpeed\Thirdparty;
defined('WPINC') || exit();

class Woo_Paypal
{
	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');
	}
}
woocommerce.cls.php000064400000057571151540133450010374 0ustar00<?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_Cache
 * @subpackage    LiteSpeed_Cache/thirdparty
 * @author        LiteSpeed Technologies <info@litespeedtech.com>
 */

namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\API;
use LiteSpeed\Base;

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';

	private $esi_enabled;

	/**
	 * Detects if WooCommerce is installed.
	 *
	 * @since 1.0.5
	 * @access public
	 */
	public static function detect()
	{
		if (!defined('WOOCOMMERCE_VERSION')) {
			return;
		}

		self::cls()->add_hooks();
	}

	/**
	 * Add hooks to woo actions
	 *
	 * @since  1.6.3
	 * @access public
	 */
	public function add_hooks()
	{
		$this->_option_append();

		$this->esi_enabled = apply_filters('litespeed_esi_status', false);

		add_action('litespeed_control_finalize', array($this, 'set_control'));
		add_action('litespeed_tag_finalize', array($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', array($this, 'purge_product'));
		add_action('woocommerce_variation_set_stock', array($this, 'purge_product')); // #984479 Update variations stock

		add_action('comment_post', array($this, 'add_review'), 10, 3);

		if ($this->esi_enabled) {
			if (function_exists('is_shop') && !is_shop()) {
				add_action('litespeed_tpl_normal', array($this, 'set_block_template'));
				// No need for add-to-cart button
				// add_action( 'litespeed_esi_load-wc-add-to-cart-form', array( $this, 'load_add_to_cart_form_block' ) ) ;

				add_action('litespeed_esi_load-storefront-cart-header', array($this, 'load_cart_header'));
				add_action('litespeed_esi_load-widget', array($this, 'register_post_view'));
			}

			if (function_exists('is_product') && is_product()) {
				add_filter('litespeed_esi_params', array($this, 'add_post_id'), 10, 2);
			}
		}

		if (is_admin()) {
			add_action('litespeed_api_purge_post', array($this, 'backend_purge')); //todo
			add_action('delete_term_relationships', array($this, 'delete_rel'), 10, 2);
			add_action('litespeed_settings_tab', array($this, 'settings_add_tab'));
			add_action('litespeed_settings_content', array($this, 'settings_add_content'));
			add_filter('litespeed_widget_default_options', array($this, 'wc_widget_default'), 10, 2);
		}

		if (apply_filters('litespeed_conf', self::O_CART_VARY)) {
			add_filter('litespeed_vary_cookies', function ($list) {
				$list[] = 'woocommerce_cart_hash';
				return array_unique($list);
			});
		}
	}

	/**
	 * Purge esi private tag
	 *
	 * @since  1.6.3
	 * @access public
	 */
	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
	 */
	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
	 */
	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', array($this, 'set_swap_header_cart'));
		}

		return $template;
	}

	/**
	 * Keep vary on if cart is not empty
	 *
	 * @since  1.7.2
	 * @access public
	 */
	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
	 */
	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, I want to set my own hook in woocommerce_before_template_part to see if it's something I can ESI.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	public function set_block_template()
	{
		add_action('woocommerce_before_template_part', array($this, 'block_template'), 999, 4);
	}

	/**
	 * Hooked to the litespeed_is_not_esi_template action.
	 * If the request is not an esi request, I want to set my own hook
	 * in storefront_header to see if it's something I can ESI.
	 *
	 * Will remove storefront_header_cart in storefront_header.
	 *
	 * @since 1.1.0
	 * @since 1.6.3 Removed static
	 * @access public
	 */
	public function set_swap_header_cart()
	{
		$priority = has_action('storefront_header', 'storefront_header_cart');
		if ($priority !== false) {
			remove_action('storefront_header', 'storefront_header_cart', $priority);
			add_action('storefront_header', array($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 I want to ESI the request, block it and build my esi code block.
	 *
	 * The function parameters will be passed to the esi request.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	public function block_template($template_name, $template_path, $located, $args)
	{
		if (strpos($template_name, 'add-to-cart') === false) {
			if (strpos($template_name, 'related.php') !== false) {
				remove_action('woocommerce_before_template_part', array($this, 'block_template'), 999);
				add_filter('woocommerce_related_products_args', array($this, 'add_related_tags'));
				add_action('woocommerce_after_template_part', array($this, 'end_template'), 999);
			}
			return;
		}
		return;

		// todo: wny not use?

		global $post;
		$params = array(
			self::ESI_PARAM_ARGS => $args,
			self::ESI_PARAM_NAME => $template_name,
			self::ESI_PARAM_POSTID => $post->ID,
			self::ESI_PARAM_PATH => $template_path,
			self::ESI_PARAM_LOCATED => $located,
		);
		add_action('woocommerce_after_add_to_cart_form', array($this, 'end_form'));
		add_action('woocommerce_after_template_part', array($this, 'end_form'), 999);
		echo apply_filters('litespeed_esi_url', 'wc-add-to-cart-form', 'WC_CART_FORM', $params);
		echo 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
	 */
	public function end_form($template_name = '')
	{
		if (!empty($template_name) && strpos($template_name, 'add-to-cart') === false) {
			return;
		}
		echo apply_filters('litespeed_clean_wrapper_end', '');
		remove_action('woocommerce_after_add_to_cart_form', array($this, 'end_form'));
		remove_action('woocommerce_after_template_part', array($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 'add-to-cart', clean the buffer.
	 *
	 * @since 1.1.0
	 * @since 1.6.3 Removed static
	 * @access public
	 * @param type $template_name
	 */
	public function end_template($template_name)
	{
		if (strpos($template_name, 'related.php') !== false) {
			remove_action('woocommerce_after_template_part', array($this, 'end_template'), 999);
			$this->set_block_template();
		}
	}

	/**
	 * Hooked to the storefront_header header.
	 * If I want to ESI the request, block it and build my esi code block.
	 *
	 * @since 1.1.0
	 * @since 1.6.3 Removed static
	 * @access public
	 */
	public function esi_cart_header()
	{
		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
	 */
	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
	 * @global type $post
	 * @global type $wp_query
	 * @param type $params
	 */
	public function load_add_to_cart_form_block($params)
	{
		global $post, $wp_query;
		$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
	 */
	public function register_post_view($params)
	{
		if ($params[API::PARAM_NAME] !== 'WC_Widget_Recently_Viewed') {
			return;
		}
		if (!isset($params[self::ESI_PARAM_POSTID])) {
			return;
		}
		$id = $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;
		}

		global $post;
		$post = $esi_post;
		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
	 */
	public function add_post_id($params, $block_id)
	{
		if ($block_id == 'widget') {
			if ($params[API::PARAM_NAME] == 'WC_Widget_Recently_Viewed') {
				$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
	 */
	public function wc_widget_default($options, $widget)
	{
		if (!is_array($options)) {
			return $options;
		}
		$widget_name = get_class($widget);
		if ($widget_name === 'WC_Widget_Recently_Viewed') {
			$options[API::WIDGET_O_ESIENABLE] = API::VAL_ON2;
			$options[API::WIDGET_O_TTL] = 0;
		} elseif ($widget_name === 'WC_Widget_Recent_Reviews') {
			$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
	 */
	public function set_tag()
	{
		$id = get_the_ID();
		if ($id === false) {
			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);
		$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 ($term === false) {
			return;
		}
		while (isset($term)) {
			do_action('litespeed_tag_add', self::CACHETAG_TERM . $term->term_id);
			if ($term->parent == 0) {
				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 boolean           	True if cacheable, false if not.
	 */
	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(array(wc_get_page_id('cart'), wc_get_page_id('checkout'), wc_get_page_id('myaccount')));
				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;
		}

		$uri = esc_url($_SERVER['REQUEST_URI']);
		$uri_len = strlen($uri);
		if ($uri_len < 5) {
			return;
		}

		if (in_array($uri, array('cart/', 'checkout/', 'my-account/', 'addons/', 'logout/', 'lost-password/', 'product/'))) {
			// why contains `product`?
			do_action('litespeed_control_set_nocache', 'uri in cart/account/user pages');
			return;
		}

		$qs = sanitize_text_field($_SERVER['QUERY_STRING']);
		$qs_len = strlen($qs);
		if (!empty($qs) && $qs_len >= 12 && strpos($qs, 'add-to-cart=') === 0) {
			do_action('litespeed_control_set_nocache', 'qs contains add-to-cart');
			return;
		}
	}

	/**
	 * 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
	 */
	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 ($config === self::O_PQS_CQS) {
				$action();
				if ($debug) {
					do_action('litespeed_debug', $debug);
				}
			} elseif ($config !== self::O_PQS_CS && $product->is_in_stock()) {
				do_action('litespeed_debug', '[3rd] Woo No purge needed [option] ' . $config);
				return false;
			} elseif ($config !== self::O_PS_CN && !$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', array(), $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.
	 */
	public function delete_rel($post_id, $term_ids)
	{
		if (!function_exists('wc_get_product')) {
			return;
		}

		if (empty($term_ids) || wc_get_product($post_id) === false) {
			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
	 */
	public function backend_purge($post_id)
	{
		if (!function_exists('wc_get_product')) {
			return;
		}

		if (!isset($post_id) || wc_get_product($post_id) === false) {
			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', array('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 $unused
	 * @param integer $comment_approved Whether the comment is approved or not.
	 * @param array $commentdata Information about the comment.
	 */
	public function add_review($unused, $comment_approved, $commentdata)
	{
		if (!function_exists('wc_get_product')) {
			return;
		}

		$post_id = $commentdata['comment_post_ID'];
		if ($comment_approved !== 1 || !isset($post_id) || wc_get_product($post_id) === false) {
			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
	 */
	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
	 */
	public function settings_add_tab($setting_page)
	{
		if ($setting_page != 'cache') {
			return;
		}

		require 'woocommerce.tab.tpl.php';
	}

	/**
	 * Hook to show config content
	 *
	 * @since  3.0
	 */
	public function settings_add_content($setting_page)
	{
		if ($setting_page != 'cache') {
			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', array('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 prepload
	 *
	 * @since  2.9.8.4
	 */
	public static function preload()
	{
		/**
		 * Auto puge for WooCommerce Advanced Bulk Edit plugin,
		 * Bulk edit hook need to add to preload as it will die before detect.
		 */
		add_action('wp_ajax_wpmelon_adv_bulk_edit', __CLASS__ . '::bulk_edit_purge', 1);
	}

	/**
	 * Auto puge for WooCommerce Advanced Bulk Edit plugin,
	 *
	 * @since  2.9.8.4
	 */
	public static function bulk_edit_purge()
	{
		if (empty($_POST['type']) || $_POST['type'] != 'saveproducts' || 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 = array();
		foreach ($_POST['data'] as $stock_value) {
			$stock_string_arr = array_merge($stock_string_arr, explode('#^#', $stock_value));
		}

		$lscwp_3rd_woocommerce = new self();

		if (count($stock_string_arr) < 1) {
			return;
		}

		foreach ($stock_string_arr as $edited_stock) {
			$product_id = strtok($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);
		}
	}
}
woocommerce.content.tpl.php000064400000006712151540133450012052 0ustar00<?php

namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit;

use \LiteSpeed\API;
use \LiteSpeed\Doc;
use \LiteSpeed\Admin_Display;
use \LiteSpeed\Lang;
use \LiteSpeed\Base;
?>

<div data-litespeed-layout='woocommerce'>

	<h3 class="litespeed-title-short">
		<?php echo __('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 echo __('NOTICE:', 'litespeed-cache'); ?></h4>
		<p><?php echo __('After verifying that the cache works in general, please test the cart.', 'litespeed-cache'); ?></p>
		<p><?php echo sprintf(__('To test the cart, visit the <a %s>FAQ</a>.', 'litespeed-cache'), 'href="https://docs.litespeedtech.com/lscache/lscwp/installation/#non-cacheable-pages" target="_blank"'); ?></p>
		<p><?php echo __('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 $id = self::O_UPDATE_INTERVAL; ?>
					<?php echo __('Product Update Interval', 'litespeed-cache'); ?>
				</th>
				<td>
					<?php
					$options = array(
						self::O_PQS_CS	=> __('Purge product on changes to the quantity or stock status.', 'litespeed-cache') . ' ' . __('Purge categories only when stock status changes.', 'litespeed-cache'),
						self::O_PS_CS	=> __('Purge product and categories only when the stock status changes.', 'litespeed-cache'),
						self::O_PS_CN	=> __('Purge product only when the stock status changes.', 'litespeed-cache') . ' ' . __('Do not purge categories on changes to the quantity or stock status.', 'litespeed-cache'),
						self::O_PQS_CQS	=> __('Always purge both product and categories on changes to the quantity or stock status.', 'litespeed-cache'),
					);
					$conf = (int) apply_filters('litespeed_conf', $id);
					foreach ($options as $k => $v) :
						$checked = (int) $k === $conf ? ' checked ' : '';
					?>
						<?php do_action('litespeed_setting_enroll', $id); ?>
						<div class='litespeed-radio-row'>
							<input type='radio' autocomplete='off' name='<?php echo $id; ?>' id='conf_<?php echo $id; ?>_<?php echo $k; ?>' value='<?php echo $k; ?>' <?php echo $checked; ?> />
							<label for='conf_<?php echo $id; ?>_<?php echo $k; ?>'><?php echo $v; ?></label>
						</div>
					<?php endforeach; ?>
					<div class="litespeed-desc">
						<?php echo __('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 $id = self::O_CART_VARY; ?>
					<?php echo __('Vary for Mini Cart', 'litespeed-cache'); ?>
				</th>
				<td>
					<?php
					$conf = (int) apply_filters('litespeed_conf', $id);
					$this->cls('Admin_Display')->build_switch($id); ?>
					<div class="litespeed-desc">
						<?php echo __('Generate a separate vary cache copy for the mini cart when the cart is not empty.', 'litespeed-cache'); ?>
						<?php echo __('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>woocommerce.tab.tpl.php000064400000000270151540133450011137 0ustar00<?php defined( 'WPINC' ) || exit ; ?>

<a class='litespeed-tab nav-tab' href='#woocommerce' data-litespeed-tab='woocommerce'><?php echo __( 'WooCommerce', 'litespeed-cache' ) ; ?></a>
wp-polls.cls.php000064400000000740151540133450007614 0ustar00<?php
/**
 * The Third Party integration with the WP-Polls plugin.
 *
 * @since		1.0.7
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

// todo: need test

class Wp_Polls
{
	public static function detect()
	{
		add_filter('wp_polls_display_pollvote', __CLASS__ . '::set_control');
		add_filter('wp_polls_display_pollresult', __CLASS__ . '::set_control');
	}

	public static function set_control()
	{
		do_action('litespeed_control_set_nocache', 'wp polls');
	}
}
wp-postratings.cls.php000064400000001136151540133450011040 0ustar00<?php
/**
 * The Third Party integration with the WP-PostRatings plugin.
 *
 * @since		1.1.1
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WP_PostRatings
{
	/**
	 * Detects if plugin is installed.
	 *
	 * @since 1.1.1
	 * @access public
	 */
	public static function detect()
	{
		if (defined('WP_POSTRATINGS_VERSION')) {
			add_action('rate_post', __CLASS__ . '::flush', 10, 3);
		}
	}

	/**
	 * Purges the cache
	 *
	 * @since 1.1.1
	 * @access public
	 */
	public static function flush($uid, $post_id, $post_ratings_score)
	{
		do_action('litespeed_purge_post', $post_id);
	}
}
wpdiscuz.cls.php000064400000001431151540133450007705 0ustar00<?php
/**
 * The Third Party integration with Wpdiscuz.
 *
 * @since		2.9.5
 * @package		LiteSpeed_Cache
 * @subpackage	LiteSpeed_Cache/thirdparty
 * @author		LiteSpeed Technologies <info@litespeedtech.com>
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\API;

class Wpdiscuz
{
	public static function detect()
	{
		if (!defined('WPDISCUZ_DS')) {
			return;
		}

		self::check_commenter();
		add_action('wpdiscuz_add_comment', __CLASS__ . '::add_comment');
	}

	public static function add_comment()
	{
		API::vary_append_commenter();
	}

	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');
		}
	}
}
wplister.cls.php000064400000001261151540133450007707 0ustar00<?php
/**
 * The Third Party integration with the WPLister plugin.
 *
 * @since        1.1.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WPLister
{
	/**
	 * Detects if WooCommerce and WPLister are installed.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	public static function detect()
	{
		if (defined('WOOCOMMERCE_VERSION') && defined('WPLISTER_VERSION')) {
			// User reported this will sync correctly.
			add_action('wplister_revise_inventory_status', array(WooCommerce::cls(), 'backend_purge'));
			// Added as a safety measure for WPLister Pro only.
			add_action('wplister_inventory_status_changed', array(WooCommerce::cls(), 'backend_purge'));
		}
	}
}
wpml.cls.php000064400000001163151540133450007016 0ustar00<?php
/**
 * The Third Party integration with WPML.
 *
 * @since		2.9.4
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WPML
{
	public static function detect()
	{
		if (!defined('WPML_PLUGIN_BASENAME')) {
			return;
		}

		add_filter('litespeed_internal_domains', __CLASS__ . '::append_domains');
	}

	/**
	 * Take language domains as internal 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;
	}
}
wptouch.cls.php000064400000001300151540133450007521 0ustar00<?php
/**
 * The Third Party integration with the WPTouch Mobile plugin.
 *
 * @since		1.0.7
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

class WpTouch
{
	/**
	 * Detects if WPTouch is installed.
	 *
	 * @since 1.0.7
	 * @access public
	 */
	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
	 * @access public
	 */
	public static function set_control()
	{
		global $wptouch_pro;
		if ($wptouch_pro->is_mobile_device) {
			add_filter('litespeed_is_mobile', '__return_true');
		}
	}
}
yith-wishlist.cls.php000064400000010505151540133450010660 0ustar00<?php
/**
 * The Third Party integration with the YITH WooCommerce Wishlist plugin.
 *
 * @since		1.1.0
 */
namespace LiteSpeed\Thirdparty;

defined('WPINC') || exit();

use LiteSpeed\Tag;
use LiteSpeed\Conf;
use LiteSpeed\Base;

class Yith_Wishlist
{
	const ESI_PARAM_POSTID = 'yith_pid';
	private static $_post_id;

	/**
	 * Detects if YITH WooCommerce Wishlist and WooCommerce are installed.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	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
	 * @access public
	 */
	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
	 * @access public
	 */
	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
	 */
	public static function add_to_wishlist_params($defaults, $atts)
	{
		self::$_post_id = !empty($atts['product_id']) ? $atts['product_id'] : $defaults['product_id'];

		return $defaults;
	}

	/**
	 * Hooked to the yith_wcwl_add_to_wishlisth_button_html filter.
	 *
	 * 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. This function replaces the normal html with the ESI block.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	public static function sub_add_to_wishlist($template)
	{
		$params = array(
			self::ESI_PARAM_POSTID => self::$_post_id,
		);

		$inline_tags = array('', 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 = array(
			'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);
	}

	/**
	 * Hooked to the litespeed_esi_load-yith_wcwl_add action.
	 *
	 * This will load the add to wishlist button html for output.
	 *
	 * @since 1.1.0
	 * @access public
	 */
	public static function load_add_to_wishlist($params)
	{
		// global $post, $wp_query;
		// $post = get_post( $params[ self::ESI_PARAM_POSTID ] );
		// $wp_query->setup_postdata( $post );
		echo \YITH_WCWL_Shortcode::add_to_wishlist(array('product_id' => $params[self::ESI_PARAM_POSTID]));
		do_action('litespeed_control_set_private', 'yith wishlist');
		do_action('litespeed_vary_no');
	}

	/**
	 * Generate ESI inline value
	 *
	 * @since  3.4.2
	 */
	public static function inline_add_to_wishlist($res, $params)
	{
		if (!is_array($res)) {
			$res = array();
		}

		$pid = $params[self::ESI_PARAM_POSTID];

		$res['val'] = \YITH_WCWL_Shortcode::add_to_wishlist(array('product_id' => $pid));

		$res['control'] = 'private,no-vary,max-age=' . Conf::cls()->conf(Base::O_CACHE_TTL_PRIV);

		$inline_tags = array('', 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;
	}
}