PluginProbe ʕ •ᴥ•ʔ
LiteSpeed Cache / 1.9.1.1
LiteSpeed Cache v1.9.1.1
trunk 1.0.15 1.9.1.1 2.9.9.2 3.6.4 4.6 5.7.0.1 6.5.4 7.0.0.1 7.0.1 7.1 7.2 7.3 7.3.0.1 7.4 7.5 7.5.0.1 7.6 7.6.1 7.6.2 7.7 7.8 7.8.0.1 7.8.1
litespeed-cache / thirdparty / lscwp-3rd-aelia-currencyswitcher.cls.php
litespeed-cache / thirdparty Last commit date
lscwp-3rd-aelia-currencyswitcher.cls.php 8 years ago lscwp-3rd-autoptimize.cls.php 8 years ago lscwp-3rd-avada.cls.php 8 years ago lscwp-3rd-bbpress.cls.php 8 years ago lscwp-3rd-betterwp-minify.cls.php 8 years ago lscwp-3rd-contact-form-7.cls.php 8 years ago lscwp-3rd-like-dislike-counter.cls.php 8 years ago lscwp-3rd-login-with-ajax.cls.php 8 years ago lscwp-3rd-nextgengallery.cls.php 8 years ago lscwp-3rd-theme-my-login.cls.php 8 years ago lscwp-3rd-woocommerce.cls.php 8 years ago lscwp-3rd-wp-polls.cls.php 8 years ago lscwp-3rd-wp-postratings.cls.php 8 years ago lscwp-3rd-wpforo.cls.php 8 years ago lscwp-3rd-wplister.cls.php 8 years ago lscwp-3rd-wptouch.cls.php 8 years ago lscwp-3rd-yith-wishlist.cls.php 8 years ago lscwp-registry-3rd.php 8 years ago
lscwp-3rd-aelia-currencyswitcher.cls.php
90 lines
1 <?php
2
3 /**
4 * The Third Party integration with the Aelia CurrencySwitcher plugin.
5 *
6 * @since 1.0.13
7 * @package LiteSpeed_Cache
8 * @subpackage LiteSpeed_Cache/thirdparty
9 * @author LiteSpeed Technologies <info@litespeedtech.com>
10 */
11 if ( ! defined('ABSPATH') ) {
12 die() ;
13 }
14
15 LiteSpeed_Cache_API::register('LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher') ;
16
17 class LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher
18 {
19 private static $_cookies = array(
20 'aelia_cs_selected_currency',
21 'aelia_customer_country',
22 'aelia_customer_state',
23 'aelia_tax_exempt',
24 ) ;
25
26 /**
27 * Detects if WooCommerce is installed.
28 *
29 * @since 1.0.13
30 * @access public
31 * @global $GLOBALS;
32 */
33 public static function detect()
34 {
35 if ( defined('WOOCOMMERCE_VERSION') && isset($GLOBALS['woocommerce-aelia-currencyswitcher']) && is_object($GLOBALS['woocommerce-aelia-currencyswitcher']) ) {
36 LiteSpeed_Cache_API::hook_control('LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher::check_cookies') ;
37 LiteSpeed_Cache_API::hook_vary('LiteSpeed_Cache_ThirdParty_Aelia_CurrencySwitcher::get_vary') ;
38 }
39 }
40
41 /**
42 * If the page is not a woocommerce page, ignore the logic.
43 * Else check cookies. If cookies are set, set the vary headers, else do not cache the page.
44 *
45 * @since 1.0.13
46 * @access public
47 */
48 public static function check_cookies()
49 {
50 if ( LiteSpeed_Cache_API::not_cacheable() ) {
51 return ;
52 }
53
54 // NOTE: is_cart and is_checkout should also be checked, but will be checked by woocommerce anyway.
55 if ( ! is_woocommerce() ) {
56 return ;
57 }
58
59 if ( isset($_COOKIE) && ! empty($_COOKIE) ) {
60 foreach (self::$_cookies as $cookie) {
61 if ( ! empty($_COOKIE[$cookie]) ) {
62 LiteSpeed_Cache_API::vary_add(self::$_cookies) ;
63 return ;
64 }
65 }
66 }
67
68 LiteSpeed_Cache_API::set_nocache() ;
69 }
70
71 /**
72 * Hooked to the litespeed_cache_get_vary filter.
73 *
74 * If Aelia Currency Switcher is enabled, will need to add their cookies
75 * to the vary array.
76 *
77 * @since 1.0.14
78 * @access public
79 * @param array $vary_arr The current list of vary cookies.
80 * @return array The updated list of vary cookies.
81 */
82 public static function get_vary($vary_arr)
83 {
84 if ( ! is_array($vary_arr) ) {
85 return $vary_arr ;
86 }
87 return array_merge($vary_arr, self::$_cookies) ;
88 }
89 }
90