aelia-currencyswitcher.cls.php
1 year ago
amp.cls.php
1 year ago
autoptimize.cls.php
1 year ago
avada.cls.php
1 year ago
bbpress.cls.php
1 year ago
beaver-builder.cls.php
1 year ago
caldera-forms.cls.php
1 year ago
divi-theme-builder.cls.php
1 year ago
elementor.cls.php
1 year ago
entry.inc.php
1 year ago
facetwp.cls.php
1 year ago
gravity-forms.cls.php
1 year ago
litespeed-check.cls.php
1 year ago
nextgengallery.cls.php
1 year ago
perfmatters.cls.php
1 year ago
theme-my-login.cls.php
1 year ago
user-switching.cls.php
1 year ago
wc-pdf-product-vouchers.cls.php
1 year ago
wcml.cls.php
1 year ago
woo-paypal.cls.php
1 year ago
woocommerce.cls.php
1 year ago
woocommerce.content.tpl.php
1 year ago
woocommerce.tab.tpl.php
1 year ago
wp-polls.cls.php
1 year ago
wp-postratings.cls.php
1 year ago
wpdiscuz.cls.php
1 year ago
wplister.cls.php
1 year ago
wpml.cls.php
1 year ago
wptouch.cls.php
1 year ago
yith-wishlist.cls.php
1 year ago
wcml.cls.php
48 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The Third Party integration with WCML. |
| 4 | * |
| 5 | * @since 3.0 |
| 6 | */ |
| 7 | namespace LiteSpeed\Thirdparty; |
| 8 | |
| 9 | defined('WPINC') || exit(); |
| 10 | |
| 11 | class WCML |
| 12 | { |
| 13 | private static $_currency = ''; |
| 14 | |
| 15 | public static function detect() |
| 16 | { |
| 17 | if (!defined('WCML_VERSION')) { |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | add_filter('wcml_client_currency', __CLASS__ . '::apply_client_currency'); |
| 22 | add_action('wcml_set_client_currency', __CLASS__ . '::set_client_currency'); |
| 23 | } |
| 24 | |
| 25 | public static function set_client_currency($currency) |
| 26 | { |
| 27 | self::apply_client_currency($currency); |
| 28 | |
| 29 | do_action('litespeed_vary_ajax_force'); |
| 30 | } |
| 31 | |
| 32 | public static function apply_client_currency($currency) |
| 33 | { |
| 34 | if ($currency !== wcml_get_woocommerce_currency_option()) { |
| 35 | self::$_currency = $currency; |
| 36 | add_filter('litespeed_vary', __CLASS__ . '::apply_vary'); |
| 37 | } |
| 38 | |
| 39 | return $currency; |
| 40 | } |
| 41 | |
| 42 | public static function apply_vary($list) |
| 43 | { |
| 44 | $list['wcml_currency'] = self::$_currency; |
| 45 | return $list; |
| 46 | } |
| 47 | } |
| 48 |